Search in sources :

Example 21 with EJBComponent

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

the class EjbIIOPService method referenceForLocator.

/**
 * Returns a corba reference for the given locator
 *
 * @param locator The locator
 * @return The corba reference
 */
public org.omg.CORBA.Object referenceForLocator(final EJBLocator<?> locator) {
    final EJBComponent ejbComponent = ejbComponentInjectedValue.getValue();
    try {
        final String earApplicationName = ejbComponent.getEarApplicationName() == null ? "" : ejbComponent.getEarApplicationName();
        if (locator.getBeanName().equals(ejbComponent.getComponentName()) && locator.getAppName().equals(earApplicationName) && locator.getModuleName().equals(ejbComponent.getModuleName()) && locator.getDistinctName().equals(ejbComponent.getDistinctName())) {
            if (locator instanceof EJBHomeLocator) {
                return (org.omg.CORBA.Object) ejbHome;
            } else if (locator instanceof StatelessEJBLocator) {
                return beanReferenceFactory.createReference(beanRepositoryIds[0]);
            } else if (locator instanceof StatefulEJBLocator) {
                try (final Marshaller marshaller = factory.createMarshaller(configuration)) {
                    final ByteArrayOutputStream stream = new ByteArrayOutputStream();
                    marshaller.start(new OutputStreamByteOutput(stream));
                    marshaller.writeObject(((StatefulEJBLocator<?>) locator).getSessionId());
                    marshaller.flush();
                    return beanReferenceFactory.createReferenceWithId(stream.toByteArray(), beanRepositoryIds[0]);
                }
            } else if (locator instanceof EntityEJBLocator) {
                try (final Marshaller marshaller = factory.createMarshaller(configuration)) {
                    final ByteArrayOutputStream stream = new ByteArrayOutputStream();
                    marshaller.start(new OutputStreamByteOutput(stream));
                    marshaller.writeObject(((EntityEJBLocator<?>) locator).getPrimaryKey());
                    marshaller.flush();
                    return beanReferenceFactory.createReferenceWithId(stream.toByteArray(), beanRepositoryIds[0]);
                }
            }
            throw EjbLogger.ROOT_LOGGER.unknownEJBLocatorType(locator);
        } else {
            throw EjbLogger.ROOT_LOGGER.incorrectEJBLocatorForBean(locator, ejbComponent.getComponentName());
        }
    } catch (Exception e) {
        throw EjbLogger.ROOT_LOGGER.couldNotCreateCorbaObject(e, locator);
    }
}
Also used : Marshaller(org.jboss.marshalling.Marshaller) StatelessEJBLocator(org.jboss.ejb.client.StatelessEJBLocator) OutputStreamByteOutput(org.jboss.marshalling.OutputStreamByteOutput) EJBHomeLocator(org.jboss.ejb.client.EJBHomeLocator) StatefulEJBLocator(org.jboss.ejb.client.StatefulEJBLocator) PortableRemoteObject(javax.rmi.PortableRemoteObject) ByteArrayOutputStream(java.io.ByteArrayOutputStream) EJBComponent(org.jboss.as.ejb3.component.EJBComponent) EntityEJBLocator(org.jboss.ejb.client.EntityEJBLocator) InvalidClassException(java.io.InvalidClassException) StartException(org.jboss.msc.service.StartException) IOException(java.io.IOException)

Example 22 with EJBComponent

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

the class IdentityOutflowInterceptorFactory method create.

@Override
protected Interceptor create(final Component component, final InterceptorFactoryContext context) {
    if (!(component instanceof EJBComponent)) {
        throw EjbLogger.ROOT_LOGGER.unexpectedComponent(component, EJBComponent.class);
    }
    final EJBComponent ejbComponent = (EJBComponent) component;
    final Function<SecurityIdentity, Set<SecurityIdentity>> identityOutflowFunction = ejbComponent.getIdentityOutflowFunction();
    return new IdentityOutflowInterceptor(identityOutflowFunction, category, roleMapper);
}
Also used : SecurityIdentity(org.wildfly.security.auth.server.SecurityIdentity) Set(java.util.Set) EJBComponent(org.jboss.as.ejb3.component.EJBComponent)

