Author: sgoeschl
Date: Mon Oct 10 03:40:42 2005
New Revision: 312606

URL: http://svn.apache.org/viewcvs?rev=312606&view=rev
Log:
+) Using the FileResourceManager as default for the configuration
+) Fixed a few JavaDoc warnings
+) Restricting the access of context-specific information in 
BaseResourceManagerImpl to protected instead of public
+) In response to the suggestions of the mailing list the implementation 
provides a list of excluded directory names. This list is currently not 
configurable but hard-coded and contains "CVS" and ".svn".

Modified:
    
jakarta/turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/BaseResourceManager.java
    
jakarta/turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/FileResourceManager.java
    
jakarta/turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/ResourceManagerServiceImpl.java
    
jakarta/turbine/fulcrum/trunk/resourcemanager/src/test/TestComponentConfig.xml
    jakarta/turbine/fulcrum/trunk/resourcemanager/xdocs/changes.xml

Modified: 
jakarta/turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/BaseResourceManager.java
URL: 
http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/BaseResourceManager.java?rev=312606&r1=312605&r2=312606&view=diff
==============================================================================
--- 
jakarta/turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/BaseResourceManager.java
 (original)
+++ 
jakarta/turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/BaseResourceManager.java
 Mon Oct 10 03:40:42 2005
@@ -55,6 +55,9 @@
     implements Contextualizable, Serviceable, Configurable,  
        Initializable, Disposable, Reconfigurable, ResourceManager
 {
+    /** the buffer size for copying streams */
+    private static final int BUF_SIZE = 1024;
+    
     /** The context supplied by the avalon framework */
     private Context context;
     
@@ -181,7 +184,7 @@
     /**
      * @return Returns the applicationDir.
      */
-    public File getApplicationDir()
+    protected File getApplicationDir()
     {
         return applicationDir;
     }
@@ -189,7 +192,7 @@
     /**
      * @return Returns the tempDir.
      */
-    public File getTempDir()
+    protected File getTempDir()
     {
         return tempDir;
     }
@@ -326,9 +329,9 @@
        }
     
     /**
-     * Reads the given file and decrypts it if required
-     * @param source the source file
-     * @return the content of the file
+     * Reads the given input stream and decrypts it if required
+     * @param is the input stream to be read
+     * @return the content of the input stream
      */
     protected byte[] read( InputStream is )
        throws IOException
@@ -429,10 +432,11 @@
     }
 
     /**
-     * Write the given file and encrypts it if required
-     * @param target the target file
-     * @parwm content the content to be written
-     * @return
+     * Write the given output stream and encrypts it if required. If the 
+     * encryption mode is "auto" we also encryt it.
+     * 
+     * @param os the output stream to be written
+     * @param content the content to be written
      */
     protected void write( OutputStream os, byte[] content )
        throws IOException
