You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by "m.mcinness1" <m....@gmail.com> on 2013/06/04 19:00:20 UTC

Jetty and multiple jaxrs servers

I'm using Karaf 2.2.4 with Servicemix 4.4.2. In configuring jaxrs with
blueprint, I am finding it convenient to define multiple servers as jetty
endpoints, with each jaxrs server listening on a different port (please see
below)

Is there anything wrong or bad or misguided about this configuration or
deploying multiple bundles with multiple jetty/jaxrs resources in Karaf? I
guess I'm fishing for advice on best practices.

Thanks for any insight or guidance. 

Bundle A, blueprint excerpt:

<jaxrs:server id="abc" address="https://0.0.0.0:18001">
    <jaxrs:serviceBeans>
        <bean class="com.something.resources.Resource" />
    </jaxrs:serviceBeans>
    <jaxrs:inInterceptors>
        <ref component-id="securityInterceptor"/>
    </jaxrs:inInterceptors>
</jaxrs:server>

<jaxrs:server id="xzy" address="http://0.0.0.0:18002">
    <jaxrs:serviceBeans>
        <bean class="com.something.resources.Resource" />
    </jaxrs:serviceBeans>
</jaxrs:server>

Bundle B, bluepring exerpt

<jaxrs:server id="123" address="http://0.0.0.0:18101">
    <jaxrs:serviceBeans>
        <bean class="com.something.resources.Resource" />
    </jaxrs:serviceBeans>
</jaxrs:server>





--
View this message in context: http://karaf.922171.n3.nabble.com/Jetty-and-multiple-jaxrs-servers-tp4028957.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Jetty and multiple jaxrs servers

Posted by "m.mcinness1" <m....@gmail.com>.
Thanks, Freeman.

After reading up a bit on configuring jetty in pax web, it looks like what I
need to employ for granular, IP-based restrictions is a jetty IP Access
Handler. Everything else I need seems routine.

I appreciate your help.



--
View this message in context: http://karaf.922171.n3.nabble.com/Jetty-and-multiple-jaxrs-servers-tp4028957p4028979.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Jetty and multiple jaxrs servers

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

Yes, pax-web can provide this flexibility IMO.

You can configure pax-web to support SSL, even in another port.[1]

And the http basic auth configuration actually is endpoint|bundle specific, not much about the transport level. For example, for cxf endpoint you can configure a authenticationInterceptor(it could be org.apache.cxf.interceptor.security.JAASLoginInterceptor) which can delegate the authentication to Karaf JAAS if this cxf endpoint need http basic auth, we have an example in SMX code base, you may wanna take a look.[2]

[1]https://ops4j1.jira.com/wiki/display/paxweb/SSL+Configuration
[2]https://svn.apache.org/repos/asf/servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-osgi/
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: @Freeman小屋

www.camelone.org : The open source integration conference: 

On 2013-6-5, at 上午11:49, m.mcinness1 wrote:

> Thanks for the replies.
> 
> Freeman, my use case is to interface with a number of third-party vendors,
> each having unique requirements and accessing very different applications.
> For example, one may require that the endpoint be restricted to ssl, another
> may require basic auth, and third might support neither. The services have
> no relationship to each other. In essence they are all private and custom to
> the third parties.
> 
> I've read a couple posts regarding proxying via camel and modifying
> jetty.xml with pax web, but it's not clear whether either of these would be
> a better choice for my situation than stand alone jetty and multiple ports.
> We'll end up running 20 or so application bundles on one karaf instance.
> Does pax web offer the flexibility we need?
> 
> Thanks again!
> 
> 
> 
> 
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Jetty-and-multiple-jaxrs-servers-tp4028957p4028962.html
> Sent from the Karaf - User mailing list archive at Nabble.com.


Re: Jetty and multiple jaxrs servers

Posted by "m.mcinness1" <m....@gmail.com>.
Thanks for the replies.

Freeman, my use case is to interface with a number of third-party vendors,
each having unique requirements and accessing very different applications.
For example, one may require that the endpoint be restricted to ssl, another
may require basic auth, and third might support neither. The services have
no relationship to each other. In essence they are all private and custom to
the third parties.

I've read a couple posts regarding proxying via camel and modifying
jetty.xml with pax web, but it's not clear whether either of these would be
a better choice for my situation than stand alone jetty and multiple ports.
We'll end up running 20 or so application bundles on one karaf instance.
Does pax web offer the flexibility we need?

Thanks again!




