-
1. Re: GateIn and REST service
ndkhoiits Oct 12, 2010 10:56 PM (in response to tharamediacept)OK, you need only add your rest service as a component under ExoContainer
For example, you have a service named 'com.yourcompany.HelloworldService', you will create a config file in your jar 'conf/portal/configuration.xml'
{code:xml}
<configuration
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
<component>
<type>com.yourcompany.HelloworldService</type>
</component>
</configuration>
{code}
-
2. Re: GateIn and REST service
tharamediacept Oct 13, 2010 10:54 AM (in response to ndkhoiits)thanks fo response,I refer to this doc: http://docs.jboss.com/gatein/portal/3.1.0-FINAL/reference-guide/en-US/html/chap-Reference_Guide-Advanced.html#sect-Reference_Guide-Foundations-Configuring_portalthat tell me how to configure a portal container.using the code configuration:thanks for response,
I refer to this doc: http://docs.jboss.com/gatein/portal/3.1.0-FINAL/reference-guide/en-US/html/chap-Reference_Guide-Advanced.html#sect-Reference_Guide-Foundations-Configuring_portal
that tell me how to configure a portal container.
using the code configuration:
<component> <type>com.yourcompany.HelloworldService</type> </component>
dose not permet to call a REST web service using its url
there is my REST web service definition:
package sample.hello.resources; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; @Path("/hello") public class HelloResource { // This method is called if TEXT_PLAIN is request @GET @Produces(MediaType.TEXT_PLAIN) public String sayPlainTextHello() { return "Hello test rest"; } // This method is called if XMLis request @GET @Produces(MediaType.TEXT_XML) public String sayXMLHello() { return "<?xml version=\"1.0\"?>" + "<hello> Hello test rest" + "</hello>"; } // This method is called if HTML is request @GET @Produces(MediaType.TEXT_HTML) public String sayHtmlHello() { return "<html> " + "<title>" + "Hello test rest" + "</title>" + "<body><h1>" + "Hello test rest" + "</body></h1>" + "</html> "; }
and add this component to configuration file:
<component> <type>sample.hello.resources.HelloResource</type> </component>
But that dose not work
any suggestion please?
-
3. Re: GateIn and REST service
ndkhoiits Oct 13, 2010 11:27 AM (in response to tharamediacept)Hi
Your REST service must be implemented org.exoplatform.services.rest.resource.ResourceContainer interface is an indicator for the ResourceBinder
-
4. Re: GateIn and REST service
zsv Dec 14, 2010 5:02 AM (in response to ndkhoiits)gatein 3.1 on tomcat 6
my service file:
package ru.tersys.projects.prodimex.web.service;
import java.util.Calendar;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.exoplatform.services.rest.resource.ResourceContainer;
@Path("pub")
public class GaugeDataServiceImpl implements ResourceContainer{
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getPlainTextValue()
{
return "hello";
}
}WEB-INF/conf/configuration.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<configuration
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
<component>
<key>ru.tersys.projects.prodimex.web.service.GaugeDataServiceImpl</key>
<type>ru.tersys.projects.prodimex.web.service.GaugeDataServiceImpl</type>
</component>
</configuration>When I try to access http://localhost:8080/rest/private/pub I get 404.
I think it simply ignore my service: for service such RestManagementProvider (path="/management") I found binding log in catalina.log.
What wrong with my configuration?
-
5. Re: GateIn and REST service
zsv Dec 14, 2010 10:35 AM (in response to zsv)If I add component definition to portal/WEB-INF/conf/configuration.xml and add GaugeDataServiceImpl to class - all working as expected.
But how to configure rest service in separate configuration.xml file in another war....?
-
6. Re: GateIn and REST service
trong.tran Dec 14, 2010 9:39 PM (in response to zsv)Why do not you put them in a jar instead of a war ? putting in a jar is recommended to implement a rest service for GateIn portal
BTW if you want the configuration in your war is detected by a portal, let try to configure it as an portal extension.
For "how to configure a portal extension", you could find there are already some discussions in forum and also refer to http://docs.jboss.com/gatein/portal/3.1.0-FINAL/reference-guide/en-US/html_single/index.html#sect-Reference_Guide-Foundations-Configuring_portal .
-
7. Re: GateIn and REST service
zsv Dec 15, 2010 2:39 AM (in response to trong.tran)Thanks, Trong Tran. This help me to understand how it working . Last night I found the following thing in gatein docs:
GateIn Kernel uses dependency injection to create services based on configuration.xml configuration files. The location of the configuration files determines if services are placed into RootContainer scope, or into PortalContainer scope. All configuration.xml files located at conf/configuration.xml in the classpath (any directory, or any jar in the classpath) will have their services configured at RootContainer scope. All configuration.xml files located at conf/portal/configuration.xml in the classpath will have their services configured at PortalContainer scope. Additionally, portal extensions can contain configuration in WEB-INF/conf/configuration.xml, and will also have their services configured at PortalContainer scope.....This is the same that you said.
-
8. Re: GateIn and REST service [SOLVED]
genia Jan 2, 2011 7:57 AM (in response to tharamediacept)Hi Guys:
I'm finding myself stuck, hopefully someone might provide some help.
When I deploy my service in JBoss, in the server.log I can read:
DelegatingHandler@1868373866[path=gatein.ear/lib/HelloworldService.jar context=file:/F:/MyPortal/GateIn-3.1.0-FINAL-jbossas/GateIn-3.1.0-GA/server/default/deploy/ real=file:/F:/MyPortal/GateIn-3.1.0-FINAL-jbossas/GateIn-3.1.0-GA/server/default/deploy/gatein.ear/lib/HelloworldService.jar],
but then if I call
curl -u root:gtn http://localhost:8080/rest/hello
I'm replyed with "HTTP Status 404" - the requested resource is not available.
I'm in the following situation:
Distribution: GateIn-3.1.0-FINAL-jbossas (JBoss AS 5.1.0 JDK6 + GateIn 3.1.0.GA)
my service file:
import javax.ws.rs.GET;import javax.ws.rs.Path;import javax.ws.rs.Produces;import javax.ws.rs.core.MediaType;@Path("/hello")public class HelloworldService{// This method is called if TEXT_PLAIN is request@GET@Produces(MediaType.TEXT_PLAIN)public String sayPlainTextHello() {return "Hello test rest";}// This method is called if XMLis request@GET@Produces(MediaType.TEXT_XML)public String sayXMLHello() {return "<?xml version=\"1.0\"?>" + "<hello> Hello test rest" + "</hello>";}// This method is called if HTML is request@GET@Produces(MediaType.TEXT_HTML)public String sayHtmlHello() {return "<html> " + "<title>" + "Hello test rest" + "</title>"+ "<body><h1>" + "Hello test rest" + "</body></h1>" + "</html> ";}}package com.company.test;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/hello")
public class HelloworldService{
// This method is called if TEXT_PLAIN is request
@GET
@Produces(MediaType.TEXT_PLAIN)
public String sayPlainTextHello() {
return "Hello test rest";
}
}
in my JAR I have a folder /conf/portal with configuration.xml:
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
<component>
<key>com.company.test.HelloworldService</key>
<type>com.company.test.HelloworldService</type>
</component>
</configuration>
Any suggestion will be appreciated.
Many thanks!
Byte
EDIT: I've figured out. I've pulled from a previous GateIn codebase org.exoplatform.services.rest.resource.ResourceContainer into my project. Implemented it in my service class and now everything works!
Cheers.