com.caucho.webbeans.component
Class ComponentImpl

java.lang.Object
  extended by com.caucho.webbeans.component.ComponentImpl
All Implemented Interfaces:
ObjectProxy, ComponentFactory
Direct Known Subclasses:
ClassComponent, FactoryComponent, ObjectProxyComponent, ProducesComponent, StatefulComponent, StatelessComponent

public class ComponentImpl
extends java.lang.Object
implements ComponentFactory, ObjectProxy

Configuration for the xml web bean component.


Field Summary
protected  ConfigProgram[] _destroyProgram
           
protected  ConfigProgram[] _initProgram
           
protected  ConfigProgram[] _injectProgram
           
protected  ScopeContext _scope
           
protected  WbWebBeans _webbeans
           
 
Constructor Summary
ComponentImpl(WbWebBeans webbeans)
           
 
Method Summary
 void addNameBinding(java.lang.String name)
           
 void addProgram(ConfigProgram program)
          Add to the init program.
 void bind()
          Binds parameters
 java.lang.Object create()
          Creates a new instance of the component.
protected  java.lang.Object createNew(ConfigContext env)
          Creates a new instance of the component
 java.lang.Object createNoInit()
          Creates a new instance of the component.
 java.lang.Object createObject(java.util.Hashtable env)
          Returns the new object for JNDI
 void createProgram(java.util.ArrayList<ConfigProgram> initList, java.lang.reflect.Field field)
           
 void destroy(java.lang.Object value)
          Destroys the value
 void destroy(java.lang.Object value, ConfigContext env)
          Destroys the value
 boolean equals(java.lang.Object obj)
           
protected  ConfigException error(java.lang.reflect.Method method, java.lang.String msg)
           
 java.lang.Object get()
          Returns the component object, creating if necessary
 java.lang.Object get(ConfigContext env)
           
 java.util.ArrayList<WbBinding> getBindingList()
           
 java.lang.String getClassName()
           
 WebBeansHandle getHandle()
          Returns the serialization handle
 java.lang.Object getIfExists()
          Returns the component object if it already exists
 java.lang.String getName()
          Gets the component's EL binding name.
 ScopeContext getScope()
          Gets the scope annotation.
 java.lang.String getScopeId()
           
protected static java.lang.String getSimpleName(java.lang.reflect.Type type)
           
 java.lang.Class getTargetClass()
           
 java.lang.String getTargetSimpleName()
           
 java.lang.reflect.Type getTargetType()
           
 WbComponentType getType()
          Gets the component type.
 WbWebBeans getWebBeans()
           
 void init()
          Initialization.
protected  java.lang.Object init(java.lang.Object value, ConfigContext env)
          Initialize the created value
protected  void introspect()
           
protected  void introspectBindings()
          Introspects the methods for any @Produces
protected  void introspectScope(java.lang.Class type)
          Called for implicit introspection.
 boolean isDestroyPresent()
          Returns true if there's a destroy program.
 boolean isFromClass()
          True if the component was defined by class introspection.
 boolean isMatch(java.lang.annotation.Annotation bindAnn)
          Returns true if at least one of this component's bindings match the injection binding.
 boolean isMatch(java.util.ArrayList<java.lang.annotation.Annotation> bindList)
           
 boolean isMatchByBinding(java.util.ArrayList<Binding> bindList)
           
 boolean isMatchByBinding(Binding binding)
          Returns true if at least one of this component's bindings match the injection binding.
 boolean isSingleton()
           
 void setBindingList(java.util.ArrayList<WbBinding> bindingList)
          Adds a component binding.
 void setFromClass(boolean isFromClass)
          True if the component was defined by class introspection.
 void setInit(ContainerProgram init)
          Sets the init program.
 void setName(java.lang.String name)
          Returns the component's EL binding name.
 void setScope(ScopeContext scope)
          Sets the scope annotation.
 void setTargetType(java.lang.reflect.Type type)
           
 void setType(WbComponentType type)
          Sets the component type.
 java.lang.String toDebugString()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_webbeans

protected WbWebBeans _webbeans

_scope

protected ScopeContext _scope

