Jerome,

I did use the latest source. It turns out that problem was not a restlet problem but a one related to deploying to application on tomcat...

thxs for your help.

cheers
</jima>

Jerome Louvel wrote:
Hi Jim,

I have just tested your code and it worked for me. Did you get the latest
current.zip? I have updated it after my initial reply to you to fix a couple
of issues.

In any case, I have attached my test files.

Best regards,
Jerome
-----Message d'origine-----
De : Jim Alateras [mailto:[EMAIL PROTECTED] Envoyé : mercredi 28 mars 2007 05:52
À : discuss@restlet.tigris.org
Objet : Re: spring and restlet

Jerome,

I have the integration with spring working through the extension of FrameworkServlet but I am having some issues with the Router.

I am trying to attach resources to the Router as follows

                        
// create the converter
this.converter = new ServletConverter(getServletContext());

// create the router and attach a default router
Router router = new Router();
router.attach("/myresource", MyResource.class);
this.converter.setTarget(router);


but the framework does not seem to be routing the URI, /restlet/myresource to the correct resource.

Any guidance would be appreciated.
cheers
</jima>



Jerome Louvel wrote:
Hi Jim,

As the integration mode 3) has been requested several times
already, I have
just added a new ServletConverter class to the Servlet
extension that
handles everything transparently. Here is a usage example:

public class TestServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    private ServletConverter converter;

    @Override
    public void init() throws ServletException {
        super.init();
        this.converter = new ServletConverter(getServletContext());
Restlet trace = new Restlet(this.converter.getContext()){ public void handle(Request req, Response res){
                getLogger().info("Hello World");
                res.setEntity("Hello World!", MediaType.TEXT_PLAIN);
            }
        };

        Router root = new Router();
        root.attach(trace);
this.converter.setTarget(root);
    }

    @Override
protected void service(HttpServletRequest req,
HttpServletResponse res)
            throws ServletException, IOException {
        this.converter.service(req, res);
    }
}

As you can see, your Servlet can extend any super class you
want, you just
need to create one ServletConverter (and ideally to reuse it for all
requests).

I will add a FAQ entry tomorrow about this. For now, you
can either get the
latest from SVN or get this current.zip:
http://www.restlet.org/downloads/1.0/current.zip

Best regards,
Jerome
-----Message d'origine-----
De : Jim Alateras [mailto:[EMAIL PROTECTED] Envoyé : lundi 26 mars 2007 13:24
À : discuss@restlet.tigris.org
Cc : [EMAIL PROTECTED]
Objet : Re: spring and restlet

Jerome,

Thxs, this is great. I have a few more comments\questions inline

Jerome Louvel wrote:
3) Embedded mode B: lighter version where Spring and the
Servlet container
are not masked by the concept of Restlet Application. This
requires the
creating of a special Servlet (maybe a Spring's
HttpBeanServlet subclass)
HttpServletBean is the class that needs to be subclassed.

and a bit of coding to convert Servlet's calls into
Restlet's calls. In this
mode, no Restlet's Application is created,
Restlets/Filters/Routers/Finders
are directly instantiated by Spring and configured like
other Spring beans.
Of course you loose the Application services and the
portability of your
Restlet code to other deployment environments.
i think this is the most appealing mode for my application but I think I need a bit more info to get going. For instance if all I want to do is use the Router class then all I need to do is

1. subclass HttpServletBean

2. subclass doXXX in HttpServletBean

3. for each method convert the HttpServletRequest to a org.restlet.data.Request and subsequently the org.restler.data.Response to a HttpServletResponse.

4. In each of the HttpServletBean.doXXX call
Router.handle(request,
response) method to route to the appropriate Resource.

Is this correct?

Should I also look at the ServerServlet class for help on converting a Servlet call to a Restlet call?


cheers
</jima>

------------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";>
        <display-name>
        ServletDemo</display-name>
        <welcome-file-list>
                <welcome-file>index.html</welcome-file>
                <welcome-file>index.htm</welcome-file>
                <welcome-file>index.jsp</welcome-file>
                <welcome-file>default.html</welcome-file>
                <welcome-file>default.htm</welcome-file>
                <welcome-file>default.jsp</welcome-file>
        </welcome-file-list>
        <servlet>
                <servlet-name>TestServlet</servlet-name>
                <servlet-class>TestServlet</servlet-class>
        </servlet>
        <servlet-mapping>
                <servlet-name>TestServlet</servlet-name>
                <url-pattern>/restlet/*</url-pattern>
        </servlet-mapping>
</web-app>

Reply via email to