org.objectweb.easybeans.deployment.xml.helper
Class MetadataMerge

java.lang.Object
  extended by org.objectweb.easybeans.deployment.xml.helper.MetadataMerge

public final class MetadataMerge
extends java.lang.Object

This class merge the information of the struct representing EJB DD into the metadata.

Author:
Florent Benoit

Field Summary
private  EjbJarAnnotationMetadata ejbMetadata
          Metadata for an ejb-jar.
static java.lang.String JAVA_LANG_OBJECT
          Defines java.lang.Object class.
private static JLog logger
          Logger.
private static java.lang.String WILDCARD
          Wildcard attribute.
 
Constructor Summary
private MetadataMerge(EjbJarAnnotationMetadata ejbMetadata)
          Helper class, no public constructor.
 
Method Summary
private  void addInterceptorForClass(ClassAnnotationMetadata classAnnotationMetadata, java.lang.String interceptorClassName)
          Adds a link on the given class to the interceptor class.
private  void applyAroundInvoke(java.util.List<AroundInvoke> aroundInvokeList, ClassAnnotationMetadata classAnnotationMetadata, java.lang.String type)
          Apply rules for a common bean (method callbacks).
private  void applyCommonBean(AbsBean bean, ClassAnnotationMetadata classAnnotationMetadata)
          Apply rules for a common bean.
private  void applyEjbLocalRef(java.util.List<EJBLocalRef> ejbLocalRefList, ClassAnnotationMetadata classAnnotationMetadata)
          Apply rules for a common bean (ejb-local-ref).
private  void applyEjbRef(java.util.List<EJBRef> ejbRefList, ClassAnnotationMetadata classAnnotationMetadata)
          Apply rules for a common bean (ejb-ref).
private  void applyInterceptor(java.lang.String type, java.lang.String interceptorClassName, java.lang.String methodName, ClassAnnotationMetadata classAnnotationMetadata)
          Finds a method in the interceptor class and set the correct type value.
private  void applyInterceptors(Interceptors interceptors)
          Apply rules for the interceptors defined in the XML DD.
private static void applyJEJB(JEjbEJB jEJB, ClassAnnotationMetadata classAnnotationMetadata, java.util.List<InjectionTarget> injectionTargetList)
          Adds the given @EJB object to the class and apply it also on injection target elements.
private  void applyJndiEnvironmentRefsGroup(AbsEnvironment envGroup, ClassAnnotationMetadata classAnnotationMetadata)
          Apply rules for a an environment.
private static void applyJResource(JAnnotationResource jResource, ClassAnnotationMetadata classAnnotationMetadata, java.util.List<InjectionTarget> injectionTargetList)
          Adds the given @Resource object to the class and apply it also on injection target elements.
private  void applyLifeCycle(java.util.List<LifeCycleCallback> lifecycleList, ClassAnnotationMetadata classAnnotationMetadata, java.lang.String type)
          Apply rules for a common bean (lifecycle callbacks).
private  void applyResourceEnvRef(java.util.List<ResourceEnvRef> resourceEnvRefList, ClassAnnotationMetadata classAnnotationMetadata)
          Apply rules for a common bean (resource-env-ref).
private  void applyResourceRef(java.util.List<ResourceRef> resourceRefList, ClassAnnotationMetadata classAnnotationMetadata)
          Apply rules for a common bean (resource-ref).
private  void applySessionBean(Session sessionbean, ClassAnnotationMetadata classAnnotationMetadata)
          Apply rules for a session bean.
private static JEjbEJB buildEJB(AbsEJBRef ref)
          Build an @EJB impl for the given ejb-ref/ejb-local-ref.
