Justin S.,
Take a look at some of the Spring integration that other folks have
done. (Substitute "IoC framework" for "Spring" and you'll get the
idea.) You can find my Spring-based solution at <http://
article.gmane.org/gmane.comp.java.restlet/2943>. It overrides the
Finder's createResource method to create (request-scoped) Resources
using Spring.
Justin M.
--
troove Inc.
http://troove.net/
"The troove appliance -- enterprising find"
On Sep 7, 2007, at 9:03 AM, Stanczak Group wrote:
The best I could find is yes Resources get created each request,
and I should extend a Restlet and override the handle method.
Allowing Pico to create the Restlet with the database connection in
it. I don't see a way to do that with a Resource unless I can make
Restlet use a custom factory.
Stanczak Group wrote:
In the following code I supply the router with a class. Restlet
then creates this class, I'm guess when a call is made. My
question is does this class get created each time or is it cached?
If I use something like PicoContainer with caching I can have it
inject the CoursesResource.class, which would allow me to use
PicoContainer to inject for example database connection entity
manager into this resource. The way I understand it is Restlet
engine, in this case, instantiates this class for me, but looking
at the constructor it appears it's created each time a new. What
am I missing here?
@Override
public Restlet getRoot() {
Router router = new Router(this.getContext());
router.attach("/v1/users/{user}/courses",
CoursesResource.class);
return router;
}
--
Justin Stanczak
Stanczak Group
812-735-3600
"All that is necessary for the triumph of evil is that good men do
nothing."
Edmund Burke