You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2005/11/06 07:08:24 UTC

svn commit: r331085 - /directory/shared/protocol/trunk/common/src/main/java/org/apache/protocol/common/store/LdifFileLoader.java

Author: akarasulu
Date: Sat Nov  5 22:08:22 2005
New Revision: 331085

URL: http://svn.apache.org/viewcvs?rev=331085&view=rev
Log:
added constructor overload to use a classloader for resolving resources

Modified:
    directory/shared/protocol/trunk/common/src/main/java/org/apache/protocol/common/store/LdifFileLoader.java

Modified: directory/shared/protocol/trunk/common/src/main/java/org/apache/protocol/common/store/LdifFileLoader.java
URL: http://svn.apache.org/viewcvs/directory/shared/protocol/trunk/common/src/main/java/org/apache/protocol/common/store/LdifFileLoader.java?rev=331085&r1=331084&r2=331085&view=diff
==============================================================================
--- directory/shared/protocol/trunk/common/src/main/java/org/apache/protocol/common/store/LdifFileLoader.java (original)
+++ directory/shared/protocol/trunk/common/src/main/java/org/apache/protocol/common/store/LdifFileLoader.java Sat Nov  5 22:08:22 2005
@@ -54,6 +54,8 @@
     protected File ldif;
     /** the filters to use while loading entries into the server */
     protected final List filters;
+    /** the class loader to use if we cannot file the file as a path */
+    protected final ClassLoader loader;
     /** the total count of entries loaded */
     private int count;
 
@@ -70,8 +72,14 @@
 
     public LdifFileLoader( DirContext ctx, File ldif, List filters )
     {
+        this( ctx, ldif, filters, null );
+    }
+
+    public LdifFileLoader( DirContext ctx, File ldif, List filters, ClassLoader loader )
+    {
         this.ctx = ctx;
         this.ldif = ldif;
+        this.loader = loader;
 
         if ( filters == null )
         {
@@ -238,13 +246,18 @@
         }
         else
         {
+            if ( loader != null && ( in = loader.getResourceAsStream( ldif.getName() ) ) != null )
+            {
+                return in;
+            }
+
             // if file not on system see if something is bundled with the jar ...
             in = getClass().getResourceAsStream( ldif.getName() );
             if ( in != null )
             {
                 return in;
             }
-            
+
             in = ClassLoader.getSystemResourceAsStream( ldif.getName() );
             if ( in != null )
             {