You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Angelo zerr <an...@gmail.com> on 2012/06/08 10:06:02 UTC

How to manage optionnal HttpServices with DOSGi with "org.apache.cxf.rs.httpservice.context" property?

Hi CXF Team,

I'm writing article about DOSGi + ServletBridge to create a WAR with DOSGi
bundles+JAX-RS Services and deploy it with Web Server which doesn't support
OSGi.
To manage that I use the "org.apache.cxf.rs.httpservice.context" property
to register the servlet with HttpServices which works with ServletBridge
well :

---------------------------------------------------------------------------------------------------------------------------
<entry key="org.apache.cxf.rs.httpservice.context" value="/UserService" />
---------------------------------------------------------------------------------------------------------------------------

But I would like manage with the same bundle the 2 configuration (only OSGi
container with OSGi Jetty, and ServletBridge)
To manage that I thought create an OSGi frgament which populate the value
of org.apache.cxf.rs.httpservice.context

---------------------------------------------------------------------------------------------------------------------------
<entry key="org.apache.cxf.rs.httpservice.context" value="${context}" />
---------------------------------------------------------------------------------------------------------------------------

For "ServletBridge" the fragment contains the property

---------------------------------------------------------------------------------------------------------------------------
context=/UserService
---------------------------------------------------------------------------------------------------------------------------

For " OSGi container with OSGi Jetty" the fragment contains the property

---------------------------------------------------------------------------------------------------------------------------
context=
---------------------------------------------------------------------------------------------------------------------------

And I thought DOSGi will not register teh service with HttpServices, but it
doesn't work.
Have you an idea how to manage the 2 configuration (with and without
HttpServices) with the same declaration of teh service?

Many thanks for your help.

Regards Angelo

Re: How to manage optionnal HttpServices with DOSGi with "org.apache.cxf.rs.httpservice.context" property?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 19/06/12 08:59, Angelo zerr wrote:
>
>
> 2012/6/18 Sergey Beryozkin <sberyozkin@gmail.com
> <ma...@gmail.com>>
>
>     Hi Angelo
>
>     On 18/06/12 08:36, Angelo zerr wrote:
>
>         Hi Sergey,
>
>         Many thank's for your suggestion, it works great. I have
>         explained how
>         to create a WAR for a DOSGi Application with ServletBridget by using
>         Libra/WARProduct in the article
>         http://angelozerr.wordpress.__com/2012/06/18/eclipse_spring___dosgi_step4/
>         <http://angelozerr.wordpress.com/2012/06/18/eclipse_spring_dosgi_step4/>
>         and
>         it explains your idea with ${name} to manage httpservices or not.
>
>         But I think it's just a little complicated and if we have a property
>         like this :
>
>         ------------------------------____----------------------------__--__--------------------------__----__------------------------__------__---
>         <entry key="org.apache.cxf.rs <http://org.apache.cxf.rs>
>         <http://org.apache.cxf.rs/>.____httpservice.ignore-if--not-__available"
>         value="true" />
>         ------------------------------____----------------------------__--__--------------------------__----__------------------------__------__---
>
>
>
>         which doesn't use HtppService if it doesn't find it. It should
>         be more easy.
>
>         What do you think about that?
>
>     I think even having the empty value for httpservice.context as you
>     did it originally will do,
>
>
> I will retest, but I think it throws an error that HttpServices is not
> found.
>
Sorry, I meant that an empty value can be used instead of introducing 
another property

>     but what I do not understand is this, what value does using DOSGi
>     (CXF) provide in the case where it does not create a 'link' between
>     the external HTTP world and a given object ?
>
> It's the same case than when you don't declare
>
> <entry key="org.apache.cxf.rs
> <http://org.apache.cxf.rs/>.httpservice.context" ..
>
> On other words don't use HTTP Service (ex from ServletBridge), but use
> Jetty as OSGi bundle.
> My idea is to develop application CXF DOSGi with Eclipse by using the
> OSGi Jetty bundle (OSGi launch) (without httpservice) for dev mode
> and create a WAR from this application CXF DOSGi (use httpservice) for
> the production mode.
>
Sure, a good idea.

