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;
21:
22: import org.apache.geronimo.gbean.AbstractName;
23: import org.apache.geronimo.j2ee.deployment.EARContext;
24: import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
25: import org.apache.openejb.jee.EnterpriseBean;
26: import org.apache.openejb.jee.EntityBean;
27: import org.apache.openejb.jee.MessageDrivenBean;
28: import org.apache.openejb.jee.SessionBean;
29:
30: /**
31: *
32: * @version $Rev:$ $Date:$
33: */
34: public class BasicEjbDeploymentGBeanNameBuilder implements
35: EjbDeploymentGBeanNameBuilder {
36:
37: public AbstractName createEjbName(EARContext earContext,
38: EjbModule ejbModule, EnterpriseBean enterpriseBean) {
39: String ejbName = enterpriseBean.getEjbName();
40: String type = null;
41: if (enterpriseBean instanceof SessionBean) {
42: SessionBean sessionBean = (SessionBean) enterpriseBean;
43: switch (sessionBean.getSessionType()) {
44: case STATELESS:
45: type = NameFactory.STATELESS_SESSION_BEAN;
46: break;
47: case STATEFUL:
48: type = NameFactory.STATEFUL_SESSION_BEAN;
49: break;
50: }
51: } else if (enterpriseBean instanceof EntityBean) {
52: type = NameFactory.ENTITY_BEAN;
53: } else if (enterpriseBean instanceof MessageDrivenBean) {
54: type = NameFactory.MESSAGE_DRIVEN_BEAN;
55: }
56: if (type == null) {
57: throw new IllegalArgumentException(
58: "Unknown enterprise bean type XXX "
59: + enterpriseBean.getClass().getName());
60: }
61: return earContext.getNaming().createChildName(
62: ejbModule.getModuleName(), ejbName, type);
63: }
64:
65: }
|