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.corba;
17:
18: import java.util.HashMap;
19: import java.util.Map;
20:
21: import org.omg.CORBA.ORB;
22: import org.omg.CORBA.Policy;
23: import org.omg.PortableServer.POA;
24: import org.apache.openejb.ContainerType;
25:
26: /**
27: * @version $Revision: 477657 $ $Date: 2006-11-21 04:54:49 -0800 (Tue, 21 Nov 2006) $
28: */
29: public final class AdapterWrapper {
30: private final static Map adapters = new HashMap();
31: private final TSSLink tssLink;
32: private Adapter generator;
33:
34: public AdapterWrapper(TSSLink tssLink) {
35: this .tssLink = tssLink;
36:
37: }
38:
39: public void start(ORB orb, POA poa, Policy securityPolicy)
40: throws CORBAException {
41: ContainerType containerType = tssLink.getDeployment()
42: .getContainer().getContainerType();
43: switch (containerType) {
44: case STATELESS:
45: generator = new AdapterStateless(tssLink, orb, poa,
46: securityPolicy);
47: break;
48: case STATEFUL:
49: generator = new AdapterStateful(tssLink, orb, poa,
50: securityPolicy);
51: break;
52: case BMP_ENTITY:
53: case CMP_ENTITY:
54: generator = new AdapterEntity(tssLink, orb, poa,
55: securityPolicy);
56: break;
57: default:
58: throw new CORBAException(
59: "CORBA Adapter does not handle MDB containers");
60: }
61: adapters.put(tssLink.getContainerId(), generator);
62: }
63:
64: public void stop() throws CORBAException {
65: generator.stop();
66: adapters.remove(tssLink.getContainerId());
67: }
68:
69: public static RefGenerator getRefGenerator(String containerId) {
70: return (RefGenerator) adapters.get(containerId);
71: }
72: }
|