org.jboss.webbeans
Class ManagerImpl

java.lang.Object
  extended by org.jboss.webbeans.ManagerImpl
All Implemented Interfaces:
java.io.Serializable, Manager

@Standard
public class ManagerImpl
extends java.lang.Object
implements Manager, java.io.Serializable

Implementation of the Web Beans Manager. Essentially a singleton for registering Beans, Contexts, Observers, Interceptors etc. as well as providing resolution

Author:
Pete Muir
See Also:
Serialized Form

Field Summary
static java.lang.String JNDI_KEY
           
 
Constructor Summary
ManagerImpl()
          Constructor
 
Method Summary
 Manager addBean(Bean<?> bean)
          Registers a bean with the manager
 Manager addContext(Context context)
          Registers a context with the manager
 Manager addDecorator(Decorator decorator)
          Registers a decorator with the manager
 Manager addInterceptor(Interceptor interceptor)
          Registers an interceptor with the manager
<T> Manager
addObserver(Observer<T> observer, java.lang.Class<T> eventType, java.lang.annotation.Annotation... bindings)
          Registers an observer for a given event type and binding types
<T> Manager
addObserver(Observer<T> observer, TypeLiteral<T> eventType, java.lang.annotation.Annotation... bindings)
          Registers an observer for a given event type literal and binding types
protected  void checkEnabledDeploymentTypes()
          Set up the enabled deployment types, if none are specified by the user, the default @Production and @Standard are used.
 Manager createChildManager()
           
 void fireEvent(java.lang.Object event, java.lang.annotation.Annotation... bindings)
          Fires an event object with given event object for given bindings
 java.util.Map<java.lang.Class<?>,Bean<?>> getBeanMap()
           
 java.util.List<Bean<?>> getBeans()
          The beans registered with the Web Bean manager.
 Context getBuiltInContext(java.lang.Class<? extends java.lang.annotation.Annotation> scopeType)
          Direct access to built in contexts.
 Context getContext(java.lang.Class<? extends java.lang.annotation.Annotation> scopeType)
          Gets an active context of the given scope.
 EjbDescriptorCache getEjbDescriptorCache()
           
 java.util.List<java.lang.Class<? extends java.lang.annotation.Annotation>> getEnabledDeploymentTypes()
          A strongly ordered, unmodifiable list of enabled deployment types
<T> T
getInstance(Bean<T> bean)
          Returns an instance of a bean
 java.lang.Object getInstanceByName(java.lang.String name)
          Gets an instance by name, returning null if none is found and throwing an exception if too many beans match
<T> T
getInstanceByType(AnnotatedItem<T,?> element, java.lang.annotation.Annotation... bindings)
          Resolve an instance, verify that the resolved bean can be instantiated, and return
<T> T
getInstanceByType(java.lang.Class<T> type, java.lang.annotation.Annotation... bindings)
          Returns an instance by API type and binding types
<T> T
getInstanceByType(TypeLiteral<T> type, java.lang.annotation.Annotation... bindings)
          Returns an instance by type literal and binding types
<T> T
getMostSpecializedInstance(Bean<T> bean, boolean create)
           
 Resolver getResolver()
          Get the web bean resolver.
 Manager parse(java.io.InputStream xmlStream)
           
<T> Manager
removeObserver(Observer<T> observer, java.lang.Class<T> eventType, java.lang.annotation.Annotation... bindings)
          Removes an observer
<T> Manager
removeObserver(Observer<T> observer, TypeLiteral<T> eventType, java.lang.annotation.Annotation... bindings)
          Removes an observer
 java.util.Set<Bean<?>> resolveByName(java.lang.String name)
          Resolves a set of beans based on their name
<T> java.util.Set<Bean<T>>
resolveByType(AnnotatedItem<T,?> element, java.lang.annotation.Annotation... bindings)
          Check the resolution request is valid, and then ask the resolver to perform the resolution.
<T> java.util.Set<Bean<T>>
resolveByType(java.lang.Class<T> type, java.lang.annotation.Annotation... bindings)
          Resolves beans by API type and binding types
