Esempio n. 1
0
  @Override
  public void requestInitialized(ServletRequestEvent event) {
    if (hasConversationContext(event)) {
      String cid = getConversationId(event);

      HttpConversationContext conversationContext =
          instance().select(HttpConversationContext.class).get();

      ManagedConversation conversation = conversationContext.getConversation(cid);

      if (conversation == null) {
        try {
          conversation = conversationContext.getCurrentConversation();
        } catch (IllegalStateException ie) {
          conversation = null;
        }
      }

      if (conversation != null) {

        if (!conversationContext.isActive()) {
          conversationContext.activate(cid);
        }

        log.debug("Conversation Status: Expired [" + isExpired(conversation) + "]");

        conversation.touch();

        //				conversationContext.invalidate();
        if (conversationContext.isActive()) {
          // Only deactivate the context if one is already active, otherwise we get Exceptions
          conversationContext.deactivate();
        }
      }
    }
  }
Esempio n. 2
0
 private static boolean isExpired(ManagedConversation conversation) {
   return System.currentTimeMillis() > (conversation.getLastUsed() + conversation.getTimeout());
 }