public interface ServerInit
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:
InitListener
, which is a ServletContextListener
:<listener> <listener-class>com.isomorphic.base.InitListener</listener-class> </listener>
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>
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.
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.