Design of a Complex Open MBean: CarOpenMBean 

 

Open Data Structures Defined by CarOpenMBean

The data structure of this Open MBean models a concrete example that could be used in a car sales application. The goal is to describe a set of objects that represent a list of cars available for sale. Basically, we manage a table of car objects setOfCars. A car is described by its maker (that is, its manufacturer), its model, its color and its price. A color is defined as one of 3 basic colors (red, green, blue). nbSoldCars is an attribute indicating the total number of cars sold, nbAvailableCars is an attribute indicating the total number of cars available in the store, mostUsedColorsData is a CompositeData attribute which represents colors most often sold and finally isStoreOpen is an attribute indicating if the store is open or not.
 

These open MBean data structures can be represented as follows :

OpenType and Attribute definition
CompositeType compositeTypeColor
    SimpleType.INTEGER red 
    SimpleType.INTEGER green 
    SimpleType.INTEGER blue 
CompositeData mostUsedColors =new CompositeDataSupport(compositeTypeColor,...) 
TabularType tabularTypeListOfColors 
    ... 
    CompositeType compositeTypeColor 
    index -> 3 column 
CompositeType compositeTypeCar
    String maker  
    String model  
    TabularData colors  
    Float price  
TabularType tabularTypeListOfCars
    ... 
    CompositeType compositeTypeCar 
    index-> column 1 and 2 

TabularData  setOfCars=new TabularDataSupport(listOfCarsType)

SimpleType.LONG nbSoldCars (default value 0) 
SimpleType.SHORT nbAvailableCars
SimpleType.BOOLEAN isStoreOpen
Definition of Operations
 

TabularData carCheaperThan(Float price)
This operation returns a TabularData of type tabularTypeListOfCars representing cars of setOfCars whose price is less than <price>. 


Boolean addCar(compositeTypeCar car)
This operation adds the CompositeData car to the setOfCars TabularData object and increments by one the nbAvailableCars attribute. 


Boolean addCar(String maker, String model, Integer red, Integer green, Integer blue, Float price)
This operation adds the car represented by its maker, model, color and price to the setOfCars TabularData object and increments by one the nbAvailableCars attribute. 


Boolean removeCar(String maker, String model)
This operation removes the car represented by its maker and model from the setOfCars TabularData object and decrements by one the nbAvailableCars attribute. 


TabularData returnAvailableColors(String maker, String model)
This operation returns a TabularData representing the list of available colors for the car represented by its maker and model. 


Void addNewColor(String maker, String model,Integer red, Integer green, Integer blue)
This operation adds a color to the TabularData representing the list of available colors for the car represented by maker and model. 


TabularData returnByMaker(String maker)
This operation returns a TabularData representing all cars whose maker is <maker>. 


CompositeData getCarByMakerAndModel(String Maker, String Model)
This operation returns a CompositeData representing the car whose maker is <maker> and model <model>.


 

Copyright © 2004 Sun Microsystems, Inc.,  901 San Antonio Road, Palo Alto, CA 94303 USA. 
All rights reserved.