Search in sources :

Example 1 with InitMethodMetaData

use of org.jboss.metadata.ejb.spec.InitMethodMetaData in project wildfly by wildfly.

the class InitMethodMergingProcessor method handleDeploymentDescriptor.

@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final StatefulComponentDescription description) throws DeploymentUnitProcessingException {
    // first look for old school ejbCreate methods
    // we are only looking on the bean class, not sure if that is correct or not
    Class<?> clazz = componentClass;
    while (clazz != Object.class && clazz != null) {
        final ClassReflectionIndex index = deploymentReflectionIndex.getClassIndex(clazz);
        for (Method method : (Iterable<Method>) index.getMethods()) {
            // it will be overridden below
            if (method.getName().startsWith("ejbCreate") && !description.getInitMethods().containsKey(method)) {
                description.addInitMethod(method, null);
            }
        }
        clazz = clazz.getSuperclass();
    }
    SessionBeanMetaData data = description.getDescriptorData();
    if (data instanceof SessionBean31MetaData) {
        SessionBean31MetaData metaData = (SessionBean31MetaData) data;
        final InitMethodsMetaData inits = metaData.getInitMethods();
        if (inits != null) {
            for (InitMethodMetaData method : inits) {
                Method beanMethod = MethodResolutionUtils.resolveMethod(method.getBeanMethod(), componentClass, deploymentReflectionIndex);
                if (method.getCreateMethod() != null) {
                    description.addInitMethod(beanMethod, method.getCreateMethod().getMethodName());
                } else {
                    description.addInitMethod(beanMethod, null);
                }
            }
        }
    }
}
Also used : InitMethodMetaData(org.jboss.metadata.ejb.spec.InitMethodMetaData) InitMethodsMetaData(org.jboss.metadata.ejb.spec.InitMethodsMetaData) SessionBeanMetaData(org.jboss.metadata.ejb.spec.SessionBeanMetaData) ClassReflectionIndex(org.jboss.as.server.deployment.reflect.ClassReflectionIndex) Method(java.lang.reflect.Method) SessionBean31MetaData(org.jboss.metadata.ejb.spec.SessionBean31MetaData)

Aggregations

Method (java.lang.reflect.Method)1 ClassReflectionIndex (org.jboss.as.server.deployment.reflect.ClassReflectionIndex)1 InitMethodMetaData (org.jboss.metadata.ejb.spec.InitMethodMetaData)1 InitMethodsMetaData (org.jboss.metadata.ejb.spec.InitMethodsMetaData)1 SessionBean31MetaData (org.jboss.metadata.ejb.spec.SessionBean31MetaData)1 SessionBeanMetaData (org.jboss.metadata.ejb.spec.SessionBeanMetaData)1