Errai 3.0.1-SNAPSHOT

org.jboss.errai.ioc.rebind.ioc.injector
Interface Injector

All Known Implementing Classes:
AbstractAsyncInjector, AbstractInjector, AsyncContextualProviderInjector, AsyncProducerInjector, AsyncProviderInjector, AsyncProxyInjector, AsyncQualifiedTypeInjectorDelegate, AsyncTypeInjector, ContextualProviderInjector, ProducerInjector, ProviderInjector, ProxyInjector, QualifiedTypeInjectorDelegate, TypeInjector

public interface Injector

Defines an injector which is responsible for providing instance references of beans to the code generating container.

Author:
Mike Brock

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 statement)
          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)
          Adds a statement to be appended to the end of the generated BeanProvider code.
 Object getAttribute(String name)
          Gets a persistent attribute associated with this injector.
 Statement getBeanInstance(InjectableInstance injectableInstance)
          Return a statement providing access to the injector (or null for asynchronous logic)
 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.
 MetaClass getEnclosingType()
          The enclosing type of the injector.
 MetaClass getInjectedType()
          The injected type of the injector.
 String getInstanceVarName()
          The unique variable name for the bean instance.
 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
 boolean hasAttribute(String name)
          Checks if injector has the specified named attribute
 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.
 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 renderProvider(InjectableInstance injectableInstance)
           
 void setAttribute(String name, Object value)
          Sets a persistent attribute to be associated with this injector.
 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 updateProxies()
          This method should be called to ensure that the proxies have been updated to reflect any code weavings that may have been added.
 

Method Detail

renderProvider

void renderProvider(InjectableInstance injectableInstance)

getBeanInstance

Statement getBeanInstance(InjectableInstance injectableInstance)
Return a statement providing access to the injector (or null for asynchronous logic)

Parameters:
injectableInstance -
Returns:

isEnabled

boolean isEnabled()
Checks if the injector is enabled, and is eligible for injection consideration.

Returns:
true if the injector is enabled

isSoftDisabled

boolean isSoftDisabled()
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.

Returns:
true if the injector is soft disabled.

isTestMock

boolean isTestMock()
Checks if the injector represents a test mock.

Returns:
true if the injector is a test mock

isAlternative

boolean isAlternative()
Checks if the injector an alternative.

Returns:
true if the injector is an alternative

isRendered

boolean isRendered()
Checks if the injector's BeanProvider already been rendered.

Returns:
true if the creational callback has already been rendered.

isCreated

boolean isCreated()
Checks if construction has begun.

Returns:

isSingleton

boolean isSingleton()
Checks if the injector for a singleton bean.

Returns:
true if the injector handles a singleton bean.

isDependent

boolean isDependent()
Check if the injector if of the dependent scope.

Returns:
true if the injector is of a dependent scope.

isPseudo

boolean isPseudo()
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.

Returns:
true if the injector is for a psuedo bean.

isProvider

boolean isProvider()
Checks if the injector represents a provider.

Returns:
true if the injector is for a provider.

isStatic

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.

Returns:
true if the injector is a static injector

getEnclosingType

MetaClass getEnclosingType()
The enclosing type of the injector. For producer injectors, this method will return the bean which the producer method is a member.

Returns:
the enclosing bean type of the injector, if applicable. Null if not applicable.

getInjectedType

MetaClass getInjectedType()
The injected type of the injector. This is the absolute type which the injector produces. For producers, this is the bean type which the producer method returns.

Returns:
the return type from the injector.

getConcreteInjectedType

MetaClass getConcreteInjectedType()
Returns the concrete type that will be returned by this injector.

Returns:

getInstanceVarName

String getInstanceVarName()
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.

Returns:
the unique variable name for a bean in the bootstrapper and CreationalContext.getInstance() method.

getProxyInstanceVarName

String getProxyInstanceVarName()
The unique variable name for the proxied bean instance.

Returns:
the unique variable name for the proxy of the bean in the bootstrapper.

getPostInitCallbackVar

String getPostInitCallbackVar()
The unique variable name for the InitalizationCallback associated with a bean CreationalContext in the boostrapper method.

Returns:
the unique variable name for an InitializationCallback instance. Null if none.

setPostInitCallbackVar

void setPostInitCallbackVar(String var)
Sets a variable name reference to the InitializationCallback to associate with the BeanProvider for this bean.

Parameters:
var - a unique variable name pointing to an instance of InitializationCallback.

