/*
(non-Javadoc)
@see
org.exoplatform.services.jcr.ext.app.SessionProviderService#getSystemSessionProvider(java.lang
.Object)
962546
public SessionProvider getSystemSessionProvider(Object key)
   {
      if (systemProviders.containsKey(key))
      {
         return systemProviders.get(key);
      }
      else
      {
         final SessionProvider ssp = SessionProvider.createSystemProvider();
         systemProviders.put(key, ssp);
         return ssp;
      }
   }
120475
public PMSession getSession(String sessionId) {
        final PMSession s = sessions.get(sessionId);
        if (s != null) {
            s.setLastAccess(new Date());
        }
        return s;
    }
999603
@Override
  public IAccSessionData getAppSessionData(Class<? extends AppSession> clazz, String sessionId) {
    if (clazz.equals(ClientAccSession.class)) {
      ClientAccSessionDataReplicatedImpl data =
          new ClientAccSessionDataReplicatedImpl(sessionId, this.mobicentsCluster, this.replicatedSessionDataSource.getContainer());
      return data;
    }
    else if (clazz.equals(ServerAccSession.class)) {
      ServerAccSessionDataReplicatedImpl data = new ServerAccSessionDataReplicatedImpl(sessionId, this.mobicentsCluster);
      return data;
    }
    throw new IllegalArgumentException();
  }
1107675
final protected function getSessionProvider()
    {
        if ($this->sessionProvider == null) {
            $this->sessionProvider = $this->getNewSessionProvider();
        }

        return $this->sessionProvider;
    }
57955
public final MobicentsSipSession getSipSession() {
		if(logger.isDebugEnabled()) {
			logger.debug("getSipSession");
		}

		if(sipSession == null && sessionKey == null) {
			sessionKey = getSipSessionKey();
			if(logger.isDebugEnabled()) {
				logger.debug("sessionKey is " + sessionKey);
			}
			if(sessionKey == null) {
				if(sipSession == null) {
					if(transactionApplicationData != null) {
						this.sessionKey =  transactionApplicationData.getSipSessionKey();
						if(logger.isDebugEnabled()) {
							logger.debug("session Key is " + sessionKey + ", retrieved from the txAppData " + transactionApplicationData);
						}
					} else if (transaction != null && transaction.getApplicationData() != null) {
						this.sessionKey =  ((TransactionApplicationData)transaction.getApplicationData()).getSipSessionKey();
						if(logger.isDebugEnabled()) {
							logger.debug("session Key is " + sessionKey + ", retrieved from the transaction txAppData " +
									(TransactionApplicationData)transaction.getApplicationData());
						}
					} else {
						if(logger.isDebugEnabled()) {
							logger.debug("txAppData and transaction txAppData are both null, there is no wya to retrieve the sessionKey anymore");
						}
					}
				} else {
					this.sessionKey = sipSession.getKey();
				}
			}
			if(logger.isDebugEnabled()) {
				logger.debug("sessionKey is " + sessionKey);
			}
		}
		if(sipSession == null && sessionKey != null) {
			if(logger.isDebugEnabled()) {
				logger.debug("session is null, trying to load the session from the sessionKey " + sessionKey);
			}
			final String applicationName = sessionKey.getApplicationName();
			final SipContext sipContext = sipFactoryImpl.getSipApplicationDispatcher().findSipApplication(applicationName);
			SipApplicationSessionKey sipApplicationSessionKey = new SipApplicationSessionKey(sessionKey.getApplicationSessionId(), sessionKey.getApplicationName(), null);
			MobicentsSipApplicationSession sipApplicationSession = sipContext.getSipManager().getSipApplicationSession(sipApplicationSessionKey, false);
			sipSession = sipContext.getSipManager().getSipSession(sessionKey, false, sipFactoryImpl, sipApplicationSession);
			if(logger.isDebugEnabled()) {
				if(sipSession == null) {
					logger.debug("couldn't find any session with sessionKey " + sessionKey);
				} else {
					logger.debug("reloaded session session " + sipSession + " with sessionKey " + sessionKey);
				}
			}
		}
		return sipSession;
	}
152877
public Session getSession() throws HibernateException
    {
        Session s = threadSession.get();
        if (s == null)
        {
            s = initSession();
        }

        return s;
    }
370400
public static systemsession get(nitro_service service, Long sid) throws Exception{
		systemsession obj = new systemsession();
		obj.set_sid(sid);
		systemsession response = (systemsession) obj.get_resource(service);
		return response;
	}
857136
public synchronized static Session getSession() {
        if(session == null){
            Properties properties = IOUtil.loadProperties("jdbc.properties");
            session = getSession(properties);
        }

        return session;
    }
1268174
@SuppressWarnings("deprecation")
    @Override
    public boolean isRequestedSessionIdFromUrl() {
        try {
            collaborator.preInvoke(componentMetaData);
            return request.isRequestedSessionIdFromUrl();
        } finally {
            collaborator.postInvoke();
        }
    }
1231056
protected Session getSession()
        throws EFapsException
    {
        if (this.session == null) {
            try {
                String username = getProperties().get(JCRStoreResource.PROPERTY_USERNAME);
                if (username == null) {
                    username = Context.getThreadContext().getPerson().getName();
                }
                String passwd = getProperties().get(JCRStoreResource.PROPERTY_PASSWORD);
                if (passwd == null) {
                    passwd = "efaps";
                }
                this.session = this.repository.login(new SimpleCredentials(username, passwd.toCharArray()),
                                getProperties().get(JCRStoreResource.PROPERTY_WORKSPACENAME));
            } catch (final LoginException e) {
                throw new EFapsException(JCRStoreResource.class, "initialize.LoginException", e);
            } catch (final NoSuchWorkspaceException e) {
                throw new EFapsException(JCRStoreResource.class, "initialize.NoSuchWorkspaceException", e);
            } catch (final RepositoryException e) {
                throw new EFapsException(JCRStoreResource.class, "initialize.RepositoryException", e);
            }
        }
        return this.session;
    }
77525
@Override
  public ICCASessionData getAppSessionData(Class<? extends AppSession> clazz, String sessionId) {
    if (clazz.equals(ClientCCASession.class)) {
      ClientCCASessionDataReplicatedImpl data =
          new ClientCCASessionDataReplicatedImpl(sessionId, this.mobicentsCluster, this.replicatedSessionDataSource.getContainer());
      return data;
    }
    else if (clazz.equals(ServerCCASession.class)) {
      ServerCCASessionDataReplicatedImpl data = new ServerCCASessionDataReplicatedImpl(sessionId, this.mobicentsCluster);
      return data;
    }
    throw new IllegalArgumentException();
  }
58334
@Override
    public ProducerSession createSystemProducerSession(SIDestinationAddress destAddress,
                                                       String discriminator,
                                                       DestinationType destFilter,
                                                       OrderingContext context,
                                                       String alternateUser)
                    throws SIConnectionUnavailableException, SIConnectionDroppedException,
                    SIResourceException, SIConnectionLostException, SILimitExceededException,
                    SIErrorException,
                    SINotAuthorizedException,
                    SINotPossibleInCurrentConfigurationException,
                    SIIncorrectCallException
    {
        return createSystemProducerSession(destAddress,
                                           discriminator,
                                           destFilter,
                                           context,
                                           alternateUser,
                                           true);
    }
711283
protected Object getSession(String id, int version, boolean isSessionAccess, boolean forceSessionRetrieval, Object xdCorrelator) {
        if (isSessionAccess) {
            if (version == -1) {
                _store.refreshSession(id, xdCorrelator);
            } else {
                _store.refreshSession(id, version, xdCorrelator);
            }
        }

        ISession iSession = getSessionFromStore(id, version, isSessionAccess, forceSessionRetrieval, xdCorrelator);
        if (iSession != null) {
            if (isSessionAccess) {
                boolean stillValid = _store.checkSessionStillValid(iSession, iSession.getLastAccessedTime());
                if (stillValid) {
                    iSession.incrementRefCount();
                    _sessionEventDispatcher.sessionAccessed(iSession);
                } else {
                    iSession = null;
                }
            }
        } else {
            if (isSessionAccess) {
                _sessionEventDispatcher.sessionAccessUnknownKey(id);
            }
        }
        return iSession;
    }
1002763
@Override
  public ICxDxSessionData getAppSessionData(Class<? extends AppSession> clazz, String sessionId) {
    if (clazz.equals(ClientCxDxSession.class)) {
      ClientCxDxSessionDataReplicatedImpl data =
          new ClientCxDxSessionDataReplicatedImpl(sessionId, this.mobicentsCluster, this.replicatedSessionDataSource.getContainer());
      return data;
    }
    else if (clazz.equals(ServerCxDxSession.class)) {
      ServerCxDxSessionDataReplicatedImpl data =
          new ServerCxDxSessionDataReplicatedImpl(sessionId, this.mobicentsCluster, this.replicatedSessionDataSource.getContainer());
      return data;
    }
    throw new IllegalArgumentException();
  }
1147433
public ObjectName getSessionManager()
    {
        SessionManager sm=_servletHandler.getSessionManager();
        if (sm==null)
            return null;
        ObjectName[] on=getComponentMBeans(new Object[]{sm},null);
        return on[0];
    }
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);

    }
1341917
@Override
    public String getSessionId() {
        ServletRESTRequestImpl ret = castRequest();
        if (ret != null)
            return ret.getSessionId();
        return null;
    }