Errai 3.0.1-SNAPSHOT

org.jboss.errai.ioc.rebind.ioc.injector
Class AbstractInjector

java.lang.Object
  extended by org.jboss.errai.ioc.rebind.ioc.injector.AbstractInjector
All Implemented Interfaces:
Injector
Direct Known Subclasses:
AbstractAsyncInjector, ProducerInjector, ProxyInjector, QualifiedTypeInjectorDelegate, TypeInjector

public abstract class AbstractInjector
extends Object
implements Injector


Nested Class Summary
protected static class AbstractInjector.RegisterCache
           
 
Field Summary
protected  AbstractInjector.RegisterCache _registerCache
           
protected  boolean alternative
           
protected  Map<String,Object> attributes
           
protected  boolean basic
           
protected  String beanName
           
protected  String creationalCallbackVarName
           
protected  boolean enabled
           
protected  MetaClass enclosingType
           
protected  String postInitCallbackVar
           
protected  String preDestroyCallbackVar
           
protected  boolean provider
           
protected  QualifyingMetadata qualifyingMetadata
           
protected  MetaParameterizedType qualifyingTypeInformation
           
protected  boolean replaceable
           
protected  boolean singleton
           
protected  boolean softDisabled
           
protected  boolean testMock
           
 
Constructor Summary
AbstractInjector()
           
 
Method Summary
 void addDisablingHook(Runnable runnable)
          Add a Runnable task to be executed when and if the injector is disabled.
 void addInvokeAfter(MetaMethod method, Statement statement)
          Adds an invoke after statement on the specified method.
 void addInvokeAround(MetaMethod method, Statement statement)
          Adds an invoke around statement on the specified method.
 void addInvokeBefore(MetaMethod method, Statement statement)
          Adds an invoke before statement on the specified method.
 ProxyMaker.ProxyProperty addProxyProperty(String propertyName, Class type, Statement statement)
          Adds a proxy property to the generated proxy.
 ProxyMaker.ProxyProperty addProxyProperty(String propertyName, MetaClass type, Statement statementReference)
          Adds a proxy property to the generated proxy.
 void addRegistrationHook(RegistrationHook registrationHook)
          Adds a registration hook to be triggered when the bean is ready to render its registration to be bean manager
 void addRenderingHook(RenderingHook renderingHook)
          Adds a RenderingHook which will be triggered when the injector is rendered.
 void addStatementToEndOfInjector(Statement statement)
          Add a statement to the end of the bean injector code.
 List<Statement> createProxyDeclaration(InjectionContext context)
           
 List<Statement> createProxyDeclaration(InjectionContext context, Statement beanRef)
           
protected  void disableSoftly()
           
 List<Statement> getAddToEndStatements()
           
 Object getAttribute(String name)
          Gets a persistent attribute associated with this injector.
 String getBeanName()
          Get the name of the bean (if it has a name).
 MetaClass getConcreteInjectedType()
          Returns the concrete type that will be returned by this injector.
 String getCreationalCallbackVarName()
          The unique variable name for a BeanProvider associated with this bean.
protected  List<Runnable> getDisablingCallbacks()
           
 MetaClass getEnclosingType()
          The enclosing type of the injector.
 String getInstanceVarName()
          The unique variable name for the bean instance.
static QualifyingMetadata getMetadataWithAny(QualifyingMetadata metadata)
           
 String getPostInitCallbackVar()
          The unique variable name for the InitalizationCallback associated with a bean CreationalContext in the boostrapper method.
 String getPreDestroyCallbackVar()
          The unique variable name for the DestructionCallback associated with the BeanProvider for this bean.
 String getProxyInstanceVarName()
          The unique variable name for the proxied bean instance.
 Map<String,ProxyMaker.ProxyProperty> getProxyPropertyMap()
          Returns a map of all proxy properties in the injector.
 QualifyingMetadata getQualifyingMetadata()
          Returns the QualifyingMetadata associated with this injector.
 MetaParameterizedType getQualifyingTypeInformation()
          Returns parameterized type data associated with this injector
protected  List<RegistrationHook> getRegistrationHooks()
           
protected  List<RenderingHook> getRenderingHooks()
           
 Map<MetaMethod,Map<WeaveType,Collection<Statement>>> getWeavingStatements()
           
 Map<MetaMethod,Map<WeaveType,Collection<Statement>>> getWeavingStatementsMap()
           
 boolean hasAttribute(String name)
          Checks if injector has the specified named attribute
