tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <>
Subject Re: Jetty Support
Date Sun, 12 Feb 2012 02:48:04 GMT

On Feb 8, 2012, at 4:53 AM, john70 wrote:

> Hi David,
> thank you again for taking time!
> David Blevins-2 wrote
>> The part that has historically been missing in Jetty terms is the
>> injection support of various Java EE things into Servlets, Filters, etc. 
>> I.e. wiring the things that Jetty controls into the overall server.  Jan
>> and I have chatted a couple times on that part.
> I don't need  the injection support for Servlets, Filters, etc. So if it is
> still missed, it is OK for me.

If that's the case, it sounds like you don't need really any "integration".  Both OpenEJB
and Jetty have very expressive APIs for building things up in code. I wouldn't recommend this
to just anyone, but it sounds like you might get a little giggle out of the possibilities.

There isn't really a "test" there, I just started playing -- I tend to use tests rather than
main classes for prototyping.

Just a little proof of concept.  There are numerous ways that could be tweaked, changed, or
expanded.  The idea was just to get the creative juices flowing.

So note on the "if (proxied)" statement.  One approach just has OpenEJB build the actual instance
and hand it over bare to Jetty.  This approach will get you a fully injected instance, but
none of the container managed services that are setup prior to calls being made; jndi, transactions,
interceptors, locking, cdi request scope.  The other approach get's you all that extra stuff.

I would note that when you have the kind of control shown in that simple little example, you
can easily make that decision however you want.  For example, that if block could be:

    if (beanContext.getBeanClass().isAnnotationPresent(Proxied.class)) {
        // Interceptors, transactions, CDI scope management all will be enabled
        servlet = (Servlet) beanContext.getBusinessLocalHome().create();
    } else {
        // Here we just take the raw injected instance and use it directly
        final InstanceContext instanceContext = beanContext.newInstance();
        servlet = (Servlet) instanceContext.getBean();

Where 'Proxied' is some annotation you made up and apply where you want it.

As well the line that uses the ejbName as the path could just as easily use some other annotation
of your design to set the path -- you could even reuse the @WebServlet annotation if you wanted.

Most people aren't used to thinking like an app server developer and so these things aren't
obvious, but with the right mindset you can have all sorts of wicked fun.


View raw message