Example 23 with EJBComponent

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

the class TimerServiceImpl method start.

@Override
public synchronized void start(final StartContext context) throws StartException {
    if (EJB3_TIMER_LOGGER.isDebugEnabled()) {
        EJB3_TIMER_LOGGER.debug("Starting timerservice for timedObjectId: " + getInvoker().getTimedObjectId());
    }
    final EJBComponent component = ejbComponentInjectedValue.getValue();
    this.tsr = component.getTransactionSynchronizationRegistry();
    final TimedObjectInvoker invoker = timedObjectInvoker.getValue();
    if (invoker == null) {
        throw EJB3_TIMER_LOGGER.invokerIsNull();
    }
    started = true;
    timerPersistence.getValue().timerDeployed(timedObjectInvoker.getValue().getTimedObjectId());
    // register ourselves to the TimerServiceRegistry (if any)
    if (timerServiceRegistry != null) {
        timerServiceRegistry.registerTimerService(this);
    }
    listenerHandle = timerPersistence.getValue().registerChangeListener(getInvoker().getTimedObjectId(), new TimerRefreshListener());
}
Also used : TimedObjectInvoker(org.jboss.as.ejb3.timerservice.spi.TimedObjectInvoker) EJBComponent(org.jboss.as.ejb3.component.EJBComponent)

Example 24 with EJBComponent

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

the class EjbSuspendInterceptor method processInvocation.

@Override
public Object processInvocation(InterceptorContext context) throws Exception {
    InvocationType invocation = context.getPrivateData(InvocationType.class);
    if (invocation != InvocationType.REMOTE && invocation != InvocationType.MESSAGE_DELIVERY) {
        return context.proceed();
    }
    // see if control point accepts or rejects this invocation
    EJBComponent component = getComponent(context, EJBComponent.class);
    ControlPoint entryPoint = component.getControlPoint();
    RunResult result = entryPoint.beginRequest();
    if (result == RunResult.REJECTED && !component.getEjbSuspendHandlerService().acceptInvocation(context)) {
        // if control point rejected, check with suspend handler
        throw EjbLogger.ROOT_LOGGER.containerSuspended();
    }
    try {
        return context.proceed();
    } finally {
        if (result == RunResult.REJECTED)
            component.getEjbSuspendHandlerService().invocationComplete();
        else
            entryPoint.requestComplete();
    }
}
Also used : InvocationType(org.jboss.as.ee.component.interceptors.InvocationType) ControlPoint(org.wildfly.extension.requestcontroller.ControlPoint) EJBComponent(org.jboss.as.ejb3.component.EJBComponent) RunResult(org.wildfly.extension.requestcontroller.RunResult)

Example 25 with EJBComponent

use of org.jboss.as.ejb3.component.EJBComponent 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

EJBComponent (org.jboss.as.ejb3.component.EJBComponent)24 Component (org.jboss.as.ee.component.Component)7 ComponentView (org.jboss.as.ee.component.ComponentView)6 MethodIntf (org.jboss.as.ejb3.component.MethodIntf)5 SecurityDomain (org.wildfly.security.auth.server.SecurityDomain)5 SecurityIdentity (org.wildfly.security.auth.server.SecurityIdentity)5 Method (java.lang.reflect.Method)4 EjbDeploymentInformation (org.jboss.as.ejb3.deployment.EjbDeploymentInformation)4 PrivilegedActionException (java.security.PrivilegedActionException)3 IOException (java.io.IOException)2 InvalidClassException (java.io.InvalidClassException)2 RemoteException (java.rmi.RemoteException)2 PrivilegedAction (java.security.PrivilegedAction)2 ProtectionDomain (java.security.ProtectionDomain)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Set (java.util.Set)2 ConcurrentAccessException (javax.ejb.ConcurrentAccessException)2 ConcurrentAccessTimeoutException (javax.ejb.ConcurrentAccessTimeoutException)2 TransactionAttributeType (javax.ejb.TransactionAttributeType)2