public final class JerseyBinding
extends java.lang.Object
JerseyInstaller
.Modifier and Type | Method and Description |
---|---|
static void |
bindComponent(org.glassfish.hk2.utilities.binding.AbstractBinder binder,
com.google.inject.Injector injector,
java.lang.Class<?> type)
Binds component into HK context.
|
static <T> void |
bindFactory(org.glassfish.hk2.utilities.binding.AbstractBinder binder,
com.google.inject.Injector injector,
java.lang.Class<?> type)
Binds hk
Factory . |
static <T> com.google.inject.binder.ScopedBindingBuilder |
bindJerseyComponent(com.google.inject.Binder binder,
javax.inject.Provider<com.google.inject.Injector> provider,
java.lang.Class<T> type)
Used to bind jersey beans in guice context (lazily).
|
static void |
bindSpecificComponent(org.glassfish.hk2.utilities.binding.AbstractBinder binder,
com.google.inject.Injector injector,
java.lang.Class<?> type,
java.lang.Class<?> specificType)
Binds jersey specific component (component implements jersey interface or extends class).
|
static boolean |
isHK2Managed(java.lang.Class<?> type) |
public static boolean isHK2Managed(java.lang.Class<?> type)
type
- type to checkHK2Managed
, false otherwiseHK2Managed
public static void bindComponent(org.glassfish.hk2.utilities.binding.AbstractBinder binder, com.google.inject.Injector injector, java.lang.Class<?> type)
HK2Managed
, then registers type,
otherwise register guice "bridge" factory around component.binder
- hk binderinjector
- guice injectortype
- component typeGuiceComponentFactory
public static <T> void bindFactory(org.glassfish.hk2.utilities.binding.AbstractBinder binder, com.google.inject.Injector injector, java.lang.Class<?> type)
Factory
. If bean is HK2Managed
then registered directly as
factory. Otherwise register factory through special "lazy bridge" to delay guice factory bean instantiation.
Also registers factory directly (through wrapper to be able to inject factory by its type).T
- actual type (used to workaround type checks)binder
- hk binderinjector
- guice injectortype
- factory to bindLazyGuiceFactory
,
GuiceComponentFactory
public static void bindSpecificComponent(org.glassfish.hk2.utilities.binding.AbstractBinder binder, com.google.inject.Injector injector, java.lang.Class<?> type, java.lang.Class<?> specificType)
If type is HK2Managed
, binds directly.
Otherwise, use guice "bridge" factory to lazily bind type.
Shortcut methods provided for most common cases.
binder
- hk binderinjector
- guice injectortype
- type which implements specific jersey interface or extends classspecificType
- specific jersey type (interface or abstract class)public static <T> com.google.inject.binder.ScopedBindingBuilder bindJerseyComponent(com.google.inject.Binder binder, javax.inject.Provider<com.google.inject.Injector> provider, java.lang.Class<T> type)
T
- typebinder
- guice binderprovider
- provider for guice injectortype
- jersey type to registerInjectorProvider