KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > j2ee > mejb > MEJB


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. 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 JavaDoc;
20 import javax.ejb.EJBHome JavaDoc;
21 import javax.ejb.EJBObject JavaDoc;
22 import javax.ejb.Handle JavaDoc;
23 import javax.ejb.RemoveException JavaDoc;
24 import javax.management.Attribute JavaDoc;
25 import javax.management.AttributeList JavaDoc;
26 import javax.management.AttributeNotFoundException JavaDoc;
27 import javax.management.InstanceNotFoundException JavaDoc;
28 import javax.management.IntrospectionException JavaDoc;
29 import javax.management.InvalidAttributeValueException JavaDoc;
30 import javax.management.MBeanException JavaDoc;
31 import javax.management.MBeanInfo JavaDoc;
32 import javax.management.MBeanServer JavaDoc;
33 import javax.management.ObjectName JavaDoc;
34 import javax.management.QueryExp JavaDoc;
35 import javax.management.ReflectionException JavaDoc;
36 import javax.management.j2ee.ListenerRegistration JavaDoc;
37 import javax.management.j2ee.Management JavaDoc;
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: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
48  */

49 public class MEJB implements Management JavaDoc {
50     private final String JavaDoc objectName;
51     private final MBeanServer JavaDoc mbeanServer;
52
53     // todo remove this as soon as Geronimo supports factory beans
54
public MEJB(String JavaDoc objectName, MBeanServerReference mbeanServerReference) {
55         this(objectName, mbeanServerReference.getMBeanServer());
56     }
57
58     public MEJB(String JavaDoc objectName, MBeanServer JavaDoc mbeanServer) {
59         this.objectName = objectName;
60         this.mbeanServer = mbeanServer;
61     }
62
63     public MBeanInfo JavaDoc getMBeanInfo(ObjectName JavaDoc objectName) throws InstanceNotFoundException JavaDoc, IntrospectionException JavaDoc, ReflectionException JavaDoc {
64         return mbeanServer.getMBeanInfo(objectName);
65     }
66
67     public String JavaDoc getDefaultDomain() {
68         return mbeanServer.getDefaultDomain();
69     }
70
71     public Object JavaDoc getAttribute(ObjectName JavaDoc objectName, String JavaDoc s) throws MBeanException JavaDoc, AttributeNotFoundException JavaDoc, InstanceNotFoundException JavaDoc, ReflectionException JavaDoc {
72         return mbeanServer.getAttribute(objectName, s);
73     }
74
75     public void setAttribute(ObjectName JavaDoc objectName, Attribute JavaDoc attribute) throws InstanceNotFoundException JavaDoc, AttributeNotFoundException JavaDoc, InvalidAttributeValueException JavaDoc, MBeanException JavaDoc, ReflectionException JavaDoc {
76         mbeanServer.setAttribute(objectName, attribute);
77     }
78
79     public AttributeList JavaDoc getAttributes(ObjectName JavaDoc objectName, String JavaDoc[] strings) throws InstanceNotFoundException JavaDoc, ReflectionException JavaDoc {
80         return mbeanServer.getAttributes(objectName, strings);
81     }
82
83     public AttributeList JavaDoc setAttributes(ObjectName JavaDoc objectName, AttributeList JavaDoc attributeList) throws InstanceNotFoundException JavaDoc, ReflectionException JavaDoc {
84         return mbeanServer.setAttributes(objectName, attributeList);
85     }
86
87     public Object JavaDoc invoke(ObjectName JavaDoc objectName, String JavaDoc s, Object JavaDoc[] objects, String JavaDoc[] strings) throws InstanceNotFoundException JavaDoc, MBeanException JavaDoc, ReflectionException JavaDoc {
88         return mbeanServer.invoke(objectName, s, objects, strings);
89     }
90
91     public Integer JavaDoc getMBeanCount() {
92         return mbeanServer.getMBeanCount();
93     }
94
95     public boolean isRegistered(ObjectName JavaDoc objectName) {
96         return mbeanServer.isRegistered(objectName);
97     }
98
99     public Set JavaDoc queryNames(ObjectName JavaDoc objectName, QueryExp JavaDoc queryExp) {
100         return mbeanServer.queryNames(objectName, queryExp);
101     }
102
103     public ListenerRegistration JavaDoc getListenerRegistry() {
104         throw new UnsupportedOperationException JavaDoc("Not Yet Implemented");
105     }
106
107
108     // EJBObject implementation
109
public EJBHome JavaDoc getEJBHome() {
110         return null;
111     }
112
113     public Handle JavaDoc getHandle() {
114         return null;
115     }
116
117     public Object JavaDoc getPrimaryKey() {
118         return null;
119     }
120
121     public boolean isIdentical(EJBObject JavaDoc obj) {
122         return false;
123     }
124
125     public void remove() throws RemoveException JavaDoc {
126     }
127
128     public String JavaDoc 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 JavaDoc.class, false);
149         infoBuilder.addReference("MBeanServerReference", MBeanServerReference.class);
150         infoBuilder.addInterface(Management JavaDoc.class);
151         infoBuilder.addInterface(J2EEManagedObject.class);
152
153         infoBuilder.setConstructor(new String JavaDoc[]{"objectName", "MBeanServerReference"});
154
155         GBEAN_INFO = infoBuilder.getBeanInfo();
156     }
157
158     public static GBeanInfo getGBeanInfo() {
159         return GBEAN_INFO;
160     }
161
162 }
163
Popular Tags