KickJava   Java API By Example, From Geeks To Geeks.

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


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: MBeanOperationInfoDeser.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.MBeanOperationInfo JavaDoc;
21 import javax.management.MBeanParameterInfo JavaDoc;
22 import javax.xml.namespace.QName JavaDoc;
23
24 /**
25  * An <code>MBeanOperationInfoDeser</code> is be used to deserialize
26  * MBeanOperationInfo 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 MBeanOperationInfoDeser extends DeserializerImpl
33 {
34
35    private String JavaDoc name;
36    private String JavaDoc description;
37    private MBeanParameterInfo JavaDoc[] signature;
38    private String JavaDoc type;
39    private int impact;
40
41    public void onStartElement(String JavaDoc namespace,
42                               String JavaDoc localName,
43                               String JavaDoc prefix,
44                               Attributes JavaDoc attributes,
45                               DeserializationContext context)
46            throws SAXException JavaDoc
47    {
48
49       if (context.isNil(attributes))
50       {
51          return;
52       }
53
54       //nothing to do
55

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