com.caucho.webbeans.manager
Class WebBeansContainer

java.lang.Object
  extended by com.caucho.webbeans.manager.WebBeansContainer
All Implemented Interfaces:
ScanListener, EnvironmentListener, java.io.Serializable, Container

public class WebBeansContainer
extends java.lang.Object
implements ScanListener, EnvironmentListener, Container, java.io.Serializable

The web beans container for a given environment.

See Also:
Serialized Form

Method Summary
 void addComponent(ComponentImpl comp)
           
 void addComponentByName(java.lang.String name, ComponentImpl comp)
           
 void addComponentByType(java.lang.reflect.Type type, ComponentImpl comp)
          Adds a component by the interface type
 void addContext(java.lang.Class<java.lang.annotation.Annotation> scopeType, Context context)
           
 void addEnabledInterceptor(java.lang.Class cl)
           
 void addObserver(ObserverImpl observer)
           
 void addSingleton(java.lang.Object object)
           
 void addSingleton(java.lang.Object object, java.lang.String name)
           
 void addSingleton(java.lang.Object object, java.lang.String name, java.lang.Class componentType)
           
 void addSingletonByName(java.lang.Object object, java.lang.String name)
          Adds a singleton only to the name map
 void bind()
          Starts the bind phase
 ComponentImpl bind(java.lang.String location, java.lang.reflect.Type type)
          Returns the web beans component corresponding to the return type.
 ComponentImpl bind(java.lang.String location, java.lang.reflect.Type type, java.lang.annotation.Annotation[] paramAnn)
          Returns the web beans component corresponding to a method parameter.
 ComponentImpl bind(java.lang.String location, java.lang.reflect.Type type, java.util.ArrayList<java.lang.annotation.Annotation> bindingList)
          Returns the web beans component with a given binding list.
 ComponentImpl bind(java.lang.String location, java.lang.reflect.Type type, java.lang.String name)
          Returns the web beans component corresponding to a method and a @Named value
 ComponentImpl bindByBindings(java.lang.String location, java.lang.reflect.Type type, java.util.ArrayList<Binding> bindingList)
          Returns the web beans component with a given binding list.
 void classMatchEvent(EnvironmentClassLoader loader, Path root, java.lang.String className)
          Callback to note the class matches
static WebBeansContainer create()
          Returns the current active container.
static WebBeansContainer create(java.lang.ClassLoader loader)
          Returns the current active container.
 WbComponentType createComponentType(java.lang.Class cl)
           
 Conversation createConversation()
           
<T> T
createFactory(java.lang.Class<T> type, java.lang.String name)
          Returns a new instance for a class, but does not register the component with webbeans.
 ComponentFactory createFactory(java.lang.Class type, java.lang.annotation.Annotation... ann)
          Returns a new instance for a class, but does not register the component with webbeans.
 void createProgram(java.util.ArrayList<ConfigProgram> injectList, java.lang.reflect.Field field, boolean isOptional)
          Creates an injection program for the given field
 void createProgram(java.util.ArrayList<ConfigProgram> injectList, java.lang.reflect.Method method)
          Creates an injection program for the given method
<T> ComponentFactory<T>
createTransient(java.lang.Class<T> type)
          Returns a ComponentFactory for a class, but does not register the component with webbeans.
<T> T
createTransientObject(java.lang.Class<T> type)
          Creates an object, but does not register the component with webbeans.
<T> T
createTransientObjectNoInit(java.lang.Class<T> type)
          Creates an object, but does not register the component with webbeans.
 void environmentBind(EnvironmentClassLoader loader)
          Handles the case the environment config phase
 void environmentConfigure(EnvironmentClassLoader loader)
          Handles the case the environment config phase
 void environmentStart(EnvironmentClassLoader loader)
          Handles the case where the environment is starting (after init).
 void environmentStop(EnvironmentClassLoader loader)
          Handles the case where the environment is stopping
static ConfigException error(java.lang.reflect.Method method, java.lang.String msg)
           
 ComponentImpl findByName(java.lang.String name)
          Finds a component by its component name.
 java.util.ArrayList<java.lang.Class> findInterceptors(java.util.ArrayList<java.lang.annotation.Annotation> annList)
           
 java.util.ArrayList<ComponentFactory> getBeansOfType(java.lang.reflect.Type type)
           
<T> T
getByType(java.lang.Class<T> apiType, java.lang.annotation.Annotation... bindingTypes)
          Returns the component which matches the apiType and binding types
 java.lang.ClassLoader getClassLoader()
           
 Context getContext(java.lang.Class<java.lang.annotation.Annotation> scopeType)
           
static WebBeansContainer getCurrent()
          Returns the local container.
static WebBeansContainer getCurrent(java.lang.ClassLoader loader)
          Returns the current environment container.
 ELContext getELContext()
           
