Author: gtrasuk
Date: Fri Mar 30 14:29:21 2012
New Revision: 1307444

URL: http://svn.apache.org/viewvc?rev=1307444&view=rev
Log:
Fixed a dumb classpath error (core-config.xml did not reference the JSK jars).  
Classloading now appears to be setup correctly to allow security manager to 
load.  Next step, add the security component, then the application module will 
be able to use RMI.

Modified:
    
river/jtsk/skunk/surrogate/src/org/apache/river/container/StarterServiceDeployer.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/Utils.java
    
river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathEntry.java
    
river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathFilter.java
    
river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/VirtualFileSystemClassLoader.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/core-config.xml

Modified: 
river/jtsk/skunk/surrogate/src/org/apache/river/container/StarterServiceDeployer.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/StarterServiceDeployer.java?rev=1307444&r1=1307443&r2=1307444&view=diff
==============================================================================
--- 
river/jtsk/skunk/surrogate/src/org/apache/river/container/StarterServiceDeployer.java
 (original)
+++ 
river/jtsk/skunk/surrogate/src/org/apache/river/container/StarterServiceDeployer.java
 Fri Mar 30 14:29:21 2012
@@ -209,7 +209,9 @@ public class StarterServiceDeployer {
                 workingDir = new File(serviceRoot.getURL().toURI());
 
             }