protected static boolean hasNewQualifier(InjectableInstance instance)
           
 boolean isAlternative()
          Checks if the injector an alternative.
 boolean isCreated()
          Checks if construction has begun.
 boolean isDependent()
          Check if the injector if of the dependent scope.
 boolean isEnabled()
          Checks if the injector is enabled, and is eligible for injection consideration.
 boolean isProvider()
          Checks if the injector represents a provider.
 boolean isProxied()
          Checks if the injector is a proxied injector.
 boolean isPseudo()
          Checks if the injector is a psuedo bean.
 boolean isRegularTypeInjector()
          Returns true if the injector type is a regular type injector.
 boolean isRendered()
          Checks if the injector's BeanProvider already been rendered.
 boolean isSingleton()
          Checks if the injector for a singleton bean.
 boolean isSoftDisabled()
          Checks if the injector is soft disabled.
 boolean isStatic()
          Checks is the injector is a static injector, meaning that it can safely be referenced from anywhere, without concern for ordering of its declaring class.
 boolean isTestMock()
          Checks if the injector represents a test mock.
protected  void markRendered(InjectableInstance injectableInstance)
           
 boolean matches(MetaParameterizedType parameterizedType, QualifyingMetadata qualifyingMetadata)
          Determines whether or not the the bean type this injector producers matches the specified parameterized type and qualifying metadata.
 void registerWithBeanManager(InjectionContext context, Statement valueRef)
           
 void setAttribute(String name, Object value)
          Sets a persistent attribute to be associated with this injector.
 void setCreated(boolean created)
           
 void setCreationalCallbackVarName(String creationalCallbackVarName)
           
 void setEnabled(boolean enabled)
          Set the enabled state of the bean.
 void setPostInitCallbackVar(String var)
          Sets a variable name reference to the InitializationCallback to associate with the BeanProvider for this bean.
 void setPreDestroyCallbackVar(String preDestroyCallbackVar)
          Sets a variable name reference to the DestructionCallback to associate with this BeanProvider for this bean.
 void setRendered(boolean rendered)
           
 void setReplaceable(boolean replaceable)
           
 void setSoftDisabled(boolean softDisabled)
           
 String toString()
           
 void updateProxies()
          This method should be called to ensure that the proxies have been updated to reflect any code weavings that may have been added.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.errai.ioc.rebind.ioc.injector.Injector
getBeanInstance, getInjectedType, renderProvider
 

Field Detail

qualifyingMetadata

protected QualifyingMetadata qualifyingMetadata

qualifyingTypeInformation

protected MetaParameterizedType qualifyingTypeInformation

postInitCallbackVar

protected String postInitCallbackVar

preDestroyCallbackVar

protected String preDestroyCallbackVar

creationalCallbackVarName

protected String creationalCallbackVarName

enabled

protected boolean enabled

softDisabled

protected boolean softDisabled

testMock

protected boolean testMock

alternative

protected boolean alternative

singleton

protected boolean singleton

replaceable

protected boolean replaceable

provider

protected boolean provider

basic

protected boolean basic

enclosingType

protected MetaClass enclosingType

beanName

protected String beanName

attributes

protected Map<String,Object> attributes

_registerCache

protected AbstractInjector.RegisterCache _registerCache
Constructor Detail

AbstractInjector

public AbstractInjector()
Method Detail

isTestMock

public boolean isTestMock()
Description copied from interface: Injector
Checks if the injector represents a test mock.

Specified by:
isTestMock in interface Injector
Returns:
true if the injector is a test mock

isAlternative

public boolean isAlternative()
Description copied from interface: Injector
Checks if the injector an alternative.

Specified by:
isAlternative in interface Injector
Returns:
true if the injector is an alternative

isRendered

public boolean isRendered()
Description copied from interface: Injector
Checks if the injector's BeanProvider already been rendered.

Specified by:
isRendered in interface Injector
Returns:
true if the creational callback has already been rendered.

isSingleton

public boolean isSingleton()
Description copied from interface: Injector
Checks if the injector for a singleton bean.

Specified by:
isSingleton in interface Injector
Returns:
true if the injector handles a singleton bean.

isDependent

public boolean isDependent()
Description copied from interface: Injector
Check if the injector if of the dependent scope.

Specified by:
isDependent in interface Injector
Returns:
true if the injector is of a dependent scope.

isPseudo