Using org.apache.cxf.rs.address property does allow to use the OSGI 
Jetty bundle directly instead of HTTPService, right ? And as you have 
confirmed, replacing the property name and value to get Jetty used 
directly works. Perhaps I'm still not following...

Cheers, Sergey

> Regards Angelo
>
>     Sorry may be I'm missing something :-)
>
>     Cheers, Sergey
>
>         Regards Angelo
>
>         2012/6/11 Sergey Beryozkin <sberyozkin@gmail.com
>         <ma...@gmail.com>
>         <mailto:sberyozkin@gmail.com <ma...@gmail.com>>>
>
>
>             Hi Angelo
>
>             On 08/06/12 09:06, Angelo zerr wrote:
>
>                 Hi CXF Team,
>
>                 I'm writing article about DOSGi + ServletBridge to
>         create a WAR
>                 with DOSGi
>                 bundles+JAX-RS Services and deploy it with Web Server which
>                 doesn't support
>                 OSGi.
>                 To manage that I use the "org.apache.cxf.rs
>         <http://org.apache.cxf.rs>
>         <http://org.apache.cxf.rs>.____httpservice.context" property
>
>                 to register the servlet with HttpServices which works with
>                 ServletBridge
>                 well :
>
>
>           ------------------------------____----------------------------__--__--------------------------__----__------------------------__------__---
>         <entry key="org.apache.cxf.rs <http://org.apache.cxf.rs>
>         <http://org.apache.cxf.rs>.____httpservice.context"
>                 value="/UserService" />
>
>           ------------------------------____----------------------------__--__--------------------------__----__------------------------__------__---
>
>
>                 But I would like manage with the same bundle the 2
>         configuration
>                 (only OSGi
>                 container with OSGi Jetty, and ServletBridge)
>                 To manage that I thought create an OSGi frgament which
>         populate
>                 the value
>                 of org.apache.cxf.rs.httpservice.____context
>
>
>           ------------------------------____----------------------------__--__--------------------------__----__------------------------__------__---
>         <entry key="org.apache.cxf.rs <http://org.apache.cxf.rs>
>         <http://org.apache.cxf.rs>.____httpservice.context"
>                 value="${context}" />
>
>           ------------------------------____----------------------------__--__--------------------------__----__------------------------__------__---
>
>
>                 For "ServletBridge" the fragment contains the property
>
>
>           ------------------------------____----------------------------__--__--------------------------__----__------------------------__------__---
>                 context=/UserService
>
>           ------------------------------____----------------------------__--__--------------------------__----__------------------------__------__---
>
>
>                 For " OSGi container with OSGi Jetty" the fragment
>         contains the
>                 property
>
>
>           ------------------------------____----------------------------__--__--------------------------__----__------------------------__------__---
>                 context=
>
>           ------------------------------____----------------------------__--__--------------------------__----__------------------------__------__---
>
>
>                 And I thought DOSGi will not register teh service with
>                 HttpServices, but it
>                 doesn't work.
>                 Have you an idea how to manage the 2 configuration (with
>         and without
>                 HttpServices) with the same declaration of teh service?
>
>             I think you should parameterize the property name too, example:
>
>         <entry key="${name}" value="${value}" />
>
>             with
>
>         'org.apache.cxf.rs <http://org.apache.cxf.rs>
>         <http://org.apache.cxf.rs>.____httpservice.context'
>
>             and "/UserService" used in one case and
>         'org.apache.cxf.rs.address'
>             and "http://host:port/context" used in the other case
>
>             Cheers, Sergey
>
>
>                 Many thanks for your help.
>
>                 Regards Angelo
>
>
>
>             --
>             Sergey Beryozkin
>
>             Talend Community Coders
>         http://coders.talend.com/
>
>             Blog: http://sberyozkin.blogspot.com
>
>
>
>
>

Re: How to manage optionnal HttpServices with DOSGi with "org.apache.cxf.rs.httpservice.context" property?

Posted by Angelo zerr <an...@gmail.com>.
2012/6/18 Sergey Beryozkin <sb...@gmail.com>

> Hi Angelo
>
> On 18/06/12 08:36, Angelo zerr wrote:
>
>> Hi Sergey,
>>
>> Many thank's for your suggestion, it works great. I have explained how
>> to create a WAR for a DOSGi Application with ServletBridget by using
>> Libra/WARProduct in the article
>> http://angelozerr.wordpress.**com/2012/06/18/eclipse_spring_**
>> dosgi_step4/<http://angelozerr.wordpress.com/2012/06/18/eclipse_spring_dosgi_step4/>and
>> it explains your idea with ${name} to manage httpservices or not.
>>
>> But I think it's just a little complicated and if we have a property
>> like this :
>>
>> ------------------------------**__----------------------------**
>> --__--------------------------**----__------------------------**
>> ------__---
>> <entry key="org.apache.cxf.rs
>> <http://org.apache.cxf.rs/>.__**httpservice.ignore-if--not-**available"
>> value="true" />
>> ------------------------------**__----------------------------**
>> --__--------------------------**----__------------------------**
>> ------__---
>>
>>
>>
>> which doesn't use HtppService if it doesn't find it. It should be more
>> easy.
>>
>> What do you think about that?
>>
>>  I think even having the empty value for httpservice.context as you did
> it originally will do,


I will retest, but I think it throws an error that HttpServices is not
found.


> but what I do not understand is this, what value does using DOSGi (CXF)
> provide in the case where it does not create a 'link' between the external
> HTTP world and a given object ?
>
It's the same case than when you don't declare

<entry key="org.apache.cxf.rs.httpservice.context" ..

On other words don't use HTTP Service (ex from ServletBridge), but use
Jetty as OSGi bundle.
My idea is to develop application CXF DOSGi with Eclipse by using the OSGi
Jetty bundle (OSGi launch) (without httpservice) for dev mode
and create a WAR from this application CXF DOSGi (use httpservice) for the
production mode.

Regards Angelo

