Class Generator
java.lang.Object
de.uni_hildesheim.sse.easy.loader.AbstractLoader
de.uni_hildesheim.sse.easy.loader.Generator
Provides generator factilities for static loading.
- Author:
- Holger Eichelberger, Patrik Pastuschek
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classHelper class for carrying unbundling information.private classProcesses URLs for packing and bundling. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Fileprivate List<BundleInfo> private List<BundleInfo> private Stringprivate static IExclusionSelectorprivate Fileprivate static final Class<?>[]private Map<URL, BundleInfo> private static booleanFields inherited from class de.uni_hildesheim.sse.easy.loader.AbstractLoader
EASY_EXCLUSION_PATTERN, EASY_INCLUSION_PATTERN, TAG_EASY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddRuntimeClass(Class<?> cls, List<Class<?>> rtClasses) Adds a runtime class for being packed with the generated jars.private voidAdds the classes needed for runtime loading toos.static List<BundleInfo> autoGenerate(List<File> mainFeature, List<File> allFeatures, boolean forceBuild, String pluginPath, String eclipsePath, String targetDir, String baseDir, String binFolder, String libsFolder) Wrapps the generation into one single method for easier access.private static Map<String, EasyDependency> collectDependencies(List<Feature> features, List<Feature> additionalFeatures) Collects all required dependencies for a list of features.collectFeatures(List<Feature> features, List<Feature> additionalFeatures) Collects all required features.private static voiddeleteFolder(File folder, boolean deleteFolder) Deletes the content of a folder.filesToFeature(List<File> files) Transforms a list of files into a list of Features.static List<BundleInfo> generate(List<Feature> features, List<Feature> additionalFeatures, boolean forceBuild, String pluginPath, String eclipsePath, String target, String baseDir, String binFolder, String libsFolder) Gathers Bundles for a list of features, depending on version restrictions.protected voidgenerateJarFiles(File targetDir, boolean bundle) Generates the JAR files for static loading.getFeatureFilesFromDir(File file) Returns all files that are called feature.xml, even in subfolders.static FeaturegetFeatureFromListByName(List<Feature> features, String name) Returns (if possible) the feature with given symbolic name.private voidhandleJar(InputStream is, JarOutputStream os, Set<String> done, Set<String> exclude, Generator.UnbundleInfo unbundle) Copies the entries of an entire JAR inisto the target JAR inoswithout duplicating entries.private voidhandleJarWritingException(String name, IOException ex, InputStream is) Handles an exception thrown while writing to a Jar file.protected booleanirrelevantInJar(String name) Returns whether the name of a certain JAR entry is irrelevant for a standalone execution.private booleanisEclipseBundle(URL bundleURL) Checks whether the given url belongs to an Eclipse bundle/plug-in.private voidlogEntryName(String name) Logs a JAR entry name.static voidExecutes the generator.protected voidnotifyMapping(URL url, BundleInfo info) Is called byAbstractLoader.collectBootstrapData(BundleInfo, List, List, Object)to notify about mapping a URL to the given bundleinfo.private voidProduces the JAR entry containing the EASy startup list to be read and interpreted at loading time.static voidsetExclusionSelector(IExclusionSelector selector) Defines the exclusion selector.static voidsetVerbose(boolean verb) Sets the verbose flag.private static voidsubGenerate(List<BundleInfo> bundles) .private static List<BundleInfo> unnamed(Generator gen, List<Feature> features, List<Feature> additionalFeatures, boolean forceBuild) ...Methods inherited from class de.uni_hildesheim.sse.easy.loader.AbstractLoader
bootstrap, collectBootstrapData, genericBootstrap, getBase, getUiBundles, initializeRegistry, printDependencies, simpleBootstrap
-
Field Details
-
RUNTIME_CLASSES
-
exclusionSelector
-
verbose
private static boolean verbose -
data
-
urls
-
urlBundleMapping
-
checkedBundles
-
checkedClasspaths
-
eclipseURIPath
-
binFolder
-
libsFolder
-
-
Constructor Details
-
Generator
Creates the generator instance.- Parameters:
base- basefile.pluginPath- Folder of the easy Plugins.eclipsePath- Folder of the eclipse Plugins.binFolder- Where to find the compiled classes, relative to basePathlibsFolder- Where to find special libs.
-
-
Method Details
-
isEclipseBundle
Checks whether the given url belongs to an Eclipse bundle/plug-in.- Parameters:
bundleURL- The url/path of a jar file.- Returns:
trueif it belongs to Eclipse.
-
setExclusionSelector
Defines the exclusion selector.- Parameters:
selector- the selector instance (may be null to ignore)
-
getFeatureFilesFromDir
Returns all files that are called feature.xml, even in subfolders.- Parameters:
file- The basefile.- Returns:
- A list of all files.
-
filesToFeature
Transforms a list of files into a list of Features.- Parameters:
files- A list of the files to use.- Returns:
- A list of features. Can be empty if no (valid) files were given.
-
getFeatureFromListByName
Returns (if possible) the feature with given symbolic name.- Parameters:
features- A list of features from which to extract.name- The symbolic name of the feature.- Returns:
- The feature (or null).
-
autoGenerate
public static List<BundleInfo> autoGenerate(List<File> mainFeature, List<File> allFeatures, boolean forceBuild, String pluginPath, String eclipsePath, String targetDir, String baseDir, String binFolder, String libsFolder) Wrapps the generation into one single method for easier access.- Parameters:
mainFeature- The file or path where the main feature(s) are.allFeatures- The file or path where other features are.forceBuild- False will interrupt the build if problem occur.pluginPath- The path of the plugins. Defines the bootstrap base.eclipsePath- the path of the eclipse plugins.targetDir- the target for the generated jars.baseDir- The baseDir for the bootstrap.binFolder- Where to find the compiled classes, relative to basePathlibsFolder- Where to find special required libs.- Returns:
- The list of generated Bundles.
-
deleteFolder
Deletes the content of a folder.- Parameters:
folder- The folder to delete.deleteFolder- Iftruealso the folder itself will be deleted.
-
generate
public static List<BundleInfo> generate(List<Feature> features, List<Feature> additionalFeatures, boolean forceBuild, String pluginPath, String eclipsePath, String target, String baseDir, String binFolder, String libsFolder) Gathers Bundles for a list of features, depending on version restrictions.- Parameters:
features- A list of features for the build.additionalFeatures- A list of features that could be used by the main features.forceBuild- if true, ignore missing plugins and version issues.pluginPath- the path of the plugins. Defines the bootstrap base.eclipsePath- the path to the eclipse plugins.target- the target for the generated jars.baseDir- The baseDir for the bootstrap. Will be used if eclipsePath and/or pluginPath do not exist.binFolder- Where to find the compiled classes, relative to basePathlibsFolder- Where to find the special libs required for the build.- Returns:
- List<BundleInfo> a list containing all needed Bundles.
-
unnamed
private static List<BundleInfo> unnamed(Generator gen, List<Feature> features, List<Feature> additionalFeatures, boolean forceBuild) ...- Parameters:
gen- ...features- ...additionalFeatures- ...forceBuild- ...- Returns:
- A list of BundleInfos.
-
subGenerate
.- Parameters:
bundles- .
-
collectFeatures
private static List<Feature> collectFeatures(List<Feature> features, List<Feature> additionalFeatures) Collects all required features.- Parameters:
features- A list of features.additionalFeatures- A list of additional Features that maybe required by the main features.- Returns:
- Map<String, EasyDependency> a map with all required dependencies.
-
collectDependencies
private static Map<String,EasyDependency> collectDependencies(List<Feature> features, List<Feature> additionalFeatures) Collects all required dependencies for a list of features.- Parameters:
features- A list of features.additionalFeatures- A list of additional Features that maybe required by the main features.- Returns:
- Map<String, EasyDependency> a map with all required dependencies.
-
addRuntimeClass
Adds a runtime class for being packed with the generated jars.- Parameters:
cls- the class to be packed (including nested classes)rtClasses- the classes to be loaded (modified as a side effect)
-
main
Executes the generator.- Parameters:
args- ignored
-
generateJarFiles
Generates the JAR files for static loading.- Parameters:
targetDir- the target dire where to put the final jar files tobundle- whether libraries shall be bundled or not
-
handleJar
private void handleJar(InputStream is, JarOutputStream os, Set<String> done, Set<String> exclude, Generator.UnbundleInfo unbundle) throws IOException Copies the entries of an entire JAR inisto the target JAR inoswithout duplicating entries. ConsidersirrelevantInJar(String)in order to filter out irrelevant entries.- Parameters:
is- the input JAR as streamos- the output JAR as streamdone- already processed entries to avoid duplicatesexclude- JAR entries not to be added (in addition toirrelevantInJar(String))unbundle- information about unbundling the current streamis- Throws:
IOException- in case that reading from or writing to a JAR stream fails
-
produceStartupList
Produces the JAR entry containing the EASy startup list to be read and interpreted at loading time.- Parameters:
os- the output stream- Throws:
IOException- in case of problems writing toos
-
addRuntimeLoaderClasses
Adds the classes needed for runtime loading toos.- Parameters:
os- the JAR output stream- Throws:
IOException- in case that reading the class file or writing toosfails
-
handleJarWritingException
private void handleJarWritingException(String name, IOException ex, InputStream is) throws IOException Handles an exception thrown while writing to a Jar file.- Parameters:
name- the name of the entry being writtenex- the exception thrownis- the input stream the program is reading from (may be null)- Throws:
IOException-exif ex is not just logged as a warning
-
notifyMapping
Description copied from class:AbstractLoaderIs called byAbstractLoader.collectBootstrapData(BundleInfo, List, List, Object)to notify about mapping a URL to the given bundleinfo.- Overrides:
notifyMappingin classAbstractLoader- Parameters:
url- the URL of the bundle JARinfo- the related bundle information object
-
irrelevantInJar
Description copied from class:AbstractLoaderReturns whether the name of a certain JAR entry is irrelevant for a standalone execution.- Overrides:
irrelevantInJarin classAbstractLoader- Parameters:
name- the name- Returns:
trueif the name (and potential overlapping names) is irrelevant,falseif relevant
-
logEntryName
Logs a JAR entry name.- Parameters:
name- the entry name
-
setVerbose
public static void setVerbose(boolean verb) Sets the verbose flag.- Parameters:
verb- the verbose flag
-