[CVS jcontainer] Make sure system classloader is included in predefined set

Peter Donald <pdonald-yCVjj/[email protected]> Wed, 31 Mar 2004 22:33:38 -0600
Newsgroups gmane.comp.java.jcontainer.cvs
Message-ID <[email protected]>
<html>
<head>
<style><!--
  body {background-color:#ffffff;}
  .file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
  .pathname {font-family:monospace; float:right;}
  .fileheader {margin-bottom:.5em;}
  .diff {margin:0;}
  .tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
  .tasklist ul {margin-top:0;margin-bottom:0;}
  tr.alt {background-color:#eeeeee}
  #added {background-color:#ddffdd;}
  #addedchars {background-color:#99ff99;font-weight:bolder;}
  tr.alt #added {background-color:#ccf7cc;}
  #removed {background-color:#ffdddd;}
  #removedchars {background-color:#ff9999;font-weight:bolder;}
  tr.alt #removed {background-color:#f7cccc;}
  #info {color:#888888;}
  #context {background-color:#eeeeee;}
  td {padding-left:.3em;padding-right:.3em;}
  tr.head {border-bottom-width:1px;border-bottom-style:solid;}
  tr.head td {padding:0;padding-top:.2em;}
  .task {background-color:#ffff00;}
  .comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
  .error {color:red;}
  hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>jcontainer/loom/engine/src/java/org/jcontainer/loom/components/classloader</tt></b><span id="info"> on MAIN</span></td></tr>
<tr><td><tt><a href="#file1">DefaultClassLoaderManager.java</a></tt></td><td align="right" id="added">+67</td><td align="right" id="removed">-66</td><td nowrap="nowrap" align="center"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/engine/src/java/org/jcontainer/loom/components/classloader/DefaultClassLoaderManager.java?rev=1.16&amp;content-type=text/vnd.viewcvs-markup">1.16</a> <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/engine/src/java/org/jcontainer/loom/components/classloader/DefaultClassLoaderManager.java.diff?r1=1.16&amp;r2=1.17">-&gt;</a> <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/engine/src/java/org/jcontainer/loom/components/classloader/DefaultClassLoaderManager.java?rev=1.17&amp;content-type=text/vnd.viewcvs-markup">1.17</a></td></tr>
</table>
<pre class="comment">
Make sure system classloader is included in predefined set
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/engine">engine</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/engine/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/engine/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/engine/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/engine/src/java/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/engine/src/java/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/engine/src/java/org/jcontainer/loom/components">components</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/engine/src/java/org/jcontainer/loom/
 components/classloader">classloader</a><br /></span>
<div class="fileheader"><big><b>DefaultClassLoaderManager.java</b></big> <small id="info"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/engine/src/java/org/jcontainer/loom/components/classloader/DefaultClassLoaderManager.java?rev=1.16&amp;content-type=text/vnd.viewcvs-markup">1.16</a> <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/engine/src/java/org/jcontainer/loom/components/classloader/DefaultClassLoaderManager.java.diff?r1=1.16&amp;r2=1.17">-&gt;</a> <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/engine/src/java/org/jcontainer/loom/components/classloader/DefaultClassLoaderManager.java?rev=1.17&amp;content-type=text/vnd.viewcvs-markup">1.17</a></small></div>
<pre class="diff"><small id="info">diff -u -r1.16 -r1.17
--- DefaultClassLoaderManager.java	31 Mar 2004 03:39:03 -0000	1.16
+++ DefaultClassLoaderManager.java	1 Apr 2004 04:33:38 -0000	1.17
@@ -92,19 +92,7 @@
</small></pre><pre class="diff" id="context"> import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
</pre><pre class="diff" id="removed">-import org.jcontainer.loom.classman.builder.LoaderBuilder;
-import org.jcontainer.loom.classman.builder.LoaderResolver;
-import org.jcontainer.loom.classman.metadata.ClassLoaderMetaData;
-import org.jcontainer.loom.classman.metadata.ClassLoaderSetMetaData;
-import org.jcontainer.loom.classman.metadata.FileSetMetaData;
-import org.jcontainer.loom.classman.metadata.JoinMetaData;
-import org.jcontainer.loom.classman.reader.ClassLoaderSetReader;
-import org.jcontainer.loom.classman.verifier.ClassLoaderVerifier;
</pre><pre class="diff" id="context"> import org.codehaus.spice.configkit.PropertyExpander;
</pre><pre class="diff" id="removed">-import org.jcontainer.loom.extension.Extension;
-import org.jcontainer.loom.xmlpolicy.builder.PolicyBuilder;
-import org.jcontainer.loom.xmlpolicy.metadata.PolicyMetaData;
-import org.jcontainer.loom.xmlpolicy.reader.PolicyReader;
</pre><pre class="diff" id="context"> import org.jcontainer.dna.AbstractLogEnabled;
 import org.jcontainer.dna.Active;
 import org.jcontainer.dna.Composable;
</pre><pre class="diff"><small id="info">@@ -113,10 +101,22 @@
</small></pre><pre class="diff" id="context"> import org.jcontainer.dna.MissingResourceException;
 import org.jcontainer.dna.ResourceLocator;
 import org.jcontainer.dna.impl.ConfigurationUtil;
</pre><pre class="diff" id="added">+import org.jcontainer.loom.classman.builder.LoaderBuilder;
+import org.jcontainer.loom.classman.builder.LoaderResolver;
+import org.jcontainer.loom.classman.metadata.ClassLoaderMetaData;
+import org.jcontainer.loom.classman.metadata.ClassLoaderSetMetaData;
+import org.jcontainer.loom.classman.metadata.FileSetMetaData;
+import org.jcontainer.loom.classman.metadata.JoinMetaData;
+import org.jcontainer.loom.classman.reader.ClassLoaderSetReader;
+import org.jcontainer.loom.classman.verifier.ClassLoaderVerifier;
</pre><pre class="diff" id="context"> import org.jcontainer.loom.components.extensions.pkgmgr.ExtensionManager;
 import org.jcontainer.loom.components.extensions.pkgmgr.PackageManager;
</pre><pre class="diff" id="added">+import org.jcontainer.loom.extension.Extension;
</pre><pre class="diff" id="context"> import org.jcontainer.loom.interfaces.ClassLoaderManager;
 import org.jcontainer.loom.interfaces.ClassLoaderSet;
</pre><pre class="diff" id="added">+import org.jcontainer.loom.xmlpolicy.builder.PolicyBuilder;
+import org.jcontainer.loom.xmlpolicy.metadata.PolicyMetaData;
+import org.jcontainer.loom.xmlpolicy.reader.PolicyReader;
</pre><pre class="diff" id="context"> import org.w3c.dom.Element;
 
 /**
</pre><pre class="diff"><small id="info">@@ -149,13 +149,19 @@
</small></pre><pre class="diff" id="context">      */
     private PackageManager m_packageManager;
 
</pre><pre class="diff" id="removed">-    /** Parent ClassLoader for all applications aka as the "common" classloader. */
</pre><pre class="diff" id="added">+    /**
+     * Parent ClassLoader for all applications aka as the "common" classloader.
+     */
</pre><pre class="diff" id="context">     private ClassLoader m_commonClassLoader;
 
</pre><pre class="diff" id="removed">-    /** The utility class used to verify {@link ClassLoaderMetaData} objects. */
</pre><pre class="diff" id="added">+    /**
+     * The utility class used to verify {@link ClassLoaderMetaData} objects.
+     */
</pre><pre class="diff" id="context">     private final ClassLoaderVerifier m_verifier = new ClassLoaderVerifier();
 
</pre><pre class="diff" id="removed">-    /** Utility class to build map of {@link ClassLoader} objects. */
</pre><pre class="diff" id="added">+    /**
+     * Utility class to build map of {@link ClassLoader} objects.
+     */
</pre><pre class="diff" id="context">     private final LoaderBuilder m_builder = new LoaderBuilder();
 
     /**
</pre><pre class="diff"><small id="info">@@ -170,10 +176,15 @@
</small></pre><pre class="diff" id="context">      */
     private Map m_predefinedLoaders;
 
</pre><pre class="diff" id="removed">-    /** The contextdata used in interpolation of the policy configuration file. */
</pre><pre class="diff" id="added">+    /**
+     * The contextdata used in interpolation of the policy configuration file.
+     */
</pre><pre class="diff" id="context">     private final Map m_data = new HashMap();
 
</pre><pre class="diff" id="removed">-    /** The property expander that will expand properties in the policy configuraiton file. */
</pre><pre class="diff" id="added">+    /**
+     * The property expander that will expand properties in the policy
+     * configuraiton file.
+     */
</pre><pre class="diff" id="context">     private final PropertyExpander m_expander = new PropertyExpander();
 
     /**
</pre><pre class="diff"><small id="info">@@ -183,11 +194,11 @@
</small></pre><pre class="diff" id="context">     public void compose( final ResourceLocator locator )
         throws MissingResourceException
     {
</pre><pre class="diff" id="removed">-        final ExtensionManager extensionManager =
-            (ExtensionManager)locator.lookup( ExtensionManager.class.getName() );
</pre><pre class="diff" id="added">+        final ExtensionManager extensionManager = (ExtensionManager) locator.lookup(
+            ExtensionManager.class.getName() );
</pre><pre class="diff" id="context">         m_packageManager = new PackageManager( extensionManager );
</pre><pre class="diff" id="removed">-        m_commonClassLoader = (ClassLoader)locator.
-            lookup( ClassLoader.class.getName() + "/common" );
</pre><pre class="diff" id="added">+        m_commonClassLoader = (ClassLoader) locator.lookup(
+            ClassLoader.class.getName() + "/common" );
</pre><pre class="diff" id="context">     }
 
     /**
</pre><pre class="diff"><small id="info">@@ -195,18 +206,17 @@
</small></pre><pre class="diff" id="context">      *
      * @throws Exception if unable to setup map
      */
</pre><pre class="diff" id="removed">-    public void initialize()
-        throws Exception
</pre><pre class="diff" id="added">+    public void initialize() throws Exception
</pre><pre class="diff" id="context">     {
         m_data.putAll( System.getProperties() );
 
         final Map defined = new HashMap();
</pre><pre class="diff" id="removed">-        defined.put( "*system*", m_commonClassLoader );
</pre><pre class="diff" id="added">+        defined.put( "*system*", ClassLoader.getSystemClassLoader() );
+        defined.put( "*common*", m_commonClassLoader );
</pre><pre class="diff" id="context">         m_predefinedLoaders = Collections.unmodifiableMap( defined );
     }
 
</pre><pre class="diff" id="removed">-    public void dispose()
-        throws Exception
</pre><pre class="diff" id="added">+    public void dispose() throws Exception
</pre><pre class="diff" id="context">     {
     }
 
</pre><pre class="diff"><small id="info">@@ -214,8 +224,8 @@
</small></pre><pre class="diff" id="context">      * Create a {@link ClassLoader} for a specific application. See Class
      * Javadoc for description of technique for creating {@link ClassLoader}.
      *
</pre><pre class="diff" id="removed">-     * @param environment the configuration "environment.xml" for the
-     * application
</pre><pre class="diff" id="added">+     * @param environment   the configuration "environment.xml" for the
+     *                      application
</pre><pre class="diff" id="context">      * @param homeDirectory the base directory of application
      * @param workDirectory the work directory of application
      * @return the ClassLoader created
</pre><pre class="diff"><small id="info">@@ -225,32 +235,27 @@
</small></pre><pre class="diff" id="context">         final Configuration environment,
         final Map data,
         final File homeDirectory,
</pre><pre class="diff" id="removed">-        final File workDirectory )
-        throws Exception
</pre><pre class="diff" id="added">+        final File workDirectory ) throws Exception
</pre><pre class="diff" id="context">     {
         //Configure policy
         final Configuration policyConfig = environment.getChild( "policy" );
</pre><pre class="diff" id="removed">-        final Policy policy =
-            configurePolicy( policyConfig,
-                             data,
-                             homeDirectory,
-                             workDirectory );
</pre><pre class="diff" id="added">+        final Policy policy = configurePolicy( policyConfig,
+                                               data,
+                                               homeDirectory,
+                                               workDirectory );
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="removed">-        final ClassLoaderSetMetaData metaData =
-            getLoaderMetaData( environment );
</pre><pre class="diff" id="added">+        final ClassLoaderSetMetaData metaData = getLoaderMetaData( environment );
</pre><pre class="diff" id="context"> 
         m_verifier.verifyClassLoaderSet( metaData );
 
</pre><pre class="diff" id="removed">-        final LoaderResolver resolver =
-            new SarLoaderResolver( m_packageManager, policy,
-                                   homeDirectory, workDirectory );
</pre><pre class="diff" id="added">+        final LoaderResolver resolver = new SarLoaderResolver(
+            m_packageManager, policy, homeDirectory, workDirectory );
</pre><pre class="diff" id="context">         setupLogger( resolver );
</pre><pre class="diff" id="removed">-        final Map map =
-            m_builder.buildClassLoaders( metaData,
-                                         resolver,
-                                         m_predefinedLoaders );
-        final ClassLoader defaultClassLoader =
-            (ClassLoader)map.get( metaData.getDefault() );
</pre><pre class="diff" id="added">+        final Map map = m_builder.buildClassLoaders( metaData,
+                                                     resolver,
+                                                     m_predefinedLoaders );
+        final ClassLoader defaultClassLoader = (ClassLoader) map.get(
+            metaData.getDefault() );
</pre><pre class="diff" id="context">         return new ClassLoaderSet( defaultClassLoader, map );
     }
 
</pre><pre class="diff"><small id="info">@@ -263,8 +268,7 @@
</small></pre><pre class="diff" id="context">      * @return the {@link ClassLoaderMetaData} object
      */
     private ClassLoaderSetMetaData getLoaderMetaData(
</pre><pre class="diff" id="removed">-        final Configuration environment )
-        throws Exception
</pre><pre class="diff" id="added">+        final Configuration environment ) throws Exception
</pre><pre class="diff" id="context">     {
         final boolean loaderDefined = isClassLoaderDefined( environment );
         if( !loaderDefined )
</pre><pre class="diff"><small id="info">@@ -291,30 +295,27 @@
</small></pre><pre class="diff" id="context">     {
         final String[] includes = new String[]{"SAR-INF/lib/*.jar"};
         final String[] excludes = new String[ 0 ];
</pre><pre class="diff" id="removed">-        final FileSetMetaData fileSet =
-            new FileSetMetaData( ".",
-                                 includes,
-                                 excludes );
</pre><pre class="diff" id="added">+        final FileSetMetaData fileSet = new FileSetMetaData( ".",
+                                                             includes,
+                                                             excludes );
</pre><pre class="diff" id="context">         final String name = "default";
         final String parent = "*system*";
         final String[] entrys = new String[]{"SAR-INF/classes/"};
         final Extension[] extensions = new Extension[ 0 ];
         final FileSetMetaData[] filesets = new FileSetMetaData[]{fileSet};
</pre><pre class="diff" id="removed">-        final ClassLoaderMetaData loader =
-            new ClassLoaderMetaData( name,
-                                     parent,
-                                     entrys,
-                                     extensions,
-                                     filesets );
</pre><pre class="diff" id="added">+        final ClassLoaderMetaData loader = new ClassLoaderMetaData( name,
+                                                                    parent,
+                                                                    entrys,
+                                                                    extensions,
+                                                                    filesets );
</pre><pre class="diff" id="context">         final String[] predefined = new String[]{parent};
         final ClassLoaderMetaData[] classLoaders = new ClassLoaderMetaData[]{
             loader};
         final JoinMetaData[] joins = new JoinMetaData[ 0 ];
</pre><pre class="diff" id="removed">-        return
-            new ClassLoaderSetMetaData( name,
-                                        predefined,
-                                        classLoaders,
-                                        joins );
</pre><pre class="diff" id="added">+        return new ClassLoaderSetMetaData( name,
+                                           predefined,
+                                           classLoaders,
+                                           joins );
</pre><pre class="diff" id="context">     }
 
     /**
</pre><pre class="diff"><small id="info">@@ -334,7 +335,7 @@
</small></pre><pre class="diff" id="context">      * Setup policy based on configuration data.
      *
      * @param configuration the configuration data
</pre><pre class="diff" id="removed">-     * @param data the context data used to expand policy file
</pre><pre class="diff" id="added">+     * @param data <span id="addedchars">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>the context data used to expand policy file
</pre><pre class="diff" id="context">      * @param baseDirectory the applications base directory
      * @throws ConfigurationException if an error occurs
      */
</pre><pre class="diff"><small id="info">@@ -344,8 +345,8 @@
</small></pre><pre class="diff" id="context">                                     final File workDirectory )
         throws Exception
     {
</pre><pre class="diff" id="removed">-        final SarPolicyResolver resolver =
-            new SarPolicyResolver( baseDirectory, workDirectory );
</pre><pre class="diff" id="added">+        final SarPolicyResolver resolver = new SarPolicyResolver(
+            baseDirectory, workDirectory );
</pre><pre class="diff" id="context">         setupLogger( resolver );
         final PolicyBuilder builder = new PolicyBuilder();
         final PolicyReader reader = new PolicyReader();
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -&gt; email">CVSspam</a> 0.2.8</small></center>
</body></html>