public boolean isPseudo()
Description copied from interface: Injector
Checks if the injector is a psuedo bean. A psuedo bean is a bean which has been discovered in the classpath and is by default considered part of the dependent scope. But it's scope may be overridden through further processing.

Specified by:
isPseudo in interface Injector
Returns:
true if the injector is for a psuedo bean.

isProvider

public boolean isProvider()
Description copied from interface: Injector
Checks if the injector represents a provider.

Specified by:
isProvider in interface Injector
Returns:
true if the injector is for a provider.

isStatic

public boolean isStatic()
Description copied from interface: Injector
Checks is the injector is a static injector, meaning that it can safely be referenced from anywhere, without concern for ordering of its declaring class.

Specified by:
isStatic in interface Injector
Returns:
true if the injector is a static injector

getEnclosingType

public MetaClass getEnclosingType()
Description copied from interface: Injector
The enclosing type of the injector. For producer injectors, this method will return the bean which the producer method is a member.

Specified by:
getEnclosingType in interface Injector
Returns:
the enclosing bean type of the injector, if applicable. Null if not applicable.

isCreated

public boolean isCreated()
Description copied from interface: Injector
Checks if construction has begun.

Specified by:
isCreated in interface Injector
Returns:

setCreated

public void setCreated(boolean created)

setRendered

public void setRendered(boolean rendered)

setReplaceable

public void setReplaceable(boolean replaceable)

getPostInitCallbackVar

public String getPostInitCallbackVar()
Description copied from interface: Injector
The unique variable name for the InitalizationCallback associated with a bean CreationalContext in the boostrapper method.

Specified by:
getPostInitCallbackVar in interface Injector
Returns:
the unique variable name for an InitializationCallback instance. Null if none.

setPostInitCallbackVar

public void setPostInitCallbackVar(String var)
Description copied from interface: Injector
Sets a variable name reference to the InitializationCallback to associate with the BeanProvider for this bean.

Specified by:
setPostInitCallbackVar in interface Injector
Parameters:
var - a unique variable name pointing to an instance of InitializationCallback.

getPreDestroyCallbackVar

public String getPreDestroyCallbackVar()
Description copied from interface: Injector
The unique variable name for the DestructionCallback associated with the BeanProvider for this bean.

Specified by:
getPreDestroyCallbackVar in interface Injector
Returns:
the unique variable name for a DestructionCallback instance. Null if none.

setPreDestroyCallbackVar

public void setPreDestroyCallbackVar(String preDestroyCallbackVar)
Description copied from interface: Injector
Sets a variable name reference to the DestructionCallback to associate with this BeanProvider for this bean.

Specified by:
setPreDestroyCallbackVar in interface Injector
Parameters:
preDestroyCallbackVar - a unique variable name pointing to an instance of InitializationCallback

getCreationalCallbackVarName

public String getCreationalCallbackVarName()
Description copied from interface: Injector
The unique variable name for a BeanProvider associated with this bean.

Specified by:
getCreationalCallbackVarName in interface Injector
Returns:
the unique variable name for the BeanProvider.

setCreationalCallbackVarName

public void setCreationalCallbackVarName(String creationalCallbackVarName)

matches

public boolean matches(MetaParameterizedType parameterizedType,
                       QualifyingMetadata qualifyingMetadata)
Description copied from interface: Injector
Determines whether or not the the bean type this injector producers matches the specified parameterized type and qualifying metadata.

Specified by:
matches in interface Injector
Parameters:
parameterizedType - the parameterized type to compare against.
qualifyingMetadata - the qualifying metadata to compare against
Returns:
true if matches.

getQualifyingMetadata

public QualifyingMetadata getQualifyingMetadata()
Description copied from interface: Injector
Returns the QualifyingMetadata associated with this injector.

Specified by:
getQualifyingMetadata in interface Injector
Returns:
the qualifying meta data.

getQualifyingTypeInformation

public MetaParameterizedType getQualifyingTypeInformation()
Description copied from interface: Injector
Returns parameterized type data associated with this injector

Specified by:
getQualifyingTypeInformation in interface Injector
Returns:
parameterized type associated with this injector. Null if none.

getProxyInstanceVarName

public String getProxyInstanceVarName()
Description copied from interface: Injector
The unique variable name for the proxied bean instance.

Specified by:
getProxyInstanceVarName in interface Injector
Returns:
the unique variable name for the proxy of the bean in the bootstrapper.

