⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 outboundconnectionfactory.java

📁 一个类似于openJMS分布在ObjectWeb之下的JMS消息中间件。
💻 JAVA
字号:
/* * JORAM: Java(TM) Open Reliable Asynchronous Messaging * Copyright (C) 2004 - Bull SA * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or any later version. *  * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Lesser General Public License for more details. *  * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 * USA. * * Initial developer(s): Frederic Maistre (Bull SA) * Contributor(s): Nicolas Tachker (Bull SA) */package org.objectweb.joram.client.connector;import javax.jms.IllegalStateException;import javax.jms.JMSException;import javax.jms.JMSSecurityException;import javax.naming.Reference;import javax.resource.spi.ConnectionManager;import javax.resource.spi.ConnectionRequestInfo;import org.objectweb.util.monolog.api.BasicLevel;/** * An <code>OutboundConnectionFactory</code> instance is used for * getting a connection to an underlying JORAM server. */public class OutboundConnectionFactory implements javax.jms.ConnectionFactory,                                                  java.io.Serializable,                                                  javax.resource.Referenceable{  /** Central manager for outbound connectivity. */  protected ManagedConnectionFactoryImpl mcf;  /** Manager for connection pooling. */  protected ConnectionManager cxManager;  /** Naming reference of this instance. */  protected Reference reference;  /**   * Constructs an <code>OutboundConnectionFactory</code> instance.   *   * @param mcf        Central manager for outbound connectivity.   * @param cxManager  Manager for connection pooling.   */  OutboundConnectionFactory(ManagedConnectionFactoryImpl mcf,                            ConnectionManager cxManager) {    if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))      AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,                                     "OutboundConnectionFactory(" + mcf +                                     ", " + cxManager + ")");    this.mcf = mcf;    if (cxManager != null) {      this.cxManager = cxManager;    } else {      this.cxManager = DefaultConnectionManager.getRef();    }  }  /**   * Requests a connection for the default user, eventually returns an   * <code>OutboundConnection</code> instance.   *   * @exception JMSSecurityException   If connecting is not allowed.   * @exception IllegalStateException  If the underlying JORAM server   *                                   is not reachable.   * @exception JMSException           Generic exception.   */  public javax.jms.Connection createConnection()     throws JMSException {    if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))      AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, this + " createConnection()");    return createConnection(mcf.userName, mcf.password);  }  /**   * Requests a connection for a given user, eventually returns an   * <code>OutboundConnection</code> instance.   *   * @exception JMSSecurityException   If connecting is not allowed.   * @exception IllegalStateException  If the underlying JORAM server   *                                   is not reachable.   * @exception JMSException           Generic exception.   */  public javax.jms.Connection      createConnection(String userName, String password)    throws JMSException {    if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))      AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,                                     this + " createConnection(" + userName +                                     ", " + password + ")");    try {      ConnectionRequest cxRequest =        new ConnectionRequest(userName, password);      if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))        AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,                                       this + " createConnection cxManager = " + cxManager);      Object o = cxManager.allocateConnection(mcf, cxRequest);      if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))        AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,                                       this + " createConnection connection = " + o);      return (javax.jms.Connection) o;    } catch (javax.resource.spi.SecurityException exc) {      throw new JMSSecurityException("Invalid user identification: " + exc);    } catch (javax.resource.spi.CommException exc) {      throw new IllegalStateException("Could not connect to the JORAM server: "                                      + exc);    } catch (javax.resource.ResourceException exc) {      throw new JMSException("Could not create connection: " + exc);    }  }  /** Sets the naming reference of this factory. */  public void setReference(Reference ref)  {    this.reference = ref;  }  /** Returns the naming reference of this factory. */  public Reference getReference()  {    return reference;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -