Search in sources :

Example 1 with EnterpriseBeanMetaData

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

the class AbstractDeploymentUnitProcessor method processDeploymentDescriptor.

protected void processDeploymentDescriptor(final DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException {
    // find the EJB jar metadata and start processing it
    final EjbJarMetaData ejbJarMetaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
    if (ejbJarMetaData == null) {
        return;
    }
    final SimpleSet<String> annotatedEJBs;
    if (appclient) {
        final List<ComponentDescription> additionalComponents = deploymentUnit.getAttachmentList(org.jboss.as.ee.component.Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS);
        annotatedEJBs = new SimpleSet<String>() {

            @Override
            public boolean contains(Object o) {
                for (final ComponentDescription component : additionalComponents) {
                    if (component.getComponentName().equals(o)) {
                        return true;
                    }
                }
                return false;
            }
        };
    } else {
        final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit);
        annotatedEJBs = new SimpleSet<String>() {

            @Override
            public boolean contains(Object o) {
                return ejbJarDescription.hasComponent((String) o);
            }
        };
    }
    // process EJBs
    final EnterpriseBeansMetaData ejbs = ejbJarMetaData.getEnterpriseBeans();
    if (ejbs != null && !ejbs.isEmpty()) {
        for (final EnterpriseBeanMetaData ejb : ejbs) {
            final String beanName = ejb.getName();
            // the important bit is to skip already processed EJBs via annotations
            if (annotatedEJBs.contains(beanName)) {
                continue;
            }
            processBeanMetaData(deploymentUnit, ejb);
        }
    }
    EjbDeploymentMarker.mark(deploymentUnit);
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EnterpriseBeansMetaData(org.jboss.metadata.ejb.spec.EnterpriseBeansMetaData) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) EjbJarDescription(org.jboss.as.ejb3.deployment.EjbJarDescription) EnterpriseBeanMetaData(org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData)

Example 2 with EnterpriseBeanMetaData

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

the class AbstractEjbXmlDescriptorProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    // get the deployment unit
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    // find the Jakarta Enterprise Beans jar metadata and start processing it
    EjbJarMetaData ejbJarMetaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
    if (ejbJarMetaData == null) {
        return;
    }
    // process Jakarta Enterprise Beans
    EnterpriseBeansMetaData ejbs = ejbJarMetaData.getEnterpriseBeans();
    if (ejbs != null && !ejbs.isEmpty()) {
        for (EnterpriseBeanMetaData ejb : ejbs) {
            if (this.getMetaDataType().isInstance(ejb)) {
                this.processBeanMetaData((T) ejb, phaseContext);
            }
        }
    }
}
Also used : EnterpriseBeansMetaData(org.jboss.metadata.ejb.spec.EnterpriseBeansMetaData) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) EnterpriseBeanMetaData(org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 3 with EnterpriseBeanMetaData

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

the class DeploymentDescriptorMethodProcessor method handleSessionBean.

private void handleSessionBean(final EJBComponentDescription component, final Module module, final DeploymentReflectionIndex reflectionIndex) throws ClassNotFoundException, DeploymentUnitProcessingException {
    if (component.getDescriptorData() == null) {
        return;
    }
    final Class<?> componentClass = ClassLoadingUtils.loadClass(component.getComponentClassName(), module);
    final EnterpriseBeanMetaData metaData = component.getDescriptorData();
    AroundInvokesMetaData aroundInvokes = null;
    if (metaData instanceof SessionBeanMetaData) {
        aroundInvokes = ((SessionBeanMetaData) metaData).getAroundInvokes();
    } else if (metaData instanceof MessageDrivenBeanMetaData) {
        aroundInvokes = ((MessageDrivenBeanMetaData) metaData).getAroundInvokes();
    }
    if (aroundInvokes != null) {
        for (AroundInvokeMetaData aroundInvoke : aroundInvokes) {
            final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
            String methodName = aroundInvoke.getMethodName();
            MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(Object.class, methodName, InvocationContext.class);
            builder.setAroundInvoke(methodIdentifier);
            if (aroundInvoke.getClassName() == null || aroundInvoke.getClassName().isEmpty()) {
                final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName();
                component.addInterceptorMethodOverride(className, builder.build());
            } else {
                component.addInterceptorMethodOverride(aroundInvoke.getClassName(), builder.build());
            }
        }
    }
    // post-construct(s) of the interceptor configured (if any) in the deployment descriptor
    LifecycleCallbacksMetaData postConstructs = metaData.getPostConstructs();
    if (postConstructs != null) {
        for (LifecycleCallbackMetaData postConstruct : postConstructs) {
            final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
            String methodName = postConstruct.getMethodName();
            MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName);
            builder.setPostConstruct(methodIdentifier);
            if (postConstruct.getClassName() == null || postConstruct.getClassName().isEmpty()) {
                final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName();
                component.addInterceptorMethodOverride(className, builder.build());
            } else {
                component.addInterceptorMethodOverride(postConstruct.getClassName(), builder.build());
            }
        }
    }
    // pre-destroy(s) of the interceptor configured (if any) in the deployment descriptor
    final LifecycleCallbacksMetaData preDestroys = metaData.getPreDestroys();
    if (preDestroys != null) {
        for (final LifecycleCallbackMetaData preDestroy : preDestroys) {
            final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
            final String methodName = preDestroy.getMethodName();
            final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName);
            builder.setPreDestroy(methodIdentifier);
            if (preDestroy.getClassName() == null || preDestroy.getClassName().isEmpty()) {
                final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName();
                component.addInterceptorMethodOverride(className, builder.build());
            } else {
                component.addInterceptorMethodOverride(preDestroy.getClassName(), builder.build());
            }
        }
    }
    if (component.isStateful()) {
        final SessionBeanMetaData sessionBeanMetadata = (SessionBeanMetaData) metaData;
        // pre-passivate(s) of the interceptor configured (if any) in the deployment descriptor
        final LifecycleCallbacksMetaData prePassivates = sessionBeanMetadata.getPrePassivates();
        if (prePassivates != null) {
            for (final LifecycleCallbackMetaData prePassivate : prePassivates) {
                final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
                final String methodName = prePassivate.getMethodName();
                final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName);
                builder.setPrePassivate(methodIdentifier);
                if (prePassivate.getClassName() == null || prePassivate.getClassName().isEmpty()) {
                    final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName();
                    component.addInterceptorMethodOverride(className, builder.build());
                } else {
                    component.addInterceptorMethodOverride(prePassivate.getClassName(), builder.build());
                }
            }
        }
        final LifecycleCallbacksMetaData postActivates = sessionBeanMetadata.getPostActivates();
        if (postActivates != null) {
            for (final LifecycleCallbackMetaData postActivate : postActivates) {
                final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
                final String methodName = postActivate.getMethodName();
                final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName);
                builder.setPostActivate(methodIdentifier);
                if (postActivate.getClassName() == null || postActivate.getClassName().isEmpty()) {
                    final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName();
                    component.addInterceptorMethodOverride(className, builder.build());
                } else {
                    component.addInterceptorMethodOverride(postActivate.getClassName(), builder.build());
                }
            }
        }
    }
}
Also used : AroundInvokesMetaData(org.jboss.metadata.ejb.spec.AroundInvokesMetaData) InterceptorClassDescription(org.jboss.as.ee.component.interceptors.InterceptorClassDescription) MessageDrivenBeanMetaData(org.jboss.metadata.ejb.spec.MessageDrivenBeanMetaData) SessionBeanMetaData(org.jboss.metadata.ejb.spec.SessionBeanMetaData) LifecycleCallbackMetaData(org.jboss.metadata.javaee.spec.LifecycleCallbackMetaData) AroundInvokeMetaData(org.jboss.metadata.ejb.spec.AroundInvokeMetaData) MethodIdentifier(org.jboss.invocation.proxy.MethodIdentifier) EnterpriseBeanMetaData(org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData) LifecycleCallbacksMetaData(org.jboss.metadata.javaee.spec.LifecycleCallbacksMetaData)

Example 4 with EnterpriseBeanMetaData

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

the class TimerMethodMergingProcessor method handleDeploymentDescriptor.