<T> T
getEnvironmentObject(java.lang.Class<T> type, java.lang.annotation.Annotation... ann)
          Returns a new instance for a class, but does not register the component with webbeans.
<T> T
getObject(java.lang.Class<T> type, java.lang.annotation.Annotation... ann)
          Returns a new instance for a class, but does not register the component with webbeans.
<T> T
getObject(java.lang.Class<T> type, java.lang.String name)
          Returns a new instance for a class, but does not register the component with webbeans.
 java.lang.Object getObjectByName(java.lang.String name)
          Finds a component by its component name.
 int getPriority()
          Since webbeans doesn't enhance, it's priority 1
 ScopeContext getScopeContext(java.lang.Class scope)
          Returns the scope context corresponding to the scope annotation type.
 WbWebBeans getWbWebBeans()
           
static ConfigException injectError(java.lang.reflect.AccessibleObject prop, java.lang.String msg)
           
 void injectObject(java.lang.Object obj)
          Injects an object
 boolean isRootScannable(Path root)
          Returns true if the root is a valid scannable root.
 boolean isScanMatch(CharBuffer annotationName)
          Returns true if the string matches an annotation class.
 java.lang.Class loadClass(java.lang.String className)
           
static java.lang.String location(java.lang.reflect.Field field)
           
static java.lang.String location(java.lang.reflect.Method method)
           
 void raiseEvent(java.lang.Object event, java.lang.annotation.Annotation... bindings)
          Sends the specified event to any observer instances in the scope
<T> ComponentFactory<T>
resolveByType(java.lang.Class<T> apiType, java.lang.annotation.Annotation... bindingTypes)
          Returns the component which matches the apiType and binding types
 java.lang.String toString()
           
 void update()
           
 java.lang.Object writeReplace()
          Serialization rewriting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getCurrent

public static WebBeansContainer getCurrent()
Returns the local container.


getCurrent

public static WebBeansContainer getCurrent(java.lang.ClassLoader loader)
Returns the current environment container.


create

public static WebBeansContainer create()
Returns the current active container.


create

public static WebBeansContainer create(java.lang.ClassLoader loader)
Returns the current active container.


getWbWebBeans

public WbWebBeans getWbWebBeans()

getClassLoader

public java.lang.ClassLoader getClassLoader()

createComponentType

public WbComponentType createComponentType(java.lang.Class cl)

addComponent

public void addComponent(ComponentImpl comp)

addComponentByName

public void addComponentByName(java.lang.String name,
                               ComponentImpl comp)

addComponentByType

public void addComponentByType(java.lang.reflect.Type type,
                               ComponentImpl comp)
Adds a component by the interface type

Parameters:
type - the interface type to expose the component
comp - the component to register

getBeansOfType

public java.util.ArrayList<ComponentFactory> getBeansOfType(java.lang.reflect.Type type)

addSingleton

public void addSingleton(java.lang.Object object)

addSingleton

public void addSingleton(java.lang.Object object,
                         java.lang.String name)

addSingleton

public void addSingleton(java.lang.Object object,
                         java.lang.String name,
                         java.lang.Class componentType)

addSingletonByName

public void addSingletonByName(java.lang.Object object,
                               java.lang.String name)
Adds a singleton only to the name map

Parameters:
object - the singleton value
name - the singleton's name

addEnabledInterceptor

public void addEnabledInterceptor(java.lang.Class cl)

findInterceptors

public java.util.ArrayList<java.lang.Class> findInterceptors(java.util.ArrayList<java.lang.annotation.Annotation> annList)

getScopeContext

public ScopeContext getScopeContext(java.lang.Class scope)
Returns the scope context corresponding to the scope annotation type.

Parameters:
scope - the scope annotation type identifying the scope

createProgram

public void createProgram(java.util.ArrayList<ConfigProgram> injectList,
                          java.lang.reflect.Field field,
                          boolean isOptional)
                   throws ConfigException
Creates an injection program for the given field

Throws:
ConfigException

createProgram

public void createProgram(java.util.ArrayList<ConfigProgram> injectList,
                          java.lang.reflect.Method method)
                   throws ConfigException
Creates an injection program for the given method

Throws:
ConfigException

bind

public ComponentImpl bind(java.lang.String location,
                          java.lang.reflect.Type type,
                          java.lang.String name)
Returns the web beans component corresponding to a method and a @Named value


bind

public ComponentImpl bind(java.lang.String location,
                          java.lang.reflect.Type type)
Returns the web beans component corresponding to the return type.


bind

public ComponentImpl bind(java.lang.String location,
                          java.lang.reflect.Type type,
                          java.lang.annotation.Annotation[] paramAnn)
Returns the web beans component corresponding to a method parameter.


bind

public ComponentImpl bind(java.lang.String location,
                          java.lang.reflect.Type type,
                          java.util.ArrayList<java.lang.annotation.Annotation> bindingList)
