Package org.jboss.as.ejb3.component.session

Examples of org.jboss.as.ejb3.component.session.SessionBeanComponentDescription


                throw EjbMessages.MESSAGES.sessionTypeNotSpecified(beanName);
            }
        }

        final String beanClassName = sessionBean.getEjbClass();
        final SessionBeanComponentDescription sessionBeanDescription;
        switch (sessionType) {
            case Stateless:
                sessionBeanDescription = new StatelessComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnit.getServiceName(), sessionBean);
                break;
            case Stateful:
View Full Code Here


        /*
        * Special handling of stateful session bean getEJBObject due how the stateful session handles acquire the
        * proxy by sending an invocation to the ejb container.
        */
        if (component instanceof SessionBeanComponentDescription) {
            SessionBeanComponentDescription session = SessionBeanComponentDescription.class.cast(component);
            if (session.isStateful()) {
                EJBMethodPermission p = new EJBMethodPermission(ejbName, "getEJBObject", "Home", null);
                config.addPermit(p);
            }
        }
    }
View Full Code Here

        final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
        for (ComponentDescription component : moduleDescription.getComponentDescriptions()) {
            BeanDeploymentArchiveImpl bda = resolveComponentBda(component.getComponentClassName(), bdaMap, rootBda, indexes);
            component.setBeanDeploymentArchiveId(bda.getId());
            if (component instanceof SessionBeanComponentDescription) {
                SessionBeanComponentDescription componentDescription = (SessionBeanComponentDescription) component;
                //first we need to resolve the correct BDA for the bean
                bda.addEjbDescriptor(new EjbDescriptorImpl<Object>(componentDescription, bda, reflectionIndex));
            }
        }
    }
View Full Code Here

    private void processEjbComponents(DeploymentUnit deploymentUnit, Map<ResourceRoot, BeanDeploymentArchiveImpl> bdaMap, BeanDeploymentArchiveImpl rootBda, Map<ResourceRoot, Index> indexes) {
        final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
        for(AbstractComponentDescription component : moduleDescription.getComponentDescriptions()) {
            if(component instanceof SessionBeanComponentDescription) {
                SessionBeanComponentDescription componentDescription = (SessionBeanComponentDescription) component;
                //first we need to resolve the correct BDA for the bean
                BeanDeploymentArchiveImpl bda = resolveSessionBeanBda(componentDescription.getEJBClassName(), bdaMap,rootBda,indexes);
                bda.addEjbDescriptor(new EjbDescriptorImpl<Object>(componentDescription,bda,deploymentUnit));
            }
        }
    }
