Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.tools
Class LoaderConfiguration

    java.lang.Object
      org.codehaus.groovy.tools.LoaderConfiguration

    public class LoaderConfiguration

extends 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.

Defining the main class is optional if setRequireMain(boolean) was called with false, before reading the configuration. You can use the wildcard "*" to filter the path, but only for files, not directories. to match directories use "**". The ${propertyname} is replaced by the value of the system's property name. You can use user.home here for example. If the property does not exist, an empty string will be used. If the path or file after the load command does not exist, the path will be ignored.

Version:
  $Revision: 10259 $
Author:
  Jochen Theodorou
See Also:
  `RootLoader`

Constructor Summary
`LoaderConfiguration()` creates a new loader configuration

Method Summary
`void` | `addClassPath(String path)` adds a classpath to this configuration.
`void` | `addFile(File f)` adds a file to the classpath if it does exist
`void` | `addFile(String s)` adds a file to the classpath if it does exist
`void` | `configure(InputStream is)` configures this loader with a stream
`URL[]` | `getClassPathUrls()` gets a classpath as URL[] from this configuration.
`String` | `getMainClass()` returns the main class or null is no is defined
`void` | `setMainClass(String clazz)` sets the main class.
`void` | `setRequireMain(boolean requireMain)` if set to false no main class is required when calling

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### LoaderConfiguration

    public LoaderConfiguration()

  creates a new loader configuration

Method Detail

### configure

    public void configure(InputStream is)
                   throws IOException

  configures this loader with a stream

  Parameters:
    `is` - stream used to read the configuration
  Throws:
    `IOException` - if reading or parsing the contents of the stream fails

### addFile

    public void addFile(File f)

  adds a file to the classpath if it does exist

### addFile

    public void addFile(String s)

  adds a file to the classpath if it does exist

### addClassPath

    public void addClassPath(String path)

  adds a classpath to this configuration. It expects a string with multiple paths, seperated by the system dependent

  See Also:
    `File.pathSeparator`

### getClassPathUrls

    public URL[] getClassPathUrls()

  gets a classpath as URL[] from this configuration. This can be used to construct a @see java.net.URLClassLoader

### getMainClass

    public String getMainClass()

  returns the main class or null is no is defined

### setMainClass

    public void setMainClass(String clazz)

  sets the main class. If there is already a main class it is overwritten. Calling @see #configure(InputStream) after calling this method does not require a main class definition inside the stream

### setRequireMain

    public void setRequireMain(boolean requireMain)

  if set to false no main class is required when calling

  See Also:
    `configure(InputStream)`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 2003-2008 The Codehaus. All rights reserved.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD