01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
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(
42: "containerId is required");
43: }
44: this .containerId = containerId;
45: }
46:
47: public AppModule deploy(AppModule appModule)
48: throws OpenEJBException {
49: for (org.apache.openejb.config.EjbModule ejbModule : appModule
50: .getEjbModules()) {
51: OpenejbJar openejbJar = ejbModule.getOpenejbJar();
52: EjbJar ejbJar = ejbModule.getEjbJar();
53: for (EnterpriseBean enterpriseBean : ejbJar
54: .getEnterpriseBeans()) {
55: if (enterpriseBean instanceof SessionBean) {
56: SessionBean sessionBean = (SessionBean) enterpriseBean;
57: switch (sessionBean.getSessionType()) {
58: case STATEFUL:
59: String ejbName = sessionBean.getEjbName();
60: EjbDeployment ejbDeployment = openejbJar
61: .getDeploymentsByEjbName().get(ejbName);
62: if (null == ejbDeployment) {
63: throw new OpenEJBException(
64: "No ejbDeployment for ejbName ["
65: + ejbName + "]");
66: }
67: ejbDeployment.setContainerId(containerId);
68: }
69: }
70: }
71: }
72: return appModule;
73: }
74: }
|