@@ -0,0 +1,1787 @@
+/**%0A * Teknei 2016%0A */%0Apackage com.teknei;%0A%0Aimport java.net.HttpURLConnection;%0Aimport java.net.URL;%0A%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0Aimport org.springframework.beans.factory.annotation.Value;%0Aimport org.springframework.stereotype.Component;%0A%0A/**%0A * Class for testing if there is an active connection to the server%0A * %0A * @author Jorge Amaro%0A *%0A */%0A@Component%0Apublic class ReplyConnection %7B%0A%0A%09@Value(%22$%7Btkn.ip.destiny%7D%22)%0A%09private String ipDestiny;%0A%09@Value(%22$%7Btkn.connection.timeout%7D%22)%0A%09private String timeOut;%0A%0A%09private static final Logger log = LoggerFactory.getLogger(ReplyConnection.class);%0A%0A%09/**%0A%09 * Check if the process can reach the destination server%0A%09 * %0A%09 * @return true if the server is reachable, false otherwise%0A%09 */%0A%09public boolean checkStatus() %7B%0A%09%09String url = %22%22;%0A%09%09Integer tOut = null;%0A%09%09if(timeOut == null)%7B%0A%09%09%09log.debug(%22No timeout specified, setting 10 seconds%22);%0A%09%09%09tOut = 10;%0A%09%09%7Delse%7B%0A%09%09%09try%7B%0A%09%09%09%09tOut = Integer.parseInt(timeOut);%0A%09%09%09%7Dcatch(Exception e)%7B%0A%09%09%09%09log.error(%22Error setting timeout property, setting 10 seconds%22);%0A%09%09%09%09tOut = 10;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09try %7B%0A%09%09%09StringBuilder sb = new StringBuilder(%22http://%22);%0A%09%09%09sb.append(ipDestiny);%0A%09%09%09sb.append(%22:%22);%0A%09%09%09sb.append(%228080%22);%0A%09%09%09URL siteURL = new URL(sb.toString());%0A%09%09%09url = sb.toString();%0A%09%09%09HttpURLConnection connection = (HttpURLConnection) siteURL.openConnection();%0A%09%09%09connection.setConnectTimeout(1000 * tOut); //send in millis%0A%09%09%09connection.setRequestMethod(%22GET%22);%0A%09%09%09connection.connect();%0A%09%09%09int code = connection.getResponseCode();%0A%09%09%09if (code == HttpURLConnection.HTTP_OK) %7B%0A%09%09%09%09log.info(%22Connection successful%22);%0A%09%09%09%09return true;%0A%09%09%09%7D%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09log.error(%22Error connecting the remote server url %7B%7D with error: %7B%7D%22, url, e.getMessage());%0A%09%09%7D%0A%09%09return false;%0A%09%7D%0A%7D%0A

Test connection