Re: Where can I do some application initialize work?

2002-04-04 Thread Max Cooper

Annie,

Write a servlet with an init() method that initializes Torque, and specify
that this servlet should load at startup in your web.xml file. Perhaps you
could turn your existing DataModel class into a servlet for this purpose.
See the ActionServlet stuff in web.xml for how to make a servlet load at
startup (give your servlet a lower number than ActionServlet to make yours
load first).

-Max

- Original Message -
From: "Annie Zhang" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, April 03, 2002 6:39 PM
Subject: Where can I do some application initialize work?


HI,

I'm using struts & torque together. I put some initialize code in one of my
class as a static code. But these code is not executed until class DataModel
is lodaded. So, if I call any function of Torque, it will report that
"Torque is not initialized".

Where can I put some global initialize code for the application ? Thanks.

Annie

public class DataModel {

  static {
  try{
  Torque.init("piso.properties");
  }
  catch (Exception e)
  {
  e.printStackTrace();
  }
  }





--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Where can I do some application initialize work?

2002-04-04 Thread Chuck Cavaness

If you're using 1.1, you can setup a plugin for it. If you're using a 2.3 
container and don't need to support 2.2, you can setup a event listener on 
the servlet context creation for the application. Or you could just put 
initialize it in the init() method of the ActionServlet.

Chuck


At 06:39 PM 4/3/2002 -0800, you wrote:
>HI,
>
>I'm using struts & torque together. I put some initialize code in one of 
>my class as a static code. But these code is not executed until class 
>DataModel is lodaded. So, if I call any function of Torque, it will report 
>that "Torque is not initialized".
>
>Where can I put some global initialize code for the application ? Thanks.
>
>Annie
>
>public class DataModel {
>
>   static {
>   try{
>   Torque.init("piso.properties");
>   }
>   catch (Exception e)
>   {
>   e.printStackTrace();
>   }
>   }


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Where can I do some application initialize work?

2002-04-03 Thread Annie Zhang

HI,

I'm using struts & torque together. I put some initialize code in one of my class as a 
static code. But these code is not executed until class DataModel is lodaded. So, if I 
call any function of Torque, it will report that "Torque is not initialized". 

Where can I put some global initialize code for the application ? Thanks.

Annie 

public class DataModel {

  static {
  try{
  Torque.init("piso.properties");
  }
  catch (Exception e)
  {
  e.printStackTrace();
  }
  }