public static HttpSession deserializeInto(byte[] data, HttpSession session, ClassLoader loader) throws IOException, ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { if (data != null && data.length > 0 && session != null) { Field facadeSessionField = StandardSessionFacade.class.getDeclaredField("session"); facadeSessionField.setAccessible(true); StandardSession standardSession = (StandardSession) facadeSessionField.get(session); // StandardSessionFacade standardSession = (StandardSessionFacade) // session; BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(data)); ObjectInputStream ois = new CustomObjectInputStream(bis, loader); standardSession.setCreationTime(ois.readLong()); standardSession.readObjectData(ois); } return session; }
@Override public void deserializeInto(byte[] data, RedisSession session, SessionSerializationMetadata metadata) throws IOException, ClassNotFoundException { try( BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(data)); ObjectInputStream ois = new CustomObjectInputStream(bis, loader); ) { SessionSerializationMetadata serializedMetadata = (SessionSerializationMetadata)ois.readObject(); metadata.copyFieldsFrom(serializedMetadata); session.readObjectData(ois); } }
@Override public void deserializeInto(byte[] data, CustomSession session, SessionMetadata metadata) throws IOException, ClassNotFoundException { try (BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(data)); ObjectInputStream ois = new CustomObjectInputStream(bis, loader);) { SessionMetadata serializedMetadata = (SessionMetadata) ois.readObject(); metadata.copyFieldsFrom(serializedMetadata); session.readObjectData(ois); } }
protected final NonStickySession fromBinary(byte[] binary) throws ClassNotFoundException, IOException { try (ObjectInputStream ois = new CustomObjectInputStream(new ByteArrayInputStream(binary), loader)) { NonStickySession session = createEmptySession(); session.readObjectData(ois); session.setManager(this); return session; } }