Java 类org.apache.catalina.util.CustomObjectInputStream 实例源码

项目:geeCommerce-Java-Shop-Software-and-PIM    文件:JavaSerializer.java   
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;
}
项目:tomcat8-redis-session-manager    文件:JavaSerializer.java   
@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);
  }
}
项目:various_demos    文件:JavaSerializer.java   
@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);
  }
}
项目:tomcat-extensions-redis-session-manager    文件:JavaSerializer.java   
@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);
    }
}
项目:distributed-session-manager    文件:JavaSerializer.java   
@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);
    }
}
项目:tomcat-redis-session-manager    文件:NonStickySessionManager.java   
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;
    }
}