--
View this message in context: http://karaf.922171.n3.nabble.com/Jetty-and-multiple-jaxrs-servers-tp4028957p4028962.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Jetty and multiple jaxrs servers

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

Though use standalone http-jetty transport would work, in OSGi container we suggest to use http-osgi transport(which is use osgi http service provided by pax-web), one port configuration is easier for you to manage(like the firewall configuration, etc). Think about you deploy multiple wars into a tomcat container, every user only expect one well known listening port, right?
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: @Freeman小屋

www.camelone.org : The open source integration conference: 

On 2013-6-5, at 上午1:00, m.mcinness1 wrote:

> I'm using Karaf 2.2.4 with Servicemix 4.4.2. In configuring jaxrs with
> blueprint, I am finding it convenient to define multiple servers as jetty
> endpoints, with each jaxrs server listening on a different port (please see
> below)
> 
> Is there anything wrong or bad or misguided about this configuration or
> deploying multiple bundles with multiple jetty/jaxrs resources in Karaf? I
> guess I'm fishing for advice on best practices.
> 
> Thanks for any insight or guidance. 
> 
> Bundle A, blueprint excerpt:
> 
> <jaxrs:server id="abc" address="https://0.0.0.0:18001">
>    <jaxrs:serviceBeans>
>        <bean class="com.something.resources.Resource" />
>    </jaxrs:serviceBeans>
>    <jaxrs:inInterceptors>
>        <ref component-id="securityInterceptor"/>
>    </jaxrs:inInterceptors>
> </jaxrs:server>
> 
> <jaxrs:server id="xzy" address="http://0.0.0.0:18002">
>    <jaxrs:serviceBeans>
>        <bean class="com.something.resources.Resource" />
>    </jaxrs:serviceBeans>
> </jaxrs:server>
> 
> Bundle B, bluepring exerpt
> 
> <jaxrs:server id="123" address="http://0.0.0.0:18101">
>    <jaxrs:serviceBeans>
>        <bean class="com.something.resources.Resource" />
>    </jaxrs:serviceBeans>
> </jaxrs:server>
> 
> 
> 
> 
> 
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Jetty-and-multiple-jaxrs-servers-tp4028957.html
> Sent from the Karaf - User mailing list archive at Nabble.com.


Re: Jetty and multiple jaxrs servers

Posted by Achim Nierbeck <bc...@googlemail.com>.
Your proposed way sounds pretty good, it's also possible to bind your
web-services to the Karaf contained Pax-Web container, but I'm not sure if
it already supports to bind every endpoint to a different connector.
So I think you're on a safe road there.

regards, Achim


2013/6/4 m.mcinness1 <m....@gmail.com>

> I'm using Karaf 2.2.4 with Servicemix 4.4.2. In configuring jaxrs with
> blueprint, I am finding it convenient to define multiple servers as jetty
> endpoints, with each jaxrs server listening on a different port (please see
> below)
>
> Is there anything wrong or bad or misguided about this configuration or
> deploying multiple bundles with multiple jetty/jaxrs resources in Karaf? I
> guess I'm fishing for advice on best practices.
>
> Thanks for any insight or guidance.
>
> Bundle A, blueprint excerpt:
>
> <jaxrs:server id="abc" address="https://0.0.0.0:18001">
>     <jaxrs:serviceBeans>
>         <bean class="com.something.resources.Resource" />
>     </jaxrs:serviceBeans>
>     <jaxrs:inInterceptors>
>         <ref component-id="securityInterceptor"/>
>     </jaxrs:inInterceptors>
> </jaxrs:server>
>
> <jaxrs:server id="xzy" address="http://0.0.0.0:18002">
>     <jaxrs:serviceBeans>
>         <bean class="com.something.resources.Resource" />
>     </jaxrs:serviceBeans>
> </jaxrs:server>
>
> Bundle B, bluepring exerpt
>
> <jaxrs:server id="123" address="http://0.0.0.0:18101">
>     <jaxrs:serviceBeans>
>         <bean class="com.something.resources.Resource" />
>     </jaxrs:serviceBeans>
> </jaxrs:server>
>
>
>
>
>
> --
> View this message in context:
> http://karaf.922171.n3.nabble.com/Jetty-and-multiple-jaxrs-servers-tp4028957.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>



-- 

Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
OPS4J Pax for Vaadin <http://team.ops4j.org/wiki/display/PAXVAADIN/Home>
Commiter & Project Lead
blog <http://notizblog.nierbeck.de/>