You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by sh...@apache.org on 2009/03/11 00:11:10 UTC
svn commit: r752300 [11/12] - in /qpid/branches/qpid-1673/qpid: cpp/
cpp/examples/ cpp/examples/direct/ cpp/examples/failover/
cpp/examples/fanout/ cpp/examples/pub-sub/ cpp/examples/qmf-console/
cpp/examples/request-response/ cpp/examples/tradedemo/ c...
Modified: qpid/branches/qpid-1673/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WsDmAdapterTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-1673/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WsDmAdapterTest.java?rev=752300&r1=752299&r2=752300&view=diff
==============================================================================
--- qpid/branches/qpid-1673/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WsDmAdapterTest.java (original)
+++ qpid/branches/qpid-1673/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WsDmAdapterTest.java Tue Mar 10 23:10:57 2009
@@ -21,36 +21,13 @@
package org.apache.qpid.management.wsdm;
import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.lang.reflect.Array;
-import java.lang.reflect.Method;
import java.net.ServerSocket;
-import java.net.URI;
-import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanInfo;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.xml.namespace.QName;
-
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.muse.core.proxy.ProxyHandler;
-import org.apache.muse.core.proxy.ReflectionProxyHandler;
import org.apache.muse.core.serializer.SerializerRegistry;
-import org.apache.muse.util.xml.XmlUtils;
-import org.apache.muse.ws.addressing.EndpointReference;
-import org.apache.muse.ws.addressing.soap.SoapFault;
-import org.apache.muse.ws.resource.remote.WsResourceClient;
-import org.apache.muse.ws.resource.sg.remote.ServiceGroupClient;
import org.apache.qpid.management.Names;
import org.apache.qpid.management.Protocol;
import org.apache.qpid.management.wsdm.capabilities.Result;
@@ -61,26 +38,14 @@
import org.apache.qpid.management.wsdm.muse.serializer.UUIDSerializer;
import org.mortbay.component.LifeCycle;
import org.mortbay.component.LifeCycle.Listener;
-import org.w3c.dom.Element;
-/**
- * Test case for WS-Resource lifecycle management.
- *
- * @author Andrea Gazzarini
- */
-public class WsDmAdapterTest extends TestCase {
-
- private MBeanServer _managementServer;
- private ObjectName _resourceObjectName;
-
- private WsResourceClient _resourceClient;
- private MBeanInfo _mbeanInfo;
-
- private Map<String, ProxyHandler> _invocationHandlers = createInvocationHandlers();
- final Long retCodeOk = new Long(0);
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class WsDmAdapterTest
+{
- private static ServerThread _server;
-
/**
* Test case wide set up.
* Provides Server startup & shutdown global procedure.
@@ -102,6 +67,7 @@
}
};
+ private ServerThread _server;
/**
* Builds a new test setup with for the given test.
@@ -153,927 +119,30 @@
};
/**
- * Set up fixture for this test case.
- *
- * @throws Exception when the test case intialization fails.
- */
- protected void setUp() throws Exception
- {
- _managementServer = ManagementFactory.getPlatformMBeanServer();
-
- ServiceGroupClient serviceGroup = getServiceGroupClient();
- WsResourceClient [] members = serviceGroup.getMembers();
-
- assertEquals(
- "No resource has been yet created so how is " +
- "it possible that service group children list is not empty?",
- 0,
- members.length);
-
- _managementServer.invoke(
- Names.QPID_EMULATOR_OBJECT_NAME,
- "createQueue", new Object[]{_resourceObjectName = createResourceName()},
- new String[]{ObjectName.class.getName()});
-
- members = serviceGroup.getMembers();
- assertEquals(
- "One resource has just been created so " +
- "I expect to find it on service group children list...",
- 1,
- members.length);
-
- _resourceClient = members[0];
- _mbeanInfo = _managementServer.getMBeanInfo(_resourceObjectName);
- }
-
- /**
- * Shutdown procedure for this test case.
- *
- * @throws Exception when either the server or some resource fails to shutdown.
- */
- @Override
- protected void tearDown() throws Exception
- {
- ServiceGroupClient serviceGroup = getServiceGroupClient();
- WsResourceClient [] members = serviceGroup.getMembers();
-
- _managementServer.invoke(
- Names.QPID_EMULATOR_OBJECT_NAME,
- "unregister",
- new Object[]{_resourceObjectName},
- new String[]{ObjectName.class.getName()});
-
- members = serviceGroup.getMembers();
-
- assertEquals(
- "No resource has been yet created so how is it possible that service group children list is not empty?",
- 0,
- members.length);
- }
-
- /**
- * Test the WS-RP GetResourceProperty interface of the WS-DM adapter.
- *
- * <br>precondition : a ws resource exists and is registered.
- * <br>postcondition : property values coming from WS-DM resource are the same of the JMX interface.
- */
- public void testGetResourcePropertiesOK() throws Exception
- {
- MBeanAttributeInfo [] attributesMetadata = _mbeanInfo.getAttributes();
- for (MBeanAttributeInfo attributeMetadata : attributesMetadata)
- {
- String name = attributeMetadata.getName();
- Object propertyValues = _resourceClient.getPropertyAsObject(
- new QName(
- Names.NAMESPACE_URI,
- name,
- Names.PREFIX),
- Class.forName(attributeMetadata.getType()));
-
- int length = Array.getLength(propertyValues);
- if (length != 0)
- {
- Object propertyValue = Array.get(propertyValues, 0);
-
- assertEquals(
- "Comparison failed for property "+name,
- _managementServer.getAttribute(_resourceObjectName,name),
- propertyValue);
- } else {
- assertNull(
- String.format(
- "\"%s\" property value shouldn't be null. Its value is %s",
- name,
- _managementServer.getAttribute(_resourceObjectName,name)),
- _managementServer.getAttribute(_resourceObjectName,name));
- }
- }
- }
-
- /**
- * Test the WS-RP SetResourceProperty interface of the WS-DM adapter.
- *
- * <br>precondition : a WS-Resource exists and is registered.
- * <br>postcondition : property values are correctly updated on the target WS-Resource..
- */
- public void testSetResourcePropertiesOK() throws Exception
- {
- Map<String, Object> sampleMap = new HashMap<String, Object>();
- sampleMap.put("Key1", "BLABALABLABALBAL");
- sampleMap.put("Key2", 182838484l);
- sampleMap.put("Key3", -928376362);
- sampleMap.put("Key4", 23762736276.33D);
- sampleMap.put("Key4", 2327363.2F);
-
- Map<String, Object> sampleValues = new HashMap<String, Object>();
- sampleValues.put(String.class.getName(),"SAMPLE_STRING");
- sampleValues.put(UUID.class.getName(),UUID.randomUUID());
- sampleValues.put(Boolean.class.getName(),Boolean.FALSE);
- sampleValues.put(Map.class.getName(),sampleMap);
- sampleValues.put(Long.class.getName(),283781273L);
- sampleValues.put(Integer.class.getName(),12727);
- sampleValues.put(Short.class.getName(),new Short((short)22));
- sampleValues.put(Date.class.getName(),new Date());
-
- MBeanAttributeInfo [] attributesMetadata = _mbeanInfo.getAttributes();
- boolean atLeastThereIsOneWritableProperty = false;
-
- for (MBeanAttributeInfo attributeMetadata : attributesMetadata)
- {
- String name = attributeMetadata.getName();
-
- if (attributeMetadata.isWritable())
- {
- atLeastThereIsOneWritableProperty = true;
- Object sampleValue = sampleValues.get(attributeMetadata.getType());
- Object []values = new Object[]{sampleValue};
-
- Object result = _managementServer.getAttribute(_resourceObjectName, name);
- if (result == null)
- {
- _resourceClient.insertResourceProperty(
- new QName(
- Names.NAMESPACE_URI,
- name,
- Names.PREFIX),
- values);
- } else
- {
- _resourceClient.updateResourceProperty(
- new QName(
- Names.NAMESPACE_URI,
- name,
- Names.PREFIX),
- values);
- }
-
- Object propertyValues = _resourceClient.getPropertyAsObject(
- new QName(
- Names.NAMESPACE_URI,
- name,
- Names.PREFIX),
- Class.forName(attributeMetadata.getType()));
- int length = Array.getLength(propertyValues);
- if (length != 0)
- {
- Object propertyValue = Array.get(propertyValues, 0);
-
- assertEquals(
- "Comparison failed for property "+name,
- sampleValue,
- propertyValue);
- } else {
- assertNull(
- String.format(
- "\"%s\" property value shouldn't be null. Its value is %s",
- name,
- _managementServer.getAttribute(_resourceObjectName,name)),
- sampleValue);
- }
- }
- }
- assertTrue(
- "It's not possibile to run successfully this test case if " +
- "the target WS-Resource has no at least one writable property",
- atLeastThereIsOneWritableProperty);
- }
-
- /**
- * Test the WS-RP SetResourceProperty interface of the WS-DM adapter when the
- * target property is null.
- * According to WS-RP specs this operation is not allowed because in this case a SetResourceProperty with an "Insert"
- * message should be sent in order to initialize the property.
- *
- * <br>precondition : a ws resource exists and is registered. The value of the target property is null.
- * <br>postcondition : a Soap fault is received indicating the failuire.
- */
- public void testSetResourcePropertiesKO() throws Exception
- {
- Object typePropertyValue = _managementServer.getAttribute(_resourceObjectName, "Type");
- assertNull(typePropertyValue);
-
- try
- {
- _resourceClient.updateResourceProperty(
- new QName(
- Names.NAMESPACE_URI,
- "Type",
- Names.PREFIX),
- new Object[]{"sampleValue"});
- fail(
- "If the property is null on the target ws resource, according " +
- "to WS-RP specs, an update of its value is not possible.");
- } catch(SoapFault expected)
- {
-
- }
- }
-
- /**
- * Tests the WS-RP PutResourcePropertyDocument interface of the WS-DM adapter.
- *
- * <br>precondition : a ws resource exists and is registered.
- * <br>postcondition : A read / write property is correctly set according to WSRP interface.
- */
- public void testGetAndPutResourcePropertyDocumentOK() throws Exception
- {
- String expectedMgmtPubIntervalValue = "4321";
- String propertyName = "MgmtPubInterval";
-
- Element propertiesDocument = _resourceClient.getResourcePropertyDocument();
- Element [] properties = XmlUtils.getAllElements(propertiesDocument);
-
- for (Element element : properties)
- {
- if (propertyName.equals(element.getLocalName())) {
- element.setTextContent(expectedMgmtPubIntervalValue);
- } else {
- propertiesDocument.removeChild(element);
- }
- }
-
- _resourceClient.putResourcePropertyDocument(propertiesDocument);
-
- Element newProperties = _resourceClient.getResourcePropertyDocument();
-
- Element mgmtPubInterval = XmlUtils.getElement(
- newProperties, new QName(
- Names.NAMESPACE_URI,
- propertyName,
- Names.PREFIX));
-
- assertEquals(expectedMgmtPubIntervalValue,mgmtPubInterval.getTextContent());
- }
-
- /**
- * Tests the WS-RP PutResourcePropertyDocument interface of the WS-DM adapter.
- * Specifically it tries to update the value of a read-only property.
- *
- * <br>precondition : a ws resource exists, it is registered and has at least one read-only property.
- * <br>postcondition : An exception is thrown indicating the failure.
- */
- public void testGetAndPutResourcePropertyDocumentKO_WithReadOnlyProperty() throws Exception
- {
- String propertyName = "Name";
-
- Element propertiesDocument = _resourceClient.getResourcePropertyDocument();
- Element [] properties = XmlUtils.getAllElements(propertiesDocument);
-
- for (Element element : properties)
- {
- if (propertyName.equals(element.getLocalName())) {
- element.setTextContent("ThisIsTheNewValueOfNameProperty");
- } else {
- propertiesDocument.removeChild(element);
- }
- }
-
- try
- {
- _resourceClient.putResourcePropertyDocument(propertiesDocument);
- fail("It's not possible to update the value of a read-only property.");
- } catch (SoapFault expected)
- {
-
- }
- }
-
- /**
- * Test the WS-RP GetResourceProperties interface of the WS-DM adapter.
- *
- * <br>precondition : a ws resource exists and is registered.
- * <br>postcondition : Properties are correctly returned according to WSRP interface and they (their value)
- * are matching with corresponding MBean properties.
- */
- public void testGetMultipleResourcePropertiesOK() throws Exception
- {
- MBeanAttributeInfo [] attributesMetadata = _mbeanInfo.getAttributes();
- QName[] names = new QName[attributesMetadata.length];
-
- int index = 0;
- for (MBeanAttributeInfo attributeMetadata : _mbeanInfo.getAttributes())
- {
- QName qname = new QName(Names.NAMESPACE_URI,attributeMetadata.getName(),Names.PREFIX);
- names[index++] = qname;
- }
-
- Element[] properties =_resourceClient.getMultipleResourceProperties(names);
- for (Element element : properties)
- {
- String name = element.getLocalName();
- Object value = _managementServer.getAttribute(_resourceObjectName, name);
- if ("Name".equals(name))
- {
- assertEquals(
- value,
- element.getTextContent());
- } else if ("Durable".equals(name))
- {
- assertEquals(
- value,
- Boolean.valueOf(element.getTextContent()));
- } else if ("ExpireTime".equals(name))
- {
- assertEquals(
- value,
- new Date(Long.valueOf(element.getTextContent())));
- } else if ("MsgTotalEnqueues".equals(name))
- {
- assertEquals(
- value,
- Long.valueOf(element.getTextContent()));
- } else if ("ConsumerCount".equals(name))
- {
- assertEquals(
- value,
- Integer.valueOf(element.getTextContent()));
- }else if ("VhostRef".equals(name))
- {
- assertEquals(
- value,
- UUID.fromString(element.getTextContent()));
- }
- }
- }
-
- /**
- * Test operation invocation on WS-Resource.
- * This method tests the exchange of simple types between requestor and service provider.
- * With simple types we mean :
- *
- * <ul>
- * <li>java.lang.Long / long (xsd:long)
- * <li>java.lang.Integer / int (xsd:int / xsd:integer)
- * <li>java.lang.Double/ double (xsd:double)
- * <li>java.lang.Float / float (xsd:float)
- * <li>java.lang.Short / short (xsd:short)
- * <li>java.lang.Boolean / boolean (xsd:boolean)
- * <li>java.lang.String (xsd:string)
- * <li>java.net.URI (xsd:anyURI)
- * <li>java.util.Date(xsd:dateTime)
- * </ul>
- *
- * <br>precondition : a ws resource exists and is registered and the requested operation is available on that.
- * <br>postcondition : invocations are executed successfully, no exception is thrown and parameters are correctly returned.
- */
- @SuppressWarnings("unchecked")
- public void testOperationInvocationOK_withSimpleTypes() throws Exception
- {
- Long expectedLongResult = new Long(1373);
- Boolean expectedBooleanResult = Boolean.TRUE;
- Double expectedDoubleResult = new Double(12763.44);
- Float expectedFloatResult = new Float(2727.233f);
- Integer expectedIntegerResult = new Integer(28292);
- Short expectedShortResult = new Short((short)227);
- String expectedStringResult = "expectedStringResult";
- URI expectedUriResult = URI.create("http://qpid.apache.org/");
- Date expectedDateResult = new Date();
-
- Object result = _resourceClient.invoke(
- _invocationHandlers.get("echoWithSimpleTypes"),
- new Object[]{
- expectedLongResult,
- expectedBooleanResult,
- expectedDoubleResult,
- expectedFloatResult,
- expectedIntegerResult,
- expectedShortResult,
- expectedStringResult,
- expectedUriResult,
- expectedDateResult});
-
- Method getStatusCode = result.getClass().getMethod("getStatusCode");
- Method getOutputParameters = result.getClass().getMethod("getOutputParameters");
- assertEquals(retCodeOk,getStatusCode.invoke(result));
- Map<String,Object> out = (Map<String, Object>) getOutputParameters.invoke(result);
-
- assertEquals("Output parameters must be 9.",9,out.size());
- assertTrue("Long output parameter not found on result object.",out.containsValue(expectedLongResult));
- assertTrue("Boolean output parameter not found on result object.",out.containsValue(expectedBooleanResult));
- assertTrue("Double output parameter not found on result object.",out.containsValue(expectedDoubleResult));
- assertTrue("Float output parameter not found on result object.",out.containsValue(expectedFloatResult));
- assertTrue("Integer output parameter not found on result object.",out.containsValue(expectedIntegerResult));
- assertTrue("Short output parameter not found on result object.",out.containsValue(expectedShortResult));
- assertTrue("String output parameter not found on result object.",out.containsValue(expectedStringResult));
- assertTrue("URI output parameter not found on result object.",out.containsValue(expectedUriResult));
- assertTrue("Date output parameter not found on result object.",out.containsValue(expectedDateResult));
- }
-
- /**
- * Test operation invocation on WS-Resource.
- * This method tests the exchange of arrays between requestor and service provider.
- * For this test exchanged arrays contain :
- *
- * <ul>
- * <li>java.lang.Long (xsd:long)
- * <li>java.lang.Integer (xsd:int / xsd:integer)
- * <li>java.lang.Double (xsd:double)
- * <li>java.lang.Float (xsd:float)
- * <li>java.lang.Short (xsd:short)
- * <li>java.lang.Boolean (xsd:boolean)
- * <li>java.lang.String (xsd:string)
- * <li>java.net.URI (xsd:anyURI)
- * <li>java.util.Date(xsd:dateTime)
- * </ul>
- *
- * <br>precondition : a ws resource exists and is registered and the requested operation is available on that.
- * <br>postcondition : invocations are executed successfully, no exception is thrown and parameters are correctly returned.
- */
- @SuppressWarnings("unchecked")
- public void testOperationInvocationOK_withWrapperArrays() throws Exception
- {
- Long [] expectedLongResult = {new Long(2),new Long(1),new Long(3),new Long(4)};
- Boolean [] expectedBooleanResult = { Boolean.TRUE,Boolean.FALSE,Boolean.FALSE};
- Double [] expectedDoubleResult = {12763.44d,2832.33d,2292.33d,22293.22d};
- Float [] expectedFloatResult = {2727.233f,1f,2f,4f,5.4f,33.2f};
- Integer [] expectedIntegerResult = {1,2,3,4,55,66,77,88,99};
- Short [] expectedShortResult = {(short)227,(short)23,(short)9};
- String [] expectedStringResult = {"s1","s2","s333","s4"};
- URI [] expectedUriResult = {
- URI.create("http://qpid.apache.org/"),
- URI.create("http://www.apache.org"),
- URI.create("http://projects.apache.org")};
-
- Date [] expectedDateResult = {
- new Date(),
- new Date(38211897),
- new Date(903820382)};
-
- Object result = _resourceClient.invoke(
- _invocationHandlers.get("echoWithArrays"),
- new Object[]{
- expectedLongResult,
- expectedBooleanResult,
- expectedDoubleResult,
- expectedFloatResult,
- expectedIntegerResult,
- expectedShortResult,
- expectedStringResult,
- expectedUriResult,
- expectedDateResult});
-
- Method getStatusCode = result.getClass().getMethod("getStatusCode");
- Method getOutputParameters = result.getClass().getMethod("getOutputParameters");
- assertEquals(retCodeOk,getStatusCode.invoke(result));
- Map<String,Object> out = (Map<String, Object>) getOutputParameters.invoke(result);
-
- assertEquals("Output parameters must be 9.",9,out.size());
- assertTrue("Long array doesn't match.",Arrays.equals(expectedLongResult, (Long[])out.get(Long.class.getName())));
- assertTrue("Boolean array doesn't match.",Arrays.equals(expectedBooleanResult, (Boolean[])out.get(Boolean.class.getName())));
- assertTrue("Double array doesn't match.",Arrays.equals(expectedDoubleResult, (Double[])out.get(Double.class.getName())));
- assertTrue("Float array doesn't match.",Arrays.equals(expectedFloatResult, (Float[])out.get(Float.class.getName())));
- assertTrue("Integer array doesn't match.", Arrays.equals(expectedIntegerResult, (Integer[])out.get(Integer.class.getName())));
- assertTrue("Short array doesn't match.",Arrays.equals(expectedShortResult, (Short[])out.get(Short.class.getName())));
- assertTrue("String array doesn't match.",Arrays.equals(expectedStringResult, (String[])out.get(String.class.getName())));
- assertTrue("URI array doesn't match.",Arrays.equals(expectedUriResult, (URI[])out.get(URI.class.getName())));
- assertTrue("Date array doesn't match.",Arrays.equals(expectedDateResult, (Date[])out.get(Date.class.getName())));
- }
-
- /**
- * Test operation invocation on WS-Resource.
- * This method tests the exchange of primitive type arrays between requestor and service provider.
- * NOte that even the sent array contain primtiive type QMan deals only with objects so in the result
- * object you will find the corresponding wrapper types.
- *
- * For this test exchanged arrays contain :
- *
- * <ul>
- * <li>java.lang.Long / long (xsd:long)
- * <li>java.lang.Integer / int (xsd:int / xsd:integer)
- * <li>java.lang.Double/ double (xsd:double)
- * <li>java.lang.Float / float (xsd:float)
- * <li>java.lang.Short / short (xsd:short)
- * <li>java.lang.Boolean / boolean (xsd:boolean)
- * </ul>
- *
- * <br>precondition : a ws resource exists and is registered and the requested operation is available on that.
- * <br>postcondition : invocations are executed successfully, no exception is thrown and parameters are correctly returned.
- */
- @SuppressWarnings("unchecked")
- public void testOperationInvocationOK_withPrimitiveArrays() throws Exception
- {
- long [] expectedLongResult = {1L,2L,3L,4L};
- boolean [] expectedBooleanResult = { true,false,false};
- double [] expectedDoubleResult = {12763.44d,2832.33d,2292.33d,22293.22d};
- float [] expectedFloatResult = {2727.233f,1f,2f,4f,5.4f,33.2f};
- int [] expectedIntegerResult = {1,2,3,4,55,66,77,88,99};
- short [] expectedShortResult = {(short)227,(short)23,(short)9};
-
- Object result = _resourceClient.invoke(
- _invocationHandlers.get("echoWithSimpleTypeArrays"),
- new Object[]{
- expectedLongResult,
- expectedBooleanResult,
- expectedDoubleResult,
- expectedFloatResult,
- expectedIntegerResult,
- expectedShortResult});
-
- Method getStatusCode = result.getClass().getMethod("getStatusCode");
- Method getOutputParameters = result.getClass().getMethod("getOutputParameters");
- assertEquals(retCodeOk,getStatusCode.invoke(result));
- Map<String,Object> out = (Map<String, Object>) getOutputParameters.invoke(result);
-
- assertEquals("Output parameters must be 6.",6,out.size());
- assertArrayEquals(expectedLongResult, out.get(long.class.getName()));
- assertArrayEquals(expectedBooleanResult, out.get(boolean.class.getName()));
- assertArrayEquals(expectedDoubleResult, out.get(double.class.getName()));
- assertArrayEquals(expectedFloatResult, out.get(float.class.getName()));
- assertArrayEquals(expectedIntegerResult, out.get(int.class.getName()));
- assertArrayEquals(expectedShortResult, out.get(short.class.getName()));
- }
-
- /**
- * Test operation invocation on WS-Resource.
- * This method tests the exchange of a byte type array between requestor and service provider.
- *
- * <br>precondition : a WS-Resource exists and is registered and the requested operation is available on that.
- * <br>postcondition : invocations are executed successfully, no exception is thrown and byte array are correctly returned.
- */
- @SuppressWarnings("unchecked")
- public void testOperationInvocationOK_withByteArray() throws Exception
- {
- byte [] expectedByteResult = {1,3,4,2,2,44,22,3,3,55,66};
-
- Object result = _resourceClient.invoke(
- _invocationHandlers.get("echoWithByteArray"),
- new Object[]{expectedByteResult});
-
- Method getStatusCode = result.getClass().getMethod("getStatusCode");
- Method getOutputParameters = result.getClass().getMethod("getOutputParameters");
-
- assertEquals(retCodeOk,getStatusCode.invoke(result));
- Map<String,Object> out = (Map<String, Object>) getOutputParameters.invoke(result);
-
- assertEquals("Output parameters must be 1.",1,out.size());
- assertArrayEquals(expectedByteResult, out.get(byte[].class.getName()));
- }
-
- /**
- * Test a simple operation invocation on a WS-Resource.
- * This method tests a simple operation without any input and output parameters.
- *
- * <br>precondition : a ws resource exists and is registered and the requested operation is available on that.
- * <br>postcondition : invocations are executed successfully an no exception is thrown.
- */
- @SuppressWarnings("unchecked")
- public void testSimpleOperationInvocationOK() throws Exception
- {
- Object result = _resourceClient.invoke(
- _invocationHandlers.get("voidWithoutArguments"),
- null);
-
- Method getStatusCode = result.getClass().getMethod("getStatusCode");
- assertEquals(
- "Something was wrong...expected return code is "+retCodeOk,
- retCodeOk,
- getStatusCode.invoke(result));
- }
-
- /**
- * Test a the invocation on a WS-Resource with a method that throws an exception..
- *
- * <br>precondition : a ws resource exists and is registered and the requested operation is available on that.
- * <br>postcondition : an exception is thrown by the requested method.
- */
- @SuppressWarnings("unchecked")
- public void testInvocationException_OK() throws Exception
- {
- try
- {
- _resourceClient.invoke(
- _invocationHandlers.get("throwsException"),
- null);
- fail("The requested operation has thrown an exception so a Soap Fault is expected...");
- } catch(SoapFault expected)
- {
- }
- }
-
- /**
- * Test operation invocation on WS-Resource.
- * This method tests the exchange of UUID type between requestor and service provider.
+ * Gets the test suite composition.
*
- * <br>precondition : a WS-Resource exists and is registered and the requested operation is available on that.
- * <br>postcondition : invocations are executed successfully, no exception is thrown and parameters are correctly returned.
+ * @return the test suite composition.
*/
- @SuppressWarnings("unchecked")
- public void testOperationInvocationOK_withUUID() throws Exception
+ public static Test suite()
{
- UUID expectedUuid = UUID.randomUUID();
-
- Object result = _resourceClient.invoke(
- _invocationHandlers.get("echoWithUUID"),
- new Object[]{expectedUuid});
-
- Method getStatusCode = result.getClass().getMethod("getStatusCode");
- Method getOutputParameters = result.getClass().getMethod("getOutputParameters");
-
- assertEquals(retCodeOk,getStatusCode.invoke(result));
- Map<String,Object> out = (Map<String, Object>) getOutputParameters.invoke(result);
-
- assertEquals("Output parameters must be 1.",1,out.size());
- assertEquals(expectedUuid, out.get("uuid"));
- }
-
- /**
- * Test operation invocation on WS-Resource.
- * This method tests the exchange of Map type between requestor and service provider.
- * For this test exchanged arrays contain :
- *
- * <br>precondition : a ws resource exists and is registered and the requested operation is available on that.
- * <br>postcondition : invocations are executed successfully, no exception is thrown and parameters are correctly returned.
- */
- @SuppressWarnings("unchecked")
- public void testOperationInvocationOK_withMap() throws Exception
- {
- Map<String,Object> expectedMap = new HashMap<String, Object>();
- expectedMap.put("p1", new Long(1));
- expectedMap.put("p2", Boolean.TRUE);
- expectedMap.put("p3", 1234d);
- expectedMap.put("p4", 11.2f);
- expectedMap.put("p5", 1272);
- expectedMap.put("p6", (short)12);
- expectedMap.put("p7", "aString");
- expectedMap.put("p8", "http://qpid.apache.org");
- expectedMap.put("p9", new Date(12383137128L));
- expectedMap.put("p10", new byte[]{1,2,2,3,3,4});
-
- Object result = _resourceClient.invoke(
- _invocationHandlers.get("echoWithMap"),
- new Object[]{expectedMap});
-
- Method getStatusCode = result.getClass().getMethod("getStatusCode");
- Method getOutputParameters = result.getClass().getMethod("getOutputParameters");
-
- assertEquals(retCodeOk,getStatusCode.invoke(result));
- Map<String,Object> out = (Map<String, Object>) ((Map<String, Object>) getOutputParameters.invoke(result)).get("map");
-
- assertEquals("Output parameters must be 10.",10,out.size());
- assertEquals(expectedMap.get("p1"),out.get("p1"));
- assertEquals(expectedMap.get("p2"),out.get("p2"));
- assertEquals(expectedMap.get("p3"),out.get("p3"));
- assertEquals(expectedMap.get("p4"),out.get("p4"));
- assertEquals(expectedMap.get("p5"),out.get("p5"));
- assertEquals(expectedMap.get("p6"),out.get("p6"));
- assertEquals(expectedMap.get("p7"),out.get("p7"));
- assertEquals(expectedMap.get("p8"),out.get("p8"));
- assertEquals(expectedMap.get("p9"),out.get("p9"));
- assertTrue( Arrays.equals((byte[])expectedMap.get("p10"),(byte[])out.get("p10")));
- }
-
- /**
- * Main entry point for running this test case.
- *
- * @return the decorated test case.
- */
- public static Test suite() {
- TestSuite suite = new TestSuite("Test Suite for WS-DM Adapter");
- suite.addTestSuite(WsDmAdapterTest.class);
+ TestSuite suite = new TestSuite("Test suite for QMan WS-DM.");
+ suite.addTestSuite(MetadataExchangeInterfaceTestCase.class);
+ suite.addTestSuite(OperationInvocationInterfaceTestCase.class);
+ suite.addTestSuite(GetResourcePropertyDocumentTestCase.class);
+ suite.addTestSuite(SetResourcePropertiesTestCase.class);
+ suite.addTestSuite(GetMultipleResourcePropertiesTestCase.class);
+ suite.addTestSuite(GetResourcePropertiesTestCase.class);
return new WsDmAdapterTestSetup(suite);
}
/**
- * Creates a service group client reference.
- *
- * @return a service group client reference.
- */
- private ServiceGroupClient getServiceGroupClient()
- {
- URI address = URI.create(
- Protocol.DEFAULT_ENDPOINT_URI.replaceFirst("8080",System.getProperty(Names.ADAPTER_PORT_PROPERTY_NAME)));
- return new ServiceGroupClient(new EndpointReference(address));
- }
-
- /**
- * In order to test the behaviour of the WS-DM adapter, at
- * least one resource must be created. This is the method that
- * returns the name (ObjectName on JMX side, Resource-ID on WSDM side)
- * of that resource
- *
- * @return the name of the MBean instance that will be created.
- * @throws Exception when the name if malformed. Practically never.
- */
- private ObjectName createResourceName() throws Exception
- {
- return new ObjectName(
- "Q-MAN:objectId="+UUID.randomUUID()+
- ", brokerID="+UUID.randomUUID()+
- ",class=queue"+
- ",package=org.apache.qpid"+
- ",name="+System.currentTimeMillis());
- }
-
- private Map<String,ProxyHandler> createInvocationHandlers()
- {
- Map<String, ProxyHandler> handlers = new HashMap<String, ProxyHandler>();
-
- ProxyHandler handler = new ReflectionProxyHandler();
- handler.setAction(Names.NAMESPACE_URI+"/"+"voidWithoutArguments");
- handler.setRequestName(
- new QName(
- Names.NAMESPACE_URI,
- "voidWithoutArgumentsRequest",
- Names.PREFIX));
- handler.setRequestParameterNames(new QName[]{});
- handler.setResponseName(
- new QName(
- Names.NAMESPACE_URI,
- "voidWithoutArgumentsResponse",
- Names.PREFIX));
- handler.setReturnType(Result.class);
-
- ProxyHandler exceptionHandler = new ReflectionProxyHandler();
- exceptionHandler.setAction(Names.NAMESPACE_URI+"/"+"throwsException");
- exceptionHandler.setRequestName(
- new QName(
- Names.NAMESPACE_URI,
- "throwsExceptionRequest",
- Names.PREFIX));
-
- exceptionHandler.setRequestParameterNames(new QName[]{});
- exceptionHandler.setResponseName(
- new QName(
- Names.NAMESPACE_URI,
- "throwsExceptionResponse",
- Names.PREFIX));
-
- exceptionHandler.setReturnType(Result.class);
-
- ProxyHandler echoWithWrapperTypesHandler = new ReflectionProxyHandler();
- echoWithWrapperTypesHandler.setAction(Names.NAMESPACE_URI+"/"+"echoWithSimpleTypes");
- echoWithWrapperTypesHandler.setRequestName(
- new QName(
- Names.NAMESPACE_URI,
- "echoWithSimpleTypesRequest",
- Names.PREFIX));
-
- echoWithWrapperTypesHandler.setRequestParameterNames(new QName[]{
- new QName(Names.NAMESPACE_URI,"p1",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p2",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p3",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p4",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p5",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p6",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p7",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p8",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p9",Names.PREFIX),
- });
-
- echoWithWrapperTypesHandler.setResponseName(
- new QName(
- Names.NAMESPACE_URI,
- "echoWithSimpleTypesResponse",
- Names.PREFIX));
-
- echoWithWrapperTypesHandler.setReturnType(Result.class);
-
- ProxyHandler echoWithArrayOfWrapperTypes = new ReflectionProxyHandler();
- echoWithArrayOfWrapperTypes.setAction(Names.NAMESPACE_URI+"/"+"echoWithArrays");
- echoWithArrayOfWrapperTypes.setRequestName(
- new QName(
- Names.NAMESPACE_URI,
- "echoWithArraysRequest",
- Names.PREFIX));
-
- echoWithArrayOfWrapperTypes.setRequestParameterNames(new QName[]{
- new QName(Names.NAMESPACE_URI,"p1",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p2",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p3",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p4",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p5",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p6",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p7",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p8",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p9",Names.PREFIX),
- });
-
- echoWithArrayOfWrapperTypes.setResponseName(
- new QName(
- Names.NAMESPACE_URI,
- "echoWithArraysResponse",
- Names.PREFIX));
-
- echoWithArrayOfWrapperTypes.setReturnType(Result.class);
-
- ProxyHandler echoWithArrayOfPrimitiveTypes = new ReflectionProxyHandler();
- echoWithArrayOfPrimitiveTypes.setAction(Names.NAMESPACE_URI+"/"+"echoWithSimpleTypeArrays");
- echoWithArrayOfPrimitiveTypes.setRequestName(
- new QName(
- Names.NAMESPACE_URI,
- "echoWithSimpleTypeArraysRequest",
- Names.PREFIX));
-
- echoWithArrayOfPrimitiveTypes.setRequestParameterNames(new QName[]{
- new QName(Names.NAMESPACE_URI,"p1",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p2",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p3",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p4",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p5",Names.PREFIX),
- new QName(Names.NAMESPACE_URI,"p6",Names.PREFIX)});
-
- echoWithArrayOfPrimitiveTypes.setResponseName(
- new QName(
- Names.NAMESPACE_URI,
- "echoWithSimpleTypeArraysResponse",
- Names.PREFIX));
-
- echoWithArrayOfPrimitiveTypes.setReturnType(Result.class);
-
- ProxyHandler echoWithByteArray = new EnhancedReflectionProxyHandler();
- echoWithByteArray.setAction(Names.NAMESPACE_URI+"/"+"echoWithByteArray");
- echoWithByteArray.setRequestName(
- new QName(
- Names.NAMESPACE_URI,
- "echoWithByteArrayRequest",
- Names.PREFIX));
-
- echoWithByteArray.setRequestParameterNames(
- new QName[]{
- new QName(Names.NAMESPACE_URI,"p1",Names.PREFIX)});
-
- echoWithByteArray.setResponseName(
- new QName(
- Names.NAMESPACE_URI,
- "echoWithByteArrayResponse",
- Names.PREFIX));
-
- echoWithByteArray.setReturnType(Result.class);
-
- ProxyHandler echoWithUUID = new EnhancedReflectionProxyHandler();
- echoWithUUID.setAction(Names.NAMESPACE_URI+"/"+"echoWithUUID");
- echoWithUUID.setRequestName(
- new QName(
- Names.NAMESPACE_URI,
- "echoWithUUIDRequest",
- Names.PREFIX));
-
- echoWithUUID.setRequestParameterNames(
- new QName[]{
- new QName(Names.NAMESPACE_URI,"p1",Names.PREFIX)});
-
- echoWithUUID.setResponseName(
- new QName(
- Names.NAMESPACE_URI,
- "echoWithUUIDResponse",
- Names.PREFIX));
-
- echoWithUUID.setReturnType(Result.class);
-
- ProxyHandler echoWithMap = new EnhancedReflectionProxyHandler();
- echoWithMap.setAction(Names.NAMESPACE_URI+"/"+"echoWithMap");
- echoWithMap.setRequestName(
- new QName(
- Names.NAMESPACE_URI,
- "echoWithMapRequest",
- Names.PREFIX));
-
- echoWithMap.setRequestParameterNames(
- new QName[]{
- new QName(Names.NAMESPACE_URI,"p1",Names.PREFIX)});
-
- echoWithMap.setResponseName(
- new QName(
- Names.NAMESPACE_URI,
- "echoWithMapResponse",
- Names.PREFIX));
-
- echoWithMap.setReturnType(Result.class);
-
- handlers.put("voidWithoutArguments",handler);
- handlers.put("echoWithSimpleTypes",echoWithWrapperTypesHandler);
- handlers.put("echoWithArrays",echoWithArrayOfWrapperTypes);
- handlers.put("echoWithSimpleTypeArrays", echoWithArrayOfPrimitiveTypes);
- handlers.put("echoWithByteArray", echoWithByteArray);
- handlers.put("echoWithUUID", echoWithUUID);
- handlers.put("echoWithMap", echoWithMap);
- handlers.put("throwsException",exceptionHandler);
- return handlers;
- }
-
- /**
- * Internal method used for array comparison using reflection.
+ * Finds a free port that will be used to run the embedded
+ * web server.
*
- * @param expectedArray the expected array.
- * @param resultArray the array that must match the expected one.
+ * @return a free port that will be used to run the
+ * embedded web server.
*/
- private void assertArrayEquals(Object expectedArray, Object resultArray)
- {
- int expectedArrayLength = Array.getLength(expectedArray);
- int resultArrayLength = Array.getLength(resultArray);
-
- assertEquals(expectedArrayLength,resultArrayLength);
-
- for (int index = 0; index < expectedArrayLength; index++)
- {
- Object expected = Array.get(expectedArray, index);
- Object result = Array.get(resultArray, index);
-
- assertEquals(expected,result);
- }
- }
-
- public static int getFreePort() throws IOException {
+ private static int getFreePort() throws IOException {
ServerSocket server = null;
try
{
Modified: qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/META-INF/MANIFEST.MF?rev=752300&r1=752299&r2=752300&view=diff
==============================================================================
--- qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/META-INF/MANIFEST.MF (original)
+++ qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/META-INF/MANIFEST.MF Tue Mar 10 23:10:57 2009
@@ -10,8 +10,8 @@
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.ui.forms,
- jmxremote.sasl;resolution:=optional,
- qpid-management-common
+ qpid-management-common,
+ org.apache.commons.codec;bundle-version="1.3.0"
Eclipse-LazyStart: true
Export-Package: org.apache.qpid.management.ui,
org.apache.qpid.management.ui.actions,
Modified: qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/build-release.xml
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/build-release.xml?rev=752300&r1=752299&r2=752300&view=diff
==============================================================================
--- qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/build-release.xml (original)
+++ qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/build-release.xml Tue Mar 10 23:10:57 2009
@@ -44,6 +44,9 @@
For linux libcairo-swt.so file:
qpidmc.companion.library
+
+ For solaris .xpm files:
+ qpidmc.solaris.xpm.files
-->
</condition>
@@ -86,15 +89,22 @@
<fileset file="${qpidmc.companion.library}"/>
</copy>
</target>
+
+ <target name="release-bin-executable-solaris-xpm-files" if="qpidmc.solaris.xpm.files">
+ <!-- Copy the solaris xpm files -->
+ <copy todir="${release.subdir}" flatten="true" failonerror="true">
+ <fileset dir="${basedir}" includes="${qpidmc.solaris.xpm.files}"/>
+ </copy>
+ </target>
<target name="release-bin-rcp-deps" description="copy eclipse-rcp dependencies into module release"
- depends="release-bin-executable-companion-library">
+ depends="release-bin-executable-companion-library, release-bin-executable-solaris-xpm-files">
<!-- Copy the rcp executable file -->
<copy todir="${release.subdir}" flatten="true" failonerror="true">
<fileset file="${qpidmc.executable}"/>
</copy>
- <chmod dir="${release.subdir}" perm="u+rx" includes="**/*"/>
+ <chmod dir="${release.subdir}" perm="u+rx" includes="qpidmc*"/>
<!-- Copy remaining startup & license files -->
<copy todir="${release.subdir}" flatten="true" failonerror="true">
Modified: qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/build.xml
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/build.xml?rev=752300&r1=752299&r2=752300&view=diff
==============================================================================
--- qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/build.xml (original)
+++ qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/build.xml Tue Mar 10 23:10:57 2009
@@ -70,6 +70,19 @@
<property file="build-release-linux-gtk-x86.properties"/>
<property file="build-release-common.properties"/>
</ant>
+
+ <!-- linux gtk x86_64 -->
+ <ant antfile="build-release.xml">
+ <property file="build-release-linux-gtk-x86_64.properties"/>
+ <property file="build-release-common.properties"/>
+ </ant>
+
+ <!-- solaris gtk sparc -->
+ <ant antfile="build-release.xml">
+ <property file="build-release-solaris-gtk-sparc.properties"/>
+ <property file="build-release-common.properties"/>
+ </ant>
+
<!-- mac os x -->
<ant antfile="build-release-macosx.xml">
<property file="build-release-macosx.properties"/>
Modified: qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java?rev=752300&r1=752299&r2=752300&view=diff
==============================================================================
--- qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java (original)
+++ qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java Tue Mar 10 23:10:57 2009
@@ -28,12 +28,13 @@
public class Constants
{
public final static String APPLICATION_NAME = "Qpid Management Console";
+ public static final String DEFAULT_DOMAIN = "org.apache.qpid";
public final static String ACTION_REMOVE_MBEANNODE = "Remove from list";
public final static String VALUE = "value";
public final static String TYPE = "type";
+ public final static String VERSION = "version";
public final static String NODE_TYPE_SERVER = "server";
- public final static String NODE_TYPE_DOMAIN = "domain";
public final static String NODE_TYPE_MBEANTYPE = "mbeantype";
// currently used only for virtual host instances, but will work as general also
public final static String NODE_TYPE_TYPEINSTANCE = "mbeantype_instance";
@@ -80,8 +81,6 @@
public final static String[] EXCHANGE_TYPE_VALUES = {"direct", "fanout", "headers", "topic"};
public final static String[] BOOLEAN_TYPE_VALUES = {"false", "true"};
public final static String[] ATTRIBUTE_TABLE_TITLES = {"Attribute Name", "Value"};
- public static final String[] CONNECTION_PROTOCOLS ={"RMI"};
- public static final String DEFAULT_PROTOCOL = CONNECTION_PROTOCOLS[0];
public final static String ACTION_ADDSERVER = "New Connection";
public final static String ACTION_RECONNECT = "Reconnect";
Modified: qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java?rev=752300&r1=752299&r2=752300&view=diff
==============================================================================
--- qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java (original)
+++ qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java Tue Mar 10 23:10:57 2009
@@ -20,13 +20,17 @@
*/
package org.apache.qpid.management.ui;
-import static org.apache.qpid.management.ui.Constants.*;
+import static org.apache.qpid.management.ui.Constants.ADMIN_MBEAN_TYPE;
+import static org.apache.qpid.management.ui.Constants.CONNECTION;
+import static org.apache.qpid.management.ui.Constants.DEFAULT_VH;
+import static org.apache.qpid.management.ui.Constants.EXCHANGE;
+import static org.apache.qpid.management.ui.Constants.QUEUE;
+import static org.apache.qpid.management.ui.Constants.VIRTUAL_HOST;
+
import java.util.HashMap;
/**
* Class representing a managed bean on the managed server
- * @author Bhupendra Bhardwaj
- *
*/
public abstract class ManagedBean extends ManagedObject
{
@@ -36,27 +40,50 @@
private String _virtualHostName = null;
private ManagedServer _server = null;
private HashMap _properties = null;
-
+ private int _version;
+
public String getProperty(String key)
{
- return (String)_properties.get(key);
+ return (String) _properties.get(key);
}
-
+
public HashMap getProperties()
{
return _properties;
}
+
public void setProperties(HashMap properties)
{
this._properties = properties;
setName(getProperty("name"));
setType(getProperty("type"));
+ setVersion(getProperty("version"));
_virtualHostName = getProperty(VIRTUAL_HOST);
}
+
+ public void setVersion(String version)
+ {
+ try
+ {
+ _version = Integer.parseInt(version);
+ }
+ catch (NumberFormatException nfe)
+ {
+ _version = 1;
+ }
+
+ }
+
+ public int getVersion()
+ {
+ return _version;
+ }
+
public String getDomain()
{
return _domain;
}
+
public void setDomain(String domain)
{
this._domain = domain;
@@ -66,65 +93,75 @@
{
return _server;
}
+
public void setServer(ManagedServer server)
{
this._server = server;
}
+
public String getType()
{
return _type;
}
+
public void setType(String type)
{
this._type = type;
}
+
public String getUniqueName()
{
return _uniqueName;
}
+
public void setUniqueName(String uniqueName)
{
this._uniqueName = uniqueName;
}
-
+
public String getVirtualHostName()
{
// To make it work with the broker with no virtual host implementation
return _virtualHostName == null ? DEFAULT_VH : _virtualHostName;
}
-
+
/**
* Returns mbean instance name. MBeans which have only one instance, the type attribute will be returned
+ *
* @return
*/
public String getInstanceName()
{
if (getName() != null)
+ {
return getName();
+ }
else
+ {
return getType();
+ }
}
-
+
public boolean isQueue()
{
return _type.endsWith(QUEUE);
}
-
+
public boolean isConnection()
{
return _type.endsWith(CONNECTION);
}
-
+
public boolean isExchange()
{
return _type.endsWith(EXCHANGE);
}
-
+
public boolean isTempQueue()
{
return (isQueue() && getName().startsWith("tmp_"));
}
-
+
public boolean isAdmin()
{
return _type.endsWith(ADMIN_MBEAN_TYPE);
Modified: qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java?rev=752300&r1=752299&r2=752300&view=diff
==============================================================================
--- qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java (original)
+++ qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java Tue Mar 10 23:10:57 2009
@@ -20,20 +20,16 @@
*/
package org.apache.qpid.management.ui;
-import static org.apache.qpid.management.ui.Constants.DEFAULT_PROTOCOL;
/**
* Class representing a server being managed eg. MBeanServer
- * @author Bhupendra Bhardwaj
*/
public class ManagedServer extends ManagedObject
{
private String _host;
private int _port;
- private String _url;
private String _domain;
private String _user;
private String _password;
- private String _protocol = DEFAULT_PROTOCOL;
public ManagedServer(String host, int port, String domain)
{
@@ -46,7 +42,6 @@
_host = host;
_port = port;
_domain = domain;
- _url = getRMIURL(host, port);
_user = user;
_password = password;
}
@@ -65,17 +60,7 @@
{
return _port;
}
-
- public String getUrl()
- {
- return _url;
- }
- public String getProtocol()
- {
- return _protocol;
- }
-
public String getPassword()
{
return _password;
@@ -96,8 +81,4 @@
_user = user;
}
- private String getRMIURL(String host, int port)
- {
- return "service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxrmi";
- }
}
Modified: qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java?rev=752300&r1=752299&r2=752300&view=diff
==============================================================================
--- qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java (original)
+++ qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java Tue Mar 10 23:10:57 2009
@@ -35,7 +35,6 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
@@ -46,12 +45,9 @@
public class AddServer extends AbstractAction implements IWorkbenchWindowActionDelegate
{
- private static final String[] _domains ={"org.apache.qpid"};
-
- private String _transport = DEFAULT_PROTOCOL;
private String _host;
private String _port;
- private String _domain;
+ private String _domain = DEFAULT_DOMAIN;
private String _user;
private String _password;
@@ -73,7 +69,7 @@
{
if (_addServer)
{
- getNavigationView().addNewServer(_transport, _host, Integer.parseInt(_port), _domain, _user, _password);
+ getNavigationView().addNewServer(_host, Integer.parseInt(_port), _domain, _user, _password);
}
}
catch(InfoRequiredException ex)
@@ -91,7 +87,6 @@
_addServer = false;
_host = null;
_port = null;
- _domain = null;
_user = null;
_password = null;
}
@@ -103,6 +98,8 @@
*/
private void createAddServerPopup()
{
+ final Shell appShell = _window.getShell();
+
Display display = Display.getCurrent();
final Shell shell = new Shell(display, SWT.BORDER | SWT.CLOSE);
shell.setText(ACTION_ADDSERVER);
@@ -112,21 +109,23 @@
createWidgets(shell);
shell.pack();
- //get current size dialog, and screen size
- int displayWidth = display.getBounds().width;
- int displayHeight = display.getBounds().height;
+ //get current size dialog, and application window size and location
+ int appWidth = appShell.getBounds().width;
+ int appHeight = appShell.getBounds().height;
+ int appLocX = appShell.getBounds().x;
+ int appLocY = appShell.getBounds().y;
int currentShellWidth = shell.getSize().x;
int currentShellHeight = shell.getSize().y;
//default sizes for the dialog
int minShellWidth = 425;
- int minShellHeight= 290;
+ int minShellHeight= 265;
//ensure this is large enough, increase it if its not
int newShellWidth = currentShellWidth > minShellWidth ? currentShellWidth : minShellWidth;
int newShellHeight = currentShellHeight > minShellHeight ? currentShellHeight : minShellHeight;
- //set the final size and centre the dialog
- shell.setBounds((displayWidth - newShellWidth)/2 , (displayHeight - newShellHeight)/2, newShellWidth, newShellHeight);
+ //set the final size and centre the dialog within the app window
+ shell.setBounds((appWidth - newShellWidth)/2 + appLocX, (appHeight - newShellHeight)/2 + appLocY, newShellWidth, newShellHeight);
shell.open();
_window.getShell().setEnabled(false);
@@ -189,17 +188,6 @@
// Verify if the value entered is numeric
textPort.addVerifyListener(new NumberVerifyListener());
-
- Label domain = new Label(composite, SWT.NONE);
- domain.setText("Domain");
- domain.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false));
-
- final Combo comboDomain = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
- comboDomain.setItems(_domains);
- comboDomain.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
- comboDomain.select(0);
-
-
Label user = new Label(composite, SWT.NONE);
user.setText(USERNAME);
user.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false));
@@ -228,7 +216,7 @@
if (event.character == SWT.ESC)
{
//Escape key acts as cancel on all widgets
- shell.close();
+ shell.dispose();
}
}
});
@@ -283,7 +271,6 @@
return;
}
- _domain = comboDomain.getText();
_addServer = true;
shell.dispose();
}
@@ -314,7 +301,7 @@
if (event.character == SWT.ESC)
{
//Escape key acts as cancel on all widgets
- shell.close();
+ shell.dispose();
}
}
});
Modified: qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java?rev=752300&r1=752299&r2=752300&view=diff
==============================================================================
--- qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java (original)
+++ qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java Tue Mar 10 23:10:57 2009
@@ -99,6 +99,8 @@
// Create the login popup fot th user to enter usernaem and password
private void createLoginPopup()
{
+ final Shell appShell = _window.getShell();
+
Display display = Display.getCurrent();
final Shell shell = new Shell(display, SWT.BORDER | SWT.CLOSE);
shell.setText(_title);
@@ -108,9 +110,11 @@
createWidgets(shell);
shell.pack();
- //get current size dialog, and screen size
- int displayWidth = display.getBounds().width;
- int displayHeight = display.getBounds().height;
+ //get current size dialog, and application window size and location
+ int appWidth = appShell.getBounds().width;
+ int appHeight = appShell.getBounds().height;
+ int appLocX = appShell.getBounds().x;
+ int appLocY = appShell.getBounds().y;
int currentShellWidth = shell.getSize().x;
int currentShellHeight = shell.getSize().y;
@@ -121,8 +125,8 @@
int newShellWidth = currentShellWidth > minShellWidth ? currentShellWidth : minShellWidth;
int newShellHeight = currentShellHeight > minShellHeight ? currentShellHeight : minShellHeight;
- //set the final size and centre the dialog
- shell.setBounds((displayWidth - newShellWidth)/2 , (displayHeight - newShellHeight)/2, newShellWidth, newShellHeight);
+ //set the final size and centre the dialog within the app window
+ shell.setBounds((appWidth - newShellWidth)/2 + appLocX, (appHeight - newShellHeight)/2 + appLocY, newShellWidth, newShellHeight);
shell.open();
_window.getShell().setEnabled(false);
@@ -182,7 +186,7 @@
if (event.character == SWT.ESC)
{
//Escape key acts as cancel on all widgets
- shell.close();
+ shell.dispose();
}
}
});
@@ -248,7 +252,7 @@
if (event.character == SWT.ESC)
{
//Escape key acts as cancel on all widgets
- shell.close();
+ shell.dispose();
}
}
});
Modified: qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/ClientListener.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/ClientListener.java?rev=752300&r1=752299&r2=752300&view=diff
==============================================================================
--- qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/ClientListener.java (original)
+++ qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/ClientListener.java Tue Mar 10 23:10:57 2009
@@ -45,7 +45,6 @@
{
ObjectName objName = null;
String type = notification.getType();
- MBeanUtility.printOutput(type + ":" + objName);
if (MBeanServerNotification.REGISTRATION_NOTIFICATION.equals(type))
{
@@ -60,6 +59,7 @@
else if (JMXConnectionNotification.FAILED.equals(type))
{
ApplicationRegistry.serverConnectionClosed(server);
+ MBeanUtility.printOutput("Recieved notification from " + server.getName() + ": " + type );
}
}
Modified: qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/ClientNotificationListener.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/ClientNotificationListener.java?rev=752300&r1=752299&r2=752300&view=diff
==============================================================================
--- qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/ClientNotificationListener.java (original)
+++ qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/ClientNotificationListener.java Tue Mar 10 23:10:57 2009
@@ -35,7 +35,6 @@
public void handleNotification(Notification notification, Object handback)
{
ObjectName objName = (ObjectName)notification.getSource();
- //String type = notification.getType();
getServerRegistry().addNotification(objName, notification);
}
}
Modified: qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java?rev=752300&r1=752299&r2=752300&view=diff
==============================================================================
--- qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java (original)
+++ qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java Tue Mar 10 23:10:57 2009
@@ -164,7 +164,6 @@
public void removeManagedObject(ManagedBean mbean)
{
- MBeanUtility.printOutput("Removing MBean:" + mbean.getUniqueName());
if (mbean.isQueue())
{
Modified: qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java?rev=752300&r1=752299&r2=752300&view=diff
==============================================================================
--- qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java (original)
+++ qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java Tue Mar 10 23:10:57 2009
@@ -440,18 +440,6 @@
return mbeans;
}
- /**
- * Returns all the domains for the given server. This method can be removed as now this RCP is specific to
- * Qpid and domain is also fixed
- */
- public static List<String> getAllDomains(ManagedServer server) throws Exception
- {
- JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(server);
- MBeanServerConnection mbsc = serverRegistry.getServerConnection();
- String[] domains = mbsc.getDomains();
- return Arrays.asList(domains);
- }
-
public static void printOutput(String statement)
{
if (ApplicationRegistry.debug)
Modified: qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java?rev=752300&r1=752299&r2=752300&view=diff
==============================================================================
--- qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java (original)
+++ qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java Tue Mar 10 23:10:57 2009
@@ -30,6 +30,7 @@
import org.apache.qpid.management.ui.exceptions.InfoRequiredException;
import org.apache.qpid.management.ui.jmx.MBeanUtility;
import org.apache.qpid.management.ui.model.AttributeData;
+import org.apache.qpid.management.ui.model.NotificationInfoModel;
import org.apache.qpid.management.ui.model.OperationData;
import org.apache.qpid.management.ui.model.OperationDataModel;
import org.eclipse.jface.viewers.ISelection;
@@ -135,8 +136,7 @@
{
try
{
- if (_selectedNode == null || NODE_TYPE_SERVER.equals(_selectedNode.getType()) ||
- NODE_TYPE_DOMAIN.equals(_selectedNode.getType()) )
+ if (_selectedNode == null || NODE_TYPE_SERVER.equals(_selectedNode.getType()))
{
return;
}
@@ -176,8 +176,7 @@
*/
private void setServer()
{
- if (NODE_TYPE_SERVER.equals(_selectedNode.getType()) ||
- NODE_TYPE_DOMAIN.equals(_selectedNode.getType()) )
+ if (NODE_TYPE_SERVER.equals(_selectedNode.getType()))
{
_server = (ManagedServer)_selectedNode.getManagedObject();
_virtualHostName = null;
@@ -359,6 +358,13 @@
private void createNotificationsTab(TabFolder tabFolder)
{
+ NotificationInfoModel[] items = MBeanUtility.getNotificationInfo(_mbean);
+ if (items == null || items.length == 0)
+ {
+ //the mbean has no notifications to subscribe for, do not create the tab.
+ return;
+ }
+
NotificationsTabControl controller = new NotificationsTabControl(tabFolder);
TabItem tab = new TabItem(tabFolder, SWT.NONE);
Modified: qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java?rev=752300&r1=752299&r2=752300&view=diff
==============================================================================
--- qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java (original)
+++ qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java Tue Mar 10 23:10:57 2009
@@ -130,16 +130,26 @@
{
public void treeExpanded(TreeExpansionEvent event)
{
- _treeViewer.setExpandedState(event.getElement(), true);
- // Following will cause the selection event to be sent, so commented
- // _treeViewer.setSelection(new StructuredSelection(event.getElement()));
- _treeViewer.refresh();
+ getSite().getShell().getDisplay().asyncExec(
+ new Runnable()
+ {
+ public void run()
+ {
+ _treeViewer.refresh();
+ }
+ });
}
public void treeCollapsed(TreeExpansionEvent event)
{
- _treeViewer.setExpandedState(event.getElement(), false);
- _treeViewer.refresh();
+ getSite().getShell().getDisplay().asyncExec(
+ new Runnable()
+ {
+ public void run()
+ {
+ _treeViewer.refresh();
+ }
+ });
}
});
@@ -201,11 +211,11 @@
}
/**
- * Creates Qpid Server connection using JMX RMI protocol
+ * Creates Qpid Server connection
* @param server
* @throws Exception
*/
- private void createRMIServerConnection(ManagedServer server) throws Exception
+ private void createJMXServerConnection(ManagedServer server) throws Exception
{
// Currently Qpid Management Console only supports JMX MBeanServer
ServerRegistry serverRegistry = new JMXServerRegistry(server);
@@ -220,42 +230,32 @@
* @param domain
* @throws Exception
*/
- public void addNewServer(String transportProtocol, String host, int port, String domain, String user, String pwd)
+ public void addNewServer(String host, int port, String domain, String user, String pwd)
throws Exception
{
- String serverAddress = host + ":" + port;
- String url = null;
ManagedServer managedServer = new ManagedServer(host, port, domain, user, pwd);
- if ("RMI".equals(transportProtocol))
+ String server = managedServer.getName();
+ List<TreeObject> list = _serversRootNode.getChildren();
+ for (TreeObject node : list)
{
- url = managedServer.getUrl();
- List<TreeObject> list = _serversRootNode.getChildren();
- for (TreeObject node : list)
+ ManagedServer nodeServer = (ManagedServer)node.getManagedObject();
+ if (server.equals(nodeServer.getName()))
{
- ManagedServer nodeServer = (ManagedServer)node.getManagedObject();
- if (url.equals(nodeServer.getUrl()))
- {
- // Server is already in the list of added servers, so now connect it.
- // Set the server node as selected and then connect it.
- _treeViewer.setSelection(new StructuredSelection(node));
- reconnect(user, pwd);
+ // Server is already in the list of added servers, so now connect it.
+ // Set the server node as selected and then connect it.
+ _treeViewer.setSelection(new StructuredSelection(node));
+ reconnect(user, pwd);
- return;
- }
+ return;
}
-
- // The server is not in the list of already added servers, so now connect and add it.
- managedServer.setName(serverAddress);
- createRMIServerConnection(managedServer);
- }
- else
- {
- throw new InfoRequiredException(transportProtocol + " transport is not supported");
}
+ // The server is not in the list of already added servers, so now connect and add it.
+ createJMXServerConnection(managedServer);
+
// Server connection is successful. Now add the server in the tree
- TreeObject serverNode = new TreeObject(serverAddress, NODE_TYPE_SERVER);
+ TreeObject serverNode = new TreeObject(server, NODE_TYPE_SERVER);
serverNode.setManagedObject(managedServer);
_serversRootNode.addChild(serverNode);
@@ -276,10 +276,12 @@
// Add the Queue/Exchanges/Connections from config file into the navigation tree
addConfiguredItems(managedServer);
+ expandInitialMBeanView(serverNode);
+
_treeViewer.refresh();
// save server address in file
- addServerInConfigFile(serverAddress);
+ addServerInConfigFile(server);
}
/**
@@ -405,50 +407,33 @@
}
}
- /**
- * Queries the qpid server for MBeans and populates the navigation view with all MBeans for
- * the given server node.
- * @param serverNode
- */
- private void populateServer(TreeObject serverNode) throws Exception
+ //check if the MBeanInfo can be retrieved.
+ private boolean haveAccessPermission(ManagedBean mbean)
{
- ManagedServer server = (ManagedServer) serverNode.getManagedObject();
- String domain = server.getDomain();
- if (!domain.equals(ALL))
- {
- TreeObject domainNode = new TreeObject(domain, NODE_TYPE_DOMAIN);
- domainNode.setParent(serverNode);
-
- populateDomain(domainNode);
+ try
+ {
+ MBeanUtility.getMBeanInfo(mbean);
}
- else
+ catch(Exception ex)
{
- List<TreeObject> domainList = new ArrayList<TreeObject>();
- List<String> domains = MBeanUtility.getAllDomains(server);
-
- for (String domainName : domains)
- {
- TreeObject domainNode = new TreeObject(domainName, NODE_TYPE_DOMAIN);
- domainNode.setParent(serverNode);
-
- domainList.add(domainNode);
- populateDomain(domainNode);
- }
+ return false;
}
+
+ return true;
}
-
+
/**
- * Queries the Qpid Server and populates the given domain node with all MBeans undser that domain.
- * @param domain
- * @throws IOException
+ * Queries the qpid server for MBeans and populates the navigation view with all MBeans for
+ * the given server node.
+ * @param serverNode
* @throws Exception
*/
- private void populateDomain(TreeObject domain) throws IOException, Exception
+ private void populateServer(TreeObject serverNode) throws Exception
{
- ManagedServer server = (ManagedServer) domain.getParent().getManagedObject();
+ ManagedServer server = (ManagedServer) serverNode.getManagedObject();
+ String domain = server.getDomain();
- // Now populate the mbenas under those types
- List<ManagedBean> mbeans = MBeanUtility.getManagedObjectsForDomain(server, domain.getName());
+ List<ManagedBean> mbeans = MBeanUtility.getManagedObjectsForDomain(server, domain);
for (ManagedBean mbean : mbeans)
{
mbean.setServer(server);
@@ -459,13 +444,17 @@
// manually by selecting from MBeanView
if (!(mbean.isConnection() || mbean.isExchange() || mbean.isQueue()))
{
- addManagedBean(domain, mbean);
+ //if we cant get the MBeanInfo then we cant display the mbean, so dont add it to the tree
+ if (haveAccessPermission(mbean))
+ {
+ addManagedBean(serverNode, mbean);
+ }
}
}
// To make it work with the broker without virtual host implementation.
// This will add the default nodes to the domain node
boolean hasVirtualHost = false;
- for (TreeObject child : domain.getChildren())
+ for (TreeObject child : serverNode.getChildren())
{
if (child.getName().startsWith(VIRTUAL_HOST))
{
@@ -475,7 +464,7 @@
}
if (!hasVirtualHost){
- addDefaultNodes(domain);
+ addDefaultNodes(serverNode);
}
}
@@ -540,15 +529,14 @@
}
/**
- * Adds the given MBean to the given domain node. Creates Notification node for the MBean.
+ * Adds the given MBean to the given domain node.
* sample ObjectNames -
* org.apache.qpid:type=VirtualHost.VirtualHostManager,VirtualHost=localhost
* org.apache.qpid:type=VirtualHost.Queue,VirtualHost=test,name=ping_1
- * @param domain
- * @param mbean
- * @throws Exception
+ * @param parent parent tree node to add the mbean to
+ * @param mbean mbean to add
*/
- private void addManagedBean(TreeObject domain, ManagedBean mbean) // throws Exception
+ private void addManagedBean(TreeObject parent, ManagedBean mbean)
{
String name = mbean.getName();
// Split the mbean type into array of Strings, to create hierarchy
@@ -558,7 +546,7 @@
// test->Queue->ping
String[] types = mbean.getType().split("\\.");
TreeObject typeNode = null;
- TreeObject parentNode = domain;
+ TreeObject parentNode = parent;
// Run this loop till all nodes(hierarchy) for this mbean are created. This loop only creates
// all the required parent nodes for the mbean
@@ -638,11 +626,6 @@
{
addItemInConfigFile(mbeanNode);
}
-
- // Add notification node
- // TODO: show this only if the mbean sends any notification
- //TreeObject notificationNode = new TreeObject(NOTIFICATION, NOTIFICATION);
- //notificationNode.setParent(mbeanNode);
}
private TreeObject createTypeNode(TreeObject parent, String name)
@@ -755,7 +738,7 @@
managedServer.setUser(user);
managedServer.setPassword(password);
- createRMIServerConnection(managedServer);
+ createJMXServerConnection(managedServer);
// put the server in the managed server map
_managedServerMap.put(managedServer, selectedNode);
@@ -775,8 +758,31 @@
// Add the Queue/Exchanges/Connections from config file into the navigation tree
addConfiguredItems(managedServer);
+ expandInitialMBeanView(selectedNode);
+
_treeViewer.refresh();
}
+
+ private void expandInitialMBeanView(TreeObject serverNode)
+ {
+ if (serverNode.getChildren().size() == 0 )
+ {
+ return;
+ }
+ else
+ {
+ _treeViewer.setExpandedState(serverNode , true);
+ }
+
+ List<TreeObject> children = serverNode.getChildren();
+ for (TreeObject child : children)
+ {
+ if (child.getChildren().size() > 0)
+ {
+ _treeViewer.setExpandedState(child, true);
+ }
+ }
+ }
/**
* Adds the items(queues/exchanges/connectins) from config file to the server tree
@@ -1157,25 +1163,12 @@
/**
* Adds the mbean to the navigation tree
- * @param mbean
- * @throws Exception
+ * @param mbean mbean to add to the tree
*/
- public void addManagedBean(ManagedBean mbean) // throws Exception
+ public void addManagedBean(ManagedBean mbean)
{
TreeObject treeServerObject = _managedServerMap.get(mbean.getServer());
- List<TreeObject> domains = treeServerObject.getChildren();
- TreeObject domain = null;
- for (TreeObject child : domains)
- {
- if (child.getName().equals(mbean.getDomain()))
- {
- domain = child;
-
- break;
- }
- }
-
- addManagedBean(domain, mbean);
+ addManagedBean(treeServerObject, mbean);
_treeViewer.refresh();
}
@@ -1200,20 +1193,8 @@
for (ManagedBean mbean : removalList)
{
TreeObject treeServerObject = _managedServerMap.get(mbean.getServer());
- List<TreeObject> domains = treeServerObject.getChildren();
- TreeObject domain = null;
- for (TreeObject child : domains)
- {
- if (child.getName().equals(mbean.getDomain()))
- {
- domain = child;
-
- break;
- }
- }
- removeManagedObject(domain, mbean);
- // serverRegistry.removeManagedObject(mbean);
+ removeManagedObject(treeServerObject, mbean);
}
_treeViewer.refresh();
Modified: qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java?rev=752300&r1=752299&r2=752300&view=diff
==============================================================================
--- qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java (original)
+++ qpid/branches/qpid-1673/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java Tue Mar 10 23:10:57 2009
@@ -33,8 +33,6 @@
import org.apache.qpid.management.ui.ApplicationRegistry;
import org.apache.qpid.management.ui.ManagedBean;
-import org.apache.qpid.management.ui.ServerRegistry;
-import org.apache.qpid.management.ui.jmx.JMXServerRegistry;
import org.apache.qpid.management.ui.jmx.MBeanUtility;
import org.apache.qpid.management.ui.model.OperationData;
import org.apache.qpid.management.ui.model.ParameterData;
@@ -69,8 +67,6 @@
/**
* Control class for the MBean operations tab. It creates the required widgets
* for the selected MBean.
- * @author Bhupendra Bhardwaj
- * @author Robert Gemmell
*/
public class OperationTabControl extends TabControl
{
@@ -521,7 +517,7 @@
private void populateResults(Object result)
{
Display display = Display.getCurrent();
- int width = 600;
+ int width = 610;
int height = 400;
Shell shell = ViewUtility.createPopupShell(RESULT, width, height);
shell.setImage(ApplicationRegistry.getImage(CONSOLE_IMAGE));
@@ -605,23 +601,37 @@
return;
}
- // customized for passwords
- if (PASSWORD.equalsIgnoreCase(param.getName()))
+ //Custom handling for the PASSWORD field
+ if (param.getName().equalsIgnoreCase(PASSWORD))
{
+ //Convert the String value to a character array if that is what is required.
if (param.getType().equals("[C"))
{
- try
+ // Retreive the mBean type and version.
+ // If we have a version 1 UserManagement class mbean then it expects the password
+ // to be sent as the hashed version.
+ if (_mbean.getType().equals("UserManagement") && _mbean.getVersion() == 1)
{
- param.setValue(ViewUtility.getHash((String)param.getValue()));
+ try
+ {
+ param.setValue(ViewUtility.getHash((String) param.getValue()));
+ }
+ catch (Exception hashException)
+ {
+ ViewUtility.popupErrorMessage(_form.getText(),
+ "Unable to calculate hash for Password:"
+ + hashException.getMessage());
+ return;
+ }
}
- catch (Exception ex)
+ else
{
- MBeanUtility.handleException(_mbean, ex);
- return;
+ param.setValue(((String) param.getValue()).toCharArray());
}
}
}
// end of customization
+
}
}
@@ -725,7 +735,14 @@
{
boolean success = Boolean.parseBoolean(result.toString());
String message = success ? OPERATION_SUCCESSFUL : OPERATION_UNSUCCESSFUL;
- ViewUtility.popupInfoMessage(title, message);
+ if(success)
+ {
+ ViewUtility.popupInfoMessage(title, message);
+ }
+ else
+ {
+ ViewUtility.popupErrorMessage(title, message);
+ }
}
else if (_opData.getParameters() != null && !_opData.getParameters().isEmpty())
{
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org