Jersey and exyus

2008-03-07 @ 20:34#

Marc Hadley offers a post on how to set up RESTful authentication (i.e. HTTP Auth) using Jersey. while i don't travel in the Java world, i notice that the basic look-and-feel of Jersey is quite close to the exyus engine i've been working on for the last several months.

for example, check out a comparison of a Jersey and exyus for the "helloword" sample:

// The Java class will be hosted at the URI path "/helloworld"
public class HelloWorldResource {

    private UriInfo context;

    /** Creates a new instance of HelloWorldResource */
    public HelloWorldResource() {

   * Retrieves representation of an instance of
   * @return an instance of java.lang.String
   public String getClichedMessage() {
       //Return some cliched textual content
       "Hello World! Here is " + context.getAbsolutePath();

// the exyus (C#) version of "/helloworld"
public class HelloWorldResource : StaticResource
    public HelloWorldResource()
        this.Content = "Hello World! Here is $_absolute-path$";

they handle authentication declarations similarly as well. Jersey uses sections in the web.xml to declare a secured path and exyus uses auth-urls.xml and auth-users.xml to handle the details:

// jersey web.xml
        <description>Have to be a USER</description>

// exyus auth-urls.xml
	<url path="/helloworld" auth="true" />
// exyus auth-users.xml
	<user name="user" password="XXXXX">
		<role name="admin" />
		<permission path="/helloworld" methods="*" />

again, nice to see things moving along the same lines. the exyus code is a bit more 'terse' and i like that. but still, nice to see the similarities.