Interface ClassLoaderWriter
-
@ProviderType public interface ClassLoaderWriter
A class loader writer is a service allowing to dynamically generate classes and resources. It provides methods for writing, removing, and moving resources. In addition it provides a dynamic class loader which can be used to dynamically load generated classes. For example a class loader writer could write generated class files into the repository or the temporary file system.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
delete(java.lang.String path)
Delete the class/resourcejava.lang.ClassLoader
getClassLoader()
Get a dynamic class loader.java.io.InputStream
getInputStream(java.lang.String path)
Get the input stream for a class or resource handled by the underlying class loader.long
getLastModified(java.lang.String path)
Return the last modified for the class or resource.java.io.OutputStream
getOutputStream(java.lang.String path)
Get the output stream for a class or resource handled by the underlying class loader.boolean
rename(java.lang.String oldPath, java.lang.String newPath)
Rename a class/resource.
-
-
-
Method Detail
-
getOutputStream
java.io.OutputStream getOutputStream(java.lang.String path)
Get the output stream for a class or resource handled by the underlying class loader. If the resource/class does not exists it should be created.- Parameters:
path
- The path of the class/resource. The path should be absolute like /com/my/domain/HelloWorld.class- Returns:
- The output stream.
-
getInputStream
java.io.InputStream getInputStream(java.lang.String path) throws java.io.IOException
Get the input stream for a class or resource handled by the underlying class loader.- Parameters:
path
- The path of the class/resource. The path should be absolute like /com/my/domain/HelloWorld.class- Returns:
- The input stream for the resource/class.
- Throws:
java.io.IOException
- If the resource/class does not exist.
-
getLastModified
long getLastModified(java.lang.String path)
Return the last modified for the class or resource.- Parameters:
path
- The path of the class/resource. The path should be absolute like /com/my/domain/HelloWorld.class- Returns:
- The last modified information or
-1
if the information can't be detected.
-
delete
boolean delete(java.lang.String path)
Delete the class/resource- Parameters:
path
- The path of the class/resource. The path should be absolute like /com/my/domain/HelloWorld.class- Returns:
true
if the resource exists and could be deleted,false
otherwise.
-
rename
boolean rename(java.lang.String oldPath, java.lang.String newPath)
Rename a class/resource. The paths should be absolute like /com/my/domain/HelloWorld.class- Parameters:
oldPath
- The path of the class/resource.newPath
- The new path.- Returns:
true
if the renaming has been successful.
-
getClassLoader
java.lang.ClassLoader getClassLoader()
Get a dynamic class loader. The returned class loader can be used to load classes and resources generated through this class loader writer. The parent of this class loader is a class loader from theDynamicClassLoaderManager
. The class loader returned by this method should not be cached, as it might get stale (e.g. used classes are removed etc.). Therefore each time a newly generated class is loaded, the class loader should be fetched again using this method. The implementation might cache the class loader and return the same loader on subsequent calls for as long as possible. Clients of the class loader can use theDynamicClassLoader.isLive()
method to check if the fetched instance can still be used.- Returns:
- A dynamic class loader implementing
DynamicClassLoader
- Since:
- 1.3
-
-