public abstract boolean equals(Affinity other);
/** * Determine whether this object is equal to another. * * @param other the other object * @return {@code true} if they are equal, {@code false} otherwise */ public boolean equals(EJBLocator<?> other) { return this == other || other != null && hashCode == other.hashCode && identifier.equals(other.identifier) && affinity.equals(other.affinity); }
void setStrongAffinity(final Affinity newAffinity) { final AtomicReference<EJBLocator<T>> locatorRef = this.locatorRef; EJBLocator<T> oldVal, newVal; do { oldVal = locatorRef.get(); if (oldVal.getAffinity().equals(newAffinity)) { return; } newVal = oldVal.withNewAffinity(newAffinity); } while (! locatorRef.compareAndSet(oldVal, newVal)); }
boolean compareAndSetStrongAffinity(final Affinity expectedAffinity, final Affinity newAffinity) { Assert.checkNotNullParam("expectedAffinity", expectedAffinity); Assert.checkNotNullParam("newAffinity", newAffinity); final AtomicReference<EJBLocator<T>> locatorRef = this.locatorRef; EJBLocator<T> oldVal = locatorRef.get(); if (! oldVal.getAffinity().equals(expectedAffinity)) { return false; } EJBLocator<T> newVal = oldVal.withNewAffinity(newAffinity); return locatorRef.compareAndSet(oldVal, newVal); } }
public StatefulEJBLocator<T> withNewAffinity(final Affinity affinity) { Assert.checkNotNullParam("affinity", affinity); return getAffinity().equals(affinity) ? this : new StatefulEJBLocator<T>(this, affinity); }
public EntityEJBLocator<T> withNewAffinity(final Affinity affinity) { Assert.checkNotNullParam("affinity", affinity); return getAffinity().equals(affinity) ? this : new EntityEJBLocator<T>(this, affinity); }
public StatelessEJBLocator<T> withNewAffinity(final Affinity affinity) { Assert.checkNotNullParam("affinity", affinity); return getAffinity().equals(affinity) ? this : new StatelessEJBLocator<T>(this, affinity); }
public EJBHomeLocator<T> withNewAffinity(final Affinity affinity) { Assert.checkNotNullParam("affinity", affinity); return getAffinity().equals(affinity) ? this : new EJBHomeLocator<T>(this, affinity); }
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 StatefulEJBLocator<T> withSessionAndAffinity(final SessionID sessionId, final Affinity affinity) { Assert.checkNotNullParam("sessionId", sessionId); Assert.checkNotNullParam("affinity", affinity); return getAffinity().equals(affinity) && getSessionId().equals(sessionId) ? this : new StatefulEJBLocator<T>(this, sessionId, affinity); }
/** * Compare and change the strong affinity of a proxy. All subsequent invocations against the proxy will use the new affinity. * Subsequent calls to {@link #getLocatorFor(Object)} for the given proxy will return the updated locator. If the * affinity is not equal to the expected value, {@code false} is returned and no change is made. * * @param proxy the proxy (may not be {@code null}) * @param newAffinity the new affinity (may not be {@code null}) * @throws IllegalArgumentException if the given proxy is not a valid client proxy instance * @throws SecurityException if a security manager is present and the caller does not have the {@code changeStrongAffinity} {@link EJBClientPermission} */ public static boolean compareAndSetStrongAffinity(Object proxy, Affinity expectedAffinity, Affinity newAffinity) throws IllegalArgumentException, SecurityException { Assert.checkNotNullParam("proxy", proxy); Assert.checkNotNullParam("expectedAffinity", expectedAffinity); Assert.checkNotNullParam("newAffinity", newAffinity); final EJBInvocationHandler<?> invocationHandler = EJBInvocationHandler.forProxy(proxy); final Affinity existing = invocationHandler.getLocator().getAffinity(); if (! expectedAffinity.equals(existing)) { return false; } final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(EJBClientPermission.CHANGE_STRONG_AFFINITY); } return invocationHandler.compareAndSetStrongAffinity(expectedAffinity, newAffinity); }
if (weakAffinity != null && !Affinity.NONE.equals(weakAffinity)) { sessionOpenRequest.updateWeakAffinity(weakAffinity);
/** * Determine whether this object is equal to another. * * @param other the other object * @return {@code true} if they are equal, {@code false} otherwise */ public boolean equals(EJBLocator<?> other) { return this == other || other != null && hashCode == other.hashCode && identifier.equals(other.identifier) && affinity.equals(other.affinity); }
void setStrongAffinity(final Affinity newAffinity) { final AtomicReference<EJBLocator<T>> locatorRef = this.locatorRef; EJBLocator<T> oldVal, newVal; do { oldVal = locatorRef.get(); if (oldVal.getAffinity().equals(newAffinity)) { return; } newVal = oldVal.withNewAffinity(newAffinity); } while (! locatorRef.compareAndSet(oldVal, newVal)); }
void setStrongAffinity(final Affinity newAffinity) { final AtomicReference<EJBLocator<T>> locatorRef = this.locatorRef; EJBLocator<T> oldVal, newVal; do { oldVal = locatorRef.get(); if (oldVal.getAffinity().equals(newAffinity)) { return; } newVal = oldVal.withNewAffinity(newAffinity); } while (! locatorRef.compareAndSet(oldVal, newVal)); }
boolean compareAndSetStrongAffinity(final Affinity expectedAffinity, final Affinity newAffinity) { Assert.checkNotNullParam("expectedAffinity", expectedAffinity); Assert.checkNotNullParam("newAffinity", newAffinity); final AtomicReference<EJBLocator<T>> locatorRef = this.locatorRef; EJBLocator<T> oldVal = locatorRef.get(); if (! oldVal.getAffinity().equals(expectedAffinity)) { return false; } EJBLocator<T> newVal = oldVal.withNewAffinity(newAffinity); return locatorRef.compareAndSet(oldVal, newVal); } }
public EJBHomeLocator<T> withNewAffinity(final Affinity affinity) { Assert.checkNotNullParam("affinity", affinity); return getAffinity().equals(affinity) ? this : new EJBHomeLocator<T>(this, affinity); }
public StatefulEJBLocator<T> withSessionAndAffinity(final SessionID sessionId, final Affinity affinity) { Assert.checkNotNullParam("sessionId", sessionId); Assert.checkNotNullParam("affinity", affinity); return getAffinity().equals(affinity) && getSessionId().equals(sessionId) ? this : new StatefulEJBLocator<T>(this, sessionId, affinity); }
public StatefulEJBLocator<T> withSessionAndAffinity(final SessionID sessionId, final Affinity affinity) { Assert.checkNotNullParam("sessionId", sessionId); Assert.checkNotNullParam("affinity", affinity); return getAffinity().equals(affinity) && getSessionId().equals(sessionId) ? this : new StatefulEJBLocator<T>(this, sessionId, affinity); }