javax.inject.manager
Interface Manager


public interface Manager

The contract between the application and the manager. Also the contract between the manager and Bean, Context and Observer objects. The application should not normally need to call this interface.

Author:
Gavin King, Pete Muir

Method Summary
 Manager addBean(Bean<?> bean)
          Allows a new bean to be registered.
 Manager addContext(Context context)
          Associate a custom Context with a scope.
 Manager addDecorator(Decorator decorator)
          Allows a new decorator to be registered.
 Manager addInterceptor(Interceptor interceptor)
          Allows a new interceptor to be registered.
<T> Manager
addObserver(Observer<T> observer, java.lang.Class<T> eventType, java.lang.annotation.Annotation... bindings)
          Register an observer with the container
<T> Manager
addObserver(Observer<T> observer, TypeLiteral<T> eventType, java.lang.annotation.Annotation... bindings)
          Register an observer with the container
 Manager createActivity()
          Create a new child activity.
 void fireEvent(java.lang.Object event, java.lang.annotation.Annotation... bindings)
          Fire an event
 Context getContext(java.lang.Class<? extends java.lang.annotation.Annotation> scopeType)
          Obtain an active context instance for the given scope type.
<T> T
getInstance(Bean<T> bean)
          Obtains an instance of a bean
 java.lang.Object getInstanceByName(java.lang.String name)
          Obtains an instance of a bean by considering the bean name and deployment precedence.
<T> T
getInstanceByType(java.lang.Class<T> type, java.lang.annotation.Annotation... bindings)
          Obtains an instance of a bean by considering bean type, bindings, and deployment precedence.
<T> T
getInstanceByType(TypeLiteral<T> type, java.lang.annotation.Annotation... bindings)
          Obtains an instance of a bean by considering bean type, bindings, and deployment precedence.
<T> T
getInstanceToInject(InjectionPoint injectionPoint)
          Obtains an instance of bean for a given injection point.
<T> T
getInstanceToInject(InjectionPoint injectionPoint, CreationalContext<?> creationalContext)
          Obtains an instance of bean for a given injection point.
 Manager parse(java.io.InputStream xmlStream)
          Allows additional XML based to be provided.
<T> Manager
removeObserver(Observer<T> observer, java.lang.Class<T> eventType, java.lang.annotation.Annotation... bindings)
          Remove an observer registration
<T> Manager
removeObserver(Observer<T> observer, TypeLiteral<T> eventType, java.lang.annotation.Annotation... bindings)
          Remove an observer registration
 java.util.Set<Bean<?>> resolveByName(java.lang.String name)
          Allows beans to be matched by considering the bean name and deployment precedence.
<T> java.util.Set<Bean<T>>
resolveByType(java.lang.Class<T> type, java.lang.annotation.Annotation... bindings)
          Allows beans to be matched to injection point by considering bean type, bindings, and deployment precedence.
<T> java.util.Set<Bean<T>>
resolveByType(TypeLiteral<T> type, java.lang.annotation.Annotation... bindings)
          Allows beans to be matched to injection point by considering bean type, bindings, and deployment precedence.
 java.util.List<Decorator> resolveDecorators(java.util.Set<java.lang.reflect.Type> types, java.lang.annotation.Annotation... bindings)
          Obtains an ordered list of enabled decorators for a set of bean types and a set of bindings
 java.util.List<Interceptor> resolveInterceptors(InterceptionType type, java.lang.annotation.Annotation... interceptorBindings)
          Obtains an ordered list of enabled interceptors for a set interceptor bindings
<T> java.util.Set<Observer<T>>
resolveObservers(T event, java.lang.annotation.Annotation... bindings)
          Obtains observers for an event by considering event type and bindings.
 Manager setCurrent(java.lang.Class<? extends java.lang.annotation.Annotation> scopeType)
          Associate an activity with the current context for a normal scope
 

Method Detail

resolveByType

