KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mortbay > jetty > servlet > jmx > ConfigurationMBean


1 //========================================================================
2
//$Id: ConfigurationMBean.java,v 1.2 2005/08/13 00:01:27 gregwilkins Exp $
3
//Copyright 2000-2004 Mort Bay Consulting Pty. Ltd.
4
//------------------------------------------------------------------------
5
//Licensed under the Apache License, Version 2.0 (the "License");
6
//you may not use this file except in compliance with the License.
7
//You may obtain a copy of the License at
8
//http://www.apache.org/licenses/LICENSE-2.0
9
//Unless required by applicable law or agreed to in writing, software
10
//distributed under the License is distributed on an "AS IS" BASIS,
11
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//See the License for the specific language governing permissions and
13
//limitations under the License.
14
//========================================================================
15

16 package org.mortbay.jetty.servlet.jmx;
17
18 import javax.management.MBeanException JavaDoc;
19 import javax.management.MBeanServer JavaDoc;
20 import javax.management.ObjectName JavaDoc;
21
22 import org.apache.commons.logging.Log;
23 import org.mortbay.log.LogFactory;
24 import org.mortbay.jetty.servlet.WebApplicationContext.Configuration;
25 import org.mortbay.util.LogSupport;
26 import org.mortbay.util.jmx.ModelMBeanImpl;
27
28
29 /**
30  *
31  * ConfigurationMBean
32  *
33  * MBean proxy for a WebApplicationContext.Configuration object.
34  *
35  * @author janb
36  * @version $Revision: 1.2 $ $Date: 2005/08/13 00:01:27 $
37  *
38  */

39 public class ConfigurationMBean extends ModelMBeanImpl
40 {
41     private static final Log log = LogFactory.getLog(ConfigurationMBean.class);
42     protected Configuration _config = null;
43     
44     public ConfigurationMBean()
45     throws MBeanException JavaDoc
46     {}
47
48     /**defineManagedResource
49      * Grab the object which this mbean is proxying for, which in
50      * this case is an org.mortbay.jetty.servlet.WebApplicationContext.Configuration
51      * @see org.mortbay.util.jmx.ModelMBeanImpl#defineManagedResource()
52      */

53     protected void defineManagedResource()
54     {
55         super.defineManagedResource();
56        defineAttribute("name", READ_ONLY, ON_MBEAN);
57         _config=(Configuration)getManagedResource();
58     }
59     
60     /**getName
61      * This method is only defined to satisfy JMX: it is non-compliant
62      * to have an mbean with no methods on it, so this method has been
63      * added as a workaround.
64      * @return classname of the Configuration instance
65      */

66     public String JavaDoc getName ()
67     {
68         if (null==_config)
69             return null;
70         
71         return _config.getClass().getName();
72     }
73     
74     /**uniqueObjectName
75      * Make a unique jmx name for this configuration object
76      * @see org.mortbay.util.jmx.ModelMBeanImpl#uniqueObjectName(javax.management.MBeanServer, java.lang.String)
77      */

78     public synchronized ObjectName JavaDoc uniqueObjectName(MBeanServer JavaDoc server, String JavaDoc on)
79     {
80         ObjectName JavaDoc oName=null;
81         try{oName=new ObjectName JavaDoc(on+",config="+_config.getClass().getName());}
82         catch(Exception JavaDoc e){log.warn(LogSupport.EXCEPTION,e);}
83         
84         return oName;
85     }
86     
87 }
88
Popular Tags