1 /**
2 *
3 * Copyright 2003-2004 The Apache Software Foundation
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 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.geronimo.j2ee.mejb;
18
19 import java.util.Set;
20 import javax.ejb.EJBHome;
21 import javax.ejb.EJBObject;
22 import javax.ejb.Handle;
23 import javax.ejb.RemoveException;
24 import javax.management.Attribute;
25 import javax.management.AttributeList;
26 import javax.management.AttributeNotFoundException;
27 import javax.management.InstanceNotFoundException;
28 import javax.management.IntrospectionException;
29 import javax.management.InvalidAttributeValueException;
30 import javax.management.MBeanException;
31 import javax.management.MBeanInfo;
32 import javax.management.MBeanServer;
33 import javax.management.ObjectName;
34 import javax.management.QueryExp;
35 import javax.management.ReflectionException;
36 import javax.management.j2ee.ListenerRegistration;
37 import javax.management.j2ee.Management;
38
39 import org.apache.geronimo.gbean.GBeanInfo;
40 import org.apache.geronimo.gbean.GBeanInfoBuilder;
41 import org.apache.geronimo.system.jmx.MBeanServerReference;
42 import org.apache.geronimo.management.J2EEManagedObject;
43
44 /**
45 * GBean implementing Management interface and supplying proxies to act as the MEJB container.
46 *
47 * @version $Rev: 395155 $ $Date: 2006-04-18 23:44:24 -0700 (Tue, 18 Apr 2006) $
48 */
49 public class MEJB implements Management {
50 private final String objectName;
51 private final MBeanServer mbeanServer;
52
53
54 public MEJB(String objectName, MBeanServerReference mbeanServerReference) {
55 this(objectName, mbeanServerReference.getMBeanServer());
56 }
57
58 public MEJB(String objectName, MBeanServer mbeanServer) {
59 this.objectName = objectName;
60 this.mbeanServer = mbeanServer;
61 }
62
63 public MBeanInfo getMBeanInfo(ObjectName objectName) throws InstanceNotFoundException, IntrospectionException, ReflectionException {
64 return mbeanServer.getMBeanInfo(objectName);
65 }
66
67 public String getDefaultDomain() {
68 return mbeanServer.getDefaultDomain();
69 }
70
71 public Object getAttribute(ObjectName objectName, String s) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException {
72 return mbeanServer.getAttribute(objectName, s);
73 }
74
75 public void setAttribute(ObjectName objectName, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
76 mbeanServer.setAttribute(objectName, attribute);
77 }
78
79 public AttributeList getAttributes(ObjectName objectName, String[] strings) throws InstanceNotFoundException, ReflectionException {
80 return mbeanServer.getAttributes(objectName, strings);
81 }
82
83 public AttributeList setAttributes(ObjectName objectName, AttributeList attributeList) throws InstanceNotFoundException, ReflectionException {
84 return mbeanServer.setAttributes(objectName, attributeList);
85 }
86
87 public Object invoke(ObjectName objectName, String s, Object[] objects, String[] strings) throws InstanceNotFoundException, MBeanException, ReflectionException {
88 return mbeanServer.invoke(objectName, s, objects, strings);
89 }
90
91 public Integer getMBeanCount() {
92 return mbeanServer.getMBeanCount();
93 }
94
95 public boolean isRegistered(ObjectName objectName) {
96 return mbeanServer.isRegistered(objectName);
97 }
98
99 public Set queryNames(ObjectName objectName, QueryExp queryExp) {
100 return mbeanServer.queryNames(objectName, queryExp);
101 }
102
103 public ListenerRegistration getListenerRegistry() {
104 throw new UnsupportedOperationException("Not Yet Implemented");
105 }
106
107
108
109 public EJBHome getEJBHome() {
110 return null;
111 }
112
113 public Handle getHandle() {
114 return null;
115 }
116
117 public Object getPrimaryKey() {
118 return null;
119 }
120
121 public boolean isIdentical(EJBObject obj) {
122 return false;
123 }
124
125 public void remove() throws RemoveException {
126 }
127
128 public String getObjectName() {
129 return objectName;
130 }
131
132 public boolean isStateManageable() {
133 return false;
134 }
135
136 public boolean isStatisticsProvider() {
137 return false;
138 }
139
140 public boolean isEventProvider() {
141 return false;
142 }
143
144 public static final GBeanInfo GBEAN_INFO;
145
146 static {
147 GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(MEJB.class);
148 infoBuilder.addAttribute("objectName", String.class, false);
149 infoBuilder.addReference("MBeanServerReference", MBeanServerReference.class);
150 infoBuilder.addInterface(Management.class);
151 infoBuilder.addInterface(J2EEManagedObject.class);
152
153 infoBuilder.setConstructor(new String[]{"objectName", "MBeanServerReference"});
154
155 GBEAN_INFO = infoBuilder.getBeanInfo();
156 }
157
158 public static GBeanInfo getGBeanInfo() {
159 return GBEAN_INFO;
160 }
161
162 }