<T> java.util.Set<Bean<T>> resolveByType(java.lang.Class<T> type,
                                         java.lang.annotation.Annotation... bindings)
Allows beans to be matched to injection point by considering bean type, bindings, and deployment precedence. Typesafe resolution usually occurs at container deployment time.

Type Parameters:
T - the type of the beans to be resolved
Parameters:
type - the type of the beans to be resolved
bindings - the bindings used to restrict the matched beans
Returns:
the matched beans
Throws:
java.lang.IllegalArgumentException - if a parameterized type with a type parameter or a wildcard is passed
java.lang.IllegalArgumentException - if an annotation which is not a binding type is passed
DuplicateBindingTypeException - if two instances of the same binding type are passed

resolveByType

<T> java.util.Set<Bean<T>> resolveByType(TypeLiteral<T> type,
                                         java.lang.annotation.Annotation... bindings)
Allows beans to be matched to injection point by considering bean type, bindings, and deployment precedence. Typesafe resolution usually occurs at container deployment time.

Type Parameters:
T - the type of the beans to be resolved
Parameters:
type - the type of the beans to be resolved
bindings - the bindings used to restrict the matched beans
Returns:
the matched beans
Throws:
java.lang.IllegalArgumentException - if a parameterized type with a type parameter or a wildcard is passed
java.lang.IllegalArgumentException - if an annotation which is not a binding type is passed
DuplicateBindingTypeException - if two instances of the same binding type are passed

getInstanceByType

<T> T getInstanceByType(java.lang.Class<T> type,
                        java.lang.annotation.Annotation... bindings)
Obtains an instance of a bean by considering bean type, bindings, and deployment precedence.

Type Parameters:
T - the type of the bean to obtain
Parameters:
type - the type of the bean to obtain
bindings - the bindings used to restrict the matched beans
Returns:
an instance of the bean
Throws:
java.lang.IllegalArgumentException - if a parameterized type with a type parameter or a wildcard is passed
java.lang.IllegalArgumentException - if an annotation which is not a binding type is passed
DuplicateBindingTypeException - if two instances of the same binding type are passed
UnsatisfiedDependencyException - if no bean can be resolved for the given type and bindings
AmbiguousDependencyException - if more than one bean is resolved for the given type and bindings

getInstanceByType

<T> T getInstanceByType(TypeLiteral<T> type,
                        java.lang.annotation.Annotation... bindings)
Obtains an instance of a bean by considering bean type, bindings, and deployment precedence.

Type Parameters:
T - the type of the bean to obtain
Parameters:
type - the type of the bean to obtain
bindings - the bindings used to restrict the matched beans
Returns:
an instance of the bean
Throws:
java.lang.IllegalArgumentException - if a parameterized type with a type parameter or a wildcard is passed
java.lang.IllegalArgumentException - if an annotation which is not a binding type is passed
DuplicateBindingTypeException - if two instances of the same binding type are passed
UnsatisfiedDependencyException - if no bean can be resolved for the given type and bindings
AmbiguousDependencyException - if more than one bean is resolved for the given type and bindings

resolveByName

java.util.Set<Bean<?>> resolveByName(java.lang.String name)
Allows beans to be matched by considering the bean name and deployment precedence. Used in an environment that doesn't support typing such EL.

Parameters:
name - the name used to restrict the beans matched
Returns:
the matched beans

getInstanceByName

java.lang.Object getInstanceByName(java.lang.String name)
Obtains an instance of a bean by considering the bean name and deployment precedence. Used in an environment that doesn't support typing such EL.

Parameters:
name - the name used to restrict the beans matched
Returns:
an instance of the bean or null if no beans matched
Throws:
AmbiguousDependencyException - if more than one bean matches

getInstance

<T> T getInstance(Bean<T> bean)
Obtains an instance of a bean

Type Parameters:
T - the type of the bean
Parameters:
bean - the bean to obtain an instance of
Returns:
an instance of the bean

getInstanceToInject

