Search in sources :

Example 16 with EJBComponentDescription

use of org.jboss.as.ejb3.component.EJBComponentDescription in project wildfly by wildfly.

the class TimerMethodMergingProcessor method parseScheduleMethods.

private void parseScheduleMethods(final EnterpriseBeanMetaData beanMetaData, final EJBComponentDescription sessionBean, final Class<?> componentClass, final DeploymentReflectionIndex deploymentReflectionIndex) throws DeploymentUnitProcessingException {
    if (beanMetaData instanceof IScheduleTarget) {
        IScheduleTarget md = (IScheduleTarget) beanMetaData;
        if (md.getTimers() != null) {
            for (final TimerMetaData timer : md.getTimers()) {
                AutoTimer autoTimer = new AutoTimer();
                autoTimer.getTimerConfig().setInfo(timer.getInfo());
                autoTimer.getTimerConfig().setPersistent(timer.isPersistent());
                final ScheduleExpression scheduleExpression = autoTimer.getScheduleExpression();
                final ScheduleMetaData schedule = timer.getSchedule();
                if (schedule != null) {
                    scheduleExpression.dayOfMonth(schedule.getDayOfMonth());
                    scheduleExpression.dayOfWeek(schedule.getDayOfWeek());
                    scheduleExpression.hour(schedule.getHour());
                    scheduleExpression.minute(schedule.getMinute());
                    scheduleExpression.month(schedule.getMonth());
                    scheduleExpression.second(schedule.getSecond());
                    scheduleExpression.year(schedule.getYear());
                }
                if (timer.getEnd() != null) {
                    scheduleExpression.end(timer.getEnd().getTime());
                }
                if (timer.getStart() != null) {
                    scheduleExpression.start(timer.getStart().getTime());
                }
                scheduleExpression.timezone(timer.getTimezone());
                sessionBean.addScheduleMethod(MethodResolutionUtils.resolveMethod(timer.getTimeoutMethod(), componentClass, deploymentReflectionIndex), autoTimer);
            }
        }
    }
}
Also used : AutoTimer(org.jboss.as.ejb3.timerservice.AutoTimer) ScheduleExpression(javax.ejb.ScheduleExpression) TimerMetaData(org.jboss.metadata.ejb.spec.TimerMetaData) IScheduleTarget(org.jboss.metadata.common.ejb.IScheduleTarget) ScheduleMetaData(org.jboss.metadata.ejb.spec.ScheduleMetaData)

Example 17 with EJBComponentDescription

use of org.jboss.as.ejb3.component.EJBComponentDescription in project wildfly by wildfly.

the class TransactionAttributeMergingProcessor method handleAnnotations.

@Override
protected void handleAnnotations(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription componentConfiguration) throws DeploymentUnitProcessingException {
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    processTransactionAttributeAnnotation(applicationClasses, deploymentReflectionIndex, componentClass, null, componentConfiguration);
    processTransactionTimeoutAnnotation(applicationClasses, deploymentReflectionIndex, componentClass, null, componentConfiguration);
    for (ViewDescription view : componentConfiguration.getViews()) {
        try {
            final Class<?> viewClass = module.getClassLoader().loadClass(view.getViewClassName());
            EJBViewDescription ejbView = (EJBViewDescription) view;
            processTransactionAttributeAnnotation(applicationClasses, deploymentReflectionIndex, viewClass, ejbView.getMethodIntf(), componentConfiguration);
            processTransactionTimeoutAnnotation(applicationClasses, deploymentReflectionIndex, viewClass, ejbView.getMethodIntf(), componentConfiguration);
        } catch (ClassNotFoundException e) {
            throw EjbLogger.ROOT_LOGGER.failToLoadEjbViewClass(e);
        }
    }
}
Also used : EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) ViewDescription(org.jboss.as.ee.component.ViewDescription) Module(org.jboss.modules.Module)

Example 18 with EJBComponentDescription

use of org.jboss.as.ejb3.component.EJBComponentDescription in project wildfly by wildfly.

the class TransactionAttributeMergingProcessor method handleDeploymentDescriptor.

