A larger scale suggestion that I recommend is using Spring, we use the
spring framework with an embedded Jetty. If your application is very small
and doesn't need to be extended and scaled, then the Spring framework is
possibly overkill, there is certainly a significant learning curve. But it
does a really great job of organizing your development in a logical way and
provides built-in functionality for probably 85% of the problems you'll run
into (including making REST services virtually trivial to develop - after
the learning curve).

 

At a minimum I'd take a look at the framework and know about it, I found
even in my smallest projects that it was worthwhile to learn it. A step
beyond spring is the Groovy/Grails platform that is a web friendly language
and platform laid on top of Java and Spring respectively, which might be
worth knowing about too (I don't have any personal experience there though,
I've only used Spring/Jetty). 



Some food for thought. Good luck.

David

 

 

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Jeremy Johnson
Sent: Tuesday, November 08, 2011 2:50 PM
To: JETTY user mailing list
Subject: Re: [jetty-users] RESTful web services with Jetty

 

Hi Martin,

 

Thanks so much!  It's great to hear that the Jersey/Jetty setup has been
working well for you.  As I mentioned, my experience in this area with Java
is near-nil although it seemed to me like this should be a great setup.  I
wonder why there are so few examples?

 

I really do appreciate your offer to share some code.  I've spent a little
time trying to get a dusty old example to work with newer versions of Jetty
and Jersey, but I'm getting errors and with my newb-ness the solution isn't
obvious.  As for my web service, it should be fairly simple (although I will
need SSL and some yet-to-be-determined authentication mechanism, if it's
worth mentioning).  Since the Websockets standard continues to evolve, I'm
pretty sure I need Jetty 7.4.4 or later to take advantage of the latest
Websockets spec.  I'll also be running the Jetty embedded in my server, if
it makes any difference.

 

If you had any code to share that just demonstrates how recent versions of
Jetty and Jersey should be properly glued together, that would probably be a
great help.

 

If you think it would be better to email code to me personally, I can build
a clean and simple Jersey/Jetty sample that I can post back to the list for
archival.

 

Thanks!

 

Jeremy

[email protected]

 

 

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Martin Hewitt
Sent: Tuesday, November 08, 2011 5:06 PM
To: JETTY user mailing list
Subject: Re: [jetty-users] RESTful web services with Jetty

 

 

On 8 Nov 2011, at 21:38, Jeremy Johnson wrote:

 

Hello list,

 

I'm looking for guidance on the best approach for implementing a RESTful
webservice with Jetty.  I should start by saying that I'm a veteran .NET
developer, but Jetty and server-side Java development are completely new to
me.  I've selected Jetty to provide a web API for a new server project as I
needed an efficient embedded webserver with excellent support for the
emerging Websocket standard. 

 

In addition to Websocket support, the web API exposed by my server needs to
be RESTful.  In looking around, I can find a few older examples of REST
frameworks such as Jersey or RESTlet with Jetty, but these are few and in
general there seems to be little discussion of RESTful web services with
Jetty.  I've been leaning towards Jersey, but the relative lack of examples
makes me wonder if I should be considering something else.


Any insights would be most welcome.  (I also wouldn't turn down any example
code, as I'm still seeing some errors with the samples I've found using
older versions of Jersey and Jetty).

 

Thanks!

Jeremy

 

 

Jeremy,

 

We use Jetty and Jersey for our primary REST API and you're right, there's
not much by way of examples.

 

We've pieced together a handful of techniques, including some nifty little
bits like determining the response type by the file extension of the request
and so on.

 

The Jetty setup is actually quite simple, Jersey takes care of a lot of the
automatic configuration & service discovery etc. We're actually very happy
with the pairing, we've been using it for almost two years now and we
haven't hit any limitations.

 

I'm happy to show you as much of our code as I can, if you have an idea of
where you'd want to start?

 

Martin

 

_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to