User: cgjung
Date: 02/03/12 03:04:46
Modified: jboss.net/src/main/org/jboss/net/jmx/adaptor
ObjectNameDeserializer.java
ObjectNameDeserializerFactory.java
ObjectNameSerializer.java
RemoteAdaptorInvocationHandler.java
Added: jboss.net/src/main/org/jboss/net/jmx/adaptor
ObjectNameSerializerFactory.java
Log:
Axis Beta RC1 is here. Needs no more to be patched for integrating with the
jboss classloading architecture. Lots of interna have changed, though.
Adapted the deployment descriptors to support WSDD now.
Revision Changes Path
1.2 +69 -12
contrib/jboss.net/src/main/org/jboss/net/jmx/adaptor/ObjectNameDeserializer.java
Index: ObjectNameDeserializer.java
===================================================================
RCS file:
/cvsroot/jboss/contrib/jboss.net/src/main/org/jboss/net/jmx/adaptor/ObjectNameDeserializer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ObjectNameDeserializer.java 12 Oct 2001 12:17:48 -0000 1.1
+++ ObjectNameDeserializer.java 12 Mar 2002 11:04:46 -0000 1.2
@@ -1,24 +1,81 @@
/*
- * ObjectNameDeserializer.java
+ * JBoss, the OpenSource J2EE webOS
*
- * Created on 2. Oktober 2001, 14:09
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
*/
+// $Id: ObjectNameDeserializer.java,v 1.2 2002/03/12 11:04:46 cgjung Exp $
+
package org.jboss.net.jmx.adaptor;
-import org.apache.axis.encoding.SOAPTypeMappingRegistry.BasicDeser;
+import org.apache.axis.encoding.DeserializerImpl;
+import org.apache.axis.encoding.DeserializationContext;
+
+import javax.xml.rpc.namespace.QName;
+
+import org.xml.sax.SAXException;
+
import javax.management.ObjectName;
/**
- *
- * @author jung
- * @version
+ * Deserializer that turns string-based XML-elements back
+ * into JMX objectnames.
+ * <br>
+ * <ul>
+ * <li> jung, 10.03.2002: made axis alpha3 compliant. </li>
+ * </ul>
+ * @created 2. Oktober 2001, 14:09
+ * @author <a href="mailto:[EMAIL PROTECTED]">Christoph G. Jung</a>
+ * @version $Revision: 1.2 $
*/
-public class ObjectNameDeserializer extends BasicDeser {
-
- public Object makeValue(String source) throws Exception {
- return new ObjectName(source);
- }
-
+public class ObjectNameDeserializer extends DeserializerImpl {
+
+ //
+ // Attributes
+ //
+
+ StringBuffer val=new StringBuffer();
+ protected QName xmlType;
+
+ //
+ // Constructors
+ //
+
+ public ObjectNameDeserializer(QName xmlType){
+ this.xmlType = xmlType;
+ }
+
+ /**
+ * Append any characters received to the value. This method is defined
+ * by Deserializer.
+ */
+ public void characters(char [] chars, int start, int end)
+ throws SAXException
+ {
+ val.append(chars, start, end);
+ }
+
+ /**
+ * Append any characters to the value. This method is defined by
+ * Deserializer.
+ */
+ public void onEndElement(String namespace, String localName,
+ DeserializationContext context)
+ throws SAXException
+ {
+ if (isNil) {
+ value = null;
+ return;
+ }
+
+ try {
+ value = new ObjectName(val.toString());
+ } catch (Exception e) {
+ throw new SAXException(e);
+ }
+
+ }
+
}
1.2 +62 -11
contrib/jboss.net/src/main/org/jboss/net/jmx/adaptor/ObjectNameDeserializerFactory.java
Index: ObjectNameDeserializerFactory.java
===================================================================
RCS file:
/cvsroot/jboss/contrib/jboss.net/src/main/org/jboss/net/jmx/adaptor/ObjectNameDeserializerFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ObjectNameDeserializerFactory.java 12 Oct 2001 12:17:48 -0000 1.1
+++ ObjectNameDeserializerFactory.java 12 Mar 2002 11:04:46 -0000 1.2
@@ -1,28 +1,79 @@
/*
- * ObjectNameDeSerializerFactory.java
+ * JBoss, the OpenSource J2EE webOS
*
- * Created on 2. Oktober 2001, 14:05
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
*/
+// $Id: ObjectNameDeserializerFactory.java,v 1.2 2002/03/12 11:04:46 cgjung Exp $
+
package org.jboss.net.jmx.adaptor;
import org.apache.axis.encoding.DeserializerFactory;
-import org.apache.axis.encoding.Deserializer;
+import javax.xml.rpc.encoding.Deserializer;
+import javax.xml.rpc.JAXRPCException;
+import javax.xml.rpc.namespace.QName;
+
+import javax.management.ObjectName;
+
+import java.util.Set;
+
/**
- *
- * @author jung
- * @version
+ * Factory for stateful ObjectName Deserialization.
+ * <br>
+ * <ul>
+ * <li> jung, 10.03.2002: made axis alpha3 compliant. </li>
+ * </ul>
+ * @created 2. Oktober 2001, 14:05
+ * @author <a href="mailto:[EMAIL PROTECTED]">Christoph G. Jung</a>
+ * @version $Revision: 1.2 $
*/
public class ObjectNameDeserializerFactory implements DeserializerFactory {
- /** Creates new ObjectNameDeSerializerFactory */
- public ObjectNameDeserializerFactory() {
+ //
+ // Attributes
+ //
+
+ final protected Set mechanisms=new java.util.HashSet(1);
+ final protected Class javaType;
+ final protected QName xmlType;
+
+ //
+ // Constructors
+ //
+
+ public ObjectNameDeserializerFactory(Class javaType, QName xmlType) throws
Exception {
+ if(!(ObjectName.class.isAssignableFrom(javaType))) {
+ throw new Exception("Could only build deserializers for JMX
ObjectName.");
+ }
+ mechanisms.add(org.apache.axis.Constants.AXIS_SAX);
+ this.javaType=javaType;
+ this.xmlType=xmlType;
+ }
+
+ //
+ // Public API
+ //
+
+ public Deserializer getDeserializerAs(String mechanismType)
+ throws JAXRPCException {
+ if(!mechanisms.contains(mechanismType)) {
+ throw new JAXRPCException("Unsupported mechanism
"+mechanismType);
+ }
+ return new ObjectNameDeserializer(xmlType);
}
+
- public Deserializer getDeserializer(Class cls) {
- return new ObjectNameDeserializer();
- }
+ /**
+ * Returns a list of all XML processing mechanism types supported by this
DeserializerFactory.
+ *
+ * @return List of unique identifiers for the supported XML processing
mechanism types
+ */
+ public java.util.Iterator getSupportedMechanismTypes() {
+ return mechanisms.iterator();
+ }
+
}
1.2 +77 -13
contrib/jboss.net/src/main/org/jboss/net/jmx/adaptor/ObjectNameSerializer.java
Index: ObjectNameSerializer.java
===================================================================
RCS file:
/cvsroot/jboss/contrib/jboss.net/src/main/org/jboss/net/jmx/adaptor/ObjectNameSerializer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ObjectNameSerializer.java 12 Oct 2001 12:17:48 -0000 1.1
+++ ObjectNameSerializer.java 12 Mar 2002 11:04:46 -0000 1.2
@@ -1,34 +1,98 @@
/*
- * ObjectNameSerializer.java
+ * JBoss, the OpenSource J2EE webOS
*
- * Created on 2. Oktober 2001, 14:01
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
*/
+// $Id: ObjectNameSerializer.java,v 1.2 2002/03/12 11:04:46 cgjung Exp $
+
package org.jboss.net.jmx.adaptor;
+import org.apache.axis.Constants;
import org.apache.axis.encoding.Serializer;
import org.apache.axis.encoding.SerializationContext;
-import org.apache.axis.utils.QName;
+import org.apache.axis.encoding.XMLType;
+import org.apache.axis.wsdl.fromJava.Types;
import org.xml.sax.Attributes;
+import org.w3c.dom.Element;
+
+import javax.xml.rpc.namespace.QName;
import javax.management.ObjectName;
import java.io.IOException;
/**
- *
- * @author jung
- * @version
+ * Serializer specialized to turn JMX-Objectnames into
+ * corresponding XML-types.
+ * <br>
+ * <ul>
+ * <li> jung, 10.03.2002: made axis alpha3 compliant. Added wsdl generation. </li>
+ * </ul>
+ * @created 2. Oktober 2001, 14:01
+ * @author <a href="mailto:[EMAIL PROTECTED]">Christoph G. Jung</a>
+ * @version $Revision: 1.2 $
*/
public class ObjectNameSerializer implements Serializer {
- public void serialize(QName name, Attributes attributes, Object value,
- SerializationContext context) throws IOException {
- context.startElement(name,attributes);
- context.writeString(((ObjectName) value).getCanonicalName());
- context.endElement();
- }
-
+ /** this is the fully-qualified type that we serialize into */
+ protected QName xmlType;
+
+ //
+ // Constructors
+ //
+
+ public ObjectNameSerializer(QName xmlType) {
+ this.xmlType = xmlType;
+ }
+
+ //
+ // Public API
+ //
+
+ /**
+ * turns a JMX objectname into a string-based xml element
+ * @param name the name of the element that carries our type
+ * @param attributes the attributes of the element that carries our type
+ * @param value the objectname to serialize
+ * @param context the serialization context we live into
+ */
+ public void serialize(
+ QName name,
+ Attributes attributes,
+ Object value,
+ SerializationContext context)
+ throws IOException {
+ context.startElement(name, attributes);
+ context.writeString(((ObjectName) value).getCanonicalName());
+ context.endElement();
+ }
+
+ /** we use sax approach */
+ public String getMechanismType() {
+ return Constants.AXIS_SAX;
+ }
+
+ /**
+ * Return XML schema for the specified type.
+ * Our type simply inherits from string.
+ */
+ public boolean writeSchema(Types types) throws Exception {
+ // Emit WSDL for simpleContent
+ javax.wsdl.QName qName = types.getWsdlQName(xmlType);
+ // ComplexType representation of SimpleType bean class
+ Element simpleType = types.createElement("simpleType");
+ types.writeSchemaElement(qName, simpleType);
+ simpleType.setAttribute("name", qName.getLocalPart());
+ Element simpleContent = types.createElement("simpleContent");
+ simpleType.appendChild(simpleContent);
+ Element extension = types.createElement("extension");
+ simpleContent.appendChild(extension);
+ extension.setAttribute("base", XMLType.XSD_STRING.toString());
+ return true;
+ }
+
}
1.3 +4 -8
contrib/jboss.net/src/main/org/jboss/net/jmx/adaptor/RemoteAdaptorInvocationHandler.java
Index: RemoteAdaptorInvocationHandler.java
===================================================================
RCS file:
/cvsroot/jboss/contrib/jboss.net/src/main/org/jboss/net/jmx/adaptor/RemoteAdaptorInvocationHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RemoteAdaptorInvocationHandler.java 16 Oct 2001 15:52:53 -0000 1.2
+++ RemoteAdaptorInvocationHandler.java 12 Mar 2002 11:04:46 -0000 1.3
@@ -5,31 +5,27 @@
* See terms of license at gnu.org.
*/
-// $Id: RemoteAdaptorInvocationHandler.java,v 1.2 2001/10/16 15:52:53 cgjung Exp $
+// $Id: RemoteAdaptorInvocationHandler.java,v 1.3 2002/03/12 11:04:46 cgjung Exp $
package org.jboss.net.jmx.adaptor;
import org.jboss.net.jmx.MBeanInvocationHandler;
-
-import org.apache.axis.client.ServiceClient;
-
-import java.rmi.RemoteException;
import java.net.URL;
/**
* An example client that accesses the JMXConnector via SOAP.
* @created 1. October, 2001
* @author <a href="mailto:[EMAIL PROTECTED]">Christoph G. Jung</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class RemoteAdaptorInvocationHandler {
- public static RemoteAdaptor createRemoteAdaptor(URL targetURL) throws
RemoteException {
+ public static RemoteAdaptor createRemoteAdaptor(URL targetURL) {
return (RemoteAdaptor)
MBeanInvocationHandler.createMBeanService(RemoteAdaptor.class,targetURL);
}
- public static RemoteAdaptor createRemoteAdaptor(MBeanInvocationHandler handler)
throws RemoteException {
+ public static RemoteAdaptor createRemoteAdaptor(MBeanInvocationHandler handler)
{
return (RemoteAdaptor)
MBeanInvocationHandler.createMBeanService(RemoteAdaptor.class,handler);
}
1.1
contrib/jboss.net/src/main/org/jboss/net/jmx/adaptor/ObjectNameSerializerFactory.java
Index: ObjectNameSerializerFactory.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
// $Id: ObjectNameSerializerFactory.java,v 1.1 2002/03/12 11:04:46 cgjung Exp $
package org.jboss.net.jmx.adaptor;
import java.util.Iterator;
import javax.xml.rpc.JAXRPCException;
import javax.xml.rpc.encoding.Serializer;
import org.apache.axis.encoding.SerializerFactory;
import javax.xml.rpc.namespace.QName;
import javax.management.ObjectName;
import java.util.Set;
/**
* Factory for ObjectName Serialization.
* <br>
* <h3>Change History</h3>
* <ul>
* </ul>
* @created 12.02.2002
* @author <a href="mailto:[EMAIL PROTECTED]">Christoph G. Jung</a>
* @version $Revision: 1.1 $
*/
public class ObjectNameSerializerFactory implements SerializerFactory {
//
// Attributes
//
final protected Set mechanisms=new java.util.HashSet(1);
final protected Class javaType;
final protected QName xmlType;
//
// Constructors
//
public ObjectNameSerializerFactory(Class javaType, QName xmlType) throws
Exception {
if(!(ObjectName.class.isAssignableFrom(javaType))) {
throw new Exception("Could only build serializers for JMX ObjectName.");
}
mechanisms.add(org.apache.axis.Constants.AXIS_SAX);
this.javaType=javaType;
this.xmlType=xmlType;
}
//
// Public API
//
public Serializer getSerializerAs(String mechanismType)
throws JAXRPCException {
if(!mechanisms.contains(mechanismType)) {
throw new JAXRPCException("Unsupported mechanism
"+mechanismType);
}
return new ObjectNameSerializer(xmlType);
}
/**
* Returns a list of all XML processing mechanism types supported by this
DeserializerFactory.
*
* @return List of unique identifiers for the supported XML processing mechanism
types
*/
public java.util.Iterator getSupportedMechanismTypes() {
return mechanisms.iterator();
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development