You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Dominique Jaeggi <dj...@adobe.com> on 2012/09/27 14:33:41 UTC

HttpComponents in the Context Of OSGI-based CMS

hi all

on of our products is an OSGi-based CMS, within which we're using the
venerable apache commons http-client 3.x since many years.

at that time we wrapped it as an OSGi bundle ourselves, in addition to
providing a bundle activator as well as patching the http client
source, all for the following purpose:

- on CMS shutdown, kill all open http-client connections in
  order to ensure proper and timely shutdown of the CMS. this
  was done by simply calling:

    MultiThreadedHttpConnectionManager.shutdownAll();

  in the bundle activator's stop() method.

- transparently provide a central proxy configuration for all
  http-client requests issued within the realm of the CMS (be
  it product code or e.g. user/client's template code. the
  configuration is OSGi based (in apache felix). a central
  proxy-selector injects any configured proxy through a patched
  org.apache.commons.httpclient.HostConfiguration class. this
  central proxy configuration is quite essential in e.g.
  enterprise deployments where outside internet access must
  flow through a proxy server.

we're now at the point where we'd like to upgrade to apache httpcomponents 4.x.

for that purpose we have experimented with version 4.2.1 of the httpcomponents:

- applied a similar patching approach for the central proxy
  configuration requirement

- we have not yet found a way to easily implement the shutdown
  requirement

seeing as httpcomponents 4.x are released as OSGi binaries as well, we
were wondering:

- would it be beneficial to have a bundle activator?
- do you agree that a central proxy configuration capability
  in the context of OSGi would benefit httpcomponents?
- do you have any hints or ideas how the shutdown feature could
  be implemented?

if you are so inclined, we'd be happy to contribute what we already
have, or to invest time for fixing/extending such contributions in the
context of above stipulated requirements. it would please us to see
such features in a future release of httpcomponents - so you deem them
fitting.

greetings
dom.

--
Adobe Research, Switzerland
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: HttpComponents in the Context Of OSGI-based CMS

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2012-09-28 at 13:17 +0100, Dominique Jaeggi wrote:
> hi
> 
> On Thu, Sep 27, 2012 at 4:42 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> > > - do you agree that a central proxy configuration capability
> > >   in the context of OSGi would benefit httpcomponents?
> >
> > I think so, as long as it is not specific to a particular OSGi container
> 
> it is not specific to a particular OSGi container.
> 
> >
> > > - do you have any hints or ideas how the shutdown feature could
> > >   be implemented?
> > >
> >
> > Connection manager shutdown should work exactly the same way in HC 4.x
> > as in HC 3.1. What kind of difficulties are you having with the new
> > API?
> 
> in HC 3.1 there was a static method
> 
>     MultiThreadedHttpConnectionManager.shutdownAll();
> 
> that would shutdown all open connections based on this concrete
> connection manager.
> 
> in HC 4 there doesn't seem to be a similar static method that would
> shutdown connections of multiple active clients. in order for the OSGi
> bundle to cleanly and timely shut down, the suggestion is to shut down
> all active client connections. how to get at those in HC 4?
> 

Oh. It has been so long since I touched HC 3.1 last time that I
completely forgot that static method existed. 

HC 4.x does not have any static data so it could be safely used in
managed environments without standing a risk of one application shutting
down connection managers that belong to another application or doing
something equally silly and destructive.

We could introduce something similar, a sort of tracking for all
connection managers (probably through weak references) but only when
running inside an OSGi container. 

> > We would happily accept such a contribution given that we have rather
> > limited resources to work on things that are not directly related to
> > HTTP.
> 
> i have created [0] for the contribution and attached an initial patch.
> it may require cleanup as you may have different ideas about in which
> package to put classes or in which pom to put dependencies. it also
> still contains a TODO in the activator class regarding above mentioned
> shutdown question. also, the activator would have to be put in the
> osgi bundle's metadata.
> 
> if you require more work in the context of the patch, i have the time
> and resources.
> 

Please see my comments in HTTPCLIENT-1238

Cheers

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: HttpComponents in the Context Of OSGI-based CMS

Posted by Dominique Jaeggi <dj...@adobe.com>.
hi

On Thu, Sep 27, 2012 at 4:42 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> > - do you agree that a central proxy configuration capability
> >   in the context of OSGi would benefit httpcomponents?
>
> I think so, as long as it is not specific to a particular OSGi container

it is not specific to a particular OSGi container.

>
> > - do you have any hints or ideas how the shutdown feature could
> >   be implemented?
> >
>
> Connection manager shutdown should work exactly the same way in HC 4.x
> as in HC 3.1. What kind of difficulties are you having with the new
> API?

in HC 3.1 there was a static method

    MultiThreadedHttpConnectionManager.shutdownAll();

that would shutdown all open connections based on this concrete
connection manager.

in HC 4 there doesn't seem to be a similar static method that would
shutdown connections of multiple active clients. in order for the OSGi
bundle to cleanly and timely shut down, the suggestion is to shut down
all active client connections. how to get at those in HC 4?

> We would happily accept such a contribution given that we have rather
> limited resources to work on things that are not directly related to
> HTTP.

i have created [0] for the contribution and attached an initial patch.
it may require cleanup as you may have different ideas about in which
package to put classes or in which pom to put dependencies. it also
still contains a TODO in the activator class regarding above mentioned
shutdown question. also, the activator would have to be put in the
osgi bundle's metadata.

if you require more work in the context of the patch, i have the time
and resources.

greetings
dom.

[0] https://issues.apache.org/jira/browse/HTTPCLIENT-1238

Re: HttpComponents in the Context Of OSGI-based CMS

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2012-09-27 at 13:33 +0100, Dominique Jaeggi wrote:
> hi all
> 

Hi Dominique

> on of our products is an OSGi-based CMS, within which we're using the
> venerable apache commons http-client 3.x since many years.
> 
> at that time we wrapped it as an OSGi bundle ourselves, in addition to
> providing a bundle activator as well as patching the http client
> source, all for the following purpose:
> 
> - on CMS shutdown, kill all open http-client connections in
>   order to ensure proper and timely shutdown of the CMS. this
>   was done by simply calling:
> 
>     MultiThreadedHttpConnectionManager.shutdownAll();
> 
>   in the bundle activator's stop() method.
> 
> - transparently provide a central proxy configuration for all
>   http-client requests issued within the realm of the CMS (be
>   it product code or e.g. user/client's template code. the
>   configuration is OSGi based (in apache felix). a central
>   proxy-selector injects any configured proxy through a patched
>   org.apache.commons.httpclient.HostConfiguration class. this
>   central proxy configuration is quite essential in e.g.
>   enterprise deployments where outside internet access must
>   flow through a proxy server.
> 
> we're now at the point where we'd like to upgrade to apache httpcomponents 4.x.
> 
> for that purpose we have experimented with version 4.2.1 of the httpcomponents:
> 
> - applied a similar patching approach for the central proxy
>   configuration requirement
> 
> - we have not yet found a way to easily implement the shutdown
>   requirement
> 
> seeing as httpcomponents 4.x are released as OSGi binaries as well, we
> were wondering:
> 
> - would it be beneficial to have a bundle activator?

I think so.

> - do you agree that a central proxy configuration capability
>   in the context of OSGi would benefit httpcomponents?

I think so, as long as it is not specific to a particular OSGi container

> - do you have any hints or ideas how the shutdown feature could
>   be implemented?
> 

Connection manager shutdown should work exactly the same way in HC 4.x
as in HC 3.1. What kind of difficulties are you having with the new
API? 

> if you are so inclined, we'd be happy to contribute what we already
> have, or to invest time for fixing/extending such contributions in the
> context of above stipulated requirements. it would please us to see
> such features in a future release of httpcomponents - so you deem them
> fitting.
> 

We would happily accept such a contribution given that we have rather
limited resources to work on things that are not directly related to
HTTP.

Cheers

Oleg 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org