hi, 

The Servlet is quite right. For me, it works like that: 

web.xml: 

Register a spring- listener: 

<listener>
        <listener-class>
             org.springframework.web.context.ContextLoaderListener
        </listener-class>
</listener>

Don't forget about the config file: 

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
              classpath:spring-beans.xml
        </param-value>
</context-param>

Register the FrameworkServlet and map it to your path: 

<servlet>
    <servlet-name>restlet</servlet-name>
    
<servlet-class>org.restlet.ext.spring.RestletFrameworkServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
 </servlet>
    
    <servlet-mapping>
    <servlet-name>restlet</servlet-name>
    <url-pattern>/restlet/*</url-pattern>
 </servlet-mapping>


Than, you need an spring- config file which is named  
{servletname}-servlet.xml, so, in that case. restlet-servlet.xml. It looks like 
that: 

<?xml version="1.0" encoding="UTF-8"?>
<beans 
    xmlns="http://www.springframework.org/schema/beans";
    xmlns:cxf="http://cxf.apache.org/core";
    xmlns:jaxws="http://cxf.apache.org/jaxws";
    xmlns:test="http://apache.org/hello_world_soap_http";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="
        http://cxf.apache.org/core
        http://cxf.apache.org/schemas/core.xsd
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
        http://cxf.apache.org/jaxws                                     
        http://cxf.apache.org/schemas/jaxws.xsd";>
 
<!-- that beans name is important, it must be root -->
 <bean id="root" class="org.restlet.ext.spring.SpringRouter">
        <property name="attachments">
                <map>
                        <entry key="/restlet1">
                                <bean 
class="org.restlet.ext.spring.SpringFinder">
                                        <lookup-method name="create"
                                                bean="restlet1" />
                                </bean>
                        </entry>
                        <entry key="/test">
                                <bean 
class="org.restlet.ext.spring.SpringFinder">
                                        <lookup-method name="create"
                                                bean="restlet2" />
                                </bean>
                        </entry>
                </map>
        </property>
</bean>
 
 <bean name="restlet1" class="ServerResourceClassName">
 </bean>
 
 <bean name="restlet2" class="ServerResourceClassName">
 </bean>

I hope that'll do, 

Alex

-------- Original-Nachricht --------
> Datum: Tue, 20 Jul 2010 10:05:17 -0600
> Von: Larry Meadors <[email protected]>
> An: [email protected]
> Betreff: Re: How to inject a Spring bean service into a Restlet component

> Not Spring...but I used a Finder to inject mine with Guice - it only
> required extending Finder and overriding one method:
> 
>       public GuiceFinder(Context context, Class<?> targetClass) {
>               super(context, targetClass);
>       }
> 
>       @Override
>       public ServerResource create(Class<? extends ServerResource>
> targetClass, Request request, Response response) {
>               return InjectorFactory.getInjector().getInstance(targetClass);
>       }
> 
> Larry
> 
> 
> On Tue, Jul 20, 2010 at 9:58 AM, Richard Brewster
> <[email protected]> wrote:
> > I really need help getting this to work.  The examples I've found refer
> to a
> > restlet Resource, which is deprecated.  For example:
> >
> >
> http://wiki.restlet.org/docs_2.0/13-restlet/28-restlet/70-restlet/196-restlet.html
> >
> > I think I need to use RestletFrameworkServlet.  But I have not found a
> good
> > example.
> >
> > --
> > View this message in context:
> http://restlet-discuss.1400322.n2.nabble.com/How-to-inject-a-Spring-bean-service-into-a-Restlet-component-tp5314211p5317233.html
> > Sent from the Restlet Discuss mailing list archive at Nabble.com.
> >
> > ------------------------------------------------------
> >
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2635832
> >
> 
> ------------------------------------------------------
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2635842

-- 
GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl.  
Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2636241

Reply via email to