[
http://www.stripesframework.org/jira/browse/STS-520?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11301#action_11301
]
Christian Nelson commented on STS-520:
--------------------------------------
The interceptor I wrote will lookup beans from the spring application context
and find them regardless of how they were defined. For example, in my sample
application where, I create spring beans via xml (ye ole fashioned way) as well
as through spring's component-scan feature:
"Spring 2.5 introduces support component scanning: autodetecting annotated
components in the classpath. Typically, such component classes will be
annotated with stereotypes such as @Component, @Repository, @Service,
@Controller. Depending on the application context configuration, such component
classes will be autodetected and turned into Spring bean definitions, not
requiring explicit configuration for each such bean. Annotation-driven bean
configuration is discussed in Section 3.12.1, "@Component and further
stereotype annotations"."
Once the beans are in the context it doesn't matter much how they got there.
It could be through spring's JavaConfig, component-scan, xml, or any
combination of those or any new mechanism that comes along.
@Autowired (etc) can be applied to fields or methods. It normally can be
applied to constructors, but that won't work in this case since Stripes is
doing the instantiation, not Spring.
Potential Caveats:
1) What I wrote will only work with Spring 2.5 and later. I don't see this as
too big a deal because if a developer or organization is using Stripes, then
they probably have a high-degree of technical freedom. Also, Spring 2.5.2 is
out and has had time for stabilization and adoption. 2.5 is completely
backwards with 2.0 so there's no (good) reason for developers not to upgrade.
2) While I think the injection process is already optimized, I think it's worth
doing a little profiling to make sure action beans can be created and injected
very quickly.
I'm heading off to Montana tomorrow and will be off the grid most of the next
week. I'd be happy to document the code I wrote, adds some tests and error
checking and send the updated version when I return.
> Support Spring's @Autowired annotation for marking fields/methods for
> dependency injection
> ------------------------------------------------------------------------------------------
>
> Key: STS-520
> URL: http://www.stripesframework.org/jira/browse/STS-520
> Project: Stripes
> Issue Type: Improvement
> Affects Versions: Release 1.4.3
> Reporter: Christian Nelson
> Priority: Trivial
> Attachments: GuiceInterceptor.java, SpringInterceptor.java
>
>
> It'd be nice if we could use the @Autowired annotation that was recently
> added in Spring 2.5 in place of the @SpringBean annotation. Dependency
> injection would then would be consistent with a spring-managed service tier.
> Obviously this isn't a big deal and I've marked it as trivial.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://www.stripesframework.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development