Class BazaarImpl<T>

  • Type Parameters:
    T - the type of product produced by this Bazaar
    All Implemented Interfaces:
    Bazaar<T>
    Direct Known Subclasses:
    ThreadSafeBazaar

    public class BazaarImpl<T>
    extends java.lang.Object
    implements Bazaar<T>
    Implementation of a Bazaar using the IEclipseContext for dependency injection.
    Author:
    jonas
    • Constructor Detail

      • BazaarImpl

        public BazaarImpl()
    • Method Detail

      • addVendor

        public void addVendor​(Vendor<? extends T> vendor)
        Description copied from interface: Bazaar
        Adds a Vendor to the bazaar. Will be queried if a product is requested, the best fitting will create the product. Has no effect if the vendor is already present in this bazaar.
        Specified by:
        addVendor in interface Bazaar<T>
        Parameters:
        vendor - the Vendor
      • removeVendor

        public void removeVendor​(Vendor<? extends T> vendor)
        Description copied from interface: Bazaar
        Removes a Vendor from the bazaar. Has no effect if the vendor is not present in this bazaar.
        Specified by:
        removeVendor in interface Bazaar<T>
        Parameters:
        vendor - the Vendor to remove
      • createProduct

        public T createProduct​(Vendor<? extends T> vendor,
                               org.eclipse.e4.core.contexts.IEclipseContext context)
        Returns the product which is provided with the highest priority by any Vendor.
        Parameters:
        vendor - The Vendor creating the product
        context - The IEclipseContext to inject parameters for creating a product (see Create)
        Returns:
        T the created product
      • addContextFunctions

        public org.eclipse.e4.core.contexts.IEclipseContext addContextFunctions​(org.eclipse.e4.core.contexts.IEclipseContext context)
        Transforms all BazaarContextFunctions to IContextFunctions and attaches those to an IEclipseContext.
        Parameters:
        context - the IEclipseContext to attache IContextFunctions to
        Returns:
        the IEclipseContext with attached IContextFunction
      • createEclipseContext

        public org.eclipse.e4.core.contexts.IEclipseContext createEclipseContext​(BazaarContext bazaarContext)
        Creates an IEclipseContext from a BazaarContext. If the bazaar context contains an Eclipse context, then it is used and will have all other values set into it from the bazaar context.
        Parameters:
        bazaarContext - the BazaarContext to get key / values from
        Returns:
        a IEclipseContext containign all key / values provided by the BazaarContext
      • getBestVendor

        public Vendor<? extends T> getBestVendor​(org.eclipse.e4.core.contexts.IEclipseContext context)
        Parameters:
        context - the Eclipse injection context
        Returns:
        obtains the best available vendor for the give context
      • checkPreConditions

        public boolean checkPreConditions​(Vendor<? extends T> vendor,
                                          org.eclipse.e4.core.contexts.IEclipseContext context)
        Checks the Preconditions for a given vendor.
        Parameters:
        vendor - The Vendor to check the Precondition for.
        context - The IEclipseContext to provide the Precondition
        Returns:
        whether the Preconditions are fulfilled