Stream the data into an existing session

@param session
@param context
@return
@throws IOException
@throws ClassNotFoundException
494033
public static StatefulKnowledgeSessionImpl readSession(StatefulKnowledgeSessionImpl session,
                                                    MarshallerReaderContext context) throws IOException,
                                                                                    ClassNotFoundException {

        ProtobufMessages.KnowledgeSession _session = loadAndParseSession( context );

        InternalAgenda agenda = resetSession( session,
                                             context,
                                             _session );

        readSession( _session,
                     session,
                     agenda,
                     context );

        return session;
    }
311918
public static void deserializeSessionAttributes(final HttpSession session) {
		File file = new File(SERIALIZE_SESSION_NAME);
		FileInputStream fis = null;
		ObjectInputStream ois = null;

		if (file.canRead()) {
			try {
				fis = new FileInputStream(file);
				ois = new ObjectInputStream(fis);

				List data = (List) ois.readObject();

				for (Iterator i = data.iterator(); i.hasNext();) {
					String key = (String) i.next();
					Object value = i.next();
					session.setAttribute(key, value);
				}
			} catch (Exception e) {
				LOG.error("Failed to read serialized session from " + file, e);
			} finally {
				if (ois != null) {
					StreamUtil.safeClose(ois);
				} else {
					StreamUtil.safeClose(fis);
				}
			}
		} else {
			LOG.warn("Unable to read serialized session from " + file);
		}
	}
996902
private void makeReadWrite(final Session session)
	{
		session.doWork(SetJDBCConnectionReadOnlyWork.READ_WRITE);
		session.setHibernateFlushMode(FlushMode.AUTO);
	}
531393
public Subscription registerDolphinContext(ClientSession session, GarbageCollector garbageCollector) {
        Assert.requireNonNull(session, "session");
        Assert.requireNonNull(garbageCollector, "garbageCollector");
        DolphinSessionInfoMBean mBean = new DolphinSessionInfo(session, garbageCollector);
        return MBeanRegistry.getInstance().register(mBean, new MBeanDescription("com.canoo.dolphin", "DolphinSession", "session"));
    }
731546
public static void log(IoSession session, Throwable t) {
        Logger logger = getTransportLogger(session);
        log(session, logger, t);
    }
909588
@Override
    public Object getSession(ServletRequest request, ServletResponse response, SessionAffinityContext affinityContext, boolean create) {

        /*
         * Check to see if the request provides a JSESSIONID cookie
         */
        String sessionID = _sam.getInUseSessionID(request, affinityContext);
        int sessionVersion = _sam.getInUseSessionVersion(request, affinityContext); // affinityContext.getRequestedSessionVersion();
        ISession session = null;

        /*
         * If the sessionID is not null, this may be a request with an existing
         * session.
         */
        if (sessionID != null) {
            session = (ISession) getSession(sessionID, sessionVersion, true, null);
            if (session == null && affinityContext.isRequestedSessionIDFromCookie() // perform allIds call and reset sac
                            && !affinityContext.isAllSessionIdsSetViaSet()){  //PM89885 add another check for isAllSessionIdsSetViaSet since we may have done a set in HttpSessionContextImpl.getIHttpSession
                List allSessionIds = _sam.getAllCookieValues(request);
                affinityContext.setAllSessionIds(allSessionIds);
            }
        }

        while ((session == null) && (_sam.setNextId(affinityContext))) {
            sessionID = _sam.getInUseSessionID(request, affinityContext);
            sessionVersion = _sam.getInUseSessionVersion(request, affinityContext); // affinityContext.getRequestedSessionVersion();
            session = (ISession) getSession(sessionID, sessionVersion, true, null);
        }

        /*
         * If the session is null, create a new one if required. The session manager
         * will check
         * to see if an alternate webmodule has a session created using
         * this session id. If not, the session object returned may have a different
         * session id from the one supplied.
         */
        if ((session == null) && create) {
            boolean reuseThisID = false;
            if (_store.getShouldReuseId() || affinityContext.isResponseIdSet() || affinityContext.isRequestedSessionIDFromSSL()) {
                reuseThisID = true;
            }
            session = createISession(sessionID, sessionVersion, reuseThisID);
        }

        return adaptAndSetCookie(request, response, affinityContext, session);

    }
358363
public List<HttpSession> getHttpSessionsForContext(Context context) {
		List<HttpSession> sessions = new LinkedList<>();
		if (this.sessions == null) {
			return sessions;
		}

		synchronized (sessionLock) {
			for (Entry<String, HttpSessionsSite> e : this.sessions.entrySet()) {
				String siteName = e.getKey();
				siteName = "http://" + siteName;
				if (context.isInContext(siteName))
					sessions.addAll(e.getValue().getHttpSessions());
			}
		}

		return sessions;
	}
