Skip navigation links
TrueCommons 2.5.0
net.java.truecommons.services

Class ServiceLocator

    • Constructor Detail

      • ServiceLocator

        public ServiceLocator(Class<?> client)
        Constructs a new locator which uses the class loader of the given client class before using the current thread context's class loader unless the latter is identical to the former.
        Parameters:
        client - the class which identifies the calling client.
      • ServiceLocator

        public ServiceLocator(ClassLoader loader)
        Constructs a new locator which uses the given class loader before using the current thread context's class loader unless the latter is identical to the former.
        Parameters:
        loader - the class loader to use before the current thread context's class loader unless the the latter is identical to the former.
        Since:
        TrueCommons 1.0.13
    • Method Detail

      • container

        public <P> Container<P> container(Class<? extends LocatableProvider<P>> provider)
                                   throws ServiceConfigurationError
        Creates a new container with a single product.
        Type Parameters:
        P - the type of the product to contain.
        Parameters:
        provider - the class of the locatable provider for the product.
        Returns:
        A new container with a single product.
        Throws:
        ServiceConfigurationError - if loading or instantiating a located class fails for some reason.
      • container

        public <P> Container<P> container(Class<? extends LocatableProvider<P>> provider,
                                          @Nullable
                                          Class<? extends LocatableDecorator<P>> decorator)
                                   throws ServiceConfigurationError
        Creates a new container with a single product.
        Type Parameters:
        P - the type of the product to contain.
        Parameters:
        provider - the class of the locatable provider for the product.
        decorator - the class of the locatable decoractors for the product.
        Returns:
        A new container with a single product.
        Throws:
        ServiceConfigurationError - if loading or instantiating a located class fails for some reason.
      • factory

        public <P> Factory<P> factory(Class<? extends LocatableFactory<P>> factory)
                               throws ServiceConfigurationError
        Creates a new factory for products.
        Type Parameters:
        P - the type of the products to create.
        Parameters:
        factory - the class of the locatable factory for the products.
        Returns:
        A new factory of products.
        Throws:
        ServiceConfigurationError - if loading or instantiating a located class fails for some reason.
      • factory

        public <P> Factory<P> factory(Class<? extends LocatableFactory<P>> factory,
                                      @Nullable
                                      Class<? extends LocatableFunction<P>> functions)
                               throws ServiceConfigurationError
        Creates a new factory for products.
        Type Parameters:
        P - the type of the products to create.
        Parameters:
        factory - the class of the locatable factory for the products.
        functions - the class of the locatable functions for the products.
        Returns:
        A new factory of products.
        Throws:
        ServiceConfigurationError - if loading or instantiating a located class fails for some reason.

Copyright © 2012–2018 Schlichtherle IT Services. All rights reserved.