Exemplo n.º 1
0
  public String deploy(String fileName) {

    try {
      File f = new File(fileName);
      URL url = null;
      if (!f.exists()) {
        LogUtil.getCoreLog().info("Search classpath ...");
        PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
        String path = "classpath:**/*" + fileName;
        Resource[] res = resolver.getResources(path);
        if (res.length > 0) {
          url = res[0].getURL();
        } else return path + " can not find in " + url;
      } else {
        url = f.toURI().toURL();
      }
      LogUtil.getCoreLog().info("Jar file path:" + url);
      JarFileService srv = JpaContext.getService(JarFileService.class);
      ReleasedJarFile jarFile = srv.deploy(url);
      String fname = null;
      try {
        fname = url.toURI().toURL().getFile();
      } catch (MalformedURLException | URISyntaxException e) {
        throw new GemliteException("Not a vaild url:" + url, e);
      }
      if (!srv.splitVersion(jarFile, fname)) {
        throw new GemliteException(fname + " not a valid jar file.");
      }

      //     if (!srv.checkDuplicate(jarFile))
      //     {
      //       throw new GemliteException(jarFile.getFileName() + " has no change.");
      //     }

      DeployParameter param =
          new DeployParameter(
              jarFile.getModuleName(), jarFile.getModuleType(), jarFile.getContent());
      FunctionUtil.deploy(param);
      srv.save(jarFile);
    } catch (IOException | GemliteException e) {
      e.printStackTrace();
      LogUtil.getCoreLog().error(fileName, e);
      return e.getMessage();
    }
    return "Deploy success";
  }
Exemplo n.º 2
0
 /**
  * 取本机的ip
  *
  * @return
  */
 private String getHost() {
   String ip = "";
   try {
     InetAddress addr = InetAddress.getLocalHost();
     ip = addr.getHostAddress().toString();
   } catch (Exception e) {
     ip = e.getMessage();
     LogUtil.getAppLog().error("get Ip error:", e);
   }
   return ip;
 }