View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.session;
8   
9   import org.mule.api.MuleException;
10  import org.mule.api.MuleMessage;
11  import org.mule.api.MuleSession;
12  import org.mule.api.config.MuleProperties;
13  import org.mule.api.transport.SessionHandler;
14  
15  import org.apache.commons.logging.Log;
16  import org.apache.commons.logging.LogFactory;
17  
18  /**
19   * A session handler used to store and retrieve session information on an
20   * event. The MuleSession information is stored as a header on the message (does not
21   * support Tcp, Udp, etc. unless the MuleMessage object is serialised across the
22   * wire). The session is stored in the "MULE_SESSION" property.
23   */
24  public class SimpleSessionHandler implements SessionHandler
25  {
26      protected transient Log logger = LogFactory.getLog(getClass());
27  
28      public MuleSession retrieveSessionInfoFromMessage(MuleMessage message) throws MuleException
29      {
30          return message.getInboundProperty(MuleProperties.MULE_SESSION_PROPERTY);
31      }
32  
33      /**
34       * @deprecated Use retrieveSessionInfoFromMessage(MuleMessage message) instead
35       */
36      public void retrieveSessionInfoFromMessage(MuleMessage message, MuleSession session) throws MuleException
37      {
38          session = retrieveSessionInfoFromMessage(message);
39      }
40  
41      public void storeSessionInfoToMessage(MuleSession session, MuleMessage message) throws MuleException
42      {
43          message.setOutboundProperty(MuleProperties.MULE_SESSION_PROPERTY, session);
44      }
45      
46      /**
47       * @deprecated This method is no longer needed and will be removed in the next major release
48       */
49      public String getSessionIDKey()
50      {
51          return "ID";
52      }
53  }