KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > mbeans > ModuleMonitoringLevelsMBean


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24
25 package com.sun.enterprise.admin.mbeans;
26
27 import java.util.Iterator JavaDoc;
28 import java.util.logging.Level JavaDoc;
29 import java.util.logging.Logger JavaDoc;
30
31 import javax.management.MBeanInfo JavaDoc;
32 import javax.management.MBeanServer JavaDoc;
33 import javax.management.ObjectName JavaDoc;
34 import javax.management.Attribute JavaDoc;
35 import javax.management.AttributeList JavaDoc;
36 import javax.management.MBeanException JavaDoc;
37 import javax.management.AttributeNotFoundException JavaDoc;
38 import javax.management.InvalidAttributeValueException JavaDoc;
39 import com.sun.enterprise.admin.common.constant.AdminConstants;
40 import com.sun.enterprise.admin.config.BaseConfigMBean;
41 import com.sun.enterprise.admin.common.exception.AFRuntimeException;
42
43 /**
44  * The MBean is used for overriding the setAttribute functionality of the BaseConfigMBean.
45  * When the monitoring-level of one of the following changes, the others are should also be
46  * impacted. This is a special case that impact only the following components:
47  * connector-service
48  * jms-service
49  * connector-connection-pool
50  */

51 public class ModuleMonitoringLevelsMBean extends BaseConfigMBean {
52     
53     public static final String JavaDoc CONNECTOR_SERVICE_ATTR_NAME = "connector-service";
54     public static final String JavaDoc JMS_SERVICE_ATTR_NAME = "jms-service";
55     public static final String JavaDoc CONNECTOR_CONNPOOL_ATTR_NAME = "connector-connection-pool";
56     public static final Logger JavaDoc sLogger = Logger.getLogger(AdminConstants.kLoggerName);
57
58     /**
59      * Creates a new instance of ModuleMonitoringLevelsMBean
60      */

61     public ModuleMonitoringLevelsMBean() {
62     
63     }
64     
65     public void setAttribute(Attribute JavaDoc attr) {
66         try {
67             super.setAttribute(attr);
68             String JavaDoc attrName = attr.getName();
69             AttributeList JavaDoc otherAttrs = new AttributeList JavaDoc();
70             sLogger.log(Level.FINE, "modulemonitoringlevelsmbean.attribute_name", attrName);
71             if(attrName.equals(CONNECTOR_SERVICE_ATTR_NAME)) {
72                 
73                 otherAttrs.add(new Attribute JavaDoc(JMS_SERVICE_ATTR_NAME, attr.getValue()));
74                 otherAttrs.add(new Attribute JavaDoc(CONNECTOR_CONNPOOL_ATTR_NAME, attr.getValue()));
75             }
76             else if(attrName.equals(JMS_SERVICE_ATTR_NAME))
77             {
78                 
79                 otherAttrs.add(new Attribute JavaDoc(CONNECTOR_CONNPOOL_ATTR_NAME, attr.getValue()));
80                 otherAttrs.add(new Attribute JavaDoc(CONNECTOR_SERVICE_ATTR_NAME, attr.getValue()));
81             }
82             else if(attrName.equals(CONNECTOR_CONNPOOL_ATTR_NAME))
83             {
84                 
85                 otherAttrs.add(new Attribute JavaDoc(CONNECTOR_SERVICE_ATTR_NAME, attr.getValue()));
86                 otherAttrs.add(new Attribute JavaDoc(JMS_SERVICE_ATTR_NAME, attr.getValue()));
87             }
88             super.setAttributes(otherAttrs);
89         } catch(AFRuntimeException afe) {
90             throw afe;
91         } catch(Exception JavaDoc e) {
92             sLogger.log(Level.WARNING, "modulemonitoringlevelsmbean.set_failed");
93             sLogger.log(Level.WARNING, e.getLocalizedMessage(), e);
94         }
95     }
96     
97     public AttributeList JavaDoc setAttributes(AttributeList JavaDoc attrs) {
98         
99         AttributeList JavaDoc attrList = new AttributeList JavaDoc();
100         Iterator JavaDoc it = attrs.iterator();
101         Attribute JavaDoc attr = null;
102         while(it.hasNext()) {
103             try {
104                 attr = (Attribute JavaDoc)it.next();
105                 setAttribute(attr);
106             } catch(AFRuntimeException afe) {
107                 throw afe;
108             } catch(Exception JavaDoc e) {
109                 sLogger.log(Level.WARNING, "modulemonitoringlevelsmbean.set_failed");
110                 sLogger.log(Level.WARNING, e.getLocalizedMessage(), e);
111             }
112             attrList.add(attr);
113         }
114         return attrList;
115     }
116     
117 }
118
Popular Tags