cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r321157 - in /cocoon/trunk/src/java/org/apache/cocoon: components/thread/ core/
Date Fri, 14 Oct 2005 17:21:44 GMT
Author: cziegeler
Date: Fri Oct 14 10:21:29 2005
New Revision: 321157

URL: http://svn.apache.org/viewcvs?rev=321157&view=rev
Log:
Clean up property reading
Code formatting

Modified:
    cocoon/trunk/src/java/org/apache/cocoon/components/thread/BoundedQueue.java
    cocoon/trunk/src/java/org/apache/cocoon/components/thread/ChannelWrapper.java
    cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java
    cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultThreadFactory.java
    cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultThreadPool.java
    cocoon/trunk/src/java/org/apache/cocoon/components/thread/LinkedQueue.java
    cocoon/trunk/src/java/org/apache/cocoon/components/thread/Queue.java
    cocoon/trunk/src/java/org/apache/cocoon/components/thread/RunnableManager.java
    cocoon/trunk/src/java/org/apache/cocoon/components/thread/SynchronousChannel.java
    cocoon/trunk/src/java/org/apache/cocoon/components/thread/ThreadFactory.java
    cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/thread/BoundedQueue.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/thread/BoundedQueue.java?rev=321157&r1=321156&r2=321157&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/thread/BoundedQueue.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/thread/BoundedQueue.java Fri Oct 14
10:21:29 2005
@@ -29,16 +29,15 @@
  */
 public class BoundedQueue
     extends EDU.oswego.cs.dl.util.concurrent.BoundedBuffer
