• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ConnectionEventListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.resource.spi.ConnectionEventListener的典型用法代码示例。如果您正苦于以下问题:Java ConnectionEventListener类的具体用法?Java ConnectionEventListener怎么用?Java ConnectionEventListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ConnectionEventListener类属于javax.resource.spi包,在下文中一共展示了ConnectionEventListener类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getNewPoolConnection

import javax.resource.spi.ConnectionEventListener; //导入依赖的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


示例2: destroyPooledConnection

import javax.resource.spi.ConnectionEventListener; //导入依赖的package包/类
/**
 * Destroys the underline physical connection to EIS.
 * 
 * @param connectionObject connection Object.
 */
@Override
void destroyPooledConnection(Object connectionObject) {
  try {
    ((ManagedConnection) connectionObject)
        .removeConnectionEventListener((ConnectionEventListener) connEventListner);
    ((ManagedConnection) connectionObject).destroy();
    connectionObject = null;
  } catch (ResourceException rex) {
    if (logger.isTraceEnabled()) {
      logger.trace(
          "ManagedPoolcacheImpl::destroyPooledConnection:Exception in closing the connection.Ignoring it. The exeption is {}",
          rex.getMessage(), rex);
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:21,代码来源:ManagedPoolCacheImpl.java


示例3: onError

import javax.resource.spi.ConnectionEventListener; //导入依赖的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();
      }
    }

  }
 
开发者ID:ampool,项目名称:monarch,代码行数:24,代码来源:JCAManagedConnection.java


示例4: onClose

import javax.resource.spi.ConnectionEventListener; //导入依赖的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


示例5: destroyPooledConnection

import javax.resource.spi.ConnectionEventListener; //导入依赖的package包/类
/**
 * Destroys the underline physical connection to EIS.
 * 
 * @param connectionObject connection Object.
 */
@Override
void destroyPooledConnection(Object connectionObject) {
  try {
    ((ManagedConnection) connectionObject)
        .removeConnectionEventListener((ConnectionEventListener) connEventListner);
    ((ManagedConnection) connectionObject).destroy();
    connectionObject = null;
  }
  catch (ResourceException rex) {
    LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
    if (writer.finerEnabled())
        writer
            .finer(
                "ManagedPoolcacheImpl::destroyPooledConnection:Exception in closing the connection.Ignoring it. The exeption is "
                    + rex.toString(), rex);
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:23,代码来源:ManagedPoolCacheImpl.java


示例6: onError

import javax.resource.spi.ConnectionEventListener; //导入依赖的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();
    }
  }

}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:25,代码来源:JCAManagedConnection.java


示例7: onClose

import javax.resource.spi.ConnectionEventListener; //导入依赖的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:gemxd,项目名称:gemfirexd-oss,代码行数:25,代码来源:JCAManagedConnection.java


示例8: connectionClosed

import javax.resource.spi.ConnectionEventListener; //导入依赖的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);
	}
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:19,代码来源:BasicManagedConnection.java


示例9: sendConnectionEvent

import javax.resource.spi.ConnectionEventListener; //导入依赖的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);
    }
}
   }
 
开发者ID:nologic,项目名称:nabs,代码行数:22,代码来源:JEManagedConnection.java


示例10: JEManagedConnection

import javax.resource.spi.ConnectionEventListener; //导入依赖的package包/类
JEManagedConnection(Subject subject, JERequestInfo jeInfo)
    throws ResourceException {

    try {
        savedTransConfig = jeInfo.getTransactionConfig();
        this.env = new XAEnvironment(jeInfo.getJERootDir(),
                                     jeInfo.getEnvConfig());
    } catch (DatabaseException DE) {
        throw new ResourceException(DE.toString());
    }
      listeners = new ArrayList<ConnectionEventListener>();
    savedLT = null;
    rwDatabaseHandleCache = new HashMap<String,Database>();
    roDatabaseHandleCache = new HashMap<String,Database>();
    rwSecondaryDatabaseHandleCache = new HashMap<String,Database>();
    roSecondaryDatabaseHandleCache = new HashMap<String,Database>();
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:18,代码来源:JEManagedConnection.java


示例11: sendConnectionEvent

import javax.resource.spi.ConnectionEventListener; //导入依赖的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);
        }
    }
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:22,代码来源:JEManagedConnection.java


示例12: fireConnectionEvent

import javax.resource.spi.ConnectionEventListener; //导入依赖的package包/类
public void fireConnectionEvent(int event) {
	ConnectionEvent connnectionEvent = new ConnectionEvent(this, event);
	connnectionEvent.setConnectionHandle(this.remoteConnection);
	for (ConnectionEventListener listener : this.listeners) {
		switch (event) {
		case LOCAL_TRANSACTION_STARTED:
			listener.localTransactionStarted(connnectionEvent);
			break;
		case LOCAL_TRANSACTION_COMMITTED:
			listener.localTransactionCommitted(connnectionEvent);
			break;
		case LOCAL_TRANSACTION_ROLLEDBACK:
			listener.localTransactionRolledback(connnectionEvent);
			break;
		case CONNECTION_CLOSED:
			listener.connectionClosed(connnectionEvent);
			break;
		default:
			throw new IllegalArgumentException("Unknown event: " + event);
		}
	}
}
 