> Sorry may be I'm missing something :-)
>
> Cheers, Sergey
>
>  Regards Angelo
>>
>> 2012/6/11 Sergey Beryozkin <sberyozkin@gmail.com
>> <ma...@gmail.com>>
>>
>>
>>    Hi Angelo
>>
>>    On 08/06/12 09:06, Angelo zerr wrote:
>>
>>        Hi CXF Team,
>>
>>        I'm writing article about DOSGi + ServletBridge to create a WAR
>>        with DOSGi
>>        bundles+JAX-RS Services and deploy it with Web Server which
>>        doesn't support
>>        OSGi.
>>        To manage that I use the "org.apache.cxf.rs
>>        <http://org.apache.cxf.rs>.__**httpservice.context" property
>>
>>        to register the servlet with HttpServices which works with
>>        ServletBridge
>>        well :
>>
>>        ------------------------------**__----------------------------**
>> --__--------------------------**----__------------------------**
>> ------__---
>>        <entry key="org.apache.cxf.rs
>>        <http://org.apache.cxf.rs>.__**httpservice.context"
>>        value="/UserService" />
>>        ------------------------------**__----------------------------**
>> --__--------------------------**----__------------------------**
>> ------__---
>>
>>
>>        But I would like manage with the same bundle the 2 configuration
>>        (only OSGi
>>        container with OSGi Jetty, and ServletBridge)
>>        To manage that I thought create an OSGi frgament which populate
>>        the value
>>        of org.apache.cxf.rs.httpservice.**__context
>>
>>        ------------------------------**__----------------------------**
>> --__--------------------------**----__------------------------**
>> ------__---
>>        <entry key="org.apache.cxf.rs
>>        <http://org.apache.cxf.rs>.__**httpservice.context"
>>        value="${context}" />
>>        ------------------------------**__----------------------------**
>> --__--------------------------**----__------------------------**
>> ------__---
>>
>>
>>        For "ServletBridge" the fragment contains the property
>>
>>        ------------------------------**__----------------------------**
>> --__--------------------------**----__------------------------**
>> ------__---
>>        context=/UserService
>>        ------------------------------**__----------------------------**
>> --__--------------------------**----__------------------------**
>> ------__---
>>
>>
>>        For " OSGi container with OSGi Jetty" the fragment contains the
>>        property
>>
>>        ------------------------------**__----------------------------**
>> --__--------------------------**----__------------------------**
>> ------__---
>>        context=
>>        ------------------------------**__----------------------------**
>> --__--------------------------**----__------------------------**
>> ------__---
>>
>>
>>        And I thought DOSGi will not register teh service with
>>        HttpServices, but it
>>        doesn't work.
>>        Have you an idea how to manage the 2 configuration (with and
>> without
>>        HttpServices) with the same declaration of teh service?
>>
>>    I think you should parameterize the property name too, example:
>>
>>    <entry key="${name}" value="${value}" />
>>
>>    with
>>
>>    'org.apache.cxf.rs <http://org.apache.cxf.rs>.__**httpservice.context'
>>
>>    and "/UserService" used in one case and 'org.apache.cxf.rs.address'
>>    and "http://host:port/context" used in the other case
>>
>>    Cheers, Sergey
>>
>>
>>        Many thanks for your help.
>>
>>        Regards Angelo
>>
>>
>>
>>    --
>>    Sergey Beryozkin
>>
>>    Talend Community Coders
>>    http://coders.talend.com/
>>
>>    Blog: http://sberyozkin.blogspot.com
>>
>>
>>
>
>

Re: How to manage optionnal HttpServices with DOSGi with "org.apache.cxf.rs.httpservice.context" property?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Angelo
On 18/06/12 08:36, Angelo zerr wrote:
> Hi Sergey,
>
> Many thank's for your suggestion, it works great. I have explained how
> to create a WAR for a DOSGi Application with ServletBridget by using
> Libra/WARProduct in the article
> http://angelozerr.wordpress.com/2012/06/18/eclipse_spring_dosgi_step4/ and
> it explains your idea with ${name} to manage httpservices or not.
>
> But I think it's just a little complicated and if we have a property
> like this :
>
> ------------------------------__------------------------------__------------------------------__------------------------------__---
> <entry key="org.apache.cxf.rs
> <http://org.apache.cxf.rs/>.__httpservice.ignore-if--not-available"
> value="true" />
> ------------------------------__------------------------------__------------------------------__------------------------------__---
>
>
> which doesn't use HtppService if it doesn't find it. It should be more easy.
>
> What do you think about that?
>
I think even having the empty value for httpservice.context as you did 
it originally will do, but what I do not understand is this, what value 
does using DOSGi (CXF) provide in the case where it does not create a 
'link' between the external HTTP world and a given object ?
Sorry may be I'm missing something :-)

Cheers, Sergey

