I'm posting my take on the Spring config detailed on the wiki.
Previously I had been using a subclass of Application, with
multiple invocations of router.attach() (per the FirstResource app)
to get routing done to specific restlets.
Hope this helps someone out there get over the hump. In your
main() method, get the bean "server" and do a server.start() on it
as one would normally do with a Component:
<bean id="server" class="org.restlet.ext.spring.SpringComponent">
<property name="server">
<bean class="org.restlet.ext.spring.SpringServer">
<constructor-arg value="HTTP" />
<constructor-arg value="8182" />
</bean>
</property>
<property name="defaultTarget" ref="router" />
</bean>
<bean id="router" class="org.restlet.ext.spring.SpringRouter">
<property name="attachments">
<map>
<entry key="/account/register">
<bean class="org.restlet.ext.spring.SpringFinder">
<lookup-method name="createResource"
bean="registerResource" />
</bean>
</entry>
<entry key="/account/login">
<bean class="org.restlet.ext.spring.SpringFinder">
<lookup-method name="createResource"
bean="loginResource" />
</bean>
</entry>
<entry key="/account/confirm/{confirmationKey}">
<bean class="org.restlet.ext.spring.SpringFinder">
<lookup-method name="createResource"
bean="confirmationResource" />
</bean>
</entry>
<entry key="/callsign/bind">
<bean class="org.restlet.ext.spring.SpringFinder">
<lookup-method name="createResource"
bean="bindCallsignResource" />
</bean>
</entry>
<entry key="/license/lookup/{callsign}">
<bean class="org.restlet.ext.spring.SpringFinder">
<lookup-method name="createResource"
bean="lookupLicenseResource" />
</bean>
</entry>
<entry key="/log/{logname}">
<bean class="org.restlet.ext.spring.SpringFinder">
<lookup-method name="createResource"
bean="createLogResource" />
</bean>
</entry>
<entry key="/log/export/{logname}">
<bean class="org.restlet.ext.spring.SpringFinder">
<lookup-method name="createResource"
bean="exportLogResource" />
</bean>
</entry>
<entry key="/qso/{logname}">
<bean class="org.restlet.ext.spring.SpringFinder">
<lookup-method name="createResource"
bean="qsoResource" />
</bean>
</entry>
<entry key="/qso/{logname}/{range}">
<bean class="org.restlet.ext.spring.SpringFinder">
<lookup-method name="createResource"
bean="qsoResource" />
</bean>
</entry>
</map>
</property>
</bean>
<bean id="registerResource"
class="com.mspetrovic.server.restlet.RegisterResource"
scope="prototype"/>
<bean id="loginResource"
class="com.mspetrovic.server.restlet.LoginResource"
scope="prototype"/>
<bean id="confirmationResource"
class="com.mspetrovic.server.restlet.AccountConfirmationResource"
scope="prototype"/>
<bean id="bindCallsignResource"
class="com.mspetrovic.server.restlet.BindCallsignResource"
scope="prototype"/>
<bean id="lookupLicenseResource"
class="com.mspetrovic.server.restlet.LookupCallsignResource"
scope="prototype"/>
<bean id="createLogResource"
class="com.mspetrovic.server.restlet.LogResource" scope="prototype"/>
<bean id="exportLogResource"
class="com.mspetrovic.server.restlet.LogExportResource"
scope="prototype"/>
<bean id="qsoResource"
class="com.mspetrovic.server.restlet.QSOResource" scope="prototype"/>
On Oct 16, 2008, at 8:16 AM, Mark Petrovic wrote:
I took a look at the javadoc for both org.restlet.ext.spring and
com.noelios.restlet.ext.spring and conclude that the method
outlined here, based on org.restlet.ext.spring,
http://wiki.restlet.org/docs_1.1/13-restlet/g2/59-restlet.html
is the most viable approach.
Having read through that example, I'm still left with the
impression that the example contains a mix of specific and general
treatments of the subject. For example, I don't understand why
this point is raised
"In this example, the last URI pattern has to be customized to
accept complete URIs (possibly including slashes) as the last
component of the pattern. We use Spring's nested properties to
drill into the configuration of the URI pattern along with
Spring's mechanism for accessing a static field in a class."
And by "don't understand" I do not mean "I object to the point
raised", but rather "what, in my lack of understanding, is this
really trying to tell me, and does it matter in my case?". The
Spring lookup-method reference strikes me the same way: is this
central to restlet configuration with Spring, or is it an advanced
idiom that I can do without for now?
I'm not asking for a clarification of this particular point, but
instead for someone to offer a second standalone example of how to
configure a simple restlet-based app using Spring. Many, many
times in my study of a thing I resort to second and third and
fourth references on the subject to gain an understanding of what
is fundamental to a subject's elucidation, vs. what is specific in
the course of that illustration. This is one of those times, and
I'm sure others routinely resort to this same approach.
Would someone be kind enough to post some non-proprietary code
showing how they configured their restlet app using Spring? The
example would configure an app no more complex than the
FirstResouce app found elsewhere on the site.
Thanks much. Hopefully posterity will benefit from my
supplications as much as I do now.
Mark
On Oct 15, 2008, at 1:57 PM, Mark Petrovic wrote:
Good day.
I notice that both the FAQ and Wiki have sections treating the
use of the org.restlet.ext.spring package to manage a restlet app
in a Spring container.
Is there a similar example someone might offer on using the
com.noelios.restlet.ext.spring package to manage a restlet app in
the same way? The FAQ says such a configuration option exists,
and I'd like to read about it.
Thanks.
Mark