Пример #1
0
  public void init(SynapseEnvironment se) {
    if (isPinnedServer(
        se.getServerContextInformation().getServerConfigurationInformation().getServerName())) {
      // If it is a pinned server we do not start the message processors. In that server.
      setActivated(false);
    }

    super.init(se);
    StdSchedulerFactory sf = null;

    try {
      sf = new StdSchedulerFactory(getSchedulerProperties(this.name));
      if (quartzConfig != null && !"".equals(quartzConfig)) {
        if (logger.isDebugEnabled()) {
          logger.debug("Initiating a Scheduler with configuration : " + quartzConfig);
        }
        sf.initialize(quartzConfig);
      }
    } catch (SchedulerException e) {
      throw new SynapseException(
          "Error initiating scheduler factory "
              + sf
              + "with configuration loaded from "
              + quartzConfig,
          e);
    }

    try {
      scheduler = sf.getScheduler();
    } catch (SchedulerException e) {
      throw new SynapseException(
          "Error getting a  scheduler instance form scheduler" + " factory " + sf, e);
    }

    this.start();
    if (!isActivated.get()) {
      deactivate();
    }
  }
Пример #2
0
  public void setParameters(Map<String, Object> parameters) {

    super.setParameters(parameters);

    if (parameters != null && !parameters.isEmpty()) {
      Object o = parameters.get(MessageProcessorConstants.CRON_EXPRESSION);
      if (o != null) {
        cronExpression = o.toString();
      }
      o = parameters.get(MessageProcessorConstants.INTERVAL);
      if (o != null) {
        interval = Integer.parseInt(o.toString());
      }
      o = parameters.get(MessageProcessorConstants.QUARTZ_CONF);
      if (o != null) {
        quartzConfig = o.toString();
      }
      o = parameters.get(MessageProcessorConstants.IS_ACTIVATED);
      if (o != null) {
        isActivated.set(Boolean.valueOf(o.toString()));
      }
    }
  }