当前位置: 首页>>代码示例>>Java>>正文


Java ManagedConnectionFactory.equals方法代码示例

本文整理汇总了Java中javax.resource.spi.ManagedConnectionFactory.equals方法的典型用法代码示例。如果您正苦于以下问题:Java ManagedConnectionFactory.equals方法的具体用法?Java ManagedConnectionFactory.equals怎么用?Java ManagedConnectionFactory.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.resource.spi.ManagedConnectionFactory的用法示例。


在下文中一共展示了ManagedConnectionFactory.equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: matchManagedConnections

import javax.resource.spi.ManagedConnectionFactory; //导入方法依赖的package包/类
/**
 * Returns a matched connection from the candidate set of connections.
 *
 * @param connectionSet The candidate connection set
 * @param subject       Caller's security information
 * @param cxRequestInfo Additional resource adapter specific connection request information
 * @return The managed connection
 * @throws ResourceException Thrown if the managed connection can not be found
 */
@Override
public ManagedConnection matchManagedConnections(final Set connectionSet,
                                                 final Subject subject,
                                                 final ConnectionRequestInfo cxRequestInfo) throws ResourceException {
   if (ActiveMQRAManagedConnectionFactory.trace) {
      ActiveMQRALogger.LOGGER.trace("matchManagedConnections(" + connectionSet +
                                       ", " +
                                       subject +
                                       ", " +
                                       cxRequestInfo +
                                       ")");
   }

   ActiveMQRAConnectionRequestInfo cri = getCRI((ActiveMQRAConnectionRequestInfo) cxRequestInfo);
   ActiveMQRACredential credential = ActiveMQRACredential.getCredential(this, subject, cri);

   if (ActiveMQRAManagedConnectionFactory.trace) {
      ActiveMQRALogger.LOGGER.trace("Looking for connection matching credentials: " + credential);
   }

   for (Object obj : connectionSet) {
      if (obj instanceof ActiveMQRAManagedConnection) {
         ActiveMQRAManagedConnection mc = (ActiveMQRAManagedConnection) obj;
         ManagedConnectionFactory mcf = mc.getManagedConnectionFactory();

         if ((mc.getUserName() == null || mc.getUserName() != null && mc.getUserName().equals(credential.getUserName())) && mcf.equals(this)) {
            if (cri.equals(mc.getCRI())) {
               if (ActiveMQRAManagedConnectionFactory.trace) {
                  ActiveMQRALogger.LOGGER.trace("Found matching connection: " + mc);
               }

               return mc;
            }
         }
      }
   }

   if (ActiveMQRAManagedConnectionFactory.trace) {
      ActiveMQRALogger.LOGGER.trace("No matching connection was found");
   }

   return null;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:53,代码来源:ActiveMQRAManagedConnectionFactory.java

示例2: matchManagedConnections

import javax.resource.spi.ManagedConnectionFactory; //导入方法依赖的package包/类
/**
 * Match a set of connections from the pool
 */
public ManagedConnection matchManagedConnections(Set connectionSet, Subject subject, ConnectionRequestInfo info) throws ResourceException {
    boolean trace = log.isTraceEnabled();

    // Get cred
    info = getInfo(info);
    JmsCred cred = JmsCred.getJmsCred(this, subject, info);

    if (trace)
        log.trace("Looking for connection matching credentials: " + cred);

    // Traverse the pooled connections and look for a match, return first
    // found
    Iterator connections = connectionSet.iterator();

    while (connections.hasNext()) {
        Object obj = connections.next();

        // We only care for connections of our own type
        if (obj instanceof JmsManagedConnection) {
            // This is one from the pool
            JmsManagedConnection mc = (JmsManagedConnection) obj;

            // Check if we even created this on
            ManagedConnectionFactory mcf = mc.getManagedConnectionFactory();

            // Only admit a connection if it has the same username as our
            // asked for creds

            // FIXME, Here we have a problem, jms connection
            // may be anonymous, have a user name

            if ((mc.getUserName() == null || (mc.getUserName() != null && mc.getUserName().equals(cred.name)))
                    && mcf.equals(this)) {
                // Now check if ConnectionInfo equals
                if (info.equals(mc.getInfo())) {

                    if (trace)
                        log.trace("Found matching connection: " + mc);

                    return mc;
                }
            }
        }
    }

    if (trace)
        log.trace("No matching connection was found");

    return null;
}
 
开发者ID:vratsel,项目名称:generic-jms-ra,代码行数:54,代码来源:JmsManagedConnectionFactory.java


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