getInstanceVarName

public String getInstanceVarName()
Description copied from interface: Injector
The unique variable name for the bean instance. Usually used to reference the bean during the wiring of the bean within the CreationalContext.getInstance() method body. This variable name is also used to provide a name to variable which holds a reference to singleton instances.

Specified by:
getInstanceVarName in interface Injector
Returns:
the unique variable name for a bean in the bootstrapper and CreationalContext.getInstance() method.

addRegistrationHook

public void addRegistrationHook(RegistrationHook registrationHook)
Description copied from interface: Injector
Adds a registration hook to be triggered when the bean is ready to render its registration to be bean manager

Specified by:
addRegistrationHook in interface Injector
Parameters:
registrationHook - a registration hook to be called at registration of the bean with the bean manager.

registerWithBeanManager

public void registerWithBeanManager(InjectionContext context,
                                    Statement valueRef)

addRenderingHook

public void addRenderingHook(RenderingHook renderingHook)
Description copied from interface: Injector
Adds a RenderingHook which will be triggered when the injector is rendered.

Specified by:
addRenderingHook in interface Injector
Parameters:
renderingHook - an instance of RenderingHook to be called when the injector is rendered.

markRendered

protected void markRendered(InjectableInstance injectableInstance)

toString

public String toString()
Overrides:
toString in class Object

getBeanName

public String getBeanName()
Description copied from interface: Injector
Get the name of the bean (if it has a name). Otherwise return null.

Specified by:
getBeanName in interface Injector
Returns:
the name of the bean. or null if it has no name.

isEnabled

public boolean isEnabled()
Description copied from interface: Injector
Checks if the injector is enabled, and is eligible for injection consideration.

Specified by:
isEnabled in interface Injector
Returns:
true if the injector is enabled

isSoftDisabled

public boolean isSoftDisabled()
Description copied from interface: Injector
Checks if the injector is soft disabled. This is an optimization flag, allowing for the code optimizers to indicate they'd like to remove the underlying bean. Soft disabled injectors will always report as not being enabled, but are subject to reactivation if they are requested for injection.

Specified by:
isSoftDisabled in interface Injector
Returns:
true if the injector is soft disabled.

setSoftDisabled

public void setSoftDisabled(boolean softDisabled)

disableSoftly

protected void disableSoftly()

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: Injector
Set the enabled state of the bean. A bean that has been disabled (set to false), is not eligible for injection.

Specified by:
setEnabled in interface Injector
Parameters:
enabled - the enabled state of the bean to set (true for enabled, false for disabled).

addDisablingHook

public void addDisablingHook(Runnable runnable)
Description copied from interface: Injector
Add a Runnable task to be executed when and if the injector is disabled.

Specified by:
addDisablingHook in interface Injector
Parameters:
runnable - an instance of Runnable to be called if the injector is disabled.

isRegularTypeInjector

public boolean isRegularTypeInjector()
Description copied from interface: Injector
Returns true if the injector type is a regular type injector. (ie. not a proxy injector, producer injector, etc).

Specified by:
isRegularTypeInjector in interface Injector
Returns:
true if the injector is a regular type injector.

hasNewQualifier

protected static boolean hasNewQualifier(InjectableInstance instance)

getConcreteInjectedType

public MetaClass getConcreteInjectedType()
Description copied from interface: Injector
Returns the concrete type that will be returned by this injector.

Specified by:
getConcreteInjectedType in interface Injector
Returns:

getRegistrationHooks

protected List<RegistrationHook> getRegistrationHooks()

getRenderingHooks

protected List<RenderingHook> getRenderingHooks()

getDisablingCallbacks

protected List<Runnable> getDisablingCallbacks()

setAttribute

public void setAttribute(String name,
                         Object value)
Description copied from interface: Injector
Sets a persistent attribute to be associated with this injector.

Specified by:
setAttribute in interface Injector
Parameters:
name - the name of the attribute
value - the value of the attribute.

getAttribute

public Object getAttribute(String name)
Description copied from interface: Injector
Gets a persistent attribute associated with this injector.

Specified by:
getAttribute in interface Injector
Parameters:
name - the name of the attribute
Returns:
the value of the attribute. null if the attribute does not exist.

hasAttribute

public boolean hasAttribute(String name)
Description copied from interface: Injector
Checks if injector has the specified named attribute

Specified by:
hasAttribute in interface Injector
Parameters:
name - the name of the attribute.
Returns:
true if the attribute exists.

