You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Thijs Suijten <t....@semantica.nl> on 2004/03/23 09:09:35 UTC

Where to put initialization code

I want to know where I can do some initialization for the web-application.
Before I used Tapestry I used the following code to do some initialization
(like starting the connection broker and loggers). This initialization code
cannot be put in the Visit Object.

Is there another way of doing the initialization or do I have to use the
same code in Tapestry?

<code>
web.xml:
<listener>
	<listener-class>semantica.docsdb.dat.Dat</listener-class>
</listener>

*****************************************************************

public final class Dat implements ServletContextListener {

	public void contextInitialized(ServletContextEvent event) {
		/* Initialization code here */
	}
}
</code>

Thijs
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.634 / Virus Database: 406 - Release Date: 18-3-2004


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


Re: Where to put initialization code

Posted by Marius Siegas <ma...@elinara.ktu.lt>.
I think the right way is the Global object constructor

M. Stellinga wrote:
> You could create your own subclass of the Application Servlet 
> (org.apache.tapestry.ApplicationServlet) and override the init method.
> In your web.xml you would have to change the servlet mapping for 
> tapestry to something like this:
>   <servlet>
>        <servlet-name>Servlet name</servlet-name>
>        <servlet-class>org.mypackage.MyApplicationServlet</servlet-class>
>        <load-on-startup>0</load-on-startup>
>    </servlet>
>    <servlet-mapping>
>          <servlet-name>Servlet name</servlet-name>
>          <url-pattern>/app</url-pattern>
>    </servlet-mapping>
> 
> 
> Martijn
> 
> Thijs Suijten wrote:
> 
>> I want to know where I can do some initialization for the 
>> web-application.
>> Before I used Tapestry I used the following code to do some 
>> initialization
>> (like starting the connection broker and loggers). This initialization 
>> code
>> cannot be put in the Visit Object.
>>
>> Is there another way of doing the initialization or do I have to use the
>> same code in Tapestry?
>>
>> <code>
>> web.xml:
>> <listener>
>>     <listener-class>semantica.docsdb.dat.Dat</listener-class>
>> </listener>
>>
>> *****************************************************************
>>
>> public final class Dat implements ServletContextListener {
>>
>>     public void contextInitialized(ServletContextEvent event) {
>>         /* Initialization code here */
>>     }
>> }
>> </code>
>>
>> Thijs
>> ---
>> Outgoing mail is certified Virus Free.
>> Checked by AVG anti-virus system (http://www.grisoft.com).
>> Version: 6.0.634 / Virus Database: 406 - Release Date: 18-3-2004
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>
>>  
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 


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


Re: Where to put initialization code

Posted by "M. Stellinga" <ta...@softwaredesign.nl>.
You could create your own subclass of the Application Servlet 
(org.apache.tapestry.ApplicationServlet) and override the init method.
In your web.xml you would have to change the servlet mapping for 
tapestry to something like this:
   <servlet>
        <servlet-name>Servlet name</servlet-name>
        <servlet-class>org.mypackage.MyApplicationServlet</servlet-class>
        <load-on-startup>0</load-on-startup>
    </servlet>
    <servlet-mapping>
          <servlet-name>Servlet name</servlet-name>
          <url-pattern>/app</url-pattern>
    </servlet-mapping>


Martijn

Thijs Suijten wrote:

>I want to know where I can do some initialization for the web-application.
>Before I used Tapestry I used the following code to do some initialization
>(like starting the connection broker and loggers). This initialization code
>cannot be put in the Visit Object.
>
>Is there another way of doing the initialization or do I have to use the
>same code in Tapestry?
>
><code>
>web.xml:
><listener>
>	<listener-class>semantica.docsdb.dat.Dat</listener-class>
></listener>
>
>*****************************************************************
>
>public final class Dat implements ServletContextListener {
>
>	public void contextInitialized(ServletContextEvent event) {
>		/* Initialization code here */
>	}
>}
></code>
>
>Thijs
>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.634 / Virus Database: 406 - Release Date: 18-3-2004
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
>  
>


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