javax.resource.spi.endpoint.MessageEndpointFactory Java Examples

The following examples show how to use javax.resource.spi.endpoint.MessageEndpointFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActiveMQResourceAdapter.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
/**
 * Endpoint activation
 *
 * @param endpointFactory The endpoint factory
 * @param spec            The activation spec
 * @throws ResourceException Thrown if an error occurs
 */
@Override
public void endpointActivation(final MessageEndpointFactory endpointFactory,
                               final ActivationSpec spec) throws ResourceException {
   if (spec == null) {
      throw ActiveMQRABundle.BUNDLE.noActivationSpec();
   }
   if (!configured.getAndSet(true)) {
      try {
         setup();
      } catch (ActiveMQException e) {
         throw new ResourceException("Unable to create activation", e);
      }
   }
   if (logger.isTraceEnabled()) {
      logger.trace("endpointActivation(" + endpointFactory + ", " + spec + ")");
   }

   ActiveMQActivation activation = new ActiveMQActivation(this, endpointFactory, (ActiveMQActivationSpec) spec);
   activations.put(spec, activation);
   activation.start();
}
 
Example #2
Source File: QuartzResourceAdapter.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Override
public void endpointActivation(final MessageEndpointFactory messageEndpointFactory, final ActivationSpec activationSpec) throws ResourceException {

    final Scheduler s = scheduler.get();
    if (null == s) {
        throw new ResourceException("Quartz Scheduler is not available");
    }

    try {

        final JobSpec spec = (JobSpec) activationSpec;

        final MessageEndpoint endpoint = messageEndpointFactory.createEndpoint(null);
        spec.setEndpoint(endpoint);

        final Job job = (Job) endpoint;

        final JobDataMap jobDataMap = spec.getDetail().getJobDataMap();
        jobDataMap.put(Data.class.getName(), new Data(job));

        s.scheduleJob(spec.getDetail(), spec.getTrigger());
    } catch (final SchedulerException e) {
        throw new ResourceException("Failed to schedule job", e);
    }
}
 
Example #3
Source File: QuartzResourceAdapter.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Override
public void endpointDeactivation(final MessageEndpointFactory messageEndpointFactory, final ActivationSpec activationSpec) {

    final Scheduler s = scheduler.get();
    if (null == s) {
        throw new IllegalStateException("Quartz Scheduler is not available");
    }

    JobSpec spec = null;

    try {
        spec = (JobSpec) activationSpec;
        s.deleteJob(spec.jobKey());

    } catch (final SchedulerException e) {
        throw new IllegalStateException("Failed to delete job", e);
    } finally {
        if (null != spec) {
            spec.getEndpoint().release();
        }
    }
}
 
Example #4
Source File: ResourceAdapterImpl.java    From ironjacamar with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void endpointDeactivation(MessageEndpointFactory mef, ActivationSpec as) throws Exception
{
   if (mef == null)
      throw new Exception("MessageEndpointFactory is null");

   if (as == null)
      throw new Exception("ActivationSpec is null");

   Endpoint e = new Endpoint(mef, as);
   InflowRecovery ir = activeEndpoints.get(e);

   if (ir != null)
      ir.deactivate();
   
   try
   {
      resourceAdapter.endpointDeactivation(mef, as);
   }
   finally
   {
      activeEndpoints.remove(e);
   }
}
 
Example #5
Source File: ResourceAdapterImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void endpointDeactivation(MessageEndpointFactory mef, ActivationSpec as) {

        if  (!(as instanceof MDBActivationSpec)) {
            LOG.fine("Ignored unknown activation spec " + as);
            return;
        }

        MDBActivationSpec spec = (MDBActivationSpec)as;
        LOG.info("CXF resource adapter is deactivating " + spec.getDisplayName());

        InboundEndpoint endpoint = endpoints.remove(spec.getDisplayName());
        if (endpoint != null) {
            try {
                endpoint.shutdown();
            } catch (Exception e) {
                LOG.log(Level.WARNING, "Failed to stop endpoint "
                        + spec.getDisplayName(), e);
            }
        }
    }
 
Example #6
Source File: ResourceAdapterImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
public void endpointActivation(MessageEndpointFactory mef, ActivationSpec as)
    throws ResourceException {

    if  (!(as instanceof MDBActivationSpec)) {
        LOG.fine("Ignored unknown activation spec " + as);
        return;
    }

    MDBActivationSpec spec = (MDBActivationSpec)as;
    LOG.info("CXF resource adapter is activating " + spec.getDisplayName());

    Work work = new MDBActivationWork(spec, mef, endpoints);
    ctx.getWorkManager().scheduleWork(work);

}
 
Example #7
Source File: SpringContextResourceAdapter.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * This implementation always throws a NotSupportedException.
 */
@Override
public void endpointActivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec)
		throws ResourceException {

	throw new NotSupportedException("SpringContextResourceAdapter does not support message endpoints");
}
 