@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription description) throws DeploymentUnitProcessingException {
    final EnterpriseBeanMetaData descriptorData = description.getDescriptorData();
    if (descriptorData != null && (description.isSession() || description.isMessageDriven())) {
        assert descriptorData instanceof ITimeoutTarget : descriptorData + " is not an ITimeoutTarget";
        ITimeoutTarget target = (ITimeoutTarget) descriptorData;
        if (target.getTimeoutMethod() != null) {
            parseTimeoutMethod(target, description, componentClass, deploymentReflectionIndex);
        }
        parseScheduleMethods(descriptorData, description, componentClass, deploymentReflectionIndex);
    }
    // or the method specified in the deployment descriptor
    if (TimedObject.class.isAssignableFrom(componentClass)) {
        Class<?> c = componentClass;
        while (c != null && c != Object.class) {
            final ClassReflectionIndex index = deploymentReflectionIndex.getClassIndex(c);
            // TimedObject takes precedence
            Method method = index.getMethod(Void.TYPE, "ejbTimeout", javax.ejb.Timer.class);
            if (method != null) {
                final Method otherMethod = description.getTimeoutMethod();
                if (otherMethod != null && !otherMethod.equals(method)) {
                    throw EjbLogger.ROOT_LOGGER.invalidEjbEntityTimeout("3.1 18.2.5.3", componentClass);
                }
                description.setTimeoutMethod(method);
                break;
            }
            c = c.getSuperclass();
        }
    }
}
Also used : ITimeoutTarget(org.jboss.metadata.ejb.common.ITimeoutTarget) ClassReflectionIndex(org.jboss.as.server.deployment.reflect.ClassReflectionIndex) TimedObject(javax.ejb.TimedObject) Method(java.lang.reflect.Method) EnterpriseBeanMetaData(org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData)

Example 5 with EnterpriseBeanMetaData

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

the class TransactionManagementMergingProcessor method handleDeploymentDescriptor.

@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription componentConfiguration) throws DeploymentUnitProcessingException {
    final EnterpriseBeanMetaData beanMetaData = componentConfiguration.getDescriptorData();
    if (componentConfiguration.isEntity() || beanMetaData == null) {
        return;
    }
    final TransactionManagementType type = componentConfiguration.getDescriptorData().getTransactionType();
    if (type != null) {
        componentConfiguration.setTransactionManagementType(type);
    }
}
Also used : TransactionManagementType(javax.ejb.TransactionManagementType) EnterpriseBeanMetaData(org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData)

Aggregations

EnterpriseBeanMetaData (org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData)6 EjbJarMetaData (org.jboss.metadata.ejb.spec.EjbJarMetaData)3 EnterpriseBeansMetaData (org.jboss.metadata.ejb.spec.EnterpriseBeansMetaData)3 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)2 EjbJarDescription (org.jboss.as.ejb3.deployment.EjbJarDescription)2 Method (java.lang.reflect.Method)1 TimedObject (javax.ejb.TimedObject)1 TransactionManagementType (javax.ejb.TransactionManagementType)1 InterceptorClassDescription (org.jboss.as.ee.component.interceptors.InterceptorClassDescription)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 ClassReflectionIndex (org.jboss.as.server.deployment.reflect.ClassReflectionIndex)1 MethodIdentifier (org.jboss.invocation.proxy.MethodIdentifier)1 ITimeoutTarget (org.jboss.metadata.ejb.common.ITimeoutTarget)1 AroundInvokeMetaData (org.jboss.metadata.ejb.spec.AroundInvokeMetaData)1 AroundInvokesMetaData (org.jboss.metadata.ejb.spec.AroundInvokesMetaData)1 MessageDrivenBeanMetaData (org.jboss.metadata.ejb.spec.MessageDrivenBeanMetaData)1 SessionBeanMetaData (org.jboss.metadata.ejb.spec.SessionBeanMetaData)1 LifecycleCallbackMetaData (org.jboss.metadata.javaee.spec.LifecycleCallbackMetaData)1 LifecycleCallbacksMetaData (org.jboss.metadata.javaee.spec.LifecycleCallbacksMetaData)1