tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Asensio, Rodrigo" <rodrigo.asen...@gilbarco.com>
Subject RE: How to run a thread on app startup
Date Mon, 03 Apr 2006 19:48:54 GMT
Here you have more info

public class Application {

  public static final int WEB_APPLICATION = 0;
  public static final int WEB_SERVICE = 1;
  public static final int WINDOWS_STANDALONE = 2;
  public static final int WINDOWS_PROCESS = 3;

  private static InheritableThreadLocal instance = new
InheritableThreadLocal();  << this is your instance singleton per thread


  public static void setInstance(Application app) {
	instance.set(app)
  }

  public static Application getInstance() {
	return (Application)instance.get();
  }

And you call always from your classes

Application.getIntance().getDefaultDB... getLogger... Getwhatever

------------------------------------------------------------------------
------------
Rodrigo Asensio
Fuel Management Services
Gilbarco Veeder Root
phone: +1 336 547 5023



 

-----Original Message-----
From: Bruce McGuire [mailto:bmcguire@mentoring-solutions.com] 
Sent: Monday, April 03, 2006 3:46 PM
To: Tomcat Users List
Subject: Re: How to run a thread on app startup

Hello  Rodrigo.

Thanks very much for the information.

Bruce.

Asensio, Rodrigo wrote:

>I figured out that the best way to do that is with a variable of type 
>InheritableThreadLocal that keeps a copy per thread.
>
>We have 4 webapps over the same framework and all works in the same
way.
>The servlet creates a new instance of MyApplication and sets this 
>"singleton by thread" in the MyApplication class
>Application.set(myApplication)
>After that, all threads created based in the servlet thread will have 
>the same copy of your App.
>
>Regards
>
>-----------------------------------------------------------------------
>-
>------------
>Rodrigo Asensio
>Fuel Management Services
>Gilbarco Veeder Root
>phone: +1 336 547 5023
>
>
>-----Original Message-----
>From: Bruce McGuire [mailto:bmcguire@mentoring-solutions.com]
>Sent: Monday, April 03, 2006 3:31 PM
>To: users@tomcat.apache.org
>Subject: How to run a thread on app startup
>
>  
>
>>Hello.
>>
>>I need to have an application that has a seperate thread that loads 
>>when tomcat loads. It scans my db every once in a while, to find out 
>>if any new info has to be processed.
>>
>>I have tried to find out from the docs how to do this, but I can't 
>>find it.
>>
>>Thanks for your help,
>>
>>Bruce.
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>This message (including any attachments) contains confidential and/or 
>proprietary information intended only for the addressee.
>Any unauthorized disclosure, copying, distribution or reliance on the 
>contents of this information is strictly prohibited and may constitute 
>a violation of law.  If you are not the intended recipient, please 
>notify the sender immediately by responding to this e-mail, and delete 
>the message from your system.  If you have any questions about this 
>e-mail please notify the sender immediately.
> 
>Ce message (ainsi que les eventuelles pieces jointes) est exclusivement

>adresse au destinataire et contient des informations confidentielles. 
>La copie, la communication ou la distribution du contenu de ce message 
>sans l'accord prealable de l'expediteur sont strictement interdits et 
>peuvent constituer un delit. Si vous n'etes pas destinataire de ce 
>message, merci de le detruire et d'avertir l'expediteur. Si vous avez 
>des questions se rapportant a ce courrier electronique, merci de bien 
>vouloir notifier l'expediteur immediatement.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>  
>


This message (including any attachments) contains confidential 
and/or proprietary information intended only for the addressee.  
Any unauthorized disclosure, copying, distribution or reliance on 
the contents of this information is strictly prohibited and may 
constitute a violation of law.  If you are not the intended 
recipient, please notify the sender immediately by responding to 
this e-mail, and delete the message from your system.  If you 
have any questions about this e-mail please notify the sender 
immediately.  
 
Ce message (ainsi que les eventuelles pieces jointes) est 
exclusivement adresse au destinataire et contient des 
informations confidentielles. La copie, la communication ou la 
distribution du contenu de ce message sans l'accord prealable de 
l'expediteur sont strictement interdits et peuvent constituer un 
delit. Si vous n'etes pas destinataire de ce message, merci de le 
detruire et d'avertir l'expediteur. Si vous avez des questions se 
rapportant a ce courrier electronique, merci de bien vouloir 
notifier 
l'expediteur immediatement.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message