Package javax.resource.cci

Examples of javax.resource.cci.Connection


    public void testProxy() throws Exception {
        Object proxy = kernel.invoke(managedConnectionFactoryName, "$getResource");
        assertNotNull(proxy);
        assertTrue(proxy instanceof ConnectionFactory);
        Connection connection = ((ConnectionFactory) proxy).getConnection();
        assertNotNull(connection);
        kernel.stopGBean(managedConnectionFactoryName);
        try {
            ((ConnectionFactory) proxy).getConnection();
            fail();
View Full Code Here


        oos.close();
        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes));
        Object proxy2 = ois.readObject();
        assertNotNull(proxy2);
        assertTrue(proxy instanceof ConnectionFactory);
        Connection connection = proxy.getConnection();
        assertNotNull(connection);
        kernel.stopGBean(managedConnectionFactoryName);
        ObjectInputStream ois2 = new ObjectInputStream(new ByteArrayInputStream(bytes));
        ConnectionFactory proxy3 = (ConnectionFactory) ois2.readObject();
        try {
View Full Code Here

                try {
                    ((AbstractConnectionManager) connectionManager).doStart();
                    try {
                        final Object cf = managedConnectionFactory.createConnectionFactory(connectionManager);
                        if (cf instanceof ConnectionFactory) {
                            final Connection connection = ((ConnectionFactory) cf).getConnection();
                            connection.getMetaData();
                            connection.close();
                        }
                    } catch (final Exception e) {
                        // no-op: just to force eager init of pool
                    }
                } catch (final Exception e) {
View Full Code Here

   * 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
   */
  public Connection getConnection() throws ResourceException {
    Connection con = ConnectionFactoryUtils.doGetConnection(getTargetConnectionFactory());
    return getTransactionAwareConnectionProxy(con, getTargetConnectionFactory());
  }
View Full Code Here

    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);
View Full Code Here

  }

  protected void doBegin(Object transaction, TransactionDefinition definition) {
    CciLocalTransactionObject txObject = (CciLocalTransactionObject) transaction;

    Connection con = null;

    try {
      con = getConnectionFactory().getConnection();
      if (logger.isDebugEnabled()) {
        logger.debug("Acquired Connection [" + con + "] for local CCI transaction");
      }

      txObject.setConnectionHolder(new ConnectionHolder(con));
      txObject.getConnectionHolder().setSynchronizedWithTransaction(true);

      con.getLocalTransaction().begin();
      int timeout = determineTimeout(definition);
      if (timeout != TransactionDefinition.TIMEOUT_DEFAULT) {
        txObject.getConnectionHolder().setTimeoutInSeconds(timeout);
      }
      TransactionSynchronizationManager.bindResource(getConnectionFactory(), txObject.getConnectionHolder());
View Full Code Here

    return txObject.getConnectionHolder().isRollbackOnly();
  }

  protected void doCommit(DefaultTransactionStatus status) {
    CciLocalTransactionObject txObject = (CciLocalTransactionObject) status.getTransaction();
    Connection con = txObject.getConnectionHolder().getConnection();
    if (status.isDebug()) {
      logger.debug("Committing CCI local transaction on Connection [" + con + "]");
    }
    try {
      con.getLocalTransaction().commit();
    }
    catch (LocalTransactionException ex) {
      throw new TransactionSystemException("Could not commit CCI local transaction", ex);
    }
    catch (ResourceException ex) {
View Full Code Here

    }
  }

  protected void doRollback(DefaultTransactionStatus status) {
    CciLocalTransactionObject txObject = (CciLocalTransactionObject) status.getTransaction();
    Connection con = txObject.getConnectionHolder().getConnection();
    if (status.isDebug()) {
      logger.debug("Rolling back CCI local transaction on Connection [" + con + "]");
    }
    try {
      con.getLocalTransaction().rollback();
    }
    catch (LocalTransactionException ex) {
      throw new TransactionSystemException("Could not roll back CCI local transaction", ex);
    }
    catch (ResourceException ex) {
View Full Code Here

    // Remove the connection holder from the thread.
    TransactionSynchronizationManager.unbindResource(getConnectionFactory());
    txObject.getConnectionHolder().clear();

    Connection con = txObject.getConnectionHolder().getConnection();
    if (logger.isDebugEnabled()) {
      logger.debug("Releasing CCI Connection [" + con + "] after transaction");
    }
    ConnectionFactoryUtils.releaseConnection(con, getConnectionFactory());
  }
View Full Code Here


  public Object execute(ConnectionCallback action) throws DataAccessException {
    Assert.notNull(action, "Callback object must not be null");

    Connection con = ConnectionFactoryUtils.getConnection(getConnectionFactory(), getConnectionSpec());
    try {
      return action.doInConnection(con, getConnectionFactory());
    }
    catch (NotSupportedException ex) {
      throw new CciOperationNotSupportedException("CCI operation not supported by connector", ex);
View Full Code Here

TOP

Related Classes of javax.resource.cci.Connection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.