-    implements Queue
-{
+    implements Queue {
+
     //~ Constructors -----------------------------------------------------------
 
     /**
-     * Create a buffer with the current default capacity
+     * Create a buffer with the current default capacity.
      */
-    public BoundedQueue(  )
-    {
-        super(  );
+    public BoundedQueue() {
+        super();
     }
 
     /**
@@ -49,8 +48,7 @@
      * @exception IllegalArgumentException if capacity less or equal to zero
      */
     public BoundedQueue( int capacity )
-        throws IllegalArgumentException
-    {
+    throws IllegalArgumentException {
         super( capacity );
     }
 
@@ -61,8 +59,7 @@
      *
      * @return current size of queue.
      */
-    public int getQueueSize(  )
-    {
+    public int getQueueSize() {
         return usedSlots_;
     }
 }

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/thread/ChannelWrapper.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/thread/ChannelWrapper.java?rev=321157&r1=321156&r2=321157&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/thread/ChannelWrapper.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/thread/ChannelWrapper.java Fri Oct
14 10:21:29 2005
@@ -17,7 +17,6 @@
 
 import EDU.oswego.cs.dl.util.concurrent.Channel;
 
-
 /**
  * Wrapper around a Channel implementation for constructor convenience
  *
@@ -25,12 +24,12 @@
  * @version $Id$
  */
 public class ChannelWrapper
-    implements Channel
-{
+    implements Channel {
+
     //~ Instance fields --------------------------------------------------------
 
     /** The wrapped Channel */
-    private Channel m_channel;
+    private Channel channel;
 
     //~ Methods ----------------------------------------------------------------
 
@@ -39,9 +38,8 @@
      *
      * @param channel DOCUMENT ME!
      */
-    public void setChannel( final Channel channel )
-    {
-        m_channel = channel;
+    public void setChannel( final Channel channel ) {
+        this.channel = channel;
     }
 
     /**
@@ -50,43 +48,37 @@
      */
     public boolean offer( final Object obj,
                           final long timeout )
-        throws InterruptedException
-    {
-        return m_channel.offer( obj, timeout );
+    throws InterruptedException {
+        return channel.offer( obj, timeout );
     }
 
     /**
      * @see EDU.oswego.cs.dl.util.concurrent.Channel#peek()
      */
-    public Object peek(  )
-    {
-        return m_channel.peek(  );
+    public Object peek() {
+        return channel.peek();
     }
 
     /**
      * @see EDU.oswego.cs.dl.util.concurrent.Takable#poll(long)
      */
     public Object poll( final long timeout )
-        throws InterruptedException
-    {
-        return m_channel.poll( timeout );
+    throws InterruptedException {
+        return channel.poll( timeout );
     }
 
     /**
      * @see EDU.oswego.cs.dl.util.concurrent.Puttable#put(java.lang.Object)
      */
     public void put( final Object obj )
-        throws InterruptedException
-    {
-        m_channel.put( obj );
+    throws InterruptedException {
+        channel.put( obj );
     }
 
     /**
      * @see EDU.oswego.cs.dl.util.concurrent.Takable#take()
      */
-    public Object take(  )
-        throws InterruptedException
-    {
-        return m_channel.take(  );
+    public Object take()  throws InterruptedException {
+        return channel.take();
     }
 }

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java?rev=321157&r1=321156&r2=321157&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java
(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java
Fri Oct 14 10:21:29 2005
@@ -79,7 +79,7 @@
 
     /** The default {@link ThreadFactory} */
     public static final String DEFAULT_THREAD_FACTORY =
-        DefaultThreadFactory.class.getName(  );
+        DefaultThreadFactory.class.getName();
 
     /** The default queue size */
     public static final int DEFAULT_QUEUE_SIZE = -1;

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultThreadFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultThreadFactory.java?rev=321157&r1=321156&r2=321157&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultThreadFactory.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultThreadFactory.java Fri
Oct 14 10:21:29 2005
@@ -22,8 +22,7 @@
  * @version $Id$
  */
 public class DefaultThreadFactory
-    implements ThreadFactory, EDU.oswego.cs.dl.util.concurrent.ThreadFactory
-{
+    implements ThreadFactory, EDU.oswego.cs.dl.util.concurrent.ThreadFactory {
     //~ Instance fields --------------------------------------------------------
 
     /** The daemon mode */
@@ -40,8 +39,7 @@
      * @param isDaemon Whether or not new <code>Thread</code> should run as
      *        daemons.
      */
-    public void setDaemon( boolean isDaemon )
-    {
+    public void setDaemon( boolean isDaemon ) {
         m_isDaemon = isDaemon;
     }
 
@@ -50,8 +48,7 @@
      *
      * @return Whether or not new <code>Thread</code> will run as daemons.
      */
-    public boolean isDaemon(  )
-    {
+    public boolean isDaemon() {
         return m_isDaemon;
     }
 
@@ -61,12 +58,10 @@
      * @param priority One of {@link Thread#MIN_PRIORITY}, {@link
      *        Thread#NORM_PRIORITY}, {@link Thread#MAX_PRIORITY}
      */
-    public void setPriority( final int priority )
-    {
+    public void setPriority( final int priority ) {
         if( ( Thread.MAX_PRIORITY == priority ) ||
             ( Thread.MIN_PRIORITY == priority ) ||
-            ( Thread.NORM_PRIORITY == priority ) )
-        {
+            ( Thread.NORM_PRIORITY == priority ) ) {
             m_priority = priority;
         }
     }
@@ -77,8 +72,7 @@
      * @return One of {@link Thread#MIN_PRIORITY}, {@link
      *         Thread#NORM_PRIORITY}, {@link Thread#MAX_PRIORITY}
      */
-    public int getPriority(  )
-    {
+    public int getPriority() {
         return m_priority;
     }
 
@@ -89,8 +83,7 @@
      *
      * @return A new Thread instance
      */
-    public Thread newThread( final Runnable command )
-    {
+    public Thread newThread( final Runnable command ) {
         final Thread thread = new Thread( command );
         thread.setPriority( m_priority );
         thread.setDaemon( m_isDaemon );

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultThreadPool.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultThreadPool.java?rev=321157&r1=321156&r2=321157&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultThreadPool.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/thread/DefaultThreadPool.java Fri Oct
14 10:21:29 2005
@@ -31,8 +31,8 @@
  */
 public class DefaultThreadPool
     extends PooledExecutor
-    implements ThreadPool, LogEnabled
-{
+    implements ThreadPool, LogEnabled {
+
     //~ Static fields/initializers ---------------------------------------------
 
     /** Default ThreadPool block policy */
@@ -69,9 +69,8 @@
     /**
      * Create a new pool.
      */
-    DefaultThreadPool(  )
-    {
-        this( new ChannelWrapper(  ) );
+    DefaultThreadPool() {
+        this( new ChannelWrapper() );
     }
 
     /**
@@ -79,8 +78,7 @@
      *
      * @param channel DOCUMENT ME!
      */
-    private DefaultThreadPool( final ChannelWrapper channel )
-    {
+    private DefaultThreadPool( final ChannelWrapper channel ) {
         super( channel );
         m_channelWrapper = channel;
     }
@@ -92,8 +90,7 @@
      *
      * @return Returns the blockPolicy.
      */
-    public String getBlockPolicy(  )
-    {
+    public String getBlockPolicy() {
         return m_blockPolicy;
     }
 
@@ -104,8 +101,7 @@
      *
      * @see org.apache.cocoon.components.thread.ThreadPool#getQueueSize()
      */
-    public int getMaxQueueSize(  )
-    {
+    public int getMaxQueueSize() {
         return ( ( m_queueSize < 0 ) ? Integer.MAX_VALUE : m_queueSize );
     }
 
@@ -116,16 +112,14 @@
      *
      * @see org.apache.cocoon.components.thread.ThreadPool#getQueueSize()
      */
-    public int getMaximumQueueSize(  )
-    {
+    public int getMaximumQueueSize() {
         return m_queueSize;
     }
 
     /**
      * @see org.apache.cocoon.components.thread.ThreadPool#getName()
      */
-    public String getName(  )
-    {
+    public String getName() {
         return m_name;
     }
 
@@ -135,8 +129,7 @@
      * @return {@link Thread#MIN_PRIORITY}, {@link Thread#NORM_PRIORITY}, or
      *         {@link Thread#MAX_PRIORITY}
      */
-    public int getPriority(  )
-    {
+    public int getPriority() {
         return ((ThreadFactory)super.getThreadFactory()).getPriority();
     }
 
@@ -147,9 +140,8 @@
      *
      * @see org.apache.cocoon.components.thread.ThreadPool#getQueueSize()
      */
-    public int getQueueSize(  )
-    {
-        return m_queue.getQueueSize(  );
+    public int getQueueSize() {
+        return m_queue.getQueueSize();
     }
 
     /**
@@ -159,8 +151,7 @@
      *
      * @see org.apache.cocoon.components.thread.ThreadPool#isQueued()
      */
-    public boolean isQueued(  )
-    {
+    public boolean isQueued() {
         return m_queueSize != 0;
     }
 
@@ -171,8 +162,7 @@
      *
      * @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(org.apache.avalon.framework.logger.Logger)
      */
-    public void enableLogging( Logger logger )
-    {
+    public void enableLogging( Logger logger ) {
         m_logger = logger;
     }
 
@@ -183,13 +173,10 @@
      *
      * @throws InterruptedException In case of interruption
      */
-    public void execute( Runnable command )
-        throws InterruptedException
-    {
-        if( getLogger(  ).isDebugEnabled(  ) )
-        {
-            getLogger(  ).debug( "Executing Command: " + command.toString(  ) +
-                                 ",pool=" + getName(  ) );
+    public void execute( Runnable command ) throws InterruptedException {
+        if( getLogger().isDebugEnabled() ) {
+            getLogger().debug( "Executing Command: " + command.toString() +
+                                 ",pool=" + getName() );
         }
 
         super.execute( command );
@@ -198,36 +185,27 @@
     /**
      * @see org.apache.cocoon.components.thread.ThreadPool#shutdownGraceful()
      */
-    public void shutdown(  )
-    {
-        if( m_shutdownGraceful )
-        {
-            shutdownAfterProcessingCurrentlyQueuedTasks(  );
-        }
-        else
-        {
-            shutdownNow(  );
+    public void shutdown() {
+        if( m_shutdownGraceful ) {
+            shutdownAfterProcessingCurrentlyQueuedTasks();
+        } else {
+            shutdownNow();
         }
 
-        try
-        {
-            if( getShutdownWaitTimeMs(  ) > 0 )
-            {
-                if( ! awaitTerminationAfterShutdown( getShutdownWaitTimeMs(  ) ) )
-                {
-                    getLogger(  ).warn( "running commands have not terminated within " +
-                                        getShutdownWaitTimeMs(  ) +
-                                        "ms. Will shut them down by interruption" );
-                    interruptAll(  );
-                    shutdownNow(  );
+        try {
+            if( getShutdownWaitTimeMs() > 0 ) {
+                if( ! awaitTerminationAfterShutdown( getShutdownWaitTimeMs()) ) {
+                    getLogger().warn( "running commands have not terminated within " +
+                                      getShutdownWaitTimeMs() +
+                                      "ms. Will shut them down by interruption" );
+                    interruptAll();
+                    shutdownNow();
                 }
             }
 
-            awaitTerminationAfterShutdown(  );
-        }
-        catch( final InterruptedException ie )
-        {
-            getLogger(  ).error( "cannot shutdown ThreadPool", ie );
+            awaitTerminationAfterShutdown();
+        } catch( final InterruptedException ie ) {
+            getLogger().error( "cannot shutdown ThreadPool", ie );
         }
     }
 
@@ -236,33 +214,21 @@
      *
      * @param blockPolicy The blocking policy value
      */
-    void setBlockPolicy( final String blockPolicy )
-    {
+    void setBlockPolicy( final String blockPolicy ) {
         m_blockPolicy = blockPolicy;
 
-        if( POLICY_ABORT.equalsIgnoreCase( blockPolicy ) )
-        {
+        if( POLICY_ABORT.equalsIgnoreCase( blockPolicy ) ) {
             abortWhenBlocked(  );
-        }
-        else if( POLICY_DISCARD.equalsIgnoreCase( blockPolicy ) )
-        {
+        } else if( POLICY_DISCARD.equalsIgnoreCase( blockPolicy ) ) {
             discardWhenBlocked(  );
-        }
-        else if( POLICY_DISCARD_OLDEST.equalsIgnoreCase( blockPolicy ) )
-        {
-            discardOldestWhenBlocked(  );
-        }
-        else if( POLICY_RUN.equalsIgnoreCase( blockPolicy ) )
-        {
-            runWhenBlocked(  );
-        }
-        else if( POLICY_WAIT.equalsIgnoreCase( blockPolicy ) )
-        {
-            waitWhenBlocked(  );
-        }
-        else
-        {
-            final StringBuffer msg = new StringBuffer(  );
+        } else if( POLICY_DISCARD_OLDEST.equalsIgnoreCase( blockPolicy ) ) {
+            discardOldestWhenBlocked();
+        } else if( POLICY_RUN.equalsIgnoreCase( blockPolicy ) ) {
+            runWhenBlocked();
+        } else if( POLICY_WAIT.equalsIgnoreCase( blockPolicy ) ) {
+            waitWhenBlocked();
+        } else {
+            final StringBuffer msg = new StringBuffer();
             msg.append( "WARNING: Unknown block-policy configuration \"" )
                .append( blockPolicy );
             msg.append( "\". Should be one of \"" ).append( POLICY_ABORT );
@@ -271,7 +237,7 @@
             msg.append( "\",\"" ).append( POLICY_RUN );
             msg.append( "\",\"" ).append( POLICY_WAIT );
             msg.append( "\". Will use \"" ).append( POLICY_DEFAULT ).append( "\"" );
-            getLogger(  ).warn( msg.toString(  ) );
+            getLogger().warn( msg.toString() );
             setBlockPolicy( POLICY_DEFAULT );
         }
     }
@@ -281,8 +247,7 @@
      *
      * @param name The name to set.
      */
-    void setName( String name )
-    {
+    void setName( String name ) {
         m_name = name;
     }
 
@@ -291,21 +256,14 @@
      *
      * @param queueSize DOCUMENT ME!
      */
-    void setQueue( final int queueSize )
-    {
-        if( queueSize != 0 )
-        {
-            if( queueSize > 0 )
-            {
+    void setQueue( final int queueSize ) {
+        if( queueSize != 0 ) {
+            if( queueSize > 0 ) {
                 m_queue = new BoundedQueue( queueSize );
-            }
-            else
-            {
+            } else {
                 m_queue = new LinkedQueue(  );
             }
-        }
-        else
-        {
+        } else {
             m_queue = new SynchronousChannel(  );
         }
 
@@ -318,8 +276,7 @@
      *
      * @param shutdownGraceful The shutdownGraceful to set.
      */
-    void setShutdownGraceful( boolean shutdownGraceful )
-    {
+    void setShutdownGraceful( boolean shutdownGraceful ) {
         m_shutdownGraceful = shutdownGraceful;
     }
 
@@ -328,8 +285,7 @@
      *
      * @return Returns the shutdownGraceful.
      */
-    boolean isShutdownGraceful(  )
-    {
+    boolean isShutdownGraceful() {
         return m_shutdownGraceful;
     }
 
@@ -338,8 +294,7 @@
      *
      * @param shutdownWaitTimeMs The shutdownWaitTimeMs to set.
      */
-    void setShutdownWaitTimeMs( int shutdownWaitTimeMs )
-    {
+    void setShutdownWaitTimeMs( int shutdownWaitTimeMs ) {
         m_shutdownWaitTimeMs = shutdownWaitTimeMs;
     }
 
@@ -348,8 +303,7 @@
      *
      * @return Returns the shutdownWaitTimeMs.
      */
-    int getShutdownWaitTimeMs(  )
-    {
+    int getShutdownWaitTimeMs() {
         return m_shutdownWaitTimeMs;
     }
 
@@ -358,8 +312,7 @@
      *
      * @return our <code>Logger</code>
      */
-    private Logger getLogger(  )
-    {
+    private Logger getLogger() {
         return m_logger;
     }
 }

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/thread/LinkedQueue.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/thread/LinkedQueue.java?rev=321157&r1=321156&r2=321157&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/thread/LinkedQueue.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/thread/LinkedQueue.java Fri Oct 14
10:21:29 2005
@@ -30,15 +30,14 @@
  */
 public class LinkedQueue
     extends EDU.oswego.cs.dl.util.concurrent.LinkedQueue
-    implements Queue
-{
+    implements Queue {
+
     //~ Methods ----------------------------------------------------------------
 
     /**
      * @see org.apache.cocoon.components.thread.Queue#getQueueSize()
      */
-    public int getQueueSize(  )
-    {
+    public int getQueueSize() {
         return -1;
     }
 }

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/thread/Queue.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/thread/Queue.java?rev=321157&r1=321156&r2=321157&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/thread/Queue.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/thread/Queue.java Fri Oct 14 10:21:29
2005
@@ -24,8 +24,8 @@
  * @see EDU.oswego.cs.dl.util.concurrent.Channel
  */
 public interface Queue
-    extends EDU.oswego.cs.dl.util.concurrent.Channel
-{
+    extends EDU.oswego.cs.dl.util.concurrent.Channel {
+
     //~ Methods ----------------------------------------------------------------
 
     /**
@@ -34,5 +34,5 @@
      * @return current size of queue. If the size of the queue is not
      *         maintained by an implementation -1 should be returned.
      */
-    int getQueueSize(  );
+    int getQueueSize();
 }

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/thread/RunnableManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/thread/RunnableManager.java?rev=321157&r1=321156&r2=321157&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/thread/RunnableManager.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/thread/RunnableManager.java Fri Oct
14 10:21:29 2005
@@ -22,12 +22,12 @@
  * @author <a href="mailto:giacomo.at.apache.org">Giacomo Pati</a>
  * @version CVS $Id$
  */
-public interface RunnableManager
-{
+public interface RunnableManager {
+
     //~ Instance fields --------------------------------------------------------
 
     /** The role name */
-    String ROLE = RunnableManager.class.getName(  );
+    String ROLE = RunnableManager.class.getName();
 
     //~ Methods ----------------------------------------------------------------
 

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/thread/SynchronousChannel.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/thread/SynchronousChannel.java?rev=321157&r1=321156&r2=321157&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/thread/SynchronousChannel.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/thread/SynchronousChannel.java Fri
Oct 14 10:21:29 2005
@@ -42,6 +42,7 @@
 public class SynchronousChannel
     extends EDU.oswego.cs.dl.util.concurrent.SynchronousChannel
     implements Queue {
+
     //~ Methods ----------------------------------------------------------------
 
     /**

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/thread/ThreadFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/thread/ThreadFactory.java?rev=321157&r1=321156&r2=321157&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/thread/ThreadFactory.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/thread/ThreadFactory.java Fri Oct 14
10:21:29 2005
@@ -24,6 +24,7 @@
  */
 public interface ThreadFactory
     extends EDU.oswego.cs.dl.util.concurrent.ThreadFactory {
+
     //~ Methods ----------------------------------------------------------------
 
     /**

Modified: cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java?rev=321157&r1=321156&r2=321157&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java Fri Oct 14 10:21:29 2005
@@ -333,16 +333,16 @@
      * This method reads several property files and merges the result. If there
      * is more than one definition for a property, the last one wins.
      * The property files are read in the following order:
-     * 1) context://WEB-INF/cocoon-settings.properties
-     *    These are the default values.
-     * 2) context://WEB-INF/properties/*.properties
-     *    Default values for each block - the order in which the files are read is not guaranteed.
-     * 3) context://WEB-INF/properties/[RUNNING_MODE]/*.properties
+     * 1) context://WEB-INF/properties/*.properties
+     *    Default values for the core and each block - the order in which the files are read
is not guaranteed.
+     * 2) context://WEB-INF/properties/[RUNNING_MODE]/*.properties
      *    Default values for the running mode - the order in which the files are read is
not guaranteed.
-     * 4) Property providers (ToBeDocumented)
-     * 5) The environment (CLI, Servlet etc.) adds own properties (e.g. from web.xml)
-     * 6) Additional property file specified by the "org.apache.cocoon.settings" system property.
-     * 7) System properties
+     * 3) Property providers (ToBeDocumented)
+     * 4) The environment (CLI, Servlet etc.) adds own properties (e.g. from web.xml)
+     * 5) Additional property file specified by the "org.apache.cocoon.settings" system property
or
+     *    if the property is not found, the file ".cocoon/settings.properties" is tried to
be read from
+     *    the user directory.
+     * 6) System properties
      *
      * @return A new Settings object
      */
@@ -357,25 +357,6 @@
         // we need our own resolver
         final SourceResolver resolver = this.createSourceResolver(new LoggerWrapper(this.env));
 
-        // read cocoon-settings.properties - if available
-        Source source = null;
-        try {
-            source = resolver.resolveURI("context://WEB-INF/cocoon-settings.properties");
-            if ( source.exists() ) {
-                final InputStream propsIS = source.getInputStream();
-                this.env.log("Reading settings from '" + source.getURI() + "'");
-                final Properties p = new Properties();
-                p.load(propsIS);
-                propsIS.close();
-                s.fill(p);
-            }
-        } catch (IOException ignore) {
-            env.log("Unable to read 'WEB-INF/cocoon-settings.properties'.", ignore);
-            env.log("Continuing initialization.");            
-        } finally {
-            resolver.release(source);
-        }
-
         // now read all properties from the properties directory
         this.readProperties("context://WEB-INF/properties", s, resolver);
         // read all properties from the mode dependent directory
@@ -397,8 +378,16 @@
         env.configure(s);
 
         // read additional properties file
-        final String additionalPropertyFile = s.getProperty(Settings.PROPERTY_USER_SETTINGS,

-                                                            System.getProperty(Settings.PROPERTY_USER_SETTINGS));
+        String additionalPropertyFile = s.getProperty(Settings.PROPERTY_USER_SETTINGS, 
+                                                      System.getProperty(Settings.PROPERTY_USER_SETTINGS));
+        // if there is no property defining the addition file, we try it in the home directory
+        if ( additionalPropertyFile == null ) {
+            additionalPropertyFile = System.getProperty("user.home") + File.separator + ".cocoon/settings.properties";
+            final File testFile = new File(additionalPropertyFile);
+            if ( !testFile.exists() ) {
+                additionalPropertyFile = null;
+            }
+        }
         if ( additionalPropertyFile != null ) {
             env.log("Reading user settings from '" + additionalPropertyFile + "'");
             final Properties p = new Properties();



Mime
View raw message