當前位置: 首頁>>代碼示例>>Java>>正文


Java ResourceException類代碼示例

本文整理匯總了Java中javax.resource.ResourceException的典型用法代碼示例。如果您正苦於以下問題:Java ResourceException類的具體用法?Java ResourceException怎麽用?Java ResourceException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ResourceException類屬於javax.resource包,在下文中一共展示了ResourceException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: destroy

import javax.resource.ResourceException; //導入依賴的package包/類
public void destroy() throws ResourceException {
  if (DEBUG) {
    try {
      throw new NullPointerException("Asif:JCAManagedConnection:destroy");
    } catch (NullPointerException npe) {
      npe.printStackTrace();
    }
  }
  synchronized (this.connections) {
    Iterator<GFConnectionImpl> connsItr = this.connections.iterator();
    while (connsItr.hasNext()) {
      GFConnectionImpl conn = connsItr.next();
      conn.invalidate();
      connsItr.remove();
    }
  }
  this.gfTxMgr = null;
  this.cache = null;
  this.localTran = null;
  this.listeners.clear();
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:22,代碼來源:JCAManagedConnection.java

示例2: getConnection

import javax.resource.ResourceException; //導入依賴的package包/類
public Object getConnection(Subject subject, ConnectionRequestInfo connectionRequestInfo) throws ResourceException {
    // Check user first
    String userName = credentialExtractor.getUserName();
    CredentialExtractor credential = new CredentialExtractor(subject, connectionRequestInfo, mcf);
    // Null users are allowed!
    if (userName != null && !userName.equals(credential.getUserName())) {
        throw new SecurityException("Password credentials not the same, reauthentication not allowed");
    }
    if (userName == null && credential.getUserName() != null) {
        throw new SecurityException("Password credentials not the same, reauthentication not allowed");
    }

    CI handle = mcf.createConnectionHandle(connectionRequestInfo, (MC) this);
    if (this.handle == null) {
        this.handle = handle;
    } else {
        if (handles == null) {
            handles = new LinkedList<>();
        }
        handles.add(handle);
    }

    this.subject = subject;
    this.cri = connectionRequestInfo;
    return handle;
}
 
開發者ID:ops4j,項目名稱:org.ops4j.pax.transx,代碼行數:27,代碼來源:AbstractManagedConnection.java

示例3: getMetaData

import javax.resource.ResourceException; //導入依賴的package包/類
public ManagedConnectionMetaData getMetaData() throws ResourceException {
    return new ManagedConnectionMetaData() {
        @Override
        public String getEISProductName() throws ResourceException {
            return null;
        }

        @Override
        public String getEISProductVersion() throws ResourceException {
            return null;
        }

        @Override
        public int getMaxConnections() throws ResourceException {
            return -1;
        }

        @Override
        public String getUserName() throws ResourceException {
            return credentialExtractor.getUserName();
        }
    };
}
 
開發者ID:ops4j,項目名稱:org.ops4j.pax.transx,代碼行數:24,代碼來源:AbstractManagedConnection.java

示例4: getMetaData

import javax.resource.ResourceException; //導入依賴的package包/類
public ManagedConnectionMetaData getMetaData() throws ResourceException {
  if (DEBUG) {
    try {
      throw new NullPointerException("Asif:JCAManagedConnection:getMetaData");
    } catch (NullPointerException npe) {
      npe.printStackTrace();
    }
  }
  if (this.initDone && !this.cache.isClosed()) {
    LogWriter logger = this.cache.getLogger();
    if (logger.fineEnabled()) {
      logger.fine("JCAManagedConnection:getMetaData");
    }
  }
  return new JCAManagedConnectionMetaData(this.factory.getProductName(),
      this.factory.getVersion(), this.factory.getUserName());
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:18,代碼來源:JCAManagedConnection.java

示例5: isValid

import javax.resource.ResourceException; //導入依賴的package包/類
private boolean isValid(ManagedConnectionInfo mci) {
    if (managedConnectionFactory instanceof ValidatingManagedConnectionFactory) {
        try {
            Set s = ((ValidatingManagedConnectionFactory) managedConnectionFactory)
                    .getInvalidConnections(Collections.singleton(mci.getManagedConnection()));
            if (s != null && s.contains(mci.getManagedConnection())) {
                return false;
            }
        } catch (ResourceException e) {
            // Ignore
        }
    } else {
        LOG.warning("Connection validation configured, but the ManagedConnectionFactory does not implement the ValidatingManagedConnectionFactory interface");
    }
    return true;
}
 
開發者ID:ops4j,項目名稱:org.ops4j.pax.transx,代碼行數:17,代碼來源:GenericConnectionManager.java

示例6: onClose

import javax.resource.ResourceException; //導入依賴的package包/類
public void onClose(GFConnectionImpl conn) throws ResourceException {
  conn.invalidate();
  this.connections.remove(conn);
  synchronized (this.listeners) {
    Iterator<ConnectionEventListener> itr = this.listeners.iterator();
    ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
    ce.setConnectionHandle(conn);
    while (itr.hasNext()) {
      itr.next().connectionClosed(ce);
    }
  }
  if (this.connections.isEmpty()) {
    // safe to dissociate this managedconnection so that it can go to pool
    if (this.initDone && !this.cache.isClosed()) {
      this.localTran = new JCALocalTransaction(this.cache, this.gfTxMgr);
    } else {
      this.localTran = new JCALocalTransaction();
    }
  }

}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:22,代碼來源:JCAManagedConnection.java

示例7: localTransactionCommit

import javax.resource.ResourceException; //導入依賴的package包/類
protected void localTransactionCommit(boolean isSPI) throws ResourceException {
    try {
        // according to the JDBC spec, reenabling autoCommit commits any current transaction
        // we need to do both here, so we rely on this behaviour in the driver as otherwise
        // commit followed by setAutoCommit(true) may result in 2 commits in the database
        if (mcf.isCommitBeforeAutocommit()) {
            connection.commit();
        }
        connection.setAutoCommit(true);
    } catch (SQLException e) {
        try {
            connection.rollback();
        } catch (SQLException e1) {
            if (log != null) {
                e.printStackTrace(log);
            }
        }
        throw new LocalTransactionException("Unable to commit", e);
    }
    super.localTransactionCommit(isSPI);
}
 
開發者ID:ops4j,項目名稱:org.ops4j.pax.transx,代碼行數:22,代碼來源:ManagedPooledConnection.java

示例8: localTransactionCommit

import javax.resource.ResourceException; //導入依賴的package包/類
protected void localTransactionCommit(boolean isSPI) throws ResourceException {
    try {
        if (mcf.isCommitBeforeAutocommit()) {
            getPhysicalConnection().commit();
        }
        getPhysicalConnection().setAutoCommit(true);
    } catch (SQLException e) {
        try {
            getPhysicalConnection().rollback();
        } catch (SQLException e1) {
            if (log != null) {
                e.printStackTrace(log);
            }
        }
        throw new LocalTransactionException("Unable to commit", e);
    }
    super.localTransactionCommit(isSPI);
}
 
開發者ID:ops4j,項目名稱:org.ops4j.pax.transx,代碼行數:19,代碼來源:ManagedJDBCConnection.java

示例9: getNewPoolConnection

import javax.resource.ResourceException; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:23,代碼來源:ManagedPoolCacheImpl.java

示例10: cleanup

import javax.resource.ResourceException; //導入依賴的package包/類
public void cleanup() throws ResourceException {
  if (DEBUG) {
    try {
      throw new NullPointerException("Asif:JCAManagedConnection:cleanup");
    } catch (NullPointerException npe) {
      npe.printStackTrace();
    }
  }
  synchronized (this.connections) {
    Iterator<GFConnectionImpl> connsItr = this.connections.iterator();
    while (connsItr.hasNext()) {
      GFConnectionImpl conn = connsItr.next();
      conn.invalidate();
      connsItr.remove();
    }
  }
  if (this.localTran == null || this.localTran.transactionInProgress()) {
    if (this.initDone && !this.cache.isClosed()) {
      this.localTran = new JCALocalTransaction(cache, gfTxMgr);
    } else {
      this.localTran = new JCALocalTransaction();
    }
  }

}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:26,代碼來源:JCAManagedConnection.java

示例11: doGetConnection

import javax.resource.ResourceException; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:34,代碼來源:ConnectionFactoryUtils.java

示例12: getXAResource

import javax.resource.ResourceException; //導入依賴的package包/類
@Override
public XAResource getXAResource() throws ResourceException {
    if (xaResource == null) {
        throw new NotSupportedException("XAResource not available");
    }
    return new XAResourceProxy();
}
 
開發者ID:ops4j,項目名稱:org.ops4j.pax.transx,代碼行數:8,代碼來源:AbstractManagedConnection.java

示例13: commit

import javax.resource.ResourceException; //導入依賴的package包/類
public void commit() throws ResourceException {
  if (DEBUG) {
    try {
      throw new NullPointerException("Asif:JCALocalTransaction:commit");
    } catch (NullPointerException npe) {
      npe.printStackTrace();
    }
  }
  LogWriter logger = cache.getLogger();
  if (logger.fineEnabled()) {
    logger.fine("JCALocalTransaction:invoked commit");
  }
  TXStateProxy tsp = this.gfTxMgr.getTXState();
  if (tsp != null && this.tid != tsp.getTransactionId()) {
    throw new IllegalStateException("Local Transaction associated with Tid = " + this.tid
        + " attempting to commit a different transaction");
  }
  try {
    this.gfTxMgr.commit();
    this.tid = null;
  } catch (Exception e) {
    throw new LocalTransactionException(e.toString());
  }
  // Iterator<ConnectionEventListener> itr = this.listeners.iterator();
  // ConnectionEvent ce = new
  // ConnectionEvent(this,ConnectionEvent.LOCAL_TRANSACTION_COMMITTED);
  // while( itr.hasNext()) {
  // itr.next().localTransactionCommitted(ce);
  // }

}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:32,代碼來源:JCALocalTransaction.java

示例14: localTransactionCommit

import javax.resource.ResourceException; //導入依賴的package包/類
protected void localTransactionCommit(boolean isSPI) throws ResourceException {
    if (!isSPI) {
        ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.LOCAL_TRANSACTION_COMMITTED);
        if (listeners != null) {
            for (ConnectionEventListener listener : reverse(listeners)) {
                listener.localTransactionCommitted(event);
            }
        }
        if (listener != null) {
            listener.localTransactionCommitted(event);
        }
    }
}
 
開發者ID:ops4j,項目名稱:org.ops4j.pax.transx,代碼行數:14,代碼來源:AbstractManagedConnection.java

示例15: afterDelivery

import javax.resource.ResourceException; //導入依賴的package包/類
/**
 * 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);
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:20,代碼來源:AbstractMessageEndpointFactory.java


注:本文中的javax.resource.ResourceException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。