<T> java.util.Set<Bean<T>>
resolveByType(TypeLiteral<T> type, java.lang.annotation.Annotation... bindings)
          Resolves beans by API type literal and binding types
 java.util.List<Decorator> resolveDecorators(java.util.Set<java.lang.Class<?>> types, java.lang.annotation.Annotation... bindings)
          Resolves a list of decorators based on API types and binding types
<T> java.util.Set<AnnotatedMethod<java.lang.Object>>
resolveDisposalMethods(java.lang.Class<T> apiType, java.lang.annotation.Annotation... bindings)
          Resolve the disposal method for the given producer method.
 java.util.List<Interceptor> resolveInterceptors(InterceptionType type, java.lang.annotation.Annotation... interceptorBindings)
          Resolves a list of interceptors based on interception type and interceptor bindings
<T> java.util.Set<Observer<T>>
resolveObservers(T event, java.lang.annotation.Annotation... bindings)
          Resolves observers for given event and bindings
 void setBeans(java.util.Set<AbstractBean<?,?>> beans)
          Wraps a collection of beans into a thread safe list.
 Manager setCurrent()
           
 void setEnabledDeploymentTypes(java.util.List<java.lang.Class<? extends java.lang.annotation.Annotation>> enabledDeploymentTypes)
          Set the enabled deployment types
 java.lang.String toDetailedString()
           
 java.lang.String toString()
          Gets a string representation
 Manager validate()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JNDI_KEY

public static final java.lang.String JNDI_KEY
See Also:
Constant Field Values
Constructor Detail

ManagerImpl

public ManagerImpl()
Constructor

Parameters:
enabledDeploymentTypes - any enabled deployment types, an empty set if none are specified
Method Detail

checkEnabledDeploymentTypes

protected void checkEnabledDeploymentTypes()
Set up the enabled deployment types, if none are specified by the user, the default @Production and @Standard are used. For internal use.

Parameters:
enabledDeploymentTypes - The enabled deployment types from web-beans.xml

addBean

public Manager addBean(Bean<?> bean)
Registers a bean with the manager

Specified by:
addBean in interface Manager
Parameters:
bean - The bean to register
Returns:
A reference to manager
See Also:
Manager.addBean(javax.webbeans.manager.Bean)

resolveDisposalMethods

public <T> java.util.Set<AnnotatedMethod<java.lang.Object>> resolveDisposalMethods(java.lang.Class<T> apiType,
                                                                                   java.lang.annotation.Annotation... bindings)
Resolve the disposal method for the given producer method. For internal use.

Parameters:
apiType - The API type to match
bindingTypes - The binding types to match
Returns:
The set of matching disposal methods

resolveObservers

public <T> java.util.Set<Observer<T>> resolveObservers(T event,
                                                       java.lang.annotation.Annotation... bindings)
Resolves observers for given event and bindings

Specified by:
resolveObservers in interface Manager
Parameters:
event - The event to match
bindings - The binding types to match
Returns:
The set of matching observers
See Also:
Manager.resolveObservers(java.lang.Object, java.lang.annotation.Annotation[])

getEnabledDeploymentTypes

public java.util.List<java.lang.Class<? extends java.lang.annotation.Annotation>> getEnabledDeploymentTypes()
A strongly ordered, unmodifiable list of enabled deployment types

Returns:
The ordered enabled deployment types known to the manager

setEnabledDeploymentTypes

public void setEnabledDeploymentTypes(java.util.List<java.lang.Class<? extends java.lang.annotation.Annotation>> enabledDeploymentTypes)
Set the enabled deployment types

Parameters:
enabledDeploymentTypes -

resolveByType

public <T> java.util.Set<Bean<T>> resolveByType(java.lang.Class<T> type,
                                                java.lang.annotation.Annotation... bindings)
Resolves beans by API type and binding types

Specified by:
resolveByType in interface Manager
Parameters:
type - The API type to match
bindingTypes - The binding types to match
Returns:
The set of matching beans
See Also:
Manager.resolveByType(java.lang.Class, java.lang.annotation.Annotation[])

resolveByType

public <T> java.util.Set<Bean<T>> resolveByType(TypeLiteral<T> type,
                                                java.lang.annotation.Annotation... bindings)
Resolves beans by API type literal and binding types

Specified by:
resolveByType in interface Manager
Parameters:
type - The API type literal to match
bindingTypes - The binding types to match
Returns:
The set of matching beans
See Also:
Manager.resolveByType(javax.webbeans.TypeLiteral, java.lang.annotation.Annotation[])

