Hi Thierry!

We choose serving restet with a servlet container. Once we have another
needed features inside that, the purpose of my mail was show to the
community embedding restlet in Jetty and use the following common used
resources by applications:

   - Restlet
   - War
   - Gwt
   - Static files
   - Redirection

Best regards,

On Wed, Feb 29, 2012 at 7:31 AM, Thierry Boileau <
[email protected]> wrote:

> Hello all,
>
> I think this could be a little bit simpler. The first step is to code your
> application without regarding the way you will serve it.
>
> By design, "Application" is the right unit of code desired, you are
> basically required to complete the "createInboundRoot" method :
> @Override
>     public Restlet createInboundRoot() {
>         Router router = new Router(getContext());
>         router.attach("/test", MyResource.class);
>         return router;
>     }
>
> At this time, your application is only composed of 2 classes :
> MyApplication and MyResource.
>
> Then, it is time to serve it.
> A/ You can serve it with a servlet container (could be tomcat, weblogic,
> jetty, etc) as a "war" file.
> 1- complete the list of libraries : org.restlet.jar,
> org.restlet.ext.servlet.jar
> 2- Provide a web.xml file that links to your application :
> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns="
> http://java.sun.com/xml/ns/javaee"; xmlns:web="
> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; xsi:schemaLocation="
> http://java.sun.com/xml/ns/javaee
> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; id="WebApp_ID"
> version="2.5">
>   <display-name>test</display-name>
>   <servlet>
>     <servlet-name>test</servlet-name>
>     <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
>     <init-param>
>       <param-name>org.restlet.application</param-name>
>       <param-value>test.MyApplication</param-value>
>     </init-param>
>   </servlet>
>   <servlet-mapping>
>     <servlet-name>test</servlet-name>
>     <url-pattern>/restlet/*</url-pattern>
>   </servlet-mapping>
> </web-app>
> 3- that's enough for your war file.
>
> B/ You can serve it without a servlet container.
> 1- add a main method, that declares a Component and links to your
> application
> Component component = new Component();
> // MyApplication will be available using the HTTP protocol on port 8182
> component.getServers().add(Protocol.HTTP, 8182);
> component.getDefaultHost().attach("/restlet", new MyApplication());
> component.start();
>
> 2- either, complete the classpath with only the org.restlet.jar core
> library
> In this case, your application uses the internal HTTP connector contained
> inside the core library. We suggest this only for development, as this
> internal connector is not stable enough.
>
> 3- or you can use one of the provided HTTP connectors such as "jetty"
> (this is not the full servlet container! but the core piece of code that
> handles HTTP requests/responses) or "simple".
> There is no need to update your code, you are just required to complete
> the classpath with the following jars
> a/ core library : org.restlet.jar
> b/ extension library : org.restlet.ext.jetty.jar or
> org.restlet.ext.simple.jar
> c/ dependencies (all are shipped with the Restlet distribution).
> In the case of the Simple extension => lib/org.simpleframework/*.jar
> In the case of the Jetty extension => lib/org.eclipse.jetty/*.jar and
> lib/javax.servlet/*.jar
>
> I hope this will help you.
>
> Best regards,
> Thierry Boileau
> ps : here is a full sample application
> http://wiki.restlet.org/docs_2.1/13-restlet/303-restlet.html
>
>
>
> Hi all,
>>
>> Guilherme and I has worked together to solve this issue.
>>
>> We have solved our problem getting more information about setting up
>> Jetty and deploying restlet on Servlet container.
>>
>> Here go our sample code:
>>
>> //Jetty server
>>
>> Server server = new Server(8080);
>>
>>
>> //Restlet context
>>
>> ServletContextHandler restletContext = 
>> newServletContextHandler(ServletContextHandler.
>> SESSIONS);
>>
>> restletContext.setContextPath("/restlet");
>>
>> ServerServlet serverServlet = new ServerServlet();
>>
>> ServletHolder servletHolder = new ServletHolder(serverServlet);
>>
>> servletHolder.setInitParameter("org.restlet.application",
>> "main.RestletApplication");
>>
>> restletContext.addServlet(servletHolder, "/*");
>>
>>
>> //War context
>>
>> WebAppContext warContext = new WebAppContext();
>>
>> warContext.setContextPath("/war");
>>
>> warContext.setWar("/somepath/minhawar.war");
>>
>>
>> //Gwt context
>>
>> WebAppContext gwtContext = new WebAppContext();
>>
>> gwtContext.setContextPath("/gwt");
>>
>> gwtContext.setWar("/somepath/hellogwt.war");
>>
>>
>> //File server context
>>
>> ContextHandler fileHandler = new ContextHandler();
>>
>> fileHandler.setContextPath("/files");
>>
>> ResourceHandler resourceHandler = new ResourceHandler();
>>
>> resourceHandler.setResourceBase("/somepath/public_html");
>>
>> resourceHandler.setDirectoriesListed(true);
>>
>> fileHandler.setHandler(resourceHandler);
>>
>>
>> //Redireciton context
>>
>> MovedContextHandler movedContextHandler = new MovedContextHandler();
>>
>> movedContextHandler.setContextPath("/data");
>>
>> movedContextHandler.setNewContextURL("/files");
>>
>> movedContextHandler.setPermanent(false);
>>
>>
>>
>> //Jetty start up
>>
>> ContextHandlerCollection contexts = new ContextHandlerCollection();
>>
>> contexts.setHandlers(new Handler[] { restletContext,
>> warContext, gwtContext, fileHandler, movedContextHandler });
>>
>>
>>
>> HandlerCollection handlerCollection = new HandlerCollection();
>>
>> handlerCollection.setHandlers(new Handler[] { contexts });
>>
>> server.setHandler(handlerCollection);
>>
>>
>> server.start();
>>
>> server.join();
>>
>> We had to add the following libraries to the project classpath:
>>
>>> jetty-distribution-7.6.1.v20120215/lib/jetty-servlet-7.6.1.v20120215.jar
>>> restlet-jee-2.0.11/lib/org.restlet.ext.servlet.jar
>>> restlet-jee-2.0.11/lib/org.restlet.jar
>>> jetty-distribution-7.6.1.v20120215/lib/servlet-api-2.5.jar
>>> jetty-distribution-7.6.1.v20120215/lib/jetty-webapp-7.6.1.v20120215.jar
>>> jetty-distribution-7.6.1.v20120215/lib/jetty-server-7.6.1.v20120215.jar
>>> jetty-distribution-7.6.1.v20120215/lib/jetty-util-7.6.1.v20120215.jar
>>> jetty-distribution-7.6.1.v20120215/lib/jetty-http-7.6.1.v20120215.jar
>>> jetty-distribution-7.6.1.v20120215/lib/jetty-io-7.6.1.v20120215.jar
>>> jetty-distribution-7.6.1.v20120215/lib/jetty-security-7.6.1.v20120215.jar
>>>
>>> jetty-distribution-7.6.1.v20120215/lib/jetty-continuation-7.6.1.v20120215.jar
>>> jetty-distribution-7.6.1.v20120215/lib/jetty-xml-7.6.1.v20120215.jar
>>> jetty-distribution-7.6.1.v20120215/lib/jsp/org.eclipse.jdt.core-3.7.1.jar
>>>
>>> jetty-distribution-7.6.1.v20120215/lib/jsp/org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar
>>>
>>> jetty-distribution-7.6.1.v20120215/lib/jsp/org.apache.jasper.glassfish-2.1.0.v201110031002.jar
>>>
>>> jetty-distribution-7.6.1.v20120215/lib/jsp/javax.servlet.jsp.jstl-1.2.0.v201105211821.jar
>>>
>>> jetty-distribution-7.6.1.v20120215/lib/jsp/javax.servlet.jsp-2.1.0.v201105211820.jar
>>>
>>> jetty-distribution-7.6.1.v20120215/lib/jsp/javax.el-2.1.0.v201105211819.jar
>>>
>>> jetty-distribution-7.6.1.v20120215/lib/jsp/com.sun.el-1.0.0.v201105211818.jar
>>
>>
>> Best regards,
>>
>>
>> On Thu, Feb 23, 2012 at 2:42 PM, Guilherme Gotardo <[email protected]
>> > wrote:
>>
>>> Hi all,
>>>
>>> I have a .WAR file that contains a simple HelloWorld, and I want to add
>>> it into my server. I'm using the Jetty connector.
>>>
>>> When I run my war directly with Jetty Server, works fine, but when I try
>>> to run using Restlet, the following error occurs:
>>>
>>> Fev 23, 2012 2:40:47 PM org.restlet.engine.Engine createHelper
>>> Warning: No available server connector supports the required protocols:
>>> 'WAR' . Please add the JAR of a matching connector to your classpath.
>>> 2012-02-23 14:40:47.274:INFO::jetty-7.1.6.v20100715
>>> 2012-02-23 14:40:47.367:INFO::Started
>>> [email protected]:8080
>>>
>>>
>>> I've attached my code, please, what can I do to resolve that?
>>> Thanks in advanced.
>>>
>>> ------------------------------------------------------
>>>
>>> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2925951
>>
>>
>>
>>
>> --
>> Danilo Rosetto Muñoz
>> [email protected]
>> http://br.linkedin.com/in/danilomunoz
>>
>>
>


-- 
Danilo Rosetto Muñoz
[email protected]
http://br.linkedin.com/in/danilomunoz

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

Reply via email to