public void endpointActivation(MessageEndpointFactory endpointFactory, ActivationSpec spec)
      throws ResourceException {
    log.debug("endpointActivation, spec=" + spec);
    QuartzActivationSpec quartzSpec = (QuartzActivationSpec) spec;

    // allocate instance of endpoint to figure out its endpoint interface
    Class clazz = QuartzJob.class;
    MessageEndpoint tmpMe = endpointFactory.createEndpoint(null);
    if (tmpMe instanceof StatefulJob) clazz = StatefulQuartzJob.class;
    tmpMe.release();

    try {
      JobDetail jobDetail =
          new JobDetail(
              quartzSpec.getJobName(), quartzSpec.getJobGroup(), clazz, true, false, false);
      jobDetail.getJobDataMap().setAllowsTransientData(true);
      jobDetail.getJobDataMap().put("endpointFactory", endpointFactory);
      log.debug("adding job: " + quartzSpec);
      CronTrigger trigger =
          new CronTrigger(
              quartzSpec.getTriggerName(),
              quartzSpec.getTriggerGroup(),
              quartzSpec.getCronTrigger());
      sched.scheduleJob(jobDetail, trigger);
    } catch (Exception e) {
      log.error(e);
      throw new ResourceException(e);
    }
  }
Exemple #2
0
  /**
   * Constructor
   *
   * @param ra The resource adapter
   * @param endpointFactory The endpoint factory
   * @param spec The activation spec
   * @throws ResourceException Thrown if an error occurs
   */
  public HornetQActivation(
      final HornetQResourceAdapter ra,
      final MessageEndpointFactory endpointFactory,
      final HornetQActivationSpec spec)
      throws ResourceException {
    spec.validate();

    if (HornetQActivation.trace) {
      HornetQRALogger.LOGGER.trace(
          "constructor(" + ra + ", " + endpointFactory + ", " + spec + ")");
    }

    if (ra.isUseMaskedPassword()) {
      String pass = spec.getOwnPassword();
      if (pass != null) {
        SensitiveDataCodec<String> codec = ra.getCodecInstance();

        try {
          spec.setPassword(codec.decode(pass));
        } catch (Exception e) {
          throw new ResourceException(e);
        }
      }
    }

    this.ra = ra;
    this.endpointFactory = endpointFactory;
    this.spec = spec;
    try {
      isDeliveryTransacted = endpointFactory.isDeliveryTransacted(HornetQActivation.ONMESSAGE);
    } catch (Exception e) {
      throw new ResourceException(e);
    }
  }
Exemple #3
0
 /**
  * Get a string representation
  *
  * @return The value
  */
 @Override
 public String toString() {
   StringBuffer buffer = new StringBuffer();
   buffer.append(HornetQActivation.class.getName()).append('(');
   buffer.append("spec=").append(spec.getClass().getName());
   buffer.append(" mepf=").append(endpointFactory.getClass().getName());
   buffer.append(" active=").append(deliveryActive.get());
   if (spec.getDestination() != null) {
     buffer.append(" destination=").append(spec.getDestination());
   }
   buffer.append(" transacted=").append(isDeliveryTransacted);
   buffer.append(')');
   return buffer.toString();
 }
    public void endpointActivation(
        MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec)
        throws ResourceException {
      assertNotNull("messageEndpointFactory is null", messageEndpointFactory);
      assertNotNull("activationSpec is null", activationSpec);
      assertTrue(
          "activationSpec should be an instance of FakeActivationSpec",
          activationSpec instanceof FakeActivationSpec);

      MessageEndpoint endpoint = messageEndpointFactory.createEndpoint(null);
      assertNotNull("endpoint is null", endpoint);
      assertTrue(
          "endpoint should be an instance of FakeMessageListener",
          endpoint instanceof FakeMessageListener);
    }