_injectProgram

protected ConfigProgram[] _injectProgram

_initProgram

protected ConfigProgram[] _initProgram

_destroyProgram

protected ConfigProgram[] _destroyProgram
Constructor Detail

ComponentImpl

public ComponentImpl(WbWebBeans webbeans)
Method Detail

getWebBeans

public WbWebBeans getWebBeans()

setName

public void setName(java.lang.String name)
Returns the component's EL binding name.


getName

public java.lang.String getName()
Gets the component's EL binding name.


addNameBinding

public void addNameBinding(java.lang.String name)

getType

public WbComponentType getType()
Gets the component type.


setType

public void setType(WbComponentType type)
Sets the component type.


setTargetType

public void setTargetType(java.lang.reflect.Type type)

getTargetType

public java.lang.reflect.Type getTargetType()

getTargetSimpleName

public java.lang.String getTargetSimpleName()

getTargetClass

public java.lang.Class getTargetClass()

getClassName

public java.lang.String getClassName()

setBindingList

public void setBindingList(java.util.ArrayList<WbBinding> bindingList)
Adds a component binding.


getBindingList

public java.util.ArrayList<WbBinding> getBindingList()

setScope

public void setScope(ScopeContext scope)
Sets the scope annotation.


getScope

public ScopeContext getScope()
Gets the scope annotation.


isSingleton

public boolean isSingleton()

setInit

public void setInit(ContainerProgram init)
Sets the init program.


addProgram

public void addProgram(ConfigProgram program)
Add to the init program.


setFromClass

public void setFromClass(boolean isFromClass)
True if the component was defined by class introspection.


isFromClass

public boolean isFromClass()
True if the component was defined by class introspection.


getHandle

public WebBeansHandle getHandle()
Returns the serialization handle


init

public void init()
Initialization.


introspect

protected void introspect()

introspectScope

protected void introspectScope(java.lang.Class type)
Called for implicit introspection.


introspectBindings

protected void introspectBindings()
Introspects the methods for any @Produces


isMatch

public boolean isMatch(java.util.ArrayList<java.lang.annotation.Annotation> bindList)

isMatch

public boolean isMatch(java.lang.annotation.Annotation bindAnn)
Returns true if at least one of this component's bindings match the injection binding.


isMatchByBinding

public boolean isMatchByBinding(java.util.ArrayList<Binding> bindList)

isMatchByBinding

public boolean isMatchByBinding(Binding binding)
Returns true if at least one of this component's bindings match the injection binding.


getIfExists

public java.lang.Object getIfExists()
Returns the component object if it already exists


get

public java.lang.Object get()
Returns the component object, creating if necessary

Specified by:
get in interface ComponentFactory

get

public java.lang.Object get(ConfigContext env)

create

public java.lang.Object create()
Creates a new instance of the component.

Specified by:
create in interface ComponentFactory

createNoInit

public java.lang.Object createNoInit()
Creates a new instance of the component.


createNew

protected java.lang.Object createNew(ConfigContext env)
Creates a new instance of the component

Parameters:
env - the configuration environment
Returns:
the new object

init

protected java.lang.Object init(java.lang.Object value,
                                ConfigContext env)
Initialize the created value


isDestroyPresent

public boolean isDestroyPresent()
Returns true if there's a destroy program.


destroy

public void destroy(java.lang.Object value,
                    ConfigContext env)
Destroys the value


destroy

public void destroy(java.lang.Object value)
Destroys the value

Specified by:
destroy in interface ComponentFactory

bind

public void bind()
Binds parameters


createProgram

public void createProgram(java.util.ArrayList<ConfigProgram> initList,
                          java.lang.reflect.Field field)
                   throws ConfigException
Throws:
ConfigException

getScopeId

public java.lang.String getScopeId()

createObject

public java.lang.Object createObject(java.util.Hashtable env)
Returns the new object for JNDI

Specified by:
createObject in interface ObjectProxy
Returns:
the object named by the proxy.

error

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

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toDebugString

public java.lang.String toDebugString()

toString

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

getSimpleName

protected static java.lang.String getSimpleName(java.lang.reflect.Type type)