From 2c418b019c8f3a9cc720c588e0268c00b86c8576 Mon Sep 17 00:00:00 2001 From: Bhupendra Bhusman Bhardwaj Date: Thu, 21 Dec 2006 11:32:58 +0000 Subject: QPID-188 Unit test for AMQProtocolSession mbean updated and closeChannel() method removed from mbean because it didn't seem to be a required feature for management console. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@489330 13f79535-47bb-0310-9956-ffa450edef68 --- .../server/protocol/AMQMinaProtocolSession.java | 7 +++++- .../qpid/server/protocol/AMQProtocolSession.java | 2 +- .../server/protocol/AMQProtocolSessionMBean.java | 29 ++++++---------------- .../qpid/server/protocol/ManagedConnection.java | 9 ------- 4 files changed, 15 insertions(+), 32 deletions(-) (limited to 'java/broker/src/main') diff --git a/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java b/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java index 6ba78ba722..7a9dfbc67c 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java +++ b/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java @@ -316,8 +316,13 @@ public class AMQMinaProtocolSession implements AMQProtocolSession, return _channelMap.get(channelId); } - public void addChannel(AMQChannel channel) + public void addChannel(AMQChannel channel) throws AMQException { + if (_closed) + { + throw new AMQException("Session is closed"); + } + _channelMap.put(channel.getChannelId(), channel); checkForNotification(); } diff --git a/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java b/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java index 03d0c50dac..a75627d240 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java +++ b/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java @@ -70,7 +70,7 @@ public interface AMQProtocolSession * @param channel the channel to associate with this session. It is an error to * associate the same channel with more than one session but this is not validated. */ - void addChannel(AMQChannel channel); + void addChannel(AMQChannel channel) throws AMQException; /** * Close a specific channel. This will remove any resources used by the channel, including: diff --git a/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java b/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java index a47d462810..d57f9b9be1 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java +++ b/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java @@ -18,6 +18,9 @@ package org.apache.qpid.server.protocol; import org.apache.qpid.AMQException; +import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.framing.ConnectionCloseBody; +import org.apache.qpid.framing.AMQFrame; import org.apache.qpid.server.AMQChannel; import org.apache.qpid.server.management.AMQManagedObject; import org.apache.qpid.server.management.MBeanConstructor; @@ -182,27 +185,6 @@ public class AMQProtocolSessionMBean extends AMQManagedObject implements Managed return channelsList; } - /** - * @see AMQMinaProtocolSession#closeChannel(int) - */ - public void closeChannel(int id) throws JMException - { - try - { - AMQChannel channel = _session.getChannel(id); - if (channel == null) - { - throw new JMException("The channel (channel Id = " + id + ") does not exist"); - } - - _session.closeChannel(id); - } - catch (AMQException ex) - { - throw new MBeanException(ex, ex.toString()); - } - } - /** * closes the connection. The administrator can use this management operation to close connection to free up * resources. @@ -210,6 +192,11 @@ public class AMQProtocolSessionMBean extends AMQManagedObject implements Managed */ public void closeConnection() throws JMException { + + final AMQFrame response = ConnectionCloseBody.createAMQFrame(0, AMQConstant.REPLY_SUCCESS.getCode(), + "Broker Management Console has closing the connection.", 0, 0); + _session.writeFrame(response); + try { _session.closeSession(); diff --git a/java/broker/src/main/java/org/apache/qpid/server/protocol/ManagedConnection.java b/java/broker/src/main/java/org/apache/qpid/server/protocol/ManagedConnection.java index 2f3102b048..1a7b7e9e96 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/protocol/ManagedConnection.java +++ b/java/broker/src/main/java/org/apache/qpid/server/protocol/ManagedConnection.java @@ -113,15 +113,6 @@ public interface ManagedConnection impact= MBeanOperationInfo.ACTION) void rollbackTransactions(@MBeanOperationParameter(name="channel Id", description="channel Id")int channelId) throws JMException; - /** - * Unsubscribes the consumers and unregisters the channel from managed objects. - */ - @MBeanOperation(name="closeChannel", - description="Closes the channel with given channel Id and connected consumers will be unsubscribed", - impact= MBeanOperationInfo.ACTION) - void closeChannel(@MBeanOperationParameter(name="channel Id", description="channel Id")int channelId) - throws Exception; - /** * Closes all the related channels and unregisters this connection from managed objects. */ -- cgit v1.2.1