org.glassfish.jersey.internal.inject
Class AbstractBinder

java.lang.Object
  extended by org.glassfish.jersey.internal.inject.AbstractBinder
All Implemented Interfaces:
DynamicConfiguration, Binder
Direct Known Subclasses:
ContextInjectionResolver.Binder, ContextResolverFactory.Binder, ExceptionMapperFactory.Binder, ExceptionWrapperInterceptor.Binder, JaxrsProviders.Binder, MessageBodyFactory.Binder, MessagingBinders.HeaderDelegateProviders, MessagingBinders.MessageBodyProviders, ProviderInstanceBindingBinder, RequestScope.Binder, ServiceFinderBinder

public abstract class AbstractBinder
extends Object
implements Binder, DynamicConfiguration

Skeleton implementation of injection binder with convenience methods for binding definitions.

Author:
Marek Potociar (marek.potociar at oracle.com)

Constructor Summary
AbstractBinder()
           
 
Method Summary
<T> ActiveDescriptor<T>
addActiveDescriptor(ActiveDescriptor<T> activeDescriptor)
          
<T> ActiveDescriptor<T>
addActiveDescriptor(Class<T> rawClass)
          
 void addUnbindFilter(Filter unbindFilter)
          
<T> ServiceBindingBuilder<T>
bind(Class<T> serviceType)
          Start building a new class-based service binding.
<T> ActiveDescriptor<T>
bind(Descriptor descriptor)
          
 void bind(DynamicConfiguration configuration)
           
 FactoryDescriptors bind(FactoryDescriptors factoryDescriptors)
          
<T> ScopedBindingBuilder<T>
bind(T service)
          Start building a new instance-based service binding.
<T> ServiceBindingBuilder<T>
bindAsContract(Class<T> serviceType)
          Start building a new class-based service binding.
<T> ServiceBindingBuilder<T>
bindAsContract(TypeLiteral<T> serviceType)
          Start building a new generic type-based service binding.
<T> ServiceBindingBuilder<T>
bindFactory(Class<? extends Factory<T>> factoryType)
          Start building a new factory class-based service binding.
<T> ServiceBindingBuilder<T>
bindFactory(Class<? extends Factory<T>> factoryType, Class<? extends Annotation> factoryScope)
          Start building a new factory class-based service binding.
<T> ServiceBindingBuilder<T>
bindFactory(Factory<T> factory)
          Start building a new factory instance-based service binding.
 void commit()
          
protected abstract  void configure()
          Implement to provide binding definitions using the exposed binding methods.
 void install(Binder... binders)
          Adds all binding definitions from the binders to the binding configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractBinder

public AbstractBinder()
Method Detail

bind

public <T> ServiceBindingBuilder<T> bind(Class<T> serviceType)
Start building a new class-based service binding. Does NOT bind the service type itself as a contract type.

Type Parameters:
T - service type.
Parameters:
serviceType - service class.
Returns:
initialized binding builder.

bindAsContract

public <T> ServiceBindingBuilder<T> bindAsContract(Class<T> serviceType)
Start building a new class-based service binding. Binds the service type itself as a contract type.

Type Parameters:
T - service type.
Parameters:
serviceType - service class.
Returns:
initialized binding builder.

bindAsContract

public <T> ServiceBindingBuilder<T> bindAsContract(TypeLiteral<T> serviceType)
Start building a new generic type-based service binding. Binds the generic service type itself as a contract type.

Type Parameters:
T - service type.
Parameters:
serviceType - generic service type information.
Returns:
initialized binding builder.

bind

public <T> ScopedBindingBuilder<T> bind(T service)
Start building a new instance-based service binding. The binding is naturally considered to be a singleton-scoped. Does NOT bind the service type itself as a contract type.

Type Parameters:
T - service type.
Parameters:
service - service instance.
Returns:
initialized binding builder.

bindFactory

public <T> ServiceBindingBuilder<T> bindFactory(Class<? extends Factory<T>> factoryType,
                                                Class<? extends Annotation> factoryScope)
Start building a new factory class-based service binding.

Type Parameters:
T - service type.
Parameters:
factoryType - service factory class.
factoryScope - factory scope.
Returns:
initialized binding builder.

bindFactory

public <T> ServiceBindingBuilder<T> bindFactory(Class<? extends Factory<T>> factoryType)
Start building a new factory class-based service binding. The factory itself is bound in a per-lookup scope.

Type Parameters:
T - service type.
Parameters:
factoryType - service factory class.
Returns:
initialized binding builder.

bindFactory

public <T> ServiceBindingBuilder<T> bindFactory(Factory<T> factory)
Start building a new factory instance-based service binding.

Type Parameters:
T - service type.
Parameters:
factory - service instance.
Returns:
initialized binding builder.

bind

public void bind(DynamicConfiguration configuration)
Specified by:
bind in interface Binder

configure

protected abstract void configure()
Implement to provide binding definitions using the exposed binding methods.


bind

public <T> ActiveDescriptor<T> bind(Descriptor descriptor)

This method can be called only in the execution context of the configure() method.

Specified by:
bind in interface DynamicConfiguration

bind

public FactoryDescriptors bind(FactoryDescriptors factoryDescriptors)

This method can be called only in the execution context of the configure() method.

Specified by:
bind in interface DynamicConfiguration

addActiveDescriptor

public <T> ActiveDescriptor<T> addActiveDescriptor(ActiveDescriptor<T> activeDescriptor)
                                        throws IllegalArgumentException

This method can be called only in the execution context of the configure() method.

Specified by:
addActiveDescriptor in interface DynamicConfiguration
Throws:
IllegalArgumentException

addActiveDescriptor

public <T> ActiveDescriptor<T> addActiveDescriptor(Class<T> rawClass)
                                        throws MultiException,
                                               IllegalArgumentException

This method can be called only in the execution context of the configure() method.

Specified by:
addActiveDescriptor in interface DynamicConfiguration
Throws:
MultiException
IllegalArgumentException

addUnbindFilter

public void addUnbindFilter(Filter unbindFilter)
                     throws IllegalArgumentException

This method can be called only in the execution context of the configure() method.

Specified by:
addUnbindFilter in interface DynamicConfiguration
Throws:
IllegalArgumentException

commit

public void commit()
            throws MultiException

This method can be called only in the execution context of the configure() method.

Specified by:
commit in interface DynamicConfiguration
Throws:
MultiException

install

public final void install(Binder... binders)
Adds all binding definitions from the binders to the binding configuration.

Parameters:
binders - binders whose binding definitions should be configured.


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