db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raphael.x.man...@gsk.com
Subject Re: Torque and jsp
Date Tue, 15 Mar 2005 16:01:15 GMT
Nice one!. However I am not always running in a servlet, sometimes it is a
stand-alone program.

However I do like the suggestion of using the class loader to locate it.
The true answer, of course, is that Torque.init() should itself search the
classpath. Add it to the TODO list.




|---------+---------------------------->
|         |           "Guy Galil"      |
|         |           <guy_galil@guardi|
|         |           um.com>          |
|         |                            |
|         |                            |
|         |           15-Mar-2005 14:54|
|         |           Please respond to|
|         |           "Apache Torque   |
|         |           Users List"      |
|         |           <torque-user@db.a|
|         |           pache.org>;      |
|         |           Please respond to|
|         |           Guy_Galil@guardiu|
|         |           m.com            |
|         |                            |
|---------+---------------------------->
  >-------------------------------------------------------------------------------------------------------------------------|
  |                                                                                      
                                  |
  |                                                                                      
                                  |
  |                                                                                      
                                  |
  |       To:      "Apache Torque Users List" <torque-user@db.apache.org>          
                                        |
  |                                                                                      
                                  |
  |       cc:                                                                            
                                  |
  |       Subject: Re: Torque and jsp                                                    
                                  |
  >-------------------------------------------------------------------------------------------------------------------------|



another alternative when you initiate Torque in  a servlet is to get the
actual full path from the servlet:

ServletContext ctxt = getServletContext();
String path = ctxt.getRealPath("/")+"/WEB-INF/conf/";
Torque.init(path+"Torque.properties");


 On Tue, 2005-03-15 at 09:48, Andras Balogh wrote:
> Hello,
>
>     Why don't You put the torque.properties file in WEB-INF/classes/ and
> load it like this:
> if(!Torque.isInit())
> {
>                 PropertiesConfiguration pc = new PropertiesConfiguration
();
>                 pc.load(
> this.getClass().getClassLoader().getResourceAsStream("torque.properties")
);
>
>                 Torque.init(pc);
>  }
>     This way You don't have to hardcode any path and it will work on any
> deployment.
> I use this  in a Servlet but I don't see why it wouldn't work in a jsp
too.
>
> Best regards,
> Andras.
>
>
> raphael.x.mankin@gsk.com wrote:
>
> >Torque.init() requires an absolute pathname. It's a bummer.
> >
> >I put the true pathname in another properties file so that I do not have
to
> >hard-code it in the program. This does mean, however, that I have to
know
> >the absolute path where, in my case, Tomcat is installed. Here is my
> >initialisation code
> >
> >        apiResources = ResourceBundle.getBundle("betapi");
> >        if (!Torque.isInit()) {
> >            String configFile = apiResources.getString
> >("betapi.torqueconfig");
> >            try {
> >                Torque.init(configFile);
> >            } catch (TorqueException e) {
> >                  context.log(e,"Cannot initalise Torque: " + e.toString
()
> >);
> >                e.printStackTrace(System.err);
> >                System.exit(1);
> >            }
> >        }
> >
> >and betapi.properties contains:
> >      betapi.torqueconfig=
> >/users/rxm1676/workspace/pmfeditor/WEB-INF/classes/Torque.properties
> >
> >
> >In cases where I build on one machine but run on another I have a little
> >shell script that that runs on installation. It tracks down the
appropriate
> >line in betapi.properties and adjusts it so suit where the code is
actually
> >installed.
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org









---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message