|
|
|
Re: Multiple scout client applications accessing the same scout server? [message #1405760 is a reply to message #1405033] |
Fri, 08 August 2014 05:46 |
Matthias Nick Messages: 197 Registered: August 2013 |
Senior Member |
|
|
Hi Peter,
thanks for your questions. I can think of two different ways:
1) == Reusing Services ==
First, I created a simple client server project (Project A). Afterwards I went to the server node and created a server service called "IServerTimeService", which simply returns the ServerTime:
@InputValidation(IValidationStrategy.PROCESS.class)
public interface IServerTimeService extends IService {
long getTime() throws ProcessingException;
}
The implementation for the IServerTimeService is very simple:
public class ServerTimeService extends AbstractService implements IServerTimeService {
@Override
public long getTime() throws ProcessingException {
return System.nanoTime();
}
}
What happens when I create the service is, the IServerTimeService.java will be created in Project A's shared plug-in, the implementation is stored in the server plug-in and a proxy registration is done in the client plug-in.
In Project A's client, I can use the service as usual:
IServerTimeService service = SERVICES.getService(IServerTimeService.class);
long serverTime = service.getTime();
Okay, now the interesting part. I create a new scout project, called Project B. Basically Project B does not need a server since we will reuse the server of Project A. After creating I imported Project A's shared plug-in. Open Project B's shared plug-in and add the Project A's shared plug-in as dependency and reexport it. Accordingly the IServerTimeService is now available in our project.
Now, we have to add the proxy registration of IServerTimeService in our client's plugin.xml as well (this can be copy pasted from Project A's client plugin.xml).
Now we open the swing.product and also add Project A's shared plug-in to the dependencies.
As a last step we have to make sure Project B uses the server url of Project A. Therefore we open the swing product's config.ini and look for the line
### URL to the scout backend webapp
server.url=http\://localhost\:8080/Project_B/process
and of course have to change the url to project A:
### URL to the scout backend webapp
#server.url=http\://localhost\:8080/Project_B/process
server.url=http\://localhost\:8080/Project_A/process
Afterwards you can reuse the IServerTimeService in Project B.
2) == Webservices ==
The 2nd solution I can think of is to provide every service which need to be shared across several scout applications as a webservice. See Webservice Tutorial for more information.
Hope this helps. If other users have comments/solutions I would love to hear them.
Best regards,
Matthias
|
|
|
|
Powered by
FUDForum. Page generated in 0.02981 seconds