Search in sources :

Example 6 with EjbDeploymentInformation

use of org.jboss.as.ejb3.deployment.EjbDeploymentInformation in project wildfly by wildfly.

the class RemoteObjectSubstitutionService method serviceForLocator.

private EjbIIOPService serviceForLocator(final EJBLocator<?> locator, DeploymentRepository deploymentRepository) {
    final ModuleDeployment module = deploymentRepository.getModules().get(new DeploymentModuleIdentifier(locator.getAppName(), locator.getModuleName(), locator.getDistinctName()));
    if (module == null) {
        EjbLogger.ROOT_LOGGER.couldNotFindEjbForLocatorIIOP(locator);
        return null;
    }
    final EjbDeploymentInformation ejb = module.getEjbs().get(locator.getBeanName());
    if (ejb == null) {
        EjbLogger.ROOT_LOGGER.couldNotFindEjbForLocatorIIOP(locator);
        return null;
    }
    final EjbIIOPService factory = ejb.getIorFactory();
    if (factory == null) {
        EjbLogger.ROOT_LOGGER.ejbNotExposedOverIIOP(locator);
        return null;
    }
    return factory;
}
Also used : ModuleDeployment(org.jboss.as.ejb3.deployment.ModuleDeployment) EjbDeploymentInformation(org.jboss.as.ejb3.deployment.EjbDeploymentInformation) DeploymentModuleIdentifier(org.jboss.as.ejb3.deployment.DeploymentModuleIdentifier)

Example 7 with EjbDeploymentInformation

use of org.jboss.as.ejb3.deployment.EjbDeploymentInformation in project wildfly by wildfly.

the class AssociationImpl method receiveInvocationRequest.

@Override
public CancelHandle receiveInvocationRequest(@NotNull final InvocationRequest invocationRequest) {
    final EJBIdentifier ejbIdentifier = invocationRequest.getEJBIdentifier();
    final String appName = ejbIdentifier.getAppName();
    final String moduleName = ejbIdentifier.getModuleName();
    final String distinctName = ejbIdentifier.getDistinctName();
    final String beanName = ejbIdentifier.getBeanName();
    final EjbDeploymentInformation ejbDeploymentInformation = findEJB(appName, moduleName, distinctName, beanName);
    if (ejbDeploymentInformation == null) {
        invocationRequest.writeNoSuchEJB();
        return CancelHandle.NULL;
    }
    final ClassLoader classLoader = ejbDeploymentInformation.getDeploymentClassLoader();
    ClassLoader originalTccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
    final InvocationRequest.Resolved requestContent;
    try {
        requestContent = invocationRequest.getRequestContent(classLoader);
    } catch (IOException | ClassNotFoundException e) {
        invocationRequest.writeException(new EJBException(e));
        return CancelHandle.NULL;
    } finally {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(originalTccl);
    }
    final Map<String, Object> attachments = requestContent.getAttachments();
    final EJBLocator<?> ejbLocator = requestContent.getEJBLocator();
    final String viewClassName = ejbLocator.getViewType().getName();
    if (!ejbDeploymentInformation.isRemoteView(viewClassName)) {
        invocationRequest.writeWrongViewType();
        return CancelHandle.NULL;
    }
    final ComponentView componentView = ejbDeploymentInformation.getView(viewClassName);
    final Method invokedMethod = findMethod(componentView, invocationRequest.getMethodLocator());
    if (invokedMethod == null) {
        invocationRequest.writeNoSuchMethod();
        return CancelHandle.NULL;
    }
    final Component component = componentView.getComponent();
    try {
        component.waitForComponentStart();
    } catch (RuntimeException e) {
        invocationRequest.writeException(new EJBException(e));
        return CancelHandle.NULL;
    }
    final EJBLocator<?> actualLocator;
    if (component instanceof StatefulSessionComponent) {
        if (ejbLocator.isStateless()) {
            final SessionID sessionID = ((StatefulSessionComponent) component).createSessionRemote();
            try {
                invocationRequest.convertToStateful(sessionID);
            } catch (IllegalArgumentException e) {
                // cannot convert (old protocol)
                invocationRequest.writeNotStateful();
                return CancelHandle.NULL;
            }
            actualLocator = ejbLocator.withSession(sessionID);
        } else {
            actualLocator = ejbLocator;
        }
    } else {
        if (ejbLocator.isStateful()) {
            invocationRequest.writeNotStateful();
            return CancelHandle.NULL;
        } else {
            actualLocator = ejbLocator;
        }
    }
    final boolean isAsync = componentView.isAsynchronous(invokedMethod);
    final boolean oneWay = isAsync && invokedMethod.getReturnType() == void.class;
    if (oneWay) {
        // send immediate response
        updateAffinities(invocationRequest, attachments, ejbLocator, componentView);
        requestContent.writeInvocationResult(null);
    } else if (isAsync) {
        invocationRequest.writeProceedAsync();
    }
    final CancellationFlag cancellationFlag = new CancellationFlag();
    Runnable runnable = () -> {
        if (!cancellationFlag.runIfNotCancelled()) {
            if (!oneWay)
                invocationRequest.writeCancelResponse();
            return;
        }
        // invoke the method
        final Object result;
        try {
            final Map<String, Object> contextDataHolder = new HashMap<>();
            result = invokeMethod(componentView, invokedMethod, invocationRequest, requestContent, cancellationFlag, actualLocator, contextDataHolder);
            attachments.putAll(contextDataHolder);
        } catch (EJBComponentUnavailableException ex) {
            // if the Jakarta Enterprise Beans are shutting down when the invocation was done, then it's as good as the Jakarta Enterprise Beans not being available. The client has to know about this as
            // a "no such EJB" failure so that it can retry the invocation on a different node if possible.
            EjbLogger.EJB3_INVOCATION_LOGGER.debugf("Cannot handle method invocation: %s on bean: %s due to Jakarta Enterprise Beans component unavailability exception. Returning a no such Jakarta Enterprise Beans available message back to client", invokedMethod, beanName);
            if (!oneWay)
                invocationRequest.writeNoSuchEJB();
            return;
        } catch (ComponentIsStoppedException ex) {
            EjbLogger.EJB3_INVOCATION_LOGGER.debugf("Cannot handle method invocation: %s on bean: %s due to Jakarta Enterprise Beans component stopped exception. Returning a no such Jakarta Enterprise Beans available message back to client", invokedMethod, beanName);
            if (!oneWay)
                invocationRequest.writeNoSuchEJB();
            return;
        // TODO should we write a specifc response with a specific protocol letting client know that server is suspending?
        } catch (CancellationException ex) {
            if (!oneWay)
                invocationRequest.writeCancelResponse();
            return;
        } catch (Exception exception) {
            if (oneWay)
                return;
            // write out the failure
            final Exception exceptionToWrite;
            final Throwable cause = exception.getCause();
            if (componentView.getComponent() instanceof StatefulSessionComponent && exception instanceof EJBException && cause != null) {
                if (!(componentView.getComponent().isRemotable(cause))) {
                    // Avoid serializing the cause of the exception in case it is not remotable
                    // Client might not be able to deserialize and throw ClassNotFoundException
                    exceptionToWrite = new EJBException(exception.getLocalizedMessage());
                } else {
                    exceptionToWrite = exception;
                }
            } else {
                exceptionToWrite = exception;
            }
            invocationRequest.writeException(exceptionToWrite);
            return;
        }
        // invocation was successful
        if (!oneWay)
            try {
                updateAffinities(invocationRequest, attachments, actualLocator, componentView);
                requestContent.writeInvocationResult(result);
            } catch (Throwable ioe) {
                EjbLogger.REMOTE_LOGGER.couldNotWriteMethodInvocation(ioe, invokedMethod, beanName, appName, moduleName, distinctName);
            }
    };
    // invoke the method and write out the response, possibly on a separate thread
    execute(invocationRequest, runnable, isAsync, false);
    return cancellationFlag::cancel;
}
Also used : ComponentIsStoppedException(org.jboss.as.ee.component.ComponentIsStoppedException) SessionBeanComponent(org.jboss.as.ejb3.component.session.SessionBeanComponent) StatefulSessionComponent(org.jboss.as.ejb3.component.stateful.StatefulSessionComponent) StatelessSessionComponent(org.jboss.as.ejb3.component.stateless.StatelessSessionComponent) Component(org.jboss.as.ee.component.Component) EJBComponentUnavailableException(org.jboss.as.ejb3.component.EJBComponentUnavailableException) EjbDeploymentInformation(org.jboss.as.ejb3.deployment.EjbDeploymentInformation) InvocationRequest(org.jboss.ejb.server.InvocationRequest) StatefulSessionComponent(org.jboss.as.ejb3.component.stateful.StatefulSessionComponent) IOException(java.io.IOException) Method(java.lang.reflect.Method) EJBComponentUnavailableException(org.jboss.as.ejb3.component.EJBComponentUnavailableException) CancellationException(java.util.concurrent.CancellationException) EJBException(javax.ejb.EJBException) ComponentIsStoppedException(org.jboss.as.ee.component.ComponentIsStoppedException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ComponentView(org.jboss.as.ee.component.ComponentView) CancellationException(java.util.concurrent.CancellationException) CancellationFlag(org.jboss.as.ejb3.component.interceptors.CancellationFlag) EJBException(javax.ejb.EJBException) EJBIdentifier(org.jboss.ejb.client.EJBIdentifier) SessionID(org.jboss.ejb.client.SessionID) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap)

