Search in sources :

Example 6 with SessionBean31MetaData

use of org.jboss.metadata.ejb.spec.SessionBean31MetaData 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)

Example 7 with SessionBean31MetaData

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

the class SessionBeanXmlDescriptorProcessor method processBeanMetaData.

/**
 * Processes the passed {@link org.jboss.metadata.ejb.spec.SessionBeanMetaData} and creates appropriate {@link org.jboss.as.ejb3.component.session.SessionBeanComponentDescription} out of it.
 * The {@link org.jboss.as.ejb3.component.session.SessionBeanComponentDescription} is then added to the {@link org.jboss.as.ee.component.EEModuleDescription module description} available
 * in the deployment unit of the passed {@link DeploymentPhaseContext phaseContext}
 *
 * @param sessionBean  The session bean metadata
 * @param phaseContext
 * @throws DeploymentUnitProcessingException
 */
@Override
protected void processBeanMetaData(final SessionBeanMetaData sessionBean, final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    // get the module description
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
    final String beanName = sessionBean.getName();
    ComponentDescription bean = moduleDescription.getComponentByName(beanName);
    if (appclient && bean == null) {
        for (final ComponentDescription component : deploymentUnit.getAttachmentList(Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS)) {
            if (component.getComponentName().equals(beanName)) {
                bean = component;
                break;
            }
        }
    }
    if (!(bean instanceof SessionBeanComponentDescription)) {
        // if this is a GenericBeanMetadata it may actually represent an MDB
        return;
    }
    SessionBeanComponentDescription sessionBeanDescription = (SessionBeanComponentDescription) bean;
    sessionBeanDescription.setDeploymentDescriptorEnvironment(new DeploymentDescriptorEnvironment("java:comp/env/", sessionBean));
    // mapped-name
    sessionBeanDescription.setMappedName(sessionBean.getMappedName());
    // local business interface views
    final BusinessLocalsMetaData businessLocals = sessionBean.getBusinessLocals();
    if (businessLocals != null && !businessLocals.isEmpty()) {
        sessionBeanDescription.addLocalBusinessInterfaceViews(businessLocals);
    }
    final String local = sessionBean.getLocal();
    if (local != null) {
        sessionBeanDescription.addEjbLocalObjectView(local);
    }
    final String remote = sessionBean.getRemote();
    if (remote != null) {
        sessionBeanDescription.addEjbObjectView(remote);
    }
    // remote business interface views
    final BusinessRemotesMetaData businessRemotes = sessionBean.getBusinessRemotes();
    if (businessRemotes != null && !businessRemotes.isEmpty()) {
        sessionBeanDescription.addRemoteBusinessInterfaceViews(businessRemotes);
    }
    // process Enterprise Beans 3.1 specific session bean description
    if (sessionBean instanceof SessionBean31MetaData) {
        this.processSessionBean31((SessionBean31MetaData) sessionBean, sessionBeanDescription);
    }
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) DeploymentDescriptorEnvironment(org.jboss.as.ee.component.DeploymentDescriptorEnvironment) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) SessionBean31MetaData(org.jboss.metadata.ejb.spec.SessionBean31MetaData) BusinessLocalsMetaData(org.jboss.metadata.ejb.spec.BusinessLocalsMetaData) BusinessRemotesMetaData(org.jboss.metadata.ejb.spec.BusinessRemotesMetaData)

Example 8 with SessionBean31MetaData

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

the class AsynchronousMergingProcessor method handleDeploymentDescriptor.

@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final SessionBeanComponentDescription description) throws DeploymentUnitProcessingException {
    final SessionBeanMetaData data = description.getDescriptorData();
    final boolean elytronSecurityDomain = description.getSecurityDomainServiceName() != null;
    if (data instanceof SessionBean31MetaData) {
        final SessionBean31MetaData sessionBeanData = (SessionBean31MetaData) data;
        final AsyncMethodsMetaData async = sessionBeanData.getAsyncMethods();
        if (async != null) {
            for (AsyncMethodMetaData method : async) {
                final Collection<Method> methods = MethodResolutionUtils.resolveMethods(method.getMethodName(), method.getMethodParams(), componentClass, deploymentReflectionIndex);
                for (final Method m : methods) {
                    description.addAsynchronousMethod(MethodIdentifier.getIdentifierForMethod(m));
                }
            }
        }
    }
    if (!description.getAsynchronousClasses().isEmpty() || !description.getAsynchronousMethods().isEmpty()) {
        // setup a dependency on the executor service
        description.getConfigurators().add(new ComponentConfigurator() {

            @Override
            public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
                configuration.getCreateDependencies().add(new DependencyConfigurator<SessionBeanComponentCreateService>() {

                    @Override
                    public void configureDependency(final ServiceBuilder<?> serviceBuilder, final SessionBeanComponentCreateService service) throws DeploymentUnitProcessingException {
                        serviceBuilder.addDependency(asynchronousThreadPoolService, ExecutorService.class, service.getAsyncExecutorService());
                    }
                });
            }
        });
        for (final ViewDescription view : description.getViews()) {
            final EJBViewDescription ejbView = (EJBViewDescription) view;
            ejbView.getConfigurators().add(new ViewConfigurator() {

                @Override
                public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
                    final SessionBeanComponentDescription componentDescription = (SessionBeanComponentDescription) componentConfiguration.getComponentDescription();
                    for (final Method method : configuration.getProxyFactory().getCachedMethods()) {
                        // we need the component method to get the correct declaring class
                        final Method componentMethod = ClassReflectionIndexUtil.findMethod(deploymentReflectionIndex, componentClass, method);
                        if (componentMethod != null) {
                            if (componentDescription.getAsynchronousClasses().contains(componentMethod.getDeclaringClass().getName())) {
                                addAsyncInterceptor(configuration, method, elytronSecurityDomain);
                                configuration.addAsyncMethod(method);
                            } else {
                                MethodIdentifier id = MethodIdentifier.getIdentifierForMethod(method);
                                if (componentDescription.getAsynchronousMethods().contains(id)) {
                                    addAsyncInterceptor(configuration, method, elytronSecurityDomain);
                                    configuration.addAsyncMethod(method);
                                }
                            }
                        }
                    }
                }
            });
        }
    }
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ViewConfigurator(org.jboss.as.ee.component.ViewConfigurator) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) SessionBeanMetaData(org.jboss.metadata.ejb.spec.SessionBeanMetaData) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) ViewDescription(org.jboss.as.ee.component.ViewDescription) DependencyConfigurator(org.jboss.as.ee.component.DependencyConfigurator) Method(java.lang.reflect.Method) MethodIdentifier(org.jboss.invocation.proxy.MethodIdentifier) SessionBean31MetaData(org.jboss.metadata.ejb.spec.SessionBean31MetaData) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) AsyncMethodsMetaData(org.jboss.metadata.ejb.spec.AsyncMethodsMetaData) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) ViewConfiguration(org.jboss.as.ee.component.ViewConfiguration) AsyncMethodMetaData(org.jboss.metadata.ejb.spec.AsyncMethodMetaData) SessionBeanComponentCreateService(org.jboss.as.ejb3.component.session.SessionBeanComponentCreateService) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)

