OData4j y CXF con Spring

I am attempting to integrate odata4j into an existing CXF service application. The servlet already hosts an existing soap and rest service. My application server is tomcat.

Mi web.xml:

<servlet>
        <servlet-name>CXFServlet</servlet-name>
        <display-name>CXF Servlet</display-name>
        <servlet-class>
            org.apache.cxf.transport.servlet.CXFServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
        <servlet-mapping>
        <servlet-name>CXFServlet</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

The existing soap and rest services are configured via jaxrs and jaxws configuration files.

I have created my JPA OData Producer Factory:

public class CmecfOdataProducerFactoryImpl implements ODataProducerFactory {
    String namespace = "MyOData";
    private int maxResults = 100;
    @Override
    public ODataProducer create(Properties prprts) {

        String persistenceName = null;
        try {
            persistenceName = ServiceLocator.getInstance().getResource("java:/comp/env/persistenceUnitName", String.class);
        } catch (Exception ex) {
            Logger.getLogger(CmecfOdataProducerFactoryImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceName);
        JPAProducer producer = new JPAProducer(emf, namespace, maxResults);

        return producer;
    }
}

What is the cleanest way to include this odata service?

Gracias por cualquier ayuda!

preguntado el 28 de agosto de 12 a las 15:08

1 Respuestas

There is nothing to do just add your odata JPA factory in web.xml file. below web.xml configuration will work without fail, put your JPA factory package properly.

<servlet>     
<servlet-name>JPAFactory</servlet-name>     
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>     
<init-param>       
<param-name>javax.ws.rs.Application</param-name>       
<param-value>org.odata4j.jersey.producer.resources.ODataApplication</param-value>     
</init-param> 
<init-param> 
<param-name>odata4j.producerfactory</param-name> 
<param-value>**your packageName**.CmecfOdataProducerFactoryImpl </param-value> 
</init-param> 
<load-on-startup>1</load-on-startup>   
</servlet>   
<servlet-mapping>     
<servlet-name>JPAFactory</servlet-name>     
<url-pattern>/jpaproducer.svc/*</url-pattern>   
</servlet-mapping>

Respondido 05 Abr '13, 13:04

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.