KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > jsr77 > J2EEManagedObjectMBean


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: J2EEManagedObjectMBean.java 1119 2006-09-21 12:18:57Z benoitf $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.easybeans.jsr77;
27
28 import javax.management.InstanceNotFoundException JavaDoc;
29 import javax.management.MBeanException JavaDoc;
30 import javax.management.RuntimeOperationsException JavaDoc;
31 import javax.management.modelmbean.InvalidTargetObjectTypeException JavaDoc;
32
33 import org.apache.commons.modeler.BaseModelMBean;
34 import org.objectweb.easybeans.log.JLog;
35 import org.objectweb.easybeans.log.JLogFactory;
36
37 /**
38  * J2EEManagedObject MBean Base.
39  * @author Guillaume Sauthier
40  * @param <T> ManagedObject type
41  */

42 public class J2EEManagedObjectMBean<T> extends BaseModelMBean {
43
44     /**
45      * Logger.
46      */

47     private static JLog logger = JLogFactory.getLog(J2EEManagedObjectMBean.class);
48
49     /**
50      * Is the MBean an Event Provider ? (Optionnal support)
51      */

52     private static final boolean IS_EVENT_PROVIDER = false;
53
54     /**
55      * Is the MBean a Statistics Provider ? (Optionnal support)
56      */

57     private static final boolean IS_STATISTICS_PROVIDER = false;
58
59     /**
60      * Is the MBean State Manageable ? (Optionnal support)
61      */

62     private static final boolean IS_STATE_MANAGEABLE = false;
63
64     /**
65      * Create the mbean.
66      * @throws MBeanException if the super constructor fails.
67      */

68     public J2EEManagedObjectMBean() throws MBeanException JavaDoc {
69         super();
70     }
71
72
73     /**
74      * @return the deployer (managed object)
75      */

76     @SuppressWarnings JavaDoc("unchecked")
77     protected T getManagedComponent() {
78         T deployer = null;
79         try {
80             deployer = (T) getManagedResource();
81         } catch (InstanceNotFoundException JavaDoc e) {
82             throw new IllegalStateException JavaDoc("Cannot get the managed resource of the MBean", e);
83         } catch (RuntimeOperationsException JavaDoc e) {
84             throw new IllegalStateException JavaDoc("Cannot get the managed resource of the MBean", e);
85         } catch (MBeanException JavaDoc e) {
86             throw new IllegalStateException JavaDoc("Cannot get the managed resource of the MBean", e);
87         } catch (InvalidTargetObjectTypeException JavaDoc e) {
88             throw new IllegalStateException JavaDoc("Cannot get the managed resource of the MBean", e);
89         }
90         return deployer;
91     }
92
93     /**
94      * @return Returns true is the MBean can manage its state.
95      */

96     public boolean isStateManageable() {
97         return IS_STATE_MANAGEABLE;
98     }
99
100     /**
101      * @return Returns true if this MBean can provides JSR77 Statistics.
102      */

103     public boolean isStatisticsProvider() {
104         return IS_STATISTICS_PROVIDER;
105     }
106
107     /**
108      * @return Returns true if this MBean can provides JSR77 Events.
109      */

110     public boolean isEventProvider() {
111         return IS_EVENT_PROVIDER;
112     }
113
114     /**
115      * @return Returns the logger.
116      */

117     protected static final JLog getLogger() {
118         return logger;
119     }
120
121 }
122
123
Popular Tags