Example 8 with EjbDeploymentInformation

use of org.jboss.as.ejb3.deployment.EjbDeploymentInformation in project wildfly by wildfly.

the class AssociationImpl method receiveSessionOpenRequest.

@Override
@NotNull
public CancelHandle receiveSessionOpenRequest(@NotNull final SessionOpenRequest sessionOpenRequest) {
    final EJBIdentifier ejbIdentifier = sessionOpenRequest.getEJBIdentifier();
    final String appName = ejbIdentifier.getAppName();
    final String moduleName = ejbIdentifier.getModuleName();
    final String beanName = ejbIdentifier.getBeanName();
    final String distinctName = ejbIdentifier.getDistinctName();
    final EjbDeploymentInformation ejbDeploymentInformation = findEJB(appName, moduleName, distinctName, beanName);
    if (ejbDeploymentInformation == null) {
        sessionOpenRequest.writeNoSuchEJB();
        return CancelHandle.NULL;
    }
    final Component component = ejbDeploymentInformation.getEjbComponent();
    component.waitForComponentStart();
    if (!(component instanceof StatefulSessionComponent)) {
        sessionOpenRequest.writeNotStateful();
        return CancelHandle.NULL;
    }
    final StatefulSessionComponent statefulSessionComponent = (StatefulSessionComponent) component;
    // generate the session id and write out the response, possibly on a separate thread
    final AtomicBoolean cancelled = new AtomicBoolean();
    Runnable runnable = () -> {
        if (cancelled.get()) {
            sessionOpenRequest.writeCancelResponse();
            return;
        }
        final SessionID sessionID;
        try {
            sessionID = statefulSessionComponent.createSessionRemote();
        } catch (EJBComponentUnavailableException ex) {
            // if the Jakarta Enterprise Beans are shutting down when the invocation was done, then it's as good as the Jakarta Enterprise Beans not being available. The client has to know about this as
            // a "no such Jakarta Enterprise Beans" failure so that it can retry the invocation on a different node if possible.
            EjbLogger.EJB3_INVOCATION_LOGGER.debugf("Cannot handle session creation on bean: %s due to Jakarta Enterprise Beans component unavailability exception. Returning a no such Jakarta Enterprise Beans available message back to client", beanName);
            sessionOpenRequest.writeNoSuchEJB();
            return;
        } catch (ComponentIsStoppedException ex) {
            EjbLogger.EJB3_INVOCATION_LOGGER.debugf("Cannot handle session creation on bean: %s due to Jakarta Enterprise Beans component stopped exception. Returning a no such Jakarta Enterprise Beans available message back to client", beanName);
            sessionOpenRequest.writeNoSuchEJB();
            return;
        // TODO should we write a specifc response with a specific protocol letting client know that server is suspending?
        } catch (Exception t) {
            EjbLogger.REMOTE_LOGGER.exceptionGeneratingSessionId(t, statefulSessionComponent.getComponentName(), ejbIdentifier);
            sessionOpenRequest.writeException(t);
            return;
        }
        // do not update strongAffinity when it is of type NodeAffinity; this will be achieved on the client in DiscoveryInterceptor via targetAffinity
        Affinity strongAffinity = getStrongAffinity(statefulSessionComponent);
        if (strongAffinity != null && !(strongAffinity instanceof NodeAffinity)) {
            sessionOpenRequest.updateStrongAffinity(strongAffinity);
        }
        Affinity weakAffinity = getWeakAffinity(statefulSessionComponent, sessionID);
        if (weakAffinity != null && !Affinity.NONE.equals(weakAffinity)) {
            sessionOpenRequest.updateWeakAffinity(weakAffinity);
        }
        EjbLogger.EJB3_INVOCATION_LOGGER.debugf("Called receiveSessionOpenRequest ( bean = %s ): strong affinity = %s, weak affinity = %s \n", statefulSessionComponent.getClass().getName(), strongAffinity, weakAffinity);
        sessionOpenRequest.convertToStateful(sessionID);
    };
    execute(sessionOpenRequest, runnable, false, true);
    return ignored -> cancelled.set(true);
}
Also used : Arrays(java.util.Arrays) ClusterAffinity(org.jboss.ejb.client.ClusterAffinity) DeploymentRepositoryListener(org.jboss.as.ejb3.deployment.DeploymentRepositoryListener) SocketAddress(java.net.SocketAddress) NotNull(org.wildfly.common.annotation.NotNull) ModuleDeployment(org.jboss.as.ejb3.deployment.ModuleDeployment) ClusterTopologyListener(org.jboss.ejb.server.ClusterTopologyListener) SessionBeanComponent(org.jboss.as.ejb3.component.session.SessionBeanComponent) InetAddress(java.net.InetAddress) Future(java.util.concurrent.Future) EJBComponentUnavailableException(org.jboss.as.ejb3.component.EJBComponentUnavailableException) Map(java.util.Map) Affinity(org.jboss.ejb.client.Affinity) SecurityIdentity(org.wildfly.security.auth.server.SecurityIdentity) DeploymentModuleIdentifier(org.jboss.as.ejb3.deployment.DeploymentModuleIdentifier) InvocationRequest(org.jboss.ejb.server.InvocationRequest) Method(java.lang.reflect.Method) StatefulSessionComponent(org.jboss.as.ejb3.component.stateful.StatefulSessionComponent) Registry(org.wildfly.clustering.registry.Registry) CancellationException(java.util.concurrent.CancellationException) Group(org.wildfly.clustering.group.Group) StatefulEJBLocator(org.jboss.ejb.client.StatefulEJBLocator) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) ProtocolSocketBinding(org.jboss.as.network.ProtocolSocketBinding) InterceptorContext(org.jboss.invocation.InterceptorContext) InetSocketAddress(java.net.InetSocketAddress) ClientMapping(org.jboss.as.network.ClientMapping) EJBException(javax.ejb.EJBException) ModuleAvailabilityListener(org.jboss.ejb.server.ModuleAvailabilityListener) Registration(org.wildfly.clustering.Registration) RegistryListener(org.wildfly.clustering.registry.RegistryListener) List(java.util.List) WildFlySecurityManager(org.wildfly.security.manager.WildFlySecurityManager) EjbDeploymentInformation(org.jboss.as.ejb3.deployment.EjbDeploymentInformation) EJBModuleIdentifier(org.jboss.ejb.client.EJBModuleIdentifier) EJBLocator(org.jboss.ejb.client.EJBLocator) Request(org.jboss.ejb.server.Request) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ComponentIsStoppedException(org.jboss.as.ee.component.ComponentIsStoppedException) HashMap(java.util.HashMap) EJBIdentifier(org.jboss.ejb.client.EJBIdentifier) ArrayList(java.util.ArrayList) StatelessSessionComponent(org.jboss.as.ejb3.component.stateless.StatelessSessionComponent) DeploymentRepository(org.jboss.as.ejb3.deployment.DeploymentRepository) SessionOpenRequest(org.jboss.ejb.server.SessionOpenRequest) CancellationFlag(org.jboss.as.ejb3.component.interceptors.CancellationFlag) Executor(java.util.concurrent.Executor) Association(org.jboss.ejb.server.Association) ComponentView(org.jboss.as.ee.component.ComponentView) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) NodeAffinity(org.jboss.ejb.client.NodeAffinity) InvocationType(org.jboss.as.ee.component.interceptors.InvocationType) EJBMethodLocator(org.jboss.ejb.client.EJBMethodLocator) SessionID(org.jboss.ejb.client.SessionID) EjbLogger(org.jboss.as.ejb3.logging.EjbLogger) ListenerHandle(org.jboss.ejb.server.ListenerHandle) EJBClientInvocationContext(org.jboss.ejb.client.EJBClientInvocationContext) Component(org.jboss.as.ee.component.Component) CancelHandle(org.jboss.ejb.server.CancelHandle) Collections(java.util.Collections) EJBComponentUnavailableException(org.jboss.as.ejb3.component.EJBComponentUnavailableException) NodeAffinity(org.jboss.ejb.client.NodeAffinity) EjbDeploymentInformation(org.jboss.as.ejb3.deployment.EjbDeploymentInformation) StatefulSessionComponent(org.jboss.as.ejb3.component.stateful.StatefulSessionComponent) ComponentIsStoppedException(org.jboss.as.ee.component.ComponentIsStoppedException) EJBComponentUnavailableException(org.jboss.as.ejb3.component.EJBComponentUnavailableException) CancellationException(java.util.concurrent.CancellationException) EJBException(javax.ejb.EJBException) ComponentIsStoppedException(org.jboss.as.ee.component.ComponentIsStoppedException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ClusterAffinity(org.jboss.ejb.client.ClusterAffinity) Affinity(org.jboss.ejb.client.Affinity) NodeAffinity(org.jboss.ejb.client.NodeAffinity) SessionBeanComponent(org.jboss.as.ejb3.component.session.SessionBeanComponent) StatefulSessionComponent(org.jboss.as.ejb3.component.stateful.StatefulSessionComponent) StatelessSessionComponent(org.jboss.as.ejb3.component.stateless.StatelessSessionComponent) Component(org.jboss.as.ee.component.Component) EJBIdentifier(org.jboss.ejb.client.EJBIdentifier) SessionID(org.jboss.ejb.client.SessionID) NotNull(org.wildfly.common.annotation.NotNull)

Example 9 with EjbDeploymentInformation

use of org.jboss.as.ejb3.deployment.EjbDeploymentInformation in project wildfly by wildfly.

the class RegisterManagementEJBService method start.

@Override
public void start(StartContext context) throws StartException {
    final DeploymentRepository repository = deploymentRepositoryValue.getValue();
    moduleIdentifier = new DeploymentModuleIdentifier(APP_NAME, MODULE_NAME, DISTINCT_NAME);
    final InjectedValue<ComponentView> injectedHomeView = new InjectedValue<ComponentView>();
    injectedHomeView.setValue(new ImmediateValue<ComponentView>(new ManagementHomeEjbComponentView()));
    final InjectedValue<ComponentView> injectedRemoteView = new InjectedValue<ComponentView>();
    injectedRemoteView.setValue(new ImmediateValue<ComponentView>(new ManagementRemoteEjbComponentView(mbeanServerValue.getValue())));
    Map<String, InjectedValue<ComponentView>> views = new HashMap<String, InjectedValue<ComponentView>>();
    views.put(ManagementHome.class.getName(), injectedHomeView);
    views.put(Management.class.getName(), injectedRemoteView);
    final EjbDeploymentInformation ejb = new ManagementEjbDeploymentInformation(EJB_NAME, views, SecurityActions.getClassLoader(this.getClass()));
    final ModuleDeployment deployment = new ModuleDeployment(moduleIdentifier, Collections.singletonMap(EJB_NAME, ejb));
    repository.add(moduleIdentifier, deployment);
    repository.startDeployment(moduleIdentifier);
    doPrivileged((PrivilegedAction<Void>) () -> {
        final ClassLoader classLoader = getClass().getClassLoader();
        EJBClientContext.getContextManager().setClassLoaderDefault(classLoader, ejbClientContextValue.getValue().getClientContext());
        Discovery.getContextManager().setClassLoaderDefault(classLoader, Discovery.create(associationServiceInjector.getValue().getLocalDiscoveryProvider()));
        return null;
    });
}
Also used : InjectedValue(org.jboss.msc.value.InjectedValue) ManagementEjbDeploymentInformation(org.jboss.as.jsr77.ejb.ManagementEjbDeploymentInformation) EjbDeploymentInformation(org.jboss.as.ejb3.deployment.EjbDeploymentInformation) HashMap(java.util.HashMap) Management(javax.management.j2ee.Management) ManagementHomeEjbComponentView(org.jboss.as.jsr77.ejb.ManagementHomeEjbComponentView) ManagementEjbDeploymentInformation(org.jboss.as.jsr77.ejb.ManagementEjbDeploymentInformation) ManagementRemoteEjbComponentView(org.jboss.as.jsr77.ejb.ManagementRemoteEjbComponentView) ManagementHome(javax.management.j2ee.ManagementHome) ModuleDeployment(org.jboss.as.ejb3.deployment.ModuleDeployment) ManagementHomeEjbComponentView(org.jboss.as.jsr77.ejb.ManagementHomeEjbComponentView) ManagementRemoteEjbComponentView(org.jboss.as.jsr77.ejb.ManagementRemoteEjbComponentView) ComponentView(org.jboss.as.ee.component.ComponentView) DeploymentModuleIdentifier(org.jboss.as.ejb3.deployment.DeploymentModuleIdentifier) DeploymentRepository(org.jboss.as.ejb3.deployment.DeploymentRepository)

Example 10 with EjbDeploymentInformation

use of org.jboss.as.ejb3.deployment.EjbDeploymentInformation 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

EjbDeploymentInformation (org.jboss.as.ejb3.deployment.EjbDeploymentInformation)9 DeploymentModuleIdentifier (org.jboss.as.ejb3.deployment.DeploymentModuleIdentifier)6 ModuleDeployment (org.jboss.as.ejb3.deployment.ModuleDeployment)6 HashMap (java.util.HashMap)5 ComponentView (org.jboss.as.ee.component.ComponentView)5 Map (java.util.Map)4 EJBComponent (org.jboss.as.ejb3.component.EJBComponent)4 StatefulSessionComponent (org.jboss.as.ejb3.component.stateful.StatefulSessionComponent)4 Method (java.lang.reflect.Method)3 CancellationFlag (org.jboss.as.ejb3.component.interceptors.CancellationFlag)3 SessionBeanComponent (org.jboss.as.ejb3.component.session.SessionBeanComponent)3 SessionID (org.jboss.ejb.client.SessionID)3 IOException (java.io.IOException)2 UnknownHostException (java.net.UnknownHostException)2 CancellationException (java.util.concurrent.CancellationException)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Future (java.util.concurrent.Future)2 EJBException (javax.ejb.EJBException)2 Component (org.jboss.as.ee.component.Component)2 ComponentIsStoppedException (org.jboss.as.ee.component.ComponentIsStoppedException)2