Package org.picketlink.identity.federation.web.servlets

Examples of org.picketlink.identity.federation.web.servlets.IDPServlet$SessionHolder


            while (en.hasMoreElements()) {
                String key = en.nextElement();
                try {
                    //log.debug("Opening Hibernate Session");
                    session = createSession(sessionFactory);
                    TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));

                    //log.debug(key);
                    ResourceMessage resourceMessage = null;
                    try {
                        resourceMessage = resourceMessageDao.findById(key);
View Full Code Here


        participate = true;
      }
      else {
        logger.debug("Opening single Hibernate Session in OpenSessionInViewFilter");
        Session session = getSession(sessionFactory);
        TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
      }
    }
    else {
      // deferred close mode
      if (SessionFactoryUtils.isDeferredCloseActive(sessionFactory)) {
        // Do not modify deferred close: just set the participate flag.
        participate = true;
      }
      else {
        SessionFactoryUtils.initDeferredClose(sessionFactory);
      }
    }

    try {
      filterChain.doFilter(request, response);
    }

    finally {
      if (!participate) {
        if (isSingleSession()) {
          // single session mode
          SessionHolder sessionHolder =
              (SessionHolder) TransactionSynchronizationManager.unbindResource(sessionFactory);
          logger.debug("Closing single Hibernate Session in OpenSessionInViewFilter");
          closeSession(sessionHolder.getSession(), sessionFactory);
        }
        else {
          // deferred close mode
          SessionFactoryUtils.processDeferredClose(sessionFactory);
        }
View Full Code Here

        // single session mode
        logger.debug("Opening single Hibernate Session in OpenSessionInViewInterceptor");
        Session session = SessionFactoryUtils.getSession(
            getSessionFactory(), getEntityInterceptor(), getJdbcExceptionTranslator());
        applyFlushMode(session, false);
        TransactionSynchronizationManager.bindResource(getSessionFactory(), new SessionHolder(session));
      }
      else {
        // deferred close mode
        SessionFactoryUtils.initDeferredClose(getSessionFactory());
      }
View Full Code Here

   * @see #setFlushMode
   */
  public void postHandle(WebRequest request, ModelMap model) throws DataAccessException {
    if (isSingleSession()) {
      // Only potentially flush in single session mode.
      SessionHolder sessionHolder =
          (SessionHolder) TransactionSynchronizationManager.getResource(getSessionFactory());
      logger.debug("Flushing single Hibernate Session in OpenSessionInViewInterceptor");
      try {
        flushIfNecessary(sessionHolder.getSession(), false);
      }
      catch (HibernateException ex) {
        throw convertHibernateAccessException(ex);
      }
    }
View Full Code Here

      }
    }
    else {
      if (isSingleSession()) {
        // single session mode
        SessionHolder sessionHolder =
            (SessionHolder) TransactionSynchronizationManager.unbindResource(getSessionFactory());
        logger.debug("Closing single Hibernate Session in OpenSessionInViewInterceptor");
        SessionFactoryUtils.closeSession(sessionHolder.getSession());
      }
      else {
        // deferred close mode
        SessionFactoryUtils.processDeferredClose(getSessionFactory());
      }
View Full Code Here

      else {
        boolean isFirstRequest = !isAsyncDispatch(request);
        if (isFirstRequest || !applySessionBindingInterceptor(asyncManager, key)) {
          logger.debug("Opening single Hibernate Session in OpenSessionInViewFilter");
          Session session = getSession(sessionFactory);
          SessionHolder sessionHolder = new SessionHolder(session);
          TransactionSynchronizationManager.bindResource(sessionFactory, sessionHolder);

          AsyncRequestInterceptor interceptor = new AsyncRequestInterceptor(sessionFactory, sessionHolder);
          asyncManager.registerCallableInterceptor(key, interceptor);
          asyncManager.registerDeferredResultInterceptor(key, interceptor);
        }
      }
    }
    else {
      // deferred close mode
      Assert.state(!isAsyncStarted(request), "Deferred close mode is not supported on async dispatches");
      if (SessionFactoryUtils.isDeferredCloseActive(sessionFactory)) {
        // Do not modify deferred close: just set the participate flag.
        participate = true;
      }
      else {
        SessionFactoryUtils.initDeferredClose(sessionFactory);
      }
    }

    try {
      filterChain.doFilter(request, response);
    }
    finally {
      if (!participate) {
        if (isSingleSession()) {
          // single session mode
          SessionHolder sessionHolder =
              (SessionHolder) TransactionSynchronizationManager.unbindResource(sessionFactory);
          if (!isAsyncStarted(request)) {
            logger.debug("Closing single Hibernate Session in OpenSessionInViewFilter");
            closeSession(sessionHolder.getSession(), sessionFactory);
          }
        }
        else {
          // deferred close mode
          SessionFactoryUtils.processDeferredClose(sessionFactory);
View Full Code Here

    SessionFactory sf = getSessionFactory();
    if (!TransactionSynchronizationManager.hasResource(sf)) {
      // New Session to be bound for the current method's scope...
      Session session = openSession();
      try {
        TransactionSynchronizationManager.bindResource(sf, new SessionHolder(session));
        return invocation.proceed();
      }
      finally {
        SessionFactoryUtils.closeSession(session);
        TransactionSynchronizationManager.unbindResource(sf);
View Full Code Here

        // single session mode
        logger.debug("Opening single Hibernate Session in OpenSessionInViewInterceptor");
        Session session = SessionFactoryUtils.getSession(
            getSessionFactory(), getEntityInterceptor(), getJdbcExceptionTranslator());
        applyFlushMode(session, false);
        SessionHolder sessionHolder = new SessionHolder(session);
        TransactionSynchronizationManager.bindResource(getSessionFactory(), sessionHolder);

        AsyncRequestInterceptor asyncRequestInterceptor =
            new AsyncRequestInterceptor(getSessionFactory(), sessionHolder);
        asyncManager.registerCallableInterceptor(participateAttributeName, asyncRequestInterceptor);
View Full Code Here

   */
  @Override
  public void postHandle(WebRequest request, ModelMap model) throws DataAccessException {
    if (isSingleSession()) {
      // Only potentially flush in single session mode.
      SessionHolder sessionHolder =
          (SessionHolder) TransactionSynchronizationManager.getResource(getSessionFactory());
      logger.debug("Flushing single Hibernate Session in OpenSessionInViewInterceptor");
      try {
        flushIfNecessary(sessionHolder.getSession(), false);
      }
      catch (HibernateException ex) {
        throw convertHibernateAccessException(ex);
      }
    }
View Full Code Here

  @Override
  public void afterCompletion(WebRequest request, Exception ex) throws DataAccessException {
    if (!decrementParticipateCount(request)) {
      if (isSingleSession()) {
        // single session mode
        SessionHolder sessionHolder =
            (SessionHolder) TransactionSynchronizationManager.unbindResource(getSessionFactory());
        logger.debug("Closing single Hibernate Session in OpenSessionInViewInterceptor");
        SessionFactoryUtils.closeSession(sessionHolder.getSession());
      }
      else {
        // deferred close mode
        SessionFactoryUtils.processDeferredClose(getSessionFactory());
      }
View Full Code Here

TOP

Related Classes of org.picketlink.identity.federation.web.servlets.IDPServlet$SessionHolder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.