Package net.ssehub.easy.dslCore
Class DefaultLib
java.lang.Object
net.ssehub.easy.dslCore.DefaultLib
Collects URLs representing the IVML/VIL/VTL default library. Sequence of registered URLs
is relevant as loading happens along that sequence. Files of default library must be exported
by the containing bundle and shall be registered by the respective bundle. Given URLs are resolved and prepared
using
IResourceInitializer.resolve(URL).- Author:
- Holger Eichelberger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe usual name of the default lib folder.static final intMaximum nesting to search for fallback locations. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAddsurltotarget.static voidAppends all registered URLs.static URLappendDefaultLibURLQuietly(ClassLoader loader, String bundleId, org.osgi.service.component.ComponentContext context, String... parentFolderName) Tries to find the default lib URL based on information provided by the componentcontext.static URLappendDefaultLibURLQuietly(ClassLoader loader, org.osgi.service.component.ComponentContext context, String... parentFolderName) Tries to find the default lib URL based on information provided by the componentcontext.static voidappendQuietly(List<URL> target, URL url) Addsurltotarget.static voidAppends a given URL to the list of default library URLs.static voidappendURLQuietly(URL url) Appends a given URL to the list of default library URLs.static StringcomposePluginPattern(String pluginId) Returns a plugin pattern for searching for the default library.static URLfindDefaultLibURL(ClassLoader loader, int maxNesting, String defaultLibFolderName, String... parentFolderName) Tries to find the default lib URL.static URLfindDefaultLibURL(ClassLoader loader, String... parentFolderName) Tries to find the default lib URL.static URLfindDefaultLibURL(ClassLoader loader, String bundleId, org.osgi.service.component.ComponentContext context, String... parentFolderName) Tries to find the default lib URL based on information provided by the componentcontext(with precedence using the actual installation location of the bundle), but explicit fallback bundle id to be used withcomposePluginPattern(String).static URLfindDefaultLibURL(ClassLoader loader, org.osgi.service.component.ComponentContext context, String... parentFolderName) Tries to find the default lib URL based on information provided by the componentcontext.static FilefindFallbackLibFolder(int maxNesting, String defaultLibFolderName, String... parentFolderName) Tries to Find a fallback in the actual folder or its recursive (for Jenkins) parent folders.private static FilefindFallbackLibFolder(File file, int maxNesting, String folderName, boolean prefix, String defaultLibFolderName) Finds a fallback infileor its recursive (for Jenkins) parent folders.private static net.ssehub.easy.basics.logger.EASyLoggerFactory.EASyLoggerReturns the logger for this class.private static URLPrepares a givenurl.static voidprependURL(URL url) Prepends a given URL to the list of default library URLs.static voidprependURLQuietly(URL url) Appends a given URL to the list of default library URLs.static voidRemoves a given URL.static voidremoveURLQuietly(URL url) Removes a given URL.urls()Returns an iterable to all registered URLs.
-
Field Details
-
DEFAULT_LIB_FOLDER_NAME
The usual name of the default lib folder.- See Also:
-
DEFAULT_MAX_NESTING
public static final int DEFAULT_MAX_NESTINGMaximum nesting to search for fallback locations.- See Also:
-
urls
-
-
Constructor Details
-
DefaultLib
public DefaultLib()
-
-
Method Details
-
appendURL
Appends a given URL to the list of default library URLs.- Parameters:
url- the URL to append (may be null, is ignored then)- Throws:
IOException- in case that resolving the given URL (if not null) fails
-
appendURLQuietly
Appends a given URL to the list of default library URLs. This operation logs occurred exceptions.- Parameters:
url- the URL to append (may be null, is ignored then)
-
prependURL
Prepends a given URL to the list of default library URLs.- Parameters:
url- the URL to prepend (may be null, is ignored then)- Throws:
IOException- in case that resolving the given URL (if not null) fails
-
prependURLQuietly
Appends a given URL to the list of default library URLs. This operation logs occurred exceptions.- Parameters:
url- the URL to append (may be null, is ignored then)
-
removeURL
Removes a given URL.- Parameters:
url- the URL to remove (may be null, is ignored then)- Throws:
IOException- in case that resolving the given URL (if not null) fails
-
removeURLQuietly
Removes a given URL. This operation logs occurred exceptions.- Parameters:
url- the URL to remove (may be null, is ignored then)
-
urls
Returns an iterable to all registered URLs.- Returns:
- the iterable
-
appendAll
Appends all registered URLs.- Parameters:
target- the target collection to be modified as a side effect
-
append
Addsurltotarget. [helper]- Parameters:
target- the target collection to be modified as a side effecturl- the URL to remove (may be null, is ignored then)- Throws:
IOException- in case that resolving the given URL (if not null) fails
-
appendQuietly
Addsurltotarget. This operation logs occurred exceptions. [helper]- Parameters:
target- the target collection to be modified as a side effecturl- the URL to remove (may be null, is ignored then)
-
prepare
Prepares a givenurl.- Parameters:
url- the URL to be prepared (ignored if null)- Returns:
- the prepared URL (may be null)
- Throws:
IOException- in case that resolving the given URL (if not null) fails
-
appendDefaultLibURLQuietly
public static URL appendDefaultLibURLQuietly(ClassLoader loader, String bundleId, org.osgi.service.component.ComponentContext context, String... parentFolderName) Tries to find the default lib URL based on information provided by the componentcontext. This includes the symbolic bundle name (as pattern viacomposePluginPattern(String)or, with precedence, the actual installation location of the bundle. UsesfindDefaultLibURL(ClassLoader, int, String, String...).- Parameters:
loader- the class loader for holding the default libbundleId- the explicit bundle id to search for if we cannot identify the installation location fromcontext(may be null for none)context- the component context (may be null for none)parentFolderName- name(s) of the parent folder, may be a simple folder name, a folder name with path prefix using / or a prefix name ending with * (path possible)- Returns:
- the default lib URL or null
-
appendDefaultLibURLQuietly
public static URL appendDefaultLibURLQuietly(ClassLoader loader, org.osgi.service.component.ComponentContext context, String... parentFolderName) Tries to find the default lib URL based on information provided by the componentcontext. This includes the symbolic bundle name (as pattern viacomposePluginPattern(String)or, with precedence, the actual installation location of the bundle. UsesfindDefaultLibURL(ClassLoader, ComponentContext, String...).- Parameters:
loader- the class loader for holding the default libcontext- the component context (may be null for none)parentFolderName- name(s) of the parent folder, may be a simple folder name, a folder name with path prefix using / or a prefix name ending with * (path possible)- Returns:
- the default lib URL or null
-
findDefaultLibURL
public static URL findDefaultLibURL(ClassLoader loader, org.osgi.service.component.ComponentContext context, String... parentFolderName) throws IOException Tries to find the default lib URL based on information provided by the componentcontext. This includes the symbolic bundle name (as pattern viacomposePluginPattern(String)or, with precedence, the actual installation location of the bundle. UsesfindDefaultLibURL(ClassLoader, ComponentContext, String...).- Parameters:
loader- the class loader for holding the default libcontext- the component context (may be null for none)parentFolderName- name(s) of the parent folder, may be a simple folder name, a folder name with path prefix using / or a prefix name ending with * (path possible)- Returns:
- the default lib URL or null
- Throws:
IOException- in case of I/O problems or problems constructing the result URL
-
findDefaultLibURL
public static URL findDefaultLibURL(ClassLoader loader, String bundleId, org.osgi.service.component.ComponentContext context, String... parentFolderName) throws IOException Tries to find the default lib URL based on information provided by the componentcontext(with precedence using the actual installation location of the bundle), but explicit fallback bundle id to be used withcomposePluginPattern(String). UsesfindDefaultLibURL(ClassLoader, String...).- Parameters:
loader- the class loader for holding the default libbundleId- the explicit bundle id to search for if we cannot identify the installation location fromcontext(may be null for none)context- the component context (may be null for none)parentFolderName- name(s) of the parent folder, may be a simple folder name, a folder name with path prefix using / or a prefix name ending with * (path possible)- Returns:
- the default lib URL or null
- Throws:
IOException- in case of I/O problems or problems constructing the result URL
-
findDefaultLibURL
public static URL findDefaultLibURL(ClassLoader loader, String... parentFolderName) throws IOException Tries to find the default lib URL. The first pass uses the class loader. If this fails, we usefindFallbackLibFolder(int, String, String...), which searches forparentFoldercontainingDEFAULT_LIB_FOLDER_NAMEstarting at the current folder walking up to the root folder. This method limits the path to a nesting level of 3. This complicated approach may be needed in standalone/CI testing.- Parameters:
loader- the class loader for holding the default libparentFolderName- name(s) of the parent folder, may be a simple folder name, a folder name with path prefix using / or a prefix name ending with * (path possible)- Returns:
- the default lib URL or null
- Throws:
IOException- in case of I/O problems or problems constructing the result URL- See Also:
-
findDefaultLibURL
public static URL findDefaultLibURL(ClassLoader loader, int maxNesting, String defaultLibFolderName, String... parentFolderName) throws IOException Tries to find the default lib URL. The first pass uses the class loader. If this fails, we usefindFallbackLibFolder(int, String, String...), which searches forparentFoldercontainingdefaultLibFolderNamestarting at the current folder walking up to the root folder. This complicated approach may be needed in standalon/CI testing.- Parameters:
loader- the class loader for holding the default libmaxNesting- the maximum file path nesting to search for,0is none, negative is unlimiteddefaultLibFolderName- name of the contained default lib folderparentFolderName- name(s) of the parent folder(s), may be full names, paths or prefix search patterns (ending with a star), see e.g.,composePluginPattern(String).- Returns:
- the default lib URL or null
- Throws:
IOException- in case of I/O problems or problems constructing the result URL
-
findFallbackLibFolder
public static File findFallbackLibFolder(int maxNesting, String defaultLibFolderName, String... parentFolderName) Tries to Find a fallback in the actual folder or its recursive (for Jenkins) parent folders.- Parameters:
maxNesting- the maximum file path nesting to search for,0is none, negative is unlimiteddefaultLibFolderName- name of the contained default lib folderparentFolderName- name(s) of the parent folder(s), may be full names, paths or prefix search patterns (ending with a star), see e.g.,composePluginPattern(String).- Returns:
- the fallback folder or null if there is none
-
findFallbackLibFolder
private static File findFallbackLibFolder(File file, int maxNesting, String folderName, boolean prefix, String defaultLibFolderName) Finds a fallback infileor its recursive (for Jenkins) parent folders.- Parameters:
file- the file/folder to searchmaxNesting- the maximum file path nesting to search for,0is none, negative is unlimitedfolderName- the folder name to search for, null to search fordefaultLibFolderName(second pass)prefix- whetherfolderNameshall be considered as a file name prefix or a full file namedefaultLibFolderName- the default lib folder name- Returns:
- the fallback folder or null if the is none
-
composePluginPattern
Returns a plugin pattern for searching for the default library.- Parameters:
pluginId- the plugin id- Returns:
- the plugin pattern
-
getLogger
private static net.ssehub.easy.basics.logger.EASyLoggerFactory.EASyLogger getLogger()Returns the logger for this class.- Returns:
- the logger
-