Class ServiceLocatorFactory
- Direct Known Subclasses:
ServiceLocatorFactoryImpl
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Tells the create method what to do if an existing ServiceLocator with the given name exists -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
addListener
(ServiceLocatorListener listener) Adds a service listener to the unordered set of listeners that will be notified when named listeners are added or removed from the system.abstract ServiceLocator
Creates (or finds) a ServiceLocator.abstract ServiceLocator
create
(String name, ServiceLocator parent) Creates or finds a ServiceLocator.abstract ServiceLocator
create
(String name, ServiceLocator parent, ServiceLocatorGenerator generator) Creates or finds a ServiceLocator.abstract ServiceLocator
create
(String name, ServiceLocator parent, ServiceLocatorGenerator generator, ServiceLocatorFactory.CreatePolicy policy) Creates a ServiceLocator.abstract void
Removes the ServiceLocator with this nameabstract void
destroy
(ServiceLocator locator) Removes the given ServiceLocatorabstract ServiceLocator
Finds the ServiceLocator with this namestatic ServiceLocatorFactory
This will return a factory where the ServiceLocatorGenerator is discovered from the META-INF/services of the processabstract void
removeListener
(ServiceLocatorListener listener) Removes a service listener from the set of listeners that are notified when named listeners are added or removed from the system
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
ServiceLocatorFactory
public ServiceLocatorFactory()
-
-
Method Details
-
getInstance
This will return a factory where the ServiceLocatorGenerator is discovered from the META-INF/services of the process- Returns:
- The factory to use to create service locators
-
create
Creates (or finds) a ServiceLocator.If there is already a ServiceLocator with the given name then this method will return that locator.
- Parameters:
name
- The name of this service locator. Passing a null name will result in a newly created service locator with a generated name and that will not be tracked by the system- Returns:
- The created or found named ServiceLocator
-
create
Creates or finds a ServiceLocator.If there is already a ServiceLocator with the given name then this method will return that ServiceLocator. The parent argument will be ignored in that case
- Parameters:
name
- The name of this service locator. Passing a null name will result in a newly created service locator with a generated name and that will not be tracked by the systemparent
- The parent of this ServiceLocator. Services can be found in the parent (and all grand-parents). May be null if the returned ServiceLocator should not be parented- Returns:
- The created or found named ServiceLocator
-
create
public abstract ServiceLocator create(String name, ServiceLocator parent, ServiceLocatorGenerator generator) Creates or finds a ServiceLocator.If there is already a ServiceLocator with the given name then this method will return that ServiceLocator. The parent argument will be ignored in that case. If a null name is given then a new ServiceLocator with a generated name will be returned.
- Parameters:
name
- The name of this service locator. Passing a null name will result in a newly created service locator with a generated name and that will not be tracked by the systemparent
- The parent of this ServiceLocator. Services can be found in the parent (and all grand-parents). May be null if the returned ServiceLocator should not be parentedgenerator
- An implementation of the generator interface that can be used to provide an implementation of ServiceLocator. If null then the generator used will be discovered from the OSGi service registry or from META-INF/services- Returns:
- The created or found named ServiceLocator
-
create
public abstract ServiceLocator create(String name, ServiceLocator parent, ServiceLocatorGenerator generator, ServiceLocatorFactory.CreatePolicy policy) Creates a ServiceLocator.If there is already a ServiceLocator with the given name then this method will honor the given CreatePolicy. return that ServiceLocator. The policies are
- RETURN: Return the existing locator
- DESTOY: Destroy the existing locator
- ERROR: Throw an IllegalStateException exception
- Parameters:
name
- The name of this service locator. Passing a null name will result in a newly created service locator with a generated name and that will not be tracked by the systemparent
- The parent of this ServiceLocator. Services can be found in the parent (and all grand-parents). May be null if the returned ServiceLocator should not be parentedgenerator
- An implementation of the generator interface that can be used to provide an implementation of ServiceLocator. If null then the generator used will be discovered from the OSGi service registry or from META-INF/servicespolicy
- The policy that should be used if there is an existing locator with the non-null name. If null the policy of RETURN will be used- Returns:
- The created or found named ServiceLocator
-
find
Finds the ServiceLocator with this name- Parameters:
name
- May not be null, is the name of the ServiceLocator to find- Returns:
- The ServiceLocator with the given name, or null if there is no ServiceLocator with that name
-
destroy
Removes the ServiceLocator with this nameAll services associated with this ServiceLocator will be shutdown
- Parameters:
name
- The name of the ServiceLocator to destroy
-
destroy
Removes the given ServiceLocatorAll services associated with this ServiceLocator will be shutdown
- Parameters:
locator
- The ServiceLocator to destroy. If null this will do nothing. If the ServiceLocator given was already destroyed this will do nothing
-
addListener
Adds a service listener to the unordered set of listeners that will be notified when named listeners are added or removed from the system. If this listener is already registered this method does nothing- Parameters:
listener
- The non-null listener to add to the system
-
removeListener
Removes a service listener from the set of listeners that are notified when named listeners are added or removed from the system- Parameters:
listener
- The non-null listener to remove from the system
-