@@ -504,7 +508,7 @@
     private void copy( InputStream is, OutputStream os )
         throws IOException
     {
-        byte[] buf = new byte[1024];
+        byte[] buf = new byte[BUF_SIZE];
         int n = 0;
         int total = 0;
 

Modified: 
jakarta/turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/FileResourceManager.java
URL: 
http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/FileResourceManager.java?rev=312606&r1=312605&r2=312606&view=diff
==============================================================================
--- 
jakarta/turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/FileResourceManager.java
 (original)
+++ 
jakarta/turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/FileResourceManager.java
 Mon Oct 10 03:40:42 2005
@@ -44,7 +44,7 @@
     private String suffix;
     
     /** try to locate a resource automagically? */
-    private boolean useLocator = true;
+    private boolean useLocator;
 
     /** the location where all resources are located */
     private File resourceDir;
@@ -52,8 +52,8 @@
     /** the cached list of all available resources */
     private String[] resourceFileNameList;
     
-    /** the name of the subversion metadata directory */
-    private static final String SVN_DIRNAME = ".svn";
+    /** the directory names we usually want to exclude  */
+    private String[] defaultDirectoryExcludes;
     
     /////////////////////////////////////////////////////////////////////////
     // Avalon Service Lifecycle Implementation
@@ -65,6 +65,9 @@
     public FileResourceManager()
     { 
         super();
+        
+        this.useLocator = true;
+        this.defaultDirectoryExcludes =  new String[] { "CVS", ".svn" };
     }
 
     /**
@@ -152,7 +155,7 @@
     /**
      * @see 
org.apache.fulcrum.resourcemanager.ResourceManager#exists(java.lang.String)
      */
-    public boolean exists(String resourceName)
+    public synchronized boolean exists(String resourceName)
     {
         File resourceFile = this.findResourceFile( resourceName, 
this.resourceFileNameList );
         
@@ -273,7 +276,7 @@
     /**
      * @see 
org.apache.fulcrum.resourcemanager.ResourceManager#read(java.lang.String[], 
java.lang.String)
      */
-    public byte [] read( String[] context, String resourceName )
+    public synchronized byte[] read( String[] context, String resourceName )
         throws IOException
     {
         String resourceFileName = this.createResourceFileName( context, 
resourceName );
@@ -283,7 +286,7 @@
     /**
      * @see 
org.apache.fulcrum.resourcemanager.ResourceManager#locate(java.lang.String[], 
java.lang.String)
      */
-    public String locate( String[] context, String resourceName )
+    public synchronized String locate( String[] context, String resourceName )
     {
         String result = null;
         String resourceDirName = this.getResourceDir().getAbsolutePath();
@@ -308,7 +311,7 @@
     /**
      * @see 
org.apache.fulcrum.resourcemanager.ResourceManager#getResourceURL(java.lang.String[],
 java.lang.String)
      */
-    public URL getResourceURL(String [] context, String resourceName)
+    public synchronized URL getResourceURL(String [] context, String 
resourceName)
     {
         String resourceFileName = this.createResourceFileName( context, 
resourceName );
         File resourceFile = this.findResourceFile( resourceFileName, 
this.resourceFileNameList );
@@ -335,6 +338,27 @@
     /////////////////////////////////////////////////////////////////////////
 
     /**
+     * Check if the given directory name is excluded from the search.
+     * 
+     * @param directory the directory
+     * @return true if the directory name is excluded
+     */
+    private boolean isDirectoryExcluded( File directory )
+    {
+        String directoryName = directory.getName();
+        
+        for( int i=0; i<this.defaultDirectoryExcludes.length; i++ )
+        {
+            if(this.defaultDirectoryExcludes[i].equals(directoryName))
+            {
+                return true;
+            }
+        }
+        
+        return false;
+    }
+    
+    /**
      * Creates a sorted list of resource file names using the user-supplied 
      * suffix.
      */
@@ -460,11 +484,16 @@
 
             for( int i=0; i<list.length; i++ )
             {
-                // skip the subversion directories otherwise we pick up 
unexpected files 
+                // recursive search for all subdirectories 
                 
-                if( list[i].isDirectory() && 
(list[i].getName().equalsIgnoreCase(SVN_DIRNAME) == false) )
+                if( list[i].isDirectory() )
                 {
-                    this.findAllResources( list[i], suffix, result );
+                    // check that the subdirectory is not excluded from the 
seach
+                    
+                    if( !this.isDirectoryExcluded(list[i]) )
+                    {
+                        this.findAllResources( list[i], suffix, result );
+                    }
                 }
                 else
                 {

Modified: 
jakarta/turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/ResourceManagerServiceImpl.java
URL: 
http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/ResourceManagerServiceImpl.java?rev=312606&r1=312605&r2=312606&view=diff
==============================================================================
--- 
jakarta/turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/ResourceManagerServiceImpl.java
 (original)
+++ 
jakarta/turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/ResourceManagerServiceImpl.java
 Mon Oct 10 03:40:42 2005
@@ -59,8 +59,7 @@
     
     /** The list of registered domains */
     private Hashtable domainList;
-        
-    
+            
     /////////////////////////////////////////////////////////////////////////
     // Avalon Service Lifecycle Implementation
     /////////////////////////////////////////////////////////////////////////
@@ -268,7 +267,7 @@
     /**
      * @return Returns the domainList.
      */
-    public Hashtable getDomainList()
+    protected Hashtable getDomainList()
     {
         return domainList;
     }
@@ -282,15 +281,11 @@
         ResourceManager result = null;
         
         String domainName = domainConfiguration.getAttribute("name");
-        String domainType = domainConfiguration.getAttribute("type");
-        
+        String domainType = 
domainConfiguration.getAttribute("type",FileResourceManager.class.getName()); 
+            
         // create an instance dynamically
         
-        this.getLogger().debug( "Creating a resource manager for " 
-            + domainName
-            + "@"
-            + domainType
-            );
+        this.getLogger().debug( "Creating a resource manager for " + 
domainName);
           
         result = this.createResourceManager( domainType, domainName );
         

Modified: 
jakarta/turbine/fulcrum/trunk/resourcemanager/src/test/TestComponentConfig.xml
URL: 
http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/resourcemanager/src/test/TestComponentConfig.xml?rev=312606&r1=312605&r2=312606&view=diff
==============================================================================
--- 
jakarta/turbine/fulcrum/trunk/resourcemanager/src/test/TestComponentConfig.xml 
(original)
+++ 
jakarta/turbine/fulcrum/trunk/resourcemanager/src/test/TestComponentConfig.xml 
Mon Oct 10 03:40:42 2005
@@ -3,23 +3,23 @@
 <componentConfig>
   
   <ResourceManagerService>
-    <domain name="groovy" 
type="org.apache.fulcrum.resourcemanager.impl.FileResourceManager">
+    <domain name="groovy">
       <suffix>groovy</suffix>
       <location>./src/test/resources/scripts</location>
       <useLocator>true</useLocator>
     </domain>
-    <domain name="xslt" 
type="org.apache.fulcrum.resourcemanager.impl.FileResourceManager">
+    <domain name="xslt">
       <suffix>xsl</suffix>
       <location>./src/test/resources/xslt</location>
       <useLocator>true</useLocator>
     </domain>
-    <domain name="test" 
type="org.apache.fulcrum.resourcemanager.impl.FileResourceManager">
+    <domain name="test">
       <suffix>txt</suffix>
       <location>./src/test/resources/test</location>
       <useLocator>false</useLocator>
       <useEncryption>true</useEncryption>
     </domain>    
-    <domain name="crypto" 
type="org.apache.fulcrum.resourcemanager.impl.FileResourceManager">
+    <domain name="crypto">
       <suffix>txt</suffix>
       <location>./src/test/resources/crypto</location>
       <useLocator>false</useLocator>

Modified: jakarta/turbine/fulcrum/trunk/resourcemanager/xdocs/changes.xml
URL: 
http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/resourcemanager/xdocs/changes.xml?rev=312606&r1=312605&r2=312606&view=diff
==============================================================================
--- jakarta/turbine/fulcrum/trunk/resourcemanager/xdocs/changes.xml (original)
+++ jakarta/turbine/fulcrum/trunk/resourcemanager/xdocs/changes.xml Mon Oct 10 
03:40:42 2005
@@ -2,15 +2,30 @@
 <document>
   <properties>
     <title>Fulcrum ResourceManager Service</title>
-    <author email="[EMAIL PROTECTED]">Siegfried Goeschl</author>
+    <author email="[EMAIL PROTECTED]">Siegfried Goeschl</author>
   </properties>
 
   <body>
     <release version="1.0.1-dev" date="in SVN">
+      <action dev="sgoeschl" type="update">
+       Using the FileResourceManager as default for the configuration
+      </action>
+      <action dev="sgoeschl" type="fix">
+       Fixed a few JavaDoc warnings
+      </action>
+      <action dev="sgoeschl" type="fix">
+        Restricting the access of context-specific information in
+        BaseResourceManagerImpl to protected instead of public
+      </action>
+      <action dev="sgoeschl" type="fix">
+        In response to the suggestions of the mailing list the implementation
+        provides a list of excluded directory names. This list is currently not
+        configurable but hard-coded and contains "CVS" and ".svn".
+      </action>
       <action dev="sgoeschl" type="fix">
         Skipping all ".svn" directories otherwise we pick up arbitrary files
       </action>
-    </release>  
+    </release>    
     <release version="1.0.0" date="in CVS">
       <action dev="sgoeschl" type="add">
         Initial version



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to