001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.openejb;
017:
018: import java.util.Properties;
019:
020: import org.apache.geronimo.gbean.GBeanInfo;
021: import org.apache.geronimo.gbean.GBeanInfoBuilder;
022: import org.apache.geronimo.gbean.GBeanLifecycle;
023: import org.apache.openejb.assembler.classic.ContainerInfo;
024: import org.apache.openejb.assembler.classic.StatelessSessionContainerInfo;
025: import org.apache.openejb.assembler.classic.StatefulSessionContainerInfo;
026: import org.apache.openejb.assembler.classic.BmpEntityContainerInfo;
027: import org.apache.openejb.assembler.classic.CmpEntityContainerInfo;
028: import org.apache.openejb.assembler.classic.MdbContainerInfo;
029:
030: /**
031: * @version $Rev: 583409 $ $Date: 2007-10-10 02:38:51 -0700 (Wed, 10 Oct 2007) $
032: */
033: public class EjbContainer implements GBeanLifecycle {
034: private OpenEjbSystem openEjbSystem;
035: private String id;
036: private Properties properties;
037: private String provider;
038: private String type;
039: private Class<? extends ContainerInfo> infoType;
040:
041: public OpenEjbSystem getOpenEjbSystem() {
042: return openEjbSystem;
043: }
044:
045: public void setOpenEjbSystem(OpenEjbSystem openEjbSystem) {
046: this .openEjbSystem = openEjbSystem;
047: }
048:
049: public String getId() {
050: return id;
051: }
052:
053: public void setId(String id) {
054: this .id = id;
055: }
056:
057: public Properties getProperties() {
058: return properties;
059: }
060:
061: public void setProperties(Properties properties) {
062: this .properties = properties;
063: }
064:
065: public String getProvider() {
066: return provider;
067: }
068:
069: public void setProvider(String provider) {
070: this .provider = provider;
071: }
072:
073: public String getType() {
074: return type;
075: }
076:
077: public void setType(String type) {
078: this .type = type;
079: }
080:
081: public static Class<? extends ContainerInfo> getInfoType(String type) {
082: if ("STATELESS".equalsIgnoreCase(type))
083: return StatelessSessionContainerInfo.class;
084: if ("STATEFUL".equalsIgnoreCase(type))
085: return StatefulSessionContainerInfo.class;
086: if ("BMP_ENTITY".equalsIgnoreCase(type))
087: return BmpEntityContainerInfo.class;
088: if ("CMP_ENTITY".equalsIgnoreCase(type))
089: return CmpEntityContainerInfo.class;
090: if ("CMP2_ENTITY".equalsIgnoreCase(type))
091: return CmpEntityContainerInfo.class;
092: if ("MESSAGE".equalsIgnoreCase(type))
093: return MdbContainerInfo.class;
094: else
095: return ContainerInfo.class;
096: }
097:
098: public Class<? extends ContainerInfo> getInfoType() {
099: return infoType == null ? getInfoType(type) : infoType;
100: }
101:
102: public void setInfoType(Class<? extends ContainerInfo> infoType) {
103: this .infoType = infoType;
104: }
105:
106: public void doStart() throws Exception {
107: openEjbSystem.createContainer(getInfoType(), id, properties,
108: provider);
109: }
110:
111: public void doStop() throws Exception {
112: }
113:
114: public void doFail() {
115: }
116:
117: public static final GBeanInfo GBEAN_INFO;
118:
119: static {
120: GBeanInfoBuilder infoBuilder = GBeanInfoBuilder
121: .createStatic(EjbContainer.class);
122: infoBuilder.addReference("OpenEjbSystem", OpenEjbSystem.class);
123: infoBuilder.addAttribute("id", String.class, true);
124: infoBuilder.addAttribute("properties", Properties.class, true);
125: infoBuilder.addAttribute("provider", String.class, true);
126: infoBuilder.addAttribute("type", String.class, true);
127: infoBuilder.addAttribute("infoType", Class.class, true);
128: GBEAN_INFO = infoBuilder.getBeanInfo();
129: }
130:
131: public static GBeanInfo getGBeanInfo() {
132: return GBEAN_INFO;
133: }
134: }
|