cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Obele, Azubuko" <Azubuko.Ob...@morganstanleysmithbarney.com>
Subject RE: Customizing the Underlying Jetty Server with JAXRS
Date Thu, 15 Jul 2010 21:44:01 GMT
Dan,

I might take you up on that offer.  I'm just trying to have a jetty server that serves up
static resources as well as exports   various service points. For now, I've done the following
which SEEMS to work. I'm not sure why, or how, but it works. All I've done is made sure the
jaxrs:server uses the same port as the httpj:engine-factory eg:

<httpj:engine-factory bus="cxf" id="jetty-factory">
         <httpj:engine port="8080">
            <httpj:handlers>
                <ref bean="staticResourceJettyHandler" />
            </httpj:handlers>
        </httpj:engine>
	</httpj:engine-factory>
	
	<jaxrs:server id="server" address="http://localhost.com:8080/services/" >
	   <jaxrs:serviceBeans>
	       <ref bean="userService" />
	   </jaxrs:serviceBeans>
	   <jaxrs:providers>
           <ref bean="jsonProvider" />
	       <ref bean="jaxbElementProvider" />
	   </jaxrs:providers>
	   <jaxrs:extensionMappings>
	       <entry key="json" value="application/json" />
           <entry key="xml" value="application/xml" />
        </jaxrs:extensionMappings>	   
        
	</jaxrs:server>

-----Original Message-----
From: Daniel Kulp [mailto:dkulp@apache.org] 
Sent: Thursday, July 15, 2010 4:39 PM
To: users@cxf.apache.org
Cc: Obele, Azubuko (GWMG Technology)
Subject: Re: Customizing the Underlying Jetty Server with JAXRS


That's a really good question.   I was going to point at:

http://cxf.apache.org/docs/jetty-configuration.html

but that really doesn't address completely what you need.   You can add 
handlers with it, but not sure about other static file serving and such.   

>From code, you could do something like:
 JettyHTTPServerEngineFactory serverEngineFactory =getBus().getExtension(JettyHTTPServerEngineFactory.class);
if (serverEngineFactory == null) {
            serverEngineFactory = new JettyHTTPServerEngineFactory();
            serverEngineFactory.setBus(getBus());
        }

And then call:
JettyHTTPServerEngine createJettyHTTPServerEngine(String host, int port, 
        String protocol)

on there to get the engine for whatever port you are on and start mucking with it.

That all said, if you REALLY would like "top notch" ability to do this, I would recommend
digging into the cxf-transport-http-jetty code and adding some options to the stuff described
on the above docs page to add additional 
functionality and submit that back to CXF.     I'd be willing to help provide 
pointers.   :-)

Dan


On Wednesday 14 July 2010 6:14:02 pm Obele, Azubuko wrote:
> I'm using the namespace-based Spring configuration to setup JAXRS so I 
> have something like:
> 
> <jaxrs:server id="myservice" address="http://localhost.ms.com:8080/ai/" >
>     <jaxrs:serviceBeans>
>         <ref bean="a" />
>     </jaxrs:serviceBeans>
>     <jaxrs:providers>
>         <ref bean="jaxbElementProvider" />
>         <ref bean="jacksonProvider" />
>     </jaxrs:providers>
>     <jaxrs:extensionMappings>
>         <entry key="json" value="application/json" />
>            <entry key="xml" value="application/xml" />
>         </jaxrs:extensionMappings>
>  </jaxrs:server>
> 
> It works great.
> 
> The thing is, I'd like to customize the underlying Jetty server used here.
> I'd like to also serve up static resources and add a few other handlers.
> This seems like a common request but I can't google up any definitive 
> answers.
> 
> I see that jaxrs:server has a serviceClass and a transportId attribute 
> but I'm having a lot of trouble figuring out exactly how I might use 
> these to do what I want. Any ideas?
> 
> Thanks,
> 
> ----------------------------------------------------------------------
> ----
> Important Notice to Recipients:
> 
> It is important that you do not use e-mail to request, authorize or 
> effect the purchase or sale of any security or commodity, to send fund 
> transfer instructions, or to effect any other transactions. Any such 
> request, orders, or instructions that you send will not be accepted 
> and will not be processed by Morgan Stanley Smith Barney.
> 
> The sender of this e-mail is an employee of Morgan Stanley Smith 
> Barney LLC. If you have received this communication in error, please 
> destroy all electronic and paper copies and notify the sender 
> immediately.  Erroneous transmission is not intended to waive 
> confidentiality or privilege. Morgan Stanley Smith Barney reserves the 
> right, to the extent permitted under applicable law, to monitor 
> electronic communications. By e-mailing with Morgan Stanley Smith Barney you consent
to the foregoing.

--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

--------------------------------------------------------------------------
Important Notice to Recipients:
 
It is important that you do not use e-mail to request, authorize or effect the purchase or
sale of any security or commodity, to send fund transfer instructions, or to effect any other
transactions. Any such request, orders, or instructions that you send will not be accepted
and will not be processed by Morgan Stanley Smith Barney.
 
The sender of this e-mail is an employee of Morgan Stanley Smith Barney LLC. If you have received
this communication in error, please destroy all electronic and paper copies and notify the
sender immediately.  Erroneous transmission is not intended to waive confidentiality or privilege.
Morgan Stanley Smith Barney reserves the right, to the extent permitted under applicable law,
to monitor electronic communications. By e-mailing with Morgan Stanley Smith Barney you consent
to the foregoing.

Mime
View raw message