public class Injections extends Object
| Constructor and Description |
|---|
Injections() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addBinding(org.glassfish.hk2.utilities.binding.BindingBuilder<?> builder,
org.glassfish.hk2.api.DynamicConfiguration configuration)
Add a binding represented by the binding builder to the HK2 dynamic configuration.
|
static void |
addBinding(org.glassfish.hk2.utilities.binding.BindingBuilder<?> builder,
org.glassfish.hk2.api.DynamicConfiguration configuration,
org.glassfish.hk2.api.HK2Loader defaultLoader)
Add a binding represented by the binding builder to the HK2 dynamic configuration.
|
static org.glassfish.hk2.api.ServiceLocator |
createLocator(org.glassfish.hk2.utilities.Binder... binders)
Create an unnamed
ServiceLocator. |
static org.glassfish.hk2.api.ServiceLocator |
createLocator(org.glassfish.hk2.api.ServiceLocator parent,
org.glassfish.hk2.utilities.Binder... binders)
Create an unnamed, parented
ServiceLocator. |
static org.glassfish.hk2.api.ServiceLocator |
createLocator(String name,
org.glassfish.hk2.utilities.Binder... binders)
Create a
ServiceLocator. |
static org.glassfish.hk2.api.ServiceLocator |
createLocator(String name,
org.glassfish.hk2.api.ServiceLocator parent,
org.glassfish.hk2.utilities.Binder... binders)
Create a
ServiceLocator. |
static org.glassfish.hk2.api.DynamicConfiguration |
getConfiguration(org.glassfish.hk2.api.ServiceLocator locator)
Get service locator
dynamic configuration. |
static <T> T |
getOrCreate(org.glassfish.hk2.api.ServiceLocator serviceLocator,
Class<T> clazz)
Get the class by contract or create and inject a new instance.
|
static <T> org.glassfish.hk2.utilities.binding.ServiceBindingBuilder<T> |
newBinder(Class<T> serviceType)
Get a new class-based service binding builder.
|
static <T> org.glassfish.hk2.utilities.binding.ScopedBindingBuilder<T> |
newBinder(T service)
Get a new instance-based service binding builder.
|
static <T> org.glassfish.hk2.utilities.binding.ServiceBindingBuilder<T> |
newFactoryBinder(Class<? extends org.glassfish.hk2.api.Factory<T>> factoryType)
Get a new factory class-based service binding builder.
|
static <T> org.glassfish.hk2.utilities.binding.ServiceBindingBuilder<T> |
newFactoryBinder(Class<? extends org.glassfish.hk2.api.Factory<T>> factoryType,
Class<? extends Annotation> factoryScope)
Get a new factory class-based service binding builder.
|
static <T> org.glassfish.hk2.utilities.binding.ServiceBindingBuilder<T> |
newFactoryBinder(org.glassfish.hk2.api.Factory<T> factory)
Get a new factory instance-based service binding builder.
|
static void |
shutdownLocator(org.glassfish.hk2.api.ServiceLocator locator)
Shutdown
ServiceLocator - either via service locator factory (if possible) or directly by
calling shutdown method. |
public static org.glassfish.hk2.api.DynamicConfiguration getConfiguration(org.glassfish.hk2.api.ServiceLocator locator)
dynamic configuration.locator - HK2 service locator.public static org.glassfish.hk2.api.ServiceLocator createLocator(String name, org.glassfish.hk2.api.ServiceLocator parent, org.glassfish.hk2.utilities.Binder... binders)
ServiceLocator. In case the name is not specified, the locator
will be unnamed.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.binders - custom the HK2 binders.public static org.glassfish.hk2.api.ServiceLocator createLocator(String name, org.glassfish.hk2.utilities.Binder... binders)
ServiceLocator. In case the name is not specified, the locator
will be unnamed.name - The name of this service locator. Passing a null
name will result in a newly created service locator with a
generated name.binders - custom the HK2 binders.public static org.glassfish.hk2.api.ServiceLocator createLocator(org.glassfish.hk2.api.ServiceLocator parent,
org.glassfish.hk2.utilities.Binder... binders)
ServiceLocator. In case the parent service locator
is not specified, the locator will not be parented.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.binders - custom the HK2 binders.public static org.glassfish.hk2.api.ServiceLocator createLocator(org.glassfish.hk2.utilities.Binder... binders)
ServiceLocator.binders - custom the HK2 binders.public static <T> T getOrCreate(org.glassfish.hk2.api.ServiceLocator serviceLocator,
Class<T> clazz)
T - instance type.serviceLocator - HK2 service locator.clazz - class of the instance to be provider.public static void addBinding(org.glassfish.hk2.utilities.binding.BindingBuilder<?> builder,
org.glassfish.hk2.api.DynamicConfiguration configuration)
builder - binding builder.configuration - HK2 dynamic configuration.public static void addBinding(org.glassfish.hk2.utilities.binding.BindingBuilder<?> builder,
org.glassfish.hk2.api.DynamicConfiguration configuration,
org.glassfish.hk2.api.HK2Loader defaultLoader)
builder - binding builder.configuration - HK2 dynamic configuration.defaultLoader - default HK2 service loader that should be used to load the service class
in case a custom loader has not been set.public static <T> org.glassfish.hk2.utilities.binding.ServiceBindingBuilder<T> newFactoryBinder(Class<? extends org.glassfish.hk2.api.Factory<T>> factoryType, Class<? extends Annotation> factoryScope)
T - service type.factoryType - service factory class.factoryScope - factory scope.public static <T> org.glassfish.hk2.utilities.binding.ServiceBindingBuilder<T> newFactoryBinder(Class<? extends org.glassfish.hk2.api.Factory<T>> factoryType)
per-lookup scope.T - service type.factoryType - service factory class.public static <T> org.glassfish.hk2.utilities.binding.ServiceBindingBuilder<T> newFactoryBinder(org.glassfish.hk2.api.Factory<T> factory)
T - service type.factory - service instance.public static <T> org.glassfish.hk2.utilities.binding.ServiceBindingBuilder<T> newBinder(Class<T> serviceType)
T - service type.serviceType - service class.public static <T> org.glassfish.hk2.utilities.binding.ScopedBindingBuilder<T> newBinder(T service)
singleton-scoped.
Does NOT bind the service type itself as a contract type.T - service type.service - service instance.public static void shutdownLocator(org.glassfish.hk2.api.ServiceLocator locator)
ServiceLocator - either via service locator factory (if possible) or directly by
calling shutdown method.locator - locator to be shut down.Copyright © 2007-2014, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.