getPreDestroyCallbackVar

String getPreDestroyCallbackVar()
The unique variable name for the DestructionCallback associated with the BeanProvider for this bean.

Returns:
the unique variable name for a DestructionCallback instance. Null if none.

setPreDestroyCallbackVar

void setPreDestroyCallbackVar(String preDestroyCallbackVar)
Sets a variable name reference to the DestructionCallback to associate with this BeanProvider for this bean.

Parameters:
preDestroyCallbackVar - a unique variable name pointing to an instance of InitializationCallback

getCreationalCallbackVarName

String getCreationalCallbackVarName()
The unique variable name for a BeanProvider associated with this bean.

Returns:
the unique variable name for the BeanProvider.

matches

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.

Parameters:
parameterizedType - the parameterized type to compare against.
qualifyingMetadata - the qualifying metadata to compare against
Returns:
true if matches.

getQualifyingMetadata

QualifyingMetadata getQualifyingMetadata()
Returns the QualifyingMetadata associated with this injector.

Returns:
the qualifying meta data.

getQualifyingTypeInformation

MetaParameterizedType getQualifyingTypeInformation()
Returns parameterized type data associated with this injector

Returns:
parameterized type associated with this injector. Null if none.

addRegistrationHook

void addRegistrationHook(RegistrationHook registrationHook)
Adds a registration hook to be triggered when the bean is ready to render its registration to be bean manager

Parameters:
registrationHook - a registration hook to be called at registration of the bean with the bean manager.

addRenderingHook

void addRenderingHook(RenderingHook renderingHook)
Adds a RenderingHook which will be triggered when the injector is rendered.

Parameters:
renderingHook - an instance of RenderingHook to be called when the injector is rendered.

addDisablingHook

void addDisablingHook(Runnable runnable)
Add a Runnable task to be executed when and if the injector is disabled.

Parameters:
runnable - an instance of Runnable to be called if the injector is disabled.

getBeanName

String getBeanName()
Get the name of the bean (if it has a name). Otherwise return null.

Returns:
the name of the bean. or null if it has no name.

setEnabled

void setEnabled(boolean enabled)
Set the enabled state of the bean. A bean that has been disabled (set to false), is not eligible for injection.

Parameters:
enabled - the enabled state of the bean to set (true for enabled, false for disabled).

isRegularTypeInjector

boolean isRegularTypeInjector()
Returns true if the injector type is a regular type injector. (ie. not a proxy injector, producer injector, etc).

Returns:
true if the injector is a regular type injector.

setAttribute

void setAttribute(String name,
                  Object value)
Sets a persistent attribute to be associated with this injector.

Parameters:
name - the name of the attribute
value - the value of the attribute.

getAttribute

Object getAttribute(String name)
Gets a persistent attribute associated with this injector.

Parameters:
name - the name of the attribute
Returns:
the value of the attribute. null if the attribute does not exist.

hasAttribute

boolean hasAttribute(String name)
Checks if injector has the specified named attribute

Parameters:
name - the name of the attribute.
Returns:
true if the attribute exists.

isProxied

boolean isProxied()
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.

Returns:
true if the injector returns a proxied instance.

addStatementToEndOfInjector

void addStatementToEndOfInjector(Statement statement)
Adds a statement to be appended to the end of the generated BeanProvider code. Statements added here will be executed after all bean wiring activity has finished.

Parameters:
statement -

addInvokeAround

void addInvokeAround(MetaMethod method,
                     Statement statement)
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.

Parameters:
method - the method to invoke around
statement - the statement to execute.

addInvokeBefore

void addInvokeBefore(MetaMethod method,
                     Statement statement)
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.

Parameters:
method - the method to invoke around
statement - the statement to execute.

addInvokeAfter

void addInvokeAfter(MetaMethod method,
                    Statement statement)
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.

Parameters:
method - the method to invoke around
statement - the statement to execute.

addProxyProperty

ProxyMaker.ProxyProperty addProxyProperty(String propertyName,
                                          Class type,
                                          Statement statement)
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.

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

ProxyMaker.ProxyProperty addProxyProperty(String propertyName,
                                          MetaClass type,
                                          Statement statement)
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.

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.

getProxyPropertyMap

Map<String,ProxyMaker.ProxyProperty> getProxyPropertyMap()
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.

Returns:
a map of proxy properties.

updateProxies

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.


Errai 3.0.1-SNAPSHOT

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