resolveByType

public <T> java.util.Set<Bean<T>> resolveByType(AnnotatedItem<T,?> element,
                                                java.lang.annotation.Annotation... bindings)
Check the resolution request is valid, and then ask the resolver to perform the resolution. For internal use.

Parameters:
element - The item to resolve
bindingTypes - The binding types to match
Returns:
The set of matching beans

setBeans

public void setBeans(java.util.Set<AbstractBean<?,?>> beans)
Wraps a collection of beans into a thread safe list. Since this overwrites any existing list of beans in the manager, this should only be done on startup and other controlled situations. For internal use.

Parameters:
beans - The set of beans to add

getBeanMap

public java.util.Map<java.lang.Class<?>,Bean<?>> getBeanMap()

getBeans

public java.util.List<Bean<?>> getBeans()
The beans registered with the Web Bean manager. For internal use

Returns:
The list of known beans

addContext

public Manager addContext(Context context)
Registers a context with the manager

Specified by:
addContext in interface Manager
Parameters:
context - The context to add
Returns:
A reference to the manager
See Also:
Manager.addContext(javax.webbeans.manager.Context)

addDecorator

public Manager addDecorator(Decorator decorator)
Registers a decorator with the manager

Specified by:
addDecorator in interface Manager
Parameters:
decorator - The decorator to register
Returns:
A reference to the manager
See Also:
Manager.addDecorator(javax.webbeans.manager.Decorator)

addInterceptor

public Manager addInterceptor(Interceptor interceptor)
Registers an interceptor with the manager

Specified by:
addInterceptor in interface Manager
Parameters:
interceptor - The interceptor to register
Returns:
A reference to the manager
See Also:
Manager.addInterceptor(javax.webbeans.manager.Interceptor)

addObserver

public <T> Manager addObserver(Observer<T> observer,
                               java.lang.Class<T> eventType,
                               java.lang.annotation.Annotation... bindings)
Registers an observer for a given event type and binding types

Specified by:
addObserver in interface Manager
Parameters:
observer - The observer to register
eventType - The event type to match
bindings - The bindings to match
Returns:
A reference to the manager
See Also:
Manager.addObserver(javax.webbeans.Observer, java.lang.Class, java.lang.annotation.Annotation[])

addObserver

public <T> Manager addObserver(Observer<T> observer,
                               TypeLiteral<T> eventType,
                               java.lang.annotation.Annotation... bindings)
Registers an observer for a given event type literal and binding types

Specified by:
addObserver in interface Manager
Parameters:
observer - The observer to register
eventType - The event type literal to match
bindings - The bindings to match
Returns:
A reference to the manager
See Also:
Manager.addObserver(javax.webbeans.Observer, javax.webbeans.TypeLiteral, java.lang.annotation.Annotation[])

fireEvent

public void fireEvent(java.lang.Object event,
                      java.lang.annotation.Annotation... bindings)
Fires an event object with given event object for given bindings

Specified by:
fireEvent in interface Manager
Parameters:
event - The event object to pass along
bindings - The binding types to match
See Also:
Manager.fireEvent(java.lang.Object, java.lang.annotation.Annotation[])

getContext

public Context getContext(java.lang.Class<? extends java.lang.annotation.Annotation> scopeType)
Gets an active context of the given scope. Throws an exception if there are no active contexts found or if there are too many matches

Specified by:
getContext in interface Manager
Parameters:
scopeType - The scope to match
Returns:
A single active context of the given scope
See Also:
Manager.getContext(java.lang.Class)

getBuiltInContext

public Context getBuiltInContext(java.lang.Class<? extends java.lang.annotation.Annotation> scopeType)
Direct access to built in contexts. For internal use.

Parameters:
scopeType - The scope type of the context
Returns:
The context

getInstance

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

Specified by:
getInstance in interface Manager
Parameters:
bean - The bean to instantiate
Returns:
An instance of the bean
See Also:
Manager.getInstance(javax.webbeans.manager.Bean)

getInstanceByName

public java.lang.Object getInstanceByName(java.lang.String name)
Gets an instance by name, returning null if none is found and throwing an exception if too many beans match

