当前位置: 首页>>代码示例>>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;未经允许,请勿转载。