Scout Client/Server Version Management [message #858409] |
Fri, 27 April 2012 05:47 |
Adrian Moser Messages: 67 Registered: March 2011 |
Member |
|
|
Using the version parameter on HttpServiceTunnel and by removing the "min-version" init parameter on HttpProxyHandlerServlet on the server a client version >= server version is enforced by Scout.
String version = Activator.getDefault().getBundle().getVersion().toString();
String serverUrl = getBundle().getBundleContext().getProperty("server.url");
setServiceTunnel(new HttpServiceTunnel(this, serverUrl, version));
But how can I enforce a strict check, client version == server version?
|
|
|
Re: Scout Client/Server Version Management [message #867243 is a reply to message #858409] |
Tue, 01 May 2012 07:37 |
|
Hi Adrian
As you may have noticed the version check is done in DefaultTransactionDelegate.invokeImpl. Unfortunately there is no obvious way to exchange that functionality, but there is a possibility.
If I were you I would create a custom TransactionDelegate and override invokeImpl. There you can insert your version check. If it fails, return a VersionMismatchException as it is done in DefaultTransactionDelegate, otherwise call super.invokeImpl.
ServiceTunnelResponse serviceRes = new ServiceTunnelResponse(null, null, new VersionMismatchException(requestVersion.toString(), m_requestMinVersion.toString()));
return serviceRes;
To activate your custom transaction delegate simply extend ServiceTunnelServlet and add the following code:
@Override
protected ServiceTunnelResponse runServerJobTransactionWithDelegate(ServiceTunnelRequest req, Bundle[] loaderBundles, Version requestMinVersion, boolean debug) throws Exception {
return new CustomTransactionDelegate(loaderBundles, requestMinVersion, debug).invoke(req);
}
Please let us know if that works for you, I haven't tried it.
Regards
Claudio
|
|
|
Re: Scout Client/Server Version Management [message #883726 is a reply to message #858409] |
Sat, 09 June 2012 07:32 |
Adrian Moser Messages: 67 Registered: March 2011 |
Member |
|
|
Thanks, your suggestion works, here is the code if someone is interested. Additionally, please make sure you have a customized translation for "VersionMismatchTextXY", since the original text refers to the simple standard check.
@Override
protected ServiceTunnelResponse invokeImpl(ServiceTunnelRequest serviceReq) throws Throwable {
if (requestMinVersion != null) {
String v = serviceReq.getVersion();
if (v == null) {
v = "0.0.0";
}
Version requestVersion = Version.parseVersion(v);
if (requestVersion.compareTo(requestMinVersion) != 0) {
ServiceTunnelResponse serviceRes = new ServiceTunnelResponse(null, null, new VersionMismatchException(requestVersion.toString(), requestMinVersion.toString()));
return serviceRes;
}
}
return super.invokeImpl(serviceReq);
}
|
|
|
Powered by
FUDForum. Page generated in 0.03413 seconds