cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "xuhb" <x...@tongtech.com>
Subject Re: What's the usage of MultipleEndpointObserver
Date Wed, 28 Dec 2011 14:05:24 GMT
Thanks Freeman:

It's great, thank you very much;

----- Original Message ----- 
From: "Freeman Fang" <freeman.fang@gmail.com>
To: <dev@cxf.apache.org>
Sent: Wednesday, December 28, 2011 6:14 PM
Subject: Re: What's the usage of MultipleEndpointObserver


Hi,

Yes.

IIRC,  for server side you need write a routingInterceptor to dispatch  
message to different endpoint.
When multiple endpoints publish to same address, those endpoints will  
share same MultipleEndpointObserver, by default, the  
MultipleEndpointObserver will use EndpointSelectionInterceptor to  
select on the proper endpoint based on soap version, this is a typical  
usecase which different endpoints(use soap11 or soap12) get published  
to same uri.
You can replace this routingInterceptor for your purpose, we actually  
have a testcase[1] which demonstrate how it works, the  
routingInterceptor used in this tesecase is[2]
The key code to publish different endpoints on same address and  
register a  MultipleEndpointObserver which use the routingInterceptor  
you want is

         String address = "http://localhost:" + PORT + "/SoapContext/ 
SoapPort";

         Object implementor1 = new GreeterImplMixedStyle(" version1");
         EndpointImpl ep1 = (EndpointImpl) Endpoint.publish(address,  
implementor1);

         ep1.getServer().getEndpoint().put("version", "1");
         ep1.getServer().getEndpoint().put("allow-multiplex-endpoint",  
Boolean.TRUE);

         //Register a MediatorInInterceptor on this dummy service

         Object implementor2 = new GreeterImplMixedStyle(" version2");
         EndpointImpl ep2 = (EndpointImpl) Endpoint.publish(address,  
implementor2);
         ep2.getServer().getEndpoint().put("version", "2");

         MultipleEndpointObserver meo = (MultipleEndpointObserver)
             ep1.getServer().getDestination().getMessageObserver();
         meo.getRoutingInterceptors().clear();
         meo.getRoutingInterceptors().add(new MediatorInInterceptor());


[1]https://svn.apache.org/repos/asf/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/versioning/ClientServerVersioningTest.java
[2]https://svn.apache.org/repos/asf/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/versioning/MediatorInInterceptor.java

Freeman
On 2011-12-28, at 下午5:51, xuhb wrote:

> Hi:
>    Does anyone know when will  
> org.apache.cxf.transport.MultipleEndpointObserver be used?
>
>    Does it means CXF support a feature: publish multiple endpoint on  
> same address?
>
>    Thanks any suggestion.

---------------------------------------------
Freeman Fang

FuseSource
Email:ffang@fusesource.com
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com









Mime
View raw message