Returns the web beans component with a given binding list.


bindByBindings

public ComponentImpl bindByBindings(java.lang.String location,
                                    java.lang.reflect.Type type,
                                    java.util.ArrayList<Binding> bindingList)
Returns the web beans component with a given binding list.


findByName

public ComponentImpl findByName(java.lang.String name)
Finds a component by its component name.


getObjectByName

public java.lang.Object getObjectByName(java.lang.String name)
Finds a component by its component name.


injectObject

public void injectObject(java.lang.Object obj)
Injects an object


addObserver

public void addObserver(ObserverImpl observer)

resolveByType

public <T> ComponentFactory<T> resolveByType(java.lang.Class<T> apiType,
                                             java.lang.annotation.Annotation... bindingTypes)
Returns the component which matches the apiType and binding types

Specified by:
resolveByType in interface Container

getByType

public <T> T getByType(java.lang.Class<T> apiType,
                       java.lang.annotation.Annotation... bindingTypes)
Returns the component which matches the apiType and binding types


addContext

public void addContext(java.lang.Class<java.lang.annotation.Annotation> scopeType,
                       Context context)
Specified by:
addContext in interface Container

getContext

public Context getContext(java.lang.Class<java.lang.annotation.Annotation> scopeType)
Specified by:
getContext in interface Container

raiseEvent

public void raiseEvent(java.lang.Object event,
                       java.lang.annotation.Annotation... bindings)
Sends the specified event to any observer instances in the scope

Specified by:
raiseEvent in interface Container

createConversation

public Conversation createConversation()

createTransientObject

public <T> T createTransientObject(java.lang.Class<T> type)
Creates an object, but does not register the component with webbeans.


createTransientObjectNoInit

public <T> T createTransientObjectNoInit(java.lang.Class<T> type)
Creates an object, but does not register the component with webbeans.


createTransient

public <T> ComponentFactory<T> createTransient(java.lang.Class<T> type)
Returns a ComponentFactory for a class, but does not register the component with webbeans.


getELContext

public ELContext getELContext()

getObject

public <T> T getObject(java.lang.Class<T> type,
                       java.lang.annotation.Annotation... ann)
Returns a new instance for a class, but does not register the component with webbeans.


getObject

public <T> T getObject(java.lang.Class<T> type,
                       java.lang.String name)
Returns a new instance for a class, but does not register the component with webbeans.


createFactory

public <T> T createFactory(java.lang.Class<T> type,
                           java.lang.String name)
Returns a new instance for a class, but does not register the component with webbeans.


getEnvironmentObject

public <T> T getEnvironmentObject(java.lang.Class<T> type,
                                  java.lang.annotation.Annotation... ann)
Returns a new instance for a class, but does not register the component with webbeans.


createFactory

public ComponentFactory createFactory(java.lang.Class type,
                                      java.lang.annotation.Annotation... ann)
Returns a new instance for a class, but does not register the component with webbeans.


update

public void update()

bind

public void bind()
Starts the bind phase


loadClass

public java.lang.Class loadClass(java.lang.String className)

environmentConfigure

public void environmentConfigure(EnvironmentClassLoader loader)
Handles the case the environment config phase

Specified by:
environmentConfigure in interface EnvironmentListener

environmentBind

public void environmentBind(EnvironmentClassLoader loader)
Handles the case the environment config phase

Specified by:
environmentBind in interface EnvironmentListener

environmentStart

public void environmentStart(EnvironmentClassLoader loader)
Handles the case where the environment is starting (after init).

Specified by:
environmentStart in interface EnvironmentListener

environmentStop

public void environmentStop(EnvironmentClassLoader loader)
Handles the case where the environment is stopping

Specified by:
environmentStop in interface EnvironmentListener

injectError

public static ConfigException injectError(java.lang.reflect.AccessibleObject prop,
                                          java.lang.String msg)

location

public static java.lang.String location(java.lang.reflect.Field field)

location

public static java.lang.String location(java.lang.reflect.Method method)

error

public static ConfigException error(java.lang.reflect.Method method,
                                    java.lang.String msg)

getPriority

public int getPriority()
Since webbeans doesn't enhance, it's priority 1

Specified by:
getPriority in interface ScanListener

isRootScannable

public boolean isRootScannable(Path root)
Returns true if the root is a valid scannable root.

Specified by:
isRootScannable in interface ScanListener

isScanMatch

public boolean isScanMatch(CharBuffer annotationName)
Description copied from interface: ScanListener
Returns true if the string matches an annotation class.

Specified by:
isScanMatch in interface ScanListener

classMatchEvent

public void classMatchEvent(EnvironmentClassLoader loader,
                            Path root,
                            java.lang.String className)
Callback to note the class matches

Specified by:
classMatchEvent in interface ScanListener

writeReplace

public java.lang.Object writeReplace()
Serialization rewriting


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object