Class FolderClasspathPluginSetupDescriptor
java.lang.Object
de.iip_ecosphere.platform.support.plugins.URLPluginSetupDescriptor
de.iip_ecosphere.platform.support.plugins.FolderClasspathPluginSetupDescriptor
- All Implemented Interfaces:
PluginSetupDescriptor
Default plugin setup descriptor based based on loading from a project folder containing jars and the
classpath in "classpath", in "target/jars/classpath", or in "target/classes/classpath".
- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a classpath file and selected descriptive entries. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates an instance based on project folder containing jars and the classpath in "target/classes/classpath".FolderClasspathPluginSetupDescriptor(File folder, boolean descriptorOnly, File... appends) Creates an instance based on project folder containing jars and the classpath in "target/classes/classpath". -
Method Summary
Modifier and TypeMethodDescriptionstatic FileadjustBase(File folder) Adjusts the base directory.protected ClassLoadercreateClassLoader(URL[] urls, ClassLoader parent) Actually creates the classloader.static FilefindClasspathFile(File folder, String suffix) Finds the classpath file.Returns the installation directory.private static LoggerReturns the logger for this class.getPluginDescriptors(ClassLoader loader) Returns the plugin descriptors represented by this setup descriptor.static Stream<PluginDescriptor> getPluginDescriptors(URL[] urls, ClassLoader loader) Returns the plugin descriptors represented by this setup descriptor.static URL[]loadClasspathFileSafe(File cpFile, boolean descriptorOnly) Loads a classpath file relative to the actual jars and returns the specified classpath entries as URLs.private static URL[]loadClasspathFileSafe(File cpFile, File base, boolean descriptorOnly, File... appends) Loads a classpath file relative to the actual jars and returns the specified classpath entries as URLs.static URL[]loadClasspathSafe(File folder, boolean descriptorOnly, File... appends) Loads a resource in classpath format and returns the specified classpath entries as URLs.private static voidloadDescriptors(URL url, ClassLoader loader, List<PluginDescriptor> result) Loads the plugin descriptors fromurl.readClasspathFile(InputStream in, File base) Reads and parses a given classpath file.private static final StringstripExtension(String name) Strip the extension of a file name.Methods inherited from class de.iip_ecosphere.platform.support.plugins.URLPluginSetupDescriptor
createClassLoader, getURLs, toURL, toURL, toURLSafe, toURLSafeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.iip_ecosphere.platform.support.plugins.PluginSetupDescriptor
preventDuplicates
-
Field Details
-
KEY_SETUP_DESCRIPTOR
- See Also:
-
KEY_PLUGIN_IDS
- See Also:
-
installDir
-
descriptorOnly
private boolean descriptorOnly
-
-
Constructor Details
-
FolderClasspathPluginSetupDescriptor
Creates an instance based on project folder containing jars and the classpath in "target/classes/classpath".- Parameters:
folder- the basis folder
-
FolderClasspathPluginSetupDescriptor
Creates an instance based on project folder containing jars and the classpath in "target/classes/classpath".- Parameters:
folder- the basis folderdescriptorOnly- load the descriptor JARs only or the full thingappends- further classpath files that shall be appended, e.g., logging, may be null
-
-
Method Details
-
getInstallDir
Description copied from interface:PluginSetupDescriptorReturns the installation directory.- Returns:
- the installation directory, may be null
-
findClasspathFile
Finds the classpath file.- Parameters:
folder- the folder to start searchingsuffix- optional suffix, e.g., "-win", may be empty or null for none- Returns:
- the classpath file
-
adjustBase
Adjusts the base directory.- Parameters:
folder- the folder to be used as base directory- Returns:
- the adjusted base directory
-
loadClasspathSafe
Loads a resource in classpath format and returns the specified classpath entries as URLs. Logs errors and exceptions.- Parameters:
folder- the basis folderdescriptorOnly- only the first/two entries, the full thing elseappends- further classpath files that shall be appended, e.g., logging, may be null- Returns:
- the URLs, may be empty
- See Also:
-
loadClasspathFileSafe
Loads a classpath file relative to the actual jars and returns the specified classpath entries as URLs. Logs errors and exceptions.- Parameters:
cpFile- the classpath filedescriptorOnly- only the first/two entries, the full thing else- Returns:
- the URLs, may be empty
-
loadClasspathFileSafe
private static URL[] loadClasspathFileSafe(File cpFile, File base, boolean descriptorOnly, File... appends) Loads a classpath file relative to the actual jars and returns the specified classpath entries as URLs. Logs errors and exceptions.- Parameters:
cpFile- the classpath filebase- the base folder use to make relative classpath entries absolutedescriptorOnly- only the first/two entries, the full thing elseappends- further classpath files that shall be appended, e.g., logging, may be null- Returns:
- the URLs, may be empty
-
readClasspathFile
public static FolderClasspathPluginSetupDescriptor.ClasspathFile readClasspathFile(InputStream in, File base) throws IOException Reads and parses a given classpath file.- Parameters:
in- the input streambase- the base folder use to make relative classpath entries absolute- Returns:
- the classpath file description object
- Throws:
IOException- if accessing the classpath file fails
-
stripExtension
Strip the extension of a file name.- Parameters:
name- the name- Returns:
- the stripped name
-
createClassLoader
Description copied from class:URLPluginSetupDescriptorActually creates the classloader.- Overrides:
createClassLoaderin classURLPluginSetupDescriptor- Parameters:
urls- the URLs to create the classloader fromparent- the parent class loader- Returns:
- the created classloader
-
getPluginDescriptors
Description copied from interface:PluginSetupDescriptorReturns the plugin descriptors represented by this setup descriptor.- Parameters:
loader- the class loader to use, preferably the result ofPluginSetupDescriptor.createClassLoader(ClassLoader)- Returns:
- the plugin descriptors
-
getPluginDescriptors
Returns the plugin descriptors represented by this setup descriptor. We just look into the first (main) or second (optional test) jar to speed up and focus the search for descriptors.- Parameters:
urls- the classpath URLsloader- the class loader to use, preferably the result ofURLPluginSetupDescriptor.createClassLoader(ClassLoader)- Returns:
- the plugin descriptors
- See Also:
-
loadDescriptors
Loads the plugin descriptors fromurl.- Parameters:
url- the URL to load the descriptors fromloader- the class loader to use, preferably the result ofURLPluginSetupDescriptor.createClassLoader(ClassLoader)result- modified with added plugin descriptor instances as side effect
-
getLogger
Returns the logger for this class.- Returns:
- the logger
-