com.smartgwt.client.docs

## Interface ServerInit

-     public interface ServerInit

  ### Server Framework Initialization

  The Smart GWT Server framework must be initialized from its config files at startup time, before user code invokes any framework functionality. If you are running standalone (ie, outside of a servlet container), you should call the static utility method `ISCInit.go()` early in your bootstrap code (eg, from the top of your `main()` method).

  If you are running inside a servlet engine, there are two ways to initialize the framework:

  - Install `InitListener`, which is a `ServletContextListener`:

           <listener>
                 <listener-class>com.isomorphic.base.InitListener</listener-class>
             </listener>

  - Install `Init`, which is a `Servlet`, to load at startup:

            <servlet>
                 <servlet-name>Init</servlet-name>
                 <servlet-class>com.isomorphic.base.Init</servlet-class>
                 <load-on-startup>1</load-on-startup>
             </servlet>

  As shipped, the framework's `web.xml` file loads both of these classes, to ensure the best chance of correct and early initialization. The recommended approach is to use `InitListener` if your servlet container implements the Servlet 2.4 API or greater, because `ServletContextListener`s are guaranteed to run before any servlets or filters are instantiated. `ServletContextListener`s are available in Servlet API 2.3, but the requirement that they run before any filter or servlet is initialized was not added until 2.4. Some 2.3 servlet engines do enforce this behavior even though it is not part of the spec; experimentation with your servlet container of choice will be required if it only implements 2.3.

  Note that it does no harm to leave the `web.xml` file with both `Init` and `InitListener` in place, because the framework simply ignores any request to initialize once initialization has taken place.

  #### Interaction with Spring initialization

  The Spring framework attempts to initialize itself in similar ways to the Smart GWT framework, and similarly it wants its own initialization to be the very first thing that happens. This can cause problems in certain cases. For example, one known problem occurs when you define DataSource instances as Spring beans, and Spring gets to initialize itself first: it attempts to instantiate a instance of the bean, which ultimately calls into our framework code before the framework has been initialized.

  The solution to this is to use the `InitListener`, and to ensure that it is declared in your `web.xml` file before the Spring `ContextLoaderListener`. The Servlet 2.3 spec states (SRV.10.3.3):

  "During Web application execution, listeners are invoked in the order of their registration."

  Therefore, declaring the Smart GWT listener before the Spring one ensures that things run in the correct order in Servlet 2.4-compatible containers, and in those Servlet 2.3 containers that enforce the rule of running listeners before initializing filters or servlets.