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

public Class ServiceLocatorFactoryImpl

extends ServiceLocatorFactory
Class Inheritance
Imports
java.security.AccessController, .PrivilegedAction, java.util.Collections, .HashMap, .HashSet, .Iterator, .ServiceConfigurationError, java.util.concurrent.locks.ReentrantLock, org.glassfish.hk2.api.ServiceLocator, .ServiceLocatorFactory, .ServiceLocatorListener, org.glassfish.hk2.extension.ServiceLocatorGenerator, org.glassfish.hk2.osgiresourcelocator.ServiceLoader, org.glassfish.hk2.utilities.reflection.Logger

The implementation of the ServiceLocatorFactory that looks in the OSGi service registry or the META-INF/services for the implementation to use. Failing those things, it uses the standard default locator generator, which is found in auto-depends, which is the 99.9% case
Author
jwells

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final boolean
private static final String
private static final String
private final HashSet<ServiceLocatorListener>
private final ReentrantLock
private static int
private final HashMap<String, ServiceLocator>
private static final ReentrantLock

Constructor Summary

AccessConstructor and Description
public
ServiceLocatorFactoryImpl()

This will create a new set of name to locator mappings

Method Summary

Modifier and TypeMethod and Description
public void
addListener(ServiceLocatorListener listener)

Implements abstract org.glassfish.hk2.api.ServiceLocatorFactory.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.

private void
public ServiceLocator
create(String name)

Implements abstract org.glassfish.hk2.api.ServiceLocatorFactory.create.

Creates (or finds) a ServiceLocator.

public ServiceLocator
create(String name, ServiceLocator parent)

Implements abstract org.glassfish.hk2.api.ServiceLocatorFactory.create.

Creates or finds a ServiceLocator.

public ServiceLocator
create(String name, ServiceLocator parent, ServiceLocatorGenerator generator)

Implements abstract org.glassfish.hk2.api.ServiceLocatorFactory.create.

Creates or finds a ServiceLocator.

public ServiceLocator
public void
destroy(String name)

Implements abstract org.glassfish.hk2.api.ServiceLocatorFactory.destroy.

Removes the ServiceLocator with this name

All services associated with this ServiceLocator will be shutdown

private void
destroy(String name, ServiceLocator locator)

public void
destroy(ServiceLocator locator)

Implements abstract org.glassfish.hk2.api.ServiceLocatorFactory.destroy.

Removes the given ServiceLocator

All services associated with this ServiceLocator will be shutdown

public ServiceLocator
find(String name)

Implements abstract org.glassfish.hk2.api.ServiceLocatorFactory.find.

Finds the ServiceLocator with this name

private static String
private static ServiceLocatorGenerator
private static ServiceLocatorGenerator
private static Iterable<? extends ServiceLocatorGenerator>
private ServiceLocator
public void
removeListener(ServiceLocatorListener listener)

Implements abstract org.glassfish.hk2.api.ServiceLocatorFactory.removeListener.

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

Inherited from org.glassfish.hk2.api.ServiceLocatorFactory:
getInstance

Field Detail

DEBUG_SERVICE_LOCATOR_LIFECYCLEback to summary
private static final boolean DEBUG_SERVICE_LOCATOR_LIFECYCLE
DEBUG_SERVICE_LOCATOR_PROPERTYback to summary
private static final String DEBUG_SERVICE_LOCATOR_PROPERTY
GENERATED_NAME_PREFIXback to summary
private static final String GENERATED_NAME_PREFIX
listenersback to summary
private final HashSet<ServiceLocatorListener> listeners
lockback to summary
private final ReentrantLock lock
name_countback to summary
private static int name_count
serviceLocatorsback to summary
private final HashMap<String, ServiceLocator> serviceLocators
sLockback to summary
private static final ReentrantLock sLock

Constructor Detail

ServiceLocatorFactoryImplback to summary
public ServiceLocatorFactoryImpl()

This will create a new set of name to locator mappings

Method Detail