View Full Code Here

            } else {
                // both original and override session beans are non-empty. Merge them
                Set<String> commonBeans = new HashSet<String>();
                for (SessionBeanComponentDescription originalSessionBean : original) {
                    // find the session bean in the overriden collection
                    SessionBeanComponentDescription overrideSessionBean = findSessionBean(originalSessionBean.getEJBName(), override);
                    if (overrideSessionBean == null) {
                        // if there's no overridden session bean, then just add the original to the merged collection
                        mergedResult.add(originalSessionBean);
                    } else {
                        // make sure we are merging beans of the same type
                        SessionBeanComponentDescription.SessionBeanType sessionBeanType = originalSessionBean.getSessionBeanType();
                        if (overrideSessionBean.getSessionBeanType() != sessionBeanType) {
                            throw new RuntimeException("Cannot mergeSessionBean two EJBs with the same name = " + originalSessionBean.getEJBName() +
                                    " but with different session bean types, type 1 - " + overrideSessionBean.getSessionBeanType()
                                    + " type 2 - " + originalSessionBean.getSessionBeanType());
                        }
                        // there's a overridden session bean, so merge them
                        commonBeans.add(originalSessionBean.getEJBName());
                        SessionBeanComponentDescription mergedBean = createNewSessionBean(originalSessionBean, ejbModuleDescription);
                        switch (sessionBeanType) {
                            case STATELESS:
                                mergeStatelessBean((StatelessComponentDescription) mergedBean, (StatelessComponentDescription) originalSessionBean, (StatelessComponentDescription) overrideSessionBean);
                                break;
                            case STATEFUL:
View Full Code Here

        if (sessionType == null) {
            throw new DeploymentUnitProcessingException("Unknown session-type for session bean: " + sessionBean.getName() + " in deployment unit: " + deploymentUnit);
        }
        String beanName = sessionBean.getName();
        String beanClassName = sessionBean.getEjbClass();
        SessionBeanComponentDescription sessionBeanDescription = null;
        switch (sessionType) {
            case Stateless:
                sessionBeanDescription = new StatelessComponentDescription(beanName, beanClassName, ejbJarDescription);
                break;
            case Stateful:
                sessionBeanDescription = new StatefulComponentDescription(beanName, beanClassName, ejbJarDescription);
                break;
            case Singleton:
                sessionBeanDescription = new SingletonComponentDescription(beanName, beanClassName, ejbJarDescription);
                break;
            default:
                throw new IllegalArgumentException("Unknown session bean type: " + sessionType);
        }
        // mapped-name
        sessionBeanDescription.setMappedName(sessionBean.getMappedName());
        // local business interface views
        BusinessLocalsMetaData businessLocals = sessionBean.getBusinessLocals();
        if (businessLocals != null && !businessLocals.isEmpty()) {
            sessionBeanDescription.addLocalBusinessInterfaceViews(businessLocals);
        }
        // remote business interface views
        BusinessRemotesMetaData businessRemotes = sessionBean.getBusinessRemotes();
        if (businessRemotes != null && !businessRemotes.isEmpty()) {
            sessionBeanDescription.addRemoteBusinessInterfaceViews(businessRemotes);
        }
        // tx management type
        if (sessionBean.getTransactionType() != null) {
            sessionBeanDescription.setTransactionManagementType(sessionBean.getTransactionType());
        }
        // CMT Tx attributes
        if (sessionBean.getTransactionType() != TransactionManagementType.BEAN) {
            ContainerTransactionsMetaData containerTransactions = sessionBean.getContainerTransactions();
            if (containerTransactions != null && !containerTransactions.isEmpty()) {
                for (ContainerTransactionMetaData containerTx : containerTransactions) {
                    TransactionAttributeType txAttr = containerTx.getTransAttribute();
                    MethodsMetaData methods = containerTx.getMethods();
                    for (MethodMetaData method : methods) {
                        String methodName = method.getMethodName();
                        MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf());
                        if (methodName.equals("*")) {
                            sessionBeanDescription.setTransactionAttribute(methodIntf, txAttr);
                        } else {

                            MethodParametersMetaData methodParams = method.getMethodParams();
                            // update the session bean description with the tx attribute info
                            sessionBeanDescription.setTransactionAttribute(methodIntf, txAttr, methodName, this.getMethodParams(methodParams));
                        }
                    }
                }
            }
        }
View Full Code Here

            final String beanClassName = sessionBeanClassInfo.name().toString();
            final String ejbName = sessionBeanClassInfo.name().local();
            final AnnotationValue nameValue = sessionBeanAnnotation.value("name");
            final String beanName = nameValue == null || nameValue.asString().isEmpty() ? ejbName : nameValue.asString();

            SessionBeanComponentDescription sessionBeanDescription = null;
            switch (sessionBeanType) {
                case STATELESS:
                    sessionBeanDescription = new StatelessComponentDescription(beanName, beanClassName, ejbJarDescription);
                    break;
                case STATEFUL:
                    sessionBeanDescription = new StatefulComponentDescription(beanName, beanClassName, ejbJarDescription);
                    break;
                case SINGLETON:
                    sessionBeanDescription = new SingletonComponentDescription(beanName, beanClassName, ejbJarDescription);
                    break;
                default:
                    throw new IllegalArgumentException("Unknown session bean type: " + sessionBeanType);
            }

            // Add this component description to module description
            if (ejbJarDescription.getEEModuleDescription().getComponentByName(sessionBeanDescription.getComponentName()) == null) {
                ejbJarDescription.getEEModuleDescription().addComponent(sessionBeanDescription);
            }
        }
    }
View Full Code Here

        }
    }

    private static EJBEndpoint newEjbEndpoint(final PortComponentMetaData portComponentMD, final EEModuleDescription moduleDescription, final Set<String> securityRoles) {
        final String ejbName = portComponentMD.getEjbLink();
        final SessionBeanComponentDescription sessionBean = (SessionBeanComponentDescription)moduleDescription.getComponentByName(ejbName);
        final String seiIfaceClassName = portComponentMD.getServiceEndpointInterface();
        final EJBViewDescription ejbViewDescription = sessionBean.addWebserviceEndpointView(seiIfaceClassName);
        // JSR 109 - Version 1.3 - 6.2.2.4 Security
        // For EJB based service implementations, Handlers run after method level authorization has occurred.
        // JSR 109 - Version 1.3 - 6.2.2.5 Transaction
        // Handlers run under the transaction context of the component they are associated with.
        sessionBean.getConfigurators().addLast(new JAXRPCHandlersConfigurator());
        final ServiceName ejbViewName = ejbViewDescription.getServiceName();

        return new EJBEndpoint(sessionBean, ejbViewName, securityRoles, null, false, null);
    }