@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription componentDescription) throws DeploymentUnitProcessingException {
    // CMT Tx attributes
    //DO NOT USE componentConfiguration.getDescriptorData()
    //It will return null if there is no <enterprise-beans/> declaration even if there is an assembly descriptor entry
    EjbJarMetaData ejbJarMetadata = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
    if (ejbJarMetadata != null) {
        boolean wildcardAttributeSet = false;
        boolean wildcardTimeoutSet = false;
        ContainerTransactionMetaData global = null;
        final AssemblyDescriptorMetaData assemblyDescriptor = ejbJarMetadata.getAssemblyDescriptor();
        if (assemblyDescriptor != null) {
            final ContainerTransactionsMetaData globalTransactions = assemblyDescriptor.getContainerTransactionsByEjbName("*");
            if (globalTransactions != null) {
                if (globalTransactions.size() > 1) {
                    throw EjbLogger.ROOT_LOGGER.mustOnlyBeSingleContainerTransactionElementWithWildcard();
                }
                global = globalTransactions.iterator().next();
                for (MethodMetaData method : global.getMethods()) {
                    if (!method.getMethodName().equals("*")) {
                        throw EjbLogger.ROOT_LOGGER.wildcardContainerTransactionElementsMustHaveWildcardMethodName();
                    }
                }
            }
            final ContainerTransactionsMetaData containerTransactions = assemblyDescriptor.getContainerTransactionsByEjbName(componentDescription.getEJBName());
            if (containerTransactions != null) {
                for (final ContainerTransactionMetaData containerTx : containerTransactions) {
                    final TransactionAttributeType txAttr = containerTx.getTransAttribute();
                    final Integer timeout = timeout(containerTx);
                    final MethodsMetaData methods = containerTx.getMethods();
                    for (final MethodMetaData method : methods) {
                        final String methodName = method.getMethodName();
                        final MethodIntf defaultMethodIntf = (componentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
                        final MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf(), defaultMethodIntf);
                        if (methodName.equals("*")) {
                            if (txAttr != null) {
                                wildcardAttributeSet = true;
                                componentDescription.getTransactionAttributes().setAttribute(methodIntf, null, txAttr);
                            }
                            if (timeout != null) {
                                wildcardTimeoutSet = true;
                                componentDescription.getTransactionTimeouts().setAttribute(methodIntf, null, timeout);
                            }
                        } else {
                            final MethodParametersMetaData methodParams = method.getMethodParams();
                            // update the session bean description with the tx attribute info
                            if (methodParams == null) {
                                if (txAttr != null)
                                    componentDescription.getTransactionAttributes().setAttribute(methodIntf, txAttr, methodName);
                                if (timeout != null)
                                    componentDescription.getTransactionTimeouts().setAttribute(methodIntf, timeout, methodName);
                            } else {
                                if (txAttr != null)
                                    componentDescription.getTransactionAttributes().setAttribute(methodIntf, txAttr, null, methodName, this.getMethodParams(methodParams));
                                if (timeout != null)
                                    componentDescription.getTransactionTimeouts().setAttribute(methodIntf, timeout, null, methodName, this.getMethodParams(methodParams));
                            }
                        }
                    }
                }
            }
        }
        if (global != null) {
            if (!wildcardAttributeSet && global.getTransAttribute() != null) {
                for (MethodMetaData method : global.getMethods()) {
                    final MethodIntf defaultMethodIntf = (componentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
                    final MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf(), defaultMethodIntf);
                    componentDescription.getTransactionAttributes().setAttribute(methodIntf, null, global.getTransAttribute());
                }
            }
            final Integer timeout = timeout(global);
            if (!wildcardTimeoutSet && timeout != null) {
                for (MethodMetaData method : global.getMethods()) {
                    final MethodIntf defaultMethodIntf = (componentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
                    final MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf(), defaultMethodIntf);
                    componentDescription.getTransactionTimeouts().setAttribute(methodIntf, null, timeout);
                }
            }
        }
    }
}
Also used : EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) MethodMetaData(org.jboss.metadata.ejb.spec.MethodMetaData) MethodParametersMetaData(org.jboss.metadata.ejb.spec.MethodParametersMetaData) MethodIntf(org.jboss.as.ejb3.component.MethodIntf) ContainerTransactionMetaData(org.jboss.metadata.ejb.spec.ContainerTransactionMetaData) MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) ContainerTransactionsMetaData(org.jboss.metadata.ejb.spec.ContainerTransactionsMetaData) AssemblyDescriptorMetaData(org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData) MethodsMetaData(org.jboss.metadata.ejb.spec.MethodsMetaData) TransactionAttributeType(javax.ejb.TransactionAttributeType)

Example 19 with EJBComponentDescription

use of org.jboss.as.ejb3.component.EJBComponentDescription in project wildfly by wildfly.

the class EjbDependsOnMergingProcessor method setupDependencies.

