Package ch.grengine.engine
Class Loader
java.lang.Object
ch.grengine.engine.Loader
- All Implemented Interfaces:
Closeable,AutoCloseable
Wrapper for a
SourceClassLoader that can only be used
by the Engine that created it.- Since:
- 1.0
- Author:
- Alain Stalder, Made in Switzerland.
-
Constructor Summary
ConstructorsConstructorDescriptionLoader(EngineId engineId, long number, boolean isAttached, ClassReleaser classReleaser, SourceClassLoader sourceClassLoader) constructor, with given class releaser.Loader(EngineId engineId, long number, boolean isAttached, SourceClassLoader sourceClassLoader) constructor, with default class releaser. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()release metadata for all classed ever loaded using this loader.booleantwo loaders are equal if and only if their loader number and their engine ID are equal.longgets the loader number.getSourceClassLoader(EngineId engineId) gets the source class loader (if the engine ID matches).inthashCode()implementation based on loader number and engine ID.booleangets whether the loader is attached to the engine or not.voidsetSourceClassLoader(EngineId engineId, SourceClassLoader sourceClassLoader) sets the source class loader (if the engine ID matches).toString()returns a string suitable for logging.
-
Constructor Details
-
Loader
public Loader(EngineId engineId, long number, boolean isAttached, SourceClassLoader sourceClassLoader) constructor, with default class releaser.- Parameters:
engineId- the engine ID, used to authenticate the caller in some instance methodsnumber- the loader numberisAttached- whether the loader is attached to the engine or notsourceClassLoader- theSourceClassLoaderto use for loading classes- Throws:
NullPointerException- if any of the arguments is null- Since:
- 1.0
-
Loader
public Loader(EngineId engineId, long number, boolean isAttached, ClassReleaser classReleaser, SourceClassLoader sourceClassLoader) constructor, with given class releaser.- Parameters:
engineId- the engine ID, used to authenticate the caller in some instance methodsnumber- the loader numberisAttached- whether the loader is attached to the engine or notclassReleaser- the class releasersourceClassLoader- theSourceClassLoaderto use for loading classes- Throws:
NullPointerException- if any of the arguments is null- Since:
- 1.1
-
-
Method Details
-
getSourceClassLoader
gets the source class loader (if the engine ID matches).- Parameters:
engineId- engine ID- Returns:
- source class loader
- Throws:
IllegalArgumentException- if the engine ID does not match- Since:
- 1.0
-
setSourceClassLoader
sets the source class loader (if the engine ID matches).- Parameters:
engineId- engine IDsourceClassLoader- source class loader- Throws:
IllegalArgumentException- if the engine ID does not match- Since:
- 1.0
-
getNumber
public long getNumber()gets the loader number.- Returns:
- loader number
- Since:
- 1.0
-
isAttached
public boolean isAttached()gets whether the loader is attached to the engine or not.- Returns:
- whether the loader is attached to the engine or not
- Since:
- 1.0
-
equals
two loaders are equal if and only if their loader number and their engine ID are equal. -
hashCode
public int hashCode()implementation based on loader number and engine ID. -
toString
returns a string suitable for logging. -
close
public void close()release metadata for all classed ever loaded using this loader.Allows to remove metadata associated by Groovy (or Java) with a class, which is often necessary to get on-the-fly garbage collection.
Generally call only when really done using this loader and all loaded classes; subsequently trying to use this loader or its classes results generally in undefined behavior.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Since:
- 1.1
-