View Javadoc

1   package net.trajano.twiff.adapter;
2   
3   import static net.trajano.twiff.internal.TwiffInternal.HTTP_SESSION_CONTAINER_KEY;
4   import javax.servlet.http.HttpSession;
5   import org.picocontainer.MutablePicoContainer;
6   import org.picocontainer.PicoContainer;
7   
8   /***
9    * This provides access to the {@link javax.servlet.http.HttpSession} data.
10   * Adapters like this are meant to remove the implicit casting performed by
11   * those that use it.
12   * 
13   * @author Archimedes Trajano
14   */
15  public class SessionAdapter {
16      /***
17       * The session level container.
18       */
19      private final MutablePicoContainer container;
20  
21      /***
22       * Creates the adapter.
23       * 
24       * @param session
25       *                   the session to adapt
26       */
27      public SessionAdapter(final HttpSession session) {
28          this.container = (MutablePicoContainer) session.getAttribute(HTTP_SESSION_CONTAINER_KEY);
29      }
30  
31      /***
32       * Returns the {@link PicoContainer} stored in the session. The container is
33       * stored in the attribute
34       * {@link net.trajano.twiff.internal.TwiffInternal#HTTP_SESSION_CONTAINER_KEY}.
35       * 
36       * @return the application level container.
37       */
38      public final MutablePicoContainer getContainer() {
39          return container;
40      }
41  }