Example 9 with SessionBean31MetaData

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

the class EjbConcurrencyMergingProcessor method handleDeploymentDescriptor.

protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final SessionBeanComponentDescription componentConfiguration) throws DeploymentUnitProcessingException {
    if (componentConfiguration.getDescriptorData() == null) {
        return;
    }
    SessionBeanMetaData sessionBeanMetaData = componentConfiguration.getDescriptorData();
    if (sessionBeanMetaData instanceof SessionBean31MetaData) {
        SessionBean31MetaData descriptor = (SessionBean31MetaData) sessionBeanMetaData;
        // handle lock
        if (descriptor.getLockType() != null) {
            componentConfiguration.setBeanLevelLockType(componentConfiguration.getEJBClassName(), descriptor.getLockType());
        }
        // handle access timeout
        if (descriptor.getAccessTimeout() != null) {
            componentConfiguration.setBeanLevelAccessTimeout(componentConfiguration.getEJBClassName(), new AccessTimeoutDetails(descriptor.getAccessTimeout().getTimeout(), descriptor.getAccessTimeout().getUnit()));
        }
        final ConcurrentMethodsMetaData methods = descriptor.getConcurrentMethods();
        if (methods != null) {
            for (final ConcurrentMethodMetaData method : methods) {
                final Method realMethod = resolveMethod(deploymentReflectionIndex, componentClass, componentClass, method.getMethod());
                final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(realMethod);
                if (method.getLockType() != null) {
                    componentConfiguration.setLockType(method.getLockType(), methodIdentifier);
                }
                if (method.getAccessTimeout() != null) {
                    componentConfiguration.setAccessTimeout(new AccessTimeoutDetails(method.getAccessTimeout().getTimeout(), method.getAccessTimeout().getUnit()), methodIdentifier);
                }
            }
        }
    }
}
Also used : ConcurrentMethodsMetaData(org.jboss.metadata.ejb.spec.ConcurrentMethodsMetaData) SessionBeanMetaData(org.jboss.metadata.ejb.spec.SessionBeanMetaData) AccessTimeoutDetails(org.jboss.as.ejb3.concurrency.AccessTimeoutDetails) ConcurrentMethodMetaData(org.jboss.metadata.ejb.spec.ConcurrentMethodMetaData) Method(java.lang.reflect.Method) MethodIdentifier(org.jboss.invocation.proxy.MethodIdentifier) SessionBean31MetaData(org.jboss.metadata.ejb.spec.SessionBean31MetaData)

Aggregations

SessionBean31MetaData (org.jboss.metadata.ejb.spec.SessionBean31MetaData)9 SessionBeanMetaData (org.jboss.metadata.ejb.spec.SessionBeanMetaData)7 Method (java.lang.reflect.Method)3 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)2 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)2 ClassReflectionIndex (org.jboss.as.server.deployment.reflect.ClassReflectionIndex)2 MethodIdentifier (org.jboss.invocation.proxy.MethodIdentifier)2 TimeUnit (java.util.concurrent.TimeUnit)1 ConcurrencyManagementType (javax.ejb.ConcurrencyManagementType)1 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)1 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)1 DependencyConfigurator (org.jboss.as.ee.component.DependencyConfigurator)1 DeploymentDescriptorEnvironment (org.jboss.as.ee.component.DeploymentDescriptorEnvironment)1 EEApplicationDescription (org.jboss.as.ee.component.EEApplicationDescription)1 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)1 ViewConfiguration (org.jboss.as.ee.component.ViewConfiguration)1 ViewConfigurator (org.jboss.as.ee.component.ViewConfigurator)1 ViewDescription (org.jboss.as.ee.component.ViewDescription)1 EJBViewDescription (org.jboss.as.ejb3.component.EJBViewDescription)1 SessionBeanComponentCreateService (org.jboss.as.ejb3.component.session.SessionBeanComponentCreateService)1