void setSessionID(final SessionID sessionID) { final AtomicReference<EJBLocator<T>> locatorRef = this.locatorRef; EJBLocator<T> oldVal, newVal; do { oldVal = locatorRef.get(); if (oldVal.isStateful()) { if (oldVal.asStateful().getSessionId().equals(sessionID)) { // harmless/idempotent return; } throw Logs.MAIN.ejbIsAlreadyStateful(); } newVal = oldVal.withSession(sessionID); } while (! locatorRef.compareAndSet(oldVal, newVal)); }
if (ejbLocator.isStateful()) { interceptorContext.putPrivateData(SessionID.class, ejbLocator.asStateful().getSessionId());
private void updateAffinities(InvocationRequest invocationRequest, Map<String, Object> attachments, EJBLocator<?> ejbLocator, ComponentView componentView) { Affinity legacyAffinity = null; Affinity weakAffinity = null; Affinity clusterAffinity = getClusterAffinity(); if (ejbLocator.isStateful() && componentView.getComponent() instanceof StatefulSessionComponent) { final StatefulSessionComponent statefulSessionComponent = (StatefulSessionComponent) componentView.getComponent(); weakAffinity = legacyAffinity = getWeakAffinity(statefulSessionComponent, ejbLocator.asStateful()); } else if (componentView.getComponent() instanceof StatelessSessionComponent) { // V3 and less used cluster affinity as a weak affinity for SLSBs legacyAffinity = clusterAffinity; } // Always use the cluster as the strong affinity, if there is one if (clusterAffinity != null) { invocationRequest.updateStrongAffinity(clusterAffinity); } if (weakAffinity != null && !weakAffinity.equals(Affinity.NONE)) { invocationRequest.updateWeakAffinity(weakAffinity); } if (legacyAffinity != null && !legacyAffinity.equals(Affinity.NONE)) { attachments.put(Affinity.WEAK_AFFINITY_CONTEXT_KEY, legacyAffinity); } }
public Object handleInvocationResult(final EJBClientInvocationContext context) throws Exception { final Object result; try { result = context.getResult(); } catch (NoSuchEJBException | RequestSendFailedException e) { processMissingTarget(context); throw e; } final EJBLocator<?> locator = context.getLocator(); if (locator.isStateful() && locator.getAffinity() instanceof ClusterAffinity && context.getWeakAffinity() == Affinity.NONE) { // set the weak affinity to the location of the session (in case it failed over) final Affinity targetAffinity = context.getTargetAffinity(); if (targetAffinity != null) { context.setWeakAffinity(targetAffinity); } else { final URI destination = context.getDestination(); if (destination != null) { context.setWeakAffinity(URIAffinity.forUri(destination)); } // if destination is null, then an interceptor set the location } } return result; }
interceptorContext.putPrivateData(ComponentView.class, view); if (locator.isStateful()) { interceptorContext.putPrivateData(SessionID.class, locator.asStateful().getSessionId()); } else if (locator instanceof EntityEJBLocator) {
void setSessionID(final SessionID sessionID) { final AtomicReference<EJBLocator<T>> locatorRef = this.locatorRef; EJBLocator<T> oldVal, newVal; do { oldVal = locatorRef.get(); if (oldVal.isStateful()) { if (oldVal.asStateful().getSessionId().equals(sessionID)) { // harmless/idempotent return; } throw Logs.MAIN.ejbIsAlreadyStateful(); } newVal = oldVal.withSession(sessionID); } while (! locatorRef.compareAndSet(oldVal, newVal)); }
void setSessionID(final SessionID sessionID) { final AtomicReference<EJBLocator<T>> locatorRef = this.locatorRef; EJBLocator<T> oldVal, newVal; do { oldVal = locatorRef.get(); if (oldVal.isStateful()) { if (oldVal.asStateful().getSessionId().equals(sessionID)) { // harmless/idempotent return; } throw Logs.MAIN.ejbIsAlreadyStateful(); } newVal = oldVal.withSession(sessionID); } while (! locatorRef.compareAndSet(oldVal, newVal)); }
public Object handleInvocationResult(final EJBClientInvocationContext context) throws Exception { final Object result; try { result = context.getResult(); } catch (NoSuchEJBException | RequestSendFailedException e) { processMissingTarget(context); throw e; } final EJBLocator<?> locator = context.getLocator(); if (locator.isStateful() && locator.getAffinity() instanceof ClusterAffinity && context.getWeakAffinity() == Affinity.NONE) { // set the weak affinity to the location of the session (in case it failed over) final Affinity targetAffinity = context.getTargetAffinity(); if (targetAffinity != null) { context.setWeakAffinity(targetAffinity); } else { final URI destination = context.getDestination(); if (destination != null) { context.setWeakAffinity(URIAffinity.forUri(destination)); } // if destination is null, then an interceptor set the location } } return result; }
public Object handleInvocationResult(final EJBClientInvocationContext context) throws Exception { final Object result; try { result = context.getResult(); } catch (NoSuchEJBException | RequestSendFailedException e) { processMissingTarget(context); throw e; } final EJBLocator<?> locator = context.getLocator(); if (locator.isStateful() && locator.getAffinity() instanceof ClusterAffinity && context.getWeakAffinity() == Affinity.NONE) { // set the weak affinity to the location of the session (in case it failed over) final Affinity targetAffinity = context.getTargetAffinity(); if (targetAffinity != null) { context.setWeakAffinity(targetAffinity); } else { final URI destination = context.getDestination(); if (destination != null) { context.setWeakAffinity(URIAffinity.forUri(destination)); } // if destination is null, then an interceptor set the location } } return result; }