001: /**
002: *
003: * Licensed to the Apache Software Foundation (ASF) under one or more
004: * contributor license agreements. See the NOTICE file distributed with
005: * this work for additional information regarding copyright ownership.
006: * The ASF licenses this file to You under the Apache License, Version 2.0
007: * (the "License"); you may not use this file except in compliance with
008: * the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */package org.apache.openejb.config;
018:
019: import org.apache.openejb.jee.EjbJar;
020: import org.apache.openejb.jee.Webservices;
021: import org.apache.openejb.jee.oejb3.OpenejbJar;
022:
023: import java.io.File;
024: import java.util.Map;
025: import java.util.HashMap;
026: import java.util.Set;
027: import java.util.TreeSet;
028:
029: /**
030: * Class is to remain "dumb" and should not have deployment logic added to it.
031: * Class is intentionally not an interface as that would encourage "smart" implementations
032: * @version $Revision: 607308 $ $Date: 2007-12-28 10:31:49 -0800 $
033: */
034: public class EjbModule implements WsModule {
035:
036: private final ValidationContext validation;
037:
038: private ClassLoader classLoader;
039: private String jarLocation;
040: private EjbJar ejbJar;
041: private OpenejbJar openejbJar;
042: private Webservices webservices;
043: private String moduleId;
044: private final Map<String, Object> altDDs = new HashMap<String, Object>();
045: private final Set<String> watchedResources = new TreeSet<String>();
046:
047: public EjbModule(EjbJar ejbJar) {
048: this (Thread.currentThread().getContextClassLoader(), null,
049: ejbJar, null);
050: }
051:
052: public EjbModule(EjbJar ejbJar, OpenejbJar openejbJar) {
053: this (Thread.currentThread().getContextClassLoader(), null,
054: ejbJar, openejbJar);
055: }
056:
057: public EjbModule(ClassLoader classLoader, String moduleId,
058: String jarURI, EjbJar ejbJar, OpenejbJar openejbJar) {
059: if (classLoader == null) {
060: throw new NullPointerException("classLoader is null");
061: }
062: this .classLoader = classLoader;
063: this .ejbJar = ejbJar;
064: this .openejbJar = openejbJar;
065:
066: if (jarURI == null) {
067: if (moduleId != null) {
068: jarURI = moduleId;
069: } else if (ejbJar.getId() != null
070: && !ejbJar.getId().equals("")) {
071: jarURI = ejbJar.getId();
072: } else {
073: jarURI = ejbJar.toString();
074: }
075: }
076: this .jarLocation = jarURI;
077:
078: if (moduleId == null) {
079: if (ejbJar != null && ejbJar.getId() != null
080: && !ejbJar.getId().equals("")) {
081: moduleId = ejbJar.getId();
082: } else {
083: File file = new File(jarURI);
084: moduleId = file.getName();
085: if (moduleId == null) {
086: moduleId = jarURI;
087: }
088: }
089: }
090: this .moduleId = moduleId;
091: validation = new ValidationContext(EjbModule.class, jarLocation);
092: }
093:
094: public EjbModule(ClassLoader classLoader, String jarURI,
095: EjbJar ejbJar, OpenejbJar openejbJar) {
096: this (classLoader, null, jarURI, ejbJar, openejbJar);
097: }
098:
099: public ValidationContext getValidation() {
100: return validation;
101: }
102:
103: public Map<String, Object> getAltDDs() {
104: return altDDs;
105: }
106:
107: public ClassLoader getClassLoader() {
108: return classLoader;
109: }
110:
111: public void setClassLoader(ClassLoader classLoader) {
112: this .classLoader = classLoader;
113: }
114:
115: public EjbJar getEjbJar() {
116: return ejbJar;
117: }
118:
119: public void setEjbJar(EjbJar ejbJar) {
120: this .ejbJar = ejbJar;
121: }
122:
123: public String getJarLocation() {
124: return jarLocation;
125: }
126:
127: public void setJarLocation(String jarLocation) {
128: this .jarLocation = jarLocation;
129: }
130:
131: public String getModuleId() {
132: return moduleId;
133: }
134:
135: public void setModuleId(String moduleId) {
136: this .moduleId = moduleId;
137: }
138:
139: public OpenejbJar getOpenejbJar() {
140: return openejbJar;
141: }
142:
143: public void setOpenejbJar(OpenejbJar openejbJar) {
144: this .openejbJar = openejbJar;
145: }
146:
147: public Webservices getWebservices() {
148: return webservices;
149: }
150:
151: public void setWebservices(Webservices webservices) {
152: this .webservices = webservices;
153: }
154:
155: public Set<String> getWatchedResources() {
156: return watchedResources;
157: }
158: }
|