addListenerback to summary
public void addListener(ServiceLocatorListener listener)

Implements abstract org.glassfish.hk2.api.ServiceLocatorFactory.addListener.

Doc from org.glassfish.hk2.api.ServiceLocatorFactory.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

Annotations
@Override
callListenerAddedback to summary
private void callListenerAdded(ServiceLocator added)
createback to summary
public ServiceLocator create(String name)

Implements abstract org.glassfish.hk2.api.ServiceLocatorFactory.create.

Doc from org.glassfish.hk2.api.ServiceLocatorFactory.create.

Creates (or finds) a ServiceLocator.

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

Annotations
@Override
createback to summary
public ServiceLocator create(String name, ServiceLocator parent)

Implements abstract org.glassfish.hk2.api.ServiceLocatorFactory.create.

Doc from org.glassfish.hk2.api.ServiceLocatorFactory.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

Annotations
@Override
createback to summary
public ServiceLocator create(String name, ServiceLocator parent, ServiceLocatorGenerator generator)

Implements abstract org.glassfish.hk2.api.ServiceLocatorFactory.create.

Doc from org.glassfish.hk2.api.ServiceLocatorFactory.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. If a null name is given then a new ServiceLocator with a generated name will be returned.

Annotations
@Override
createback to summary
public ServiceLocator create(String name, ServiceLocator parent, ServiceLocatorGenerator generator, ServiceLocatorFactory.CreatePolicy policy)

Implements abstract org.glassfish.hk2.api.ServiceLocatorFactory.create.

Doc from org.glassfish.hk2.api.ServiceLocatorFactory.create.

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
Annotations
@Override
destroyback to summary
public void destroy(String name)

Implements abstract org.glassfish.hk2.api.ServiceLocatorFactory.destroy.

Doc from org.glassfish.hk2.api.ServiceLocatorFactory.destroy.

Removes the ServiceLocator with this name

All services associated with this ServiceLocator will be shutdown

Annotations
@Override
destroyback to summary
private void destroy(String name, ServiceLocator locator)
destroyback to summary
public void destroy(ServiceLocator locator)

Implements abstract org.glassfish.hk2.api.ServiceLocatorFactory.destroy.

Doc from org.glassfish.hk2.api.ServiceLocatorFactory.destroy.

Removes the given ServiceLocator

All services associated with this ServiceLocator will be shutdown

findback to summary
public ServiceLocator find(String name)

Implements abstract org.glassfish.hk2.api.ServiceLocatorFactory.find.

Doc from org.glassfish.hk2.api.ServiceLocatorFactory.find.

Finds the ServiceLocator with this name

Annotations
@Override
getGeneratedNameback to summary
private static String getGeneratedName()
getGeneratorback to summary
private static ServiceLocatorGenerator getGenerator()
getGeneratorSecureback to summary
private static ServiceLocatorGenerator getGeneratorSecure()
getOSGiSafeGeneratorsback to summary
private static Iterable<? extends ServiceLocatorGenerator> getOSGiSafeGenerators()
internalCreateback to summary
private ServiceLocator internalCreate(String name, ServiceLocator parent, ServiceLocatorGenerator generator)
removeListenerback to summary
public void removeListener(ServiceLocatorListener listener)

Implements abstract org.glassfish.hk2.api.ServiceLocatorFactory.removeListener.

Doc from org.glassfish.hk2.api.ServiceLocatorFactory.removeListener.

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

Annotations
@Override
org.glassfish.hk2.internal back to summary

private final Class ServiceLocatorFactoryImpl.DefaultGeneratorInitializer

extends Object
Class Inheritance
  • java.lang.Object
  • org.glassfish.hk2.internal.ServiceLocatorFactoryImpl.DefaultGeneratorInitializer

Field Summary

Modifier and TypeField and Description
private static final ServiceLocatorGenerator

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultGeneratorback to summary
private static final ServiceLocatorGenerator defaultGenerator

Constructor Detail

DefaultGeneratorInitializerback to summary
private DefaultGeneratorInitializer()