> Regards Angelo
>
> 2012/6/11 Sergey Beryozkin <sberyozkin@gmail.com
> <ma...@gmail.com>>
>
>     Hi Angelo
>
>     On 08/06/12 09:06, Angelo zerr wrote:
>
>         Hi CXF Team,
>
>         I'm writing article about DOSGi + ServletBridge to create a WAR
>         with DOSGi
>         bundles+JAX-RS Services and deploy it with Web Server which
>         doesn't support
>         OSGi.
>         To manage that I use the "org.apache.cxf.rs
>         <http://org.apache.cxf.rs>.__httpservice.context" property
>         to register the servlet with HttpServices which works with
>         ServletBridge
>         well :
>
>         ------------------------------__------------------------------__------------------------------__------------------------------__---
>         <entry key="org.apache.cxf.rs
>         <http://org.apache.cxf.rs>.__httpservice.context"
>         value="/UserService" />
>         ------------------------------__------------------------------__------------------------------__------------------------------__---
>
>         But I would like manage with the same bundle the 2 configuration
>         (only OSGi
>         container with OSGi Jetty, and ServletBridge)
>         To manage that I thought create an OSGi frgament which populate
>         the value
>         of org.apache.cxf.rs.httpservice.__context
>
>         ------------------------------__------------------------------__------------------------------__------------------------------__---
>         <entry key="org.apache.cxf.rs
>         <http://org.apache.cxf.rs>.__httpservice.context"
>         value="${context}" />
>         ------------------------------__------------------------------__------------------------------__------------------------------__---
>
>         For "ServletBridge" the fragment contains the property
>
>         ------------------------------__------------------------------__------------------------------__------------------------------__---
>         context=/UserService
>         ------------------------------__------------------------------__------------------------------__------------------------------__---
>
>         For " OSGi container with OSGi Jetty" the fragment contains the
>         property
>
>         ------------------------------__------------------------------__------------------------------__------------------------------__---
>         context=
>         ------------------------------__------------------------------__------------------------------__------------------------------__---
>
>         And I thought DOSGi will not register teh service with
>         HttpServices, but it
>         doesn't work.
>         Have you an idea how to manage the 2 configuration (with and without
>         HttpServices) with the same declaration of teh service?
>
>     I think you should parameterize the property name too, example:
>
>     <entry key="${name}" value="${value}" />
>
>     with
>
>     'org.apache.cxf.rs <http://org.apache.cxf.rs>.__httpservice.context'
>     and "/UserService" used in one case and 'org.apache.cxf.rs.address'
>     and "http://host:port/context" used in the other case
>
>     Cheers, Sergey
>
>
>         Many thanks for your help.
>
>         Regards Angelo
>
>
>
>     --
>     Sergey Beryozkin
>
>     Talend Community Coders
>     http://coders.talend.com/
>
>     Blog: http://sberyozkin.blogspot.com
>
>



Re: How to manage optionnal HttpServices with DOSGi with "org.apache.cxf.rs.httpservice.context" property?

Posted by Angelo zerr <an...@gmail.com>.
Hi Sergey,

Many thank's for your suggestion, it works great. I have explained how to
create a WAR for a DOSGi Application with ServletBridget by using
Libra/WARProduct in the article
http://angelozerr.wordpress.com/2012/06/18/eclipse_spring_dosgi_step4/ and
it explains your idea with ${name} to manage httpservices or not.

But I think it's just a little complicated and if we have a property like
this :

------------------------------**------------------------------**
------------------------------**------------------------------**---
<entry key="org.apache.cxf.rs.**httpservice.ignore-if--not-available"
value="true" />
------------------------------**------------------------------**
------------------------------**------------------------------**---

which doesn't use HtppService if it doesn't find it. It should be more easy.

What do you think about that?

Regards Angelo

2012/6/11 Sergey Beryozkin <sb...@gmail.com>

