Home » geronimo-2.2-source-release » org.apache.geronimo.openejb » [javadoc | source]

    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.openejb;
   18   
   19   import org.apache.geronimo.gbean.AbstractName;
   20   import org.apache.geronimo.gbean.GBeanLifecycle;
   21   import org.apache.openejb.assembler.classic.ContainerInfo;
   22   import org.apache.openejb.assembler.classic.StatelessSessionContainerInfo;
   23   import org.apache.openejb.assembler.classic.StatefulSessionContainerInfo;
   24   import org.apache.openejb.assembler.classic.BmpEntityContainerInfo;
   25   import org.apache.openejb.assembler.classic.CmpEntityContainerInfo;
   26   import org.apache.openejb.assembler.classic.MdbContainerInfo;
   27   import org.apache.openejb.assembler.classic.SingletonSessionContainerInfo;
   28   
   29   import java.util.Properties;
   30   
   31   /**
   32    * @version $Rev: 829260 $ $Date: 2009-10-23 15:15:26 -0700 (Fri, 23 Oct 2009) $
   33    */
   34   public class EjbContainer implements GBeanLifecycle {
   35       private final OpenEjbSystem openEjbSystem;
   36       private final String id;
   37       private final Properties properties = new Properties();
   38       private final String provider;
   39       private final String type;
   40       private final Class<? extends ContainerInfo> infoType;
   41   
   42       public EjbContainer(AbstractName abstractName, Class<? extends ContainerInfo> infoType, OpenEjbSystem openEjbSystem, String provider, String type, Properties properties) {
   43           this.id = getId(abstractName);
   44           this.infoType = infoType;
   45           this.openEjbSystem = openEjbSystem;
   46           this.provider = provider;
   47           this.type = type;
   48           if (properties != null){
   49               this.properties.putAll(properties);
   50           }
   51       }
   52   
   53       public static String getId(AbstractName abstractName) {
   54           return (String) abstractName.getName().get("name");
   55       }
   56   
   57       protected Object set(String key, String value) {
   58           return properties.setProperty(key, value);
   59       }
   60   
   61       public String getId() {
   62           return id;
   63       }
   64   
   65       public OpenEjbSystem getOpenEjbSystem() {
   66           return openEjbSystem;
   67       }
   68   
   69       public Properties getProperties() {
   70           return properties;
   71       }
   72   
   73       public String getProvider() {
   74           return provider;
   75       }
   76   
   77       public String getType() {
   78           return type;
   79       }
   80   
   81       public Class<? extends ContainerInfo> getInfoType() {
   82           return infoType;
   83       }
   84   
   85       public void doStart() throws Exception {
   86           openEjbSystem.createContainer(getInfoType(), id, properties, provider);
   87       }
   88   
   89       public void doStop() throws Exception {
   90       }
   91   
   92       public void doFail() {
   93       }
   94   
   95       public static Class<? extends ContainerInfo> getInfoType(String type) {
   96           if ("STATELESS".equalsIgnoreCase(type)) return StatelessSessionContainerInfo.class;
   97           if ("SINGLETON".equalsIgnoreCase(type)) return SingletonSessionContainerInfo.class;
   98           if ("STATEFUL".equalsIgnoreCase(type)) return StatefulSessionContainerInfo.class;
   99           if ("BMP_ENTITY".equalsIgnoreCase(type)) return BmpEntityContainerInfo.class;
  100           if ("CMP_ENTITY".equalsIgnoreCase(type)) return CmpEntityContainerInfo.class;
  101           if ("CMP2_ENTITY".equalsIgnoreCase(type)) return CmpEntityContainerInfo.class;
  102           if ("MESSAGE".equalsIgnoreCase(type)) return MdbContainerInfo.class;
  103   
  104           String className = type; // EjbModuleBuilder will pass in the className of the gbean
  105           if (className.endsWith("StatelessContainerGBean")) return StatelessSessionContainerInfo.class;
  106           if (className.endsWith("StatefulContainerGBean")) return StatefulSessionContainerInfo.class;
  107           if (className.endsWith("SingletonContainerGBean")) return SingletonSessionContainerInfo.class;
  108           if (className.endsWith("BmpContainerGBean")) return BmpEntityContainerInfo.class;
  109           if (className.endsWith("CmpContainerGBean")) return CmpEntityContainerInfo.class;
  110   
  111           else return ContainerInfo.class;
  112       }
  113   
  114   }

Home » geronimo-2.2-source-release » org.apache.geronimo.openejb » [javadoc | source]