private static java.lang.String encode(java.lang.String className)
          Encode a classname (replace .
private  ClassAnnotationMetadata findClassForEjb(java.lang.String ejbName, java.lang.String ejbClass)
          Find/Gets a classAnnotationMetadata for a given ejb name and/or a given ejbclass name.
private static FieldAnnotationMetadata getField(ClassAnnotationMetadata classAnnotationMetadata, InjectionTarget injectionTarget)
          Gets the field metadata for a given injection target.
private static java.util.List<MethodAnnotationMetadata> getMethodsForGivenMethodDD(MethodDD methodDD, ClassAnnotationMetadata classAnnotationMetadata)
          Gets the methods metadata that are matching a given method DD.
static void merge(EjbJarAnnotationMetadata ejbMetadata)
          Takes struct of metadata and adds/set information on class/methods metadata.
 void mergeApplicationException(AssemblyDescriptor assemblyDescriptor)
          Set/override the current application-exception.
 void mergeInterceptorBinding(AssemblyDescriptor assemblyDescriptor)
          Set/override the current interceptor-binding.
private  void resolve()
          Do all merging operations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WILDCARD

private static final java.lang.String WILDCARD
Wildcard attribute.

See Also:
Constant Field Values

JAVA_LANG_OBJECT

public static final java.lang.String JAVA_LANG_OBJECT
Defines java.lang.Object class.

See Also:
Constant Field Values

ejbMetadata

private EjbJarAnnotationMetadata ejbMetadata
Metadata for an ejb-jar.


logger

private static JLog logger
Logger.

Constructor Detail

MetadataMerge

private MetadataMerge(EjbJarAnnotationMetadata ejbMetadata)
Helper class, no public constructor.

Parameters:
ejbMetadata - the metadata corresponding to an EJB-JAR file.
Method Detail

merge

public static void merge(EjbJarAnnotationMetadata ejbMetadata)
Takes struct of metadata and adds/set information on class/methods metadata.

Parameters:
ejbMetadata - the metadata corresponding to an EJB-JAR file.

resolve

private void resolve()
Do all merging operations.


applyInterceptors

private void applyInterceptors(Interceptors interceptors)
Apply rules for the interceptors defined in the XML DD.

Parameters:
interceptors - the interceptors struct representing <interceptors> element

applySessionBean

private void applySessionBean(Session sessionbean,
                              ClassAnnotationMetadata classAnnotationMetadata)
Apply rules for a session bean.

Parameters:
sessionbean - the struct (XML DD)
classAnnotationMetadata - (Annotation metadata)

applyCommonBean

private void applyCommonBean(AbsBean bean,
                             ClassAnnotationMetadata classAnnotationMetadata)
Apply rules for a common bean.

Parameters:
bean - the struct (XML DD)
classAnnotationMetadata - (Annotation metadata)

applyJndiEnvironmentRefsGroup

private void applyJndiEnvironmentRefsGroup(AbsEnvironment envGroup,
                                           ClassAnnotationMetadata classAnnotationMetadata)
Apply rules for a an environment.

Parameters:
envGroup - the struct (XML DD)
classAnnotationMetadata - (Annotation metadata)

applyResourceRef

private void applyResourceRef(java.util.List<ResourceRef> resourceRefList,
                              ClassAnnotationMetadata classAnnotationMetadata)
Apply rules for a common bean (resource-ref).

Parameters:
resourceRefList - the list of resource-ref.
classAnnotationMetadata - (Annotation metadata) of the bean using this interceptor (may be null).

applyResourceEnvRef

private void applyResourceEnvRef(java.util.List<ResourceEnvRef> resourceEnvRefList,
                                 ClassAnnotationMetadata classAnnotationMetadata)
Apply rules for a common bean (resource-env-ref).

Parameters:
resourceEnvRefList - the list of resource-env-ref.
classAnnotationMetadata - (Annotation metadata) of the bean using this interceptor (may be null).

applyEjbRef

private void applyEjbRef(java.util.List<EJBRef> ejbRefList,
                         ClassAnnotationMetadata classAnnotationMetadata)
Apply rules for a common bean (ejb-ref).

Parameters:
ejbRefList - the list of ejb-ref.
classAnnotationMetadata - (Annotation metadata) of the bean using this interceptor (may be null).

applyEjbLocalRef

private void applyEjbLocalRef(java.util.List<EJBLocalRef> ejbLocalRefList,
                              ClassAnnotationMetadata classAnnotationMetadata)
Apply rules for a common bean (ejb-local-ref).

Parameters:
ejbLocalRefList - the list of ejb-local-ref.
classAnnotationMetadata - (Annotation metadata) of the bean using this interceptor (may be null).

applyJResource

private static void applyJResource(JAnnotationResource jResource,
                                   ClassAnnotationMetadata classAnnotationMetadata,
                                   java.util.List<InjectionTarget> injectionTargetList)
Adds the given @Resource object to the class and apply it also on injection target elements.

Parameters:
jResource - an @Resource impl
classAnnotationMetadata - the bean's class
injectionTargetList - the list of injection fields to set

getField

private static FieldAnnotationMetadata getField(ClassAnnotationMetadata classAnnotationMetadata,
                                                InjectionTarget injectionTarget)
Gets the field metadata for a given injection target.

Parameters:
classAnnotationMetadata - the class used to search the target element
injectionTarget - the given target info element
Returns:
a field if element is found

applyJEJB

private static void applyJEJB(JEjbEJB jEJB,
                              ClassAnnotationMetadata classAnnotationMetadata,
                              java.util.List<InjectionTarget> injectionTargetList)
Adds the given @EJB object to the class and apply it also on injection target elements.

Parameters:
jEJB - an @EJB impl
classAnnotationMetadata - the bean's class
injectionTargetList - the list of injection fields to set

buildEJB

private static JEjbEJB buildEJB(AbsEJBRef ref)
Build an @EJB impl for the given ejb-ref/ejb-local-ref.

Parameters:
ref - an instance of a ejb-ref/ejb-local-ref.
Returns:
a implementation of @EJB interface.

applyAroundInvoke

private void applyAroundInvoke(java.util.List<AroundInvoke> aroundInvokeList,
                               ClassAnnotationMetadata classAnnotationMetadata,
                               java.lang.String type)
Apply rules for a common bean (method callbacks).

Parameters:
aroundInvokeList - the list of method/aroundInvoke callbacks.
classAnnotationMetadata - (Annotation metadata) of the bean using this interceptor (may be null).
type - the type of lifecycle.

applyLifeCycle

private void applyLifeCycle(java.util.List<LifeCycleCallback> lifecycleList,
                            ClassAnnotationMetadata classAnnotationMetadata,
                            java.lang.String type)
Apply rules for a common bean (lifecycle callbacks).

Parameters:
lifecycleList - the list of lifecycle callbacks.
classAnnotationMetadata - (Annotation metadata) of the bean using this interceptor (may be null).
type - the type of lifecycle.

addInterceptorForClass

private void addInterceptorForClass(ClassAnnotationMetadata classAnnotationMetadata,
                                    java.lang.String interceptorClassName)
Adds a link on the given class to the interceptor class.

Parameters:
classAnnotationMetadata - the class that will use/import the interceptor
interceptorClassName - the interceptor class.

applyInterceptor

private void applyInterceptor(java.lang.String type,
                              java.lang.String interceptorClassName,
                              java.lang.String methodName,
                              ClassAnnotationMetadata classAnnotationMetadata)
Finds a method in the interceptor class and set the correct type value.

Parameters:
type - type of interceptor
interceptorClassName - the name of the interceptor class
methodName - the name of the method in the interceptor class
classAnnotationMetadata - the class that is using the interceptor (may be null)

findClassForEjb

private ClassAnnotationMetadata findClassForEjb(java.lang.String ejbName,
                                                java.lang.String ejbClass)
Find/Gets a classAnnotationMetadata for a given ejb name and/or a given ejbclass name.

Parameters:
ejbName - the name of the EJB.
ejbClass - the class of the EJB.
Returns:
a classAnnotationMetadata if found, else exception

mergeApplicationException

public void mergeApplicationException(AssemblyDescriptor assemblyDescriptor)
Set/override the current application-exception.

Parameters:
assemblyDescriptor - the given assembly descriptor to analyze.

mergeInterceptorBinding

public void mergeInterceptorBinding(AssemblyDescriptor assemblyDescriptor)
Set/override the current interceptor-binding.

Parameters:
assemblyDescriptor - the given assembly descriptor to analyze.

getMethodsForGivenMethodDD

private static java.util.List<MethodAnnotationMetadata> getMethodsForGivenMethodDD(MethodDD methodDD,
                                                                                   ClassAnnotationMetadata classAnnotationMetadata)
Gets the methods metadata that are matching a given method DD.

Parameters:
methodDD - the methodDD object
classAnnotationMetadata - the class where to search methods.
Returns:
the list of methods metadata

encode

private static java.lang.String encode(java.lang.String className)
Encode a classname (replace . by /) as it's the internal form of the metadata

Parameters:
className - the name of the class to encode
Returns:
encoded name