Search in sources :

Example 11 with ViewDescription

use of org.jboss.as.ee.component.ViewDescription 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 12 with ViewDescription

use of org.jboss.as.ee.component.ViewDescription in project wildfly by wildfly.

the class MessageDrivenComponentDescription method setupViewInterceptors.

@Override
protected void setupViewInterceptors(EJBViewDescription view) {
    // let the super do its job
    super.setupViewInterceptors(view);
    view.getConfigurators().add(new ViewConfigurator() {

        @Override
        public void configure(DeploymentPhaseContext context, ComponentConfiguration componentConfiguration, ViewDescription description, ViewConfiguration configuration) throws DeploymentUnitProcessingException {
            //add the invocation type to the start of the chain
            //TODO: is there a cleaner way to do this?
            configuration.addViewInterceptor(new ImmediateInterceptorFactory(new Interceptor() {

                @Override
                public Object processInvocation(final InterceptorContext context) throws Exception {
                    context.putPrivateData(InvocationType.class, InvocationType.MESSAGE_DELIVERY);
                    return context.proceed();
                }
            }), InterceptorOrder.View.INVOCATION_TYPE);
            // add the instance associating interceptor at the start of the interceptor chain
            configuration.addViewInterceptor(MessageDrivenComponentInstanceAssociatingFactory.instance(), InterceptorOrder.View.ASSOCIATING_INTERCEPTOR);
            final MessageDrivenComponentDescription mdb = (MessageDrivenComponentDescription) componentConfiguration.getComponentDescription();
            if (mdb.getTransactionManagementType() == TransactionManagementType.CONTAINER) {
                configuration.addViewInterceptor(CMTTxInterceptor.FACTORY, InterceptorOrder.View.CMT_TRANSACTION_INTERCEPTOR);
            }
        }
    });
}
Also used : ViewConfigurator(org.jboss.as.ee.component.ViewConfigurator) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) ViewDescription(org.jboss.as.ee.component.ViewDescription) InvocationType(org.jboss.as.ee.component.interceptors.InvocationType) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) ViewConfiguration(org.jboss.as.ee.component.ViewConfiguration) ImmediateInterceptorFactory(org.jboss.invocation.ImmediateInterceptorFactory) InterceptorContext(org.jboss.invocation.InterceptorContext) CurrentInvocationContextInterceptor(org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor) Interceptor(org.jboss.invocation.Interceptor) LifecycleCMTTxInterceptor(org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor) TimerCMTTxInterceptor(org.jboss.as.ejb3.tx.TimerCMTTxInterceptor) CMTTxInterceptor(org.jboss.as.ejb3.tx.CMTTxInterceptor) EjbBMTInterceptor(org.jboss.as.ejb3.tx.EjbBMTInterceptor)

Example 13 with ViewDescription

use of org.jboss.as.ee.component.ViewDescription in project wildfly by wildfly.

the class SessionBeanComponentDescription method addNoInterfaceView.

public void addNoInterfaceView() {
    noInterfaceViewPresent = true;
    final ViewDescription viewDescription = registerView(getEJBClassName(), MethodIntf.LOCAL);
    //set up interceptor for non-business methods
    viewDescription.getConfigurators().add(new ViewConfigurator() {

        @Override
        public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
            DeploymentReflectionIndex index = context.getDeploymentUnit().getAttachment(Attachments.REFLECTION_INDEX);
            for (final Method method : configuration.getProxyFactory().getCachedMethods()) {
                if (!Modifier.isPublic(method.getModifiers()) && isNotOverriden(method, componentConfiguration.getComponentClass(), index)) {
                    configuration.addClientInterceptor(method, new ImmediateInterceptorFactory(new NotBusinessMethodInterceptor(method)), InterceptorOrder.Client.NOT_BUSINESS_METHOD_EXCEPTION);
                }
            }
        }
    });
}
Also used : ViewConfigurator(org.jboss.as.ee.component.ViewConfigurator) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ViewConfiguration(org.jboss.as.ee.component.ViewConfiguration) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) ViewDescription(org.jboss.as.ee.component.ViewDescription) ImmediateInterceptorFactory(org.jboss.invocation.ImmediateInterceptorFactory) Method(java.lang.reflect.Method) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)

Example 14 with ViewDescription

use of org.jboss.as.ee.component.ViewDescription in project wildfly by wildfly.

