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

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one
    3    * or more contributor license agreements.  See the NOTICE file
    4    * distributed with this work for additional information
    5    * regarding copyright ownership.  The ASF licenses this file
    6    * to you under the Apache License, Version 2.0 (the
    7    * "License"); you may not use this file except in compliance
    8    * with the License.  You may obtain a copy of the License at
    9    *
   10    *  http://www.apache.org/licenses/LICENSE-2.0
   11    *
   12    * Unless required by applicable law or agreed to in writing,
   13    * software distributed under the License is distributed on an
   14    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   15    * KIND, either express or implied.  See the License for the
   16    * specific language governing permissions and limitations
   17    * under the License.
   18    */
   19   
   20   package org.apache.geronimo.openejb.deployment.cluster;
   21   
   22   import org.apache.openejb.OpenEJBException;
   23   import org.apache.openejb.config.AppModule;
   24   import org.apache.openejb.config.DynamicDeployer;
   25   import org.apache.openejb.jee.EjbJar;
   26   import org.apache.openejb.jee.EnterpriseBean;
   27   import org.apache.openejb.jee.SessionBean;
   28   import org.apache.openejb.jee.oejb3.EjbDeployment;
   29   import org.apache.openejb.jee.oejb3.OpenejbJar;
   30   
   31   /**
   32    *
   33    * @version $Rev:$ $Date:$
   34    */
   35   public class MapSFSBToContainerIDDeployer implements DynamicDeployer {
   36   
   37       private final String containerId;
   38   
   39       public MapSFSBToContainerIDDeployer(String containerId) {
   40           if (null == containerId) {
   41               throw new IllegalArgumentException("containerId is required");
   42           }
   43           this.containerId = containerId;
   44       }
   45   
   46       public AppModule deploy(AppModule appModule) throws OpenEJBException {
   47           for (org.apache.openejb.config.EjbModule ejbModule : appModule.getEjbModules()) {
   48               OpenejbJar openejbJar = ejbModule.getOpenejbJar();
   49               EjbJar ejbJar = ejbModule.getEjbJar();
   50               for (EnterpriseBean enterpriseBean : ejbJar.getEnterpriseBeans()) {
   51                   if (enterpriseBean instanceof SessionBean) {
   52                       SessionBean sessionBean = (SessionBean) enterpriseBean;
   53                       switch (sessionBean.getSessionType()) {
   54                           case STATEFUL:
   55                               String ejbName = sessionBean.getEjbName();
   56                               EjbDeployment ejbDeployment = openejbJar.getDeploymentsByEjbName().get(ejbName);
   57                               if (null == ejbDeployment) {
   58                                   throw new OpenEJBException("No ejbDeployment for ejbName [" + ejbName + "]");
   59                               }
   60                               ejbDeployment.setContainerId(containerId);
   61                       }
   62                   }
   63               }
   64           }
   65           return appModule;
   66       }
   67   }

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