Skip to content

Instantly share code, notes, and snippets.

@cemartins
Created October 5, 2014 22:58
Show Gist options
  • Save cemartins/bd17fce7d003a7536663 to your computer and use it in GitHub Desktop.
Save cemartins/bd17fce7d003a7536663 to your computer and use it in GitHub Desktop.
Method to calculate the server address based on the server-url parameter in the JNLP file
private URI getServerEndpointAddress() {
String serverEndpointStr = SERVER_URL;
Parameters parameters = getParameters();
if(parameters != null && parameters.getNamed().get("server-url") != null) {
serverEndpointStr = parameters.getNamed().get("server-url");
if(serverEndpointStr.startsWith("https"))
serverEndpointStr = serverEndpointStr.replaceFirst("https", "wss");
else
serverEndpointStr = serverEndpointStr.replaceFirst("http", "ws");
serverEndpointStr = serverEndpointStr + "/wstest";
logger.debug("Calculated Server Endpoint Address: " + serverEndpointStr);
}
return URI.create(serverEndpointStr);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment