/** * Reconstitute the session ID from this serialized representation. * * @return the session ID object */ protected Object readResolve() { return createSessionID(id); } }
@Override public void write(DataOutput output, SessionID id) throws IOException { byte[] encoded = id.getEncodedForm(); IndexSerializer.UNSIGNED_BYTE.writeInt(output, encoded.length); output.write(encoded); }
/** * Determine whether this object is equal to another. Session IDs are equal if their encoded form is * equal and the class is equal. * * @param other the other object * @return {@code true} if they are equal, {@code false} otherwise */ public final boolean equals(Object other) { return this == other || other != null && other.getClass() == getClass() && equals((SessionID) other); }
@Override public Object processInvocation(final InterceptorContext context) throws Exception { if (context.getMethod().getName().equals("equals") || context.getMethod().getName().equals("isIdentical")) { final Object other = context.getParameters()[0]; final ComponentView componentView = context.getPrivateData(ComponentView.class); final Class<?> proxyType = componentView.getProxyClass(); final SessionID sessionId = context.getPrivateData(SessionID.class); if( proxyType.isAssignableFrom(other.getClass())) { //now we know that this is an ejb for the correct component view //as digging out the session id from the proxy object is not really //a viable option, we invoke equals() for the other instance with a //SessionIdHolder as the other side return other.equals(new SessionIdHolder(sessionId)); } else if(other instanceof SessionIdHolder) { return sessionId.equals( ((SessionIdHolder)other).sessionId); } else { return false; } } else if (context.getMethod().getName().equals("hashCode")) { final SessionID sessionId = context.getPrivateData(SessionID.class); //use the identity of the component view as a hash code return sessionId.hashCode(); } else { return context.proceed(); } }
int calculateHashCode() { return sessionId.hashCode() * 13 + super.calculateHashCode(); }
if (instance == null) { throw EjbLogger.ROOT_LOGGER.couldNotFindEjb(sessionId.toString());
@Override public Object processInvocation(final InterceptorContext context) throws Exception { if (context.getMethod().getName().equals("equals") || context.getMethod().getName().equals("isIdentical")) { final Object other = context.getParameters()[0]; final Class<?> proxyType = componentView.getProxyClass(); if( proxyType.isAssignableFrom(other.getClass())) { //now we know that this is an ejb for the correct component view //as digging out the session id from the proxy object is not really //a viable option, we invoke equals() for the other instance with a //SessionIdHolder as the other side return other.equals(new SessionIdHolder(sessionIdReference.get())); } else if(other instanceof SessionIdHolder) { return sessionIdReference.get().equals( ((SessionIdHolder)other).sessionId); } else { return false; } } else if (context.getMethod().getName().equals("hashCode")) { //use the identity of the component view as a hash code return sessionIdReference.get().hashCode(); } else { return context.proceed(); } }
int calculateHashCode() { return sessionId.hashCode() * 13 + super.calculateHashCode(); }
if (instance == null) { throw EjbMessages.MESSAGES.couldNotFindEjb(sessionId.toString());
@Override public SessionID read(DataInput input) throws IOException { byte[] encoded = new byte[IndexSerializer.UNSIGNED_BYTE.readInt(input)]; input.readFully(encoded); return SessionID.createSessionID(encoded); }
final byte[] bytes = sessionId.getEncodedForm(); PackedInteger.writePackedInteger(os, bytes.length); os.write(bytes);
/** * 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(final StatefulEJBLocator<?> other) { return super.equals(other) && sessionId.equals(other.sessionId); }
int calculateHashCode() { return sessionId.hashCode() * 13 + super.calculateHashCode(); }
result.completeExceptionally(EjbHttpClientMessages.MESSAGES.noSessionIdInResponse()); } else { SessionID sessionID = SessionID.createSessionID(Base64.getUrlDecoder().decode(sessionId)); result.complete(sessionID);
.setBeanName(locator.getBeanName()); if (locator instanceof StatefulEJBLocator) { builder.setBeanId(Base64.getUrlEncoder().encodeToString(locator.asStateful().getSessionId().getEncodedForm()));
public void convertToStateful(@NotNull final SessionID sessionId) throws IllegalArgumentException, IllegalStateException { Assert.checkNotNullParam("sessionId", sessionId); final SessionID ourSessionId = this.sessionId; if (ourSessionId != null) { if (! sessionId.equals(ourSessionId)) { throw new IllegalStateException(); } } else { this.sessionId = sessionId; } }
byte[] encoded = new byte[PackedInteger.readPackedInteger(inputStream)]; inputStream.readFully(encoded); final SessionID sessionID = SessionID.createSessionID(encoded); final Object invokedProxy = context.getInvokedProxy(); EJBClient.convertToStateful(invokedProxy, sessionID);
os.writeByte(Protocol.OPEN_SESSION_RESPONSE); os.writeShort(invId); final byte[] encodedForm = sessionId.getEncodedForm(); PackedInteger.writePackedInteger(os, encodedForm.length); os.write(encodedForm);
public StatefulEJBLocator<T> withSession(final SessionID sessionId) { Assert.checkNotNullParam("sessionId", sessionId); if (sessionId.equals(this.sessionId)) { return this; } else { return new StatefulEJBLocator<T>(this, sessionId); } }
StatefulEJBLocator<T> locator = statelessLocator.withSessionAndAffinity(SessionID.createSessionID(bytes), affinity); clientInvocationContext.setLocator(locator); return locator;