javax.resource.ResourceException Java Examples

The following examples show how to use javax.resource.ResourceException. 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: CciTemplate.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public <T> T execute(final InteractionCallback<T> action) throws DataAccessException {
	Assert.notNull(action, "Callback object must not be null");
	return execute(new ConnectionCallback<T>() {
		@Override
		public T doInConnection(Connection connection, ConnectionFactory connectionFactory)
				throws ResourceException, SQLException, DataAccessException {
			Interaction interaction = connection.createInteraction();
			try {
				return action.doInInteraction(interaction, connectionFactory);
			}
			finally {
				closeInteraction(interaction);
			}
		}
	});
}
 
Example #2
Source File: AutoConnectionTracker.java    From tomee with Apache License 2.0 6 votes vote down vote up
private void proxyConnection(final ConnectionTrackingInterceptor interceptor, final ConnectionInfo connectionInfo) throws ResourceException {
    // no-op if we have opted to not use proxies
    if (connectionInfo.getConnectionProxy() != null) {
        return;
    }

    // DissociatableManagedConnection do not need to be proxied
    if (connectionInfo.getManagedConnectionInfo().getManagedConnection() instanceof DissociatableManagedConnection) {
        return;
    }

    try {
        final Object handle = connectionInfo.getConnectionHandle();
        final ConnectionInvocationHandler invocationHandler = new ConnectionInvocationHandler(handle);
        final Object proxy = newProxy(handle, invocationHandler);
        connectionInfo.setConnectionProxy(proxy);
        final ProxyPhantomReference reference = new ProxyPhantomReference(interceptor, connectionInfo.getManagedConnectionInfo(), invocationHandler, referenceQueue);
        references.put(connectionInfo.getManagedConnectionInfo(), reference);
    } catch (final Throwable e) {
        throw new ResourceException("Unable to construct connection proxy", e);
    }
}
 
Example #3
Source File: ActiveMQRAManagedConnection.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
/**
 * Cleanup
 *
 * @throws ResourceException Thrown if an error occurs
 */
@Override
public void cleanup() throws ResourceException {
   if (logger.isTraceEnabled()) {
      ActiveMQRALogger.LOGGER.trace("cleanup()");
   }

   if (isDestroyed.get()) {
      throw new IllegalStateException("ManagedConnection already destroyed");
   }

   destroyHandles();

   inManagedTx = false;

   inManagedTx = false;

   // I'm recreating the lock object when we return to the pool
   // because it looks too nasty to expect the connection handle
   // to unlock properly in certain race conditions
   // where the dissociation of the managed connection is "random".
   lock = new ReentrantLock();
}
 
Example #4
Source File: UnifiedSecurityManagedConnectionFactory.java    From ironjacamar with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Set getInvalidConnections(Set connectionSet) throws ResourceException
{
   Set result = new HashSet<>();

   Iterator it = connectionSet.iterator();

   while (it.hasNext())
   {
      UnifiedSecurityManagedConnection mc = (UnifiedSecurityManagedConnection) it.next();
      if (mc.isInvalid())
      {
         result.add(mc);
      }
   }

   return result;
}
 
Example #5
Source File: GenericMessageEndpointManager.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Prepares the message endpoint, and automatically activates it
 * if the "autoStartup" flag is set to "true".
 */
@Override
public void afterPropertiesSet() throws ResourceException {
	if (getResourceAdapter() == null) {
		throw new IllegalArgumentException("Property 'resourceAdapter' is required");
	}
	if (getMessageEndpointFactory() == null) {
		throw new IllegalArgumentException("Property 'messageEndpointFactory' is required");
	}
	ActivationSpec activationSpec = getActivationSpec();
	if (activationSpec == null) {
		throw new IllegalArgumentException("Property 'activationSpec' is required");
	}

	if (activationSpec.getResourceAdapter() == null) {
		activationSpec.setResourceAdapter(getResourceAdapter());
	}
	else if (activationSpec.getResourceAdapter() != getResourceAdapter()) {
		throw new IllegalArgumentException("ActivationSpec [" + activationSpec +
				"] is associated with a different ResourceAdapter: " + activationSpec.getResourceAdapter());
	}
}
 
