Ejemplo n.º 1
0
  private void addModules(
      EPServiceProvider cep, String modulesList, ServletContextEvent servletContextEvent) {
    try {
      List<Module> modules = new ArrayList<Module>();
      if (modulesList != null) {
        String[] split = modulesList.split(",");
        for (int i = 0; i < split.length; i++) {
          String resourceName = split[i].trim();
          if (resourceName.length() == 0) {
            continue;
          }
          // String realPath = servletContextEvent.getServletContext()
          // .getRealPath(resourceName);
          Module module =
              cep.getEPAdministrator().getDeploymentAdmin().read(new File(resourceName));
          modules.add(module);
          log.info(String.format("Module %s added to engine %s", resourceName, cep.getURI()));
        }

        // Determine deployment order
        DeploymentOrder order =
            cep.getEPAdministrator().getDeploymentAdmin().getDeploymentOrder(modules, null);

        // Deploy
        for (Module module : order.getOrdered()) {
          DeploymentResult result =
              cep.getEPAdministrator().getDeploymentAdmin().deploy(module, new DeploymentOptions());
          deploymentIds.add(result.getDeploymentId());
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }