org.glassfish.hk2
Interface Services

All Superinterfaces:
Locator

@Contract
public interface Services
extends Locator

Services is the registry for HK2 services. In earlier versions this was referred to as the Habitat.

Services can be dynamically added to this instance or looked up. Services can also be implicitly added to HK2 by annotating the class with the @Service annotation.

Services are organized in a parent-child structure. Whenever services are being located, a parent search first algorithm is used.


Method Summary
 DynamicBinderFactory bindDynamically()
          Allow dynamic additions to this service registry.
 java.util.Collection<Binding<?>> getBindings()
          Retrieve the collection of all existing bindings in this as well as in parent service registries.
 java.util.Collection<Binding<?>> getBindings(Descriptor descriptor)
          Retrieve the collection of existing bindings in this as well as in parent service registries that matches the Descriptor.
 java.util.Collection<Binding<?>> getDeclaredBindings()
          Retrieve the collection of all existing bindings in this, and only this, service registry.
 java.util.Collection<Binding<?>> getDeclaredBindings(Descriptor descriptor)
          Retrieve the collection of existing bindings in this, and only this, service registry that matches the Descriptor.
 Services getDefault()
          Retrieves the default Services registry.
 Services getServices(java.lang.String moduleName)
          Retrieves the service registry given a module name.
 
Methods inherited from interface org.glassfish.hk2.Locator
byType, byType, forContract, forContract, forContract
 

Method Detail

getDefault

Services getDefault()
Retrieves the default Services registry. This can be thought of as the root.

Returns:
the default, root service registry

getServices

Services getServices(java.lang.String moduleName)
Retrieves the service registry given a module name.

Parameters:
moduleName - the module name, or null for the default services registry
Returns:
the service registry, or null if the service registry does not exist

bindDynamically

DynamicBinderFactory bindDynamically()
Allow dynamic additions to this service registry.

Returns:
a DynamicBinderFactory instance to add services after this services has been initialized.

getDeclaredBindings

java.util.Collection<Binding<?>> getDeclaredBindings()
Retrieve the collection of all existing bindings in this, and only this, service registry.

Returns:
a non-null collection of service bindings

getDeclaredBindings

java.util.Collection<Binding<?>> getDeclaredBindings(Descriptor descriptor)
Retrieve the collection of existing bindings in this, and only this, service registry that matches the Descriptor.

A Descriptor matches if it's attributes are equal, or specified as null. A Descriptor with all null attributes will therefore match all services in this services registry.

Parameters:
descriptor - the descriptor used for matching, or null for all
Returns:
a non-null collection of service bindings matching the argument

getBindings

java.util.Collection<Binding<?>> getBindings()
Retrieve the collection of all existing bindings in this as well as in parent service registries.

Returns:
a non-null collection of service bindings

getBindings

java.util.Collection<Binding<?>> getBindings(Descriptor descriptor)
Retrieve the collection of existing bindings in this as well as in parent service registries that matches the Descriptor.

A Descriptor matches if it's attributes are equal, or specified as null. A Descriptor with all null attributes will therefore match all services in this services registry.

Parameters:
descriptor - the descriptor used for matching, or null for all
Returns:
a non-null collection of service bindings matching the argument


Copyright © 2011 Oracle Corporation. All Rights Reserved.