org.glassfish.jersey.internal
Class ProviderBinder

java.lang.Object
  extended by org.glassfish.jersey.internal.ProviderBinder

public class ProviderBinder
extends java.lang.Object

Class used for registration of the custom providers into HK2 services.

Custom providers are classes that implements specific JAX-RS or Jersey SPI interfaces (e.g. MessageBodyReader and are supplied by the user. These providers will be bound into the HK2 services annotated by a @Custom qualifier annotation.

Use the @Custom qualifier annotation to retrieve these providers from HK2 services. For example:

  Collection<Provider<MessageBodyReader>> hk2Providers =
          services.forContract(MessageBodyReader.class)
                  .annotatedWith(Custom.class)
                  .all();
 

You may also use a one of the provider accessor utility method defined in Providers class.

Author:
Miroslav Fuksa (miroslav.fuksa at oracle.com), Marek Potociar (marek.potociar at oracle.com)

Nested Class Summary
static class ProviderBinder.ProviderBinderModule
          Module which registers ProviderBinder into the the HK2 services.
 
Constructor Summary
ProviderBinder()
           
 
Method Summary
 void bindClasses(java.lang.Class<?>... classes)
          Register/bind custom provider classes.
 void bindClasses(java.lang.Iterable<java.lang.Class<?>> classes)
          Register/bind custom provider classes.
 void bindClasses(java.lang.Iterable<java.lang.Class<?>> classes, boolean bindResources)
          Register/bind custom provider classes that may also be resources.
 void bindInstances(java.util.Set<java.lang.Object> instances)
          Register/bind custom provider instances.
<T> void
bindInstances(T... instances)
          Register/bind custom provider instances.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProviderBinder

public ProviderBinder()
Method Detail

bindInstances

public <T> void bindInstances(T... instances)
Register/bind custom provider instances. Registered providers will be handled always as Singletons.

Parameters:
instances - custom provider instances.

bindInstances

public void bindInstances(java.util.Set<java.lang.Object> instances)
Register/bind custom provider instances. Registered providers will be handled always as Singletons.

Parameters:
instances - custom provider instances.

bindClasses

public void bindClasses(java.lang.Class<?>... classes)
Register/bind custom provider classes. Registered providers will be handled always as Singletons unless annotated by PerLookup.

Parameters:
classes - custom provider classes.

bindClasses

public void bindClasses(java.lang.Iterable<java.lang.Class<?>> classes)
Register/bind custom provider classes. Registered providers will be handled always as Singletons unless annotated by PerLookup.

Parameters:
classes - custom provider classes.

bindClasses

public void bindClasses(java.lang.Iterable<java.lang.Class<?>> classes,
                        boolean bindResources)
Register/bind custom provider classes that may also be resources. Registered providers/resources will be handled always as Singletons unless annotated by PerLookup.

If bindAsResources is set to true, the providers will also be bound as resources.

Parameters:
classes - custom provider classes.
bindResources - if true, the provider classes will also be bound as resources.


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.