Package org.eclipse.emfforms.bazaar
Interface Bazaar<T>
-
- Type Parameters:
T- the type of product create by this Bazaar
- All Known Implementing Classes:
BazaarImpl,ThreadSafeBazaar
public interface Bazaar<T>A Bazaar is a flexible registry for factories to create specific objects of type T, called "product". To create a product, an arbitrary number ofVendoris queried.Vendorrequest certain parameters to create a product. This is queried from theBazaarContext. If aAllPermissionparameters requested by aVendorare present in theBazaarContext, aVendorwill do aBid. TheVendorwith the highestBidwill finally create a product. If two or moreVendordo the same bid, the registeredBazaar.PriorityOverlapCallBackwill be notified, an arbitraryVendorwith the sameBidwill create the product in this case. To transform parameter in theBazaarContextinto parametersVendors expect, you can registerBazaarContextFunctions at theBazaar.- Author:
- jonas
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classBazaar.Builder<T>A fluent builder ofBazaars.static interfaceBazaar.PriorityOverlapCallBack<T>If two or moreVendors make the same bid, the registeredBazaar.PriorityOverlapCallBackwill be notified, an arbitraryVendorwith the sameBidwill create the product in this case.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddContextFunction(java.lang.String key, BazaarContextFunction contextFunction)Adds aBazaarContextFunctionto thisBazaarto exchange existing parameters to a parameter requested by aVendor.voidaddVendor(Vendor<? extends T> vendor)Adds aVendorto the bazaar.TcreateProduct(BazaarContext context)Creates a product of type T, provided by theVendorwith the highestBidand which is statisfied by the parameters in theBazaarContext.java.util.List<T>createProducts(BazaarContext context)Creates a list of products of type T, provided byVendors which are statisfied by the parameters in theBazaarContext, ordered by theirBid.voidremoveVendor(Vendor<? extends T> vendor)Removes aVendorfrom the bazaar.voidsetPriorityOverlapCallBack(Bazaar.PriorityOverlapCallBack<? super T> priorityOverlapCallBack)
-
-
-
Method Detail
-
addVendor
void addVendor(Vendor<? extends T> vendor)
Adds aVendorto the bazaar. Will be queried if a product is requested, the best fitting will create the product. Has no effect if thevendoris already present in this bazaar.- Parameters:
vendor- theVendor
-
removeVendor
void removeVendor(Vendor<? extends T> vendor)
Removes aVendorfrom the bazaar. Has no effect if thevendoris not present in this bazaar.- Parameters:
vendor- theVendorto remove
-
addContextFunction
void addContextFunction(java.lang.String key, BazaarContextFunction contextFunction)Adds aBazaarContextFunctionto thisBazaarto exchange existing parameters to a parameter requested by aVendor.- Parameters:
key- the key of a requested parameter, which can be exchanged from other available parameters in theBazaarContextby thisBazaarContextFunctioncontextFunction- theBazaarContextFunctionbeing able to exchange to the requested parameter
-
createProduct
T createProduct(BazaarContext context)
Creates a product of type T, provided by theVendorwith the highestBidand which is statisfied by the parameters in theBazaarContext. In case of tied bids, theBazaar.PriorityOverlapCallBackif one is set will be notified of which vendor is chosen to break the tie. Note that during the bidding process, ties may have to be broken in this way that are later defeated by a higher bid.- Parameters:
context- theBazaarContext, which is used to provide requested parameters forVendor- Returns:
- the product provided by the best
Vendor - See Also:
setPriorityOverlapCallBack(PriorityOverlapCallBack)
-
createProducts
java.util.List<T> createProducts(BazaarContext context)
Creates a list of products of type T, provided byVendors which are statisfied by the parameters in theBazaarContext, ordered by theirBid. Ties are not broken as all bids are successful and are used only for ordering.- Parameters:
context- theBazaarContext, which is used to provide requested parameters forVendor- Returns:
- a list of products ordered by the highest
Bid
-
setPriorityOverlapCallBack
void setPriorityOverlapCallBack(Bazaar.PriorityOverlapCallBack<? super T> priorityOverlapCallBack)
- Parameters:
priorityOverlapCallBack- a PriorityOverlapCallBack
-
-