KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > scriptella > tools > ant > ClasspathSupportTask


1 /*
2  * Copyright 2006-2007 The Scriptella Project Team.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package scriptella.tools.ant;
17
18 import org.apache.tools.ant.AntClassLoader;
19 import org.apache.tools.ant.Task;
20 import org.apache.tools.ant.types.Path;
21 import org.apache.tools.ant.types.Reference;
22
23
24 /**
25  * Not in use now
26  *
27  * @author Fyodor Kupolov
28  * @version 1.0
29  */

30 public abstract class ClasspathSupportTask extends Task {
31     private Path classpath;
32     private AntClassLoader classLoader;
33
34     /**
35      * Sets the classpath for loading the driver.
36      *
37      * @param classpath The classpath to set
38      */

39     public void setClasspath(final Path classpath) {
40         this.classpath = classpath;
41     }
42
43     /**
44      * Add a path to the classpath for loading the driver.
45      */

46     public Path createClasspath() {
47         if (this.classpath == null) {
48             this.classpath = new Path(getProject());
49         }
50
51         return this.classpath.createPath();
52     }
53
54     /**
55      * Set the classpath for loading the driver
56      * using the classpath reference.
57      */

58     public void setClasspathRef(final Reference r) {
59         createClasspath().setRefid(r);
60     }
61
62     public ClassLoader JavaDoc getClassLoader() {
63         if (classpath != null) {
64             if (classLoader == null) {
65                 classLoader = getProject().createClassLoader(classpath);
66             }
67
68             return classLoader;
69         } else {
70             return getProject().getCoreLoader();
71         }
72     }
73
74     /**
75      * Gets the classpath.
76      *
77      * @return Returns a Path
78      */

79     public Path getClasspath() {
80         return classpath;
81     }
82
83 }
84
Popular Tags