Example #6
Source File: LocalXAResourceImpl.java    From ironjacamar with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void commit(Xid xid, boolean onePhase) throws XAException
{
   if (!xid.equals(currentXid))
   {
      throw new LocalXAException(bundle.wrongXidInCommit(currentXid, xid), XAException.XAER_PROTO);
      
   }
   
   currentXid = null;

   try
   {
      cl.getManagedConnection().getLocalTransaction().commit();
   }
   catch (LocalResourceException lre)
   {
      connectionManager.returnConnectionListener(cl, true);
      throw new LocalXAException(bundle.couldNotCommitLocalTx(), XAException.XAER_RMFAIL, lre);
   }
   catch (ResourceException re)
   {
      connectionManager.returnConnectionListener(cl, true);
      throw new LocalXAException(bundle.couldNotCommitLocalTx(), XAException.XA_RBROLLBACK, re);
   }
}
 
Example #7
Source File: ConnectionFactoryUtils.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Actually obtain a CCI Connection from the given ConnectionFactory.
 * Same as {@link #getConnection}, but throwing the original ResourceException.
 * <p>Is aware of a corresponding Connection bound to the current thread, for example
 * when using {@link CciLocalTransactionManager}. Will bind a Connection to the thread
 * if transaction synchronization is active (e.g. if in a JTA transaction).
 * <p>Directly accessed by {@link TransactionAwareConnectionFactoryProxy}.
 * @param cf the ConnectionFactory to obtain Connection from
 * @return a CCI Connection from the given ConnectionFactory
 * @throws ResourceException if thrown by CCI API methods
 * @see #doReleaseConnection
 */
public static Connection doGetConnection(ConnectionFactory cf) throws ResourceException {
	Assert.notNull(cf, "No ConnectionFactory specified");

	ConnectionHolder conHolder = (ConnectionHolder) TransactionSynchronizationManager.getResource(cf);
	if (conHolder != null) {
		return conHolder.getConnection();
	}

	logger.debug("Opening CCI Connection");
	Connection con = cf.getConnection();

	if (TransactionSynchronizationManager.isSynchronizationActive()) {
		logger.debug("Registering transaction synchronization for CCI Connection");
		conHolder = new ConnectionHolder(con);
		conHolder.setSynchronizedWithTransaction(true);
		TransactionSynchronizationManager.registerSynchronization(new ConnectionSynchronization(conHolder, cf));
		TransactionSynchronizationManager.bindResource(cf, conHolder);
	}

	return con;
}
 
Example #8
Source File: TestActivation.java    From ironjacamar with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Start the activation
 * @throws ResourceException Thrown if an error occurs
 */
public void start() throws ResourceException
{
   try
   {
      Method m = TestMessageListener.class.getMethod("onMessage", new Class<?>[] {String.class});
      
      MessageEndpoint me = endpointFactory.createEndpoint(null);
      me.beforeDelivery(m);

      TestMessageListener tml = (TestMessageListener)me;
      tml.onMessage(spec.getName());
      
      me.afterDelivery();
      me.release();
   }
   catch (ResourceException re)
   {
      throw re;
   }
   catch (Exception e)
   {
      throw new ResourceException(e);
   }
}
 
Example #9
Source File: SingleConnectionFactory.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Initialize the single underlying Connection.
 * <p>Closes and reinitializes the Connection if an underlying
 * Connection is present already.
 * @throws javax.resource.ResourceException if thrown by CCI API methods
 */
public void initConnection() throws ResourceException {
	if (getTargetConnectionFactory() == null) {
		throw new IllegalStateException(
				"'targetConnectionFactory' is required for lazily initializing a Connection");
	}
	synchronized (this.connectionMonitor) {
		if (this.target != null) {
			closeConnection(this.target);
		}
		this.target = doCreateConnection();
		prepareConnection(this.target);
		if (logger.isInfoEnabled()) {
			logger.info("Established shared CCI Connection: " + this.target);
		}
		this.connection = getCloseSuppressingConnectionProxy(this.target);
	}
}
 
Example #10
Source File: ConnectionFactoryUtils.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Actually obtain a CCI Connection from the given ConnectionFactory.
 * Same as {@link #getConnection}, but throwing the original ResourceException.
 * <p>Is aware of a corresponding Connection bound to the current thread, for example
 * when using {@link CciLocalTransactionManager}. Will bind a Connection to the thread
 * if transaction synchronization is active (e.g. if in a JTA transaction).
 * <p>Directly accessed by {@link TransactionAwareConnectionFactoryProxy}.
 * @param cf the ConnectionFactory to obtain Connection from
 * @return a CCI Connection from the given ConnectionFactory
 * @throws ResourceException if thrown by CCI API methods
 * @see #doReleaseConnection
 */
public static Connection doGetConnection(ConnectionFactory cf) throws ResourceException {
	Assert.notNull(cf, "No ConnectionFactory specified");

	ConnectionHolder conHolder = (ConnectionHolder) TransactionSynchronizationManager.getResource(cf);
	if (conHolder != null) {
		return conHolder.getConnection();
	}

	logger.debug("Opening CCI Connection");
	Connection con = cf.getConnection();

	if (TransactionSynchronizationManager.isSynchronizationActive()) {
		conHolder = new ConnectionHolder(con);
		conHolder.setSynchronizedWithTransaction(true);
		TransactionSynchronizationManager.registerSynchronization(new ConnectionSynchronization(conHolder, cf));
		TransactionSynchronizationManager.bindResource(cf, conHolder);
	}

	return con;
}
 
Example #11
Source File: HelloWorldManagedConnectionFactory.java    From ironjacamar with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns a matched connection from the candidate set of connections. 
 *
 * @param connectionSet Candidate connection set
 * @param subject Caller's security information
 * @param cxRequestInfo Additional resource adapter specific connection request information
 * @throws ResourceException generic exception
 * @return ManagedConnection if resource adapter finds an acceptable match otherwise null 
 */
public ManagedConnection matchManagedConnections(Set connectionSet,
                                                 Subject subject, ConnectionRequestInfo cxRequestInfo) 
   throws ResourceException
{
   ManagedConnection result = null;

   Iterator it = connectionSet.iterator();
   while (result == null && it.hasNext()) 
   {
      ManagedConnection mc = (ManagedConnection)it.next();
      if (mc instanceof HelloWorldManagedConnection) 
      {
         HelloWorldManagedConnection hwmc = (HelloWorldManagedConnection)mc;
         result = hwmc;
      }
   }

   return result;
}
 
Example #12
Source File: AbstractMessageEndpointFactory.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * This {@code afterDelivery} implementation resets the thread context
 * ClassLoader and completes the transaction, if any.
 * <p>Note that the JCA 1.5 specification does not require a ResourceAdapter
 * to call this method after invoking the concrete endpoint. See the
 * explanation in {@link #beforeDelivery}'s javadoc.
 */
@Override
public void afterDelivery() throws ResourceException {
	this.beforeDeliveryCalled = false;
	Thread.currentThread().setContextClassLoader(this.previousContextClassLoader);
	this.previousContextClassLoader = null;
	try {
		this.transactionDelegate.endTransaction();
	}
	catch (Throwable ex) {
		throw new ApplicationServerInternalException("Failed to complete transaction", ex);
	}
}
 
Example #13
Source File: SampleManagedConnection.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void associateConnection(Object connection) throws ResourceException {
    log.finest("associateConnection()");

    if (connection == null)
        throw new ResourceException("Null connection handle");

    if (!(connection instanceof SampleConnectionImpl))
        throw new ResourceException("Wrong connection handle");

    this.connection = (SampleConnectionImpl) connection;
}
 
Example #14
Source File: ManagedPoolCacheImpl.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new connection for the managed connection pool.
 * 
 * @return the managed connection from the EIS as ManagedConnection object.
 * @throws PoolException
 */
@Override
public Object getNewPoolConnection() throws PoolException {
  ManagedConnection manConn = null;
  try {
    manConn = connFactory.createManagedConnection(sub, connReqInfo);
  }
  catch (ResourceException rex) {
    rex.printStackTrace();
    throw new PoolException(LocalizedStrings.ManagedPoolCacheImpl_MANAGEDPOOLCACHEIMPLGETNEWCONNECTION_EXCEPTION_IN_CREATING_NEW_MANAGED_POOLEDCONNECTION.toLocalizedString(), rex);
  }
  manConn
      .addConnectionEventListener((javax.resource.spi.ConnectionEventListener) connEventListner);
  return manConn;
}
 
Example #15
Source File: UnzipSplitterBean.java    From equalize-xpi-modules with MIT License 5 votes vote down vote up
private void createAndDispatchMessages(String name, byte[] content, boolean reuse) throws NamingException, MessagingException, ResourceException {
	this.msgdisp.createMessage(content, DeliverySemantics.ExactlyOnce);
	this.msgdisp.setRefToMessageId(this.msg.getMessageId());
	this.msgdisp.setPayloadContentType(this.mimeType + "; name=\"" + name +"\"");
	this.msgdisp.addDynamicConfiguration(this.fileNameNS, this.fileNameAttr, name);
	if(reuse)
		this.msgdisp.addDynamicConfiguration(reuseNS, "reuseIndicator", "true");
	// Dispatch child message
	this.msgdisp.dispatchMessage();
}
 
Example #16
Source File: AbstractPool.java    From ironjacamar with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Test if a connection can be obtained
 * @param credential The credential
 * @return True if possible; otherwise false
 */
protected boolean internalTestConnection(Credential credential)
{
   boolean result = false;
   boolean kill = false;
   ConnectionListener cl = null;

   if (isShutdown())
      return false;

   if (isFull())
      return false;

   try
   {
      ManagedConnectionPool mcp = getManagedConnectionPool(credential);
      cl = mcp.getConnectionListener();
      result = true;
   }
   catch (Throwable t)
   {
      kill = true;
   }
   finally
   {
      if (cl != null)
      {
         try
         {
            returnConnectionListener(cl, kill);
         }
         catch (ResourceException ire)
         {
            // Ignore
         }
      }
   }

   return result;
}
 
Example #17
Source File: CciTemplateTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputGeneratorExtractorTrueWithCreator()
		throws ResourceException, SQLException {
	ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
	RecordFactory recordFactory = mock(RecordFactory.class);
	Connection connection = mock(Connection.class);
	Interaction interaction = mock(Interaction.class);
	RecordCreator generator = mock(RecordCreator.class);
	RecordExtractor<Object> extractor = mock(RecordExtractor.class);
	RecordCreator creator = mock(RecordCreator.class);

	Record inputRecord = mock(Record.class);
	Record outputRecord = mock(Record.class);

	Object obj = new Object();

	InteractionSpec interactionSpec = mock(InteractionSpec.class);

	given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
	given(connectionFactory.getConnection()).willReturn(connection);
	given(connection.createInteraction()).willReturn(interaction);
	given(creator.createRecord(recordFactory)).willReturn(outputRecord);
	given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
	given(generator.createRecord(recordFactory)).willReturn(inputRecord);
	given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
	given(extractor.extractData(outputRecord)).willReturn(obj);

	CciTemplate ct = new CciTemplate(connectionFactory);
	ct.setOutputRecordCreator(creator);
	assertEquals(obj, ct.execute(interactionSpec, generator, extractor));

	verify(interaction).close();
	verify(connection).close();
}
 
Example #18
Source File: TransactionAwareConnectionFactoryProxy.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Delegate to ConnectionFactoryUtils for automatically participating in Spring-managed
 * transactions. Throws the original ResourceException, if any.
 * @return a transactional Connection if any, a new one else
 * @see org.springframework.jca.cci.connection.ConnectionFactoryUtils#doGetConnection
 */
@Override
public Connection getConnection() throws ResourceException {
	ConnectionFactory targetConnectionFactory = obtainTargetConnectionFactory();
	Connection con = ConnectionFactoryUtils.doGetConnection(targetConnectionFactory);
	return getTransactionAwareConnectionProxy(con, targetConnectionFactory);
}
 
Example #19
Source File: ManagedPoolCacheImpl.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new connection for the managed connection pool.
 * 
 * @return the managed connection from the EIS as ManagedConnection object.
 * @throws PoolException
 */
@Override
public Object getNewPoolConnection() throws PoolException {
  ManagedConnection manConn = null;
  try {
    manConn = connFactory.createManagedConnection(sub, connReqInfo);
  }
  catch (ResourceException rex) {
    rex.printStackTrace();
    throw new PoolException(LocalizedStrings.ManagedPoolCacheImpl_MANAGEDPOOLCACHEIMPLGETNEWCONNECTION_EXCEPTION_IN_CREATING_NEW_MANAGED_POOLEDCONNECTION.toLocalizedString(), rex);
  }
  manConn
      .addConnectionEventListener((javax.resource.spi.ConnectionEventListener) connEventListner);
  return manConn;
}
 
Example #20
Source File: ActiveMQRAManagedConnection.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
/**
 * Get the XAResource for the connection.
 *
 * @return The XAResource for the connection.
 * @throws ResourceException XA transaction not supported
 */
@Override
public XAResource getXAResource() throws ResourceException {
   if (logger.isTraceEnabled()) {
      ActiveMQRALogger.LOGGER.trace("getXAResource()");
   }

   //
   // Spec says a mc must always return the same XA resource,
   // so we cache it.
   //
   if (xaResource == null) {
      ClientSessionInternal csi = (ClientSessionInternal) xaSession.getXAResource();
      ActiveMQRAXAResource activeMQRAXAResource = new ActiveMQRAXAResource(this, xaSession.getXAResource());
      Map<String, Object> xaResourceProperties = new HashMap<>();
      xaResourceProperties.put(ActiveMQXAResourceWrapper.ACTIVEMQ_JNDI_NAME, ra.getJndiName());
      xaResourceProperties.put(ActiveMQXAResourceWrapper.ACTIVEMQ_NODE_ID, csi.getNodeId());
      xaResourceProperties.put(ActiveMQXAResourceWrapper.ACTIVEMQ_PRODUCT_NAME, ActiveMQResourceAdapter.PRODUCT_NAME);
      xaResourceProperties.put(ActiveMQXAResourceWrapper.ACTIVEMQ_PRODUCT_VERSION, VersionLoader.getVersion().getFullVersion());
      xaResource = ServiceUtils.wrapXAResource(activeMQRAXAResource, xaResourceProperties);
   }

   if (logger.isTraceEnabled()) {
      ActiveMQRALogger.LOGGER.trace("XAResource=" + xaResource);
   }

   return xaResource;
}
 
Example #21
Source File: CciTemplate.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Execute the specified interaction on an EIS with CCI.
 * All other interaction execution methods go through this.
 * @param spec the CCI InteractionSpec instance that defines
 * the interaction (connector-specific)
 * @param inputRecord the input record
 * @param outputRecord output record (can be {@code null})
 * @param outputExtractor object to convert the output record to a result object
 * @return the output data extracted with the RecordExtractor object
 * @throws DataAccessException if there is any problem
 */
protected <T> T doExecute(
		final InteractionSpec spec, final Record inputRecord, final Record outputRecord,
		final RecordExtractor<T> outputExtractor) throws DataAccessException {

	return execute(new InteractionCallback<T>() {
		@Override
		public T doInInteraction(Interaction interaction, ConnectionFactory connectionFactory)
				throws ResourceException, SQLException, DataAccessException {
			Record outputRecordToUse = outputRecord;
			try {
				if (outputRecord != null || getOutputRecordCreator() != null) {
					// Use the CCI execute method with output record as parameter.
					if (outputRecord == null) {
						RecordFactory recordFactory = getRecordFactory(connectionFactory);
						outputRecordToUse = getOutputRecordCreator().createRecord(recordFactory);
					}
					interaction.execute(spec, inputRecord, outputRecordToUse);
				}
				else {
					outputRecordToUse = interaction.execute(spec, inputRecord);
				}
				return (outputExtractor != null ? outputExtractor.extractData(outputRecordToUse) : null);
			}
			finally {
				if (outputRecordToUse instanceof ResultSet) {
					closeResultSet((ResultSet) outputRecordToUse);
				}
			}
		}
	});
}
 
Example #22
Source File: ActiveMQRALocalTransaction.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
/**
 * Begin
 *
 * @throws ResourceException Thrown if the operation fails
 */
@Override
public void begin() throws ResourceException {
   if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
      ActiveMQRALogger.LOGGER.trace("begin()");
   }

   // mc.setInManagedTx(true);
}
 
Example #23
Source File: ConnectionFactoryImplTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetConnectionWithNonInterface() throws Exception {
    try {
        param.setInterface(Object.class);
        param.setWsdlLocation(new URL("file:/tmp/foo"));
        param.setServiceName(new QName(""));
        param.setPortName(new QName(""));
        cf.getConnection(param);
        fail("Expect exception on using of none interface class");
    } catch (ResourceException re) {
        // expected
    }
}
 
Example #24
Source File: ResourceAdapterFactoryBean.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Builds the BootstrapContext and starts the ResourceAdapter with it.
 * @see javax.resource.spi.ResourceAdapter#start(javax.resource.spi.BootstrapContext)
 */
@Override
public void afterPropertiesSet() throws ResourceException {
	if (this.resourceAdapter == null) {
		throw new IllegalArgumentException("'resourceAdapter' or 'resourceAdapterClass' is required");
	}
	if (this.bootstrapContext == null) {
		this.bootstrapContext = new SimpleBootstrapContext(this.workManager, this.xaTerminator);
	}
	this.resourceAdapter.start(this.bootstrapContext);
}
 
Example #25
Source File: JCAConnection.java    From hibersap with Apache License 2.0 5 votes vote down vote up
public JCAConnection(final ConnectionFactory connectionFactory, final String connectionSpecFactoryName) {
    connectionProvider = new ConnectionProvider(connectionFactory, connectionSpecFactoryName);
    try {
        recordFactory = connectionFactory.getRecordFactory();
    } catch (ResourceException e) {
        throw new HibersapException("Problem creating RecordFactory.", e);
    }
}
 
Example #26
Source File: JcaExecutorServiceManagedConnection.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void associateConnection(Object connection) throws ResourceException {
  if (connection == null) {
    throw new ResourceException("Null connection handle");
  }
  if (!(connection instanceof JcaExecutorServiceConnectionImpl)) {
    throw new ResourceException("Wrong connection handle");
  }
  this.connection = (JcaExecutorServiceConnectionImpl) connection;
}
 
Example #27
Source File: SingleConnectionFactory.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public Connection getConnection() throws ResourceException {
	synchronized (this.connectionMonitor) {
		if (this.connection == null) {
			initConnection();
		}
		return this.connection;
	}
}
 
Example #28
Source File: LazyManagedConnection.java    From ironjacamar with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns an <code>javax.transaction.xa.XAresource</code> instance. 
 *
 * @return XAResource instance
 * @throws ResourceException generic exception if operation fails
 */
public XAResource getXAResource() throws ResourceException
{
   if (!xaTransaction || localTransaction)
   {
      throw new NotSupportedException("GetXAResource not supported not supported");
   }
   else
   {
      return lazyXAResource;
   }
}
 
Example #29
Source File: ActiveMQRAManagedConnection.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
/**
 * Destroy all handles.
 *
 * @throws ResourceException Failed to close one or more handles.
 */
private void destroyHandles() throws ResourceException {
   if (logger.isTraceEnabled()) {
      ActiveMQRALogger.LOGGER.trace("destroyHandles()");
   }

   for (ActiveMQRASession session : handles) {
      session.destroy();
   }

   handles.clear();
}
 
Example #30
Source File: AutoConnectionTrackerTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public ManagedConnection matchManagedConnections(Set connectionSet, Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
    ManagedConnection result = null;
    Iterator it = connectionSet.iterator();
    while (result == null && it.hasNext()) {
        ManagedConnection mc = (ManagedConnection) it.next();
        if (mc instanceof FakeManagedConnection) {
            result = mc;
        }

    }
    return result;
}