-            invokeStatic(cl, VirtualFileSystemConfiguration.class.getName(),
+            Utils.logClassLoaderHierarchy(log, Level.FINE, this.getClass());
+            String configName=VirtualFileSystemConfiguration.class.getName();
+            invokeStatic(cl, configName,
                     Strings.SET_WORKING_DIRECTORY,
                     workingDir);
         } catch (Exception ex) {

Modified: river/jtsk/skunk/surrogate/src/org/apache/river/container/Utils.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/Utils.java?rev=1307444&r1=1307443&r2=1307444&view=diff
==============================================================================
--- river/jtsk/skunk/surrogate/src/org/apache/river/container/Utils.java 
(original)
+++ river/jtsk/skunk/surrogate/src/org/apache/river/container/Utils.java Fri 
Mar 30 14:29:21 2012
@@ -29,10 +29,11 @@ import org.apache.commons.vfs.FileSystem
 import org.apache.commons.vfs.FileType;
 
 /**
- *
- * @author trasukg
+
+ @author trasukg
  */
 public class Utils {
+
     public static String format(Object array[]) {
         if (array == null) {
             return "null";
@@ -58,12 +59,12 @@ public class Utils {
         }
         StringBuffer sb = new StringBuffer();
         sb.append("[");
-        for (Map.Entry entry: props.entrySet()) {
-            boolean first=true;
+        for (Map.Entry entry : props.entrySet()) {
+            boolean first = true;
             if (!first) {
                 sb.append(", ");
             } else {
-                first=false;
+                first = false;
             }
             sb.append(entry.getKey() + "=\"");
             sb.append(entry.getValue());
@@ -73,36 +74,55 @@ public class Utils {
 
         return sb.toString();
     }
+
     public static String[] splitOnWhitespace(String input) {
-        List<String> strings=new ArrayList<String>();
-        StringTokenizer tok=new StringTokenizer(Strings.WHITESPACE_SEPARATORS);
+        List<String> strings = new ArrayList<String>();
+        StringTokenizer tok = new 
StringTokenizer(Strings.WHITESPACE_SEPARATORS);
         while (tok.hasMoreTokens()) {
             strings.add(tok.nextToken());
         }
         return (String[]) strings.toArray(new String[0]);
     }
-    
+
     public static List<FileObject> findChildrenWithSuffix(FileObject dir, 
String suffix) throws FileSystemException {
-        
-        List<FileObject> ret=new ArrayList<FileObject>();
-        
-        for(FileObject fo: dir.getChildren()) {
-            if (fo.getType()==FileType.FILE && 
fo.getName().getBaseName().endsWith(suffix)) {
+
+        List<FileObject> ret = new ArrayList<FileObject>();
+
+        for (FileObject fo : dir.getChildren()) {
+            if (fo.getType() == FileType.FILE && 
fo.getName().getBaseName().endsWith(suffix)) {
                 ret.add(fo);
             }
         }
         return ret;
     }
-    
+
     public static void logClassLoaderHierarchy(Logger log,
             Class cls) {
-        log.log(Level.FINE, MessageNames.CLASSLOADER_IS,
-                new Object[] { cls.getName(), cls.getClassLoader() });
-        ClassLoader parent=cls.getClassLoader().getParent();
-        while (parent!= null) {
-            log.log(Level.FINE, MessageNames.PARENT_CLASS_LOADER_IS,
-                    new Object[] { parent } );
-            parent=parent.getParent();
+        logClassLoaderHierarchy(log, Level.FINE, cls);
+    }
+
+    public static void logClassLoaderHierarchy(Logger log, Level level,
+            Class cls) {
+        log.log(level, MessageNames.CLASSLOADER_IS,
+                new Object[]{cls.getName(), cls.getClassLoader()});
+        ClassLoader parent = cls.getClassLoader().getParent();
+        while (parent != null) {
+            log.log(level, MessageNames.PARENT_CLASS_LOADER_IS,
+                    new Object[]{parent});
+            parent = parent.getParent();
+        }
+    }
+
+    public static void logClassLoaderHierarchy(Logger log,
+            Level level,
+            ClassLoader loader) {
+        log.log(level, MessageNames.CLASSLOADER_IS,
+                new Object[]{null, loader});
+        ClassLoader parent = loader.getParent();
+        while (parent != null) {
+            log.log(level, MessageNames.PARENT_CLASS_LOADER_IS,
+                    new Object[]{parent});
+            parent = parent.getParent();
         }
     }
 }

Modified: 
river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathEntry.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathEntry.java?rev=1307444&r1=1307443&r2=1307444&view=diff
==============================================================================
--- 
river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathEntry.java
 (original)
+++ 
river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathEntry.java
 Fri Mar 30 14:29:21 2012
@@ -18,8 +18,10 @@
 
 package org.apache.river.container.classloading;
 
+import java.util.logging.Logger;
 import org.apache.commons.vfs.FileObject;
 import org.apache.commons.vfs.FileSystemException;
+import org.apache.river.container.MessageNames;
 
 /**
  * A ClassPathEntry is used by the VirtualFileSystemClassLoader, and is a
@@ -46,4 +48,9 @@ public class ClasspathEntry {
         }
         return null;
     }
+    @Override
+    public String toString() {
+        return fileObject.toString() + classpathFilter.toString();
+    }
+        
 }

Modified: 
river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathFilter.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathFilter.java?rev=1307444&r1=1307443&r2=1307444&view=diff
==============================================================================
--- 
river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathFilter.java
 (original)
+++ 
river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathFilter.java
 Fri Mar 30 14:29:21 2012
@@ -56,4 +56,22 @@ public class ClasspathFilter {
         }
         return false;
     }
+    
+    public String toString() {
+        return "("+acceptorString()+")";
+    }
+    
+    private String acceptorString() {
+        StringBuilder sb=new StringBuilder();
+        boolean first=true;
+        for (Acceptor a: getAcceptors()) {
+            if (!first) {
+                sb.append(", ");
+            } else {
+                first=false;
+            }
+            sb.append(a);     
+        }
+        return sb.toString();
+    }
 }

Modified: 
river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/VirtualFileSystemClassLoader.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/VirtualFileSystemClassLoader.java?rev=1307444&r1=1307443&r2=1307444&view=diff
==============================================================================
--- 
river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/VirtualFileSystemClassLoader.java
 (original)
+++ 
river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/VirtualFileSystemClassLoader.java
 Fri Mar 30 14:29:21 2012
@@ -32,10 +32,11 @@ import org.apache.commons.vfs.FileSystem
 import org.apache.commons.vfs.FileUtil;
 import org.apache.river.container.LocalizedRuntimeException;
 import org.apache.river.container.MessageNames;
+import org.apache.river.container.Utils;
 
 /**
- *
- * @author trasukg
+
+ @author trasukg
  */
 public class VirtualFileSystemClassLoader extends URLClassLoader {
 
@@ -55,9 +56,10 @@ public class VirtualFileSystemClassLoade
     }
 
     /**
-    Add the given classpath to this classloader, based on the default root 
supplied at
-    construction time.
-    @param classPath
+     Add the given classpath to this classloader, based on the default root
+     supplied at construction time.
+
+     @param classPath
      */
     public void addClassPathEntry(String classPath) {
 
@@ -65,25 +67,29 @@ public class VirtualFileSystemClassLoade
     }
 
     /**
-    Add the given classpath to this classloader, based on the given fileRoot.
-    The classpath can contain multiple entries, separated by colons, e.g.
-    'jsk-platform.jar:jsk-lib.jar'.<br>
-    Each entry can either be a jar file or a jar file with a list of classes 
that the
-    jar file can be used to provide.  For instance, 
'surrogate.jar(org.apache.ABC, org.apache.DEF)'.
-    
-    @param fileRoot
-    @param classPath
+     Add the given classpath to this classloader, based on the given fileRoot.
+     The classpath can contain multiple entries, separated by colons, e.g.
+     'jsk-platform.jar:jsk-lib.jar'.<br> Each entry can either be a jar file or
+     a jar file with a list of classes that the jar file can be used to 
provide.
+     For instance, 'surrogate.jar(org.apache.ABC, org.apache.DEF)'.
+
+     @param fileRoot
+     @param classPath
      */
     public void addClassPathEntry(FileObject fileRoot, String classPath) {
 
         try {
-            /* Classpath entry is a jar file with filter expressions that can
-            be understood by ClasspathFilterBuilder. */
-            /* Create a nested file system from it and add it to the file 
objects.
+            /*
+             Classpath entry is a jar file with filter expressions that can be
+             understood by ClasspathFilterBuilder.
+             */
+            /*
+             Create a nested file system from it and add it to the file 
objects.
              */
             List<ClasspathFilter> filters = new 
ClasspathFilterBuilder().parseToFilters(classPath);
             for (ClasspathFilter filter : filters) {
                 FileObject entryObject = 
fileRoot.resolveFile(filter.getJarName());
+                
                 FileObject entryFileSystem =
                         
fileRoot.getFileSystem().getFileSystemManager().createFileSystem(entryObject);
                 classpathEntries.add(new ClasspathEntry(filter, 
entryFileSystem));
@@ -94,10 +100,11 @@ public class VirtualFileSystemClassLoade
     }
 
     /**
-    Find a resource by searching through all the classpath entries that have
-    been set up.
-    @param name
-    @return
+     Find a resource by searching through all the classpath entries that have
+     been set up.
+
+     @param name
+     @return
      */
     @Override
     public URL findResource(String name) {
@@ -125,10 +132,11 @@ public class VirtualFileSystemClassLoade
     }
 
     /**
-    Find the file object for a resource by searching through all the classpath
-    entries that have been set up.
-    @param name
-    @return
+     Find the file object for a resource by searching through all the classpath
+     entries that have been set up.
+
+     @param name
+     @return
      */
     public FileObject findResourceFileObject(String name) {
         for (ClasspathEntry cpEntry : classpathEntries) {
@@ -144,15 +152,15 @@ public class VirtualFileSystemClassLoade
         return null;
     }
 
-   /**
-    Find the all the file objects for a resource by 
-    searching through all the classpath
-    entries that have been set up.
-    @param name
-    @return
+    /**
+     Find the all the file objects for a resource by searching through all the
+     classpath entries that have been set up.
+
+     @param name
+     @return
      */
     public List<FileObject> findResourceFileObjects(String name) {
-        List<FileObject> foList=new ArrayList<FileObject>();
+        List<FileObject> foList = new ArrayList<FileObject>();
         for (ClasspathEntry cpEntry : classpathEntries) {
             try {
                 FileObject fo = cpEntry.resolveFile(name);
@@ -182,11 +190,12 @@ public class VirtualFileSystemClassLoade
     }
 
     /**
-     * Set the codebase URLs to an arbitrary list of URLs.  These URLs form the
-     * codebase annotation for classes loaded through this classloader.
-     * For the sake of general paranoia, sets the codebase to a copy of the
-     * provided array.
-     * @param codebase
+     Set the codebase URLs to an arbitrary list of URLs. These URLs form the
+     codebase annotation for classes loaded through this classloader. For the
+     sake of general paranoia, sets the codebase to a copy of the provided
+     array.
+
+     @param codebase
      */
     public void setCodebase(URL[] codebase) {
         if (codebase == null || codebase.length == 0) {
@@ -200,18 +209,57 @@ public class VirtualFileSystemClassLoade
     }
 
     /**
-     * Get the list of URLs that are used for the codebase annotation.
-     * Note that this list is not the actual classpath (that is in the
-     * superclass).  The codebase URLs are imposed to match whatever the Jini
-     * service wants to expose as its codebase annotation.
-     * @return
+     Get the list of URLs that are used for the codebase annotation. Note that
+     this list is not the actual classpath (that is in the superclass). The
+     codebase URLs are imposed to match whatever the Jini service wants to
+     expose as its codebase annotation.
+
+     @return
      */
     @Override
     public URL[] getURLs() {
         return codebaseURLs;
     }
-    /** Stores the codebase that will be returned as the codebase annotation.
-     *
+    /**
+     Stores the codebase that will be returned as the codebase annotation.
+
      */
     private URL codebaseURLs[] = new URL[0];
+
+    @Override
+    public String toString() {
+        StringBuffer listString = new StringBuffer();
+        listString.append(format(classpathEntries));
+        
+        listString.append(", codebase [");
+        URL[] urlArray = getURLs();
+        for (int i = 0; i < urlArray.length; i++) {
+            listString.append(" ");
+            listString.append(urlArray[i]);
+        }
+        listString.append("]");
+        return listString.toString();
+    }
+    public static String format(List<ClasspathEntry> items) {
+        if (items == null) {
+            return "null";
+        }
+        StringBuffer sb = new StringBuffer();
+        sb.append("[");
+        boolean first=true;
+        for (Object o: items) {
+            if (!first) {
+                sb.append(", ");
+            } else {
+                first=false;
+            }
+            sb.append("'");
+            sb.append(o.toString());
+            sb.append("'");
+        }
+        sb.append("]");
+
+        return sb.toString();
+    }
+
 }

Modified: 
river/jtsk/skunk/surrogate/src/org/apache/river/container/core-config.xml
URL: 
http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/core-config.xml?rev=1307444&r1=1307443&r2=1307444&view=diff
==============================================================================
--- river/jtsk/skunk/surrogate/src/org/apache/river/container/core-config.xml 
(original)
+++ river/jtsk/skunk/surrogate/src/org/apache/river/container/core-config.xml 
Fri Mar 30 14:29:21 2012
@@ -50,6 +50,8 @@
         lib/RiverSurrogate.jar
         lib/commons-logging-1.1.1.jar
         lib/commons-vfs-1.0.jar
+        lib/jsk-platform.jar
+        lib/jsk-resources.jar
     </cfg:classpath>
 
     <!--cfg:component 
class="org.apache.river.container.ShowContextToConsole"/-->


Reply via email to