Package org.codehaus.groovy.tools
Class LoaderConfiguration
- java.lang.Object
-
- org.codehaus.groovy.tools.LoaderConfiguration
-
public class LoaderConfiguration extends java.lang.Object
Class used to configure a RootLoader from a stream or by using it's methods. The stream can be for example a FileInputStream from a file with the following format:# comment main is classname load path load file load pathWith${property} load pathWith!{required.property} load path/*.jar load path/**/*.jar
- All lines starting with "#" are ignored.
- The "main is" part may only be once in the file. The String afterwards is the name of a class with a main method.
- The "load" command will add the given file or path to the classpath in this configuration object. If the path does not exist, the path will be ignored.
- properties referenced using !{x} are required.
- properties referenced using ${x} are not required. If the property does not exist the whole load instruction line will be ignored.
- * is used to match zero or more characters in a file.
- ** is used to match zero or more directories.
- Loading paths with
load ./*.jar
orload *.jar
are not supported.
- Version:
- $Revision$
- Author:
- Jochen Theodorou
- See Also:
RootLoader
-
-
Constructor Summary
Constructors Constructor Description LoaderConfiguration()
creates a new loader configuration
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addClassPath(java.lang.String path)
Adds a classpath to this configuration.void
addFile(java.io.File file)
Adds a file to the classpath if it exists.void
addFile(java.lang.String filename)
Adds a file to the classpath if it exists.void
configure(java.io.InputStream is)
configures this loader with a streamjava.net.URL[]
getClassPathUrls()
The classpath as URL[] from this configuration.java.lang.String
getMainClass()
Returns the name of the main class for this configuration.void
setMainClass(java.lang.String classname)
Sets the main class.void
setRequireMain(boolean requireMain)
Determines if a main class is required when calling.
-
-
-
Method Detail
-
configure
public void configure(java.io.InputStream is) throws java.io.IOException
configures this loader with a stream- Parameters:
is
- stream used to read the configuration- Throws:
java.io.IOException
- if reading or parsing the contents of the stream fails
-
addFile
public void addFile(java.io.File file)
Adds a file to the classpath if it exists.- Parameters:
file
- the file to add
-
addFile
public void addFile(java.lang.String filename)
Adds a file to the classpath if it exists.- Parameters:
filename
- the name of the file to add
-
addClassPath
public void addClassPath(java.lang.String path)
Adds a classpath to this configuration. It expects a string with multiple paths, separated by the system dependent path separator. Expands wildcards, e.g. dir/* into all the jars in dir.- Parameters:
path
- the path as a path separator delimited string- See Also:
File.pathSeparator
-
getClassPathUrls
public java.net.URL[] getClassPathUrls()
The classpath as URL[] from this configuration. This can be used to construct a class loader.- Returns:
- the classpath
- See Also:
URLClassLoader
-
getMainClass
public java.lang.String getMainClass()
Returns the name of the main class for this configuration.- Returns:
- the name of the main class or null if not defined
-
setMainClass
public void setMainClass(java.lang.String classname)
Sets the main class. If there is already a main class it is overwritten. Callingconfigure(InputStream)
after calling this method does not require a main class definition inside the stream.- Parameters:
classname
- the name to become the main class
-
setRequireMain
public void setRequireMain(boolean requireMain)
Determines if a main class is required when calling.- Parameters:
requireMain
- set to false if no main class is required- See Also:
configure(InputStream)
-
-