users@glassfish.java.net

RE: Is there a way to automatically instantiate a bean at startup?

From: Wim Verreycken <wim_at_pizzastop.be>
Date: Tue, 10 Mar 2009 21:23:37 +0100

Or, you could put your bean(s) in a spring xml file and load a spring
ClassPathXmlApplicationContext :)

http://www.onjava.com/pub/a/onjava/2006/01/25/spring-xml-configuration-best-
practices.html?page=1

Wim
-----Original Message-----
From: Dan6077 [mailto:dmcguire_at_jerviswebb.com]
Sent: dinsdag 10 maart 2009 19:48
To: users_at_glassfish.dev.java.net
Subject: Re: Is there a way to automatically instantiate a bean at startup?


There IS a way to instantiate a bean at start up. This is how I connect to
my database and load up my properties file. I use the NETBEANS IDE to do
this, but all it does is to place an attribute into the XML file for the
bean. If you google RUNATSTARTUP attribute you should be able to see more
as to how this is done.

I am away from the code that does this but if you need more help I can send
you a copy of that.




glassfish-2 wrote:
>
> I've spent a number of hours searching this forum and google for an answer
> to this question (in the title), but so far while I've seen a lot of
> references to it I've not found a good answer.
>
> It also seems that this is a popular question.
>
> All I want to do is to create a bean that will periodically ping mysql to
> see if there are any new records in a mail table, and if those records
> exist to send some emails. I'm using Glassfish for the rest of my app and
> so it makes sense to me that I would want to use it for this function too.
> I don't want a web interface or anything like that.
>
> I've looked at the ServletContextListener but from what I can see it
> requires a bean to be instantiated. So far I've not been able to figure
> out how to automatically instantiate a bean when Glassfish starts up.
>
> Am I missing something obvious here?
>
> Thanks,
>
> Eric
> [Message sent by forum member 'eric_marsh' (eric_marsh)]
>
> http://forums.java.net/jive/thread.jspa?messageID=335746
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>

-- 
View this message in context:
http://www.nabble.com/Is-there-a-way-to-automatically-instantiate-a-bean-at-
startup--tp22401108p22440834.html
Sent from the java.net - glassfish users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
For additional commands, e-mail: users-help_at_glassfish.dev.java.net