I believe I'm taking a different approach. I have all of Restlet in my
PicoContainer. In other works I've created a server class that listens
to lifecycle on Pico and creates the component and starts Restlet when
start is called on PicoContainer. Like so:
pico = new PicoBuilder().withCaching().build();
pico.addComponent(factory);
pico.addComponent(Component.class);
pico.addComponent(SavvyApplication.class);
pico.start();
Then I was going to let Pico create all Restlets needed by the
application. I had planed on using an array in the constructor. This
array would be an extended Restlet class with a get path() method that
would tell the router which path that Restlet uses. So as you can see I
need to know if my container can pass in a pre configured Restlet,
knowing it will not be instantiated by the Restlet engine. This is why I
was thinking I wouldn't be able to use Resources, but instead I would
need to use a Restlet. Really in a stateless system, why would you
create a new Resource on each request? I may be going about it all wrong?
Justin Makeig wrote:
Justin S.,
Finder looks to me like a per-request Resource factory. How it
generates the Resources is of no concern to the rest of the framework.
My example just delegates the creation of the Resource to Spring. (I
guess that is "outside the Restlet API".) There is some overhead of
asking Spring for a bean by its type and wiring (though not
initializing) the collaborators. However, I think these are
out-weighed by the overall simplicity of the integration between
RESTlet and Spring and fully leveraging Spring's IoC capabilities. At
least from my understanding of Spring, to get a bean Resource wired
with its collaborators you have to define that bean and its
dependencies up front (i.e. in a Spring ApplicationContext). If you
just wire your Restlet, you'd have to manage all of the Resource's
collaborators each time you instantiate it.
I'd be interested in hearing others' take.
Justin M.
--
troove Inc.
http://troove.net/
On Sep 7, 2007, at 11:36 AM, Stanczak Group wrote:
Ok. I've looked it over and the question I have is doesn't this
approach put you outside the Restlet API? And, would it be better to
just create Restlets instead of Resources? The way I understand the
document is that Resources get loaded every time, but Restlets are
loaded once? Is this correct?
Justin Makeig wrote:
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.
--
Justin Stanczak
Stanczak Group
812-735-3600
"All that is necessary for the triumph of evil is that good men do
nothing."
Edmund Burke
--
Justin Stanczak
Stanczak Group
812-735-3600
"All that is necessary for the triumph of evil is that good men do nothing."
Edmund Burke