Apache CXF and Spring




 Follwing maven settings in  jroller http://www.jroller.com/gmazza/entry/web_service_tutorial

Reading a little from Spring I understood that this is actually the applicationcontext.xml and cxf is somehow cooking its beans with Spring


< bean id="cxf" class="org.apache.cxf.bus.spring.SpringBus" destroy-method="shutdown" / >
      
    < bean id="org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor"
                class="org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor" / >
    < bean id="org.apache.cxf.bus.spring.Jsr250BeanPostProcessor"
                class="org.apache.cxf.bus.spring.Jsr250BeanPostProcessor" / >   
    < bean id="org.apache.cxf.bus.spring.BusExtensionPostProcessor"
                class="org.apache.cxf.bus.spring.BusExtensionPostProcessor" / >

Two of the most fundamental and important packages in Spring are the org.springframework.beans and org.springframework.context packages. Code in these packages provides the basis for Spring's Inversion of Control (alternately called Dependency Injection) features. The BeanFactory provides an advanced configuration mechanism capable of managing beans (objects) of any nature, using potentially any kind of storage facility. The ApplicationContext builds on top of the BeanFactory (it's a subclass) and adds other functionality such as easier integration with Springs AOP features, message resource handling (for use in internationalization), event propagation, declarative mechanisms to create the ApplicationContext and optional parent contexts, and application-layer specific contexts such as the WebApplicationContext, among other enhancements.

A BeanFactory configuration consists of, at its most basic level, definitions of one or more beans that the BeanFactory must manage. In an XmlBeanFactory, these are configured as one or morebean elements inside a top-level beans element.

< ? xml version="1.0" encoding="UTF-8" ? >
< !DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd" >

< beans >
 
  < bean id="..." class="..." >
    ...

  < / bean >


Using the servlet transport without Spring
A user who doesn't want to touch any Spring stuff could also publish the endpoint with CXF servlet transport. First you should extend the CXFNonSpringServlet and then override the method loadBus, e.g.:
import javax.xml.ws.Endpoint;
... 
 
    @Override
    public void loadBus(ServletConfig servletConfig) throws ServletException {
        super.loadBus(servletConfig);       
       
        // You could add the endpoint publish codes here
        Bus bus = cxf.getBus();
        BusFactory.setDefaultBus(bus);
        Endpoint.publish("/Greeter", new GreeterImpl());
       
        // You can als use the simple frontend API to do this
        ServerFactoryBean factroy = new ServerFactoryBean();
        factory.setBus(bus);
        factory.setServiceClass(GreeterImpl.class);
        factory.setAddress("/Greeter");

        factory.create();

Comments

Popular posts from this blog

Long running Java process resource consumption monitoring , leak detection and GC tuning

Best practises - Selenium WebDriver/ Java

CORBA - C++ Client (ACE TAO) Java Server (JacORB) A simple example