the class DeploymentRepositoryProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    if (eeModuleDescription == null) {
        return;
    }
    // Note, we do not use the EEModuleDescription.getApplicationName() because that API returns the
    // module name if the top level unit isn't a .ear, which is not what we want. We really want a
    // .ear name as application name (that's the semantic in EJB spec). So use EEModuleDescription.getEarApplicationName
    String applicationName = eeModuleDescription.getEarApplicationName();
    // if it's not a .ear deployment then set app name to empty string
    applicationName = applicationName == null ? "" : applicationName;
    final DeploymentModuleIdentifier identifier = new DeploymentModuleIdentifier(applicationName, eeModuleDescription.getModuleName(), eeModuleDescription.getDistinctName());
    final Collection<ComponentDescription> componentDescriptions = eeModuleDescription.getComponentDescriptions();
    final Map<String, EjbDeploymentInformation> deploymentInformationMap = new HashMap<String, EjbDeploymentInformation>();
    final Set<ServiceName> componentStartServices = new HashSet<ServiceName>();
    final Map<ServiceName, InjectedValue<?>> injectedValues = new HashMap<ServiceName, InjectedValue<?>>();
    for (final ComponentDescription component : componentDescriptions) {
        if (component instanceof EJBComponentDescription) {
            final EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) component;
            componentStartServices.add(component.getStartServiceName());
            final InjectedValue<EJBComponent> componentInjectedValue = new InjectedValue<EJBComponent>();
            injectedValues.put(component.getCreateServiceName(), componentInjectedValue);
            final Map<String, InjectedValue<ComponentView>> remoteViews = new HashMap<String, InjectedValue<ComponentView>>();
            final Map<String, InjectedValue<ComponentView>> localViews = new HashMap<String, InjectedValue<ComponentView>>();
            for (final ViewDescription view : ejbComponentDescription.getViews()) {
                boolean remoteView = false;
                if (view instanceof EJBViewDescription) {
                    final MethodIntf viewType = ((EJBViewDescription) view).getMethodIntf();
                    if (viewType == MethodIntf.HOME || viewType == MethodIntf.REMOTE) {
                        remoteView = true;
                    }
                }
                final InjectedValue<ComponentView> componentViewInjectedValue = new InjectedValue<ComponentView>();
                if (remoteView) {
                    remoteViews.put(view.getViewClassName(), componentViewInjectedValue);
                } else {
                    localViews.put(view.getViewClassName(), componentViewInjectedValue);
                }
                injectedValues.put(view.getServiceName(), componentViewInjectedValue);
            }
            final InjectedValue<EjbIIOPService> iorFactory = new InjectedValue<EjbIIOPService>();
            if (ejbComponentDescription.isExposedViaIiop()) {
                injectedValues.put(ejbComponentDescription.getServiceName().append(EjbIIOPService.SERVICE_NAME), iorFactory);
            }
            final EjbDeploymentInformation info = new EjbDeploymentInformation(ejbComponentDescription.getEJBName(), componentInjectedValue, remoteViews, localViews, module.getClassLoader(), iorFactory);
            deploymentInformationMap.put(ejbComponentDescription.getEJBName(), info);
        }
    }
    final StartupCountdown countdown = deploymentUnit.getAttachment(Attachments.STARTUP_COUNTDOWN);
    final ModuleDeployment deployment = new ModuleDeployment(identifier, deploymentInformationMap, countdown);
    ServiceName moduleDeploymentService = deploymentUnit.getServiceName().append(ModuleDeployment.SERVICE_NAME);
    final ServiceBuilder<ModuleDeployment> builder = phaseContext.getServiceTarget().addService(moduleDeploymentService, deployment);
    for (Map.Entry<ServiceName, InjectedValue<?>> entry : injectedValues.entrySet()) {
        builder.addDependency(entry.getKey(), (InjectedValue<Object>) entry.getValue());
    }
    builder.addDependency(DeploymentRepository.SERVICE_NAME, DeploymentRepository.class, deployment.getDeploymentRepository());
    builder.install();
    final ModuleDeployment.ModuleDeploymentStartService deploymentStart = new ModuleDeployment.ModuleDeploymentStartService(identifier, countdown);
    final ServiceBuilder<Void> startBuilder = phaseContext.getServiceTarget().addService(deploymentUnit.getServiceName().append(ModuleDeployment.START_SERVICE_NAME), deploymentStart);
    startBuilder.addDependencies(componentStartServices);
    startBuilder.addDependency(moduleDeploymentService);
    startBuilder.addDependency(DeploymentRepository.SERVICE_NAME, DeploymentRepository.class, deploymentStart.getDeploymentRepository());
    startBuilder.install();
}
Also used : InjectedValue(org.jboss.msc.value.InjectedValue) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) HashMap(java.util.HashMap) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) MethodIntf(org.jboss.as.ejb3.component.MethodIntf) ModuleDeployment(org.jboss.as.ejb3.deployment.ModuleDeployment) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) StartupCountdown(org.jboss.as.ee.component.deployers.StartupCountdown) HashSet(java.util.HashSet) EjbDeploymentInformation(org.jboss.as.ejb3.deployment.EjbDeploymentInformation) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) ViewDescription(org.jboss.as.ee.component.ViewDescription) EJBComponent(org.jboss.as.ejb3.component.EJBComponent) ComponentView(org.jboss.as.ee.component.ComponentView) ServiceName(org.jboss.msc.service.ServiceName) DeploymentModuleIdentifier(org.jboss.as.ejb3.deployment.DeploymentModuleIdentifier) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) EjbIIOPService(org.jboss.as.ejb3.iiop.EjbIIOPService) HashMap(java.util.HashMap) Map(java.util.Map)

