KickJava   Java API By Example, From Geeks To Geeks.

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


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: MBeanConstructorInfoDeser.java,v 1.4.8.1 2005/03/02 14:19:55 tdiesler Exp $
9

10 package org.jboss.net.jmx.adaptor;
11
12 import org.jboss.axis.encoding.DeserializationContext;
13 import org.jboss.axis.encoding.Deserializer;
14 import org.jboss.axis.encoding.DeserializerImpl;
15 import org.jboss.axis.encoding.DeserializerTarget;
16 import org.jboss.axis.message.SOAPHandler;
17 import org.xml.sax.Attributes JavaDoc;
18 import org.xml.sax.SAXException JavaDoc;
19
20 import javax.management.MBeanConstructorInfo JavaDoc;
21 import javax.management.MBeanParameterInfo JavaDoc;
22 import javax.xml.namespace.QName JavaDoc;
23
24 /**
25  * An <code>MBeanConstructorInfoDeser</code> is be used to deserialize
26  * MBeanConstructorInfo using the <code>SOAP-ENC</code>
27  * encoding style.<p>
28  *
29  * @author <a HREF="mailto:a_taherkordi@users.sourceforge.net">Alireza Taherkordi</a>
30  * @version $Revision: 1.4.8.1 $
31  */

32 public class MBeanConstructorInfoDeser extends DeserializerImpl
33 {
34
35    private String JavaDoc name;
36    private String JavaDoc description;
37    private MBeanParameterInfo JavaDoc[] signature;
38
39    public void onStartElement(String JavaDoc namespace,
40                               String JavaDoc localName,
41                               String JavaDoc prefix,
42                               Attributes JavaDoc attributes,
43                               DeserializationContext context)
44            throws SAXException JavaDoc
45    {
46
47       if (context.isNil(attributes))
48       {
49          return;
50       }
51
52       //nothing to do
53

54    }
55
56    public SOAPHandler onStartChild(String JavaDoc namespace,
57                                    String JavaDoc localName,
58                                    String JavaDoc prefix,
59                                    Attributes JavaDoc attributes,
60                                    DeserializationContext context)
61            throws SAXException JavaDoc
62    {
63
64       // Get the type
65
QName JavaDoc itemType =
66               context.getTypeFromAttributes(namespace, localName, attributes);
67       // Get the deserializer
68
Deserializer dSer = null;
69       if (itemType != null)
70       {
71          dSer = context.getDeserializerForType(itemType);
72       }
73       if (dSer == null)
74       {
75          dSer = new DeserializerImpl();
76       }
77
78       // When the value is deserialized, inform us.
79
// Need to pass the localName as a hint
80
dSer.registerValueTarget(new DeserializerTarget(this, localName));
81
82       addChildDeserializer(dSer);
83
84       return (SOAPHandler)dSer;
85    }
86
87    public void setChildValue(Object JavaDoc value, Object JavaDoc hint) throws SAXException JavaDoc
88    {
89       if (hint.equals("name"))
90          name = (String JavaDoc)value;
91       else if (hint.equals("description"))
92          description = (String JavaDoc)value;
93       else if (hint.equals("signature"))
94          signature = (MBeanParameterInfo JavaDoc[])value;
95
96    }
97
98    public void onEndElement(String JavaDoc s,
99                             String JavaDoc s1,
100                             DeserializationContext deserializationcontext)
101    {
102       try
103       {
104          super.value = new MBeanConstructorInfo JavaDoc(name, description, signature);
105       }
106       catch (Exception JavaDoc exception)
107       {
108          exception.printStackTrace();
109       }
110    }
111
112 }
113
Popular Tags