Example #8
Source File: NoMessageDeliveryTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void endpointDeactivation(final MessageEndpointFactory messageEndpointFactory, final ActivationSpec activationSpec) {
    final EmailAccountInfo accountInfo = (EmailAccountInfo) activationSpec;

    final EmailConsumer emailConsumer = consumers.remove(accountInfo.getAddress());
    final MessageEndpoint endpoint = (MessageEndpoint) emailConsumer;
    endpoint.release();
}
 
Example #9
Source File: TestResourceAdapter.java    From ironjacamar with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void endpointActivation(MessageEndpointFactory endpointFactory,
                               ActivationSpec spec) throws ResourceException
{
   TestActivation activation = new TestActivation(this, endpointFactory, (TestActivationSpec)spec);
   activations.put((TestActivationSpec)spec, activation);
   activation.start();
}
 
Example #10
Source File: MdbConfigTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void endpointActivation(final MessageEndpointFactory messageEndpointFactory, final 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);

    final MessageEndpoint endpoint = messageEndpointFactory.createEndpoint(null);
    assertNotNull("endpoint is null", endpoint);
    assertTrue("endpoint should be an instance of FakeMessageListener", endpoint instanceof FakeMessageListener);
}
 
Example #11
Source File: SampleResourceAdapter.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void endpointActivation(final MessageEndpointFactory messageEndpointFactory, final ActivationSpec activationSpec)
        throws ResourceException
{
    final SampleActivationSpec sampleActivationSpec = (SampleActivationSpec) activationSpec;

    try {
        final MessageEndpoint messageEndpoint = messageEndpointFactory.createEndpoint(null);
        final EndpointTarget target = new EndpointTarget(messageEndpoint);
        targets.put(sampleActivationSpec, target);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #12
Source File: MDBActivationWork.java    From cxf with Apache License 2.0 5 votes vote down vote up
public MDBActivationWork(MDBActivationSpec spec,
        MessageEndpointFactory endpointFactory,
        Map<String, InboundEndpoint> endpoints) {
    this.spec = spec;
    this.endpointFactory = endpointFactory;
    this.endpoints = endpoints;
}
 
Example #13
Source File: SpringContextResourceAdapter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * This implementation always throws a NotSupportedException.
 */
@Override
public void endpointActivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec)
		throws ResourceException {

	throw new NotSupportedException("SpringContextResourceAdapter does not support message endpoints");
}
 
Example #14
Source File: SampleResourceAdapter.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void endpointActivation(final MessageEndpointFactory messageEndpointFactory, final ActivationSpec activationSpec)
        throws ResourceException
{
    final SampleActivationSpec sampleActivationSpec = (SampleActivationSpec) activationSpec;

    try {
        final MessageEndpoint messageEndpoint = messageEndpointFactory.createEndpoint(null);
        final EndpointTarget target = new EndpointTarget(messageEndpoint);
        targets.put(sampleActivationSpec, target);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #15
Source File: SampleResourceAdapter.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void endpointDeactivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) {
    final SampleActivationSpec sampleActivationSpec = (SampleActivationSpec) activationSpec;

    final EndpointTarget endpointTarget = targets.get(sampleActivationSpec);
    if (endpointTarget == null) {
        throw new IllegalStateException("No EndpointTarget to undeploy for ActivationSpec " + activationSpec);
    }

    endpointTarget.messageEndpoint.release();
}
 
Example #16
Source File: SpringContextResourceAdapter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This implementation always throws a NotSupportedException.
 */
@Override
public void endpointActivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec)
		throws ResourceException {

	throw new NotSupportedException("SpringContextResourceAdapter does not support message endpoints");
}
 
Example #17
Source File: SampleResourceAdapter.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void endpointDeactivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) {
    final SampleActivationSpec sampleActivationSpec = (SampleActivationSpec) activationSpec;

    final EndpointTarget endpointTarget = targets.get(sampleActivationSpec);
    if (endpointTarget == null) {
        throw new IllegalStateException("No EndpointTarget to undeploy for ActivationSpec " + activationSpec);
    }

    endpointTarget.messageEndpoint.release();
}
 
Example #18
Source File: TestResourceAdapter.java    From ironjacamar with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void endpointDeactivation(MessageEndpointFactory endpointFactory,
                                 ActivationSpec spec)
{
   TestActivation activation = activations.remove(spec);
   if (activation != null)
      activation.stop();
}
 
Example #19
Source File: TestActivation.java    From ironjacamar with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Constructor
 * @param ra TestResourceAdapter
 * @param endpointFactory MessageEndpointFactory
 * @param spec TestActivationSpec
 * @exception ResourceException Thrown if an error occurs
 */
public TestActivation(TestResourceAdapter ra, 
                      MessageEndpointFactory endpointFactory,
                      TestActivationSpec spec) throws ResourceException

{
   this.ra = ra;
   this.endpointFactory = endpointFactory;
   this.spec = spec;
}
 