Specified by:
getInstanceByName in interface Manager
Parameters:
name - The name to match
Returns:
An instance of the bean
See Also:
Manager.getInstanceByName(java.lang.String)

getInstanceByType

public <T> T getInstanceByType(java.lang.Class<T> type,
                               java.lang.annotation.Annotation... bindings)
Returns an instance by API type and binding types

Specified by:
getInstanceByType in interface Manager
Parameters:
type - The API type to match
bindingTypes - The binding types to match
Returns:
An instance of the bean
See Also:
Manager.getInstanceByType(java.lang.Class, java.lang.annotation.Annotation[])

getMostSpecializedInstance

public <T> T getMostSpecializedInstance(Bean<T> bean,
                                        boolean create)

getInstanceByType

public <T> T getInstanceByType(TypeLiteral<T> type,
                               java.lang.annotation.Annotation... bindings)
Returns an instance by type literal and binding types

Specified by:
getInstanceByType in interface Manager
Parameters:
type - The type to match
bindingTypes - The binding types to match
Returns:
An instance of the bean
See Also:
Manager.getInstanceByType(javax.webbeans.TypeLiteral, java.lang.annotation.Annotation[])

getInstanceByType

public <T> T getInstanceByType(AnnotatedItem<T,?> element,
                               java.lang.annotation.Annotation... bindings)
Resolve an instance, verify that the resolved bean can be instantiated, and return

Parameters:
element - The annotated item to match
bindingTypes - The binding types to match
Returns:
An instance of the bean

removeObserver

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

Specified by:
removeObserver in interface Manager
Parameters:
observer - The observer to remove
eventType - The event type to match
bindings - the binding types to match
Returns:
A reference to the manager
See Also:
Manager.removeObserver(javax.webbeans.Observer, java.lang.Class, java.lang.annotation.Annotation[])

removeObserver

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

Specified by:
removeObserver in interface Manager
Parameters:
observer - The observer to remove
eventType - The event type to match
bindings - the binding types to match
Returns:
A reference to the manager
See Also:
Manager.removeObserver(javax.webbeans.Observer, javax.webbeans.TypeLiteral, java.lang.annotation.Annotation[])

resolveByName

public java.util.Set<Bean<?>> resolveByName(java.lang.String name)
Resolves a set of beans based on their name

Specified by:
resolveByName in interface Manager
Parameters:
The - name to match
Returns:
The set of matching beans
See Also:
Manager.resolveByName(java.lang.String)

resolveDecorators

public java.util.List<Decorator> resolveDecorators(java.util.Set<java.lang.Class<?>> types,
                                                   java.lang.annotation.Annotation... bindings)
Resolves a list of decorators based on API types and binding types

Specified by:
resolveDecorators in interface Manager
Parameters:
types - The set of API types to match
bindingTypes - The binding types to match
Returns:
A list of matching decorators
See Also:
Manager.resolveDecorators(java.util.Set, java.lang.annotation.Annotation[])

resolveInterceptors

public java.util.List<Interceptor> resolveInterceptors(InterceptionType type,
                                                       java.lang.annotation.Annotation... interceptorBindings)
Resolves a list of interceptors based on interception type and interceptor bindings

Specified by:
resolveInterceptors in interface Manager
Parameters:
type - The interception type to resolve
interceptorBindings - The binding types to match
Returns:
A list of matching interceptors
See Also:
Manager.resolveInterceptors(javax.webbeans.manager.InterceptionType, java.lang.annotation.Annotation[])

getResolver

public Resolver getResolver()
Get the web bean resolver. For internal use

Returns:
The resolver

getEjbDescriptorCache

public EjbDescriptorCache getEjbDescriptorCache()

toString

public java.lang.String toString()
Gets a string representation

Overrides:
toString in class java.lang.Object
Returns:
A string representation

toDetailedString

public java.lang.String toDetailedString()

parse

public Manager parse(java.io.InputStream xmlStream)
Specified by:
parse in interface Manager

validate

public Manager validate()
Specified by:
validate in interface Manager

createChildManager

public Manager createChildManager()
Specified by:
createChildManager in interface Manager

setCurrent

public Manager setCurrent()
Specified by:
setCurrent in interface Manager


Copyright © 2008. All Rights Reserved.