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.openejb.config;
17:
18: import org.apache.openejb.OpenEJBException;
19: import org.apache.openejb.jee.JndiConsumer;
20: import org.apache.openejb.jee.JndiReference;
21:
22: import java.util.ArrayList;
23: import java.util.List;
24:
25: /**
26: * @version $Rev$ $Date$
27: */
28: public class ClearEmptyMappedName implements DynamicDeployer {
29:
30: public AppModule deploy(AppModule appModule)
31: throws OpenEJBException {
32: for (EjbModule ejbModule : appModule.getEjbModules()) {
33: for (JndiConsumer consumer : ejbModule.getEjbJar()
34: .getEnterpriseBeans()) {
35: clearEmptyMappedName(consumer);
36: }
37: }
38: for (ClientModule clientModule : appModule.getClientModules()) {
39: clearEmptyMappedName(clientModule.getApplicationClient());
40: }
41: for (WebModule webModule : appModule.getWebModules()) {
42: clearEmptyMappedName(webModule.getWebApp());
43: }
44: return appModule;
45: }
46:
47: private void clearEmptyMappedName(JndiConsumer consumer) {
48: List<JndiReference> refs = new ArrayList<JndiReference>();
49: refs.addAll(consumer.getEjbLocalRef());
50: refs.addAll(consumer.getEjbRef());
51: refs.addAll(consumer.getEnvEntry());
52: refs.addAll(consumer.getMessageDestinationRef());
53: refs.addAll(consumer.getPersistenceContextRef());
54: refs.addAll(consumer.getPersistenceUnitRef());
55: refs.addAll(consumer.getResourceEnvRef());
56: refs.addAll(consumer.getResourceRef());
57: refs.addAll(consumer.getServiceRef());
58:
59: for (JndiReference ref : refs) {
60: if (ref.getMappedName() != null
61: && ref.getMappedName().length() == 0)
62: ref.setMappedName(null);
63: }
64: }
65: }
|