Hi Glen,

Thanks, James, I see how this was done in the class you gave[2], and
just updated our docs with a link to that sample.

Next question (for anyone to answer):  Not that someone would normally
program this way, but I would like to know if it can be done.  Using our
"logging messages"[1] example again on how one can programmatically add
interceptors to an endpoint:

import org.apache.cxf.jaxws.EndpointImpl;

Object implementor = new GreeterImpl();
EndpointImpl ep = (EndpointImpl) Endpoint.publish("http://localhost/service";, 
implementor);

ep.getServer().getEndpoint().getInInterceptors().add(new
LoggingInInterceptor());

Question: Given an EndpointImpl, can you access the *bus*, and add
interceptors to it (for use with all other subsequent endpoints), or do
anything else with the bus?  Something like:

You can,

ep.getServiceFactory().getBus()

James

ep.getServer().getBus().getInInterceptors().add(new
LoggingInInterceptor());

The answer seems to be "no", because this EndpointImpl[3] (unlike
org.apache.cxf.endpoint.EndpointImpl's[4]) (intentionally) does not have
a getBus() method--probably(?) because it is not really a safe design to
allow an endpoint to alter its parent bus in this manner.

Thanks,
Glen

[2] http://tinyurl.com/3docsl
[3]
http://incubator.apache.org/cxf/javadoc/latest/org/apache/cxf/jaxws/EndpointImpl.html
[4]
http://incubator.apache.org/cxf/javadoc/latest/org/apache/cxf/endpoint/EndpointImpl.html


Am Donnerstag, den 15.11.2007, 15:02 +0800 schrieb James Mao:
Yes, You can do that through the configuration,
Besides, You can also get the default bus from the BusFactory, and add the interceptors into the bus.
see

systests/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java


James


Team,

The code for adding interceptors to a web service is shown on this
page[1] as follows:

---------------------------------------------------

import javax.xml.ws.Endpoint;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.EndpointImpl;

EndpointImpl ep = (EndpointImpl)
Endpoint.publish("http://localhost/service";, service);

ep.getServer().getEndpoint().getInInterceptors().add(new
LoggingInInterceptor());
ep.getServer().getEndpoint().getOutInterceptors().add(new
LoggingOutInterceptor());

----------------------------------------------------

Question: If I am not creating a web service is this manner, but am
instead just implementing an SEI created from wsdl2java (to be wrapped
up in a servlet WAR file), then I *cannot* add interceptors
programmically as above--in this case, I would have to use configuration
files, correct?

Just want to clarify this point for the documentation.

Thanks,
Glen

[1] http://cwiki.apache.org/confluence/display/CXF20DOC/Debugging



Reply via email to