View Full Code Here

                logger.debug("Installing timer service for component " + component.getComponentName());

                component.getConfigurators().add(new ComponentConfigurator() {
                    @Override
                    public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
                        final SessionBeanComponentDescription ejbComponentDescription = (SessionBeanComponentDescription) description;

                        final DeploymentReflectionIndex deploymentReflectionIndex = context.getDeploymentUnit().getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);

                        //First resolve the timer method and auto timer
                        Class<?> c = configuration.getComponentClass();
                        while (c != null && c != Object.class) {
                            final ClassReflectionIndex<?> index = deploymentReflectionIndex.getClassIndex(c);
                            //TimedObject takes precedence
                            Method method = null;
                            if (TimedObject.class.isAssignableFrom(configuration.getComponentClass())) {
                                method = index.getMethod(Void.TYPE, "ejbTimeout", javax.ejb.Timer.class);
                            } else if (ejbComponentDescription.getTimeoutMethod() == null && ejbComponentDescription.getTimeoutMethodIdentifier() != null) {
                                method = index.getMethod(ejbComponentDescription.getTimeoutMethodIdentifier());
                            } else {
                                break;
                            }
                            if (method != null) {
                                ejbComponentDescription.setTimeoutMethod(method);
                                break;
                            }
                            c = c.getSuperclass();
                        }
                        //now for the schedule methods
                        for (Map.Entry<MethodIdentifier, List<AutoTimer>> entry : ejbComponentDescription.getScheduleMethodIdentifiers().entrySet()) {
                            c = configuration.getComponentClass();
                            while (c != null && c != Object.class) {
                                final ClassReflectionIndex<?> index = deploymentReflectionIndex.getClassIndex(c);
                                final Method method = index.getMethod(entry.getKey());
                                if (method != null) {
                                    for (AutoTimer timer : entry.getValue()) {
                                        ejbComponentDescription.addScheduleMethod(method, timer);
                                    }
                                    break;
                                }
                                c = c.getSuperclass();
                            }
                        }

                        configuration.addTimeoutInterceptor(SessionInvocationContextInterceptor.FACTORY, InterceptorOrder.Component.TIMEOUT_INVOCATION_CONTEXT_INTERCEPTOR);

                        //install the timer create service
                        final TimerServiceService service = new TimerServiceService(ejbComponentDescription.getScheduleMethods(), module.getClassLoader());
                        final ServiceName serviceName = component.getServiceName().append(TimerServiceService.SERVICE_NAME);
                        final ServiceBuilder<javax.ejb.TimerService> createBuilder = context.getServiceTarget().addService(serviceName, service);
                        createBuilder.addDependency(deploymentUnit.getServiceName().append(TimerServiceFactoryService.SERVICE_NAME), TimerServiceFactory.class, service.getTimerServiceFactoryInjectedValue());
                        createBuilder.addDependency(component.getCreateServiceName(), EJBComponent.class, service.getEjbComponentInjectedValue());
                        createBuilder.install();

                        ejbComponentDescription.setTimerService(service);

                        //inject the timer service directly into the start service
                        configuration.getStartDependencies().add(new DependencyConfigurator<ComponentStartService>() {
                            @Override
                            public void configureDependency(final ServiceBuilder<?> serviceBuilder, final ComponentStartService service) throws DeploymentUnitProcessingException {
View Full Code Here

            } else {
                sessionBeanType = annotatedSessionBeanType;
                beanClassName = sessionBeanClassInfo.name().toString();
            }

            final SessionBeanComponentDescription sessionBeanDescription;
            switch (sessionBeanType) {
                case STATELESS:
                    sessionBeanDescription = new StatelessComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnitServiceName);
                    break;
                case STATEFUL:
View Full Code Here

TOP

Related Classes of org.jboss.as.ejb3.component.session.SessionBeanComponentDescription

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.