001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.openejb.config;
017:
018: import org.apache.openejb.jee.Connector;
019:
020: import java.io.File;
021: import java.util.HashMap;
022: import java.util.Map;
023: import java.util.List;
024: import java.util.ArrayList;
025: import java.util.Set;
026: import java.util.TreeSet;
027: import java.net.URL;
028:
029: /**
030: * @version $Rev: 602704 $ $Date: 2007-12-09 09:58:22 -0800 $
031: */
032: public class ConnectorModule implements DeploymentModule {
033: private final ValidationContext validation;
034: private final Map<String, Object> altDDs = new HashMap<String, Object>();
035:
036: private Connector connector;
037: private ClassLoader classLoader;
038: private String jarLocation;
039: private final String moduleId;
040: private final List<URL> libraries = new ArrayList<URL>();
041: private final Set<String> watchedResources = new TreeSet<String>();
042:
043: public ConnectorModule(Connector connector,
044: ClassLoader classLoader, String jarLocation, String moduleId) {
045: this .connector = connector;
046: this .classLoader = classLoader;
047: this .jarLocation = jarLocation;
048:
049: if (moduleId == null) {
050: if (connector != null && connector.getId() != null) {
051: moduleId = connector.getId();
052: } else {
053: File file = new File(jarLocation);
054: moduleId = file.getName();
055: if (moduleId.endsWith(".unpacked")) {
056: moduleId = moduleId.substring(0, moduleId.length()
057: - ".unpacked".length());
058: }
059: if (moduleId.endsWith(".rar")) {
060: moduleId = moduleId.substring(0, moduleId.length()
061: - ".rar".length());
062: }
063: }
064: }
065:
066: this .moduleId = moduleId;
067: validation = new ValidationContext(ConnectorModule.class,
068: jarLocation);
069: }
070:
071: public ValidationContext getValidation() {
072: return validation;
073: }
074:
075: public String getModuleId() {
076: return moduleId;
077: }
078:
079: public Map<String, Object> getAltDDs() {
080: return altDDs;
081: }
082:
083: public Connector getConnector() {
084: return connector;
085: }
086:
087: public void setConnector(Connector connector) {
088: this .connector = connector;
089: }
090:
091: public ClassLoader getClassLoader() {
092: return classLoader;
093: }
094:
095: public void setClassLoader(ClassLoader classLoader) {
096: this .classLoader = classLoader;
097: }
098:
099: public String getJarLocation() {
100: return jarLocation;
101: }
102:
103: public void setJarLocation(String jarLocation) {
104: this .jarLocation = jarLocation;
105: }
106:
107: public List<URL> getLibraries() {
108: return libraries;
109: }
110:
111: public Set<String> getWatchedResources() {
112: return watchedResources;
113: }
114: }
|