This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Hands On Software Engineering with Python and have Brian Allbey on-line!
See this thread for details.
Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Application Level Initialization  RSS feed

 
Ranch Hand
Posts: 209
Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ranchers,
I am facing an issue in my design of my application and struggling to get a robust solution for it.
To lay it down in simple terms i have an EAR which has currently 1 war and 1 ejb jar. I am expecting my EAR to scale up in near time,
where i will be having few more wars and business components added. Currently i am using a ServletContextListener to do all the application level initialization.
But then later noticed that it is not a correct solution as i don't want to depend on sequence of servlet's startups (from different wars).
There should be some standardized solution which allows me to do initialization at application level. In simple terms i want to execute some piece of code(at EAR level)
before any other code gets executed.


Regards,
Shroff.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sagar Shroff wrote:
But then later noticed that it is not a correct solution as i don't want to depend on sequence of servlet's startups (from different wars).



You can use initialize-in-order within the application.xml and then list the war modules in the right order and have the initialization done in the first listed war.
 
Sagar Shroff
Ranch Hand
Posts: 209
Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jaikiran Pai wrote:
You can use initialize-in-order within the application.xml and then list the war modules in the right order and have the initialization done in the first listed war.


Yeah thats what i am backing on currently, just wanted to know if this is the only standard way ?


Regards,
Shroff.
 
Sheriff
Posts: 21555
100
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about a bean annotated with @Singleton and @Startup? You still don't have full control over the startup order if you use other mechanisms (like ServletContextListener), but at least you can use @DependsOn to specify that these beans should be loaded after another. For instance:
You can now know for sure that these three beans are loaded at startup in order MyBean1, MyBean2, MyBean3.
 
Sagar Shroff
Ranch Hand
Posts: 209
Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Spoor wrote:How about a bean annotated with @Singleton and @Startup? You still don't have full control over the startup order if you use other mechanisms (like ServletContextListener), but at least you can use @DependsOn to specify that these beans should be loaded after another.



Thanks. Actually i was trying to figure out whether there is any way i can achieve to put all my initialization code in ear project. But then reading through articles i realized that ear core objective is packaging of application.


Regards,
Shroff.
 
No prison can hold Chairface Chippendale. And on a totally different topic ... my stuff:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!