コード例 #1
0
  private TriggerKey createTriggerKey(String uri, String remaining, QuartzEndpoint endpoint)
      throws Exception {
    // Parse uri for trigger name and group
    URI u = new URI(uri);
    String path = ObjectHelper.after(u.getPath(), "/");
    String host = u.getHost();

    // host can be null if the uri did contain invalid host characters such as an underscore
    if (host == null) {
      host = ObjectHelper.before(remaining, "/");
    }

    // Trigger group can be optional, if so set it to this context's unique name
    String name;
    String group;
    if (ObjectHelper.isNotEmpty(path) && ObjectHelper.isNotEmpty(host)) {
      group = host;
      name = path;
    } else {
      String camelContextName = getCamelContext().getManagementName();
      group = camelContextName == null ? "Camel" : "Camel_" + camelContextName;
      name = host;
    }

    if (prefixJobNameWithEndpointId) {
      name = endpoint.getId() + "_" + name;
    }

    return new TriggerKey(name, group);
  }
コード例 #2
0
  @Override
  protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters)
      throws Exception {
    // Get couple of scheduler settings
    Integer startDelayedSeconds =
        getAndRemoveParameter(parameters, "startDelayedSeconds", Integer.class);
    if (startDelayedSeconds != null) {
      if (this.startDelayedSeconds != 0 && !(this.startDelayedSeconds == startDelayedSeconds)) {
        LOG.warn(
            "A Quartz job is already configured with a different 'startDelayedSeconds' configuration! "
                + "All Quartz jobs must share the same 'startDelayedSeconds' configuration! Cannot apply the 'startDelayedSeconds' configuration!");
      } else {
        this.startDelayedSeconds = startDelayedSeconds;
      }
    }

    Boolean autoStartScheduler =
        getAndRemoveParameter(parameters, "autoStartScheduler", Boolean.class);
    if (autoStartScheduler != null) {
      this.autoStartScheduler = autoStartScheduler;
    }

    Boolean prefixJobNameWithEndpointId =
        getAndRemoveParameter(parameters, "prefixJobNameWithEndpointId", Boolean.class);
    if (prefixJobNameWithEndpointId != null) {
      this.prefixJobNameWithEndpointId = prefixJobNameWithEndpointId;
    }

    // Extract trigger.XXX and job.XXX properties to be set on endpoint below
    Map<String, Object> triggerParameters =
        IntrospectionSupport.extractProperties(parameters, "trigger.");
    Map<String, Object> jobParameters = IntrospectionSupport.extractProperties(parameters, "job.");

    // Create quartz endpoint
    QuartzEndpoint result = new QuartzEndpoint(uri, this);
    TriggerKey triggerKey = createTriggerKey(uri, remaining, result);
    result.setTriggerKey(triggerKey);
    result.setTriggerParameters(triggerParameters);
    result.setJobParameters(jobParameters);
    return result;
  }