本文整理汇总了Java中javax.resource.spi.ConnectionEvent类的典型用法代码示例。如果您正苦于以下问题:Java ConnectionEvent类的具体用法?Java ConnectionEvent怎么用?Java ConnectionEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionEvent类属于javax.resource.spi包,在下文中一共展示了ConnectionEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connectionClosed
import javax.resource.spi.ConnectionEvent; //导入依赖的package包/类
/**
* Callback for Connection Closed.
*
* @param event ConnectionEvent Object.
*/
public void connectionClosed(ConnectionEvent event) {
if (isActive) {
ManagedConnection conn = (ManagedConnection) event.getSource();
TransactionManagerImpl transManager = TransactionManagerImpl.getTransactionManager();
try {
Transaction txn = transManager.getTransaction();
if (txn == null) {
mannPoolCache.returnPooledConnectionToPool(conn);
}
} catch (Exception se) {
String exception =
"FacetsJCAConnectionManagerImpl::connectionClosed: Exception occured due to "
+ se.getMessage();
if (logger.isDebugEnabled()) {
logger.debug(exception, se);
}
}
}
}
示例2: onError
import javax.resource.spi.ConnectionEvent; //导入依赖的package包/类
private void onError(Exception e) {
this.localTran = null;
synchronized (this.connections) {
Iterator<GFConnectionImpl> connsItr = this.connections.iterator();
while (connsItr.hasNext()) {
GFConnectionImpl conn = connsItr.next();
conn.invalidate();
synchronized (this.listeners) {
Iterator<ConnectionEventListener> itr = this.listeners.iterator();
ConnectionEvent ce =
new ConnectionEvent(this, ConnectionEvent.CONNECTION_ERROR_OCCURRED, e);
ce.setConnectionHandle(conn);
while (itr.hasNext()) {
itr.next().connectionErrorOccurred(ce);
}
}
connsItr.remove();
}
}
}
示例3: onClose
import javax.resource.spi.ConnectionEvent; //导入依赖的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();
}
}
}
示例4: connectionClosed
import javax.resource.spi.ConnectionEvent; //导入依赖的package包/类
/**
* Callback for Connection Closed.
*
* @param event ConnectionEvent Object.
*/
public void connectionClosed(ConnectionEvent event) {
if (isActive) {
ManagedConnection conn = (ManagedConnection) event.getSource();
XAResource xar = null;
if (xaResourcesMap.get(conn) != null)
xar = (XAResource) xaResourcesMap.get(conn);
xaResourcesMap.remove(conn);
try {
Transaction txn = transManager.getTransaction();
if (txn != null && xar != null) {
txn.delistResource(xar, XAResource.TMSUCCESS);
}
}
catch (Exception se) {
String exception = "JCAConnectionManagerImpl::connectionClosed: Exception occured due to "
+ se;
LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
if (writer.fineEnabled()) writer.fine(exception, se);
}
mannPoolCache.returnPooledConnectionToPool(conn);
}
}
示例5: connectionClosed
import javax.resource.spi.ConnectionEvent; //导入依赖的package包/类
/**
* Callback for Connection Closed.
*
* @param event ConnectionEvent Object.
*/
public void connectionClosed(ConnectionEvent event) {
if (isActive) {
ManagedConnection conn = (ManagedConnection) event.getSource();
TransactionManagerImpl transManager = TransactionManagerImpl
.getTransactionManager();
try {
Transaction txn = transManager.getTransaction();
if (txn == null) {
mannPoolCache.returnPooledConnectionToPool(conn);
}
}
catch (Exception se) {
String exception = "FacetsJCAConnectionManagerImpl::connectionClosed: Exception occured due to "
+ se;
LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
if (writer.fineEnabled()) writer.fine(exception, se);
}
}
}
示例6: onError
import javax.resource.spi.ConnectionEvent; //导入依赖的package包/类
private void onError(Exception e)
{
this.localTran = null;
synchronized (this.connections) {
Iterator<GFConnectionImpl> connsItr = this.connections.iterator();
while (connsItr.hasNext()) {
GFConnectionImpl conn = connsItr.next();
conn.invalidate();
synchronized (this.listeners) {
Iterator<ConnectionEventListener> itr = this.listeners.iterator();
ConnectionEvent ce = new ConnectionEvent(this,
ConnectionEvent.CONNECTION_ERROR_OCCURRED, e);
ce.setConnectionHandle(conn);
while (itr.hasNext()) {
itr.next().connectionErrorOccurred(ce);
}
}
connsItr.remove();
}
}
}
示例7: onClose
import javax.resource.spi.ConnectionEvent; //导入依赖的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();
}
}
}
示例8: connectionClosed
import javax.resource.spi.ConnectionEvent; //导入依赖的package包/类
void connectionClosed(WrappedConnection wc) {
synchronized (this.handles) {
handles.remove(wc);
}
ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
ce.setConnectionHandle(wc);
ArrayList<ConnectionEventListener> copy = null;
synchronized (this.listeners) {
copy = new ArrayList<ConnectionEventListener>(this.listeners);
}
for(ConnectionEventListener l: copy) {
l.connectionClosed(ce);
}
}
示例9: sendConnectionEvent
import javax.resource.spi.ConnectionEvent; //导入依赖的package包/类
protected void sendConnectionEvent(ConnectionEvent connEvent) {
for (int i = listeners.size() - 1; i >= 0; i--) {
ConnectionEventListener listener =
(ConnectionEventListener) listeners.get(i);
if (connEvent.getId() == ConnectionEvent.CONNECTION_CLOSED) {
listener.connectionClosed(connEvent);
} else if (connEvent.getId() ==
ConnectionEvent.CONNECTION_ERROR_OCCURRED) {
listener.connectionErrorOccurred(connEvent);
} else if (connEvent.getId() ==
ConnectionEvent.LOCAL_TRANSACTION_STARTED) {
listener.localTransactionStarted(connEvent);
} else if (connEvent.getId() ==
ConnectionEvent.LOCAL_TRANSACTION_COMMITTED) {
listener.localTransactionCommitted(connEvent);
} else if (connEvent.getId() ==
ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK) {
listener.localTransactionRolledback(connEvent);
}
}
}
示例10: begin
import javax.resource.spi.ConnectionEvent; //导入依赖的package包/类
public void begin()
throws ResourceException {
checkEnv("begin");
long id = -1;
try {
Transaction txn = env.beginTransaction(null, transConfig);
env.setThreadTransaction(txn);
id = txn.getId();
} catch (DatabaseException DE) {
throw new ResourceException("During begin: " + DE.toString());
}
ConnectionEvent connEvent = new ConnectionEvent
(mgdConn, ConnectionEvent.LOCAL_TRANSACTION_STARTED);
connEvent.setConnectionHandle(mgdConn);
mgdConn.sendConnectionEvent(connEvent);
if (DEBUG) {
System.out.println("JELocalTransaction.begin " + id);
}
}
示例11: commit
import javax.resource.spi.ConnectionEvent; //导入依赖的package包/类
public void commit()
throws ResourceException {
checkEnv("commit");
try {
env.getThreadTransaction().commit();
} catch (DatabaseException DE) {
ResourceException ret = new ResourceException(DE.toString());
ret.initCause(DE);
throw ret;
} finally {
env.setThreadTransaction(null);
}
ConnectionEvent connEvent = new ConnectionEvent
(mgdConn, ConnectionEvent.LOCAL_TRANSACTION_COMMITTED);
connEvent.setConnectionHandle(mgdConn);
mgdConn.sendConnectionEvent(connEvent);
if (DEBUG) {
System.out.println("JELocalTransaction.commit");
}
}
示例12: rollback
import javax.resource.spi.ConnectionEvent; //导入依赖的package包/类
public void rollback()
throws ResourceException {
checkEnv("rollback");
try {
env.getThreadTransaction().abort();
} catch (DatabaseException DE) {
ResourceException ret = new ResourceException(DE.toString());
ret.initCause(DE);
throw ret;
} finally {
env.setThreadTransaction(null);
}
ConnectionEvent connEvent = new ConnectionEvent
(mgdConn, ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK);
connEvent.setConnectionHandle(mgdConn);
mgdConn.sendConnectionEvent(connEvent);
if (DEBUG) {
System.out.println("JELocalTransaction.rollback");
}
}
示例13: sendConnectionEvent
import javax.resource.spi.ConnectionEvent; //导入依赖的package包/类
protected void sendConnectionEvent(ConnectionEvent connEvent) {
for (int i = listeners.size() - 1; i >= 0; i--) {
ConnectionEventListener listener =
listeners.get(i);
if (connEvent.getId() == ConnectionEvent.CONNECTION_CLOSED) {
listener.connectionClosed(connEvent);
} else if (connEvent.getId() ==
ConnectionEvent.CONNECTION_ERROR_OCCURRED) {
listener.connectionErrorOccurred(connEvent);
} else if (connEvent.getId() ==
ConnectionEvent.LOCAL_TRANSACTION_STARTED) {
listener.localTransactionStarted(connEvent);
} else if (connEvent.getId() ==
ConnectionEvent.LOCAL_TRANSACTION_COMMITTED) {
listener.localTransactionCommitted(connEvent);
} else if (connEvent.getId() ==
ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK) {
listener.localTransactionRolledback(connEvent);
}
}
}
示例14: begin
import javax.resource.spi.ConnectionEvent; //导入依赖的package包/类
public void begin()
throws ResourceException {
checkEnv("begin");
long id = -1;
try {
Transaction txn = env.beginTransaction(null, transConfig);
env.setThreadTransaction(txn);
id = txn.getId();
} catch (DatabaseException DE) {
throw new ResourceException("During begin: " + DE.toString());
}
ConnectionEvent connEvent = new ConnectionEvent
(mgdConn, ConnectionEvent.LOCAL_TRANSACTION_STARTED);
connEvent.setConnectionHandle(mgdConn);
mgdConn.sendConnectionEvent(connEvent);
if (DEBUG) {
System.out.println("JELocalTransaction.begin " + id);
}
}
示例15: commit
import javax.resource.spi.ConnectionEvent; //导入依赖的package包/类
public void commit()
throws ResourceException {
checkEnv("commit");
try {
env.getThreadTransaction().commit();
} catch (DatabaseException DE) {
ResourceException ret = new ResourceException(DE.toString());
ret.initCause(DE);
throw ret;
} finally {
env.setThreadTransaction(null);
}
ConnectionEvent connEvent = new ConnectionEvent
(mgdConn, ConnectionEvent.LOCAL_TRANSACTION_COMMITTED);
connEvent.setConnectionHandle(mgdConn);
mgdConn.sendConnectionEvent(connEvent);
if (DEBUG) {
System.out.println("JELocalTransaction.commit");
}
}