lundi 2 mars 2015

How to annotate Jersey POJO when Impl is remote?

I have 2 JVM's.


JettyJVM Runs http requests and has an interface CarFacade that is backed using RmiProxyFactoryBean to the CarFacadeImpl running in the CoreJVM



<bean class="org.springframework.remoting.rmi.RmiProxyFactoryBeanFactory">
<property name="serviceInterface" value="org.foo.CarFacade"/>
<property name="serviceUrl" value="http://rmi#{HOST}:1099/CarFacade"/>
</bean>


CoreJVM Runs core business logic in a spring container and has CarFacadeImpl



<bean id="carFacade" class="org.foo.impl.CarFacadeImpl"></bean>
<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
<property name="service" ref="carFacade"></property>
<property name="serviceInterface" value="org.foo.CarFacade"></property>
<property name="serviceName" value="CarFacade"></property>
<property name="replaceExistingBinding" value="true"></property>
<property name="registryPort" value="1099"></property>
</bean>


This setup works currently for flex/blazds and my services are exposed nicely.


Is there any way I can also expose this via Jersey?


I tried with the annotations on the Impl (preferred) but the component scan doesn't find the annotations (obviously as the interface doesn't have them) So I tried with the annotations on the Interface but jersey says it can't instantiate the interface.



// CarFacadeImpl.java - when I had the annotations on the class in the CoreJVM
@Path("car")
public class CarFacadeImpl implements CarFacade {
@GET
public String getName() {
return "CarFacade";
}
}

// CarFacade.java - When I had the annotations on the interface in JettyJVM
@Path("car")
public class CarFacade {
@GET
String getName();
}


I would really like to not have to write an additional layer just to expose via rest.


I have tried the examples from here http://ift.tt/1DtE4hq and they work without the RMI call in between.


Aucun commentaire:

Enregistrer un commentaire