Example 15 with ViewDescription

use of org.jboss.as.ee.component.ViewDescription in project wildfly by wildfly.

the class StatelessComponentDescription method setupViewInterceptors.

@Override
protected void setupViewInterceptors(EJBViewDescription view) {
    // let super do its job first
    super.setupViewInterceptors(view);
    addViewSerializationInterceptor(view);
    // add the instance associating interceptor at the start of the interceptor chain
    view.getConfigurators().addFirst(new ViewConfigurator() {

        @Override
        public void configure(DeploymentPhaseContext context, ComponentConfiguration componentConfiguration, ViewDescription description, ViewConfiguration configuration) throws DeploymentUnitProcessingException {
            //add equals/hashCode interceptor
            for (Method method : configuration.getProxyFactory().getCachedMethods()) {
                if ((method.getName().equals("hashCode") && method.getParameterTypes().length == 0) || method.getName().equals("equals") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class) {
                    configuration.addClientInterceptor(method, ComponentTypeIdentityInterceptorFactory.INSTANCE, InterceptorOrder.Client.EJB_EQUALS_HASHCODE);
                }
            }
            // add the stateless component instance associating interceptor
            configuration.addViewInterceptor(StatelessComponentInstanceAssociatingFactory.instance(), InterceptorOrder.View.ASSOCIATING_INTERCEPTOR);
        }
    });
    if (view instanceof EJBViewDescription) {
        EJBViewDescription ejbViewDescription = (EJBViewDescription) view;
        if (ejbViewDescription.getMethodIntf() == MethodIntf.REMOTE) {
            view.getConfigurators().add(new ViewConfigurator() {

                @Override
                public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
                    final String earApplicationName = componentConfiguration.getComponentDescription().getModuleDescription().getEarApplicationName();
                    configuration.setViewInstanceFactory(new StatelessRemoteViewInstanceFactory(earApplicationName, componentConfiguration.getModuleName(), componentConfiguration.getComponentDescription().getModuleDescription().getDistinctName(), componentConfiguration.getComponentName()));
                }
            });
        }
    }
}
Also used : ViewConfigurator(org.jboss.as.ee.component.ViewConfigurator) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ViewConfiguration(org.jboss.as.ee.component.ViewConfiguration) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) ViewDescription(org.jboss.as.ee.component.ViewDescription) StatelessRemoteViewInstanceFactory(org.jboss.as.ejb3.component.session.StatelessRemoteViewInstanceFactory) Method(java.lang.reflect.Method) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext)

Aggregations

ViewDescription (org.jboss.as.ee.component.ViewDescription)21 EJBViewDescription (org.jboss.as.ejb3.component.EJBViewDescription)15 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)15 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)14 ViewConfiguration (org.jboss.as.ee.component.ViewConfiguration)14 ViewConfigurator (org.jboss.as.ee.component.ViewConfigurator)14 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)14 Method (java.lang.reflect.Method)8 ImmediateInterceptorFactory (org.jboss.invocation.ImmediateInterceptorFactory)6 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)5 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)4 ClassReflectionIndex (org.jboss.as.server.deployment.reflect.ClassReflectionIndex)4 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)3 WriteReplaceInterface (org.jboss.as.ee.component.serialization.WriteReplaceInterface)3 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)3 Module (org.jboss.modules.Module)3 HashSet (java.util.HashSet)2 ComponentView (org.jboss.as.ee.component.ComponentView)2 DependencyConfigurator (org.jboss.as.ee.component.DependencyConfigurator)2 NamespaceViewConfigurator (org.jboss.as.ee.component.NamespaceViewConfigurator)2