564231
@Override
    public final void sessionOpened(IoSession session) throws Exception {
        ProxyIoSession proxyIoSession = (ProxyIoSession) session
                .getAttribute(ProxyIoSession.PROXY_SESSION);

        if (proxyIoSession.getRequest() instanceof SocksProxyRequest
                || proxyIoSession.isAuthenticationFailed()
                || proxyIoSession.getHandler().isHandshakeComplete()) {
            proxySessionOpened(session);
        } else {
            logger.debug("Filtered session opened event !");
        }
    }
121125
public static void stream(String path, String method, ApiClient client, SocketListener listener)
      throws ApiException, IOException {
    stream(path, method, new ArrayList<Pair>(), client, listener);
  }
93188
public void initiate() throws IOException
    {
        logger.debug("[Stream #{}] Sending stream init for incoming stream", session.planId());
        Socket incomingSocket = session.createConnection();
        incoming.start(incomingSocket, StreamMessage.CURRENT_VERSION);
        incoming.sendInitMessage(incomingSocket, true);

        logger.debug("[Stream #{}] Sending stream init for outgoing stream", session.planId());
        Socket outgoingSocket = session.createConnection();
        outgoing.start(outgoingSocket, StreamMessage.CURRENT_VERSION);
        outgoing.sendInitMessage(outgoingSocket, false);
    }
92530
protected synchronized IHttpSessionContext createSessionContext(
                                                                  String appName,
                                                                  boolean distributableWebApp, boolean allowDispatchRemoteInclude, 
                                                                  WebApp sc, ClassLoader appCl,
                                                                  SessionManagerConfig smc, String j2eeName,
                                                                  boolean sessionSharing, String applicationSessionAppName) throws Throwable {

        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.entering(methodClassName, methodNames[CREATE_SESSION_CONTEXT]);
        }
        // ensure no other thread just finished creating
        IHttpSessionContext sessCtx = (IHttpSessionContext)scrSessionContexts.get(appName);
        if (sessCtx == null) {
            WebAppConfiguration webAppConfig=sc.getConfiguration();
            SessionApplicationParameters sap = new SessionApplicationParameters(appName, 
                                                                                webAppConfig.isModuleSessionTimeoutSet(),
                                                                                webAppConfig.getSessionTimeout(),
                                                                                distributableWebApp, 
                                                                                allowDispatchRemoteInclude, 
                                                                                sc, 
                                                                                appCl, 
                                                                                j2eeName, 
                                                                                webAppConfig.getSessionCookieConfig(), 
                                                                                webAppConfig.isModuleSessionTrackingModeSet(), 
                                                                                webAppConfig.getSessionTrackingMode());
            if(webAppConfig.getSessionCookieConfig()!=null) {
                webAppConfig.setHasProgrammaticCookieConfig(); // in tWAS, this happens in SessionApplicationParameters(...)
            }
            
            //if session sharing or Servlet21Compatibility (the var sessionSharing should be true) - don't create appSession
            //and calls to getIBMApplicationSession will return null
            if (!sessionSharing) {
                sap.setHasApplicationSession(true);
                sap.setApplicationSessionName(applicationSessionAppName);
            }
            sessCtx = createSessionContextObject(smc, sap);
            scrSessionContexts.put(appName, sessCtx);
        }
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.exiting(methodClassName, methodNames[CREATE_SESSION_CONTEXT]);
        }
        return sessCtx;
    }
20655
public void addHttpSession(HttpSession session) {
		synchronized (this.sessions) {
			this.sessions.add(session);
		}
		this.model.addHttpSession(session);
	}
1062992
private function initializeSessionContext()
    {
        $sessionServer = SessionServer::create($this)->getValue();
        $this->sessionContext = SessionContext::create($sessionServer);
    }
470889
private void write(IoSession session, IoBuffer data) {
        IoBuffer dest = buffersMap.putIfAbsent(session,
                new IoBufferLazyInitializer(bufferSize));

        write(session, data, dest);
    }
685503
public Session newSession() {
		session = new Session(this);
		// Always start with one context
		session.saveContext(session.getNewContext(Constant.messages.getString("context.default.name")));
		return session;
	}
1303070
@Override
    public void exceptionCaught(IoSession session, Throwable cause) {
        final IoSessionInputStream in = (IoSessionInputStream) session
                .getAttribute(KEY_IN);

        IOException e = null;
        if (cause instanceof StreamIoException) {
            e = (IOException) cause.getCause();
        } else if (cause instanceof IOException) {
            e = (IOException) cause;
        }

        if (e != null && in != null) {
            in.throwException(e);
        } else {
            LOGGER.warn("Unexpected exception.", cause);
            session.close(true);
        }
    }
1114919
private void readObject(ObjectInputStream stream)
        throws IOException, ClassNotFoundException
    {
        stream.defaultReadObject();

        // set transient fields
        setOut( System.out );
        setErr( System.err );
    }