KickJava   Java API By Example, From Geeks To Geeks.

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


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: MBeanInfoDeser.java,v 1.5.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.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.MBeanAttributeInfo JavaDoc;
21 import javax.management.MBeanConstructorInfo JavaDoc;
22 import javax.management.MBeanInfo JavaDoc;
23 import javax.management.MBeanNotificationInfo JavaDoc;
24 import javax.management.MBeanOperationInfo JavaDoc;
25 import javax.xml.namespace.QName JavaDoc;
26
27 /**
28  * An <code>MBeanInfoDeser</code> is be used to deserialize
29  * MBeanInfo using the <code>SOAP-ENC</code>
30  * encoding style.<p>
31  *
32  * @author <a HREF="mailto:a_taherkordi@users.sourceforge.net">Alireza Taherkordi</a>
33  * @version $Revision: 1.5.6.1 $
34  */

35 public class MBeanInfoDeser extends DeserializerImpl
36 {
37
38    private String JavaDoc className;
39    private String JavaDoc description;
40    private MBeanAttributeInfo JavaDoc[] attributes;
41    private MBeanConstructorInfo JavaDoc[] constructors;
42    private MBeanOperationInfo JavaDoc[] operations;
43    private MBeanNotificationInfo JavaDoc[] notifications;
44
45    public void onStartElement(String JavaDoc namespace,
46                               String JavaDoc localName,
47                               String JavaDoc prefix,
48                               Attributes JavaDoc attributes,
49                               DeserializationContext context)
50            throws SAXException JavaDoc
51    {
52
53       if (context.isNil(attributes))
54       {
55          return;
56       }
57
58       //nothing to do
59

60    }
61
62    public SOAPHandler onStartChild(String JavaDoc namespace,
63                                    String JavaDoc localName,
64                                    String JavaDoc prefix,
65                                    Attributes JavaDoc attributes,
66                                    DeserializationContext context)
67            throws SAXException JavaDoc
68    {
69
70       // Get the type
71
QName JavaDoc itemType =
72               context.getTypeFromAttributes(namespace, localName, attributes);
73       // Get the deserializer
74
Deserializer dSer = null;
75       if (itemType != null)
76       {
77          dSer = context.getDeserializerForType(itemType);
78       }
79       if (dSer == null)
80       {
81          dSer = new DeserializerImpl();
82       }
83
84       // When the value is deserialized, inform us.
85
// Need to pass the localName as a hint
86
dSer.registerValueTarget(new DeserializerTarget(this, localName));
87
88       addChildDeserializer(dSer);
89
90       return (SOAPHandler)dSer;
91    }
92
93    public void setChildValue(Object JavaDoc value, Object JavaDoc hint) throws SAXException JavaDoc
94    {
95       if (hint.equals("className"))
96          className = (String JavaDoc)value;
97       else if (hint.equals("description"))
98          description = (String JavaDoc)value;
99       else if (hint.equals("attributes"))
100          attributes = (MBeanAttributeInfo JavaDoc[])value;
101       else if (hint.equals("constructors"))
102          constructors = (MBeanConstructorInfo JavaDoc[])value;
103       else if (hint.equals("operations"))
104          operations = (MBeanOperationInfo JavaDoc[])value;
105       else if (hint.equals("notifications"))
106          notifications = (MBeanNotificationInfo JavaDoc[])value;
107
108    }
109
110    public void onEndElement(String JavaDoc s,
111                             String JavaDoc s1,
112                             DeserializationContext deserializationcontext)
113    {
114       try
115       {
116          super.value =
117                  new MBeanInfo JavaDoc(className,
118                          description,
119                          attributes,
120                          constructors,
121                          operations,
122                          notifications);
123       }
124       catch (Exception JavaDoc exception)
125       {
126          exception.printStackTrace();
127       }
128    }
129
130 }
131
Popular Tags