`

CXF Logging Interceptor的使用

 
阅读更多

 

    1.代码方式

       

public final class Server {

    public static void main(String args[]) throws Exception {
		CourseBuilderImpl implementor = new CourseBuilderImpl();
		JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
		svrFactory.setAddress("http://localhost:9000/CourseBuilder");
		svrFactory.setServiceBean(implementor);
		svrFactory.getInInterceptors().add(new LoggingInInterceptor());
		svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
		svrFactory.create();
    }
}

 

    2.注解方式

    

@WebService
@InInterceptors(interceptors = "org.apache.cxf.interceptor.LoggingInInterceptor")
@OutInterceptors(interceptors = "org.apache.cxf.interceptor.LoggingOutInterceptor")
public class CourseBuilderImpl implements CourseBuilder {
...

     3.Spring集成方式

    

<beans>
...
	<bean id="logIn" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
	<bean id="logOut" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>

	<jaxws:endpoint 
	  id="courseBuilder" 
	  implementor="demo.cxf.logging.CourseBuilderImpl" 
	  address="/CourseBuilder" >
	  
		<jaxws:inInterceptors>
			<ref bean="logIn"/>
		</jaxws:inInterceptors>
		<jaxws:outInterceptors>
			<ref bean="logOut"/>
		</jaxws:outInterceptors>
		
	</jaxws:endpoint>
</beans>

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics