You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2012/03/13 16:56:54 UTC
svn commit: r1300204 [2/8] - in
/qpid/branches/java-config-and-management/qpid/java: ./
broker-plugins/experimental/shutdown/src/main/java/org/apache/qpid/shutdown/
broker-plugins/extras/src/main/java/org/apache/qpid/extras/exchanges/diagnostic/
broker...
Added: qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/ManagedObjectRegistry.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/ManagedObjectRegistry.java?rev=1300204&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/ManagedObjectRegistry.java (added)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/ManagedObjectRegistry.java Tue Mar 13 15:56:45 2012
@@ -0,0 +1,48 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.jmx;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.common.Closeable;
+
+import javax.management.JMException;
+import java.io.IOException;
+
+/**
+ * Handles the registration (and unregistration and so on) of managed objects.
+ *
+ * Managed objects are responsible for exposting attributes, operations and notifications. They will expose
+ * these outside the JVM therefore it is important not to use implementation objects directly as managed objects.
+ * Instead, creating inner classes and exposing those is an effective way of exposing internal state in a
+ * controlled way.
+ *
+ * Although we do not explictly use them while targetting Java 5, the enhanced MXBean approach in Java 6 will
+ * be the obvious choice for managed objects.
+ *
+ */
+public interface ManagedObjectRegistry extends Closeable
+{
+ void start() throws IOException, ConfigurationException;
+
+ void registerObject(ManagedObject managedObject) throws JMException;
+
+ void unregisterObject(ManagedObject managedObject) throws JMException;
+}
Copied: qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ConfigurationManagementMBean.java (from r1300169, qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/management/ConfigurationManagementMBean.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ConfigurationManagementMBean.java?p2=qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ConfigurationManagementMBean.java&p1=qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/management/ConfigurationManagementMBean.java&r1=1300169&r2=1300204&rev=1300204&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/management/ConfigurationManagementMBean.java (original)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ConfigurationManagementMBean.java Tue Mar 13 15:56:45 2012
@@ -18,20 +18,24 @@
* under the License.
*
*/
-package org.apache.qpid.server.configuration.management;
+package org.apache.qpid.server.jmx.mbeans;
import org.apache.qpid.management.common.mbeans.ConfigurationManagement;
-import org.apache.qpid.server.management.AMQManagedObject;
+import org.apache.qpid.server.jmx.AMQManagedObject;
+import org.apache.qpid.server.jmx.ManagedObject;
+import org.apache.qpid.server.jmx.ManagedObjectRegistry;
import org.apache.qpid.server.registry.ApplicationRegistry;
+import javax.management.JMException;
import javax.management.NotCompliantMBeanException;
public class ConfigurationManagementMBean extends AMQManagedObject implements ConfigurationManagement
{
- public ConfigurationManagementMBean() throws NotCompliantMBeanException
+ public ConfigurationManagementMBean(ManagedObjectRegistry registry) throws JMException
{
- super(ConfigurationManagement.class, ConfigurationManagement.TYPE);
+ super(ConfigurationManagement.class, ConfigurationManagement.TYPE, registry);
+ register();
}
public String getObjectInstanceName()
@@ -44,4 +48,9 @@ public class ConfigurationManagementMBea
ApplicationRegistry.getInstance().getConfiguration().reparseConfigFileSecuritySections();
}
+ @Override
+ public ManagedObject getParentObject()
+ {
+ return null;
+ }
}
Added: qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ConnectionMBean.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ConnectionMBean.java?rev=1300204&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ConnectionMBean.java (added)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ConnectionMBean.java Tue Mar 13 15:56:45 2012
@@ -0,0 +1,185 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.qpid.server.jmx.mbeans;
+
+import org.apache.qpid.management.common.mbeans.ManagedConnection;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanOperationParameter;
+import org.apache.qpid.server.jmx.AMQManagedObject;
+import org.apache.qpid.server.jmx.ManagedObject;
+import org.apache.qpid.server.model.Connection;
+
+import javax.management.JMException;
+import javax.management.openmbean.TabularData;
+import java.io.IOException;
+import java.util.Date;
+
+public class ConnectionMBean extends AMQManagedObject implements ManagedConnection
+{
+ private final VirtualHostMBean _virtualHostMBean;
+ private final Connection _connection;
+
+ public ConnectionMBean(Connection conn, VirtualHostMBean virtualHostMBean) throws JMException
+ {
+ super(ManagedConnection.class, ManagedConnection.TYPE, virtualHostMBean.getRegistry());
+ _virtualHostMBean = virtualHostMBean;
+ _connection = conn;
+ register();
+ }
+
+ public String getObjectInstanceName()
+ {
+ return _connection.getName();
+ }
+
+ @Override
+ public ManagedObject getParentObject()
+ {
+ return _virtualHostMBean;
+ }
+
+ public String getClientId()
+ {
+ return null; // TODO - Implement
+ }
+
+ public String getAuthorizedId()
+ {
+ return null; // TODO - Implement
+ }
+
+ public String getVersion()
+ {
+ return null; // TODO - Implement
+ }
+
+ public String getRemoteAddress()
+ {
+ return null; // TODO - Implement
+ }
+
+ public Date getLastIoTime()
+ {
+ return null; // TODO - Implement
+ }
+
+ public Long getMaximumNumberOfChannels()
+ {
+ return null; // TODO - Implement
+ }
+
+ public TabularData channels() throws IOException, JMException
+ {
+ return null; // TODO - Implement
+ }
+
+ public void commitTransactions(
+ @MBeanOperationParameter(name = "channel Id", description = "channel Id") int channelId) throws JMException
+ {
+ // TODO - Implement
+ }
+
+ public void rollbackTransactions(
+ @MBeanOperationParameter(name = "channel Id", description = "channel Id") int channelId) throws JMException
+ {
+ // TODO - Implement
+ }
+
+ public void closeConnection() throws Exception
+ {
+ // TODO - Implement
+ }
+
+ public void resetStatistics() throws Exception
+ {
+ // TODO - Implement
+ }
+
+ public double getPeakMessageDeliveryRate()
+ {
+ return 0; // TODO - Implement
+ }
+
+ public double getPeakDataDeliveryRate()
+ {
+ return 0; // TODO - Implement
+ }
+
+ public double getMessageDeliveryRate()
+ {
+ return 0; // TODO - Implement
+ }
+
+ public double getDataDeliveryRate()
+ {
+ return 0; // TODO - Implement
+ }
+
+ public long getTotalMessagesDelivered()
+ {
+ return 0; // TODO - Implement
+ }
+
+ public long getTotalDataDelivered()
+ {
+ return 0; // TODO - Implement
+ }
+
+ public double getPeakMessageReceiptRate()
+ {
+ return 0; // TODO - Implement
+ }
+
+ public double getPeakDataReceiptRate()
+ {
+ return 0; // TODO - Implement
+ }
+
+ public double getMessageReceiptRate()
+ {
+ return 0; // TODO - Implement
+ }
+
+ public double getDataReceiptRate()
+ {
+ return 0; // TODO - Implement
+ }
+
+ public long getTotalMessagesReceived()
+ {
+ return 0; // TODO - Implement
+ }
+
+ public long getTotalDataReceived()
+ {
+ return 0; // TODO - Implement
+ }
+
+ public boolean isStatisticsEnabled()
+ {
+ return false; // TODO - Implement
+ }
+
+ public void setStatisticsEnabled(boolean enabled)
+ {
+ // TODO - Implement
+ }
+}
Added: qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBean.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBean.java?rev=1300204&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBean.java (added)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBean.java Tue Mar 13 15:56:45 2012
@@ -0,0 +1,271 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.qpid.server.jmx.mbeans;
+
+import org.apache.qpid.management.common.mbeans.ManagedExchange;
+import org.apache.qpid.management.common.mbeans.ManagedQueue;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanOperationParameter;
+import org.apache.qpid.server.jmx.AMQManagedObject;
+import org.apache.qpid.server.jmx.ManagedObject;
+import org.apache.qpid.server.model.Binding;
+import org.apache.qpid.server.model.Exchange;
+import org.apache.qpid.server.model.LifetimePolicy;
+import org.apache.qpid.server.model.Queue;
+
+import javax.management.JMException;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ExchangeMBean extends AMQManagedObject implements ManagedExchange
+{
+
+ private static final String[] TABULAR_UNIQUE_INDEX_ARRAY =
+ TABULAR_UNIQUE_INDEX.toArray(new String[TABULAR_UNIQUE_INDEX.size()]);
+
+ private static final String[] COMPOSITE_ITEM_NAMES_ARRAY =
+ COMPOSITE_ITEM_NAMES.toArray(new String[COMPOSITE_ITEM_NAMES.size()]);
+
+ private static final String[] COMPOSITE_ITEM_DESCRIPTIONS_ARRAY =
+ COMPOSITE_ITEM_DESCRIPTIONS.toArray(new String[COMPOSITE_ITEM_DESCRIPTIONS.size()]);
+
+ private static final OpenType[] BINDING_ITEM_TYPES;
+ private static final CompositeType BINDING_DATA_TYPE;
+ private static final OpenType[] HEADERS_BINDING_ITEM_TYPES;
+
+
+ private static final CompositeType HEADERS_BINDING_DATA_TYPE;
+
+ private static final String[] HEADERS_COMPOSITE_ITEM_NAMES_ARRAY =
+ HEADERS_COMPOSITE_ITEM_NAMES.toArray(new String[HEADERS_COMPOSITE_ITEM_NAMES.size()]);
+
+ private static final String[] HEADERS_COMPOSITE_ITEM_DESCS_ARRAY =
+ HEADERS_COMPOSITE_ITEM_DESC.toArray(new String[HEADERS_COMPOSITE_ITEM_DESC.size()]);
+ private static final String[] HEADERS_TABULAR_UNIQUE_INDEX_ARRAY =
+ HEADERS_TABULAR_UNIQUE_INDEX.toArray(new String[HEADERS_TABULAR_UNIQUE_INDEX.size()]);
+
+ static
+ {
+ try
+ {
+ BINDING_ITEM_TYPES = new OpenType[] {SimpleType.STRING, new ArrayType(1, SimpleType.STRING)};
+
+ BINDING_DATA_TYPE= new CompositeType("Exchange Binding", "Binding key and Queue names",
+ COMPOSITE_ITEM_NAMES_ARRAY,
+ COMPOSITE_ITEM_DESCRIPTIONS_ARRAY,
+ BINDING_ITEM_TYPES);
+
+ HEADERS_BINDING_ITEM_TYPES = new OpenType[] {SimpleType.INTEGER,
+ SimpleType.STRING,
+ new ArrayType(1, SimpleType.STRING)};
+
+ HEADERS_BINDING_DATA_TYPE = new CompositeType("Exchange Binding", "Queue name and header bindings",
+ HEADERS_COMPOSITE_ITEM_NAMES_ARRAY,
+ HEADERS_COMPOSITE_ITEM_DESCS_ARRAY,
+ HEADERS_BINDING_ITEM_TYPES);
+
+
+ }
+ catch(OpenDataException e)
+ {
+ throw new RuntimeException("Unexpected Error creating ArrayType", e);
+ }
+ }
+
+
+ private final Exchange _exchange;
+ private final VirtualHostMBean _vhostMBean;
+
+ protected ExchangeMBean(Exchange exchange, VirtualHostMBean virtualHostMBean)
+ throws JMException
+ {
+ super(ManagedExchange.class, ManagedExchange.TYPE, virtualHostMBean.getRegistry());
+ _exchange = exchange;
+ _vhostMBean = virtualHostMBean;
+
+ register();
+ }
+
+ public String getObjectInstanceName()
+ {
+ return ObjectName.quote(getName());
+ }
+
+ @Override
+ public ManagedObject getParentObject()
+ {
+ return _vhostMBean;
+ }
+
+ public ObjectName getObjectName() throws MalformedObjectNameException
+ {
+ String objNameString = super.getObjectName().toString();
+ objNameString = objNameString + ",ExchangeType=" + getExchangeType();
+ return new ObjectName(objNameString);
+ }
+
+
+ public String getName()
+ {
+ return _exchange.getName();
+ }
+
+ public String getExchangeType()
+ {
+ return _exchange.getExchangeType();
+ }
+
+ public Integer getTicketNo()
+ {
+ return 0;
+ }
+
+ public boolean isDurable()
+ {
+ return _exchange.isDurable();
+ }
+
+ public boolean isAutoDelete()
+ {
+ return _exchange.getLifetimePolicy() == LifetimePolicy.AUTO_DELETE;
+ }
+
+ public TabularData bindings() throws IOException, JMException
+ {
+ if("headers".equals(_exchange.getExchangeType()))
+ {
+ return getHeadersBindings(_exchange.getBindings());
+ }
+ else
+ {
+ return getNonHeadersBindings(_exchange.getBindings());
+ }
+ }
+
+
+ private TabularData getHeadersBindings(Collection<Binding> bindings) throws OpenDataException
+ {
+ TabularType bindinglistDataType =
+ new TabularType("Exchange Bindings", "List of exchange bindings for " + getName(),
+ HEADERS_BINDING_DATA_TYPE,
+ HEADERS_TABULAR_UNIQUE_INDEX_ARRAY);
+
+ TabularDataSupport bindingList = new TabularDataSupport(bindinglistDataType);
+ int count = 1;
+ for (Binding binding : bindings)
+ {
+
+ String queueName = binding.getParent(Queue.class).getName();
+
+
+ Map<String,Object> headerMappings = binding.getArguments();
+
+ final List<String> mappingList = new ArrayList<String>();
+
+ if(headerMappings != null)
+ {
+ for(Map.Entry<String,Object> entry : headerMappings.entrySet())
+ {
+
+ mappingList.add(entry.getKey() + "=" + entry.getValue());
+ }
+ }
+
+
+ Object[] bindingItemValues = {count++, queueName, mappingList.toArray(new String[0])};
+ CompositeData bindingData = new CompositeDataSupport(HEADERS_BINDING_DATA_TYPE,
+ HEADERS_COMPOSITE_ITEM_NAMES_ARRAY,
+ bindingItemValues);
+ bindingList.put(bindingData);
+ }
+
+ return bindingList;
+
+ }
+
+ private TabularData getNonHeadersBindings(Collection<Binding> bindings) throws OpenDataException
+ {
+
+ TabularType bindinglistDataType =
+ new TabularType("Exchange Bindings", "Exchange Bindings for " + getName(),
+ BINDING_DATA_TYPE,
+ TABULAR_UNIQUE_INDEX_ARRAY);
+
+ TabularDataSupport bindingList = new TabularDataSupport(bindinglistDataType);
+
+ Map<String, List<String>> bindingMap = new HashMap<String, List<String>>();
+
+ for (Binding binding : bindings)
+ {
+ String key = "fanout".equals(_exchange.getExchangeType()) ? "*" : binding.getName();
+ List<String> queueList = bindingMap.get(key);
+ if(queueList == null)
+ {
+ queueList = new ArrayList<String>();
+ bindingMap.put(key, queueList);
+ }
+ queueList.add(binding.getParent(Queue.class).getName());
+
+ }
+
+ for(Map.Entry<String, List<String>> entry : bindingMap.entrySet())
+ {
+ Object[] bindingItemValues = {entry.getKey(), entry.getValue().toArray(new String[0])};
+ CompositeData bindingData = new CompositeDataSupport(BINDING_DATA_TYPE,
+ COMPOSITE_ITEM_NAMES_ARRAY,
+ bindingItemValues);
+ bindingList.put(bindingData);
+ }
+
+ return bindingList;
+ }
+
+ public void createNewBinding(
+ @MBeanOperationParameter(name = ManagedQueue.TYPE, description = "Queue name") String queueName,
+ @MBeanOperationParameter(name = "Binding", description = "New binding") String binding) throws JMException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void removeBinding(
+ @MBeanOperationParameter(name = ManagedQueue.TYPE, description = "Queue name") String queueName,
+ @MBeanOperationParameter(name = "Binding", description = "Binding key") String binding)
+ throws IOException, JMException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
Copied: qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/LoggingManagementMBean.java (from r1300169, qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/LoggingManagementMBean.java?p2=qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/LoggingManagementMBean.java&p1=qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java&r1=1300169&r2=1300204&rev=1300204&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java (original)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/LoggingManagementMBean.java Tue Mar 13 15:56:45 2012
@@ -18,7 +18,7 @@
*
*
*/
-package org.apache.qpid.server.logging.management;
+package org.apache.qpid.server.jmx.mbeans;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
@@ -27,16 +27,17 @@ import org.apache.log4j.xml.Log4jEntityR
import org.apache.log4j.xml.QpidLog4JConfigurator;
import org.apache.log4j.xml.QpidLog4JConfigurator.IllegalLoggerLevelException;
import org.apache.log4j.xml.QpidLog4JConfigurator.QpidLog4JSaxErrorHandler;
+import org.apache.qpid.management.common.mbeans.LoggingManagement;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
+import org.apache.qpid.server.jmx.AMQManagedObject;
+import org.apache.qpid.server.jmx.ManagedObject;
+import org.apache.qpid.server.jmx.ManagedObjectRegistry;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
-import org.apache.qpid.management.common.mbeans.LoggingManagement;
-import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
-import org.apache.qpid.server.management.AMQManagedObject;
-
import javax.management.JMException;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataSupport;
@@ -107,11 +108,14 @@ public class LoggingManagementMBean exte
}
}
- public LoggingManagementMBean(String log4jConfigFileName, int log4jLogWatchInterval) throws JMException
+ public LoggingManagementMBean(String log4jConfigFileName,
+ int log4jLogWatchInterval,
+ ManagedObjectRegistry registry) throws JMException
{
- super(LoggingManagement.class, LoggingManagement.TYPE);
+ super(LoggingManagement.class, LoggingManagement.TYPE, registry);
_log4jConfigFileName = log4jConfigFileName;
_log4jLogWatchInterval = log4jLogWatchInterval;
+ register();
}
public String getObjectInstanceName()
@@ -819,4 +823,10 @@ public class LoggingManagementMBean exte
LOCK.unlock();
}
}
+
+ @Override
+ public ManagedObject getParentObject()
+ {
+ return null;
+ }
}
Added: qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java?rev=1300204&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java (added)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java Tue Mar 13 15:56:45 2012
@@ -0,0 +1,255 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.qpid.server.jmx.mbeans;
+
+import org.apache.qpid.management.common.mbeans.ManagedQueue;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanOperationParameter;
+import org.apache.qpid.server.jmx.AMQManagedObject;
+import org.apache.qpid.server.jmx.ManagedObject;
+import org.apache.qpid.server.jmx.ManagedObjectRegistry;
+import org.apache.qpid.server.model.LifetimePolicy;
+import org.apache.qpid.server.model.Queue;
+
+import javax.management.JMException;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+import java.io.IOException;
+
+public class QueueMBean extends AMQManagedObject implements ManagedQueue
+{
+ private final Queue _queue;
+ private final VirtualHostMBean _vhostMBean;
+
+ public QueueMBean(Queue queue, VirtualHostMBean virtualHostMBean) throws JMException
+ {
+ super(ManagedQueue.class, ManagedQueue.TYPE, virtualHostMBean.getRegistry());
+ _queue = queue;
+ _vhostMBean = virtualHostMBean;
+ register();
+ }
+
+ public ManagedObject getParentObject()
+ {
+ return _vhostMBean;
+ }
+
+ public String getObjectInstanceName()
+ {
+ return ObjectName.quote(getName());
+ }
+
+ public String getName()
+ {
+ return _queue.getName();
+ }
+
+ public Integer getMessageCount() throws IOException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Integer getMaximumDeliveryCount() throws IOException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Long getReceivedMessageCount() throws IOException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Long getQueueDepth() throws IOException, JMException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Integer getActiveConsumerCount() throws IOException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Integer getConsumerCount() throws IOException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public String getOwner() throws IOException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean isDurable() throws IOException
+ {
+ return _queue.isDurable();
+ }
+
+ public boolean isAutoDelete() throws IOException
+ {
+ return _queue.getLifetimePolicy() == LifetimePolicy.AUTO_DELETE;
+ }
+
+ public Long getMaximumMessageAge() throws IOException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setMaximumMessageAge(Long age) throws IOException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Long getMaximumMessageSize() throws IOException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setMaximumMessageSize(Long size) throws IOException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Long getMaximumMessageCount() throws IOException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setMaximumMessageCount(Long value) throws IOException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Long getMaximumQueueDepth() throws IOException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setMaximumQueueDepth(Long value) throws IOException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Long getCapacity() throws IOException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setCapacity(Long value) throws IOException, IllegalArgumentException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Long getFlowResumeCapacity() throws IOException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setFlowResumeCapacity(Long value) throws IOException, IllegalArgumentException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean isFlowOverfull() throws IOException
+ {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean isExclusive() throws IOException
+ {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setExclusive(boolean exclusive) throws IOException, JMException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setAlternateExchange(String exchangeName) throws IOException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public String getAlternateExchange() throws IOException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public TabularData viewMessages(
+ @MBeanOperationParameter(name = "from index", description = "from index") int fromIndex,
+ @MBeanOperationParameter(name = "to index", description = "to index") int toIndex)
+ throws IOException, JMException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public TabularData viewMessages(
+ @MBeanOperationParameter(name = "start position", description = "start position") long startPosition,
+ @MBeanOperationParameter(name = "end position", description = "end position") long endPosition)
+ throws IOException, JMException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public CompositeData viewMessageContent(
+ @MBeanOperationParameter(name = "Message Id", description = "Message Id") long messageId)
+ throws IOException, JMException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void deleteMessageFromTop() throws IOException, JMException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Long clearQueue() throws IOException, JMException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void moveMessages(
+ @MBeanOperationParameter(name = "from MessageId", description = "from MessageId") long fromMessageId,
+ @MBeanOperationParameter(name = "to MessageId", description = "to MessageId") long toMessageId,
+ @MBeanOperationParameter(name = ManagedQueue.TYPE, description = "to Queue Name") String toQueue)
+ throws IOException, JMException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void deleteMessages(
+ @MBeanOperationParameter(name = "from MessageId", description = "from MessageId") long fromMessageId,
+ @MBeanOperationParameter(name = "to MessageId", description = "to MessageId") long toMessageId)
+ throws IOException, JMException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void copyMessages(
+ @MBeanOperationParameter(name = "from MessageId", description = "from MessageId") long fromMessageId,
+ @MBeanOperationParameter(name = "to MessageId", description = "to MessageId") long toMessageId,
+ @MBeanOperationParameter(name = ManagedQueue.TYPE, description = "to Queue Name") String toQueue)
+ throws IOException, JMException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
Copied: qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/Shutdown.java (from r1300169, qpid/branches/java-config-and-management/qpid/java/broker-plugins/experimental/shutdown/src/main/java/org/apache/qpid/shutdown/Shutdown.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/Shutdown.java?p2=qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/Shutdown.java&p1=qpid/branches/java-config-and-management/qpid/java/broker-plugins/experimental/shutdown/src/main/java/org/apache/qpid/shutdown/Shutdown.java&r1=1300169&r2=1300204&rev=1300204&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/experimental/shutdown/src/main/java/org/apache/qpid/shutdown/Shutdown.java (original)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/Shutdown.java Tue Mar 13 15:56:45 2012
@@ -17,8 +17,15 @@
* under the License.
*
*/
-package org.apache.qpid.shutdown;
+package org.apache.qpid.server.jmx.mbeans;
+import org.apache.log4j.Logger;
+import org.apache.qpid.server.jmx.DefaultManagedObject;
+import org.apache.qpid.server.jmx.ManagedObject;
+import org.apache.qpid.server.jmx.ManagedObjectRegistry;
+
+import javax.management.JMException;
+import javax.management.NotCompliantMBeanException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -27,11 +34,6 @@ import java.util.concurrent.ScheduledExe
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
-import javax.management.NotCompliantMBeanException;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.server.management.DefaultManagedObject;
-
/**
* Implementation of the JMX broker shutdown plugin.
*/
@@ -46,9 +48,10 @@ public class Shutdown extends DefaultMan
private final Runnable _shutdown = new SystemExiter();
- public Shutdown() throws NotCompliantMBeanException
+ public Shutdown(ManagedObjectRegistry registry) throws JMException
{
- super(ShutdownMBean.class, ShutdownMBean.TYPE);
+ super(ShutdownMBean.class, ShutdownMBean.TYPE, registry);
+ register();
}
/** @see ShutdownMBean#shutdown() */
@@ -108,6 +111,12 @@ public class Shutdown extends DefaultMan
EXECUTOR.schedule(_shutdown, delay, TimeUnit.MILLISECONDS);
}
+ @Override
+ public ManagedObject getParentObject()
+ {
+ return null;
+ }
+
/**
* Shutting down the system in another thread to avoid JMX exceptions being thrown.
*/
@@ -122,7 +131,6 @@ public class Shutdown extends DefaultMan
/**
* @see org.apache.qpid.server.management.ManagedObject#getObjectInstanceName()
*/
- @Override
public String getObjectInstanceName()
{
return "Shutdown";
Added: qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ShutdownMBean.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ShutdownMBean.java?rev=1300204&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ShutdownMBean.java (added)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ShutdownMBean.java Tue Mar 13 15:56:45 2012
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.jmx.mbeans;
+
+import org.apache.qpid.management.common.mbeans.annotations.MBeanOperation;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanOperationParameter;
+
+import javax.management.MBeanOperationInfo;
+
+/**
+ * Shutdown plugin JMX MBean interface.
+ *
+ * Shuts the Qpid broker down via JMX.
+ */
+public interface ShutdownMBean
+{
+ static final String TYPE = "Shutdown";
+
+ /**
+ * Broker will be shut down immediately.
+ */
+ @MBeanOperation(name="shutdown", description="Shut down immediately", impact = MBeanOperationInfo.ACTION)
+ public void shutdown();
+
+ /**
+ * Broker will be shutdown after the specified delay
+ *
+ * @param delay the number of ms to wait
+ */
+ @MBeanOperation(name="shutdown", description="Shutdown after the specified delay (ms)", impact = MBeanOperationInfo.ACTION)
+ public void shutdown(@MBeanOperationParameter(name = "when", description = "delay (ms)") long delay);
+
+ /**
+ * Broker will be shutdown at the specified date and time.
+ *
+ * @param when the date and time to shutdown
+ */
+ @MBeanOperation(name="shutdownAt", description="Shutdown at the specified date and time (yyyy/MM/dd HH:mm:ss)", impact = MBeanOperationInfo.ACTION)
+ public void shutdownAt(@MBeanOperationParameter(name = "when",
+ description = "shutdown date/time (yyyy/MM/dd HH:mm:ss)") String when);
+}
Added: qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostMBean.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostMBean.java?rev=1300204&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostMBean.java (added)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostMBean.java Tue Mar 13 15:56:45 2012
@@ -0,0 +1,208 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.qpid.server.jmx.mbeans;
+
+import org.apache.qpid.server.jmx.AMQManagedObject;
+import org.apache.qpid.server.jmx.ManagedObject;
+import org.apache.qpid.server.jmx.ManagedObjectRegistry;
+import org.apache.qpid.server.model.ConfigurationChangeListener;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.Connection;
+import org.apache.qpid.server.model.Exchange;
+import org.apache.qpid.server.model.Queue;
+import org.apache.qpid.server.model.State;
+import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.virtualhost.ManagedVirtualHost;
+
+import javax.management.JMException;
+import javax.management.ObjectName;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+public class VirtualHostMBean extends AMQManagedObject implements ManagedVirtualHost, ConfigurationChangeListener
+{
+ private final VirtualHost _virtualHost;
+
+ private final Map<ConfiguredObject, AMQManagedObject> _children =
+ new HashMap<ConfiguredObject, AMQManagedObject>();
+ private VirtualHostManagerMBean _managerMBean;
+
+ public VirtualHostMBean(VirtualHost virtualHost, ManagedObjectRegistry registry) throws JMException
+ {
+ super(ManagedVirtualHost.class, ManagedVirtualHost.TYPE, registry);
+ _virtualHost = virtualHost;
+ //register();
+ virtualHost.addChangeListener(this);
+
+ initQueues();
+ initExchanges();
+ initConnections();
+
+ _managerMBean = new VirtualHostManagerMBean(this);
+ }
+
+ private void initQueues() throws JMException
+ {
+ synchronized (_children)
+ {
+ for(Queue queue : _virtualHost.getQueues())
+ {
+ if(!_children.containsKey(queue))
+ {
+ _children.put(queue, new QueueMBean(queue, this));
+ }
+ }
+ }
+ }
+
+ private void initExchanges() throws JMException
+ {
+ synchronized (_children)
+ {
+ for(Exchange exchange : _virtualHost.getExchanges())
+ {
+ if(!_children.containsKey(exchange))
+ {
+ _children.put(exchange, new ExchangeMBean(exchange, this));
+ }
+ }
+ }
+ }
+
+ private void initConnections() throws JMException
+ {
+ synchronized (_children)
+ {
+ for(Connection conn : _virtualHost.getConnections())
+ {
+ if(!_children.containsKey(conn))
+ {
+ _children.put(conn, new ConnectionMBean(conn, this));
+ }
+ }
+ }
+ }
+
+ public String getObjectInstanceName()
+ {
+ return ObjectName.quote(_virtualHost.getName());
+ }
+
+ public String getName()
+ {
+ return _virtualHost.getName();
+ }
+
+ public void stateChanged(ConfiguredObject object, State oldState, State newState)
+ {
+ // ignore
+ }
+
+ public void childAdded(ConfiguredObject object, ConfiguredObject child)
+ {
+ synchronized (_children)
+ {
+ try
+ {
+ if(child instanceof Queue)
+ {
+ QueueMBean queueMB = new QueueMBean((Queue)child, this);
+ _children.put(child, queueMB);
+
+ }
+ else if(child instanceof Exchange)
+ {
+ ExchangeMBean exchangeMBean = new ExchangeMBean((Exchange)child, this);
+ _children.put(child, exchangeMBean);
+
+ }
+ if(child instanceof Connection)
+ {
+ ConnectionMBean connectionMBean = new ConnectionMBean((Connection)child, this);
+ _children.put(child, connectionMBean);
+
+ }
+ else
+ {
+
+ }
+
+ }
+ catch(JMException e)
+ {
+ e.printStackTrace(); //TODO
+ }
+ }
+ }
+
+ public void childRemoved(ConfiguredObject object, ConfiguredObject child)
+ {
+ synchronized (_children)
+ {
+ AMQManagedObject mbean = _children.remove(child);
+ if(mbean != null)
+ {
+ try
+ {
+ mbean.unregister();
+ }
+ catch(JMException e)
+ {
+ e.printStackTrace(); //TODO
+ }
+ }
+ }
+ }
+
+ @Override
+ public ManagedObject getParentObject()
+ {
+ return null;
+ }
+
+ protected VirtualHost getVirtualHost()
+ {
+ return _virtualHost;
+ }
+
+ public Collection<QueueMBean> getQueues()
+ {
+ Collection<AMQManagedObject> children;
+ synchronized (_children)
+ {
+ children = new ArrayList<AMQManagedObject>(_children.values());
+ }
+ Collection<QueueMBean> queues = new ArrayList<QueueMBean>();
+
+ for(AMQManagedObject child : children)
+ {
+ if(child instanceof QueueMBean)
+ {
+ queues.add((QueueMBean) child);
+ }
+ }
+
+ return queues;
+ }
+}
Added: qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBean.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBean.java?rev=1300204&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBean.java (added)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBean.java Tue Mar 13 15:56:45 2012
@@ -0,0 +1,238 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.qpid.server.jmx.mbeans;
+
+import org.apache.qpid.management.common.mbeans.ManagedBroker;
+import org.apache.qpid.management.common.mbeans.ManagedExchange;
+import org.apache.qpid.management.common.mbeans.ManagedQueue;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanConstructor;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanOperationParameter;
+import org.apache.qpid.server.jmx.AMQManagedObject;
+import org.apache.qpid.server.jmx.ManagedObject;
+import org.apache.qpid.server.model.Queue;
+
+import javax.management.JMException;
+import javax.management.MBeanException;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+@MBeanDescription("This MBean exposes the broker level management features")
+public class VirtualHostManagerMBean extends AMQManagedObject implements ManagedBroker
+{
+
+ private final VirtualHostMBean _virtualHostMBean;
+
+ @MBeanConstructor("Creates the Broker Manager MBean")
+ public VirtualHostManagerMBean(VirtualHostMBean virtualHostMBean) throws JMException
+ {
+ super(ManagedBroker.class, ManagedBroker.TYPE, virtualHostMBean.getRegistry());
+ _virtualHostMBean = virtualHostMBean;
+ register();
+ }
+
+ public String getObjectInstanceName()
+ {
+ return _virtualHostMBean.getName();
+ }
+
+ @Override
+ public ManagedObject getParentObject()
+ {
+ return _virtualHostMBean;
+ }
+
+ public String[] getExchangeTypes() throws IOException
+ {
+ return new String[0]; //TODO
+ }
+
+ public List<String> retrieveQueueAttributeNames() throws IOException
+ {
+ return ManagedQueue.QUEUE_ATTRIBUTES;
+ }
+
+ public List<List<Object>> retrieveQueueAttributeValues(
+ @MBeanOperationParameter(name = "attributes", description = "Attributes to retrieve") String[] attributes)
+ throws IOException
+ {
+ int attributesLength = attributes.length;
+
+ List<List<Object>> queueAttributesList = new ArrayList<List<Object>>();
+
+ for(QueueMBean queue : _virtualHostMBean.getQueues())
+ {
+
+ if(queue == null)
+ {
+ continue;
+ }
+
+ List<Object> attributeValues = new ArrayList<Object>(attributesLength);
+
+ for(int i=0; i < attributesLength; i++)
+ {
+ try
+ {
+ attributeValues.add(queue.getAttribute(attributes[i]));
+ }
+ catch (Exception e)
+ {
+ attributeValues.add("-");
+ }
+ }
+
+ queueAttributesList.add(attributeValues);
+ }
+
+ return queueAttributesList;
+
+ }
+
+ public void createNewExchange(
+ @MBeanOperationParameter(name = "name", description = "Name of the new exchange") String name,
+ @MBeanOperationParameter(name = "ExchangeType", description = "Type of the exchange") String type,
+ @MBeanOperationParameter(name = "durable",
+ description = "true if the Exchang should be durable") boolean durable)
+ throws IOException, JMException, MBeanException
+ {
+ //TODO
+ }
+
+ public void unregisterExchange(
+ @MBeanOperationParameter(name = ManagedExchange.TYPE, description = "Exchange Name") String exchange)
+ throws IOException, JMException, MBeanException
+ {
+ //TODO
+ }
+
+ public void createNewQueue(
+ @MBeanOperationParameter(name = "queue name", description = "Name of the new queue") String queueName,
+ @MBeanOperationParameter(name = "owner", description = "Owner name") String owner,
+ @MBeanOperationParameter(name = "durable",
+ description = "true if the queue should be durable") boolean durable)
+ throws IOException, JMException, MBeanException
+ {
+ //TODO
+ }
+
+ public void createNewQueue(
+ @MBeanOperationParameter(name = "queue name", description = "Name of the new queue") String queueName,
+ @MBeanOperationParameter(name = "owner", description = "Owner name") String owner,
+ @MBeanOperationParameter(name = "durable",
+ description = "true if the queue should be durable") boolean durable,
+ @MBeanOperationParameter(name = "arguments",
+ description = "Map of arguments") Map<String, Object> arguments)
+ throws IOException, JMException
+ {
+ //TODO
+ }
+
+ public void deleteQueue(
+ @MBeanOperationParameter(name = ManagedQueue.TYPE, description = "Queue Name") String queueName)
+ throws IOException, JMException, MBeanException
+ {
+ //TODO
+ }
+
+ public void resetStatistics() throws Exception
+ {
+ //TODO
+ }
+
+ public double getPeakMessageDeliveryRate()
+ {
+ return 0; //TODO
+ }
+
+ public double getPeakDataDeliveryRate()
+ {
+ return 0; //TODO
+ }
+
+ public double getMessageDeliveryRate()
+ {
+ return 0; //TODO
+ }
+
+ public double getDataDeliveryRate()
+ {
+ return 0; //TODO
+ }
+
+ public long getTotalMessagesDelivered()
+ {
+ return 0; //TODO
+ }
+
+ public long getTotalDataDelivered()
+ {
+ return 0; //TODO
+ }
+
+ public double getPeakMessageReceiptRate()
+ {
+ return 0; //TODO
+ }
+
+ public double getPeakDataReceiptRate()
+ {
+ return 0; //TODO
+ }
+
+ public double getMessageReceiptRate()
+ {
+ return 0; //TODO
+ }
+
+ public double getDataReceiptRate()
+ {
+ return 0; //TODO
+ }
+
+ public long getTotalMessagesReceived()
+ {
+ return 0; //TODO
+ }
+
+ public long getTotalDataReceived()
+ {
+ return 0; //TODO
+ }
+
+ public boolean isStatisticsEnabled()
+ {
+ return false; //TODO
+ }
+
+
+ @Override
+ public ObjectName getObjectName() throws MalformedObjectNameException
+ {
+ return getObjectNameForSingleInstanceMBean();
+ }
+
+}
Added: qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/MANIFEST.MF
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/MANIFEST.MF?rev=1300204&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/MANIFEST.MF (added)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/MANIFEST.MF Tue Mar 13 15:56:45 2012
@@ -0,0 +1,56 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Qpid Broker-Plugins Management
+Bundle-SymbolicName: broker-plugins-management
+Bundle-Description: Management plugin for Qpid.
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-DocURL: http://www.apache.org/
+Bundle-Version: 1.0.0
+Bundle-Activator: org.apache.qpid.server.management.plugin.ManagementActivator
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ClassPath: .
+Bundle-ActivationPolicy: lazy
+Import-Package: org.apache.qpid,
+ org.apache.qpid.framing,
+ org.apache.qpid.junit.extensions.util,
+ org.apache.qpid.protocol,
+ org.apache.qpid.common,
+ org.apache.qpid.server.security.auth,
+ org.apache.qpid.server.security.auth.manager,
+ org.apache.qpid.server.binding,
+ org.apache.qpid.server.exchange,
+ org.apache.qpid.server.logging,
+ org.apache.qpid.server.model,
+ org.apache.qpid.server.model.adapter,
+ org.apache.qpid.server.model.impl,
+ org.apache.qpid.server.configuration,
+ org.apache.qpid.server.configuration.plugins,
+ org.apache.qpid.server.connection,
+ org.apache.qpid.server.management,
+ org.apache.qpid.server.plugins,
+ org.apache.qpid.server.protocol,
+ org.apache.qpid.server.queue,
+ org.apache.qpid.server.registry,
+ org.apache.qpid.server.security,
+ org.apache.qpid.server.security.access,
+ org.apache.qpid.server.stats,
+ org.apache.qpid.server.virtualhost,
+ org.apache.qpid.util,
+ org.mortbay.jetty;version=6,
+ org.mortbay.jetty.servlet;version=6,
+ org.apache.commons.codec;version=1.3.0,
+ org.apache.commons.codec.binary;version=1.3.0,
+ org.apache.commons.configuration;version=1.0.0,
+ org.apache.commons.lang;version=1.0.0,
+ org.apache.commons.lang.builder;version=1.0.0,
+ org.apache.log4j;version=1.0.0,
+ org.codehaus.jackson;version=1.9.0,
+ org.codehaus.jackson.map;version=1.9.0,
+ javax.servlet,
+ javax.servlet.http,
+ javax.management;version=1.0.0,
+ javax.management.openmbean;version=1.0.0,
+ org.osgi.util.tracker;version=1.0.0,
+ org.osgi.framework;version=1.3
+Private-Package: org.apache.qpid.server.management.plugin.impl
+Export-Package: org.apache.qpid.server.management.plugin;uses:="org.osgi.framework"
Added: qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/build.xml
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/build.xml?rev=1300204&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/build.xml (added)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/build.xml Tue Mar 13 15:56:45 2012
@@ -0,0 +1,29 @@
+<!--
+ - Licensed to the Apache Software Foundation (ASF) under one
+ - or more contributor license agreements. See the NOTICE file
+ - distributed with this work for additional information
+ - regarding copyright ownership. The ASF licenses this file
+ - to you under the Apache License, Version 2.0 (the
+ - "License"); you may not use this file except in compliance
+ - with the License. You may obtain a copy of the License at
+ -
+ - http://www.apache.org/licenses/LICENSE-2.0
+ -
+ - Unless required by applicable law or agreed to in writing,
+ - software distributed under the License is distributed on an
+ - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ - KIND, either express or implied. See the License for the
+ - specific language governing permissions and limitations
+ - under the License.
+ -->
+<project name="Qpid Broker-Plugins Management" default="build">
+ <property name="module.depends" value="common broker broker-plugins broker-plugins-management" />
+ <property name="module.test.depends" value="test broker/test common/test management/common" />
+
+ <property name="module.manifest" value="MANIFEST.MF" />
+ <property name="module.plugin" value="true" />
+
+ <import file="../../module.xml" />
+
+ <target name="bundle" depends="bundle-tasks" />
+</project>
Added: qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/Management.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/Management.java?rev=1300204&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/Management.java (added)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/Management.java Tue Mar 13 15:56:45 2012
@@ -0,0 +1,88 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.management.plugin;
+
+import org.apache.log4j.Logger;
+import org.apache.qpid.server.model.adapter.BrokerAdapter;
+import org.apache.qpid.server.management.plugin.servlet.FileServlet;
+import org.apache.qpid.server.management.plugin.servlet.api.ExchangesServlet;
+import org.apache.qpid.server.management.plugin.servlet.api.VhostsServlet;
+import org.apache.qpid.server.management.plugin.servlet.rest.ConnectionServlet;
+import org.apache.qpid.server.management.plugin.servlet.rest.ExchangeServlet;
+import org.apache.qpid.server.management.plugin.servlet.rest.QueueServlet;
+import org.apache.qpid.server.management.plugin.servlet.rest.VirtualHostServlet;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+public class Management
+{
+
+ private final Logger _logger = Logger.getLogger(Management.class);
+
+ private Broker _broker;
+
+ public Management()
+ {
+ _logger.info("Starting up web server on port 8080");
+
+ _broker = BrokerAdapter.getInstance();
+
+ start();
+
+
+
+ }
+
+ private void start()
+ {
+ Server server = new Server(8080);
+ try
+ {
+ Context root = new Context(server,"/", Context.SESSIONS);
+ root.addServlet(new ServletHolder(new VhostsServlet(_broker)), "/api/vhosts/*");
+ root.addServlet(new ServletHolder(new ExchangesServlet(_broker)), "/api/exchanges/*");
+
+ root.addServlet(new ServletHolder(new VirtualHostServlet(_broker)), "/rest/virtualhost/*");
+ root.addServlet(new ServletHolder(new ExchangeServlet(_broker)), "/rest/exchange/*");
+ root.addServlet(new ServletHolder(new QueueServlet(_broker)), "/rest/queue/*");
+ root.addServlet(new ServletHolder(new ConnectionServlet(_broker)), "/rest/connection/*");
+
+ root.addServlet(new ServletHolder(FileServlet.INSTANCE), "*.js");
+ root.addServlet(new ServletHolder(FileServlet.INSTANCE), "*.css");
+ root.addServlet(new ServletHolder(FileServlet.INSTANCE), "*.html");
+ root.addServlet(new ServletHolder(FileServlet.INSTANCE), "*.png");
+ root.addServlet(new ServletHolder(FileServlet.INSTANCE), "*.gif");
+ root.addServlet(new ServletHolder(FileServlet.INSTANCE), "*.jpg");
+ root.addServlet(new ServletHolder(FileServlet.INSTANCE), "*.jpeg");
+ root.addServlet(new ServletHolder(FileServlet.INSTANCE), "*.json");
+
+ server.start();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(); //TODO
+ }
+ }
+
+}
Added: qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/ManagementActivator.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/ManagementActivator.java?rev=1300204&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/ManagementActivator.java (added)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/ManagementActivator.java Tue Mar 13 15:56:45 2012
@@ -0,0 +1,58 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.management.plugin;
+
+import org.apache.log4j.Logger;
+import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class ManagementActivator implements BundleActivator
+{
+ private static final Logger _logger = Logger.getLogger(ManagementActivator.class);
+
+
+ private BundleContext _ctx;
+ private String _bundleName;
+ private Management _managementService;
+
+
+ public void start(final BundleContext ctx) throws Exception
+ {
+ _ctx = ctx;
+ _managementService = new Management();
+ _bundleName = ctx.getBundle().getSymbolicName();
+
+ // register the service
+ _logger.info("Registering management plugin: " + _bundleName);
+ _ctx.registerService(Management.class.getName(), _managementService, null);
+ _ctx.registerService(ConfigurationPluginFactory.class.getName(), ManagementConfiguration.FACTORY, null);
+ }
+
+ public void stop(final BundleContext bundleContext) throws Exception
+ {
+ _logger.info("Stopping management plugin: " + _bundleName);
+
+ // null object references
+ _managementService = null;
+ _ctx = null;
+ }
+}
Added: qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/ManagementConfiguration.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/ManagementConfiguration.java?rev=1300204&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/ManagementConfiguration.java (added)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/ManagementConfiguration.java Tue Mar 13 15:56:45 2012
@@ -0,0 +1,77 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.management.plugin;
+
+import org.apache.commons.configuration.CompositeConfiguration;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.XMLConfiguration;
+
+import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
+import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class ManagementConfiguration extends ConfigurationPlugin
+{
+ CompositeConfiguration _finalConfig;
+
+ public static final ConfigurationPluginFactory FACTORY = new ConfigurationPluginFactory()
+ {
+ public ConfigurationPlugin newInstance(String path, Configuration config) throws ConfigurationException
+ {
+ ConfigurationPlugin instance = new ManagementConfiguration();
+ instance.setConfiguration(path, config);
+ return instance;
+ }
+
+ public List<String> getParentPaths()
+ {
+ return Arrays.asList("management");
+ }
+ };
+
+ public String[] getElementsProcessed()
+ {
+ return new String[] { "" };
+ }
+
+ public Configuration getConfiguration()
+ {
+ return _finalConfig;
+ }
+
+
+ @Override
+ public void validateConfiguration() throws ConfigurationException
+ {
+ // Valid Configuration either has xml links to new files
+ _finalConfig = new CompositeConfiguration(getConfig());
+ List subFiles = getConfig().getList("xml[@fileName]");
+ for (Object subFile : subFiles)
+ {
+ _finalConfig.addConfiguration(new XMLConfiguration((String) subFile));
+ }
+
+ }
+
+}
Added: qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/FileServlet.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/FileServlet.java?rev=1300204&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/FileServlet.java (added)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/FileServlet.java Tue Mar 13 15:56:45 2012
@@ -0,0 +1,96 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.management.plugin.servlet;
+
+import org.apache.qpid.common.QpidProperties;
+import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.registry.IApplicationRegistry;
+import org.apache.qpid.server.stats.StatisticsCounter;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.codehaus.jackson.map.ObjectMapper;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.UUID;
+
+public class FileServlet extends HttpServlet
+{
+ public static final FileServlet INSTANCE = new FileServlet();
+
+
+ public FileServlet()
+ {
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ String filename = request.getServletPath();
+
+ if(filename.endsWith(".js"))
+ {
+ response.setContentType("application/javascript");
+ }
+ else if(filename.endsWith(".html"))
+ {
+ response.setContentType("text/html");
+ }
+ else if(filename.endsWith(".css"))
+ {
+ response.setContentType("text/css");
+ }
+ else if(filename.endsWith(".json"))
+ {
+ response.setContentType("application/json");
+ }
+
+ final ServletOutputStream output = response.getOutputStream();
+ InputStream fileInput = getClass().getResourceAsStream("/resources" + filename);
+System.out.println("Got: " + filename);
+ if(fileInput != null)
+ {
+ byte[] buffer = new byte[1024];
+ response.setStatus(HttpServletResponse.SC_OK);
+ int read = 0;
+
+ while((read = fileInput.read(buffer)) > 0)
+ {
+ output.write(buffer, 0, read);
+ }
+ }
+ else
+ {
+System.out.println("Not found: " + filename);
+ response.sendError(404, "unknown file: "+ filename);
+ }
+
+ }
+
+}
Added: qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/api/ExchangesServlet.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/api/ExchangesServlet.java?rev=1300204&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/api/ExchangesServlet.java (added)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/api/ExchangesServlet.java Tue Mar 13 15:56:45 2012
@@ -0,0 +1,201 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.management.plugin.servlet.api;
+
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.ObjectReader;
+
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.Exchange;
+import org.apache.qpid.server.model.LifetimePolicy;
+import org.apache.qpid.server.model.State;
+import org.apache.qpid.server.model.VirtualHost;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ExchangesServlet extends HttpServlet
+{
+
+
+ private Broker _broker;
+
+ public ExchangesServlet(Broker broker)
+ {
+ _broker = broker;
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ response.setContentType("application/json");
+ response.setStatus(HttpServletResponse.SC_OK);
+
+ Collection<VirtualHost> vhosts = _broker.getVirtualHosts();
+ Collection<Exchange> exchanges = new ArrayList<Exchange>();
+ Collection<Map<String,Object>> outputObject = new ArrayList<Map<String,Object>>();
+
+ final PrintWriter writer = response.getWriter();
+
+ ObjectMapper mapper = new ObjectMapper();
+ String vhostName = null;
+ String exchangeName = null;
+
+ if(request.getPathInfo() != null && request.getPathInfo().length()>0)
+ {
+ String path = request.getPathInfo().substring(1);
+ String[] parts = path.split("/");
+ vhostName = parts.length == 0 ? "" : parts[0];
+ if(parts.length > 1)
+ {
+ exchangeName = parts[1];
+ }
+ }
+
+ for(VirtualHost vhost : vhosts)
+ {
+ if(vhostName == null || vhostName.equals(vhost.getName()))
+ {
+ for(Exchange exchange : vhost.getExchanges())
+ {
+ if(exchangeName == null || exchangeName.equals(exchange.getName()))
+ {
+ outputObject.add(convertToObject(exchange));
+ if(exchangeName != null)
+ {
+ break;
+ }
+ }
+ }
+ if(vhostName != null)
+ {
+ break;
+ }
+ }
+ }
+
+ mapper.writeValue(writer, outputObject);
+
+ }
+
+ private Map<String,Object> convertToObject(final Exchange exchange)
+ {
+ Map<String, Object> object = new LinkedHashMap<String, Object>();
+ object.put("name",exchange.getName());
+ object.put("type", exchange.getExchangeType());
+ object.put("durable", exchange.isDurable());
+ object.put("auto-delete", exchange.getLifetimePolicy() == LifetimePolicy.AUTO_DELETE);
+
+ Map<String,Object> arguments = new HashMap<String, Object>();
+ for(String key : exchange.getAttributeNames())
+ {
+ if(!key.equals(Exchange.EXCHANGE_TYPE))
+ {
+ arguments.put(key, exchange.getAttribute(key));
+ }
+ }
+ object.put("arguments", arguments);
+ return object;
+ }
+
+ protected void doPut(final HttpServletRequest request, final HttpServletResponse response)
+ throws ServletException, IOException
+ {
+
+ response.setContentType("application/json");
+
+
+ String vhostName = null;
+ String exchangeName = null;
+ if(request.getPathInfo() != null && request.getPathInfo().length()>0)
+ {
+ String path = request.getPathInfo().substring(1);
+ String[] parts = path.split("/");
+ vhostName = parts.length == 0 ? "" : parts[0];
+ if(parts.length > 1)
+ {
+ exchangeName = parts[1];
+ }
+ }
+ if(vhostName == null)
+ {
+ response.setStatus(HttpServletResponse.SC_PRECONDITION_FAILED);
+ }
+ else if (exchangeName == null)
+ {
+ response.setStatus(HttpServletResponse.SC_PRECONDITION_FAILED);
+ }
+ else
+ {
+ VirtualHost vhost = null;
+ for(VirtualHost host : _broker.getVirtualHosts())
+ {
+ if(host.getName().equals(vhostName))
+ {
+ vhost = host;
+ }
+ }
+ if(vhost == null)
+ {
+ response.setStatus(HttpServletResponse.SC_PRECONDITION_FAILED);
+ }
+ else
+ {
+ response.setStatus(HttpServletResponse.SC_NO_CONTENT);
+ ObjectMapper mapper = new ObjectMapper();
+ Map<String,Object> exchangeObject = mapper.readValue(request.getInputStream(), LinkedHashMap.class);
+
+ final boolean isDurable = exchangeObject.get("durable") instanceof Boolean
+ && ((Boolean)exchangeObject.get("durable"));
+ final boolean isAutoDelete = exchangeObject.get("auto_delete") instanceof Boolean
+ && ((Boolean)exchangeObject.get("auto_delete"));
+
+ final String type = (String) exchangeObject.get("type");
+ final Map<String, Object> attributes = new HashMap<String, Object>(exchangeObject);
+ attributes.remove("durable");
+ attributes.remove("auto_delete");
+ attributes.remove("type");
+
+ vhost.createExchange(exchangeName, State.ACTIVE, isDurable,
+ isAutoDelete ? LifetimePolicy.AUTO_DELETE : LifetimePolicy.PERMANENT,
+ 0l,
+ type,
+ attributes);
+ }
+
+
+
+ }
+
+
+
+ }
+}
Added: qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/api/VhostsServlet.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/api/VhostsServlet.java?rev=1300204&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/api/VhostsServlet.java (added)
+++ qpid/branches/java-config-and-management/qpid/java/broker-plugins/management/src/main/java/org/apache/qpid/server/management/plugin/servlet/api/VhostsServlet.java Tue Mar 13 15:56:45 2012
@@ -0,0 +1,111 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.management.plugin.servlet.api;
+
+import org.codehaus.jackson.map.ObjectMapper;
+
+import org.apache.qpid.common.QpidProperties;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.LifetimePolicy;
+import org.apache.qpid.server.model.State;
+import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.protocol.AMQConnectionModel;
+
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.*;
+
+public class VhostsServlet extends HttpServlet
+{
+
+
+ private Broker _broker;
+
+ public VhostsServlet(Broker broker)
+ {
+ _broker = broker;
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+System.out.println("Get /api/vhosts");
+ response.setContentType("application/json");
+ response.setStatus(HttpServletResponse.SC_OK);
+
+ Collection<VirtualHost> vhosts = _broker.getVirtualHosts();
+
+
+
+ final PrintWriter writer = response.getWriter();
+
+ ObjectMapper mapper = new ObjectMapper();
+
+ if(request.getPathInfo() == null || request.getPathInfo().length()==0)
+ {
+
+ LinkedHashMap<String, Object> vhostObject = new LinkedHashMap<String, Object>();
+ List<Map> vhostList = new ArrayList<Map>();
+
+ for(VirtualHost vhost : vhosts)
+ {
+ vhostList.add(Collections.singletonMap("name", vhost.getName()));
+ }
+ mapper.writeValue(writer, vhostList);
+ }
+ else
+ {
+ LinkedHashMap<String, Object> vhostObject = new LinkedHashMap<String, Object>();
+ String vhostName = request.getPathInfo().substring(1);
+
+ for(VirtualHost vhost : vhosts)
+ {
+ if(vhostName.equals(vhost.getName()))
+ {
+ vhostObject.put("name", vhost.getName());
+ break;
+ }
+ }
+ mapper.writeValue(writer, vhostObject);
+ }
+ }
+
+
+ protected void doPut(final HttpServletRequest request, final HttpServletResponse response)
+ throws ServletException, IOException
+ {
+
+ response.setContentType("application/json");
+ response.setStatus(HttpServletResponse.SC_NO_CONTENT);
+
+ if(request.getPathInfo() != null && request.getPathInfo().length()>0)
+ {
+ String vhostName = request.getPathInfo().substring(1);
+ _broker.createVirtualHost(vhostName, State.ACTIVE, true, LifetimePolicy.PERMANENT, 0L, Collections.EMPTY_MAP);
+ }
+
+
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org