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);
}
}
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);
}
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());
}
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();
}
}
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();
}
Aggregations