/**
  * Checks if this started server has already a configured proxy and returns the associated port if
  * it is still free, or associate a new port if the previous port is not avaiable anymore, or
  * create a new port if none existed before.
  *
  * @param startedServer
  * @return the proxy port
  * @throws CoreException
  */
 private int getProxyPort(final IServer startedServer) throws CoreException {
   final IServer liveReloadServer = getServer();
   @SuppressWarnings("unchecked")
   final Map<String, Integer> proxyPorts =
       liveReloadServer.getAttribute(PROXY_PORTS, new HashMap<String, Integer>());
   final String startedServerId = startedServer.getId();
   if (proxyPorts.containsKey(startedServerId)) {
     final int port = proxyPorts.get(startedServerId);
     if (!SocketUtil.isPortInUse(port)) {
       return port;
     }
   }
   final IServerWorkingCopy swc = getServer().createWorkingCopy();
   final int port = SocketUtil.findUnusedPort(50000, 60000);
   proxyPorts.put(startedServerId, port);
   swc.setAttribute(PROXY_PORTS, proxyPorts);
   swc.saveAll(true, null);
   return port;
 }