I have not submitted a patch yet as the ObjectFactory stuff is still brand new 
and may undergo further changes at this point.   I haven't had a chance to test 
any of the the constructor args variants yet either.  This probably means I 
need to enhance the api for looking up beans, stripes' SpringHelper class might 
be what I need to look at.   And I'm actually using a singleton class for bean 
lookup this which I know is bad, but it can't be a spring bean so...

Basically I have the standard spring ServletContextListener, and on 
contextInitialized() I pass the servlet context to this singleton 
SpringBeanLocator thing that does the famous this.springContext = 
WebApplicationContextUtils.getRequiredWebApplicationContext(ctx);  and has 
methods like <T> T getBean(Class<T> beanClass)


public class SpringObjectFactory extends DefaultObjectFactory {

      private SpringBeanLocator springBeanLocator;


      @Override
      public void init(Configuration configuration) throws Exception {
            super.init(configuration);
            this.springBeanLocator = SpringBeanLocator.getInstance();
      }


      @Override
      public <T> T newInstance(Class<T> clazz) {
            T springBean = springBeanLocator.getBean(clazz);
            return springBean != null ? springBean : super.newInstance(clazz);
      }
      // other variants still need tested
}



From: Brandon Goodin [mailto:[email protected]]
Sent: Wednesday, June 24, 2009 10:36 AM
To: Stripes Users List
Subject: Re: [Stripes-users] Spring managed action beans - any change?

That sound fantastic. Have you submitted a patch? You'll run up against the Tim 
(Mr "Why would want to do that!!!?" ;-) <-- notice the wink don't hate me). 
There are several things that I like about the Stripes-Guice integration that i 
wrote. I didn't have to invent any annotations. I don't like that with my 
current implementation. It's super nice to simply allow the injection framework 
do all the work. With the Stripes-Spring I just had to override all the yucky 
object creation innards. I was looking to do the same with Spring. I'd love to 
see your 1.6 code as I have yet to add the 1.6 version to the Stripes-Guice or 
Stripes-Spring stuff. With Stripes-Spring I should be able to create consistent 
functionality across the 1.5 and 1.6 Stripes dependent versions. In the 
Stripes-Guice integration I have interceptor injection as well and the 
potential really to inject into any component.

Brandon Goodin
Silver Mind Software
http://www.silvermindsoftware.com
[email protected]<mailto:[email protected]>
615-306-3652
http://www.linkedin.com/in/bgoodin

On Wed, Jun 24, 2009 at 9:04 AM, Newman, John W 
<[email protected]<mailto:[email protected]>> wrote:
The stripes-spring project is only for action beans.  This works for any 
stripes components (interceptors, converters, formatters, action bean context, 
factories, etc.) as well as fields in your action bean that are instantiated 
during binding.  I usually don't make entities spring beans, but I've seen some 
people do that..

And it's real simple... just extend object factory and put the package name in 
your Extension.Packages.

IMO this is the cleanest way, ObjectFactory is the correct hook instead of 
sub-classing every factory.  This is probably one reason why it was created for 
1.6.  I'd like to see all the existing spring stuff deprecated, and a new 
SpringObjectFactory, EJB3ObjectFactory, etc make it into the trunk.

I haven't really had time to test it too thoroughly, I'm not sure why there are 
6 or so variants of newInstance in there. I did override the few that were 
actually referenced by another class within stripes to check my spring context 
first, and as far as I can tell it works great, very clean.

-----Original Message-----
From: Dmitri Colebatch [mailto:[email protected]<mailto:[email protected]>]
Sent: Wednesday, June 24, 2009 8:50 AM
To: 
[email protected]<mailto:[email protected]>
Subject: Re: [Stripes-users] Spring managed action beans - any change?

> Using the current trunk (not released yet .. I can?t wait), I?ve extended 
> DefaultObjectFactory, and overrode the newInstance methods to look in my 
> spring context for a matching bean first.  This simple trick has given me 
> full transparent spring integration of all stripes components - action beans, 
> converters, interceptors, etc all configured in my spring context.  =)  I?ve 
> been waiting for this for a long time, can?t wait for this to make it into 
> production.  Now if I could just get jboss to do the same thing for servlet 
> listeners etc I?d be in great shape. =)
>
> If you can?t use the trunk or wait for 1.6, there?s not much hope.

What's the difference between this and the stripes spring work?  Is it
the same functionality, but built in?  Or does it do something else?

I'm perfectly happy to use trunk - this is just a little side-project.

Cheers,
Dim

------------------------------------------------------------------------------
_______________________________________________
Stripes-users mailing list
[email protected]<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/stripes-users
------------------------------------------------------------------------------
_______________________________________________
Stripes-users mailing list
[email protected]<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/stripes-users

------------------------------------------------------------------------------
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to