I use spring aop and cglib and it works well for me. I do appreciate
problems with cglib and proxys however.
I also use my own version of SpringRouter to map uri and resources and
to "filter" them with globally before and after filter lists. I also
have filters set on my individual resources. I find it works well and
that spring extensions do satisfy my needs (even though they need some
tweaking).
Best regaards,
Jonathan Hall
Valdis Rigdon wrote:
Adam Taft wrote:
Ultimately, no matter how we get there, Resource needs to be a
stateless in order to work well with Ioc.
Having used Spring and Restlet together on my current project I
disagree. I can't speak for other IoC frameworks, but Spring
provides multiple way to inject other beans into "stateful" (or
prototype) beans. I like the fact that Resources are not singletons
and I don't have to pass along Request, Resource, etc. to every method
that may or may not need them. For those that have used Struts, I
can't count how many times I've seen non-thread safe code in Struts
Actions. It's just a bug waiting to happen.
To retrieve new instances of classes with injected resources define
your bean with 'scope="prototype"' in your Spring configuration and
then use one of the following:
1. Use @Configurable and AspectJ (see Chapter 6 of the Spring
documentation)
2. Use Spring AOP and cglib extensions via lookup-method (see
SpringFinder)
3. Call ApplicationContext.getBean("beanId")
I'm currently using option 1 with compile-time weaving under Maven2
and it's works great.
In addition, Jerome's suggestion of a SpringRouter makes perfect
sense. I've implemented something similar but it's an extension to
Application. It's a simple bean with (1) a Map for URI to Resource
classes, (2) a Map for URI to Restlet instances and (3) a Map for URI
to "guarded" Resources. One can also set the default Resource as well
as provide the Guard to use for the "guarded" resources. We've also
added an ApplicationContextAwareFinder which allows Resource classes
to implement ApplicationContextAware and have a handle to the
ApplicationContext if needed. I could clean it up a bit and share it
if anyone is interested.
Valdis