<T> T getInstanceToInject(InjectionPoint injectionPoint,
                          CreationalContext<?> creationalContext)
Obtains an instance of bean for a given injection point. This method should not be called by an application.

Type Parameters:
T - the type of the bean
Parameters:
injectionPoint - the injection point the instance is needed for
creationalContext - the context in which the injection is occurring
Returns:
an instance of the bean
Throws:
UnsatisfiedDependencyException - if no bean can be resolved for the given type and bindings
AmbiguousDependencyException - if more than one bean is resolved for the given type and bindings

getInstanceToInject

<T> T getInstanceToInject(InjectionPoint injectionPoint)
Obtains an instance of bean for a given injection point. This method should not be called by an application.

Type Parameters:
T - the type of the bean
Parameters:
injectionPoint - the injection point the instance is needed for
Returns:
an instance of the bean
Throws:
UnsatisfiedDependencyException - if no bean can be resolved for the given type and bindings
AmbiguousDependencyException - if more than one bean is resolved for the given type and bindings

fireEvent

void fireEvent(java.lang.Object event,
               java.lang.annotation.Annotation... bindings)
Fire an event

Parameters:
event - the event object
bindings - the event bindings used to restrict the observers matched
Throws:
java.lang.IllegalArgumentException - if a parameterized type with a type parameter or a wildcard is passed

getContext

Context getContext(java.lang.Class<? extends java.lang.annotation.Annotation> scopeType)
Obtain an active context instance for the given scope type.

Parameters:
scopeType - the scope to get the context instance for
Returns:
the context instance
Throws:
ContextNotActiveException - if no active contexts exist for the given scope type
java.lang.IllegalArgumentException - if more than one active context exists for the given scope type

addContext

Manager addContext(Context context)
Associate a custom Context with a scope. This method may be called at any time in the applications lifecycle.

Parameters:
context - the context to register
Returns:
the manager the context was registered with

addBean

Manager addBean(Bean<?> bean)
Allows a new bean to be registered. This method may be called at any time in the applications lifecycle.

Parameters:
bean - the bean to register
Returns:
the manager the bean was registered with

addInterceptor

Manager addInterceptor(Interceptor interceptor)
Allows a new interceptor to be registered. This method may be called at any time in the applications lifecycle.

Parameters:
interceptor - the interceptor to register
Returns:
the manager the interceptor was registered with

addDecorator

Manager addDecorator(Decorator decorator)
Allows a new decorator to be registered. This method may be called at any time in the applications lifecycle.

Parameters:
decorator - the decorator to register
Returns:
the manager the decorator was registered with

parse

Manager parse(java.io.InputStream xmlStream)
Allows additional XML based to be provided. This method may be called at any time in the applications lifecycle.

Parameters:
xmlStream - the XML metadata
Returns:
the manager the XML metadata was registered with

createActivity

Manager createActivity()
Create a new child activity. A child activity inherits all beans, interceptors, decorators, observers, and contexts defined by its direct and indirect parent activities. This method should not be called by the application.

Returns:
the child activity

setCurrent

Manager setCurrent(java.lang.Class<? extends java.lang.annotation.Annotation> scopeType)
Associate an activity with the current context for a normal scope

Parameters:
scopeType - the scope to associate the activity with
Returns:
the activity
Throws:
ContextNotActiveException - if the given scope is inactive
java.lang.IllegalArgumentException - if the given scope is not a normal scope

addObserver

<T> Manager addObserver(Observer<T> observer,
                        java.lang.Class<T> eventType,
                        java.lang.annotation.Annotation... bindings)
Register an observer with the container

Type Parameters:
T - the type of the observer
Parameters:
observer - the observer to register
eventType - the event type the observer observes
bindings - event bindings to further restrict the events observed
Returns:
the manager the observer was registered with
Throws:
java.lang.IllegalArgumentException - if a parameterized type with a type parameter or a wildcard is passed
java.lang.IllegalArgumentException - if an annotation which is not a binding type is passed
DuplicateBindingTypeException - if two instances of the same binding type are passed

