View Javadoc

1   package net.trajano.twiff.container;
2   
3   import org.picocontainer.MutablePicoContainer;
4   
5   /***
6    * <p>
7    * Implementors of this interface will be called when populating PicoContainers
8    * with components. Methods would generally look like:
9    * </p>
10   * <p>
11   * <code>container.registerComponentImplementation(SomeObject.class);</code>
12   * </p>
13   * <p>
14   * The use of this method was prefered over nanocontainer's approach of using
15   * external scripting languages for flexibility. Using this method allows for
16   * stricter compile time checks.
17   * </p>
18   * <p>
19   * NOTE: do not register the following classes or implementors into the
20   * containers as they are used by the system:
21   * </p>
22   * <ul>
23   * <li>{@link javax.servlet.ServletContext}</li>
24   * <li>{@link javax.servlet.http.HttpSession}</li>
25   * </ul>
26   * 
27   * @author Archimedes Trajano
28   */
29  public interface ContainerBuilder {
30      /***
31       * This method registers components in the application level. Namely the
32       * {@link javax.servlet.ServletContext}. Please note that there one
33       * ServletContext created for every virtual machine so ensure that
34       * components for this container are not meant to be shared.
35       * 
36       * @param container
37       *                   the container to populate.
38       */
39      void buildApplicationLevelContainer(MutablePicoContainer container);
40  
41      /***
42       * This method registers components per request. Though creating the
43       * container may be quick, since PicoContainers are quite small, you should
44       * avoid putting too much things in here as well.
45       * 
46       * @param container
47       *                   the container to populate.
48       */
49      void buildRequestLevelContainer(MutablePicoContainer container);
50  
51      /***
52       * This method registers components in the session level. Namely the
53       * {@link javax.servlet.http.HttpSession}. This is created once per
54       * session, but it is replicated across all nodes in a cluster so do not
55       * make this too big.
56       * 
57       * @param container
58       *                   the container to populate.
59       */
60      void buildSessionLevelContainer(MutablePicoContainer container);
61  }