diff options
author | Bhupendra Bhusman Bhardwaj <bhupendrab@apache.org> | 2007-05-02 14:19:52 +0000 |
---|---|---|
committer | Bhupendra Bhusman Bhardwaj <bhupendrab@apache.org> | 2007-05-02 14:19:52 +0000 |
commit | 42a5d17829488ac72117e763d9f2d1b83a577cc2 (patch) | |
tree | 197514040c84561e9337c4ea1654b3a7ea3b9844 | |
parent | 3739a1e857f826d6530ca234a9ac22fe13ca04e8 (diff) | |
download | qpid-python-42a5d17829488ac72117e763d9f2d1b83a577cc2.tar.gz |
Exchange MBeans updated - init method moved to super class.
Exception handling of management console updated for SecurityException.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2@534473 13f79535-47bb-0310-9956-ffa450edef68
10 files changed, 117 insertions, 146 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java index ff120e6a92..868ac31a54 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java +++ b/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java @@ -23,6 +23,13 @@ package org.apache.qpid.server.exchange; import javax.management.MalformedObjectNameException; import javax.management.NotCompliantMBeanException; import javax.management.ObjectName; +import javax.management.openmbean.OpenType; +import javax.management.openmbean.CompositeType; +import javax.management.openmbean.TabularType; +import javax.management.openmbean.TabularDataSupport; +import javax.management.openmbean.OpenDataException; +import javax.management.openmbean.SimpleType; +import javax.management.openmbean.ArrayType; import org.apache.qpid.AMQException; import org.apache.qpid.framing.AMQShortString; @@ -60,11 +67,33 @@ public abstract class AbstractExchange implements Exchange, Managable */ protected abstract class ExchangeMBean extends AMQManagedObject implements ManagedExchange { + // open mbean data types for representing exchange bindings + protected String[] _bindingItemNames; + protected String[] _bindingItemIndexNames; + protected OpenType[] _bindingItemTypes; + protected CompositeType _bindingDataType; + protected TabularType _bindinglistDataType; + protected TabularDataSupport _bindingList; + public ExchangeMBean() throws NotCompliantMBeanException { super(ManagedExchange.class, ManagedExchange.TYPE); } + protected void init() throws OpenDataException + { + _bindingItemNames = new String[]{"Binding Key", "Queue Names"}; + _bindingItemIndexNames = new String[]{_bindingItemNames[0]}; + + _bindingItemTypes = new OpenType[2]; + _bindingItemTypes[0] = SimpleType.STRING; + _bindingItemTypes[1] = new ArrayType(1, SimpleType.STRING); + _bindingDataType = new CompositeType("Exchange Binding", "Binding key and Queue names", + _bindingItemNames, _bindingItemNames, _bindingItemTypes); + _bindinglistDataType = new TabularType("Exchange Bindings", "Exchange Bindings for " + getName(), + _bindingDataType, _bindingItemIndexNames); + } + public ManagedObject getParentObject() { return _virtualHost.getManagedObject(); diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/DestNameExchange.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/DestNameExchange.java index de3905268e..ab103fbd2a 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/exchange/DestNameExchange.java +++ b/java/broker/src/main/java/org/apache/qpid/server/exchange/DestNameExchange.java @@ -64,14 +64,6 @@ public class DestNameExchange extends AbstractExchange @MBeanDescription("Management Bean for Direct Exchange") private final class DestNameExchangeMBean extends ExchangeMBean { - // open mbean data types for representing exchange bindings - private String[] _bindingItemNames = {"Routing Key", "Queue Names"}; - private String[] _bindingItemIndexNames = {_bindingItemNames[0]}; - private OpenType[] _bindingItemTypes = new OpenType[2]; - private CompositeType _bindingDataType = null; - private TabularType _bindinglistDataType = null; - private TabularDataSupport _bindingList = null; - @MBeanConstructor("Creates an MBean for AMQ direct exchange") public DestNameExchangeMBean() throws JMException { @@ -80,19 +72,6 @@ public class DestNameExchange extends AbstractExchange init(); } - /** - * initialises the OpenType objects. - */ - private void init() throws OpenDataException - { - _bindingItemTypes[0] = SimpleType.STRING; - _bindingItemTypes[1] = new ArrayType(1, SimpleType.STRING); - _bindingDataType = new CompositeType("Exchange Binding", "Routing key and Queue names", - _bindingItemNames, _bindingItemNames, _bindingItemTypes); - _bindinglistDataType = new TabularType("Exchange Bindings", "Exchange Bindings for " + getName(), - _bindingDataType, _bindingItemIndexNames); - } - public TabularData bindings() throws OpenDataException { Map<AMQShortString, List<AMQQueue>> bindings = _index.getBindingsMap(); diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/DestWildExchange.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/DestWildExchange.java index 605a4bcb61..386cfd2349 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/exchange/DestWildExchange.java +++ b/java/broker/src/main/java/org/apache/qpid/server/exchange/DestWildExchange.java @@ -61,14 +61,6 @@ public class DestWildExchange extends AbstractExchange @MBeanDescription("Management Bean for Topic Exchange") private final class DestWildExchangeMBean extends ExchangeMBean { - // open mbean data types for representing exchange bindings - private String[] _bindingItemNames = {"Routing Key", "Queue Names"}; - private String[] _bindingItemIndexNames = {_bindingItemNames[0]}; - private OpenType[] _bindingItemTypes = new OpenType[2]; - private CompositeType _bindingDataType = null; - private TabularType _bindinglistDataType = null; - private TabularDataSupport _bindingList = null; - @MBeanConstructor("Creates an MBean for AMQ topic exchange") public DestWildExchangeMBean() throws JMException { @@ -77,17 +69,6 @@ public class DestWildExchange extends AbstractExchange init(); } - /** initialises the OpenType objects. */ - private void init() throws OpenDataException - { - _bindingItemTypes[0] = SimpleType.STRING; - _bindingItemTypes[1] = new ArrayType(1, SimpleType.STRING); - _bindingDataType = new CompositeType("Exchange Binding", "Routing key and Queue names", - _bindingItemNames, _bindingItemNames, _bindingItemTypes); - _bindinglistDataType = new TabularType("Exchange Bindings", "Exchange Bindings for " + getName(), - _bindingDataType, _bindingItemIndexNames); - } - /** returns exchange bindings in tabular form */ public TabularData bindings() throws OpenDataException { diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java index 095fd2b7e9..b3690d3e10 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java +++ b/java/broker/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java @@ -41,14 +41,6 @@ public class FanoutExchange extends AbstractExchange @MBeanDescription("Management Bean for Fanout Exchange")
private final class FanoutExchangeMBean extends ExchangeMBean
{
- // open mbean data types for representing exchange bindings
- private String[] _bindingItemNames = {"Routing Key", "Queue Names"};
- private String[] _bindingItemIndexNames = {_bindingItemNames[0]};
- private OpenType[] _bindingItemTypes = new OpenType[2];
- private CompositeType _bindingDataType = null;
- private TabularType _bindinglistDataType = null;
- private TabularDataSupport _bindingList = null;
-
@MBeanConstructor("Creates an MBean for AMQ fanout exchange")
public FanoutExchangeMBean() throws JMException
{
@@ -57,19 +49,6 @@ public class FanoutExchange extends AbstractExchange init();
}
- /**
- * initialises the OpenType objects.
- */
- private void init() throws OpenDataException
- {
- _bindingItemTypes[0] = SimpleType.STRING;
- _bindingItemTypes[1] = new ArrayType(1, SimpleType.STRING);
- _bindingDataType = new CompositeType("Exchange Binding", "Routing key and Queue names",
- _bindingItemNames, _bindingItemNames, _bindingItemTypes);
- _bindinglistDataType = new TabularType("Exchange Bindings", "Exchange Bindings for " + getName(),
- _bindingDataType, _bindingItemIndexNames);
- }
-
public TabularData bindings() throws OpenDataException
{
diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java index 204e2f9f93..b4b2bc20bc 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java +++ b/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java @@ -90,14 +90,6 @@ public class HeadersExchange extends AbstractExchange @MBeanDescription("Management Bean for Headers Exchange") private final class HeadersExchangeMBean extends ExchangeMBean { - // open mbean data types for representing exchange bindings - private String[] _bindingItemNames = {"S.No.", "Queue Name", "Header Bindings"}; - private String[] _bindingItemIndexNames = {_bindingItemNames[0]}; - private OpenType[] _bindingItemTypes = new OpenType[3]; - private CompositeType _bindingDataType = null; - private TabularType _bindinglistDataType = null; - private TabularDataSupport _bindingList = null; - @MBeanConstructor("Creates an MBean for AMQ Headers exchange") public HeadersExchangeMBean() throws JMException { @@ -105,11 +97,16 @@ public class HeadersExchange extends AbstractExchange _exchangeType = "headers"; init(); } + /** * initialises the OpenType objects. */ - private void init() throws OpenDataException + protected void init() throws OpenDataException { + _bindingItemNames = new String[]{"Binding No", "Queue Name", "Queue Bindings"}; + _bindingItemIndexNames = new String[]{_bindingItemNames[0]}; + + _bindingItemTypes = new OpenType[3]; _bindingItemTypes[0] = SimpleType.INTEGER; _bindingItemTypes[1] = SimpleType.STRING; _bindingItemTypes[2] = new ArrayType(1, SimpleType.STRING); diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java index f6eace3101..0ad85dbf33 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java @@ -106,7 +106,7 @@ public abstract class ApplicationRegistry public static ServerRegistry getServerRegistry(ManagedBean mbean) { ManagedServer server = mbean.getServer(); - return _serverRegistryMap.get(server); + return getServerRegistry(server); } public static boolean isServerConnected(ManagedServer server) @@ -118,7 +118,7 @@ public abstract class ApplicationRegistry public static void serverConnectionClosed(ManagedServer server) { _closedServerList.add(server); - _serverRegistryMap.remove(server); + removeServer(server); } /* diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java index f70452dd42..53aa927299 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java @@ -22,6 +22,8 @@ package org.apache.qpid.management.ui.actions; import static org.apache.qpid.management.ui.Constants.ERROR_SERVER_CONNECTION; +import java.io.IOException; + import org.apache.qpid.management.ui.ApplicationRegistry; import org.apache.qpid.management.ui.ApplicationWorkbenchAdvisor; import org.apache.qpid.management.ui.Constants; @@ -75,8 +77,27 @@ public class AbstractAction MBeanUtility.printStackTrace(ex); if (msg == null) { - msg = ex.getMessage(); + if (ex instanceof IOException) + { + if ((ex.getMessage() != null) && (ex.getMessage().indexOf(RMI_SASL_ERROR) != -1)) + { + msg = SECURITY_FAILURE; + } + else + { + msg = SERVER_UNAVAILABLE; + } + } + else if (ex instanceof SecurityException) + { + msg = SECURITY_FAILURE; + } + else + { + msg = ex.getMessage(); + } } + if ((msg == null) && (ex.getCause() != null)) { msg = ex.getCause().getMessage(); diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java index c13f54929d..7a36ca6160 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java @@ -22,8 +22,6 @@ package org.apache.qpid.management.ui.actions; import static org.apache.qpid.management.ui.Constants.*; -import java.io.IOException; - import org.apache.qpid.management.ui.ApplicationRegistry; import org.apache.qpid.management.ui.exceptions.InfoRequiredException; import org.apache.qpid.management.ui.views.NumberVerifyListener; @@ -63,37 +61,26 @@ public class AddServer extends AbstractAction implements IWorkbenchWindowActionD public void run(IAction action) { - if(_window != null) - { - reset(); - createAddServerPopup(); - try - { - if (_addServer) - { - getNavigationView().addNewServer(_transport, _host, Integer.parseInt(_port), _domain, _user, _password); - } - } - catch(InfoRequiredException ex) - { - ViewUtility.popupInfoMessage(ACTION_ADDSERVER, ex.getMessage()); - } - catch (IOException ex) - { - if ((ex.getMessage() != null) && (ex.getMessage().indexOf(RMI_SASL_ERROR) != -1)) - { - handleException(ex, null, SECURITY_FAILURE); - } - else - { - handleException(ex, null, SERVER_UNAVAILABLE); - } - } - catch (Exception ex) + if(_window == null) + return; + + reset(); + createAddServerPopup(); + try + { + if (_addServer) { - handleException(ex, null, null); + getNavigationView().addNewServer(_transport, _host, Integer.parseInt(_port), _domain, _user, _password); } } + catch(InfoRequiredException ex) + { + ViewUtility.popupInfoMessage(ACTION_ADDSERVER, ex.getMessage()); + } + catch (Exception ex) + { + handleException(ex, null, null); + } } private void reset() diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java index 609484a557..dd9e792912 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java @@ -27,8 +27,6 @@ import static org.apache.qpid.management.ui.Constants.INFO_USERNAME; import static org.apache.qpid.management.ui.Constants.PASSWORD; import static org.apache.qpid.management.ui.Constants.USERNAME; -import java.io.IOException; - import org.apache.qpid.management.ui.ApplicationRegistry; import org.apache.qpid.management.ui.Constants; import org.apache.qpid.management.ui.exceptions.InfoRequiredException; @@ -58,45 +56,34 @@ public class ReconnectServer extends AbstractAction implements IWorkbenchWindowA public void run(IAction action) { - if(_window != null) - { - try - { - reset(); - // Check if a server node is selected to be reconnected. - TreeObject serverNode = getNavigationView().getSelectedServerNode(); - _serverName = serverNode.getName(); - _title = ACTION_LOGIN + " (" + _serverName + ")"; - - // Get the login details(username/password) - createLoginPopup(); - - if (_connect) - { - // Connect the server - getNavigationView().reconnect(_user, _password); - } - } - catch(InfoRequiredException ex) - { - ViewUtility.popupInfoMessage("Reconnect Qpid server", ex.getMessage()); - } - catch (IOException ex) - { - if ((ex.getMessage() != null) && (ex.getMessage().indexOf(RMI_SASL_ERROR) != -1)) - { - handleException(ex, null, SECURITY_FAILURE); - } - else - { - handleException(ex, null, SERVER_UNAVAILABLE); - } - } - catch (Exception ex) + if(_window == null) + return; + + try + { + reset(); + // Check if a server node is selected to be reconnected. + TreeObject serverNode = getNavigationView().getSelectedServerNode(); + _serverName = serverNode.getName(); + _title = ACTION_LOGIN + " (" + _serverName + ")"; + + // Get the login details(username/password) + createLoginPopup(); + + if (_connect) { - handleException(ex, null, null); + // Connect the server + getNavigationView().reconnect(_user, _password); } } + catch(InfoRequiredException ex) + { + ViewUtility.popupInfoMessage("Reconnect Qpid server", ex.getMessage()); + } + catch (Exception ex) + { + handleException(ex, null, null); + } } private void reset() diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java index f97568e275..f671a1dc9a 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java @@ -65,6 +65,7 @@ public class JMXServerRegistry extends ServerRegistry private JMXServiceURL _jmxUrl = null; private JMXConnector _jmxc = null; private MBeanServerConnection _mbsc = null; + private Exception _connectionException = null; private List<String> _usersList; // When an mbean gets removed from mbean server, then the notification listener @@ -175,9 +176,16 @@ public class JMXServerRegistry extends ServerRegistry long timeNow = System.currentTimeMillis(); connectorThread.join(ApplicationRegistry.timeout); - if (!_connected && (System.currentTimeMillis() - timeNow >= ApplicationRegistry.timeout)) + if (_connectionException != null) { - throw new Exception("Qpid server connection timed out"); + throw _connectionException; + } + if (!_connected) + { + if (System.currentTimeMillis() - timeNow >= ApplicationRegistry.timeout) + throw new Exception("Qpid server connection timed out"); + else + throw new Exception("Qpid server connection failed"); } } @@ -188,11 +196,14 @@ public class JMXServerRegistry extends ServerRegistry try { _connected = false; + _connectionException = null; + _jmxc.connect(); _connected = true; } catch (Exception ex) { + _connectionException = ex; MBeanUtility.printStackTrace(ex); } } @@ -205,10 +216,10 @@ public class JMXServerRegistry extends ServerRegistry { try { - if (_jmxc != null) + if (_jmxc != null && _clientListener != null) _jmxc.removeConnectionNotificationListener(_clientListener); - if (_mbsc != null) + if (_mbsc != null && _clientListener != null) _mbsc.removeNotificationListener(_serverObjectName, _clientListener); // remove mbean notification listeners @@ -219,7 +230,7 @@ public class JMXServerRegistry extends ServerRegistry } catch (ListenerNotFoundException ex) { - System.out.println(ex.toString()); + MBeanUtility.printOutput(ex.toString()); } } |