Class LibExtClassLoaderHelper
- java.lang.Object
-
- org.eclipse.jetty.osgi.boot.internal.webapp.LibExtClassLoaderHelper
-
public class LibExtClassLoaderHelper extends java.lang.Object
LibExtClassLoaderHelperHelper to create a URL class-loader with the jars inside
${jetty.home}/lib/ext
and${jetty.home}/resources
. In an ideal world, every library is an OSGi bundle that does loads nicely. To support standard jars or bundles that cannot be loaded in the current OSGi environment, we support inserting the jars in the usual jetty/lib/ext folders in the proper classpath for the webapps.The drawback is that those jars will not be available in the OSGi classloader.
Alternatives to placing jars in lib/ext:
- Bundle the jars in an osgi bundle. Have the webapp(s) that need these jars depend on that bundle.
- Bundle those jars in an osgi bundle-fragment that targets the jetty-bootstrap bundle
- Use equinox Buddy-Policy: register a buddy of the jetty bootstrapper bundle. (Note: it will work only on equinox)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
LibExtClassLoaderHelper.IFilesInJettyHomeResourcesProcessor
IFilesInJettyHomeResourcesProcessor Interface for callback impls
-
Field Summary
Fields Modifier and Type Field Description static java.util.Set<LibExtClassLoaderHelper.IFilesInJettyHomeResourcesProcessor>
registeredFilesInJettyHomeResourcesProcessors
-
Constructor Summary
Constructors Constructor Description LibExtClassLoaderHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.ClassLoader
createLibEtcClassLoader(java.io.File jettyHome, java.lang.ClassLoader parentClassLoader)
static java.lang.ClassLoader
createLibExtClassLoader(java.util.List<java.io.File> jarsContainerOrJars, java.util.List<java.net.URL> otherJarsOrFolder, java.lang.ClassLoader parentClassLoader)
protected static void
processFilesInResourcesFolder(java.io.File jettyHome, java.util.Map<java.lang.String,java.io.File> childrenFiles)
When we find files typically used for central logging configuration we do what it takes in this method to do what the user expects.
-
-
-
Field Detail
-
registeredFilesInJettyHomeResourcesProcessors
public static final java.util.Set<LibExtClassLoaderHelper.IFilesInJettyHomeResourcesProcessor> registeredFilesInJettyHomeResourcesProcessors
-
-
Method Detail
-
createLibEtcClassLoader
public static java.lang.ClassLoader createLibEtcClassLoader(java.io.File jettyHome, java.lang.ClassLoader parentClassLoader) throws java.net.MalformedURLException
- Parameters:
jettyHome
- the jetty homeparentClassLoader
- the parent classloader- Returns:
- a url classloader with the jars of resources, lib/ext and the jars passed in the other argument. The parent classloader usually is the JettyBootStrapper (an osgi classloader.
- Throws:
java.net.MalformedURLException
- if the jetty home reference is invalid
-
createLibExtClassLoader
public static java.lang.ClassLoader createLibExtClassLoader(java.util.List<java.io.File> jarsContainerOrJars, java.util.List<java.net.URL> otherJarsOrFolder, java.lang.ClassLoader parentClassLoader) throws java.net.MalformedURLException
- Parameters:
jarsContainerOrJars
- the jars via file referencesotherJarsOrFolder
- more jars via url referencesparentClassLoader
- the parent classloader- Returns:
- a url classloader with the jars of resources, lib/ext and the jars passed in the other argument. The parent classloader usually is the JettyBootStrapper (an osgi classloader). If there was no extra jars to insert, then just return the parentClassLoader.
- Throws:
java.net.MalformedURLException
- if there is a bad jar file reference
-
processFilesInResourcesFolder
protected static void processFilesInResourcesFolder(java.io.File jettyHome, java.util.Map<java.lang.String,java.io.File> childrenFiles)
When we find files typically used for central logging configuration we do what it takes in this method to do what the user expects. Without depending too much directly on a particular logging framework.We can afford to do some implementation specific code for a logging framework only in a fragment.
Trying to configure log4j and logback in here.
We recommend that slf4j jars are all placed in the osgi framework. And a single implementation if possible packaged as an osgi bundle is there.
- Parameters:
jettyHome
- the jetty home referencechildrenFiles
- the map of child files
-
-