You can mention in ApplicationContext.xml Dipesh
Sent from Samsung Mobile -------- Original message -------- From: behowar <[email protected]> Date: 18/10/2015 01:57 (GMT+05:30) To: [email protected] Subject: CXF Spring interceptors without web.xml I am configuring CXF using all Java code and Spring’s framework. Need assistance to add interceptors in this style? Do I just add the interceptor class to the .setServiceBeans() method array parameter? public class WebAppInitializer implements WebApplicationInitializer { /* * (non-Javadoc) * @see org.springframework.web.WebApplicationInitializer#onStartup(javax.servlet.ServletContext) * Configure the deployment descriptor using only Java, * no web.xml is needed. */ public void onStartup( ServletContext servletContext ) throws ServletException { servletContext.addListener( new ContextLoaderListener( createWebAppContext() ) ); addApacheCxfServlet( servletContext ); } private void addApacheCxfServlet( ServletContext servletContext ) { CXFServlet cxfServlet = new CXFServlet(); Dynamic dynamicAppServlet = servletContext.addServlet( "CXFServlet" , cxfServlet ); dynamicAppServlet.setLoadOnStartup( 1 ); Set<String> mappingConflicts = dynamicAppServlet.addMapping( "/api/*" ); } private WebApplicationContext createWebAppContext() { AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext(); appContext.register( AppConfig.class ); return appContext; } } ——————————— @Configuration public class AppConfig { @ApplicationPath( "/" ) public class JaxRsApiApplication extends Application{} @Bean( destroyMethod = "shutdown" ) public SpringBus cxf() { return new SpringBus(); } @Bean @DependsOn( "cxf" ) public Server jaxRsServer( ApplicationContext appContext ) { JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance() .createEndpoint( jaxRsApiApplication() , JAXRSServerFactoryBean.class ); factory.setServiceBeans( Arrays. asList( personServiceImpl() , exceptionImpl() ) ); factory.setAddress( "/" + factory.getAddress() ); factory.setProvider( jsonProvider() ); return factory.create(); } @Bean public JaxRsApiApplication jaxRsApiApplication() { return new JaxRsApiApplication(); } @Bean public JacksonJsonProvider jsonProvider() { return new JacksonJsonProvider(); } @Bean public PersonServiceDao personServiceDao() { return new PersonServiceDaoImpl(); } @Bean public PersonServiceImpl personServiceImpl() { return new PersonServiceImpl(); } @Bean public ServiceRequestManager serviceRequestManager() { return new ServiceRequestManager(); } @Bean public ServiceResponseBuilder serviceResponseBuilder() { return new ServiceResponseBuilder(); } @Bean public ServiceResponseManager serviceResponseManager() { return new ServiceResponseManager(); } @Bean public ExceptionImpl exceptionImpl() { return new ExceptionImpl(); } } -- View this message in context: http://cxf.547215.n5.nabble.com/CXF-Spring-interceptors-without-web-xml-tp5761947.html Sent from the cxf-user mailing list archive at Nabble.com.
