Top Description Inners Fields Constructors Methods
org.glassfish.hk2.api

public abstract Class ServiceLocatorFactory

extends Object
Class Inheritance
Known Direct Subclasses
org.glassfish.hk2.internal.ServiceLocatorFactoryImpl
Imports
org.glassfish.hk2.extension.ServiceLocatorGenerator, org.glassfish.hk2.internal.ServiceLocatorFactoryImpl

This factory can be used to create new named ServiceLocators
Author
jwells

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
ServiceLocatorFactory.CreatePolicy

Tells the create method what to do if an existing ServiceLocator with the given name exists

Field Summary

Modifier and TypeField and Description
private static ServiceLocatorFactory

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract void
addListener(ServiceLocatorListener
The non-null listener to add to the system
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.

public abstract ServiceLocator

Returns:

The created or found named ServiceLocator
create
(String
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
name
)

Creates (or finds) a ServiceLocator.

public abstract ServiceLocator

Returns:

The created or found named ServiceLocator
create
(String
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
name
,
ServiceLocator
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
parent
)

Creates or finds a ServiceLocator.

public abstract ServiceLocator

Returns:

The created or found named ServiceLocator
create
(String
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
name
,
ServiceLocator
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
parent
,
ServiceLocatorGenerator
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
generator
)

Creates or finds a ServiceLocator.

public abstract ServiceLocator

Returns:

The created or found named ServiceLocator
create
(String
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
name
,
ServiceLocator
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
parent
,
ServiceLocatorGenerator
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
generator
,
ServiceLocatorFactory.CreatePolicy
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
policy
)

Creates a ServiceLocator.

public abstract void
destroy(String
The name of the ServiceLocator to destroy
name
)

Removes the ServiceLocator with this name

All services associated with this ServiceLocator will be shutdown

public abstract void
destroy(ServiceLocator
The ServiceLocator to destroy. If null this will do nothing. If the ServiceLocator given was already destroyed this will do nothing
locator
)

Removes the given ServiceLocator

All services associated with this ServiceLocator will be shutdown

public abstract ServiceLocator

Returns:

The ServiceLocator with the given name, or null if there is no ServiceLocator with that name
find
(String
May not be null, is the name of the ServiceLocator to find
name
)

Finds the ServiceLocator with this name

public static ServiceLocatorFactory

Returns:

The factory to use to create service locators
getInstance
()

This will return a factory where the ServiceLocatorGenerator is discovered from the META-INF/services of the process

public abstract void
removeListener(ServiceLocatorListener
The non-null listener to remove from the system
listener
)

Removes a service listener from the set of listeners that are notified when named listeners are added or removed from the system

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
private static ServiceLocatorFactory INSTANCE

Constructor Detail

ServiceLocatorFactoryback to summary
public ServiceLocatorFactory()

Method Detail

addListenerback to summary
public abstract 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. If this listener is already registered this method does nothing

Parameters
listener:ServiceLocatorListener

The non-null listener to add to the system

createback to summary
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 that locator.

Parameters
name:String

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:ServiceLocator

The created or found named ServiceLocator

createback to summary
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 return that ServiceLocator. The parent argument will be ignored in that case

Parameters
name:String

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

parent:ServiceLocator

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:ServiceLocator

The created or found named ServiceLocator

createback to summary
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:String

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

parent:ServiceLocator

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:ServiceLocatorGenerator

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:ServiceLocator

The created or found named ServiceLocator

createback to summary
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:String

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

parent:ServiceLocator

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:ServiceLocatorGenerator

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

policy:ServiceLocatorFactory.CreatePolicy

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:ServiceLocator

The created or found named ServiceLocator

destroyback to summary
public abstract void destroy(String name)

Removes the ServiceLocator with this name

All services associated with this ServiceLocator will be shutdown

Parameters
name:String

The name of the ServiceLocator to destroy

destroyback to summary
public abstract void destroy(ServiceLocator locator)

Removes the given ServiceLocator

All services associated with this ServiceLocator will be shutdown

Parameters
locator:ServiceLocator

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

findback to summary
public abstract ServiceLocator find(String name)

Finds the ServiceLocator with this name

Parameters
name:String

May not be null, is the name of the ServiceLocator to find

Returns:ServiceLocator

The ServiceLocator with the given name, or null if there is no ServiceLocator with that name

getInstanceback to summary
public static ServiceLocatorFactory getInstance()

This will return a factory where the ServiceLocatorGenerator is discovered from the META-INF/services of the process

Returns:ServiceLocatorFactory

The factory to use to create service locators

removeListenerback to summary
public abstract 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

Parameters
listener:ServiceLocatorListener

The non-null listener to remove from the system

org.glassfish.hk2.api back to summary

public final Enum ServiceLocatorFactory.CreatePolicy

extends Enum<ServiceLocatorFactory.CreatePolicy>
Class Inheritance

Tells the create method what to do if an existing ServiceLocator with the given name exists
Author
jwells

Field Summary

Modifier and TypeField and Description
public static final ServiceLocatorFactory.CreatePolicy
DESTROY

Destroy the existing ServiceLocator

public static final ServiceLocatorFactory.CreatePolicy
ERROR

Throw an IllegalStateException

public static final ServiceLocatorFactory.CreatePolicy
RETURN

Return the existing ServiceLocator

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ServiceLocatorFactory.CreatePolicy
public static ServiceLocatorFactory.CreatePolicy[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

DESTROYback to summary
public static final ServiceLocatorFactory.CreatePolicy DESTROY

Destroy the existing ServiceLocator

ERRORback to summary
public static final ServiceLocatorFactory.CreatePolicy ERROR

Throw an IllegalStateException

RETURNback to summary
public static final ServiceLocatorFactory.CreatePolicy RETURN

Return the existing ServiceLocator

Constructor Detail

CreatePolicyback to summary
private CreatePolicy()

Method Detail

valueOfback to summary
public static ServiceLocatorFactory.CreatePolicy valueOf(String name)
valuesback to summary
public static ServiceLocatorFactory.CreatePolicy[] values()