You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Conficio <Ka...@Conficio.com> on 2011/07/25 19:59:57 UTC

Re: separate CXFServlet for private API's

Dan,
just wondering if you like my example or if there is anything else I could
provide?

Is there any idea of an alternative (like starting some service per
CXFServlet and others per Java class?

Kaj
Still hoping to make multiple CXFServlet configs work.

--
View this message in context: http://cxf.547215.n5.nabble.com/separate-CXFServlet-for-private-API-s-tp3261355p4631755.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: separate CXFServlet for private API's (solution?)

Posted by Conficio <Ka...@Conficio.com>.
Thanks Dan,
2.4.1 does seem to improve things a lot.

I got it working as you hint on and did not need to subclass CXFServlet.

Here is web.xml
{code}
<web-app>
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>WEB-INF/globalContext.xml</param-value>
	</context-param>
 	<listener>
		<listener-class>
			org.springframework.web.context.ContextLoaderListener
		</listener-class>
	</listener>

	<servlet>
		<servlet-name>PublicCXFServlet</servlet-name>
		<display-name>Public CXF Servlet</display-name>
		<servlet-class>
			org.apache.cxf.transport.servlet.CXFServlet
		</servlet-class>
		<init-param>
      		<param-name>config-location</param-name>
      		<param-value>/WEB-INF/beans-public.xml</param-value>    
    	</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>PublicCXFServlet</servlet-name>
		<url-pattern>/public/*</url-pattern>
	</servlet-mapping>

	<servlet>
		<servlet-name>PrivateCXFServlet</servlet-name>
		<display-name>Private CXF Servlet</display-name>
		<servlet-class>
			org.apache.cxf.transport.servlet.CXFServlet
		</servlet-class>
		<init-param>
      		<param-name>config-location</param-name>
      		<param-value>/WEB-INF/beans-private.xml</param-value>    
    	</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>PrivateCXFServlet</servlet-name>
		<url-pattern>/private/*</url-pattern>
	</servlet-mapping>
</web-app>
{/code}
and here my public beans as an example
{code}
	<import resource="classpath:META-INF/cxf/cxf.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
	<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

	<cxf:bus name="public"/>
	
	<jaxws:endpoint 
	  id="helloWorld" 
	  implementor="demo.spring.HelloWorldImpl" 
	  address="/HelloWorld" />
{/code}
I even found that it appears the <cxf:bus .../> clause is optional. It
appears to be working (in the sample derived from java-first-spring) with
all services being on the default bus "cxf". Is there any advantage to
separate the busses?

K<o>
P.S.: Would you like me to submit my example for inclusion in the CXF
samples?

--
View this message in context: http://cxf.547215.n5.nabble.com/separate-CXFServlet-for-private-API-s-tp3261355p4634799.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: separate CXFServlet for private API's

Posted by Conficio <Ka...@Conficio.com>.
I created https://issues.apache.org/jira/browse/CXF-3688 for the missing
jetty-* jars

--
View this message in context: http://cxf.547215.n5.nabble.com/separate-CXFServlet-for-private-API-s-tp3261355p4634493.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: separate CXFServlet for private API's

Posted by Conficio <Ka...@Conficio.com>.
Also missing jetty-xml

--
View this message in context: http://cxf.547215.n5.nabble.com/separate-CXFServlet-for-private-API-s-tp3261355p4633400.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: separate CXFServlet for private API's

Posted by Conficio <Ka...@Conficio.com>.
Dan, 
o.k. I'll give that a try.
In order to get the java first with spring samples to run (in Eclipse and
not through maven), the jetty-webapp and jetty-servlet jars are missing in
the lib folder (2.4.1)

K<o>

--
View this message in context: http://cxf.547215.n5.nabble.com/separate-CXFServlet-for-private-API-s-tp3261355p4633380.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: separate CXFServlet for private API's

Posted by Daniel Kulp <dk...@apache.org>.

With 2.4.1, this may be easier to achieve than before, but it's not quite 
there.

With 2.4.x, support for multiple bus's has been greatly enhanced.  Thus, with 
a little work, you may be able to have  a context with 2 bus objects, one for 
the secure and one for the insecure.   Then have a servlet work for each.

<cxf:bus name="secure"/>
<cxf:bus name="insecure"/>


<jaxws:endpoint bus="secure" address="/secure/MyService" ..../>
<jaxws:endpoint bus="insecure" address="/insecure/MyService" ..../>
.....

Looking at the code, you would need a subclass of CXFServlet that would 
override the 
    protected void loadBus(ServletConfig sc);

method to look at a servlet init-param to have it lookup the appropriate 
spring bean.      Actually, if you want to post a patch, a patch to CXFServlet 
that would allow configuring the bus id to use would be great (and likely 
pretty easy)

Let me know how that works for you.


Dan




On Monday, July 25, 2011 10:59:57 AM Conficio wrote:
> Dan,
> just wondering if you like my example or if there is anything else I could
> provide?
> 
> Is there any idea of an alternative (like starting some service per
> CXFServlet and others per Java class?
> 
> Kaj
> Still hoping to make multiple CXFServlet configs work.
> 
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/separate-CXFServlet-for-private-API-s-tp326
> 1355p4631755.html Sent from the cxf-user mailing list archive at Nabble.com.
-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com