Exemple #1
0
  public void setProperty(final QName pid, final QName propName, final String value) {
    if (__log.isDebugEnabled()) __log.debug("Setting property " + propName + " on process " + pid);

    ProcessConfImpl pconf = _processes.get(pid);
    if (pconf == null) {
      String msg = __msgs.msgProcessNotFound(pid);
      __log.info(msg);
      throw new ContextException(msg);
    }

    final DeploymentUnitDir dudir = pconf.getDeploymentUnit();
    exec(
        new ProcessStoreImpl.Callable<Object>() {
          public Object call(ConfStoreConnection conn) {
            DeploymentUnitDAO dudao = conn.getDeploymentUnit(dudir.getName());
            if (dudao == null) return null;
            ProcessConfDAO proc = dudao.getProcess(pid);
            if (proc == null) return null;
            proc.setProperty(propName, value);
            return null;
          }
        });

    fireEvent(new ProcessStoreEvent(ProcessStoreEvent.Type.PROPERTY_CHANGED, pid, dudir.getName()));
  }
Exemple #2
0
  public void setState(final QName pid, final ProcessState state) {
    __log.debug("Changing process state for " + pid + " to " + state);

    final ProcessConfImpl pconf;

    _rw.readLock().lock();
    try {
      pconf = _processes.get(pid);
      if (pconf == null) {
        String msg = __msgs.msgProcessNotFound(pid);
        __log.info(msg);
        throw new ContextException(msg);
      }
    } finally {
      _rw.readLock().unlock();
    }

    final DeploymentUnitDir dudir = pconf.getDeploymentUnit();

    // Update in the database.
    ProcessState old =
        exec(
            new Callable<ProcessState>() {
              public ProcessState call(ConfStoreConnection conn) {
                DeploymentUnitDAO dudao = conn.getDeploymentUnit(dudir.getName());
                if (dudao == null) {
                  String errmsg = __msgs.msgProcessNotFound(pid);
                  __log.error(errmsg);
                  throw new ContextException(errmsg);
                }

                ProcessConfDAO dao = dudao.getProcess(pid);
                if (dao == null) {
                  String errmsg = __msgs.msgProcessNotFound(pid);
                  __log.error(errmsg);
                  throw new ContextException(errmsg);
                }

                Set processKeys = _processes.keySet();
                Iterator processConfQNameItr = processKeys.iterator();

                while (processConfQNameItr.hasNext()) {
                  ProcessConf cachedProcessConf = _processes.get(processConfQNameItr.next());
                  if (dao.getType().equals(cachedProcessConf.getType())) {
                    if (ProcessState.ACTIVE == cachedProcessConf.getState()
                        && ProcessState.RETIRED == dao.getState()
                        && ProcessState.ACTIVE == state) {
                      String errorMsg =
                          "Can't activate the process with PID: "
                              + dao.getPID()
                              + " with version "
                              + dao.getVersion()
                              + ", as another version of the process with PID : "
                              + cachedProcessConf.getProcessId()
                              + " with version "
                              + cachedProcessConf.getVersion()
                              + " is already active.";
                      __log.error(errorMsg);
                      throw new ContextException(errorMsg);
                    }
                  }
                }

                ProcessState old = dao.getState();
                dao.setState(state);
                pconf.setState(state);
                return old;
              }
            });

    pconf.setState(state);
    if (old != null && old != state)
      fireStateChange(pid, state, pconf.getDeploymentUnit().getName());
  }