Ejemplo n.º 1
0
 public void start() {
   if (realH2Server == null || !realH2Server.isRunning(false)) {
     try {
       DeleteDbFiles.execute("", "JPADroolsFlow", true);
       realH2Server = Server.createTcpServer(new String[0]);
       realH2Server.start();
     } catch (SQLException e) {
       throw new RuntimeException("can't start h2 server db", e);
     }
   }
 }
Ejemplo n.º 2
0
  @Action(
      value = "h2-db-web-console-tab-content",
      results = {@Result(name = "tab", location = "h2-db-web-console-tab-content.jsp")})
  @SkipValidation
  public String tab() throws Exception {
    Server server = (Server) application.get("h2DbWebServer");
    if (server != null && server.isRunning(false)) {
      h2DbWebServerRunning = true;
    } else {
      h2DbWebServerRunning = false;
    }

    return "tab";
  }
Ejemplo n.º 3
0
  @Action(
      value = "h2-db-web-console-stop",
      results = {@Result(name = "sucess", location = "h2-db-web-console-start.jsp")})
  @SkipValidation
  public String stop() throws Exception {
    synchronized (lock) {
      Server server = (Server) application.get("h2DbWebServer");
      if (server != null && server.isRunning(false)) {
        server.stop();
      }
    }

    return "sucess";
  }
Ejemplo n.º 4
0
  @Action(
      value = "h2-db-web-console-start",
      results = {@Result(name = "sucess", location = "h2-db-web-console-stop.jsp")})
  public String start() throws Exception {
    synchronized (lock) {
      Server server = (Server) application.get("h2DbWebServer");
      if (server != null && server.isRunning(false)) {
        URL urlObj = new URL(ServletActionContext.getRequest().getRequestURL().toString());
        StringBuffer sb = new StringBuffer();
        sb.append(urlObj.getProtocol())
            .append("://")
            .append(urlObj.getHost())
            .append(":")
            .append(server.getPort())
            .append("/");
        url = sb.toString();
      } else {
        server =
            Server.createWebServer(
                "-webPort", port.toString(), "-baseDir", ".", "-webAllowOthers", "-webDaemon");
        server.start();
        application.put("h2DbWebServer", server);

        URL urlObj = new URL(ServletActionContext.getRequest().getRequestURL().toString());
        StringBuffer sb = new StringBuffer();
        sb.append(urlObj.getProtocol())
            .append("://")
            .append(urlObj.getHost())
            .append(":")
            .append(port)
            .append("/");
        url = sb.toString();
      }
    }

    return "sucess";
  }