01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: */package org.apache.geronimo.openejb;
17:
18: import javax.management.j2ee.Management;
19: import javax.management.j2ee.ManagementHome;
20:
21: import org.apache.geronimo.gbean.GBeanInfo;
22: import org.apache.geronimo.gbean.GBeanInfoBuilder;
23: import org.apache.geronimo.gbean.GBeanLifecycle;
24: import org.apache.openejb.assembler.classic.EjbJarInfo;
25: import org.apache.openejb.config.EjbModule;
26: import org.apache.openejb.jee.EjbJar;
27: import org.apache.openejb.jee.StatelessBean;
28: import org.apache.openejb.mgmt.MEJBBean;
29:
30: public class MEJBGBean implements GBeanLifecycle {
31:
32: public static final GBeanInfo GBEAN_INFO;
33:
34: private EjbContainer ejbContainer;
35:
36: public MEJBGBean(EjbContainer ejbContainer) {
37: this .ejbContainer = ejbContainer;
38: }
39:
40: public void doStart() throws Exception {
41: EjbJar ejbJar = new EjbJar();
42: StatelessBean bean = ejbJar
43: .addEnterpriseBean(new StatelessBean("MEJB",
44: MEJBBean.class.getName()));
45: bean.setHomeAndRemote(ManagementHome.class, Management.class);
46:
47: ClassLoader cl = MEJBBean.class.getClassLoader();
48: OpenEjbSystem openEjbSystem = ejbContainer.getOpenEjbSystem();
49: //A dummy URL MEJBGBean.class.getResource( "" ).toString() to avoid the "java.net.MalformedURLException: no protocol: MEJBGBean" when startup
50: EjbJarInfo ejbJarInfo = openEjbSystem
51: .configureApplication(new EjbModule(cl, getClass()
52: .getSimpleName(), MEJBGBean.class.getResource(
53: "").toString(), ejbJar, null));
54: openEjbSystem.createEjbJar(ejbJarInfo, cl);
55: }
56:
57: static {
58: GBeanInfoBuilder infoBuilder = GBeanInfoBuilder
59: .createStatic(MEJBGBean.class);
60: infoBuilder.addReference("StatelessContainer",
61: EjbContainer.class);
62: infoBuilder
63: .setConstructor(new String[] { "StatelessContainer" });
64: GBEAN_INFO = infoBuilder.getBeanInfo();
65: }
66:
67: public static GBeanInfo getGBeanInfo() {
68: return GBEAN_INFO;
69: }
70:
71: public void doStop() throws Exception {
72:
73: }
74:
75: public void doFail() {
76:
77: }
78:
79: }
|