use of org.wildfly.common.annotation.NotNull 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);
}
Aggregations