You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by brownie <fe...@gmail.com> on 2009/11/11 11:21:50 UTC
Is it possible to load a servlet on the standalone server startup?
I need to write JUnit tests for an existing project. There are some servlets
that should be loaded to initialize some stuff.
Is it possible to load a servlet on the standalone server startup, e.g.
using Jetty?
Thanks in advance.
--
View this message in context: http://old.nabble.com/Is-it-possible-to-load-a-servlet-on-the-standalone-server-startup--tp26299042p26299042.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Is it possible to load a servlet on the standalone server
startup?
Posted by Quintin Beukes <qu...@skywalk.co.za>.
I'm not sure about the servlet, but if you're using OpenEJB 3.1.2 you
can use the @Startup annotation on a Singleton EJB to do the
initialization. You can also make such a bean only available in your
tests, so initialization for tests happen through this and in
production through the servlet. Delegating this to a dedicated
Initialize class/object would centralize the code.
Quintin Beukes
On Wed, Nov 11, 2009 at 12:21 PM, brownie <fe...@gmail.com> wrote:
>
> I need to write JUnit tests for an existing project. There are some servlets
> that should be loaded to initialize some stuff.
> Is it possible to load a servlet on the standalone server startup, e.g.
> using Jetty?
>
> Thanks in advance.
> --
> View this message in context: http://old.nabble.com/Is-it-possible-to-load-a-servlet-on-the-standalone-server-startup--tp26299042p26299042.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>
Re: Is it possible to load a servlet on the standalone server
startup?
Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.
Hi,
not sure it's the better mailing list t talk about Servlet.
Never mind, to specify a load order, you can try something like
<servlet>
<servlet-name>Servlet name</servlet-name>
<display-name>Display name</display-name>
<servlet-class>XXXServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<load-on-startup>0</load-on-startup> indicates that the servlet won't be
started until a request tries to access it.
If load-on-startup is greater than zero then when the container starts it
will start that servlet in ascending order of the load on startup value you
put there (ie 1 then 2 then 5 then 10 and so on).
IMO, it would be better to use a servlet listener and implement the
contextInitialized method.
Hope it helps.
Jean-Louis
brownie wrote:
>
> I need to write JUnit tests for an existing project. There are some
> servlets that should be loaded to initialize some stuff.
> Is it possible to load a servlet on the standalone server startup, e.g.
> using Jetty?
>
> Thanks in advance.
>
--
View this message in context: http://old.nabble.com/Is-it-possible-to-load-a-servlet-on-the-standalone-server-startup--tp26299042p26304910.html
Sent from the OpenEJB User mailing list archive at Nabble.com.