You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Glen Mazza <gl...@verizon.net> on 2007/11/15 07:47:15 UTC

Adding interceptors to an SEI implementation class

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



Re: Adding interceptors to an SEI implementation class

Posted by James Mao <ja...@iona.com>.
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
>>>
>>>
>>>   
>>>       
>
>   

Re: Adding interceptors to an SEI implementation class

Posted by Glen Mazza <gl...@verizon.net>.
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:

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
> >
> >
> >   


Re: Adding interceptors to an SEI implementation class

Posted by James Mao <ja...@iona.com>.
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
>
>
>   

Re: Adding interceptors to an SEI implementation class

Posted by Glen Mazza <gl...@verizon.net>.
Thanks--I confirmed what you wrote and updated the Wiki to incorporate
this.

Glen

Am Donnerstag, den 15.11.2007, 13:24 -0500 schrieb Daniel Kulp:
> Glenn,
> 
> Spring config is definitely an option.   
> 
> For the logging intereptors (or other that have a default constructor and 
> no other configuration needed), you can use interceptors on the SEI 
> interface (or impl).
> 
> @Features(features = "org.apache.cxf.feature.LoggingFeature")
> 
> or 
> 
> @InInterceptors(interceptors 
> = "org.apache.cxf.interceptor.LoggingInInterceptor")
> 
> 
> 
> 
> Dan
> 
> 
> On Thursday 15 November 2007, Glen Mazza wrote:
> > 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
> 
> 
> 


Re: Adding interceptors to an SEI implementation class

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

Spring config is definitely an option.   

For the logging intereptors (or other that have a default constructor and 
no other configuration needed), you can use interceptors on the SEI 
interface (or impl).

@Features(features = "org.apache.cxf.feature.LoggingFeature")

or 

@InInterceptors(interceptors 
= "org.apache.cxf.interceptor.LoggingInInterceptor")




Dan


On Thursday 15 November 2007, Glen Mazza wrote:
> 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



-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog