code: @Override
      public void configureGateway(Gateway gateway) {
          Properties properties = new Properties();
          properties.putAll(System.getProperties());
  
          String gatewayHome = properties.getProperty(Gateway.GATEWAY_HOME_PROPERTY);
          if ((gatewayHome == null) || "".equals(gatewayHome)) {
              ClassLoader loader = Thread.currentThread().getContextClassLoader();
              URL classUrl = loader.getResource("org/kaazing/gateway/server/Gateway.class");
              String urlStr;
              try {
                  urlStr = URLDecoder.decode(classUrl.toString(), "UTF-8");
              } catch (UnsupportedEncodingException ex) {
                  // it's not likely that UTF-8 will be unsupported, so in practice this will never occur
                  throw new RuntimeException("Failed to configure Gateway", ex);
              }
  
              // The URL is coming from a JAR file.  The format of that is supposed to be
              // jar:<url>!/<packagepath>.  Normally the first part of the <url> section will be
              // 'file:', but could be different if somehow the JAR is loaded from the network.
              // We can only handle the 'file' case, so will check.
              int packageSeparatorIndex = urlStr.indexOf("!/");
              if (packageSeparatorIndex > 0) {
                  urlStr = urlStr.substring(0, urlStr.indexOf("!/"));
                  urlStr = urlStr.substring(4);  // remove the 'jar:' part.
              }
  
              if (!urlStr.startsWith("file:")) {
                  throw new RuntimeException("The Gateway class was not loaded from a file, so we " +
                          "cannot determine the location of GATEWAY_HOME");
              }
  
              urlStr = urlStr.substring(5);  // remove the 'file:' stuff.
              File jarFile = new File(urlStr);
              gatewayHome = jarFile.getParentFile().getParent();
              properties.setProperty("GATEWAY_HOME", gatewayHome);
          }
  
          gateway.setProperties(properties);
      }
docs: Bootstrap the Gateway instance with a GATEWAY_HOME if not already set in System properties.