KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > kernel > repository > Environment


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. 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 JavaDoc;
21 import java.util.Collection JavaDoc;
22 import java.util.HashSet JavaDoc;
23 import java.util.LinkedHashSet JavaDoc;
24 import java.util.Set JavaDoc;
25 import java.util.List JavaDoc;
26 import java.util.Collections JavaDoc;
27 import java.util.ArrayList JavaDoc;
28 import java.util.Iterator JavaDoc;
29
30 /**
31  * holds the data from the EnvironmentType xml while it is being resolved, transitively closed, etc.
32  *
33  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
34  */

35 public class Environment implements Serializable JavaDoc {
36     private static final long serialVersionUID = 7075760873629376317L;
37
38     private Artifact configId;
39
40     private final LinkedHashSet JavaDoc dependencies = new LinkedHashSet JavaDoc();
41
42     private final Set JavaDoc hiddenClasses = new HashSet JavaDoc();
43     private final Set JavaDoc nonOverrideableClasses = new HashSet JavaDoc();
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 JavaDoc getDependencies() {
79         return Collections.unmodifiableList(new ArrayList JavaDoc(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 JavaDoc dependencies) {
91         for (Iterator JavaDoc iterator = dependencies.iterator(); iterator.hasNext();) {
92             // make sure they are all dependency objects... generics would be sooooo nice
93
Dependency dependency = (Dependency) iterator.next();
94             addDependency(dependency);
95         }
96     }
97
98     public void setDependencies(Collection JavaDoc 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 JavaDoc getHiddenClasses() {
108         return hiddenClasses;
109     }
110
111     public void addHiddenClasses(Collection JavaDoc hiddenClasses) {
112         this.hiddenClasses.addAll(hiddenClasses);
113     }
114
115     public void setHiddenClasses(Collection JavaDoc 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 JavaDoc getNonOverrideableClasses() {
125         return nonOverrideableClasses;
126     }
127
128     public void addNonOverrideableClasses(Collection JavaDoc nonOverrideableClasses) {
129         this.nonOverrideableClasses.addAll(nonOverrideableClasses);
130     }
131
132     public void setNonOverrideableClasses(Collection JavaDoc 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 }
154
Popular Tags