Created
December 3, 2010 15:56
-
-
Save jawher/727127 to your computer and use it in GitHub Desktop.
Configuring Restlet with a servlet container + using the JAX-RS API + JSON encoding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.restlet.Context; | |
import org.restlet.ext.jaxrs.JaxRsApplication; | |
import javax.ws.rs.core.Application; | |
import java.util.HashSet; | |
import java.util.Set; | |
import org.codehaus.jackson.jaxrs.JacksonJsonProvider; | |
class GfeResources extends Application { | |
@Override | |
public Set<Object> getSingletons() { | |
Set<Object> res = new HashSet<Object>(); | |
res.add(new JacksonJsonProvider()); | |
return res; | |
} | |
public Set<Class<?>> getClasses() { | |
Set<Class<?>> res = new HashSet<Class<?>>(); | |
res.add(FilesystemResource.class); | |
return res; | |
} | |
} | |
public class GfeApp extends JaxRsApplication { | |
public GfeApp(Context context) { | |
super(context); | |
add(new GfeResources()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<repositories> | |
<repository> | |
<id>maven-restlet</id> | |
<name>Public online Restlet repository</name> | |
<url>http://maven.restlet.org</url> | |
</repository> | |
</repositories> | |
<dependencies> | |
<dependency> | |
<groupId>org.restlet.jse</groupId> | |
<artifactId>org.restlet</artifactId> | |
<version>2.0.3</version> | |
</dependency> | |
<dependency> | |
<groupId>org.restlet.jse</groupId> | |
<artifactId>org.restlet.ext.jaxrs</artifactId> | |
<version>2.0.3</version> | |
</dependency> | |
<dependency> | |
<groupId>org.restlet.jee</groupId> | |
<artifactId>org.restlet.ext.servlet</artifactId> | |
<version>2.0.3</version> | |
</dependency> | |
<dependency> | |
<groupId>org.restlet.jse</groupId> | |
<artifactId>org.restlet.ext.jackson</artifactId> | |
<version>2.0.3</version> | |
</dependency> | |
</dependencies> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<servlet> | |
<servlet-name>RestRestlet</servlet-name> | |
<servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class> | |
<init-param> | |
<param-name>org.restlet.application</param-name> | |
<param-value>gfe.server.GfeApp</param-value> | |
</init-param> | |
</servlet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment