Beispiel #1
0
  /**
   * Load a deployment unit record stored in the db into memory.
   *
   * @param dudao
   */
  protected List<ProcessConfImpl> load(DeploymentUnitDAO dudao) {
    __log.debug("Loading deployment unit record from db: " + dudao.getName());

    File dudir = findDeployDir(dudao);

    if (dudir == null || !dudir.exists())
      throw new ContextException(
          "Deployed directory " + (dudir == null ? "(unknown)" : dudir) + " no longer there!");
    DeploymentUnitDir dud = new DeploymentUnitDir(dudir);
    // set the name with the one from database
    dud.setName(dudao.getName());
    dud.scan();

    ArrayList<ProcessConfImpl> loaded = new ArrayList<ProcessConfImpl>();

    _rw.writeLock().lock();
    try {
      _deploymentUnits.put(dud.getName(), dud);

      long version = 0;
      for (ProcessConfDAO p : dudao.getProcesses()) {
        TDeployment.Process pinfo = dud.getProcessDeployInfo(p.getType());
        if (pinfo == null) {
          __log.warn("Cannot load " + p.getPID() + "; cannot find descriptor.");
          continue;
        }

        Map<QName, Node> props = calcInitialProperties(dud.getProperties(), pinfo);
        // TODO: update the props based on the values in the DB.

        ProcessConfImpl pconf =
            new ProcessConfImpl(
                p.getPID(),
                p.getType(),
                p.getVersion(),
                dud,
                pinfo,
                dudao.getDeployDate(),
                props,
                p.getState(),
                eprContext,
                _configDir,
                generateProcessEventsAll);
        version = p.getVersion();

        _processes.put(pconf.getProcessId(), pconf);
        loaded.add(pconf);
      }

      // All processes and the DU have the same version
      dud.setVersion(version);
    } finally {
      _rw.writeLock().unlock();
    }

    return loaded;
  }
Beispiel #2
0
  protected File findDeployDir(DeploymentUnitDAO dudao) {
    File f = new File(dudao.getDeploymentUnitDir());
    if (f.exists()) return f;
    f = new File(_deployDir, dudao.getName());
    if (f.exists()) {
      try {
        dudao.setDeploymentUnitDir(f.getCanonicalPath());
      } catch (IOException e) {
        __log.warn("Could not update deployment unit directory for " + dudao.getName(), e);
      }
      return f;
    }

    return null;
  }