nu.staldal.lagoon.core
Interface LagoonContext

All Known Implementing Classes:
LagoonProcessor

public interface LagoonContext

Defines project-wide services for components. The repository may be unavailable. Then all attempts to use it will return null or false


Method Summary
 boolean canCheckFileHasBeenUpdated(java.lang.String url)
          Tell whether the given source can be checked for dependency.
 void deleteClassInRepository(java.lang.String className)
          Delete a Java class file from the repository.
 java.lang.String getFileURLRelativeTo(java.lang.String url, java.lang.String base)
          Get an URL representing the given file or directory.
 java.lang.Object getObjectFromRepository(java.lang.String key)
          Get an object from the repository.
 java.lang.String getProperty(java.lang.String key)
          Return the value of a project property.
 java.io.File getSourceRootDir()
          Get an absolute File object representing the source root directory.
 java.io.File getTempDir()
          Get the temp directory.
 java.lang.Class loadClassFromRepository(java.lang.String className)
          Load a Java class file from the repository.
 boolean putObjectIntoRepository(java.lang.String key, java.lang.Object obj)
          Store an object into the repository.
 java.io.InputStream readFileFromRepository(java.lang.String key)
          Read from a file in the repository.
 void reloadClasses()
          Reload classes.
 java.io.OutputStream storeClassInRepository(java.lang.String className)
          Store a Java class file in the repository.
 java.io.OutputStream storeFileInRepository(java.lang.String key)
          Store a file in the repository.
 

Method Detail

getTempDir

java.io.File getTempDir()
Get the temp directory.


readFileFromRepository

java.io.InputStream readFileFromRepository(java.lang.String key)
Read from a file in the repository. Read from the returned InputStream and close() it.

Parameters:
key - the key to locate the file
Returns:
an InputStream to read the file from, or null if the file wasn't found.

storeFileInRepository

java.io.OutputStream storeFileInRepository(java.lang.String key)
                                           throws java.io.IOException
Store a file in the repository. Write to the returned OutputStream and close() it.

Parameters:
key - the key to locate the file
Returns:
an OutputStream to write to the file, or null if the repository is unavailable.
Throws:
java.io.IOException

loadClassFromRepository

java.lang.Class loadClassFromRepository(java.lang.String className)
                                        throws java.lang.ClassNotFoundException
Load a Java class file from the repository.

Parameters:
className - the class name, no package
Returns:
the Class, never null
Throws:
java.lang.ClassNotFoundException - if the class cannot be loaded

storeClassInRepository

java.io.OutputStream storeClassInRepository(java.lang.String className)
                                            throws java.io.IOException
Store a Java class file in the repository. Write to the returned OutputStream and close() it.

Parameters:
className - the class name, no package
Returns:
an OutputStream to write to the class, or null if the repository is unavailable.
Throws:
java.io.IOException

deleteClassInRepository

void deleteClassInRepository(java.lang.String className)
                             throws java.io.IOException
Delete a Java class file from the repository.

Parameters:
className - the class name, no package
Throws:
java.io.IOException

getObjectFromRepository

java.lang.Object getObjectFromRepository(java.lang.String key)
                                         throws java.io.IOException
Get an object from the repository.

Parameters:
key - the key to locate the object
Returns:
the object, or null if not found
Throws:
java.io.IOException

reloadClasses

void reloadClasses()
Reload classes.


putObjectIntoRepository

boolean putObjectIntoRepository(java.lang.String key,
                                java.lang.Object obj)
                                throws java.io.IOException
Store an object into the repository.

Parameters:
key - the key to locate the object
obj - the object to store, must be Serializable
Returns:
true if successful, false if the repository is unavailable.
Throws:
java.io.IOException

canCheckFileHasBeenUpdated

boolean canCheckFileHasBeenUpdated(java.lang.String url)
Tell whether the given source can be checked for dependency.

Parameters:
url - URL to the file

getSourceRootDir

java.io.File getSourceRootDir()
Get an absolute File object representing the source root directory.


getFileURLRelativeTo

java.lang.String getFileURLRelativeTo(java.lang.String url,
                                      java.lang.String base)
Get an URL representing the given file or directory.

Parameters:
url - URL to the file, if relative it's searched for relative to the base parameter.
base - base URL, must be pseudo-absolute
Returns:
an absolute or pseudo-absolute URL (the url parameter unchanged unless it's relative)

getProperty

java.lang.String getProperty(java.lang.String key)
Return the value of a project property.

Parameters:
key - the property name
Returns:
the property value, or null if the property is not defined.