org.glassfish.hk2.api
Class ServiceLocatorFactory

java.lang.Object
  extended by org.glassfish.hk2.api.ServiceLocatorFactory
Direct Known Subclasses:
ServiceLocatorFactoryImpl

public abstract class ServiceLocatorFactory
extends Object

This factory can be used to create new named ServiceLocators

Author:
jwells

Constructor Summary
ServiceLocatorFactory()
           
 
Method Summary
abstract  ServiceLocator create(String name)
          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  void destroy(ServiceLocator locator)
          Removes the given ServiceLocator
abstract  void destroy(String name)
          Removes the ServiceLocator with this name
abstract  ServiceLocator find(String name)
          Finds the ServiceLocator with this name
static ServiceLocatorFactory getInstance()
          This will return a factory where the ServiceLocatorGenerator is discovered from the META-INF/services of the process
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceLocatorFactory

public ServiceLocatorFactory()
Method Detail

getInstance

public static ServiceLocatorFactory 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

public abstract ServiceLocator create(String name)
Creates (or finds) a ServiceLocator.

If there is already a ServiceLocator with the given name then this method will return null.

Parameters:
name - The name of this service locator. May not be null
Returns:
The created or found named ServiceLocator

create

public abstract ServiceLocator create(String name,
                                      ServiceLocator parent)
Creates or finds a ServiceLocator.

If there is already a ServiceLocator with the given name then this method will that ServiceLocator. The parent argument will be ignored in that case

Parameters:
name - The name of this service locator. May not be null
parent - 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.
parent - 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
generator - 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

find

public abstract ServiceLocator find(String name)
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

public abstract void destroy(String name)
Removes the ServiceLocator with this name

All services associated with this ServiceLocator will be shutdown

Parameters:
name - The name of the ServiceLocator to destroy

destroy

public abstract void destroy(ServiceLocator locator)
Removes the given ServiceLocator

All services associated with this ServiceLocator will be shutdown

Parameters:
name - The ServiceLocator to destroy. If null this will do nothing. If the ServiceLocator given was already destroyed this will do nothing


Copyright © 2013 Oracle Corporation. All Rights Reserved.