KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > tools > remote > soap > axis > ser > MBeanServerNotificationFilterSer


1 /*
2  * Copyright (C) The MX4J Contributors.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package mx4j.tools.remote.soap.axis.ser;
10
11 import java.io.IOException JavaDoc;
12 import java.util.Iterator JavaDoc;
13 import java.util.Vector JavaDoc;
14 import javax.management.NotificationFilterSupport JavaDoc;
15 import javax.management.ObjectName JavaDoc;
16 import javax.management.relation.MBeanServerNotificationFilter JavaDoc;
17 import javax.xml.namespace.QName JavaDoc;
18
19 import org.apache.axis.encoding.SerializationContext;
20 import org.apache.axis.wsdl.fromJava.Types;
21 import org.w3c.dom.Element JavaDoc;
22
23 /**
24  * @version $Revision: 1.3 $
25  */

26 public class MBeanServerNotificationFilterSer extends NotificationFilterSupportSer
27 {
28    static final String JavaDoc ENABLED_OBJECT_NAME = "enabledObjectName";
29    static final String JavaDoc DISABLED_OBJECT_NAME = "disabledObjectName";
30    static final String JavaDoc ALL_DISABLED = "allDisabled";
31    static final String JavaDoc ALL_ENABLED = "allEnabled";
32    private static final QName JavaDoc ENABLED_OBJECT_NAME_QNAME = new QName JavaDoc("", ENABLED_OBJECT_NAME);
33    private static final QName JavaDoc DISABLED_OBJECT_NAME_QNAME = new QName JavaDoc("", DISABLED_OBJECT_NAME);
34    private static final QName JavaDoc ALL_DISABLED_QNAME = new QName JavaDoc("", ALL_DISABLED);
35    private static final QName JavaDoc ALL_ENABLED_QNAME = new QName JavaDoc("", ALL_ENABLED);
36
37    protected void onSerialize(SerializationContext context, NotificationFilterSupport JavaDoc filter) throws IOException JavaDoc
38    {
39       super.onSerialize(context, filter);
40
41       MBeanServerNotificationFilter JavaDoc serverFilter = (MBeanServerNotificationFilter JavaDoc)filter;
42       Vector JavaDoc enabledNames = serverFilter.getEnabledObjectNames();
43       Vector JavaDoc disabledNames = serverFilter.getDisabledObjectNames();
44
45       // A special logic should be implemented: an empty vector has a different meaning than a null vector
46
// See JMX specification (javadocs) for further details
47
if (enabledNames != null)
48       {
49          if (enabledNames.size() == 0)
50          {
51             context.serialize(ALL_DISABLED_QNAME, null, Boolean.TRUE);
52          }
53          else
54          {
55             context.serialize(ALL_DISABLED_QNAME, null, Boolean.FALSE);
56          }
57          for (Iterator JavaDoc i = enabledNames.iterator(); i.hasNext();)
58          {
59             ObjectName JavaDoc enabled = (ObjectName JavaDoc)i.next();
60             context.serialize(ENABLED_OBJECT_NAME_QNAME, null, enabled);
61          }
62       }
63       if (disabledNames != null)
64       {
65          if (disabledNames.size() == 0)
66          {
67             context.serialize(ALL_ENABLED_QNAME, null, Boolean.TRUE);
68          }
69          else
70          {
71             context.serialize(ALL_ENABLED_QNAME, null, Boolean.FALSE);
72          }
73          for (Iterator JavaDoc i = disabledNames.iterator(); i.hasNext();)
74          {
75             ObjectName JavaDoc disabled = (ObjectName JavaDoc)i.next();
76             context.serialize(DISABLED_OBJECT_NAME_QNAME, null, disabled);
77          }
78       }
79    }
80
81    public Element JavaDoc writeSchema(Class JavaDoc javaType, Types types) throws Exception JavaDoc
82    {
83       // TODO: Use XML Schema syntax to specify that this is a subclass of NotificationFilterSupport
84
return null;
85    }
86 }
87
Popular Tags