addObserver

<T> Manager addObserver(Observer<T> observer,
                        TypeLiteral<T> eventType,
                        java.lang.annotation.Annotation... bindings)
Register an observer with the container

Type Parameters:
T - the type of the observer
Parameters:
observer - the observer to register
eventType - the event type the observer observes
bindings - event bindings to further restrict the events observed
Returns:
the manager the observer was registered with
Throws:
java.lang.IllegalArgumentException - if a parameterized type with a type parameter or a wildcard is passed
java.lang.IllegalArgumentException - if an annotation which is not a event binding type is passed
DuplicateBindingTypeException - if two instances of the same binding type are passed

removeObserver

<T> Manager removeObserver(Observer<T> observer,
                           java.lang.Class<T> eventType,
                           java.lang.annotation.Annotation... bindings)
Remove an observer registration

Type Parameters:
T - the type of the observer
Parameters:
observer - the observer to register
eventType - the event type the observer obseres
bindings - event bindings to further restrict the events observed
Returns:
the manager the observer was registered with
Throws:
java.lang.IllegalArgumentException - if a parameterized type with a type parameter or a wildcard is passed
java.lang.IllegalArgumentException - if an annotation which is not a event binding type is passed
DuplicateBindingTypeException - if two instances of the same binding type are passed

removeObserver

<T> Manager removeObserver(Observer<T> observer,
                           TypeLiteral<T> eventType,
                           java.lang.annotation.Annotation... bindings)
Remove an observer registration

Type Parameters:
T - the type of the observer
Parameters:
observer - the observer to register
eventType - the event type the observer obseres
bindings - event bindings to further restrict the events observed
Returns:
the manager the observer was registered with
Throws:
java.lang.IllegalArgumentException - if a parameterized type with a type parameter or a wildcard is passed
java.lang.IllegalArgumentException - if an annotation which is not a event binding type is passed
DuplicateBindingTypeException - if two instances of the same binding type are passed

resolveObservers

<T> java.util.Set<Observer<T>> resolveObservers(T event,
                                                java.lang.annotation.Annotation... bindings)
Obtains observers for an event by considering event type and bindings.

Type Parameters:
T - the type of the event to obtain
Parameters:
event - the event object
bindings - the bindings used to restrict the matched observers
Returns:
the resolved observers
Throws:
java.lang.IllegalArgumentException - if a parameterized type with a type parameter or a wildcard is passed
java.lang.IllegalArgumentException - if an annotation which is not a event binding type is passed
DuplicateBindingTypeException - if two instances of the same binding type are passed

resolveInterceptors

java.util.List<Interceptor> resolveInterceptors(InterceptionType type,
                                                java.lang.annotation.Annotation... interceptorBindings)
Obtains an ordered list of enabled interceptors for a set interceptor bindings

Parameters:
type - the type of the interception
bindings - the bindings used to restrict the matched interceptors
Returns:
the resolved interceptors
Throws:
java.lang.IllegalArgumentException - if no interceptor binding type is passed
java.lang.IllegalArgumentException - if an annotation which is not a interceptor binding type is passed
DuplicateBindingTypeException - if two instances of the same binding type are passed

resolveDecorators

java.util.List<Decorator> resolveDecorators(java.util.Set<java.lang.reflect.Type> types,
                                            java.lang.annotation.Annotation... bindings)
Obtains an ordered list of enabled decorators for a set of bean types and a set of bindings

Parameters:
types - the set of bean types of the decorated bean
bindings - the bindings declared by the decorated bean
Returns:
the resolved decorators
Throws:
java.lang.IllegalArgumentException - if the set of bean types is empty
java.lang.IllegalArgumentException - if an annotation which is not a binding type is passed
DuplicateBindingTypeException - if two instances of the same binding type are passed


Copyright © 2008-2009. All Rights Reserved.