📄 queue.java
字号:
/* * JORAM: Java(TM) Open Reliable Asynchronous Messaging * Copyright (C) 2001 - 2005 ScalAgent Distributed Technologies * Copyright (C) 2004 - 2004 Bull SA * Copyright (C) 1996 - 2000 Dyade * * 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 (INRIA) * Contributor(s): ScalAgent Distributed Technologies */package org.objectweb.joram.client.jms;import java.net.ConnectException;import java.util.Vector;import java.util.Hashtable;import java.util.Properties;import javax.jms.JMSException;import javax.naming.NamingException;import org.objectweb.util.monolog.api.BasicLevel;import org.objectweb.joram.client.jms.admin.AdminException;import org.objectweb.joram.client.jms.admin.AdminModule;import org.objectweb.joram.shared.admin.*;import fr.dyade.aaa.util.management.MXWrapper;/** * Implements the <code>javax.jms.Queue</code> interface and provides * Joram specific administration and monitoring methods. This is a proxy * object a client uses to specify the destination of messages it is * sending and the source of messages it receives. * */public class Queue extends Destination implements javax.jms.Queue, QueueMBean { private final static String QUEUE_TYPE = "queue"; public static boolean isQueue(String type) { return Destination.isAssignableTo(type, QUEUE_TYPE); } // Used by jndi2 SoapObjectHelper public Queue() {} public Queue(String name) { super(name, QUEUE_TYPE); } protected Queue(String name, String type) { super(name, type); } /** * Gets the The Joram's internal unique identifier of this queue. * API method. * * @exception JMSException Actually never thrown. * @return The Joram's internal unique identifier. */ public String getQueueName() throws JMSException { return getName(); } /** * Admin method creating and deploying (or retrieving) a queue on a * given server. First a destination with the specified name is searched * on the given server, if it does not exist it is created. In any case, * its provider-specific address is returned. * <p> * The request fails if the target server does not belong to the platform, * or if the destination deployement fails server side. * * @param serverId The identifier of the server where deploying the queue. * @param name The name of the queue. * @param className The MOM's queue class name. * @param prop The queue properties. * * @exception ConnectException If the admin connection is closed or broken. * @exception AdminException If the request fails. */ public static Queue create(int serverId, String name, String className, Properties prop) throws ConnectException, AdminException { Queue queue = new Queue(); doCreate(serverId, name, className, prop, queue, QUEUE_TYPE); StringBuffer buff = new StringBuffer(); buff.append("type=").append(QUEUE_TYPE); buff.append(",name=").append(name); try { MXWrapper.registerMBean(queue, "joramClient", buff.toString()); } catch (Exception e) { if (JoramTracing.dbgClient.isLoggable(BasicLevel.DEBUG)) JoramTracing.dbgClient.log(BasicLevel.DEBUG, "registerMBean", e); } return queue; } /** * Admin method creating and deploying a queue on a given server. * <p> * The request fails if the target server does not belong to the platform, * or if the destination deployement fails server side. * * @param serverId The identifier of the server where deploying the queue. * @param className The queue class name. * @param prop The queue properties. * * @exception ConnectException If the admin connection is closed or broken. * @exception AdminException If the request fails. */ public static Queue create(int serverId, String className, Properties prop) throws ConnectException, AdminException { return create(serverId, null, className, prop); } /** * Admin method creating and deploying a queue on a given server. * It creates a Joram's standart queue. * <p> * The request fails if the target server does not belong to the platform, * or if the destination deployement fails server side. * * @param serverId The identifier of the server where deploying the queue. * @param prop The queue properties. * * @exception ConnectException If the admin connection is closed or broken. * @exception AdminException If the request fails. */ public static Queue create(int serverId, Properties prop) throws ConnectException, AdminException { return create(serverId, "org.objectweb.joram.mom.dest.Queue", prop); } /** * Admin method creating and deploying (or retrieving) a queue on a given * server with a given name. First a destination with the specified name is * searched on the given server, if it does not exist it is created. In any * case, its provider-specific address is returned. * <p> * The request fails if the target server does not belong to the platform, * or if the destination deployement fails server side. * * @param serverId The identifier of the server where deploying the queue. * @param name The queue name. * * @exception ConnectException If the admin connection is closed or broken. * @exception AdminException If the request fails. */ public static Queue create(int serverId, String name) throws ConnectException, AdminException { return create(serverId, name, "org.objectweb.joram.mom.dest.Queue", null); } /** * Admin method creating and deploying (or retrieving) a queue on the * local server. First a destination with the specified name is searched * on the given server, if it does not exist it is created. In any case, * its provider-specific address is returned. * <p> * The request fails if the destination deployement fails server side. * * @param name The queue name. * * @exception ConnectException If the admin connection is closed or broken. * @exception AdminException If the request fails. */ public static Queue create(String name) throws ConnectException, AdminException { return create(AdminModule.getLocalServerId(), name, "org.objectweb.joram.mom.dest.Queue", null); } /** * Admin method creating and deploying a queue on a given server. * <p> * The request fails if the target server does not belong to the platform, * or if the destination deployement fails server side. * * @param serverId The identifier of the server where deploying the queue. * * @exception ConnectException If the admin connection is closed or broken. * @exception AdminException If the request fails. */ public static Queue create(int serverId) throws ConnectException, AdminException { return create(serverId, null, "org.objectweb.joram.mom.dest.Queue", null); } /** * Admin method creating and deploying a queue on the local server. * <p> * The request fails if the destination deployement fails server side. * * @exception ConnectException If the admin connection is closed or broken. * @exception AdminException If the request fails. */ public static Queue create() throws ConnectException, AdminException { return create(AdminModule.getLocalServerId()); } /** * Admin method setting or unsetting the threshold for this queue. * <p> * The request fails if the queue is deleted server side. * * @param threshold The threshold value to be set (-1 for unsetting * previous value). * * @exception ConnectException If the admin connection is closed or broken. * @exception AdminException If the request fails. */ public void setThreshold(int threshold) throws ConnectException, AdminException { if (threshold == -1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -