Hi
I've worked today on supporting the JAX-RS 1.1 ApplicationPath annotation
and did some work to do with
RuntimeDelegate.createEndpoint(Application, Class<T> endpointClass) along
the way, with the idea of hiding away from the users most of
JAXRServerFactory specific code - as long as they want to use JAX-RS
Applications.
As I said earlier on RuntimeDelegate.createEndpoint(...) can not help with
writing a 100% portable code because
one needs to write an http container specific code.
With that in mind, I provided some initial support for
RuntimeDelegate.createEndpoint(Application app, Class<T> endpointType)
For example :
MyApplication app = new MyApplication();
org.apache.cxf.endpoint.Server server =
RuntimeDelegate.newInstance().createEndpoint(app,
org.apache.cxf.endpoint.Server.class);
server.start();
This is not a portable code - but it is as portable as it can get. The
interaction with the CXF specific API is limited.
The above code should work fine if CXF ServletDestination is available.
If not then
MyApplication app = new MyApplication();
JAXRSServerFactoryBean bean =
RuntimeDelegate.newInstance().createEndpoint(app,
JAXRSServerFactoryBean.class);
bean.setAddress("http:/localhost:8080/somecontext" + bean.getAddress());
bean.create();
Note
"
bean.setAddress("http:/localhost:8080/somecontext" + bean.getAddress());
".
Application may have the ApplicationContext annotation so its value has to
be taken into account.
It does not make sense to have an absolute address encoded in the
Application subclass and there's no way with either JAX-RS Application or
RuntimeDelegate to provide an absolute URI unless one deal directly with
some HTTP stack API.
cheers, Sergey
On Wed, Aug 11, 2010 at 9:10 AM, Sergey Beryozkin <[email protected]>wrote:
> Hi
>
> On Tue, Aug 10, 2010 at 5:09 PM, rickcole3 <[email protected]> wrote:
>
>>
>> We are adding REST support to our application. Our container is homegrown
>> and
>> based on Spring running an embedded Jetty instance. We need the ability to
>> dynamically deploy and undeploy JAX-RS REST web services. We have already
>> done this for SOAP services using the Endpoint.publish() and
>> Endpoint.stop()
>> API. However, I need to do the same for a REST API and I have not been
>> able
>> to find any way to do this. I would prefer to use only the JAX-RS API, but
>> I
>> am not adverse to using CXF-specific code. Has anyone had any success
>> doing
>> this? Thanks!
>>
>
> JAX-RS API offers
>
> RuntimeDelegate.createEndpoint(Application, Class<T> endpointClass)
>
> and the idea is that one does, for example,
>
> RuntimeDelegate.createEndpoint(new MyApplication(), SomeJetty.class)
>
> etc, for different types of containers.
>
> This is not implemented in CXF and IMHO it would not make the code any more
> portable than with using some stack-specific API. I recall proposing
> introducing an Endpoint interface to be used instead of container-specific
> classes, but it was not approved.
>
> So you can use CXF JAXRSServerFactoryBean to start and stop endpoints.
> With DOSGI RI that can be done at the OSGI level (just using shell
> commands).
>
> cheers, Sergey
>
>
>> --
>>
>> View this message in context:
>> http://cxf.547215.n5.nabble.com/Dynamically-Deploying-JAX-RS-RESTful-web-services-tp2453549p2453549.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>>
>
>