You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ag...@apache.org on 2009/01/23 21:44:49 UTC
svn commit: r737182 [1/3] - in /qpid/trunk/qpid/java/management/client: ./
src/main/java/ src/main/java/org/apache/qpid/management/
src/main/java/org/apache/qpid/management/domain/handler/impl/
src/main/java/org/apache/qpid/management/domain/model/ src...
Author: agazzarini
Date: Fri Jan 23 12:44:48 2009
New Revision: 737182
URL: http://svn.apache.org/viewvc?rev=737182&view=rev
Log:
QPID-1579 : WS-DM unit tests and method invocation improvements
Added:
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/QpidDomainObject.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/QpidDomainObjectMBean.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmu.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmuInitializer.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmuMBean.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/DummyCapabilityBuilder.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManMessageHandler.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/muse/serializer/DateSerializer.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/qman/debug/WsdlDebugger.java
qpid/trunk/qpid/java/management/client/src/test/java/log4j.xml
qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/
qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/EnhancedReflectionProxyHandler.java
qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/ServerThread.java
qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WebApplicationLifeCycleListener.java
qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WsDmAdapterTest.java
qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/capabilities/
qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilderTest.java
qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityTest.java
qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/capabilities/RmdBuilderTest.java
qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/web.xml
Modified:
qpid/trunk/qpid/java/management/client/build.xml
qpid/trunk/qpid/java/management/client/src/main/java/muse.xml
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Messages.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Names.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/InvocationResult.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidClass.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapability.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilder.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManAdapterCapability.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/RmdBuilder.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/WsArtifacts.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/WsArtifactsFactory.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/WsdlBuilder.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/muse/engine/WSDMAdapterEnvironment.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/muse/resources/QManWsResource.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/muse/serializer/InvocationResultSerializer.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/muse/serializer/MapSerializer.java
qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/muse/serializer/ObjectSerializer.java
qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/TestConstants.java
Modified: qpid/trunk/qpid/java/management/client/build.xml
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/build.xml?rev=737182&r1=737181&r2=737182&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/build.xml (original)
+++ qpid/trunk/qpid/java/management/client/build.xml Fri Jan 23 12:44:48 2009
@@ -20,22 +20,22 @@
-->
<project name="QMan - Qpid JMX / WS-DM Adapter" default="build">
- <property name="module.depends" value="client common systests"/>
+ <property name="module.depends" value="client common"/>
+ <property name="module.test.depends" value="client common"/>
+
<import file="../../module.xml"/>
<property name="war.name" value="qman.war"/>
<property name="build.root" value="${module.build}"/>
- <property name="web.module" value="${module.build}/WsdmModule"/>
- <property name="web-inf.folder" value="${web.module}/WEB-INF"/>
- <property name="classes.folder" value="${web-inf.folder}/classes"/>
+ <property name="web.module" value="${module.build}${file.separator}WsdmModule"/>
+ <property name="web-inf.folder" value="${web.module}${file.separator}WEB-INF"/>
+ <property name="classes.folder" value="${web-inf.folder}${file.separator}classes"/>
<target name="release-bin-other">
<mkdir dir="${module.release}${file.separator}log"/>
</target>
<target name="libs-release" description="copy dependencies into module release">
-
- <!-- Copy the module dependencies for JMX Bridge release-->
<copy todir="${module.release}${file.separator}" failonerror="true" verbose="true">
<fileset dir="${build}" casesensitive="yes" includes="${module.libs}">
<not><filename name="**/*javassist*"/></not>
@@ -46,38 +46,29 @@
<not><filename name="**/*muse*"/></not>
</fileset>
</copy>
-
- <!-- qpid-management-client.jar : this should be copied only on jmx dist -->
- <copy todir="${module.release}/lib" failonerror="true">
+ <copy todir="${module.release}${file.separator}lib" failonerror="true">
<fileset file="${module.jar}"/>
<fileset dir="${build.lib}" includes="${module.depends.jars}"/>
</copy>
-
- <!-- qman.war -->
- <copy todir="${module.release}/lib" failonerror="true">
- <fileset file="${web.module}${file.separator}${war.name}"/>
- </copy>
+ <jar destfile="${module.release}${file.separator}lib${file.separator}${war.name}" basedir="${web.module}"/>
</target>
<target name="prepare-wsdm-module">
<mkdir dir="${web.module}"/>
<mkdir dir="${web-inf.folder}"/>
<mkdir dir="${classes.folder}"/>
- <copy file="./web.xml" todir="${web-inf.folder}" verbose="false"/>
- <copy todir="${classes.folder}" verbose="false">
- <fileset dir="${module.classes}">
- <include name="org/apache/qpid/management/servlet/*"/>
- <include name="org/apache/qpid/management/wsdm/**"/>
- <include name="org/apache/qpid/qman/**"/>
- <include name="wsdl/**"/>
+ <copy file=".${file.separator}web.xml" todir="${web-inf.folder}" verbose="false"/>
+ <copy todir="${classes.folder}" verbose="false">
+ <fileset dir="${module.classes}">
+ <include name="wsdl/**"/>
<include name="muse.xml"/>
<include name="router-entries/**"/>
- </fileset>
- </copy>
+ </fileset>
+ </copy>
<copy todir="${web-inf.folder}">
<fileset dir="${build}" includes="${module.libs}"/>
</copy>
- <copy todir="${web-inf.folder}/lib">
+ <copy todir="${web-inf.folder}${file.separator}lib">
<fileset dir="${build}/lib">
<include name="qpid-client-*.jar"/>
<include name="qpid-common-*.jar"/>
@@ -89,45 +80,69 @@
</fileset>
</copy>
</target>
- <target name="jar.manifest" depends="compile" if="module.manifest">
- <jar destfile="${module.jar}" manifest="${module.manifest}">
- <fileset dir="${module.classes}" casesensitive="yes">
+ <target name="jar.manifest" depends="compile" if="module.manifest">
+ <jar destfile="${module.jar}" manifest="${module.manifest}">
+ <fileset dir="${module.classes}" casesensitive="yes">
<include name="**/**"/>
- <exclude name="org/apache/qpid/management/servlet/*"/>
- <exclude name="org/apache/qpid/management/wsdm/**"/>
- <exclude name="org/apache/qpid/qman/**"/>
<exclude name="wsdl/**"/>
<exclude name="muse.xml"/>
<exclude name="router-entries/**"/>
- </fileset>
- </jar>
- </target>
- <target name="jar.nomanifest" depends="compile" unless="module.manifest">
- <jar destfile="${module.jar}">
- <metainf dir="${project.root}/resources/" />
- <fileset dir="${module.classes}" casesensitive="yes">
+ </fileset>
+ </jar>
+ </target>
+ <target name="jar.nomanifest" depends="compile" unless="module.manifest">
+ <jar destfile="${module.jar}">
+ <metainf dir="${project.root}${file.separator}resources/" />
+ <fileset dir="${module.classes}" casesensitive="yes">
<include name="**/**"/>
- <exclude name="org/apache/qpid/management/servlet/*"/>
- <exclude name="org/apache/qpid/management/wsdm/**"/>
- <exclude name="org/apache/qpid/qman/**"/>
<exclude name="wsdl/**"/>
<exclude name="muse.xml"/>
<exclude name="router-entries/**"/>
</fileset>
- </jar>
- </target>
-
- <target name="clean-wsdm-module" description="Clean up web module directory before proceed.">
- <delete dir="${web.module}"/>
- </target>
+ </jar>
+ </target>
+ <target name="postbuild" depends="prepare-wsdm-module" description="Build WS-DM module"/>
+ <path id="module.test.path">
+ <pathelement path="${module.test.classes}" />
+ <path refid="module.test.libs"/>
+ <fileset dir="${build}/lib">
+ <include name="qpid-client-*.jar"/>
+ <include name="qpid-common-*.jar"/>
+ <include name="qpid-management-client-*.jar"/>
+ <exclude name="qpid-client-example*.jar"/>
+ <exclude name="qpid-client-tests*.jar"/>
+ <exclude name="qpid-common-tests*.jar"/>
+ <exclude name="qpid-management-client-tests*.jar"/>
+ </fileset>
+ </path>
+ <target name="test" depends="build,compile-tests" if="module.test.src.exists" unless="${dontruntest}" description="execute unit tests">
+ <delete file="${module.failed}"/>
+ <echo message="Using config:${config}" level="info"/>
+ <junit fork="${test.fork}" maxmemory="1024M" reloading="no"
+ haltonfailure="${haltonfailure}" haltonerror="${haltonerror}"
+ failureproperty="test.failures" printsummary="on" timeout="600000" >
+
+ <jvmarg value="${jvm.args}"/>
+ <sysproperty key="qman.war" value="${web.module}"/>
+
+ <formatter type="plain"/>
+ <formatter type="xml"/>
- <target name="clenaup-wsdm-module-tmp-files" description="Clean up all the temporary files used for build WSDM module.">
- <delete dir="${web-inf.folder}"/>
- </target>
+ <classpath refid="module.test.path"/>
- <target name="create-wsdm-module" description="Creates WSDM Module (Web Application Archive ).">
- <jar destfile="${web.module}/${war.name}" basedir="${web.module}"/>
- </target>
-
- <target name="postbuild" depends="clean-wsdm-module,prepare-wsdm-module,create-wsdm-module,clenaup-wsdm-module-tmp-files" description="Build WS-DM module"/>
+ <batchtest fork="${test.fork}" todir="${module.results}">
+ <fileset dir="${module.test.src}" excludes="${module.test.excludes}">
+ <include name="**/${test}.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ <antcall target="touch-failed"/>
+ <condition property="failed">
+ <and>
+ <isfalse value="${test.failures.ignore}"/>
+ <available file="${module.failed}"/>
+ </and>
+ </condition>
+ <fail if="failed" message="TEST SUITE FAILED"/>
+ </target>
</project>
\ No newline at end of file
Modified: qpid/trunk/qpid/java/management/client/src/main/java/muse.xml
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/muse.xml?rev=737182&r1=737181&r2=737182&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/muse.xml (original)
+++ qpid/trunk/qpid/java/management/client/src/main/java/muse.xml Fri Jan 23 12:44:48 2009
@@ -13,6 +13,10 @@
<java-serializer-class>org.apache.qpid.management.wsdm.muse.serializer.MapSerializer</java-serializer-class>
</custom-serializer>
<custom-serializer>
+ <java-serializable-type>java.util.HashMap</java-serializable-type>
+ <java-serializer-class>org.apache.qpid.management.wsdm.muse.serializer.MapSerializer</java-serializer-class>
+ </custom-serializer>
+ <custom-serializer>
<java-serializable-type>java.util.UUID</java-serializable-type>
<java-serializer-class>org.apache.qpid.management.wsdm.muse.serializer.UUIDSerializer</java-serializer-class>
</custom-serializer>
@@ -20,11 +24,15 @@
<java-serializable-type>org.apache.qpid.management.wsdm.capabilities.Result</java-serializable-type>
<java-serializer-class>org.apache.qpid.management.wsdm.muse.serializer.InvocationResultSerializer</java-serializer-class>
</custom-serializer>
+ <custom-serializer>
+ <java-serializable-type>java.util.Date</java-serializable-type>
+ <java-serializer-class>org.apache.qpid.management.wsdm.muse.serializer.DateSerializer</java-serializer-class>
+ </custom-serializer>
<router>
<java-router-class>org.apache.muse.core.routing.SimpleResourceRouter</java-router-class>
<logging>
<log-file>log/muse.log</log-file>
- <log-level>FINE</log-level>
+ <log-level>SEVERE</log-level>
</logging>
<persistence>
<java-persistence-class>org.apache.muse.core.routing.RouterFilePersistence</java-persistence-class>
Modified: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Messages.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Messages.java?rev=737182&r1=737181&r2=737182&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Messages.java (original)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Messages.java Fri Jan 23 12:44:48 2009
@@ -108,6 +108,8 @@
String QMAN_200040_WS_ARTIFACTS_CACHED = "<QMAN-200040> : WS Artifacts has been stored on cache with the following id : %s";
String QMAN_200041_INCOMING_OBJECT_NAME_AND_DERIVED_KEY = "<QMAN-200041> : Incoming object name : %s, derived search key : %s";
String QMAN_200042_REMOVING_RESOURCE = "<QMAN-200042> : WS-Resource %s is going to be removed";
+ String QMAN_200043_GENERATED_ACCESSOR_METHOD = "<QMAN-200043> : Generated accessor method for %s : %s";
+ String QMAN_200044_GENERATED_METHOD = "<QMAN-200044> : Generated method for %s : %s";
// WARNING
String QMAN_300001_MESSAGE_DISCARDED = "<QMAN-300001> : No handler has been configured for processing messages with \"%s\" as opcode. Message will be discarded.";
@@ -150,4 +152,10 @@
String QMAN_100032_WS_RESOURCE_NOT_YET_INITIALIZED = "<QMAN-100032> : Bad request has been received on this WS-Resource : Shutdown is not possible because the resource hasn't yet been initialized.";
String QMAN_100033_WS_RESOURCE_ALREADY_SHUTDOWN = "<QMAN-100033> : Bad request has been received on this WS-Resource : Shutdown is not possible because the resource has already been shutdown.";
String QMAN_100034_WSDL_SCHEMA_SECTION_NOT_FOUND = "<QMAN-100034> : Unable to get via XPath the schema section in WSDL.";
+ String QMAN_100035_RESOURCE_CAPABILITY_INVOCATION_FAILURE = "<QMAN-100035> : Resource thrown a failure while invoking a capability operation.";
+
+ // NEW
+ String QMAN_100035_GET_ATTRIBUTE_FAILURE = "<QMAN-100035> : Get Attribute invocation failure for attribute %s, resource %s.";
+ String QMAN_100036_SET_ATTRIBUTE_FAILURE = "<QMAN-100036> : Set Attribute invocation failure for attribute %s, resource %s.";
+ String QMAN_100037_INVOKE_OPERATION_FAILURE = "<QMAN-100037> : Operation Invocation failure for operation.";
}
\ No newline at end of file
Modified: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Names.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Names.java?rev=737182&r1=737181&r2=737182&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Names.java (original)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Names.java Fri Jan 23 12:44:48 2009
@@ -141,5 +141,6 @@
public final static String TYPE = "type";
public final static String XSI_TYPE = "xsi:"+TYPE;
- public final static String ADAPTER_PORT= "qman.port";
+ public final static String ADAPTER_HOST_PROPERTY_NAME = "qman.host";
+ public final static String ADAPTER_PORT_PROPERTY_NAME = "qman.port";
}
\ No newline at end of file
Modified: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/InvocationResult.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/InvocationResult.java?rev=737182&r1=737181&r2=737182&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/InvocationResult.java (original)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/InvocationResult.java Fri Jan 23 12:44:48 2009
@@ -36,7 +36,7 @@
public class InvocationResult implements Serializable
{
private static final long serialVersionUID = 2062662997326399693L;
-
+
private final long _returnCode;
private final String _statusText;
private final byte [] _outputAndBidirectionalArgumentValues;
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/QpidDomainObject.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/QpidDomainObject.java?rev=737182&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/QpidDomainObject.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/QpidDomainObject.java Fri Jan 23 12:44:48 2009
@@ -0,0 +1,307 @@
+/*
+ *
+ * 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.management.domain.handler.impl;
+
+import java.net.URI;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.qpid.management.domain.services.MethodInvocationException;
+
+/**
+ * This is a sample entity used on QMan test case.
+ *
+ * @author Andrea Gazzarini
+ */
+public class QpidDomainObject implements QpidDomainObjectMBean
+{
+ private UUID _vhostRef;
+ private String _name;
+ private Boolean _durable;
+ private Map<String, Object> _arguments;
+ private Long _msgTotalEnqueues;
+ private Integer _consumerCount;
+ private Short _mgmtPubInterval;
+ private Date _expireTime;
+ private String _type;
+
+ /**
+ * Builds a new QpidDomainObject with default values for
+ * its properties.
+ */
+ public QpidDomainObject()
+ {
+ _vhostRef = UUID.randomUUID();
+ _name = "Initial Name";
+ _durable = Boolean.TRUE;
+ _arguments = new HashMap<String, Object>();
+ _arguments.put("Key1", "aStringValue");
+ _arguments.put("Key2", Long.MIN_VALUE);
+ _arguments.put("Key3", Integer.MAX_VALUE);
+ _arguments.put("Key4", Double.MIN_VALUE);
+ _arguments.put("Key4", Float.MAX_VALUE);
+
+ _msgTotalEnqueues = Long.MAX_VALUE-10;
+ _consumerCount = Integer.MIN_VALUE+10;
+ _mgmtPubInterval = Short.MAX_VALUE;
+ _expireTime = new Date(Long.MAX_VALUE);
+ }
+
+ /**
+ * A method that is throwing an exception, everytime.
+ *
+ * @throws Exception each time the method is called.
+ */
+ public void throwsException() throws Exception
+ {
+ throw new MethodInvocationException(-1,"KO");
+ }
+
+ /**
+ * Sample echo method that return an empty result object.
+ * That is, an object with only status code / text valorized
+ * (no output parameters).
+ *
+ * @return an empty result object.
+ */
+ public InvocationResult voidWithoutArguments()
+ {
+ return new InvocationResult(0,"OK,null",null);
+ }
+
+ /**
+ * Echo method that accepts and returns primitive type arrays.
+ *
+ * @param longs an array of long.
+ * @param booleans an array of boolean.
+ * @param doubles an array of double.
+ * @param floats an array of float.
+ * @param integers an array of int.
+ * @param shorts an array of short.
+ * @return a result object with the same input parameters (as output parameters).
+ */
+ public InvocationResult echoWithSimpleTypeArrays(
+ long [] longs,
+ boolean [] booleans,
+ double [] doubles,
+ float [] floats,
+ int [] integers,
+ short [] shorts)
+ {
+ InvocationResult result = new InvocationResult(0,"OK",null);
+ Map<String, Object> outputParameters = new HashMap<String, Object>();
+ outputParameters.put(long.class.getName(), longs);
+ outputParameters.put(boolean.class.getName(), booleans);
+ outputParameters.put(double.class.getName(), doubles);
+ outputParameters.put(float.class.getName(), floats);
+ outputParameters.put(int.class.getName(), integers);
+ outputParameters.put(short.class.getName(), shorts);
+ result.setOutputSection(outputParameters);
+ return result;
+ }
+
+ /**
+ * Echo method that accepts and returns wrapper types.
+ *
+ * @param aLong a java.lang.Long
+ * @param aBoolean a java.lang.Boolean
+ * @param aDouble a java.lang.Double
+ * @param aFloat a java.lang.Float
+ * @param anInteger a java.lang.Integer
+ * @param aShort a java.lang.Short
+ * @param aString a java.lang.String
+ * @param anURI a java.net.URI
+ * @param aDate a java.util.Date
+ * @return a result object with the same given parameters (as output parameters)
+ */
+ public InvocationResult echoWithSimpleTypes(
+ Long aLong,
+ Boolean aBoolean,
+ Double aDouble,
+ Float aFloat,
+ Integer anInteger,
+ Short aShort,
+ String aString,
+ URI anURI,
+ Date aDate)
+ {
+ InvocationResult result = new InvocationResult(0,"OK",null);
+ Map<String, Object> outputParameters = new HashMap<String, Object>();
+ outputParameters.put("p1", aLong);
+ outputParameters.put("p2", aBoolean);
+ outputParameters.put("p3", aDouble);
+ outputParameters.put("p4", aFloat);
+ outputParameters.put("p5", anInteger);
+ outputParameters.put("p6", aShort);
+ outputParameters.put("p7", aString);
+ outputParameters.put("p8", anURI);
+ outputParameters.put("p9", aDate);
+ result.setOutputSection(outputParameters);
+ return result;
+ }
+
+ /**
+ * Echo method that accepts and returns wrapper type arrays .
+ *
+ * @param longs an array of java.lang.Long
+ * @param booleans an array of java.lang.Boolean
+ * @param doubles an array of java.lang.Double
+ * @param floats an array of java.lang.Float
+ * @param integers an array of java.lang.Integer
+ * @param shorts an array of java.lang.Short
+ * @param strings an array of java.lang.String
+ * @param uris an array of java.net.URI
+ * @param dates an array of java.util.Date
+ * @return a result object with the same input parameters (as output parameters).
+ */
+ public InvocationResult echoWithArrays(
+ Long [] longs,
+ Boolean [] booleans,
+ Double [] doubles,
+ Float [] floats,
+ Integer [] integers,
+ Short [] shorts,
+ String [] strings,
+ URI [] uris,
+ Date [] dates)
+ {
+ InvocationResult result = new InvocationResult(0,"OK",null);
+ Map<String, Object> outputParameters = new HashMap<String, Object>();
+ outputParameters.put(Long.class.getName(), longs);
+ outputParameters.put(Boolean.class.getName(), booleans);
+ outputParameters.put(Double.class.getName(), doubles);
+ outputParameters.put(Float.class.getName(), floats);
+ outputParameters.put(Integer.class.getName(), integers);
+ outputParameters.put(Short.class.getName(), shorts);
+ outputParameters.put(String.class.getName(), strings);
+ outputParameters.put(URI.class.getName(), uris);
+ outputParameters.put(Date.class.getName(), dates);
+ result.setOutputSection(outputParameters);
+ return result;
+ }
+
+ /**
+ * Echo method that accepts and returns a byte array.
+ *
+ * @param byteArray a byte array
+ * @return a result containing the input byte array (as output parameter)
+ */
+ public InvocationResult echoWithByteArray(byte [] byteArray)
+ {
+ InvocationResult result = new InvocationResult(0,"OK",null);
+ Map<String, Object> outputParameters = new HashMap<String, Object>();
+ outputParameters.put(byte[].class.getName(),byteArray);
+ result.setOutputSection(outputParameters);
+ return result;
+ }
+
+ /**
+ * Echo method that accepts and returns an UUID.
+ *
+ * @param uuid a java.util.UUID.
+ * @return a result containing the input UUID (as output parameter)
+ */
+ public InvocationResult echoWithUUID(UUID uuid)
+ {
+ InvocationResult result = new InvocationResult(0,"OK",null);
+ Map<String, Object> outputParameters = new HashMap<String, Object>();
+ outputParameters.put("uuid",uuid);
+ result.setOutputSection(outputParameters);
+ return result;
+ }
+
+ /**
+ * Echo method that accepts and returns a Map.
+ *
+ * @param map a java.util.Map.
+ * @return a result containing the input Map (as output parameter)
+ */
+ public InvocationResult echoWithMap(Map<String,Object> map)
+ {
+ InvocationResult result = new InvocationResult(0,"OK",null);
+ Map<String, Object> outputParameters = new HashMap<String, Object>();
+ outputParameters.put("map",map);
+ result.setOutputSection(outputParameters);
+ return result;
+ }
+
+ public UUID getVhostRef()
+ {
+ return _vhostRef;
+ }
+
+ public String getName()
+ {
+ return _name;
+ }
+
+ public Boolean getDurable()
+ {
+ return _durable;
+ }
+
+ public Map<String, Object> getArguments()
+ {
+ return _arguments;
+ }
+
+ public Long getMsgTotalEnqueues()
+ {
+ return _msgTotalEnqueues;
+ }
+
+ public Integer getConsumerCount()
+ {
+ return _consumerCount;
+ }
+
+ public Date getExpireTime()
+ {
+ return _expireTime;
+ }
+
+ public Short getMgmtPubInterval()
+ {
+ return _mgmtPubInterval;
+ }
+
+ public void setExpireTime(Date expireTime)
+ {
+ this._expireTime = expireTime;
+ }
+
+ public void setMgmtPubInterval(Short value)
+ {
+ this._mgmtPubInterval = value;
+ }
+
+ public void setType(String type)
+ {
+ this._type = type;
+ }
+
+ public String getType()
+ {
+ return _type;
+ }
+}
\ No newline at end of file
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/QpidDomainObjectMBean.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/QpidDomainObjectMBean.java?rev=737182&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/QpidDomainObjectMBean.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/QpidDomainObjectMBean.java Fri Jan 23 12:44:48 2009
@@ -0,0 +1,227 @@
+/*
+ *
+ * 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.management.domain.handler.impl;
+
+import java.net.URI;
+import java.util.Date;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * Management interface for Qpid domain object.
+ *
+ * @author Andrea Gazzarini
+ */
+public interface QpidDomainObjectMBean
+{
+ /**
+ * A method that is throwing an exception, everytime.
+ *
+ * @throws Exception each time the method is called.
+ */
+ void throwsException() throws Exception;
+
+ /**
+ * Sample echo method that return an empty result object.
+ * That is, an object with only status code / text valorized
+ * (no output parameters).
+ *
+ * @return an empty result object.
+ */
+ InvocationResult voidWithoutArguments();
+
+ /**
+ * Echo method that accepts and returns wrapper types.
+ *
+ * @param aLong a java.lang.Long
+ * @param aBoolean a java.lang.Boolean
+ * @param aDouble a java.lang.Double
+ * @param aFloat a java.lang.Float
+ * @param anInteger a java.lang.Integer
+ * @param aShort a java.lang.Short
+ * @param aString a java.lang.String
+ * @param anURI a java.net.URI
+ * @param aDate a java.util.Date
+ * @return a result object with the same given parameters (as output parameters)
+ */
+ InvocationResult echoWithSimpleTypes(
+ Long aLong,
+ Boolean aBoolean,
+ Double aDouble,
+ Float aFloat,
+ Integer anInteger,
+ Short aShort,
+ String aString,
+ URI anURI,
+ Date aDate);
+
+ /**
+ * Echo method that accepts and returns wrapper type arrays .
+ *
+ * @param longs an array of java.lang.Long
+ * @param booleans an array of java.lang.Boolean
+ * @param doubles an array of java.lang.Double
+ * @param floats an array of java.lang.Float
+ * @param integers an array of java.lang.Integer
+ * @param shorts an array of java.lang.Short
+ * @param strings an array of java.lang.String
+ * @param uris an array of java.net.URI
+ * @param dates an array of java.util.Date
+ * @return a result object with the same input parameters (as output parameters).
+ */
+ InvocationResult echoWithArrays(
+ Long [] longs,
+ Boolean [] booleans,
+ Double [] doubles,
+ Float [] floats,
+ Integer [] integers,
+ Short [] shorts,
+ String [] strings,
+ URI [] uris,
+ Date [] dates);
+
+ /**
+ * Echo method that accepts and returns primitive type arrays.
+ *
+ * @param longs an array of long.
+ * @param booleans an array of boolean.
+ * @param doubles an array of double.
+ * @param floats an array of float.
+ * @param integers an array of int.
+ * @param shorts an array of short.
+ * @return a result object with the same input parameters (as output parameters).
+ */
+ InvocationResult echoWithSimpleTypeArrays(
+ long [] longs,
+ boolean [] booleans,
+ double [] doubles,
+ float [] floats,
+ int [] integers,
+ short [] shorts);
+
+ /**
+ * Echo method that accepts and returns a byte array.
+ *
+ * @param byteArray a byte array
+ * @return a result containing the input byte array (as output parameter)
+ */
+ InvocationResult echoWithByteArray(byte [] byteArray);
+
+ /**
+ * Echo method that accepts and returns an UUID.
+ *
+ * @param uuid a java.util.UUID.
+ * @return a result containing the input UUID (as output parameter)
+ */
+ InvocationResult echoWithUUID(UUID uuid);
+
+ /**
+ * Echo method that accepts and returns a Map.
+ *
+ * @param map a java.util.Map.
+ * @return a result containing the input Map (as output parameter)
+ */
+ InvocationResult echoWithMap(Map<String,Object> map);
+
+ /**
+ * Returns the VHostRef property value.
+ *
+ * @return the VHostRef property value.
+ */
+ UUID getVhostRef();
+
+ /**
+ * Returns the name property value.
+ *
+ * @return the name property value.
+ */
+ String getName();
+
+ /**
+ * Returns the durable property value.
+ *
+ * @return the durable property value.
+ */
+ Boolean getDurable();
+
+ /**
+ * Returns the arguments property value.
+ *
+ * @return the arguments property value.
+ */
+ Map<String, Object> getArguments();
+
+ /**
+ * Returns the msgTotalEnqueues property value.
+ *
+ * @return the msgTotalEnqueues property value.
+ */
+ Long getMsgTotalEnqueues();
+
+ /**
+ * Returns the consumerCount property value.
+ *
+ * @return the consumerCount property value.
+ */
+ Integer getConsumerCount();
+
+ /**
+ * Returns the mgmtPubInterval property value.
+ *
+ * @return the mgmtPubInterval property value.
+ */
+ Short getMgmtPubInterval();
+
+ /**
+ * Sets the mgmtPubInterval property value.
+ *
+ * @param the mgmtPubInterval property value.
+ */
+ void setMgmtPubInterval(Short mgmtPubInterval);
+
+ /**
+ * Returns the expireTime property value.
+ *
+ * @return the expireTime property value.
+ */
+ Date getExpireTime();
+
+ /**
+ * Sets the expireTime property value.
+ *
+ * @return the expireTime property value.
+ */
+ void setExpireTime(Date expireTime);
+
+ /**
+ * Returns the type property value.
+ *
+ * @return the type property value.
+ */
+ void setType(String type);
+
+ /**
+ * Sets the type property value.
+ *
+ * @return the type property value.
+ */
+ String getType();
+}
\ No newline at end of file
Modified: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidClass.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidClass.java?rev=737182&r1=737181&r2=737182&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidClass.java (original)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidClass.java Fri Jan 23 12:44:48 2009
@@ -368,7 +368,6 @@
OperationHasBeenInvokedNotification notification = null;
try
{
- // TODO : Overloaded methods
QpidMethod method = _methods.get(actionName);
if (method != null)
{
@@ -384,12 +383,14 @@
notification = new OperationHasBeenInvokedNotification(actionName,params,signature,exception);
throw exception;
}
- } else {
+ } else
+ {
ReflectionException exception = new ReflectionException(new NoSuchMethodException(actionName));
notification = new OperationHasBeenInvokedNotification(actionName,params,signature,exception);
throw exception;
}
- }finally {
+ } finally
+ {
sendNotification(notification);
}
}
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmu.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmu.java?rev=737182&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmu.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmu.java Fri Jan 23 12:44:48 2009
@@ -0,0 +1,124 @@
+/*
+ *
+ * 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.management.wsdm;
+
+import javax.management.MBeanRegistration;
+import javax.management.MBeanServer;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.ObjectName;
+
+import org.apache.qpid.management.Names;
+import org.apache.qpid.management.domain.handler.impl.QpidDomainObject;
+import org.apache.qpid.management.domain.handler.impl.QpidDomainObjectMBean;
+import org.apache.qpid.management.jmx.EntityLifecycleNotification;
+
+/**
+ * QEmu is basically an instance creator that is installed separately
+ * as part of QMan test cases & examples.
+ * Reason for that is to emulate object creation (queues, exchanges, etc...) without having Qpid broker
+ * connected and therefore controlling the total number of the instances that are created.
+ *
+ * @author Andrea Gazzarini
+ */
+public class QEmu extends NotificationBroadcasterSupport implements QEmuMBean, MBeanRegistration{
+
+ private MBeanServer _mxServer;
+ private final static String PACKAGE_NAME= "org.apache.qpid";
+ private final static String QUEUE = "queue";
+
+ /**
+ * Unregisters a Queue MBean with MBeanServer.
+ *
+ * @param objectName the name of the MBean that must unregistered.
+ * @throws Exception when the creation or the registration fails.
+ */
+ public void unregister(ObjectName objectName) throws Exception
+ {
+ _mxServer.unregisterMBean(objectName);
+ sendNotification(EntityLifecycleNotification.INSTANCE_REMOVED,objectName);
+ }
+
+ /**
+ * Creates and registers a Queue MBean with MBeanServer.
+ *
+ * @param objectName the name of the queue MBean.
+ * @throws Exception when the creation or the registration fails.
+ */
+ public void createQueue(ObjectName objectName) throws Exception
+ {
+ QpidDomainObjectMBean queue = new QpidDomainObject();
+ _mxServer.registerMBean(queue, objectName);
+
+ sendNotification(EntityLifecycleNotification.INSTANCE_ADDED,objectName);
+ }
+
+ /**
+ * Sends a notification about a lifecycle event of the mbean associated
+ * with the given object.
+ *
+ * @param type the event (notification) type.
+ * @param name the name of the event source.
+ */
+ private void sendNotification(String type,ObjectName name)
+ {
+ sendNotification(
+ new EntityLifecycleNotification(
+ type,
+ PACKAGE_NAME,
+ QUEUE,
+ Names.CLASS,
+ name));
+ }
+
+ /**
+ * Not implemented for this class.
+ */
+ public void postDeregister()
+ {
+ // N.A.
+ }
+
+ /**
+ * Not implemented for this class.
+ */
+ public void postRegister(Boolean registrationDone)
+ {
+ // N.A.
+ }
+
+ /**
+ * Not implemented for this class.
+ */
+ public void preDeregister()
+ {
+ // N.A.
+ }
+
+ /**
+ * MBean server callback.
+ * Stores the value of the owner MBeanServer.
+ */
+ public ObjectName preRegister(MBeanServer server, ObjectName name)
+ {
+ this._mxServer = server;
+ return name;
+ }
+}
\ No newline at end of file
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmuInitializer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmuInitializer.java?rev=737182&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmuInitializer.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmuInitializer.java Fri Jan 23 12:44:48 2009
@@ -0,0 +1,92 @@
+/*
+ *
+ * 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.management.wsdm;
+
+import java.lang.management.ManagementFactory;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.qpid.management.Messages;
+import org.apache.qpid.management.Names;
+import org.apache.qpid.transport.util.Logger;
+
+/**
+ * QPid Emulator Initializer.
+ * This component is basically responsible to create and initialize an emulator module used
+ * for simulate object instances creation.
+ *
+ * @author Andrea Gazzarini
+ */
+public class QEmuInitializer extends HttpServlet
+{
+ private static final long serialVersionUID = 6149614872902682208L;
+ private final static Logger LOGGER = Logger.get(QEmuInitializer.class);
+
+ /**
+ * QEmu initialization method.
+ *
+ * @throws ServletException when the module cannot be initialized.
+ */
+ public void init() throws ServletException
+ {
+ try
+ {
+ ManagementFactory.getPlatformMBeanServer().registerMBean(
+ new QEmu(),
+ Names.QPID_EMULATOR_OBJECT_NAME);
+ } catch(Exception exception)
+ {
+ LOGGER.warn(exception,Messages.QMAN_300005_QEMU_INITIALIZATION_FAILURE);
+ throw new ServletException(exception);
+ }
+ }
+
+ /**
+ * This is a startup module only so an override of the default servlet
+ * behaviour must be done in order to prevent incoming http requests processing.
+ *
+ * @param request the http request.
+ * @param response the http response.
+ * @throws ServletException each time this method is called.
+ */
+ @Override
+ public void service(HttpServletRequest request,HttpServletResponse response) throws ServletException
+ {
+ throw new ServletException();
+ }
+
+ /**
+ * Unregister QPid emulator.
+ */
+ public void destroy()
+ {
+ try
+ {
+ ManagementFactory.getPlatformMBeanServer()
+ .unregisterMBean(Names.QPID_EMULATOR_OBJECT_NAME);
+ } catch (Exception exception)
+ {
+ }
+ }
+}
\ No newline at end of file
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmuMBean.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmuMBean.java?rev=737182&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmuMBean.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmuMBean.java Fri Jan 23 12:44:48 2009
@@ -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.management.wsdm;
+
+import javax.management.ObjectName;
+
+/**
+ * Management interface for QEmu.
+ *
+ * @author Andrea Gazzarini
+ * @see QEmu
+ */
+public interface QEmuMBean
+{
+ /**
+ * Creates and registers a Queue MBean with MBeanServer.
+ *
+ * @param objectName the name of the queue MBean.
+ * @throws Exception when the creation or the registration fails.
+ */
+ void createQueue(ObjectName name) throws Exception;
+
+ /**
+ * Unregisters a Queue MBean with MBeanServer.
+ *
+ * @param objectName the name of the MBean that must unregistered.
+ * @throws Exception when the creation or the registration fails.
+ */
+ void unregister(ObjectName name) throws Exception;
+}
\ No newline at end of file
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/DummyCapabilityBuilder.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/DummyCapabilityBuilder.java?rev=737182&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/DummyCapabilityBuilder.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/DummyCapabilityBuilder.java Fri Jan 23 12:44:48 2009
@@ -0,0 +1,61 @@
+/*
+ *
+ * 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.management.wsdm.capabilities;
+
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.ObjectName;
+
+import org.apache.muse.core.Environment;
+
+/**
+ * Dummy capability builder used for avoid duplicated builds for the
+ * same class.
+ *
+ * @author Andrea Gazzarini
+ */
+public class DummyCapabilityBuilder implements IArtifactBuilder
+{
+
+ public void begin(ObjectName objectName) throws BuilderException
+ {
+ }
+
+ public void endAttributes() throws BuilderException
+ {
+ }
+
+ public void endOperations() throws BuilderException
+ {
+ }
+
+ public void onAttribute(MBeanAttributeInfo attributeMetadata) throws BuilderException
+ {
+ }
+
+ public void onOperation(MBeanOperationInfo operationMetadata) throws BuilderException
+ {
+ }
+
+ public void setEnvironment(Environment environment)
+ {
+ }
+}
\ No newline at end of file
Modified: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapability.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapability.java?rev=737182&r1=737181&r2=737182&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapability.java (original)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapability.java Fri Jan 23 12:44:48 2009
@@ -21,7 +21,6 @@
package org.apache.qpid.management.wsdm.capabilities;
import java.lang.management.ManagementFactory;
-import java.lang.reflect.Array;
import javax.management.Attribute;
import javax.management.AttributeNotFoundException;
@@ -29,25 +28,16 @@
import javax.management.MBeanException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
-import javax.xml.namespace.QName;
-import org.apache.muse.core.serializer.Serializer;
-import org.apache.muse.core.serializer.SerializerRegistry;
-import org.apache.muse.util.ReflectUtils;
-import org.apache.muse.util.xml.XmlUtils;
-import org.apache.muse.ws.addressing.soap.SoapFault;
-import org.apache.muse.ws.resource.basefaults.BaseFault;
-import org.apache.muse.ws.resource.basefaults.WsbfUtils;
import org.apache.muse.ws.resource.impl.AbstractWsResourceCapability;
-import org.apache.muse.ws.resource.properties.ResourcePropertyCollection;
+import org.apache.qpid.management.Messages;
import org.apache.qpid.management.domain.handler.impl.InvocationResult;
import org.apache.qpid.management.domain.services.MethodInvocationException;
import org.apache.qpid.management.wsdm.common.EntityInstanceNotFoundFault;
import org.apache.qpid.management.wsdm.common.MethodInvocationFault;
import org.apache.qpid.management.wsdm.common.NoSuchAttributeFault;
import org.apache.qpid.management.wsdm.common.QManFault;
-import org.apache.qpid.management.wsdm.muse.serializer.ByteArraySerializer;
-import org.w3c.dom.Element;
+import org.apache.qpid.transport.util.Logger;
/**
* Abstract capability used for centralize common behaviour of the QMan
@@ -57,11 +47,11 @@
*/
public abstract class MBeanCapability extends AbstractWsResourceCapability
{
- private static final Element[] _NO_VALUES = new Element[0];
+ private static final Logger LOGGER = Logger.get(MBeanCapability.class);
protected final MBeanServer _mxServer;
protected ObjectName _objectName;
-
+
/**
* Builds a new capability related to the given object name.
*
@@ -93,7 +83,7 @@
* be found.
* @throws QManFault in case of internal system failure.
*/
- Object getAttribute(String attributeName) throws QManFault
+ Object getAttribute(String attributeName) throws NoSuchAttributeFault,EntityInstanceNotFoundFault,QManFault
{
try
{
@@ -110,6 +100,10 @@
_objectName);
} catch (Exception exception)
{
+ LOGGER.error(
+ Messages.QMAN_100035_GET_ATTRIBUTE_FAILURE,
+ attributeName,
+ _objectName);
throw new QManFault(
getWsResource().getEndpointReference(),
exception);
@@ -134,7 +128,7 @@
* @throws QManFault
* in case of internal system failure.
*/
- void setAttribute(String attributeName, Object value) throws QManFault
+ void setAttribute(String attributeName, Object value) throws NoSuchAttributeFault,EntityInstanceNotFoundFault,QManFault
{
try
{
@@ -151,6 +145,10 @@
_objectName);
} catch (Exception exception)
{
+ LOGGER.error(
+ Messages.QMAN_100036_SET_ATTRIBUTE_FAILURE,
+ attributeName,
+ _objectName);
throw new QManFault(
getWsResource().getEndpointReference(),
exception);
@@ -163,16 +161,31 @@
* @param operationName the name of the operation to be invoked.
* @param params parameters used for operation invocation.
* @param signature the operation / method signature.
- * @throws QManFault when invocation fails.
+ * @throws EntityInstanceNotFoundFault
+ * when the target MBean doesn't exist on Management server.
+ * @throws MethodInvocationFault
+ * when the invocation of the requested operation raises an exception.
+ * @throws QManFault
+ * in case of not-well known failure.
*/
- Result invoke(String operationName, Object [] params, String [] signature) throws QManFault
+ Result invoke(String operationName, Object [] params, String [] signature) throws EntityInstanceNotFoundFault, MethodInvocationFault,QManFault
{
try
{
- InvocationResult output = (InvocationResult) _mxServer.invoke(_objectName, operationName, params, signature);
- Result result = new Result(output.getReturnCode(),output.getStatusText(),output.getOutputSection());
+ InvocationResult output = (InvocationResult) _mxServer
+ .invoke(
+ _objectName,
+ operationName,
+ params,
+ signature);
+
+ Result result = new Result(
+ output.getReturnCode(),
+ output.getStatusText(),
+ output.getOutputSection());
+
return result;
- } catch (InstanceNotFoundException e)
+ } catch (InstanceNotFoundException exception)
{
throw new EntityInstanceNotFoundFault(
getWsResource().getEndpointReference(),
@@ -188,96 +201,23 @@
failure.getStatusText(),
failure.getReturnCode());
} else {
+ LOGGER.error(
+ Messages.QMAN_100037_INVOKE_OPERATION_FAILURE,
+ operationName,
+ _objectName);
throw new QManFault(
getWsResource().getEndpointReference(),
exception);
}
}catch(Exception exception)
{
+ LOGGER.error(
+ Messages.QMAN_100037_INVOKE_OPERATION_FAILURE,
+ operationName,
+ _objectName);
throw new QManFault(
getWsResource().getEndpointReference(),
exception);
}
}
-
- /**
- *
- * @param name
- * @param value
- * TODO : Vedi che poi fà co 'sto metodo che è un pò una monnezza!!!
- * @return The XML representation of the resource property value(s).
- *
- */
- @SuppressWarnings("unchecked")
- protected Element[] getPropertyElements(QName name, Object value) throws BaseFault {
- //
- // in this case, we have to determine if there IS a property
- // and it's null, or there is no property
- //
- if (value == null) {
- ResourcePropertyCollection props = getWsResource().getPropertyCollection();
-
- //
- // property is nillable - we say it exists. not 100% accurate,
- // but as close as we're going to get
- //
- if (props.getSchema().isNillable(name))
- return new Element[] { XmlUtils.createElement(name) };
-
- //
- // not nillable - must not exist
- //
- return _NO_VALUES;
- }
-
- //
- // in all other cases, we determine the type of the property
- // values and use that to serialize into XML
- //
- Object valuesArray = null;
- Class type = null;
- // TODO
- if (value.getClass().isArray()) {
- if (value.getClass() == byte[].class) {
- Serializer serializer = new ByteArraySerializer();
- try {
- return new Element[] { serializer.toXML(value, name) };
- } catch (SoapFault e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- valuesArray = value;
- type = ReflectUtils.getClassFromArrayClass(value.getClass());
- }
-
- else {
- valuesArray = new Object[] { value };
- type = value.getClass();
- }
-
- int length = Array.getLength(valuesArray);
- Element[] properties = new Element[length];
-
- SerializerRegistry registry = SerializerRegistry.getInstance();
- Serializer ser = registry.getSerializer(type);
-
- for (int n = 0; n < length; ++n)
- {
- properties[n] = serializeValue(ser, Array.get(valuesArray, n), name);
- }
- return properties;
- }
-
- private Element serializeValue(Serializer ser, Object value, QName name) throws BaseFault
- {
- try
- {
- return ser.toXML(value, name);
- } catch (SoapFault exception)
- {
- throw WsbfUtils.convertToFault(exception);
- }
- }
}
\ No newline at end of file
Modified: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilder.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilder.java?rev=737182&r1=737181&r2=737182&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilder.java (original)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilder.java Fri Jan 23 12:44:48 2009
@@ -35,14 +35,20 @@
import javax.xml.namespace.QName;
import org.apache.muse.core.Environment;
+import org.apache.qpid.management.Messages;
import org.apache.qpid.management.Names;
+import org.apache.qpid.management.wsdm.common.EntityInstanceNotFoundFault;
+import org.apache.qpid.management.wsdm.common.MethodInvocationFault;
+import org.apache.qpid.management.wsdm.common.NoSuchAttributeFault;
import org.apache.qpid.management.wsdm.common.QManFault;
+import org.apache.qpid.transport.util.Logger;
public class MBeanCapabilityBuilder implements IArtifactBuilder{
private final static String GET_PROPERTY_NAMES_METHOD_COMMON_PART = "public QName[] getPropertyNames() { return ";
private final static String GET_PROPERTY_NAMES_METHOD_WITH_ARRAY = GET_PROPERTY_NAMES_METHOD_COMMON_PART+" PROPERTIES;}";
private final static String GET_PROPERTY_NAMES_METHOD_WITH_EMPTY_ARRAY = GET_PROPERTY_NAMES_METHOD_COMMON_PART+" new QName[0];}";
+ private final static Logger LOGGER = Logger.get(MBeanCapabilityBuilder.class);
/**
* Handler interface definining operation needed to be peformed (by a concrete
@@ -67,7 +73,7 @@
* that is activated when this builder detects the presence of at least one property on the
* capability class.
*/
- private final EndAttributesHandler _atLeastThereIsOneProperty = new EndAttributesHandler() {
+ final EndAttributesHandler _atLeastThereIsOneProperty = new EndAttributesHandler() {
/**
* Creates the QName array instance member and the corresponding
@@ -81,7 +87,7 @@
{
_properties.deleteCharAt(_properties.length()-1);
_properties.append("};");
-
+
CtField properties = CtField.make(_properties.toString(), _capabilityClassDefinition);
_capabilityClassDefinition.addField(properties);
@@ -102,7 +108,7 @@
* that is activated when this builder detects that there are no properties defined for
* the capability class.
*/
- private final EndAttributesHandler _noPropertyHasBeenDefined= new EndAttributesHandler()
+ final EndAttributesHandler _noPropertyHasBeenDefined= new EndAttributesHandler()
{
/**
* Creates the getPropertyNames() that simply returns an empty QName array.
@@ -124,10 +130,192 @@
}
};
- private StringBuilder _properties = new StringBuilder("private static final QName[] PROPERTIES = new QName[]{ ");
- private CtClass _capabilityClassDefinition;
+ /**
+ * This is the active state for this builder when the requested class has never been
+ * built.
+ */
+ IArtifactBuilder _classNotAvailable = new IArtifactBuilder()
+ {
+
+ /**
+ * Build process begins.
+ * The given object name is used to build a minimal definition of the product class.
+ *
+ * @param objectName the name of the JMX entity.
+ * @throws BuilderException when the initial definiton of the capability cannot be created.
+ */
+ public void begin(ObjectName objectName) throws BuilderException
+ {
+ String className = objectName.getKeyProperty(Names.CLASS);
+ ClassPool pool = ClassPool.getDefault();
+ pool.insertClassPath(new ClassClassPath(MBeanCapabilityBuilder.class));
+ pool.importPackage(QName.class.getPackage().getName());
+ pool.importPackage(ObjectName.class.getPackage().getName());
+ pool.importPackage(QManFault.class.getPackage().getName());
+ pool.importPackage(Names.class.getPackage().getName());
+ pool.importPackage(Result.class.getPackage().getName());
+ pool.importPackage(NoSuchAttributeFault.class.getPackage().getName());
+ pool.importPackage(EntityInstanceNotFoundFault.class.getPackage().getName());
+ pool.importPackage(MethodInvocationFault.class.getPackage().getName());
+
+ _capabilityClassDefinition = pool.makeClass("org.apache.qpid.management.wsdm.capabilities."+className);
+ try
+ {
+ _capabilityClassDefinition.setSuperclass(pool.get(MBeanCapability.class.getName()));
+ } catch(Exception exception)
+ {
+ throw new BuilderException(exception);
+ }
+ }
+
+ public void endAttributes() throws BuilderException
+ {
+ _endAttributeHandler.endAttributes();
+ }
+
+ @SuppressWarnings("unchecked")
+ public void endOperations() throws BuilderException
+ {
+ try
+ {
+ _capabilityClass = _capabilityClassDefinition.toClass(
+ QManAdapterCapability.class.getClassLoader(),
+ QManAdapterCapability.class.getProtectionDomain());
+ } catch (Exception exception)
+ {
+ throw new BuilderException(exception);
+ }
+ }
+
+ /**
+ * Director callback.
+ * Attrbute metadata notification. With this callback the director informs this builder that the
+ * currently processed MBean has an attribute with the given metadata.
+ * This builder uses this information in order to add a property and the corresponding accessors
+ * to the capability class that is going to be built.
+ *
+ * @throws BuilderException bytecode manipulation / creation failure.
+ */
+ public void onAttribute(MBeanAttributeInfo attribute) throws BuilderException
+ {
+ String name = attribute.getName();
+ String type = attribute.getType();
+
+ try
+ {
+ type = Class.forName(type).getCanonicalName();
+
+ addPropertyMemberInstance(type, name);
+
+ String nameForAccessors = getNameForAccessors(name);
+
+ if (attribute.isReadable())
+ {
+ String accessor = generateGetter(type, nameForAccessors);
+ CtMethod getter = CtNewMethod.make(accessor,_capabilityClassDefinition);
+ _capabilityClassDefinition.addMethod(getter);
+ appendToPropertiesArray(name);
+
+ LOGGER.debug(
+ Messages.QMAN_200043_GENERATED_ACCESSOR_METHOD,
+ _objectName,
+ accessor);
+ }
+
+ if (attribute.isWritable())
+ {
+ String accessor = generateSetter(type, nameForAccessors);
+ CtMethod setter = CtNewMethod.make(accessor,_capabilityClassDefinition);
+ _capabilityClassDefinition.addMethod(setter);
+
+ LOGGER.debug(
+ Messages.QMAN_200043_GENERATED_ACCESSOR_METHOD,
+ _objectName,
+ accessor);
+ }
+ } catch(Exception exception)
+ {
+ throw new BuilderException(exception);
+ }
+ }
+
+ public void onOperation(MBeanOperationInfo operation) throws BuilderException
+ {
+ StringBuilder method = new StringBuilder();
+ try
+ {
+ method
+ .append("public Result ")
+ .append(operation.getName())
+ .append("( ");
+
+ for (MBeanParameterInfo parameter: operation.getSignature())
+ {
+ method
+ .append(Class.forName(parameter.getType()).getCanonicalName())
+ .append(' ')
+ .append(parameter.getName())
+ .append(',');
+ }
+
+ method.deleteCharAt(method.length()-1);
+ method.append(") throws EntityInstanceNotFoundFault, MethodInvocationFault,QManFault { return invoke(")
+ .append("\"").append(operation.getName()).append("\"")
+ .append(", new Object[]{ ");
+
+ for (MBeanParameterInfo parameter: operation.getSignature())
+ {
+ method.append(parameter.getName())
+ .append(',');
+ }
+
+ method.deleteCharAt(method.length()-1);
+ method.append("}, new String[]{ ");
+
+ for (MBeanParameterInfo parameter: operation.getSignature())
+ {
+ method
+ .append("\"")
+ .append(parameter.getType())
+ .append("\",");
+ }
+ method.deleteCharAt(method.length()-1);
+ method.append("}); }");
+
+ String methodAsString = method.toString();
+ methodAsString = methodAsString.replace("new Object[]{}","null");
+ methodAsString = methodAsString.replace("new String[]{}","null");
+
+ CtMethod definition = CtNewMethod.make(methodAsString,_capabilityClassDefinition);
+ _capabilityClassDefinition.addMethod(definition);
+ } catch(Exception exception)
+ {
+ throw new BuilderException(exception);
+ } finally {
+ if (LOGGER.isDebugEnabled())
+ {
+ LOGGER.debug(
+ Messages.QMAN_200044_GENERATED_METHOD,
+ _objectName,
+ method.toString());
+ }
+ }
+ }
+
+ public void setEnvironment(Environment environment)
+ {
+ // Nothing to do here...
+ }
+ };
+
+ StringBuilder _properties = new StringBuilder("private static final QName[] PROPERTIES = new QName[]{ ");
private Class<MBeanCapability> _capabilityClass;
- private EndAttributesHandler _endAttributeHandler = _noPropertyHasBeenDefined;
+ CtClass _capabilityClassDefinition;
+ EndAttributesHandler _endAttributeHandler = _noPropertyHasBeenDefined;
+
+ private ObjectName _objectName;
+
+ IArtifactBuilder _state;
/**
* Director callback.
@@ -140,31 +328,7 @@
*/
public void onAttribute(MBeanAttributeInfo attribute) throws BuilderException
{
- String name = attribute.getName();
- String type = attribute.getType();
- type = (type.startsWith("[B")) ? " byte[] " : type;
-
- try
- {
- addPropertyMemberInstance(type, name);
-
- String nameForAccessors =
- Character.toUpperCase(name.charAt(0)) +
- name.substring(1);
-
- if (attribute.isReadable())
- {
- generateGetter(type, nameForAccessors);
- }
-
- if (attribute.isWritable())
- {
- generateSetter(type, nameForAccessors);
- }
- } catch(Exception exception)
- {
- throw new BuilderException(exception);
- }
+ _state.onAttribute(attribute);
}
/**
@@ -174,25 +338,21 @@
* @param objectName the name of the target JMX entity of this capability.
* @throws BuilderException when the initialization fails.
*/
+ @SuppressWarnings("unchecked")
public void begin(ObjectName objectName) throws BuilderException
{
- String className = objectName.getKeyProperty(Names.CLASS);
- ClassPool pool = ClassPool.getDefault();
- pool.insertClassPath(new ClassClassPath(MBeanCapabilityBuilder.class));
- pool.importPackage(QName.class.getPackage().getName());
- pool.importPackage(ObjectName.class.getPackage().getName());
- pool.importPackage(QManFault.class.getPackage().getName());
- pool.importPackage(Names.class.getPackage().getName());
- pool.importPackage(Result.class.getPackage().getName());
-
- _capabilityClassDefinition = pool.makeClass("org.apache.qpid.management.wsdm.capabilities."+className);
- try
+ try
{
- _capabilityClassDefinition.setSuperclass(pool.get(MBeanCapability.class.getName()));
- } catch(Exception exception)
+ this._objectName = objectName;
+ String className = objectName.getKeyProperty(Names.CLASS);
+ _capabilityClass = (Class<MBeanCapability>) Class.forName("org.apache.qpid.management.wsdm.capabilities."+className);
+ _state = new DummyCapabilityBuilder();
+ } catch (ClassNotFoundException exception)
{
- throw new BuilderException(exception);
- }
+ _state = _classNotAvailable;
+ }
+
+ _state.begin(objectName);
}
/**
@@ -219,52 +379,7 @@
*/
public void onOperation(MBeanOperationInfo operation) throws BuilderException
{
- try
- {
- StringBuilder method = new StringBuilder()
- .append("public Result ")
- .append(operation.getName())
- .append("( ");
-
- for (MBeanParameterInfo parameter: operation.getSignature())
- {
- method
- .append(parameter.getType())
- .append(' ')
- .append(parameter.getName())
- .append(',');
- }
-
- method.deleteCharAt(method.length()-1);
- method.append(") throws QManFault { return invoke(")
- .append("\"").append(operation.getName()).append("\"")
- .append(", new Object[]{ ");
-
- for (MBeanParameterInfo parameter: operation.getSignature())
- {
- method.append(parameter.getName())
- .append(',');
- }
-
- method.deleteCharAt(method.length()-1);
- method.append("}, new String[]{ ");
-
- for (MBeanParameterInfo parameter: operation.getSignature())
- {
- method
- .append("\"")
- .append(parameter.getType())
- .append("\",");
- }
- method.deleteCharAt(method.length()-1);
- method.append("}); }");
-
- CtMethod definition = CtNewMethod.make(method.toString(),_capabilityClassDefinition);
- _capabilityClassDefinition.addMethod(definition);
- } catch(Exception exception)
- {
- throw new BuilderException(exception);
- }
+ _state.onOperation(operation);
}
/**
@@ -289,7 +404,7 @@
*/
public void endAttributes() throws BuilderException
{
- _endAttributeHandler.endAttributes();
+ _state.endAttributes();
}
/**
@@ -303,15 +418,7 @@
@SuppressWarnings("unchecked")
public void endOperations() throws BuilderException
{
- try
- {
- _capabilityClass = _capabilityClassDefinition.toClass(
- QManAdapterCapability.class.getClassLoader(),
- QManAdapterCapability.class.getProtectionDomain());
- } catch (Exception exception)
- {
- throw new BuilderException(exception);
- }
+ _state.endOperations();
}
/**
@@ -321,7 +428,7 @@
*/
public void setEnvironment(Environment environment)
{
- // N.A.
+ // Nothing to do here...
}
/**
@@ -329,24 +436,22 @@
*
* @param type the type of the property.
* @param name the name of the property.
- * @throws CannotCompileException compilation failure while adding the new feature.
+ * @return the getter method (as a string).
*/
- private void generateGetter(String type, String name) throws CannotCompileException
+ String generateGetter(String type, String name)
{
- StringBuilder buffer = new StringBuilder()
+ return new StringBuilder()
.append("public ")
.append(type)
.append(' ')
.append("get")
.append(name)
- .append("() throws QManFault { return (").append(type).append(") getAttribute(\"")
+ .append("() throws NoSuchAttributeFault,EntityInstanceNotFoundFault,QManFault { return (")
+ .append(type)
+ .append(") getAttribute(\"")
.append(name)
- .append("\"); }");
-
- CtMethod getter = CtNewMethod.make(buffer.toString(),_capabilityClassDefinition);
- _capabilityClassDefinition.addMethod(getter);
-
- appendToPropertiesArray(name);
+ .append("\"); }")
+ .toString();
}
/**
@@ -354,23 +459,21 @@
*
* @param type the type of the property.
* @param name the name of the property.
- * @throws CannotCompileException compilation failure while adding the new feature.
+ * @return the setter method (as a string).
*/
- private void generateSetter(String type, String name) throws CannotCompileException
+ String generateSetter(String type, String name)
{
- StringBuilder buffer = new StringBuilder()
+ return new StringBuilder()
.append("public void ")
.append("set")
.append(name)
.append("(")
.append(type)
- .append(" newValue) throws QManFault {")
+ .append(" newValue) throws NoSuchAttributeFault,EntityInstanceNotFoundFault,QManFault {")
.append(" setAttribute(\"")
.append(name)
- .append("\", newValue); }");
-
- CtMethod setter = CtNewMethod.make(buffer.toString(),_capabilityClassDefinition);
- _capabilityClassDefinition.addMethod(setter);
+ .append("\", newValue); }")
+ .toString();
}
/**
@@ -407,4 +510,20 @@
CtField field= CtField.make(buffer.toString(),_capabilityClassDefinition);
_capabilityClassDefinition.addField(field);
}
+
+ /**
+ * Returns a name that will be used in accessor methods.
+ * That name will differ from the given one because the first letter will be capitalized.
+ * For example, if the given name is "name" the return value will be "Name".
+ *
+ * @param name the plain name of the attribute.
+ * @return a capitalized version of the given name to be used in accessors.
+ */
+ String getNameForAccessors(String name)
+ {
+ return
+ Character.toUpperCase(name.charAt(0)) +
+ name.substring(1);
+ }
+
}
\ No newline at end of file
Modified: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManAdapterCapability.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManAdapterCapability.java?rev=737182&r1=737181&r2=737182&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManAdapterCapability.java (original)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManAdapterCapability.java Fri Jan 23 12:44:48 2009
@@ -38,7 +38,6 @@
import org.apache.muse.core.Resource;
import org.apache.muse.core.ResourceManager;
import org.apache.muse.core.routing.MessageHandler;
-import org.apache.muse.core.routing.ReflectionMessageHandler;
import org.apache.muse.core.serializer.SerializerRegistry;
import org.apache.muse.ws.addressing.EndpointReference;
import org.apache.muse.ws.addressing.soap.SoapFault;
@@ -293,7 +292,7 @@
QName returnValueName = new QName(Names.NAMESPACE_URI,name+"Response",Names.PREFIX);
String actionURI = Names.NAMESPACE_URI+"/"+name;
- MessageHandler handler = new ReflectionMessageHandler(actionURI, requestName, returnValueName);
+ MessageHandler handler = new QManMessageHandler(actionURI, requestName, returnValueName);
handler.setMethod(method);
handlers.add(handler);
}
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManMessageHandler.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManMessageHandler.java?rev=737182&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManMessageHandler.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManMessageHandler.java Fri Jan 23 12:44:48 2009
@@ -0,0 +1,103 @@
+/*
+ *
+ * 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.management.wsdm.capabilities;
+
+import java.lang.reflect.Method;
+
+import javax.xml.namespace.QName;
+
+import org.apache.muse.core.routing.ReflectionMessageHandler;
+import org.apache.muse.core.serializer.Serializer;
+import org.apache.muse.core.serializer.SerializerRegistry;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.addressing.soap.SoapFault;
+import org.apache.qpid.management.wsdm.muse.serializer.ByteArraySerializer;
+import org.w3c.dom.Element;
+
+/**
+ * A custom implementation of Muse message handler to properly deal with
+ * byte arrays.
+ *
+ * @author Andrea Gazzarini
+ */
+public class QManMessageHandler extends ReflectionMessageHandler
+{
+
+ /**
+ * Builds a new message handler with the given arguments.
+ *
+ * @param actionURI the action URI.
+ * @param requestQName the qname of the incoming request.
+ * @param returnValueName the qname of the result value.
+ */
+ public QManMessageHandler(String actionURI, QName requestQName,
+ QName returnValueName)
+ {
+ super(actionURI, requestQName, returnValueName);
+ }
+
+ /**
+ * Transforms the given xml element in the corresponding
+ * object representation.
+ *
+ * @throws SoapFaul when unmarshal operation fails.
+ */
+ public Object[] fromXML(Element xml) throws SoapFault
+ {
+ Method method = getMethod();
+
+ if (xml == null )
+ {
+ return EMPTY_REQUEST;
+ }
+
+ Class[] parameters = method.getParameterTypes();
+ Object[] objects = new Object[parameters.length];
+
+ Element[] elements = XmlUtils.getAllElements(xml);
+
+ if (parameters.length == 1 && elements.length == 0)
+ {
+ elements = new Element[]{ xml };
+ }
+
+ if (elements.length != parameters.length)
+ {
+ throw new SoapFault("IncorrectParams");
+ }
+
+ SerializerRegistry registry = SerializerRegistry.getInstance();
+
+ for (int i = 0; i < elements.length; ++i)
+ {
+ Class clazz = parameters[i];
+ if (clazz == byte[].class)
+ {
+ objects[i] = new ByteArraySerializer().fromXML(elements[i]);
+ } else
+ {
+ Serializer ser = registry.getSerializer(parameters[i]);
+ objects[i] = ser.fromXML(elements[i]);
+ }
+ }
+ return objects;
+ }
+}
\ No newline at end of file
Modified: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/RmdBuilder.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/RmdBuilder.java?rev=737182&r1=737181&r2=737182&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/RmdBuilder.java (original)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/RmdBuilder.java Fri Jan 23 12:44:48 2009
@@ -31,7 +31,7 @@
import org.apache.muse.util.xml.XmlUtils;
import org.apache.muse.ws.resource.metadata.WsrmdConstants;
import org.apache.qpid.management.Names;
-import org.apache.qpid.qman.debug.XmlDebugger;
+import org.apache.qpid.qman.debug.WsdlDebugger;
import org.w3c.dom.Element;
/**
@@ -45,7 +45,7 @@
{
private List<Element> _metadataDescriptor = new ArrayList<Element>();
- private ObjectName _objectName;
+ ObjectName _objectName;
/**
* Nothing to be done here on this builder.
@@ -96,7 +96,7 @@
: Names.READ_ONLY);
property.setAttribute(Names.MUTABILITY,Names.MUTABLE);
- XmlDebugger.debug(_objectName, property);
+ WsdlDebugger.debug(_objectName, property);
_metadataDescriptor.add(property);
}
Modified: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/WsArtifacts.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/WsArtifacts.java?rev=737182&r1=737181&r2=737182&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/WsArtifacts.java (original)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/WsArtifacts.java Fri Jan 23 12:44:48 2009
@@ -23,12 +23,32 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+/**
+ * Web Service Artifacts.
+ * Basically it acts as a container for all artifacts built when a new WS-Resource is created.
+ * With WS artifacts we mean :
+ *
+ * <ul>
+ * <li>Capability class (which encapsulate the WS-DM capability concern)</li>
+ * <li>WS Resource Metadata Descriptor (RMD)</li>
+ * <li>Web Service Description (WSDL)</li>
+ * </ul>
+ *
+ * @author Andrea Gazzarini
+ */
class WsArtifacts {
private final Class<MBeanCapability>_capabilityClass;
private final Element[] _resourceMetadataDescriptor;
private final Document _wsdl;
-
+
+ /**
+ * Builds a new artifacts container with the given artifacts.
+ *
+ * @param capabilityClass the capability class.
+ * @param resourceMetadataDescriptor the resource metadata descriptor.
+ * @param wsdl the wsdl.
+ */
public WsArtifacts(
Class<MBeanCapability> capabilityClass,
Element[] resourceMetadataDescriptor,
@@ -39,17 +59,34 @@
this._wsdl = wsdl;
}
- public Class<MBeanCapability> getCapabilityClass()
+ /**
+ * Returns the capability class.
+ *
+ * @return the capability class.
+ */
+ Class<MBeanCapability> getCapabilityClass()
{
return _capabilityClass;
}
- public Element[] getResourceMetadataDescriptor()
+ /**
+ * Returns the resource metadata descriptor.
+ * It is not a whole document but each property metadata is described in a
+ * separated element so the returned object is an array of elements.
+ *
+ * @return the resource metadata descriptor.
+ */
+ Element[] getResourceMetadataDescriptor()
{
return _resourceMetadataDescriptor;
}
- public Document getWsdl()
+ /**
+ * Returns the web service description.
+ *
+ * @return the web service description (WSDL).
+ */
+ Document getWsdl()
{
return _wsdl;
}
Modified: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/WsArtifactsFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/WsArtifactsFactory.java?rev=737182&r1=737181&r2=737182&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/WsArtifactsFactory.java (original)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/WsArtifactsFactory.java Fri Jan 23 12:44:48 2009
@@ -85,7 +85,8 @@
LOGGER.debug(
Messages.QMAN_200041_INCOMING_OBJECT_NAME_AND_DERIVED_KEY,
- objectName,searchKey);
+ objectName,
+ searchKey);
result = _cache.get(searchKey);
if (result == null)
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org