i was wondering if spring has any solution to support a procedure call using configuration of an in process service or remote service.
update 1
an example, lets say we have the following :
Common project:
public interface ServiceBInterface {
boolean doSomething();
}
Project A (depended on common project) :
@Service
public class ServiceA {
@Autowired
private ServiceBInterface serviceB;
public void flowA() {
// run flow A code
boolean result = serviceB.doSomething();
// continue run flow A code with result of service B
}
}
Project B (depended on common project) :
@Service
public class ServiceB implements ServiceBInterface {
public boolean doSomething() {
boolean result = false;
// execute some code
return result;
}
}
i would like to be able to configure ServiceBInterface bean to be initialized on the following options:
Answer Project A (depended on common project) :
@Service
public class ServiceA {
@Autowired
private ServiceBInterface serviceB;
@PostConstruct
public void init() {
if (Boolean.getBoolean("remote")) {
RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
rmiProxyFactoryBean.setServiceUrl("rmi://localhost:1099/ServiceB");
rmiProxyFactoryBean.setServiceInterface(ServiceBInterface.class);
rmiProxyFactoryBean.setRefreshStubOnConnectFailure(true);
rmiProxyFactoryBean.setLookupStubOnStartup(false);
rmiProxyFactoryBean.afterPropertiesSet();
serviceB = (ServiceBInterface) rmiProxyFactoryBean.getObject();
}
}
public void flowA() {
// run flow A code
boolean result = serviceB.doSomething();
// continue run flow A code with result of service B
}
}
Project B (depended on common project) :
@Service
public class ServiceB implements ServiceBInterface {
RmiServiceExporter rmiServiceExporte;
@PostConstruct
public void init() throws RemoteException {
if (Boolean.getBoolean("remoteB")) {
rmiServiceExporter = new RmiServiceExporter();
rmiServiceExporter.setServiceName("ServiceB");
rmiServiceExporter.setService(serviceB());
rmiServiceExporter.setServiceInterface(ServiceBInterface.class);
rmiServiceExporter.setServicePort(9999);
rmiServiceExporter.afterPropertiesSet();
}
}
public boolean doSomething() {
boolean result = false;
// execute some code
return result;
}
}
Sorry you question isn't clear to me, but I wonder if you'd be able to find some help for yourself reading Spring Integration Reference Manual. For example there is an RMI support which is represented as a pair of inbound/outbound gateways to communicate with the remote procedure service.
Otherwise, please, be more specific, especially with the sample of code for solution which you'd like to reach.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With