> Hi Angelo
>
> On 08/06/12 09:06, Angelo zerr wrote:
>
>> Hi CXF Team,
>>
>> I'm writing article about DOSGi + ServletBridge to create a WAR with DOSGi
>> bundles+JAX-RS Services and deploy it with Web Server which doesn't
>> support
>> OSGi.
>> To manage that I use the "org.apache.cxf.rs.**httpservice.context"
>> property
>> to register the servlet with HttpServices which works with ServletBridge
>> well :
>>
>> ------------------------------**------------------------------**
>> ------------------------------**------------------------------**---
>> <entry key="org.apache.cxf.rs.**httpservice.context"
>> value="/UserService" />
>> ------------------------------**------------------------------**
>> ------------------------------**------------------------------**---
>>
>> But I would like manage with the same bundle the 2 configuration (only
>> OSGi
>> container with OSGi Jetty, and ServletBridge)
>> To manage that I thought create an OSGi frgament which populate the value
>> of org.apache.cxf.rs.httpservice.**context
>>
>> ------------------------------**------------------------------**
>> ------------------------------**------------------------------**---
>> <entry key="org.apache.cxf.rs.**httpservice.context" value="${context}"
>> />
>> ------------------------------**------------------------------**
>> ------------------------------**------------------------------**---
>>
>> For "ServletBridge" the fragment contains the property
>>
>> ------------------------------**------------------------------**
>> ------------------------------**------------------------------**---
>> context=/UserService
>> ------------------------------**------------------------------**
>> ------------------------------**------------------------------**---
>>
>> For " OSGi container with OSGi Jetty" the fragment contains the property
>>
>> ------------------------------**------------------------------**
>> ------------------------------**------------------------------**---
>> context=
>> ------------------------------**------------------------------**
>> ------------------------------**------------------------------**---
>>
>> And I thought DOSGi will not register teh service with HttpServices, but
>> it
>> doesn't work.
>> Have you an idea how to manage the 2 configuration (with and without
>> HttpServices) with the same declaration of teh service?
>>
>>  I think you should parameterize the property name too, example:
>
> <entry key="${name}" value="${value}" />
>
> with
>
> 'org.apache.cxf.rs.**httpservice.context' and "/UserService" used in one
> case and 'org.apache.cxf.rs.address' and "http://host:port/context" used
> in the other case
>
> Cheers, Sergey
>
>
>  Many thanks for your help.
>>
>> Regards Angelo
>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>

Re: How to manage optionnal HttpServices with DOSGi with "org.apache.cxf.rs.httpservice.context" property?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Angelo
On 08/06/12 09:06, Angelo zerr wrote:
> Hi CXF Team,
>
> I'm writing article about DOSGi + ServletBridge to create a WAR with DOSGi
> bundles+JAX-RS Services and deploy it with Web Server which doesn't support
> OSGi.
> To manage that I use the "org.apache.cxf.rs.httpservice.context" property
> to register the servlet with HttpServices which works with ServletBridge
> well :
>
> ---------------------------------------------------------------------------------------------------------------------------
> <entry key="org.apache.cxf.rs.httpservice.context" value="/UserService" />
> ---------------------------------------------------------------------------------------------------------------------------
>
> But I would like manage with the same bundle the 2 configuration (only OSGi
> container with OSGi Jetty, and ServletBridge)
> To manage that I thought create an OSGi frgament which populate the value
> of org.apache.cxf.rs.httpservice.context
>
> ---------------------------------------------------------------------------------------------------------------------------
> <entry key="org.apache.cxf.rs.httpservice.context" value="${context}" />
> ---------------------------------------------------------------------------------------------------------------------------
>
> For "ServletBridge" the fragment contains the property
>
> ---------------------------------------------------------------------------------------------------------------------------
> context=/UserService
> ---------------------------------------------------------------------------------------------------------------------------
>
> For " OSGi container with OSGi Jetty" the fragment contains the property
>
> ---------------------------------------------------------------------------------------------------------------------------
> context=
> ---------------------------------------------------------------------------------------------------------------------------
>
> And I thought DOSGi will not register teh service with HttpServices, but it
> doesn't work.
> Have you an idea how to manage the 2 configuration (with and without
> HttpServices) with the same declaration of teh service?
>
I think you should parameterize the property name too, example:

<entry key="${name}" value="${value}" />

with

'org.apache.cxf.rs.httpservice.context' and "/UserService" used in one 
case and 'org.apache.cxf.rs.address' and "http://host:port/context" used 
in the other case

Cheers, Sergey

> Many thanks for your help.
>
> Regards Angelo
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com