getWeavingStatements

public Map<MetaMethod,Map<WeaveType,Collection<Statement>>> getWeavingStatements()

getWeavingStatementsMap

public Map<MetaMethod,Map<WeaveType,Collection<Statement>>> getWeavingStatementsMap()

getProxyPropertyMap

public Map<String,ProxyMaker.ProxyProperty> getProxyPropertyMap()
Description copied from interface: Injector
Returns a map of all proxy properties in the injector. The keys are the names of the property, and the values are ProxyMaker.ProxyProperty references.

Specified by:
getProxyPropertyMap in interface Injector
Returns:
a map of proxy properties.

getAddToEndStatements

public List<Statement> getAddToEndStatements()

addStatementToEndOfInjector

public void addStatementToEndOfInjector(Statement statement)
Add a statement to the end of the bean injector code. Statements added here will be rendered after all other binding activity and right before the injector returns the bean reference.

Specified by:
addStatementToEndOfInjector in interface Injector
Parameters:
statement -

isProxied

public boolean isProxied()
Description copied from interface: Injector
Checks if the injector is a proxied injector. That is to say, the value returned from generated BeanProvider returns a proxy, rather than a direct reference to a bean.

Specified by:
isProxied in interface Injector
Returns:
true if the injector returns a proxied instance.

createProxyDeclaration

public List<Statement> createProxyDeclaration(InjectionContext context)

createProxyDeclaration

public List<Statement> createProxyDeclaration(InjectionContext context,
                                              Statement beanRef)

addInvokeAround

public void addInvokeAround(MetaMethod method,
                            Statement statement)
Description copied from interface: Injector
Adds an invoke around statement on the specified method. Calling this method automatically converts this injector into a proxied injector, as AOP activities must be done through the creation of a proxy.

Specified by:
addInvokeAround in interface Injector
Parameters:
method - the method to invoke around
statement - the statement to execute.

addInvokeBefore

public void addInvokeBefore(MetaMethod method,
                            Statement statement)
Description copied from interface: Injector
Adds an invoke before statement on the specified method. Calling this method automatically converts this injector into a proxied injector, as AOP activities must be done through the creation of a proxy.

Specified by:
addInvokeBefore in interface Injector
Parameters:
method - the method to invoke around
statement - the statement to execute.

addInvokeAfter

public void addInvokeAfter(MetaMethod method,
                           Statement statement)
Description copied from interface: Injector
Adds an invoke after statement on the specified method. Calling this method automatically converts this injector into a proxied injector, as AOP activities must be done through the creation of a proxy.

Specified by:
addInvokeAfter in interface Injector
Parameters:
method - the method to invoke around
statement - the statement to execute.

addProxyProperty

public ProxyMaker.ProxyProperty addProxyProperty(String propertyName,
                                                 Class type,
                                                 Statement statement)
Description copied from interface: Injector
Adds a proxy property to the generated proxy. Effectively this means the proxy will be given an instance field to hold the value yielded by the specified statement.

Specified by:
addProxyProperty in interface Injector
Parameters:
propertyName - the name of the property.
type - the type of the property.
statement - the statement which will yield the value to be put into the property.
Returns:
a ProxyMaker.ProxyProperty reference which can be used as a regular statement reference in Errai Codegen. The instance of ProxyProperty can be used in generated code (such as in AOP statements) to refer to the injected proxy property.

addProxyProperty

public ProxyMaker.ProxyProperty addProxyProperty(String propertyName,
                                                 MetaClass type,
                                                 Statement statementReference)
Description copied from interface: Injector
Adds a proxy property to the generated proxy. Effectively this means the proxy will be given an instance field to hold the value yielded by the specified statement.

Specified by:
addProxyProperty in interface Injector
Parameters:
propertyName - the name of the property.
type - the type of the property.
statementReference - the statement which will yield the value to be put into the property.
Returns:
a ProxyMaker.ProxyProperty reference which can be used as a regular statement reference in Errai Codegen. The instance of ProxyProperty can be used in generated code (such as in AOP statements) to refer to the injected proxy property.

updateProxies

public void updateProxies()
Description copied from interface: Injector
This method should be called to ensure that the proxies have been updated to reflect any code weavings that may have been added.

Specified by:
updateProxies in interface Injector

getMetadataWithAny

public static QualifyingMetadata getMetadataWithAny(QualifyingMetadata metadata)

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.