1 /**
2 *
3 * Copyright 2006 The Apache Software Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * 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 */
17
18 package org.apache.geronimo.kernel.repository;
19
20 import java.io.Serializable;
21 import java.util.Collection;
22 import java.util.HashSet;
23 import java.util.LinkedHashSet;
24 import java.util.Set;
25 import java.util.List;
26 import java.util.Collections;
27 import java.util.ArrayList;
28 import java.util.Iterator;
29
30 /**
31 * holds the data from the EnvironmentType xml while it is being resolved, transitively closed, etc.
32 *
33 * @version $Rev: 430508 $ $Date: 2006-08-10 12:56:47 -0700 (Thu, 10 Aug 2006) $
34 */
35 public class Environment implements Serializable {
36 private static final long serialVersionUID = 7075760873629376317L;
37
38 private Artifact configId;
39
40 private final LinkedHashSet dependencies = new LinkedHashSet();
41
42 private final Set hiddenClasses = new HashSet();
43 private final Set nonOverrideableClasses = new HashSet();
44
45 private boolean inverseClassLoading;
46 private boolean suppressDefaultEnvironment;
47
48 public Environment() {
49 }
50
51 public Environment(Artifact configId) {
52 this.configId = configId;
53 }
54
55 public Environment(Environment environment) {
56 this.configId = environment.getConfigId();
57 this.dependencies.addAll(environment.dependencies);
58 this.hiddenClasses.addAll(environment.getHiddenClasses());
59 this.nonOverrideableClasses.addAll(environment.getNonOverrideableClasses());
60 this.inverseClassLoading = environment.isInverseClassLoading();
61 this.suppressDefaultEnvironment = environment.isSuppressDefaultEnvironment();
62 }
63
64 public Artifact getConfigId() {
65 return configId;
66 }
67
68 public void setConfigId(Artifact configId) {
69 this.configId = configId;
70 }
71
72 /**
73 * Gets a List (with elements of type Dependency) of the configuration and
74 * JAR dependencies of this configuration.
75 *
76 * @see Dependency
77 */
78 public List getDependencies() {
79 return Collections.unmodifiableList(new ArrayList(dependencies));
80 }
81
82 public void addDependency(Artifact artifact, ImportType importType) {
83 this.dependencies.add(new Dependency(artifact, importType));
84 }
85
86 public void addDependency(Dependency dependency) {
87 this.dependencies.add(dependency);
88 }
89
90 public void addDependencies(Collection dependencies) {
91 for (Iterator iterator = dependencies.iterator(); iterator.hasNext();) {
92
93 Dependency dependency = (Dependency) iterator.next();
94 addDependency(dependency);
95 }
96 }
97
98 public void setDependencies(Collection dependencies) {
99 this.dependencies.clear();
100 addDependencies(dependencies);
101 }
102
103 /**
104 * todo: I should be documented so it's not completely unclear what kind of
105 * elements I hold.
106 */
107 public Set getHiddenClasses() {
108 return hiddenClasses;
109 }
110
111 public void addHiddenClasses(Collection hiddenClasses) {
112 this.hiddenClasses.addAll(hiddenClasses);
113 }
114
115 public void setHiddenClasses(Collection hiddenClasses) {
116 this.hiddenClasses.clear();
117 addHiddenClasses(hiddenClasses);
118 }
119
120 /**
121 * todo: I should be documented so it's not completely unclear what kind of
122 * elements I hold.
123 */
124 public Set getNonOverrideableClasses() {
125 return nonOverrideableClasses;
126 }
127
128 public void addNonOverrideableClasses(Collection nonOverrideableClasses) {
129 this.nonOverrideableClasses.addAll(nonOverrideableClasses);
130 }
131
132 public void setNonOverrideableClasses(Collection nonOverrideableClasses) {
133 this.nonOverrideableClasses.clear();
134 addNonOverrideableClasses(nonOverrideableClasses);
135 }
136
137 public boolean isInverseClassLoading() {
138 return inverseClassLoading;
139 }
140
141 public void setInverseClassLoading(boolean inverseClassLoading) {
142 this.inverseClassLoading = inverseClassLoading;
143 }
144
145 public boolean isSuppressDefaultEnvironment() {
146 return suppressDefaultEnvironment;
147 }
148
149 public void setSuppressDefaultEnvironment(boolean suppressDefaultEnvironment) {
150 this.suppressDefaultEnvironment = suppressDefaultEnvironment;
151 }
152
153 }