Re: Struts2 startup service/action

2008-10-10 Thread dchicks

Ron, this is a great tip!  Thanks!  I do have one question, though.  Any idea
how one might go about getting the Spring web context using this method?

Normally, I would have extended ContextLoaderServlet.  Our experience, so
far, has been that it's nearly impossible to get another servlet to play
nice with Struts, though.  I prefer the method that you've outlined, because
it blends well with the Struts environment.  I'm just not sure how I can get
the context for loading beans.

Thoughts?

Thanks,
Dave

-- 
View this message in context: 
http://www.nabble.com/Struts2-startup-service-action-tp19738655p19923169.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Struts2 startup service/action

2008-10-10 Thread Brad A Cupit
From: dchicks [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 10, 2008 1:03 PM
 Our experience, so far, has been that it's nearly
 impossible to get another servlet to play nice with
 Struts, though.

You could try Spring's
org.springframework.web.context.ContextLoaderListener
instead of the ContextLoaderServlet. 

Brad Cupit
LSU - University Information Systems

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Struts2 startup service/action

2008-10-10 Thread David C. Hicks
I've been working with ContextLoaderListener for a while this afternoon, 
but I think I have a problem with dependencies. The latest API docs on 
Spring indicate that you can get the current web application context 
from a static method on ContextLoader, but I'm stuck with version 2.0.3 
due to dependencies - I think because spring-jpa hasn't caught up. At 
least, that's my guess from looking at the Maven repository.


The end result is that I haven't found a way to get hold of the web 
application context, yet. Surely, I'm not the only one who needs to do 
this to initialize some things before the app gets going. I figured 
someone here would know the secret sauce.


Thanks,
Dave


Brad A Cupit wrote:
From: dchicks [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 10, 2008 1:03 PM
  

Our experience, so far, has been that it's nearly
impossible to get another servlet to play nice with
Struts, though.



You could try Spring's
org.springframework.web.context.ContextLoaderListener
instead of the ContextLoaderServlet. 


Brad Cupit
LSU - University Information Systems

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

  


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Struts2 startup service/action

2008-10-10 Thread Ron Chan

I've not used Spring for a while so I can't answer your question directly.

But all I'm trying to do is get access to something that would have been
correctly initialized had I been under struts.  i.e.  my QuartzService
example was already working under struts, I just wanted to make the
scheduler automatically start on startup of the application, rather than
having to hit an action.  So if you are after something similar do you need
to have access to the spring context?  I'm not trying to get hold of the
Guice injector.

Hope this helps
Ron


-- 
View this message in context: 
http://www.nabble.com/Struts2-startup-service-action-tp19738655p19924529.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Struts2 startup service/action

2008-10-10 Thread David C. Hicks

I see. Thanks for the feedback.

Ron Chan wrote:

I've not used Spring for a while so I can't answer your question directly.

But all I'm trying to do is get access to something that would have been
correctly initialized had I been under struts.  i.e.  my QuartzService
example was already working under struts, I just wanted to make the
scheduler automatically start on startup of the application, rather than
having to hit an action.  So if you are after something similar do you need
to have access to the spring context?  I'm not trying to get hold of the
Guice injector.

Hope this helps
Ron


  


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Struts2 startup service/action

2008-10-10 Thread Brad A Cupit
David C. Hicks [mailto:[EMAIL PROTECTED] wrote
 I'm stuck with version 2.0.3 due to dependencies - I
 think because spring-jpa hasn't caught up

Looks like spring-jpa has moved to spring-orm in 2.5
org.springframework
spring-orm

The ContextLoaderListener should work in Spring 2.0.x though.
Have you tried
WebApplicationContextUtils.getWebApplicationContext(sevletContext) ?

Brad Cupit
LSU - University Information Systems

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Struts2 startup service/action

2008-09-30 Thread Chris Pratt
I think the more common way is to use a standard ServletContextListener.
  (*Chris*)

On Tue, Sep 30, 2008 at 2:16 AM, Ron Chan [EMAIL PROTECTED] wrote:


 There's been a number of messages about this, and I've tried a number of
 different suggestions.  After going round in circles for a few days, I
 eventually ended up with just a few lines of code that seems to work.  I
 basically extended the FilterDispatcher, added to the init() method and
 used
 the new FilterDispatcher in my web.xml instead.  This seems to work but I
 was wondering if it would cause potential problems.  I use Guice and it
 seems to work, have not  tested it with anything else.

 public class ExtendedFilterDispatcher extends FilterDispatcher {
@Override
public void init(FilterConfig filterConfig) throws ServletException
 {
super.init(filterConfig);

try {
Container cont = super.dispatcher.getContainer();

  ObjectFactory.setObjectFactory(cont.getInstance(ObjectFactory.class));
QuartzService service = (QuartzService)

  ObjectFactory.getObjectFactory().buildBean(QuartzService.class, null);
service.start();
} catch (Exception e) {
e.printStackTrace();
}
}
 }

 QuartzService is an example, it can be any action or service controlled by
 the struts objectfactory

 --
 View this message in context:
 http://www.nabble.com/Struts2-startup-service-action-tp19738655p19738655.html
 Sent from the Struts - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: Struts2 startup service/action

2008-09-30 Thread Ron Chan

but this does not give me access to the Guice injector, which is what I
wanted.  I think the ServletContextListener would work only if using Spring.



Chris Pratt wrote:
 
 I think the more common way is to use a standard ServletContextListener.
   (*Chris*)
 
 On Tue, Sep 30, 2008 at 2:16 AM, Ron Chan [EMAIL PROTECTED] wrote:
 

 There's been a number of messages about this, and I've tried a number of
 different suggestions.  After going round in circles for a few days, I
 eventually ended up with just a few lines of code that seems to work.  I
 basically extended the FilterDispatcher, added to the init() method and
 used
 the new FilterDispatcher in my web.xml instead.  This seems to work but I
 was wondering if it would cause potential problems.  I use Guice and it
 seems to work, have not  tested it with anything else.

 public class ExtendedFilterDispatcher extends FilterDispatcher {
@Override
public void init(FilterConfig filterConfig) throws
 ServletException
 {
super.init(filterConfig);

try {
Container cont = super.dispatcher.getContainer();

  ObjectFactory.setObjectFactory(cont.getInstance(ObjectFactory.class));
QuartzService service = (QuartzService)

  ObjectFactory.getObjectFactory().buildBean(QuartzService.class, null);
service.start();
} catch (Exception e) {
e.printStackTrace();
}
}
 }

 QuartzService is an example, it can be any action or service controlled
 by
 the struts objectfactory

 --
 View this message in context:
 http://www.nabble.com/Struts2-startup-service-action-tp19738655p19738655.html
 Sent from the Struts - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


 
 

-- 
View this message in context: 
http://www.nabble.com/Struts2-startup-service-action-tp19738655p19745637.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]