开发者ID:scheuchzer,项目名称:outbound-connector,代码行数:23,代码来源:GenericManagedConnection.java


示例13: LazyManagedConnection

import javax.resource.spi.ConnectionEventListener; //导入依赖的package包/类
/**
 * Default constructor
 * @param localTransaction Support local transaction
 * @param xaTransaction Support XA transaction
 * @param mcf The managed connection factory
 * @param cm The connection manager
 */
public LazyManagedConnection(boolean localTransaction, boolean xaTransaction,
                             LazyManagedConnectionFactory mcf, ConnectionManager cm)
{
   this.localTransaction = localTransaction;
   this.xaTransaction = xaTransaction;
   this.enlisted = false;
   this.mcf = mcf;
   this.cm = cm;
   this.logwriter = null;
   this.listeners = Collections.synchronizedList(new ArrayList<ConnectionEventListener>(1));
   this.connection = null;
   this.lazyLocalTransaction = null;
   this.lazyXAResource = null;

   if (localTransaction)
      this.lazyLocalTransaction = new LazyLocalTransaction(this);

   if (xaTransaction)
      this.lazyXAResource = new LazyXAResource(this);
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:28,代码来源:LazyManagedConnection.java


示例14: begin

import javax.resource.spi.ConnectionEventListener; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void begin() throws ResourceException
{
   if (txBeginDuration > 0)
   {
      try
      {
         Thread.sleep(txBeginDuration);
      }
      catch (Exception e)
      {
         // Ignore
      }
   }

   ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.LOCAL_TRANSACTION_STARTED);
   
   for (ConnectionEventListener cel : listeners)
   {
      cel.localTransactionStarted(ce);
   }
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:25,代码来源:PerfManagedConnection.java


示例15: commit

import javax.resource.spi.ConnectionEventListener; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void commit() throws ResourceException
{
   if (txCommitDuration > 0)
   {
      try
      {
         Thread.sleep(txCommitDuration);
      }
      catch (Exception e)
      {
         // Ignore
      }
   }

   ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.LOCAL_TRANSACTION_COMMITTED);
   
   for (ConnectionEventListener cel : listeners)
   {
      cel.localTransactionCommitted(ce);
   }
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:25,代码来源:PerfManagedConnection.java


示例16: rollback

import javax.resource.spi.ConnectionEventListener; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void rollback() throws ResourceException
{
   if (txCommitDuration > 0)
   {
      try
      {
         Thread.sleep(txCommitDuration);
      }
      catch (Exception e)
      {
         // Ignore
      }
   }

   ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK);
   
   for (ConnectionEventListener cel : listeners)
   {
      cel.localTransactionRolledback(ce);
   }
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:25,代码来源:PerfManagedConnection.java


示例17: connectionClosed

import javax.resource.spi.ConnectionEventListener; //导入依赖的package包/类
public void connectionClosed(CI handle) {
    ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
    event.setConnectionHandle(handle);
    // count down in case sending the event results in a handle getting removed.
    if (listeners != null) {
        for (ConnectionEventListener listener : reverse(listeners)) {
            listener.connectionClosed(event);
        }
    }
    if (listener != null) {
        listener.connectionClosed(event);
    }
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:14,代码来源:AbstractManagedConnection.java


示例18: unfilteredConnectionError

import javax.resource.spi.ConnectionEventListener; //导入依赖的package包/类
protected void unfilteredConnectionError(Exception e) {
    ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_ERROR_OCCURRED, e);
    if (listeners != null) {
        for (ConnectionEventListener listener : reverse(listeners)) {
            listener.connectionErrorOccurred(event);
        }
    }
    if (listener != null) {
        listener.connectionErrorOccurred(event);
    }
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:12,代码来源:AbstractManagedConnection.java


示例19: addConnectionEventListener

import javax.resource.spi.ConnectionEventListener; //导入依赖的package包/类
public void addConnectionEventListener(ConnectionEventListener connectionEventListener) {
    if (listener == null) {
        listener = connectionEventListener;
    } else {
        if (listeners == null) {
            listeners = new ArrayDeque<>();
        }
        listeners.add(connectionEventListener);
    }
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:11,代码来源:AbstractManagedConnection.java


示例20: removeConnectionEventListener

import javax.resource.spi.ConnectionEventListener; //导入依赖的package包/类
public void removeConnectionEventListener(ConnectionEventListener connectionEventListener) {
    if (listener == connectionEventListener) {
        listener = null;
        if (listeners != null) {
            listener = listeners.removeFirst();
        }
    } else if (listeners != null) {
        listeners.remove(connectionEventListener);
    }
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:11,代码来源:AbstractManagedConnection.java



注:本文中的javax.resource.spi.ConnectionEventListener类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LinkedBuffer类代码示例发布时间:2022-05-21
下一篇:
Java OWLObjectHasSelf类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap