use of org.jboss.ejb.server.SessionOpenRequest 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();
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 (Exception t) {
EjbLogger.REMOTE_LOGGER.exceptionGeneratingSessionId(t, statefulSessionComponent.getComponentName(), ejbIdentifier);
sessionOpenRequest.writeException(t);
return;
}
sessionOpenRequest.convertToStateful(sessionID);
};
execute(sessionOpenRequest, runnable, false);
return ignored -> cancelled.set(true);
}
Aggregations