private void setupDependencies(final EJBComponentDescription description, final EEApplicationDescription applicationDescription, final ResourceRoot deploymentRoot, final String[] annotationValues) throws DeploymentUnitProcessingException {
    for (final String annotationValue : annotationValues) {
        final Set<ComponentDescription> components = applicationDescription.getComponents(annotationValue, deploymentRoot.getRoot());
        if (components.isEmpty()) {
            throw EjbLogger.ROOT_LOGGER.failToFindEjbRefByDependsOn(annotationValue, description.getComponentClassName());
        } else if (components.size() != 1) {
            throw EjbLogger.ROOT_LOGGER.failToCallEjbRefByDependsOn(annotationValue, description.getComponentClassName(), components);
        }
        final ComponentDescription component = components.iterator().next();
        description.addDependency(component.getStartServiceName(), DependencyType.REQUIRED);
        if (description instanceof SingletonComponentDescription) {
            ((SingletonComponentDescription) description).getDependsOn().add(component.getStartServiceName());
            if (ROOT_LOGGER.isDebugEnabled()) {
                ROOT_LOGGER.debugf(description.getEJBName() + " bean is dependent on " + component.getComponentName());
            }
        }
    }
}
Also used : SingletonComponentDescription(org.jboss.as.ejb3.component.singleton.SingletonComponentDescription) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) SingletonComponentDescription(org.jboss.as.ejb3.component.singleton.SingletonComponentDescription)

Example 20 with EJBComponentDescription

use of org.jboss.as.ejb3.component.EJBComponentDescription in project wildfly by wildfly.

the class MissingMethodPermissionsDenyAccessMergingProcessor method handleDeploymentDescriptor.

@Override
protected void handleDeploymentDescriptor(DeploymentUnit deploymentUnit, DeploymentReflectionIndex deploymentReflectionIndex, Class<?> componentClass, EJBComponentDescription description) throws DeploymentUnitProcessingException {
    Boolean missingMethodPermissionsDenyAccess = null;
    Boolean missingMethodPermissionsDenyAccessApplicableForAllBeans = null;
    final EjbJarMetaData ejbJarMetaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
    if (ejbJarMetaData != null) {
        final AssemblyDescriptorMetaData assemblyMetadata = ejbJarMetaData.getAssemblyDescriptor();
        if (assemblyMetadata != null) {
            final List<EJBBoundSecurityMetaData> securityMetaDatas = assemblyMetadata.getAny(EJBBoundSecurityMetaData.class);
            if (securityMetaDatas != null) {
                for (final EJBBoundSecurityMetaData securityMetaData : securityMetaDatas) {
                    if (securityMetaData.getEjbName().equals(description.getComponentName())) {
                        missingMethodPermissionsDenyAccess = securityMetaData.getMissingMethodPermissionsDenyAccess();
                        break;
                    }
                    // check missing-method-permissions-excluded-mode that's applicable for all EJBs.
                    if (securityMetaData.getEjbName().equals("*")) {
                        missingMethodPermissionsDenyAccessApplicableForAllBeans = securityMetaData.getMissingMethodPermissionsDenyAccess();
                        continue;
                    }
                }
            }
        }
    }
    if (missingMethodPermissionsDenyAccess != null) {
        description.setMissingMethodPermissionsDenyAccess(missingMethodPermissionsDenyAccess);
    } else if (missingMethodPermissionsDenyAccessApplicableForAllBeans != null) {
        description.setMissingMethodPermissionsDenyAccess(missingMethodPermissionsDenyAccessApplicableForAllBeans);
    } else {
        description.setMissingMethodPermissionsDenyAccess(denyAccessByDefault);
    }
}
Also used : EJBBoundSecurityMetaData(org.jboss.as.ejb3.security.metadata.EJBBoundSecurityMetaData) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) AssemblyDescriptorMetaData(org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData)

Aggregations

EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)23 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)16 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)15 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)14 EJBViewDescription (org.jboss.as.ejb3.component.EJBViewDescription)9 EjbJarMetaData (org.jboss.metadata.ejb.spec.EjbJarMetaData)9 Method (java.lang.reflect.Method)8 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)8 Module (org.jboss.modules.Module)8 ServiceName (org.jboss.msc.service.ServiceName)8 HashMap (java.util.HashMap)7 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)7 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)7 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)7 ViewDescription (org.jboss.as.ee.component.ViewDescription)6 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)6 Map (java.util.Map)5 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)5 MethodIntf (org.jboss.as.ejb3.component.MethodIntf)5 MessageDrivenComponentDescription (org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription)5