javax.resource.spi.ResourceAdapter Java Examples

The following examples show how to use javax.resource.spi.ResourceAdapter. 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: XAResourceRecoveryInflowImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor
 *
 * @param rar The resource adapter
 * @param as The activation spec
 * @param productName The product name
 * @param productVersion The product version
 */
public XAResourceRecoveryInflowImpl(ResourceAdapter rar, ActivationSpec as,
                                    String productName, String productVersion)
{
   if (rar == null)
      throw new IllegalArgumentException("ResourceAdapter is null");

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

   this.resourceAdapter = rar;
   this.activationSpec = as;
   this.productName = productName;
   this.productVersion = productVersion;
   this.jndiName = null;
}
 
Example #2
Source File: StandardJmsActivationSpecFactory.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
public ActivationSpec createActivationSpec(ResourceAdapter adapter, JmsActivationSpecConfig config) {
	Class<?> activationSpecClassToUse = this.activationSpecClass;
	if (activationSpecClassToUse == null) {
		activationSpecClassToUse = determineActivationSpecClass(adapter);
		if (activationSpecClassToUse == null) {
			throw new IllegalStateException("Property 'activationSpecClass' is required");
		}
	}

	ActivationSpec spec = (ActivationSpec) BeanUtils.instantiateClass(activationSpecClassToUse);
	BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(spec);
	if (this.defaultProperties != null) {
		bw.setPropertyValues(this.defaultProperties);
	}
	populateActivationSpecProperties(bw, config);
	return spec;
}
 
Example #3
Source File: XAResourceRecoveryInflowImpl.java    From ironjacamar with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Constructor
 *
 * @param rar The resource adapter
 * @param as The activation spec
 * @param productName The product name
 * @param productVersion The product version
 */
public XAResourceRecoveryInflowImpl(ResourceAdapter rar, ActivationSpec as,
                                    String productName, String productVersion)
{
   if (rar == null)
      throw new IllegalArgumentException("ResourceAdapter is null");

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

   this.resourceAdapter = rar;
   this.activationSpec = as;
   this.productName = productName;
   this.productVersion = productVersion;
   this.jndiName = null;
}
 
Example #4
Source File: RA.java    From ironjacamar with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Validate
 * @param vo The validate object
 * @param rb The resource bundle
 * @return The list of failures found; <code>null</code> if none
 */
@SuppressWarnings("unchecked")
public List<Failure> validate(Validate vo, ResourceBundle rb)
{
   if (vo != null && Key.RESOURCE_ADAPTER == vo.getKey())
   {
      if (vo.getClazz() != null && !ResourceAdapter.class.isAssignableFrom(vo.getClazz()))
      {
         List<Failure> failures = new ArrayList<Failure>(1);

         Failure failure = new Failure(Severity.ERROR,
                                       SECTION,
                                       rb.getString("ra.RA"),
                                       vo.getClazz().getName());
         failures.add(failure);

         return failures;
      }
   }

   return null;
}
 
Example #5
Source File: StandardJmsActivationSpecFactory.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
public ActivationSpec createActivationSpec(ResourceAdapter adapter, JmsActivationSpecConfig config) {
	Class<?> activationSpecClassToUse = this.activationSpecClass;
	if (activationSpecClassToUse == null) {
		activationSpecClassToUse = determineActivationSpecClass(adapter);
		if (activationSpecClassToUse == null) {
			throw new IllegalStateException("Property 'activationSpecClass' is required");
		}
	}

	ActivationSpec spec = (ActivationSpec) BeanUtils.instantiateClass(activationSpecClassToUse);
	BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(spec);
	if (this.defaultProperties != null) {
		bw.setPropertyValues(this.defaultProperties);
	}
	populateActivationSpecProperties(bw, config);
	return spec;
}
 
Example #6
Source File: RAConfigProperties.java    From ironjacamar with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Validate
 * @param v The validate object
 * @param rb The resource bundle
 * @return The list of failures found; <code>null</code> if none
 */