Example #20
Source File: EndpointImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void deactivate(MessageEndpointFactory endpointFactory,
                       ActivationSpec spec) throws ResourceException
{
   if (endpointFactory == null)
      throw new IllegalArgumentException("MessageEndpointFactory is null");

   if (spec == null)
      throw new IllegalArgumentException("ActivationSpec is null");

   ResourceAdapter rar = ra.get();

   if (rar == null)
      throw new ResourceException(bundle.resourceAdapterInstanceNotActive());

   if (transactionIntegration != null && transactionIntegration.getRecoveryRegistry() != null && xa)
   {
      XAResourceRecovery xrr = recovery.remove(spec);
      if (xrr != null)
      {
         log.tracef("Removing %s for recovery", xrr);

         try
         {
            xrr.shutdown();
         }
         catch (Exception e)
         {
            throw new ResourceException(bundle.errorDuringRecoveryShutdown(), e);
         }
         finally
         {
            transactionIntegration.getRecoveryRegistry().removeXAResourceRecovery(xrr);
         }
      }
   }

   rar.endpointDeactivation(endpointFactory, spec);
}
 
Example #21
Source File: JcaExecutorServiceConnector.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void endpointDeactivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) {
  try {
    if(jobHandlerActivation != null) {
      jobHandlerActivation.stop();
    }
  } finally {
    jobHandlerActivation = null;
  }
}
 
Example #22
Source File: SpringContextResourceAdapter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * This implementation always throws a NotSupportedException.
 */
@Override
public void endpointActivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec)
		throws ResourceException {

	throw new NotSupportedException("SpringContextResourceAdapter does not support message endpoints");
}
 
Example #23
Source File: ResourceAdapterImpl.java    From ironjacamar with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void endpointActivation(MessageEndpointFactory mef, ActivationSpec as) throws Exception
{
   if (mef == null)
      throw new Exception("MessageEndpointFactory is null");

   if (as == null)
      throw new Exception("ActivationSpec is null");

   as.setResourceAdapter(resourceAdapter);
   
   try
   {
      as.validate();
   }
   catch (UnsupportedOperationException uoe)
   {
      // Ignore
   }

   if (is16)
   {
      verifyBeanValidation(as);
   }
   
   resourceAdapter.endpointActivation(mef, as);

   InflowRecovery ir = null;
   if (transactionIntegration != null && transactionIntegration.getRecoveryRegistry() != null)
   {
      XAResourceRecovery xar = transactionIntegration.createXAResourceRecovery(resourceAdapter,
                                                                               as,
                                                                               productName, productVersion);

      ir = new InflowRecoveryImpl(mef, as, xar, transactionIntegration.getRecoveryRegistry());
      ir.activate();
   }

   activeEndpoints.put(new Endpoint(mef, as), ir);
}
 
Example #24
Source File: ActiveMQActivation.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
/**
 * Get the message endpoint factory
 *
 * @return The value
 */
public MessageEndpointFactory getMessageEndpointFactory() {
   if (logger.isTraceEnabled()) {
      logger.trace("getMessageEndpointFactory()");
   }

   return endpointFactory;
}
 
Example #25
Source File: AutoConfigMdbContainerTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void endpointDeactivation(final MessageEndpointFactory messageEndpointFactory, final ActivationSpec activationSpec) {
    final EmailAccountInfo accountInfo = (EmailAccountInfo) activationSpec;

    final EmailConsumer emailConsumer = consumers.remove(accountInfo.getAddress());
    final MessageEndpoint endpoint = (MessageEndpoint) emailConsumer;
    endpoint.release();
}
 
Example #26
Source File: ActiveMQResourceAdapter.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
/**
 * Endpoint deactivation
 *
 * @param endpointFactory The endpoint factory
 * @param spec            The activation spec
 */
@Override
public void endpointDeactivation(final MessageEndpointFactory endpointFactory, final ActivationSpec spec) {
   if (logger.isTraceEnabled()) {
      logger.trace("endpointDeactivation(" + endpointFactory + ", " + spec + ")");
   }

   ActiveMQActivation activation = activations.remove(spec);
   if (activation != null) {
      activation.stop();
   }
}
 
Example #27
Source File: SampleResourceAdapter.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void endpointActivation(final MessageEndpointFactory messageEndpointFactory, final ActivationSpec activationSpec)
        throws ResourceException
{
    final SampleActivationSpec sampleActivationSpec = (SampleActivationSpec) activationSpec;

    try {
        targets.put(sampleActivationSpec, messageEndpointFactory);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #28
Source File: CustomMdbContainerTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void endpointActivation(final MessageEndpointFactory messageEndpointFactory, final ActivationSpec activationSpec) throws ResourceException {
    final EmailAccountInfo accountInfo = (EmailAccountInfo) activationSpec;

    final EmailConsumer emailConsumer = (EmailConsumer) messageEndpointFactory.createEndpoint(null);
    consumers.put(accountInfo.getAddress(), emailConsumer);
}
 
Example #29
Source File: TestActivation.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Get message endpoint factory
 * @return Message endpoint factory
 */
public MessageEndpointFactory getMessageEndpointFactory()
{
   return endpointFactory;
}
 
Example #30
Source File: ResourceAdapterImpl.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Constructor
 * @param mef The MessageEndpointFactory
 * @param as The ActivationSpec
 */
Endpoint(MessageEndpointFactory mef, ActivationSpec as)
{
   this.mef = mef;
   this.as = as;
}