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.geronimo.kernel.repository;
017:
018: import java.io.Serializable;
019: import java.util.Collection;
020: import java.util.HashSet;
021: import java.util.LinkedHashSet;
022: import java.util.Set;
023: import java.util.List;
024: import java.util.Collections;
025: import java.util.ArrayList;
026: import java.util.Iterator;
027:
028: /**
029: * holds the data from the EnvironmentType xml while it is being resolved, transitively closed, etc.
030: *
031: * @version $Rev: 519834 $ $Date: 2007-03-18 21:32:05 -0700 (Sun, 18 Mar 2007) $
032: */
033: public class Environment implements Serializable {
034: private static final long serialVersionUID = 7075760873629376317L;
035:
036: private Artifact configId;
037:
038: private final LinkedHashSet dependencies = new LinkedHashSet();
039:
040: private final Set hiddenClasses = new HashSet();
041: private final Set nonOverrideableClasses = new HashSet();
042:
043: private boolean inverseClassLoading;
044: private boolean suppressDefaultEnvironment;
045:
046: public Environment() {
047: }
048:
049: public Environment(Artifact configId) {
050: this .configId = configId;
051: }
052:
053: public Environment(Environment environment) {
054: this .configId = environment.getConfigId();
055: this .dependencies.addAll(environment.dependencies);
056: this .hiddenClasses.addAll(environment.getHiddenClasses());
057: this .nonOverrideableClasses.addAll(environment
058: .getNonOverrideableClasses());
059: this .inverseClassLoading = environment.isInverseClassLoading();
060: this .suppressDefaultEnvironment = environment
061: .isSuppressDefaultEnvironment();
062: }
063:
064: public Artifact getConfigId() {
065: return configId;
066: }
067:
068: public void setConfigId(Artifact configId) {
069: this .configId = configId;
070: }
071:
072: /**
073: * Gets a List (with elements of type Dependency) of the configuration and
074: * JAR dependencies of this configuration.
075: *
076: * @see Dependency
077: */
078: public List<Dependency> getDependencies() {
079: return Collections.unmodifiableList(new ArrayList<Dependency>(
080: dependencies));
081: }
082:
083: public void addDependency(Artifact artifact, ImportType importType) {
084: this .dependencies.add(new Dependency(artifact, importType));
085: }
086:
087: public void addDependency(Dependency dependency) {
088: this .dependencies.add(dependency);
089: }
090:
091: public void addDependencies(Collection dependencies) {
092: for (Iterator iterator = dependencies.iterator(); iterator
093: .hasNext();) {
094: // make sure they are all dependency objects... generics would be sooooo nice
095: Dependency dependency = (Dependency) iterator.next();
096: addDependency(dependency);
097: }
098: }
099:
100: public void setDependencies(Collection dependencies) {
101: this .dependencies.clear();
102: addDependencies(dependencies);
103: }
104:
105: /**
106: * todo: I should be documented so it's not completely unclear what kind of
107: * elements I hold.
108: */
109: public Set getHiddenClasses() {
110: return hiddenClasses;
111: }
112:
113: public void addHiddenClasses(Collection hiddenClasses) {
114: this .hiddenClasses.addAll(hiddenClasses);
115: }
116:
117: public void setHiddenClasses(Collection hiddenClasses) {
118: this .hiddenClasses.clear();
119: addHiddenClasses(hiddenClasses);
120: }
121:
122: /**
123: * todo: I should be documented so it's not completely unclear what kind of
124: * elements I hold.
125: */
126: public Set getNonOverrideableClasses() {
127: return nonOverrideableClasses;
128: }
129:
130: public void addNonOverrideableClasses(
131: Collection nonOverrideableClasses) {
132: this .nonOverrideableClasses.addAll(nonOverrideableClasses);
133: }
134:
135: public void setNonOverrideableClasses(
136: Collection nonOverrideableClasses) {
137: this .nonOverrideableClasses.clear();
138: addNonOverrideableClasses(nonOverrideableClasses);
139: }
140:
141: public boolean isInverseClassLoading() {
142: return inverseClassLoading;
143: }
144:
145: public void setInverseClassLoading(boolean inverseClassLoading) {
146: this .inverseClassLoading = inverseClassLoading;
147: }
148:
149: public boolean isSuppressDefaultEnvironment() {
150: return suppressDefaultEnvironment;
151: }
152:
153: public void setSuppressDefaultEnvironment(
154: boolean suppressDefaultEnvironment) {
155: this.suppressDefaultEnvironment = suppressDefaultEnvironment;
156: }
157:
158: }
|