@SuppressWarnings("unchecked")
public List<Failure> validate(Validate v, ResourceBundle rb)
{
   if (v != null &&
       Key.RESOURCE_ADAPTER == v.getKey() &&
       v.getClazz() != null &&
       ResourceAdapter.class.isAssignableFrom(v.getClazz()))
   {
      ValidateClass vo = (ValidateClass)v;
      if (vo.getConfigProperties() != null && !vo.getConfigProperties().isEmpty())
      {
         return ConfigPropertiesHelper.validateConfigPropertiesType(vo, SECTION,
                 rb.getString("ra.RAConfigProperties"));
      }
   }

   return null;
}
 
Example #7
Source File: MdbContainer.java    From tomee with Apache License 2.0 5 votes vote down vote up
public MdbContainer(final Object containerID, final SecurityService securityService, final ResourceAdapter resourceAdapter,
                    final Class messageListenerInterface, final Class activationSpecClass, final int instanceLimit,
                    final boolean failOnUnknownActivationSpec) {
    this.containerID = containerID;
    this.securityService = securityService;
    this.resourceAdapter = resourceAdapter;
    this.messageListenerInterface = messageListenerInterface;
    this.activationSpecClass = activationSpecClass;
    this.instanceLimit = instanceLimit;
    this.failOnUnknownActivationSpec = failOnUnknownActivationSpec;
    xaResourceWrapper = SystemInstance.get().getComponent(XAResourceWrapper.class);
    inboundRecovery = SystemInstance.get().getComponent(InboundRecovery.class);
}
 
Example #8
Source File: GenericMessageEndpointManager.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Deactivates the configured message endpoint.
 */
@Override
public void stop() {
	synchronized (this.lifecycleMonitor) {
		if (this.running) {
			ResourceAdapter resourceAdapter = getResourceAdapter();
			Assert.state(resourceAdapter != null, "No ResourceAdapter set");
			resourceAdapter.endpointDeactivation(getMessageEndpointFactory(), getActivationSpec());
			this.running = false;
		}
	}
}
 
Example #9
Source File: ActiveMQRAManagedConnectionFactory.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
/**
 * Set the resource adapter
 * <br>
 * This should ensure that when the RA is stopped, this MCF will be stopped as well.
 *
 * @param ra The resource adapter
 * @throws ResourceException Thrown if incorrect resource adapter
 */
@Override
public void setResourceAdapter(final ResourceAdapter ra) throws ResourceException {
   if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
      ActiveMQRALogger.LOGGER.trace("setResourceAdapter(" + ra + ")");
   }

   if (ra == null || !(ra instanceof ActiveMQResourceAdapter)) {
      throw new ResourceException("Resource adapter is " + ra);
   }

   this.ra = (ActiveMQResourceAdapter) ra;
   this.ra.setManagedConnectionFactory(this);
}
 
Example #10
Source File: ActiveMQActivationSpec.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
/**
 * Get the resource adapter
 *
 * @return The resource adapter
 */
@Override
public ResourceAdapter getResourceAdapter() {
   if (logger.isTraceEnabled()) {
      logger.trace("getResourceAdapter()");
   }

   return ra;
}
 
Example #11
Source File: ActiveMQRAManagedConnectionFactory.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
/**
 * Get the resource adapter
 *
 * @return The resource adapter
 */
@Override
public ResourceAdapter getResourceAdapter() {
   if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
      ActiveMQRALogger.LOGGER.trace("getResourceAdapter()");
   }

   return ra;
}
 
Example #12
Source File: GenericMessageEndpointManager.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Deactivates the configured message endpoint.
 */
@Override
public void stop() {
	synchronized (this.lifecycleMonitor) {
		if (this.running) {
			ResourceAdapter resourceAdapter = getResourceAdapter();
			Assert.state(resourceAdapter != null, "No ResourceAdapter set");
			resourceAdapter.endpointDeactivation(getMessageEndpointFactory(), getActivationSpec());
			this.running = false;
		}
	}
}
 
Example #13
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 #14
Source File: MdbContainer.java    From tomee with Apache License 2.0 5 votes vote down vote up
public MdbActivationContext(final ClassLoader classLoader, final BeanContext beanContext, final ResourceAdapter resourceAdapter, final EndpointFactory endpointFactory, final ActivationSpec activationSpec) {
    this.classLoader = classLoader;
    this.beanContext = beanContext;
    this.resourceAdapter = resourceAdapter;
    this.endpointFactory = endpointFactory;
    this.activationSpec = activationSpec;
}
 
