Search in sources :

Example 6 with MethodIntf

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

the class EJBComponentCreateService method processTxAttr.

protected void processTxAttr(final EJBComponentDescription ejbComponentDescription, final MethodIntf methodIntf, final Method method) {
    if (this.getTransactionManagementType().equals(TransactionManagementType.BEAN)) {
        // it's a BMT bean
        return;
    }
    MethodIntf defaultMethodIntf = (ejbComponentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
    TransactionAttributeType txAttr = ejbComponentDescription.getTransactionAttributes().getAttribute(methodIntf, method, defaultMethodIntf);
    MethodTransactionAttributeKey key = new MethodTransactionAttributeKey(methodIntf, MethodIdentifier.getIdentifierForMethod(method));
    if (txAttr != null) {
        txAttrs.put(key, txAttr);
        txExplicitAttrs.put(key, ejbComponentDescription.getTransactionAttributes().isMethodLevel(methodIntf, method, defaultMethodIntf));
    }
    Integer txTimeout = ejbComponentDescription.getTransactionTimeouts().getAttribute(methodIntf, method, defaultMethodIntf);
    if (txTimeout != null) {
        txTimeouts.put(key, txTimeout);
    }
}
Also used : MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) TransactionAttributeType(javax.ejb.TransactionAttributeType)

Example 7 with MethodIntf

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

the class EJBViewDescription method createInjectionSource.

@Override
protected InjectionSource createInjectionSource(final ServiceName serviceName, Value<ClassLoader> viewClassLoader, boolean appclient) {
    if (methodIntf != MethodIntf.REMOTE && methodIntf != MethodIntf.HOME) {
        return super.createInjectionSource(serviceName, viewClassLoader, appclient);
    } else {
        final EJBComponentDescription componentDescription = getComponentDescription();
        final EEModuleDescription desc = componentDescription.getModuleDescription();
        final String earApplicationName = desc.getEarApplicationName();
        return new RemoteViewInjectionSource(serviceName, earApplicationName, desc.getModuleName(), desc.getDistinctName(), componentDescription.getComponentName(), getViewClassName(), componentDescription.isStateful(), viewClassLoader, appclient);
    }
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) RemoteViewInjectionSource(org.jboss.as.ejb3.remote.RemoteViewInjectionSource)

Example 8 with MethodIntf

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

the class EjbInjectionSource method resolve.

/**
 * Checks if this Jakarta Enterprise Beans injection has been resolved yet, and if not resolves it.
 */
private void resolve() {
    if (!resolved) {
        synchronized (this) {
            if (!resolved) {
                final Set<ViewDescription> views = getViews();
                final Set<EJBViewDescription> ejbsForViewName = new HashSet<EJBViewDescription>();
                for (final ViewDescription view : views) {
                    if (view instanceof EJBViewDescription) {
                        final MethodIntf viewType = ((EJBViewDescription) view).getMethodIntf();
                        // @EJB injection *shouldn't* consider the @WebService endpoint view or MDBs
                        if (viewType == MethodIntf.SERVICE_ENDPOINT || viewType == MethodIntf.MESSAGE_ENDPOINT) {
                            continue;
                        }
                        ejbsForViewName.add((EJBViewDescription) view);
                    }
                }
                if (ejbsForViewName.isEmpty()) {
                    if (beanName == null) {
                        error = EjbLogger.ROOT_LOGGER.ejbNotFound(typeName, bindingName);
                    } else {
                        error = EjbLogger.ROOT_LOGGER.ejbNotFound(typeName, beanName, bindingName);
                    }
                } else if (ejbsForViewName.size() > 1) {
                    if (beanName == null) {
                        error = EjbLogger.ROOT_LOGGER.moreThanOneEjbFound(typeName, bindingName, ejbsForViewName);
                    } else {
                        error = EjbLogger.ROOT_LOGGER.moreThanOneEjbFound(typeName, beanName, bindingName, ejbsForViewName);
                    }
                } else {
                    final EJBViewDescription description = ejbsForViewName.iterator().next();
                    final EJBViewDescription ejbViewDescription = (EJBViewDescription) description;
                    if (ejbViewDescription.getMethodIntf() == MethodIntf.REMOTE || ejbViewDescription.getMethodIntf() == MethodIntf.HOME) {
                        final EJBComponentDescription componentDescription = (EJBComponentDescription) description.getComponentDescription();
                        final EEModuleDescription moduleDescription = componentDescription.getModuleDescription();
                        final String earApplicationName = moduleDescription.getEarApplicationName();
                        final Value<ClassLoader> viewClassLoader = new Value<ClassLoader>() {

                            @Override
                            public ClassLoader getValue() throws IllegalStateException, IllegalArgumentException {
                                final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
                                return module != null ? module.getClassLoader() : null;
                            }
                        };
                        remoteFactory = new RemoteViewManagedReferenceFactory(earApplicationName, moduleDescription.getModuleName(), moduleDescription.getDistinctName(), componentDescription.getComponentName(), description.getViewClassName(), componentDescription.isStateful(), viewClassLoader, appclient);
                    }
                    final ServiceName serviceName = description.getServiceName();
                    resolvedViewName = serviceName;
                }
                resolved = true;
            }
        }
    }
}
Also used : EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) ViewDescription(org.jboss.as.ee.component.ViewDescription) RemoteViewManagedReferenceFactory(org.jboss.as.ejb3.remote.RemoteViewManagedReferenceFactory) MethodIntf(org.jboss.as.ejb3.component.MethodIntf) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ServiceName(org.jboss.msc.service.ServiceName) Value(org.jboss.msc.value.Value) Module(org.jboss.modules.Module) HashSet(java.util.HashSet)

Example 9 with MethodIntf

use of org.jboss.as.ejb3.component.MethodIntf 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;
    }
    if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
        // don't create this for EAR's, as they cannot hold Jakarta Enterprise Beans's
        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 Jakarta Enterprise Beans 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);
    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(), Object.class, (InjectedValue<Object>) entry.getValue());
    }
    builder.addDependency(DeploymentRepositoryService.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);
    for (final ServiceName componentStartService : componentStartServices) {
        startBuilder.requires(componentStartService);
    }
    startBuilder.requires(moduleDeploymentService);
    startBuilder.addDependency(DeploymentRepositoryService.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)

Aggregations

MethodIntf (org.jboss.as.ejb3.component.MethodIntf)7 TransactionAttributeType (javax.ejb.TransactionAttributeType)4 MessageDrivenComponentDescription (org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription)4 ComponentView (org.jboss.as.ee.component.ComponentView)3 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)3 EJBComponent (org.jboss.as.ejb3.component.EJBComponent)3 MethodMetaData (org.jboss.metadata.ejb.spec.MethodMetaData)3 MethodParametersMetaData (org.jboss.metadata.ejb.spec.MethodParametersMetaData)3 HashSet (java.util.HashSet)2 Component (org.jboss.as.ee.component.Component)2 ViewDescription (org.jboss.as.ee.component.ViewDescription)2 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)2 EJBViewDescription (org.jboss.as.ejb3.component.EJBViewDescription)2 MethodsMetaData (org.jboss.metadata.ejb.spec.MethodsMetaData)2 Module (org.jboss.modules.Module)2 ServiceName (org.jboss.msc.service.ServiceName)2 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Transaction (javax.transaction.Transaction)1