KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > net > jmx > adaptor > ObjectNameSer


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 // $Id: ObjectNameSer.java,v 1.7.6.1 2005/03/02 14:19:55 tdiesler Exp $
9

10 package org.jboss.net.jmx.adaptor;
11
12 import org.jboss.axis.encoding.SerializationContext;
13 import org.jboss.axis.encoding.ser.SimpleSerializer;
14 import org.jboss.axis.wsdl.fromJava.Types;
15 import org.w3c.dom.Element JavaDoc;
16
17 import javax.management.ObjectName JavaDoc;
18 import javax.xml.namespace.QName JavaDoc;
19
20 /**
21  * Serializer specialized to turn JMX-Objectnames into
22  * corresponding XML-types.
23  * @since 26.04.2002
24  * @author <a HREF="mailto:a_taherkordi@users.sourceforge.net">Alireza Taherkordi</a>
25  * @author <a HREF="mailto:Christoph.Jung@infor.de">Christoph G. Jung</a>
26  * @version $Revision: 1.7.6.1 $
27  */

28
29 public class ObjectNameSer extends SimpleSerializer
30 {
31
32    public ObjectNameSer(Class JavaDoc javaType, QName JavaDoc xmlType)
33    {
34       super(javaType, xmlType);
35    }
36
37    public String JavaDoc getValueAsString(Object JavaDoc value, SerializationContext context)
38    {
39       return ((ObjectName JavaDoc)value).getCanonicalName();
40    }
41
42    /* (non-Javadoc)
43     * @see org.jboss.axis.encoding.Serializer#writeSchema(java.lang.Class, org.jboss.axis.wsdl.fromJava.Types)
44     */

45    public Element JavaDoc writeSchema(Class JavaDoc clazz, Types types) throws Exception JavaDoc
46    {
47       // ComplexType representation of SimpleType bean class
48
Element JavaDoc complexType = types.createElement("complexType");
49       //types.writeSchemaElement(xmlType, complexType);
50
types.writeSchemaElement(xmlType, complexType);
51       complexType.setAttribute("name", xmlType.getLocalPart());
52
53       // Produce simpleContent extending base type.
54
Element JavaDoc simpleContent = types.createElement("simpleContent");
55       complexType.appendChild(simpleContent);
56       Element JavaDoc extension = types.createElement("extension");
57       simpleContent.appendChild(extension);
58
59       // Get the base type from the "value" element of the bean
60
String JavaDoc base = "string";
61       extension.setAttribute("base", base);
62       // done
63
return complexType;
64    }
65
66 }
Popular Tags