Example #15
Source File: TransactionIntegrationImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public XAResourceRecovery createXAResourceRecovery(ResourceAdapter rar,
                                                   ActivationSpec as,
                                                   String productName, String productVersion)
{
   return new XAResourceRecoveryInflowImpl(rar, as, productName, productVersion);
}
 
Example #16
Source File: EndpointImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 * @param ra The resource adapter reference
 * @param is16 Is the resource adapter a 1.6 archive
 * @param bvg The bean validation groups
 * @param productName The product name
 * @param productVersion The product version
 * @param ti The transaction integration
 * @param xa XA capable
 */
EndpointImpl(WeakReference<ResourceAdapter> ra, boolean is16, Set<String> bvg,
             String productName, String productVersion, TransactionIntegration ti,
             boolean xa)
{
   this.ra = ra;
   this.is16 = is16;
   this.beanValidationGroups = bvg;
   this.productName = productName;
   this.productVersion = productVersion;
   this.transactionIntegration = ti;
   this.xa = xa;
   this.recovery = new HashMap<ActivationSpec, XAResourceRecovery>();
}
 
Example #17
Source File: ResourceAdapterImplTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testConstructorWithProperties() throws Exception {
    Properties props = new Properties();
    ResourceAdapterImpl rai = new ResourceAdapterImpl(props);
    assertTrue("constructed with props", rai instanceof ResourceAdapterImpl);
    assertTrue("constructed with props", rai instanceof ResourceBean);
    assertTrue("constructed with props", rai instanceof ResourceAdapter);
    assertTrue("constructed with props", rai instanceof Serializable);
}
 
Example #18
Source File: StubJmsActivationSpecFactory.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public ActivationSpec createActivationSpec(ResourceAdapter adapter, JmsActivationSpecConfig config) {
	return new StubActivationSpec();
}
 
Example #19
Source File: ResourceAdapterFactoryBean.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public ResourceAdapter getObject() {
	return this.resourceAdapter;
}
 
Example #20
Source File: LazyManagedConnectionFactory.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Set the resource adapter
 *
 * @param ra The handle
 */
public void setResourceAdapter(ResourceAdapter ra)
{
   log.trace("setResourceAdapter()");
   this.ra = ra;
}
 
Example #21
Source File: SampleManagedConnectionFactory.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void setResourceAdapter(ResourceAdapter ra) {
    log.finest("setResourceAdapter()");
    this.ra = ra;
}
 
Example #22
Source File: SampleActivationSpec.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public void setResourceAdapter(ResourceAdapter ra) throws ResourceException {
    this.resourceAdapter = ra;
}
 
Example #23
Source File: JobExecutionHandlerActivationSpec.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void setResourceAdapter(ResourceAdapter ra) {
  this.ra = ra;
}
 
Example #24
Source File: MdbPoolContainer.java    From tomee with Apache License 2.0 4 votes vote down vote up
public ResourceAdapter getResourceAdapter() {
    return resourceAdapter;
}
 
Example #25
Source File: ManagedConnectionFactoryImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public ResourceAdapter getResourceAdapter() {
    return resourceAdapter;
}
 
Example #26
Source File: MdbContainerFactory.java    From tomee with Apache License 2.0 4 votes vote down vote up
public ResourceAdapter getResourceAdapter() {
    return resourceAdapter;
}
 
Example #27
Source File: SampleActivationSpec.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public ResourceAdapter getResourceAdapter() {
    return resourceAdapter;
}
 
Example #28
Source File: MdbContainer.java    From tomee with Apache License 2.0 4 votes vote down vote up
public ResourceAdapter getResourceAdapter() {
    return resourceAdapter;
}
 
Example #29
Source File: TestAdminObjectImpl.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void setResourceAdapter(ResourceAdapter ra)
{
   this.ra = ra;
}
 
Example #30
Source File: WorkManagerImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get the resource adapter
 * @return The value
 */
public ResourceAdapter getResourceAdapter()
{
   return resourceAdapter;
}