commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1570993 [12/24] - in /commons/proper/jcs/trunk/src: assembly/ changes/ conf/ java/org/apache/commons/jcs/access/ java/org/apache/commons/jcs/access/exception/ java/org/apache/commons/jcs/admin/ java/org/apache/commons/jcs/auxiliary/ java/o...
Date Sun, 23 Feb 2014 10:37:52 GMT
Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/date/ThreadSafeSimpleDateFormat.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/date/ThreadSafeSimpleDateFormat.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/date/ThreadSafeSimpleDateFormat.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/date/ThreadSafeSimpleDateFormat.java Sun Feb 23 10:37:48 2014
@@ -1,89 +1,108 @@
-package org.apache.commons.jcs.utils.date;
-
-import java.text.DateFormatSymbols;
-import java.text.FieldPosition;
-import java.text.ParsePosition;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-/**
- * Thread Safe version of SimpleDateFormat
- * <p>
- * This class simply synchronizes format and parse for SimpleDateFormat.
- */
-public class ThreadSafeSimpleDateFormat
-    extends SimpleDateFormat
-{
-    /**
-     * Generated Serial Version ID
-     */
-    private static final long serialVersionUID = -6394173605134585999L;
-
-    /**
-     * Empty Constructor
-     */
-    public ThreadSafeSimpleDateFormat()
-    {
-        super();
-    }
-
-    /**
-     * @param pattern the pattern describing the date and time format
-     */
-    public ThreadSafeSimpleDateFormat( String pattern )
-    {
-        super( pattern );
-    }
-
-    /**
-     * @param pattern the pattern describing the date and time format
-     * @param lenient leniency option - if false, strictly valid dates are enforced
-     */
-    public ThreadSafeSimpleDateFormat( String pattern, boolean lenient )
-    {
-        super( pattern );
-        this.setLenient( lenient );
-    }
-
-    /**
-     * @param pattern the pattern describing the date and time format
-     * @param locale the locale whose date format symbols should be used.
-     */
-    public ThreadSafeSimpleDateFormat( String pattern, Locale locale )
-    {
-        super( pattern, locale );
-    }
-
-    /**
-     * @param pattern the pattern describing the date and time format
-     * @param formatSymbols the date format symbols to be used for formatting.
-     */
-    public ThreadSafeSimpleDateFormat( String pattern, DateFormatSymbols formatSymbols )
-    {
-        super( pattern, formatSymbols );
-    }
-
-    /**
-     * @param date date
-     * @param toAppendTo buffer to append to
-     * @param fieldPosition field position
-     * @return a string buffer with more data in it
-     */
-    @Override
-    public synchronized StringBuffer format( Date date, StringBuffer toAppendTo, FieldPosition fieldPosition )
-    {
-        return super.format( date, toAppendTo, fieldPosition );
-    }
-
-    /**
-     * @param source source
-     * @param pos parse position
-     * @return date
-     */
-    @Override
-    public synchronized Date parse( String source, ParsePosition pos )
-    {
-        return super.parse( source, pos );
-    }
-}
+package org.apache.commons.jcs.utils.date;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.text.DateFormatSymbols;
+import java.text.FieldPosition;
+import java.text.ParsePosition;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+/**
+ * Thread Safe version of SimpleDateFormat
+ * <p>
+ * This class simply synchronizes format and parse for SimpleDateFormat.
+ */
+public class ThreadSafeSimpleDateFormat
+    extends SimpleDateFormat
+{
+    /**
+     * Generated Serial Version ID
+     */
+    private static final long serialVersionUID = -6394173605134585999L;
+
+    /**
+     * Empty Constructor
+     */
+    public ThreadSafeSimpleDateFormat()
+    {
+        super();
+    }
+
+    /**
+     * @param pattern the pattern describing the date and time format
+     */
+    public ThreadSafeSimpleDateFormat( String pattern )
+    {
+        super( pattern );
+    }
+
+    /**
+     * @param pattern the pattern describing the date and time format
+     * @param lenient leniency option - if false, strictly valid dates are enforced
+     */
+    public ThreadSafeSimpleDateFormat( String pattern, boolean lenient )
+    {
+        super( pattern );
+        this.setLenient( lenient );
+    }
+
+    /**
+     * @param pattern the pattern describing the date and time format
+     * @param locale the locale whose date format symbols should be used.
+     */
+    public ThreadSafeSimpleDateFormat( String pattern, Locale locale )
+    {
+        super( pattern, locale );
+    }
+
+    /**
+     * @param pattern the pattern describing the date and time format
+     * @param formatSymbols the date format symbols to be used for formatting.
+     */
+    public ThreadSafeSimpleDateFormat( String pattern, DateFormatSymbols formatSymbols )
+    {
+        super( pattern, formatSymbols );
+    }
+
+    /**
+     * @param date date
+     * @param toAppendTo buffer to append to
+     * @param fieldPosition field position
+     * @return a string buffer with more data in it
+     */
+    @Override
+    public synchronized StringBuffer format( Date date, StringBuffer toAppendTo, FieldPosition fieldPosition )
+    {
+        return super.format( date, toAppendTo, fieldPosition );
+    }
+
+    /**
+     * @param source source
+     * @param pos parse position
+     * @return date
+     */
+    @Override
+    public synchronized Date parse( String source, ParsePosition pos )
+    {
+        return super.parse( source, pos );
+    }
+}

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/DiscoveredService.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/DiscoveredService.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/DiscoveredService.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/DiscoveredService.java Sun Feb 23 10:37:48 2014
@@ -1,183 +1,183 @@
-package org.apache.commons.jcs.utils.discovery;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-import java.util.ArrayList;
-
-/**
- * This contains info about a discovered service. These objects are stored in a set in the
- * UDPDiscoveryService.
- * <p>
- * @author Aaron Smuts
- */
-public class DiscoveredService
-    implements Serializable
-{
-    /** For serialization. Don't change. */
-    private static final long serialVersionUID = -7810164772089509751L;
-
-    /** region names */
-    private ArrayList<String> cacheNames;
-
-    /** service address */
-    private String serviceAddress;
-
-    /** service port */
-    private int servicePort;
-
-    /** last time we heard from this service? */
-    private long lastHearFromTime = 0;
-
-    /**
-     * @param cacheNames the cacheNames to set
-     */
-    public void setCacheNames( ArrayList<String> cacheNames )
-    {
-        this.cacheNames = cacheNames;
-    }
-
-    /**
-     * @return the cacheNames
-     */
-    public ArrayList<String> getCacheNames()
-    {
-        return cacheNames;
-    }
-
-    /**
-     * @param serviceAddress The serviceAddress to set.
-     */
-    public void setServiceAddress( String serviceAddress )
-    {
-        this.serviceAddress = serviceAddress;
-    }
-
-    /**
-     * @return Returns the serviceAddress.
-     */
-    public String getServiceAddress()
-    {
-        return serviceAddress;
-    }
-
-    /**
-     * @param servicePort The servicePort to set.
-     */
-    public void setServicePort( int servicePort )
-    {
-        this.servicePort = servicePort;
-    }
-
-    /**
-     * @return Returns the servicePort.
-     */
-    public int getServicePort()
-    {
-        return servicePort;
-    }
-
-    /**
-     * @param lastHearFromTime The lastHearFromTime to set.
-     */
-    public void setLastHearFromTime( long lastHearFromTime )
-    {
-        this.lastHearFromTime = lastHearFromTime;
-    }
-
-    /**
-     * @return Returns the lastHearFromTime.
-     */
-    public long getLastHearFromTime()
-    {
-        return lastHearFromTime;
-    }
-
-    /** @return hashcode based on address/port */
-	@Override
-	public int hashCode()
-	{
-		final int prime = 31;
-		int result = 1;
-		result = prime * result
-				+ ((serviceAddress == null) ? 0 : serviceAddress.hashCode());
-		result = prime * result + servicePort;
-		return result;
-	}
-
-	/**
-     * NOTE - this object is often put into sets, so equals needs to be overridden.
-     * <p>
-     * We can't use cache names as part of the equals unless we manually only use the address and
-     * port in a contains check. So that we can use normal set functionality, I've kept the cache
-     * names out.
-     * <p>
-     * @param otherArg other
-     * @return equality based on the address/port
-     */
-	@Override
-	public boolean equals(Object otherArg)
-	{
-		if (this == otherArg)
-		{
-			return true;
-		}
-		if (otherArg == null)
-		{
-			return false;
-		}
-		if (!(otherArg instanceof DiscoveredService))
-		{
-			return false;
-		}
-		DiscoveredService other = (DiscoveredService) otherArg;
-		if (serviceAddress == null)
-		{
-			if (other.serviceAddress != null)
-			{
-				return false;
-			}
-		} else if (!serviceAddress.equals(other.serviceAddress))
-		{
-			return false;
-		}
-		if (servicePort != other.servicePort)
-		{
-			return false;
-		}
-
-		return true;
-	}
-
-    /**
-     * @return string for debugging purposes.
-     */
-    @Override
-    public String toString()
-    {
-        StringBuffer buf = new StringBuffer();
-        buf.append( "\n DiscoveredService" );
-        buf.append( "\n CacheNames = [" + getCacheNames() + "]" );
-        buf.append( "\n ServiceAddress = [" + getServiceAddress() + "]" );
-        buf.append( "\n ServicePort = [" + getServicePort() + "]" );
-        buf.append( "\n LastHearFromTime = [" + getLastHearFromTime() + "]" );
-        return buf.toString();
-    }
-}
+package org.apache.commons.jcs.utils.discovery;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+/**
+ * This contains info about a discovered service. These objects are stored in a set in the
+ * UDPDiscoveryService.
+ * <p>
+ * @author Aaron Smuts
+ */
+public class DiscoveredService
+    implements Serializable
+{
+    /** For serialization. Don't change. */
+    private static final long serialVersionUID = -7810164772089509751L;
+
+    /** region names */
+    private ArrayList<String> cacheNames;
+
+    /** service address */
+    private String serviceAddress;
+
+    /** service port */
+    private int servicePort;
+
+    /** last time we heard from this service? */
+    private long lastHearFromTime = 0;
+
+    /**
+     * @param cacheNames the cacheNames to set
+     */
+    public void setCacheNames( ArrayList<String> cacheNames )
+    {
+        this.cacheNames = cacheNames;
+    }
+
+    /**
+     * @return the cacheNames
+     */
+    public ArrayList<String> getCacheNames()
+    {
+        return cacheNames;
+    }
+
+    /**
+     * @param serviceAddress The serviceAddress to set.
+     */
+    public void setServiceAddress( String serviceAddress )
+    {
+        this.serviceAddress = serviceAddress;
+    }
+
+    /**
+     * @return Returns the serviceAddress.
+     */
+    public String getServiceAddress()
+    {
+        return serviceAddress;
+    }
+
+    /**
+     * @param servicePort The servicePort to set.
+     */
+    public void setServicePort( int servicePort )
+    {
+        this.servicePort = servicePort;
+    }
+
+    /**
+     * @return Returns the servicePort.
+     */
+    public int getServicePort()
+    {
+        return servicePort;
+    }
+
+    /**
+     * @param lastHearFromTime The lastHearFromTime to set.
+     */
+    public void setLastHearFromTime( long lastHearFromTime )
+    {
+        this.lastHearFromTime = lastHearFromTime;
+    }
+
+    /**
+     * @return Returns the lastHearFromTime.
+     */
+    public long getLastHearFromTime()
+    {
+        return lastHearFromTime;
+    }
+
+    /** @return hashcode based on address/port */
+	@Override
+	public int hashCode()
+	{
+		final int prime = 31;
+		int result = 1;
+		result = prime * result
+				+ ((serviceAddress == null) ? 0 : serviceAddress.hashCode());
+		result = prime * result + servicePort;
+		return result;
+	}
+
+	/**
+     * NOTE - this object is often put into sets, so equals needs to be overridden.
+     * <p>
+     * We can't use cache names as part of the equals unless we manually only use the address and
+     * port in a contains check. So that we can use normal set functionality, I've kept the cache
+     * names out.
+     * <p>
+     * @param otherArg other
+     * @return equality based on the address/port
+     */
+	@Override
+	public boolean equals(Object otherArg)
+	{
+		if (this == otherArg)
+		{
+			return true;
+		}
+		if (otherArg == null)
+		{
+			return false;
+		}
+		if (!(otherArg instanceof DiscoveredService))
+		{
+			return false;
+		}
+		DiscoveredService other = (DiscoveredService) otherArg;
+		if (serviceAddress == null)
+		{
+			if (other.serviceAddress != null)
+			{
+				return false;
+			}
+		} else if (!serviceAddress.equals(other.serviceAddress))
+		{
+			return false;
+		}
+		if (servicePort != other.servicePort)
+		{
+			return false;
+		}
+
+		return true;
+	}
+
+    /**
+     * @return string for debugging purposes.
+     */
+    @Override
+    public String toString()
+    {
+        StringBuffer buf = new StringBuffer();
+        buf.append( "\n DiscoveredService" );
+        buf.append( "\n CacheNames = [" + getCacheNames() + "]" );
+        buf.append( "\n ServiceAddress = [" + getServiceAddress() + "]" );
+        buf.append( "\n ServicePort = [" + getServicePort() + "]" );
+        buf.append( "\n LastHearFromTime = [" + getLastHearFromTime() + "]" );
+        return buf.toString();
+    }
+}

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/UDPCleanupRunner.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/UDPCleanupRunner.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/UDPCleanupRunner.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/UDPCleanupRunner.java Sun Feb 23 10:37:48 2014
@@ -1,96 +1,96 @@
-package org.apache.commons.jcs.utils.discovery;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * This class periodically check the lastHeardFrom time on the services.
- * <p>
- * If they exceed the configurable limit, it removes them from the set.
- * <p>
- * @author Aaron Smuts
- */
-public class UDPCleanupRunner
-    implements Runnable
-{
-    /** log instance */
-    private static final Log log = LogFactory.getLog( UDPCleanupRunner.class );
-
-    /** UDP discovery service */
-    private final UDPDiscoveryService discoveryService;
-
-    /** default for max idle time, in seconds */
-    private static final long DEFAULT_MAX_IDLE_TIME_SECONDS = 180;
-
-    /** The configured max idle time, in seconds */
-    private final long maxIdleTimeSeconds = DEFAULT_MAX_IDLE_TIME_SECONDS;
-
-    /**
-     * @param service UDPDiscoveryService
-     */
-    public UDPCleanupRunner( UDPDiscoveryService service )
-    {
-        this.discoveryService = service;
-    }
-
-    /**
-     * This goes through the list of services and removes those that we haven't heard from in longer
-     * than the max idle time.
-     * <p>
-     * @see java.lang.Runnable#run()
-     */
-    public void run()
-    {
-        long now = System.currentTimeMillis();
-
-        // iterate through the set
-        // it is thread safe
-        // http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/CopyOnWriteArraySet.
-        // html
-        // TODO this should get a copy.  you can't simply remove from this.
-        // the listeners need to be notified.
-        Set<DiscoveredService> toRemove = new HashSet<DiscoveredService>();
-        // can't remove via the iterator. must remove directly
-        for (DiscoveredService service : discoveryService.getDiscoveredServices())
-        {
-            if ( ( now - service.getLastHearFromTime() ) > ( maxIdleTimeSeconds * 1000 ) )
-            {
-                if ( log.isInfoEnabled() )
-                {
-                    log.info( "Removing service, since we haven't heard from it in " + maxIdleTimeSeconds
-                        + " seconds.  service = " + service );
-                }
-                toRemove.add( service );
-            }
-        }
-
-        // remove the bad ones
-        for (DiscoveredService service : toRemove)
-        {
-            // call this so the listeners get notified
-            discoveryService.removeDiscoveredService( service );
-        }
-    }
-}
+package org.apache.commons.jcs.utils.discovery;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This class periodically check the lastHeardFrom time on the services.
+ * <p>
+ * If they exceed the configurable limit, it removes them from the set.
+ * <p>
+ * @author Aaron Smuts
+ */
+public class UDPCleanupRunner
+    implements Runnable
+{
+    /** log instance */
+    private static final Log log = LogFactory.getLog( UDPCleanupRunner.class );
+
+    /** UDP discovery service */
+    private final UDPDiscoveryService discoveryService;
+
+    /** default for max idle time, in seconds */
+    private static final long DEFAULT_MAX_IDLE_TIME_SECONDS = 180;
+
+    /** The configured max idle time, in seconds */
+    private final long maxIdleTimeSeconds = DEFAULT_MAX_IDLE_TIME_SECONDS;
+
+    /**
+     * @param service UDPDiscoveryService
+     */
+    public UDPCleanupRunner( UDPDiscoveryService service )
+    {
+        this.discoveryService = service;
+    }
+
+    /**
+     * This goes through the list of services and removes those that we haven't heard from in longer
+     * than the max idle time.
+     * <p>
+     * @see java.lang.Runnable#run()
+     */
+    public void run()
+    {
+        long now = System.currentTimeMillis();
+
+        // iterate through the set
+        // it is thread safe
+        // http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/CopyOnWriteArraySet.
+        // html
+        // TODO this should get a copy.  you can't simply remove from this.
+        // the listeners need to be notified.
+        Set<DiscoveredService> toRemove = new HashSet<DiscoveredService>();
+        // can't remove via the iterator. must remove directly
+        for (DiscoveredService service : discoveryService.getDiscoveredServices())
+        {
+            if ( ( now - service.getLastHearFromTime() ) > ( maxIdleTimeSeconds * 1000 ) )
+            {
+                if ( log.isInfoEnabled() )
+                {
+                    log.info( "Removing service, since we haven't heard from it in " + maxIdleTimeSeconds
+                        + " seconds.  service = " + service );
+                }
+                toRemove.add( service );
+            }
+        }
+
+        // remove the bad ones
+        for (DiscoveredService service : toRemove)
+        {
+            // call this so the listeners get notified
+            discoveryService.removeDiscoveredService( service );
+        }
+    }
+}

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryAttributes.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryAttributes.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryAttributes.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryAttributes.java Sun Feb 23 10:37:48 2014
@@ -1,231 +1,231 @@
-package org.apache.commons.jcs.utils.discovery;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Configuration properties for UDP discover service.
- * <p>
- * The service will allow out applications to find each other.
- * <p>
- * @author Aaron Smuts
- */
-public class UDPDiscoveryAttributes
-    implements Cloneable
-{
-    /** service name */
-    private String serviceName;
-
-    /** service address */
-    private String serviceAddress;
-
-    /** service port */
-    private int servicePort;
-
-    /**
-     * false -> this service instance is not ready to receive requests. true -> ready for use
-     */
-    private boolean isDark;
-
-    /** default udp discovery address */
-    private static final String DEFAULT_UDP_DISCOVERY_ADDRESS = "228.4.5.6";
-
-    /** default udp discovery port */
-    private static final int DEFAULT_UDP_DISCOVERY_PORT = 5678;
-
-    /** udp discovery address */
-    private String udpDiscoveryAddr = DEFAULT_UDP_DISCOVERY_ADDRESS;
-
-    /** udp discovery port */
-    private int udpDiscoveryPort = DEFAULT_UDP_DISCOVERY_PORT;
-
-    /** default delay between sending passive broadcasts */
-    private static final int DEFAULT_SEND_DELAY_SEC = 60;
-
-    /** delay between sending passive broadcasts */
-    private int sendDelaySec = DEFAULT_SEND_DELAY_SEC;
-
-    /** default amount of time before we remove services that we haven't heard from */
-    private static final int DEFAULT_MAX_IDLE_TIME_SEC = 180;
-
-    /** amount of time before we remove services that we haven't heard from */
-    private int maxIdleTimeSec = DEFAULT_MAX_IDLE_TIME_SEC;
-
-    /**
-     * @param serviceName The serviceName to set.
-     */
-    public void setServiceName( String serviceName )
-    {
-        this.serviceName = serviceName;
-    }
-
-    /**
-     * @return Returns the serviceName.
-     */
-    public String getServiceName()
-    {
-        return serviceName;
-    }
-
-    /**
-     * @param serviceAddress The serviceAddress to set.
-     */
-    public void setServiceAddress( String serviceAddress )
-    {
-        this.serviceAddress = serviceAddress;
-    }
-
-    /**
-     * @return Returns the serviceAddress.
-     */
-    public String getServiceAddress()
-    {
-        return serviceAddress;
-    }
-
-    /**
-     * @param servicePort The servicePort to set.
-     */
-    public void setServicePort( int servicePort )
-    {
-        this.servicePort = servicePort;
-    }
-
-    /**
-     * @return Returns the servicePort.
-     */
-    public int getServicePort()
-    {
-        return servicePort;
-    }
-
-    /**
-     * @param udpDiscoveryAddr The udpDiscoveryAddr to set.
-     */
-    public void setUdpDiscoveryAddr( String udpDiscoveryAddr )
-    {
-        this.udpDiscoveryAddr = udpDiscoveryAddr;
-    }
-
-    /**
-     * @return Returns the udpDiscoveryAddr.
-     */
-    public String getUdpDiscoveryAddr()
-    {
-        return udpDiscoveryAddr;
-    }
-
-    /**
-     * @param udpDiscoveryPort The udpDiscoveryPort to set.
-     */
-    public void setUdpDiscoveryPort( int udpDiscoveryPort )
-    {
-        this.udpDiscoveryPort = udpDiscoveryPort;
-    }
-
-    /**
-     * @return Returns the udpDiscoveryPort.
-     */
-    public int getUdpDiscoveryPort()
-    {
-        return udpDiscoveryPort;
-    }
-
-    /**
-     * @param sendDelaySec The sendDelaySec to set.
-     */
-    public void setSendDelaySec( int sendDelaySec )
-    {
-        this.sendDelaySec = sendDelaySec;
-    }
-
-    /**
-     * @return Returns the sendDelaySec.
-     */
-    public int getSendDelaySec()
-    {
-        return sendDelaySec;
-    }
-
-    /**
-     * @param maxIdleTimeSec The maxIdleTimeSec to set.
-     */
-    public void setMaxIdleTimeSec( int maxIdleTimeSec )
-    {
-        this.maxIdleTimeSec = maxIdleTimeSec;
-    }
-
-    /**
-     * @return Returns the maxIdleTimeSec.
-     */
-    public int getMaxIdleTimeSec()
-    {
-        return maxIdleTimeSec;
-    }
-
-    /**
-     * @return Returns the isDark.
-     */
-    public boolean isDark()
-    {
-        return isDark;
-    }
-
-    /**
-     * @param isDark The isDark to set.
-     */
-    public void setDark( boolean isDark )
-    {
-        this.isDark = isDark;
-    }
-
-    /** @return a clone of this object */
-    @Override
-    public Object clone()
-    {
-        UDPDiscoveryAttributes attributes = new UDPDiscoveryAttributes();
-        attributes.setSendDelaySec( this.getSendDelaySec() );
-        attributes.setMaxIdleTimeSec( this.getMaxIdleTimeSec() );
-        attributes.setServiceName( this.getServiceName() );
-        attributes.setServicePort( this.getServicePort() );
-        attributes.setUdpDiscoveryAddr( this.getUdpDiscoveryAddr() );
-        attributes.setUdpDiscoveryPort( this.getUdpDiscoveryPort() );
-        attributes.setDark( this.isDark() );
-        return attributes;
-    }
-
-    /**
-     * @return string for debugging purposes.
-     */
-    @Override
-    public String toString()
-    {
-        StringBuffer buf = new StringBuffer();
-        buf.append( "\n UDPDiscoveryAttributes" );
-        buf.append( "\n ServiceName = [" + getServiceName() + "]" );
-        buf.append( "\n ServiceAddress = [" + getServiceAddress() + "]" );
-        buf.append( "\n ServicePort = [" + getServicePort() + "]" );
-        buf.append( "\n UdpDiscoveryAddr = [" + getUdpDiscoveryAddr() + "]" );
-        buf.append( "\n UdpDiscoveryPort = [" + getUdpDiscoveryPort() + "]" );
-        buf.append( "\n SendDelaySec = [" + getSendDelaySec() + "]" );
-        buf.append( "\n MaxIdleTimeSec = [" + getMaxIdleTimeSec() + "]" );
-        buf.append( "\n IsDark = [" + isDark() + "]" );
-        return buf.toString();
-    }
-}
+package org.apache.commons.jcs.utils.discovery;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Configuration properties for UDP discover service.
+ * <p>
+ * The service will allow out applications to find each other.
+ * <p>
+ * @author Aaron Smuts
+ */
+public class UDPDiscoveryAttributes
+    implements Cloneable
+{
+    /** service name */
+    private String serviceName;
+
+    /** service address */
+    private String serviceAddress;
+
+    /** service port */
+    private int servicePort;
+
+    /**
+     * false -> this service instance is not ready to receive requests. true -> ready for use
+     */
+    private boolean isDark;
+
+    /** default udp discovery address */
+    private static final String DEFAULT_UDP_DISCOVERY_ADDRESS = "228.4.5.6";
+
+    /** default udp discovery port */
+    private static final int DEFAULT_UDP_DISCOVERY_PORT = 5678;
+
+    /** udp discovery address */
+    private String udpDiscoveryAddr = DEFAULT_UDP_DISCOVERY_ADDRESS;
+
+    /** udp discovery port */
+    private int udpDiscoveryPort = DEFAULT_UDP_DISCOVERY_PORT;
+
+    /** default delay between sending passive broadcasts */
+    private static final int DEFAULT_SEND_DELAY_SEC = 60;
+
+    /** delay between sending passive broadcasts */
+    private int sendDelaySec = DEFAULT_SEND_DELAY_SEC;
+
+    /** default amount of time before we remove services that we haven't heard from */
+    private static final int DEFAULT_MAX_IDLE_TIME_SEC = 180;
+
+    /** amount of time before we remove services that we haven't heard from */
+    private int maxIdleTimeSec = DEFAULT_MAX_IDLE_TIME_SEC;
+
+    /**
+     * @param serviceName The serviceName to set.
+     */
+    public void setServiceName( String serviceName )
+    {
+        this.serviceName = serviceName;
+    }
+
+    /**
+     * @return Returns the serviceName.
+     */
+    public String getServiceName()
+    {
+        return serviceName;
+    }
+
+    /**
+     * @param serviceAddress The serviceAddress to set.
+     */
+    public void setServiceAddress( String serviceAddress )
+    {
+        this.serviceAddress = serviceAddress;
+    }
+
+    /**
+     * @return Returns the serviceAddress.
+     */
+    public String getServiceAddress()
+    {
+        return serviceAddress;
+    }
+
+    /**
+     * @param servicePort The servicePort to set.
+     */
+    public void setServicePort( int servicePort )
+    {
+        this.servicePort = servicePort;
+    }
+
+    /**
+     * @return Returns the servicePort.
+     */
+    public int getServicePort()
+    {
+        return servicePort;
+    }
+
+    /**
+     * @param udpDiscoveryAddr The udpDiscoveryAddr to set.
+     */
+    public void setUdpDiscoveryAddr( String udpDiscoveryAddr )
+    {
+        this.udpDiscoveryAddr = udpDiscoveryAddr;
+    }
+
+    /**
+     * @return Returns the udpDiscoveryAddr.
+     */
+    public String getUdpDiscoveryAddr()
+    {
+        return udpDiscoveryAddr;
+    }
+
+    /**
+     * @param udpDiscoveryPort The udpDiscoveryPort to set.
+     */
+    public void setUdpDiscoveryPort( int udpDiscoveryPort )
+    {
+        this.udpDiscoveryPort = udpDiscoveryPort;
+    }
+
+    /**
+     * @return Returns the udpDiscoveryPort.
+     */
+    public int getUdpDiscoveryPort()
+    {
+        return udpDiscoveryPort;
+    }
+
+    /**
+     * @param sendDelaySec The sendDelaySec to set.
+     */
+    public void setSendDelaySec( int sendDelaySec )
+    {
+        this.sendDelaySec = sendDelaySec;
+    }
+
+    /**
+     * @return Returns the sendDelaySec.
+     */
+    public int getSendDelaySec()
+    {
+        return sendDelaySec;
+    }
+
+    /**
+     * @param maxIdleTimeSec The maxIdleTimeSec to set.
+     */
+    public void setMaxIdleTimeSec( int maxIdleTimeSec )
+    {
+        this.maxIdleTimeSec = maxIdleTimeSec;
+    }
+
+    /**
+     * @return Returns the maxIdleTimeSec.
+     */
+    public int getMaxIdleTimeSec()
+    {
+        return maxIdleTimeSec;
+    }
+
+    /**
+     * @return Returns the isDark.
+     */
+    public boolean isDark()
+    {
+        return isDark;
+    }
+
+    /**
+     * @param isDark The isDark to set.
+     */
+    public void setDark( boolean isDark )
+    {
+        this.isDark = isDark;
+    }
+
+    /** @return a clone of this object */
+    @Override
+    public Object clone()
+    {
+        UDPDiscoveryAttributes attributes = new UDPDiscoveryAttributes();
+        attributes.setSendDelaySec( this.getSendDelaySec() );
+        attributes.setMaxIdleTimeSec( this.getMaxIdleTimeSec() );
+        attributes.setServiceName( this.getServiceName() );
+        attributes.setServicePort( this.getServicePort() );
+        attributes.setUdpDiscoveryAddr( this.getUdpDiscoveryAddr() );
+        attributes.setUdpDiscoveryPort( this.getUdpDiscoveryPort() );
+        attributes.setDark( this.isDark() );
+        return attributes;
+    }
+
+    /**
+     * @return string for debugging purposes.
+     */
+    @Override
+    public String toString()
+    {
+        StringBuffer buf = new StringBuffer();
+        buf.append( "\n UDPDiscoveryAttributes" );
+        buf.append( "\n ServiceName = [" + getServiceName() + "]" );
+        buf.append( "\n ServiceAddress = [" + getServiceAddress() + "]" );
+        buf.append( "\n ServicePort = [" + getServicePort() + "]" );
+        buf.append( "\n UdpDiscoveryAddr = [" + getUdpDiscoveryAddr() + "]" );
+        buf.append( "\n UdpDiscoveryPort = [" + getUdpDiscoveryPort() + "]" );
+        buf.append( "\n SendDelaySec = [" + getSendDelaySec() + "]" );
+        buf.append( "\n MaxIdleTimeSec = [" + getMaxIdleTimeSec() + "]" );
+        buf.append( "\n IsDark = [" + isDark() + "]" );
+        return buf.toString();
+    }
+}

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryInfo.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryInfo.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryInfo.java Sun Feb 23 10:37:48 2014
@@ -1,40 +1,40 @@
-package org.apache.commons.jcs.utils.discovery;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.rmi.dgc.VMID;
-
-/**
- * Provides info for the udp discovery service.
- * <p>
- * @author Aaron Smuts
- */
-public class UDPDiscoveryInfo
-{
-    /**
-     * jvm unique identifier.
-     */
-    protected static VMID vmid = new VMID();
-
-    /**
-     * Identifies the listener, so we don't add ourselves to the list of known services.
-     */
-    public static long listenerId = vmid.hashCode();
-}
+package org.apache.commons.jcs.utils.discovery;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.rmi.dgc.VMID;
+
+/**
+ * Provides info for the udp discovery service.
+ * <p>
+ * @author Aaron Smuts
+ */
+public class UDPDiscoveryInfo
+{
+    /**
+     * jvm unique identifier.
+     */
+    protected static VMID vmid = new VMID();
+
+    /**
+     * Identifies the listener, so we don't add ourselves to the list of known services.
+     */
+    public static long listenerId = vmid.hashCode();
+}

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/behavior/IDiscoveryListener.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/behavior/IDiscoveryListener.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/behavior/IDiscoveryListener.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/discovery/behavior/IDiscoveryListener.java Sun Feb 23 10:37:48 2014
@@ -1,44 +1,44 @@
-package org.apache.commons.jcs.utils.discovery.behavior;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.jcs.utils.discovery.DiscoveredService;
-
-/**
- * Interface for things that want to listen to discovery events. This will allow discovery to be
- * used outside of the TCP lateral.
- */
-public interface IDiscoveryListener
-{
-    /**
-     * Add the service if needed. This does not necessarily mean that the service is not already
-     * added. This can be called if there is a change in service information, such as the cacheNames.
-     * <p>
-     * @param service the service to add
-     */
-    public void addDiscoveredService( DiscoveredService service );
-
-    /**
-     * Remove the service from the list.
-     * <p>
-     * @param service the service to remove
-     */
-    public void removeDiscoveredService( DiscoveredService service );
-}
+package org.apache.commons.jcs.utils.discovery.behavior;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.jcs.utils.discovery.DiscoveredService;
+
+/**
+ * Interface for things that want to listen to discovery events. This will allow discovery to be
+ * used outside of the TCP lateral.
+ */
+public interface IDiscoveryListener
+{
+    /**
+     * Add the service if needed. This does not necessarily mean that the service is not already
+     * added. This can be called if there is a change in service information, such as the cacheNames.
+     * <p>
+     * @param service the service to add
+     */
+    public void addDiscoveredService( DiscoveredService service );
+
+    /**
+     * Remove the service from the list.
+     * <p>
+     * @param service the service to remove
+     */
+    public void removeDiscoveredService( DiscoveredService service );
+}

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/key/KeyGeneratorUtil.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/key/KeyGeneratorUtil.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/key/KeyGeneratorUtil.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/key/KeyGeneratorUtil.java Sun Feb 23 10:37:48 2014
@@ -1,166 +1,185 @@
-package org.apache.commons.jcs.utils.key;
-
-import java.text.ParseException;
-import java.util.Calendar;
-import java.util.Date;
-
-import org.apache.commons.jcs.utils.date.DateFormatter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * This can create and parse request ids.  You can use it to generate keys that contain a create time stamp.
- * <p>
- * You can set a system property called "KEY_LEAD_NUMBER" to override the lead number. The value
- * must be a simple int from 1 to 9.
- */
-public final class KeyGeneratorUtil
-{
-    /** The logger. */
-    private static final Log log = LogFactory.getLog( KeyGeneratorUtil.class );
-
-    /** a temporary counter for generating request ids. */
-    private static int requestCounter = 0;
-
-    /** last reset time. */
-    private static long lastCounterResetTime = System.currentTimeMillis();
-
-    /** defaults to 2 hours. */
-    private static final long DEFAULT_COUNTER_RESET_INTERVAL_MILLIS = 2 * 60 * 60 * 1000;
-
-    /** How often should we reset the counter. */
-    protected static long counterResetIntervalMillis = DEFAULT_COUNTER_RESET_INTERVAL_MILLIS;
-
-    /** The size of the data portion. */
-    private static final int LENGTH_OF_DATE_STRING = 8;
-
-    /**
-     * The name of the system property that can be used to override the default. This allows us to
-     * run multiple instance on a machine.
-     */
-    public static final String KEY_LEAD_NUMBER_PROPERTY_NAME = "KEY_LEAD_NUMBER";
-
-    /** The default lead number. */
-    public static final int DEFAULT_LEAD_NUMBER = 3;
-
-    /** We lead with a number so it can be converted to a number. This is the prefix to all ids. */
-    protected static int leadNumber = DEFAULT_LEAD_NUMBER;
-
-    static
-    {
-        setLeadFromSystemProperty();
-    }
-
-    /** Sets the lead number from a system property */
-    protected static void setLeadFromSystemProperty()
-    {
-        String leadString = System.getProperty( KEY_LEAD_NUMBER_PROPERTY_NAME, String.valueOf( DEFAULT_LEAD_NUMBER ) );
-        if ( log.isInfoEnabled() )
-        {
-            log.info( "leadString = [" + leadString + "]" );
-        }
-        try
-        {
-            leadNumber = Integer.parseInt( leadString );
-        }
-        catch ( NumberFormatException e )
-        {
-            log.error( "Problem parsing lead number system property value. [" + leadString + "]", e );
-        }
-    }
-
-    /**
-     * Creates a query id in the format 1001010121712345 where the first 8 digits (10010101) is a 8
-     * digit number where: 1 is a padding digit and 001 is the first day of the year. The next 3
-     * digits (217) are the decimal representation of the last byte of data in the machine ip (for
-     * example 192.168.1.2 will be 002). The remaining digits (ex. 12345) are some unique number.
-     * These come from a counter that is reset every 2 hours.
-     * <p>
-     * @return long
-     */
-    public static String generateRequestId()
-    {
-        int counter = getNextRequestCounter();
-
-        Date d = new Date();
-        String dateString = DateFormatter.getDddHHmm( d );
-        String finalOctetOfIp = org.apache.commons.jcs.utils.net.AddressUtil.obtainFinalThreeDigitsOfAddressAsString();
-        String queryId = leadNumber + dateString + finalOctetOfIp + counter;
-        return queryId;
-    }
-
-    /**
-     * This DddHHmm.
-     * <p>
-     * This has to get the current year and set it, since the source data does not have the year.
-     * <p>
-     * @param queryId queryId
-     * @return now if we can't parse, else the data from the query id.
-     * @throws ParseException ParseException
-     */
-    public static Date getDateOfShopFromRequestId( String queryId )
-        throws ParseException
-    {
-        Date date = null;
-        if ( queryId != null )
-        {
-            if ( queryId.length() >= LENGTH_OF_DATE_STRING )
-            {
-                Calendar cal = Calendar.getInstance();
-                int year = cal.get( Calendar.YEAR );
-                int dayOfYear;
-                int hour;
-                int minute;
-
-                try
-                {
-                    dayOfYear = Integer.parseInt( queryId.substring( 1, 4 ) );
-                    hour = Integer.parseInt( queryId.substring( 4, 6 ) );
-                    minute = Integer.parseInt( queryId.substring( 6, 8 ) );
-                }
-                catch ( NumberFormatException e )
-                {
-                    throw new ParseException( "Error reading date/hour/minute from input string [" + queryId + "]", 0 );
-                }
-
-                cal.set( Calendar.YEAR, year );
-                cal.set( Calendar.DAY_OF_YEAR, dayOfYear );
-                cal.set( Calendar.HOUR_OF_DAY, hour );
-                cal.set( Calendar.MINUTE, minute );
-                date = cal.getTime();
-            }
-            else
-            {
-                throw new ParseException( "The input string is not long enough [" + queryId + "]", queryId.length() );
-            }
-        }
-        else
-        {
-            throw new ParseException( "Can't parse a null string.", 0 );
-        }
-        return date;
-    }
-
-    /**
-     * Automatically increment and return the request counter. If the last counter reset was more
-     * than the interval, reset the counter.
-     * <p>
-     * @return The incremented count.
-     */
-    protected static synchronized int getNextRequestCounter()
-    {
-        long now = System.currentTimeMillis();
-        if ( ( now - KeyGeneratorUtil.lastCounterResetTime ) > KeyGeneratorUtil.counterResetIntervalMillis )
-        {
-            resetCounter();
-        }
-        return ++requestCounter;
-    }
-
-    /** reset the counter and the reset time. */
-    protected static synchronized void resetCounter()
-    {
-        KeyGeneratorUtil.lastCounterResetTime = System.currentTimeMillis();
-        KeyGeneratorUtil.requestCounter = 0;
-    }
-}
+package org.apache.commons.jcs.utils.key;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.text.ParseException;
+import java.util.Calendar;
+import java.util.Date;
+
+import org.apache.commons.jcs.utils.date.DateFormatter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This can create and parse request ids.  You can use it to generate keys that contain a create time stamp.
+ * <p>
+ * You can set a system property called "KEY_LEAD_NUMBER" to override the lead number. The value
+ * must be a simple int from 1 to 9.
+ */
+public final class KeyGeneratorUtil
+{
+    /** The logger. */
+    private static final Log log = LogFactory.getLog( KeyGeneratorUtil.class );
+
+    /** a temporary counter for generating request ids. */
+    private static int requestCounter = 0;
+
+    /** last reset time. */
+    private static long lastCounterResetTime = System.currentTimeMillis();
+
+    /** defaults to 2 hours. */
+    private static final long DEFAULT_COUNTER_RESET_INTERVAL_MILLIS = 2 * 60 * 60 * 1000;
+
+    /** How often should we reset the counter. */
+    protected static long counterResetIntervalMillis = DEFAULT_COUNTER_RESET_INTERVAL_MILLIS;
+
+    /** The size of the data portion. */
+    private static final int LENGTH_OF_DATE_STRING = 8;
+
+    /**
+     * The name of the system property that can be used to override the default. This allows us to
+     * run multiple instance on a machine.
+     */
+    public static final String KEY_LEAD_NUMBER_PROPERTY_NAME = "KEY_LEAD_NUMBER";
+
+    /** The default lead number. */
+    public static final int DEFAULT_LEAD_NUMBER = 3;
+
+    /** We lead with a number so it can be converted to a number. This is the prefix to all ids. */
+    protected static int leadNumber = DEFAULT_LEAD_NUMBER;
+
+    static
+    {
+        setLeadFromSystemProperty();
+    }
+
+    /** Sets the lead number from a system property */
+    protected static void setLeadFromSystemProperty()
+    {
+        String leadString = System.getProperty( KEY_LEAD_NUMBER_PROPERTY_NAME, String.valueOf( DEFAULT_LEAD_NUMBER ) );
+        if ( log.isInfoEnabled() )
+        {
+            log.info( "leadString = [" + leadString + "]" );
+        }
+        try
+        {
+            leadNumber = Integer.parseInt( leadString );
+        }
+        catch ( NumberFormatException e )
+        {
+            log.error( "Problem parsing lead number system property value. [" + leadString + "]", e );
+        }
+    }
+
+    /**
+     * Creates a query id in the format 1001010121712345 where the first 8 digits (10010101) is a 8
+     * digit number where: 1 is a padding digit and 001 is the first day of the year. The next 3
+     * digits (217) are the decimal representation of the last byte of data in the machine ip (for
+     * example 192.168.1.2 will be 002). The remaining digits (ex. 12345) are some unique number.
+     * These come from a counter that is reset every 2 hours.
+     * <p>
+     * @return long
+     */
+    public static String generateRequestId()
+    {
+        int counter = getNextRequestCounter();
+
+        Date d = new Date();
+        String dateString = DateFormatter.getDddHHmm( d );
+        String finalOctetOfIp = org.apache.commons.jcs.utils.net.AddressUtil.obtainFinalThreeDigitsOfAddressAsString();
+        String queryId = leadNumber + dateString + finalOctetOfIp + counter;
+        return queryId;
+    }
+
+    /**
+     * This DddHHmm.
+     * <p>
+     * This has to get the current year and set it, since the source data does not have the year.
+     * <p>
+     * @param queryId queryId
+     * @return now if we can't parse, else the data from the query id.
+     * @throws ParseException ParseException
+     */
+    public static Date getDateOfShopFromRequestId( String queryId )
+        throws ParseException
+    {
+        Date date = null;
+        if ( queryId != null )
+        {
+            if ( queryId.length() >= LENGTH_OF_DATE_STRING )
+            {
+                Calendar cal = Calendar.getInstance();
+                int year = cal.get( Calendar.YEAR );
+                int dayOfYear;
+                int hour;
+                int minute;
+
+                try
+                {
+                    dayOfYear = Integer.parseInt( queryId.substring( 1, 4 ) );
+                    hour = Integer.parseInt( queryId.substring( 4, 6 ) );
+                    minute = Integer.parseInt( queryId.substring( 6, 8 ) );
+                }
+                catch ( NumberFormatException e )
+                {
+                    throw new ParseException( "Error reading date/hour/minute from input string [" + queryId + "]", 0 );
+                }
+
+                cal.set( Calendar.YEAR, year );
+                cal.set( Calendar.DAY_OF_YEAR, dayOfYear );
+                cal.set( Calendar.HOUR_OF_DAY, hour );
+                cal.set( Calendar.MINUTE, minute );
+                date = cal.getTime();
+            }
+            else
+            {
+                throw new ParseException( "The input string is not long enough [" + queryId + "]", queryId.length() );
+            }
+        }
+        else
+        {
+            throw new ParseException( "Can't parse a null string.", 0 );
+        }
+        return date;
+    }
+
+    /**
+     * Automatically increment and return the request counter. If the last counter reset was more
+     * than the interval, reset the counter.
+     * <p>
+     * @return The incremented count.
+     */
+    protected static synchronized int getNextRequestCounter()
+    {
+        long now = System.currentTimeMillis();
+        if ( ( now - KeyGeneratorUtil.lastCounterResetTime ) > KeyGeneratorUtil.counterResetIntervalMillis )
+        {
+            resetCounter();
+        }
+        return ++requestCounter;
+    }
+
+    /** reset the counter and the reset time. */
+    protected static synchronized void resetCounter()
+    {
+        KeyGeneratorUtil.lastCounterResetTime = System.currentTimeMillis();
+        KeyGeneratorUtil.requestCounter = 0;
+    }
+}

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/net/AddressUtil.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/net/AddressUtil.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/net/AddressUtil.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/net/AddressUtil.java Sun Feb 23 10:37:48 2014
@@ -1,115 +1,134 @@
-package org.apache.commons.jcs.utils.net;
-
-import java.net.UnknownHostException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/** Utility for getting info on the local ip address. */
-public final class AddressUtil
-{
-    /** log instance */
-    private static final Log log = LogFactory.getLog( AddressUtil.class );
-
-    /** the default returned string value for the last octet */
-    public static final String DEFAULT_INTERNET_ADDRESS_OCTET_AS_STRING = "000";
-
-    /** the default returned string value for the whole ip */
-    public static final String DEFAULT_INTERNET_ADDRESS_AS_STRING = "0.0.0.0";
-
-    /** current address octet as string */
-    private static String currentAddressOctetAsString = null;
-
-    /**
-     * private constructor.
-     */
-    private AddressUtil()
-    {
-        if ( log.isDebugEnabled() )
-        {
-            log.debug( "private constructor" );
-        }
-    }
-
-    /**
-     * This method looks up the host machines internet address, parses out the last octet and
-     * formats that number as a 3 character string.
-     * @return a string containing the digits of the ip address
-     */
-    public static synchronized String obtainFinalThreeDigitsOfAddressAsString()
-    {
-        if ( currentAddressOctetAsString == null )
-        {
-            currentAddressOctetAsString = obtainFinalThreeDigitsOfAddressAsStringLookup();
-        }
-
-        return currentAddressOctetAsString;
-    }
-
-    /**
-     * This method looks up the host machines internet address, parses out the last octet and
-     * formats that number as a 3 character string.
-     * <p>
-     * @return a string containing the digits of the ip address
-     */
-    private static String obtainFinalThreeDigitsOfAddressAsStringLookup()
-    {
-        String retval = DEFAULT_INTERNET_ADDRESS_OCTET_AS_STRING;
-        try
-        {
-            String ipAsString = HostNameUtil.getLocalHostAddress();
-
-            if ( log.isInfoEnabled() )
-            {
-                log.info( "obtainFinalThreeDigitsOfAddressAsStringLookup running; ipstring [" + ipAsString + "]" );
-            }
-
-            int lastdot = ipAsString.lastIndexOf( "." );
-            if ( lastdot != -1 )
-            {
-                if ( lastdot != ipAsString.length() )
-                {
-                    ipAsString = ipAsString.substring( lastdot + 1 );
-
-                    // pad it out to 3 characters
-                    switch ( ipAsString.length() )
-                    {
-                        case 1:
-                            ipAsString = "00" + ipAsString;
-                            break;
-                        case 2:
-                            ipAsString = "0" + ipAsString;
-                            break;
-                        case 3:
-                            if ( log.isDebugEnabled() )
-                            {
-                                log.debug( "3 digits is as we expect" );
-                            }
-                            break;
-                        default:
-                            log.warn( "detected invalid ip octet length [" + ipAsString + "] will return default" );
-                            ipAsString = DEFAULT_INTERNET_ADDRESS_OCTET_AS_STRING;
-
-                            break;
-                    }
-                    retval = ipAsString;
-                }
-                else
-                {
-                    log.warn( "ip ends in . ip: " + ipAsString + "  returning default: "
-                        + DEFAULT_INTERNET_ADDRESS_OCTET_AS_STRING );
-                }
-            }
-            else
-            {
-                log.warn( "could not find a . in address: " + ipAsString + "  returning default: "
-                    + DEFAULT_INTERNET_ADDRESS_OCTET_AS_STRING );
-            }
-        }
-        catch ( UnknownHostException e1 )
-        {
-            log.warn( "problem getting host address.  returning default: " + DEFAULT_INTERNET_ADDRESS_OCTET_AS_STRING );
-        }
-        return retval;
-    }
-}
+package org.apache.commons.jcs.utils.net;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.net.UnknownHostException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/** Utility for getting info on the local ip address. */
+public final class AddressUtil
+{
+    /** log instance */
+    private static final Log log = LogFactory.getLog( AddressUtil.class );
+
+    /** the default returned string value for the last octet */
+    public static final String DEFAULT_INTERNET_ADDRESS_OCTET_AS_STRING = "000";
+
+    /** the default returned string value for the whole ip */
+    public static final String DEFAULT_INTERNET_ADDRESS_AS_STRING = "0.0.0.0";
+
+    /** current address octet as string */
+    private static String currentAddressOctetAsString = null;
+
+    /**
+     * private constructor.
+     */
+    private AddressUtil()
+    {
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "private constructor" );
+        }
+    }
+
+    /**
+     * This method looks up the host machines internet address, parses out the last octet and
+     * formats that number as a 3 character string.
+     * @return a string containing the digits of the ip address
+     */
+    public static synchronized String obtainFinalThreeDigitsOfAddressAsString()
+    {
+        if ( currentAddressOctetAsString == null )
+        {
+            currentAddressOctetAsString = obtainFinalThreeDigitsOfAddressAsStringLookup();
+        }
+
+        return currentAddressOctetAsString;
+    }
+
+    /**
+     * This method looks up the host machines internet address, parses out the last octet and
+     * formats that number as a 3 character string.
+     * <p>
+     * @return a string containing the digits of the ip address
+     */
+    private static String obtainFinalThreeDigitsOfAddressAsStringLookup()
+    {
+        String retval = DEFAULT_INTERNET_ADDRESS_OCTET_AS_STRING;
+        try
+        {
+            String ipAsString = HostNameUtil.getLocalHostAddress();
+
+            if ( log.isInfoEnabled() )
+            {
+                log.info( "obtainFinalThreeDigitsOfAddressAsStringLookup running; ipstring [" + ipAsString + "]" );
+            }
+
+            int lastdot = ipAsString.lastIndexOf( "." );
+            if ( lastdot != -1 )
+            {
+                if ( lastdot != ipAsString.length() )
+                {
+                    ipAsString = ipAsString.substring( lastdot + 1 );
+
+                    // pad it out to 3 characters
+                    switch ( ipAsString.length() )
+                    {
+                        case 1:
+                            ipAsString = "00" + ipAsString;
+                            break;
+                        case 2:
+                            ipAsString = "0" + ipAsString;
+                            break;
+                        case 3:
+                            if ( log.isDebugEnabled() )
+                            {
+                                log.debug( "3 digits is as we expect" );
+                            }
+                            break;
+                        default:
+                            log.warn( "detected invalid ip octet length [" + ipAsString + "] will return default" );
+                            ipAsString = DEFAULT_INTERNET_ADDRESS_OCTET_AS_STRING;
+
+                            break;
+                    }
+                    retval = ipAsString;
+                }
+                else
+                {
+                    log.warn( "ip ends in . ip: " + ipAsString + "  returning default: "
+                        + DEFAULT_INTERNET_ADDRESS_OCTET_AS_STRING );
+                }
+            }
+            else
+            {
+                log.warn( "could not find a . in address: " + ipAsString + "  returning default: "
+                    + DEFAULT_INTERNET_ADDRESS_OCTET_AS_STRING );
+            }
+        }
+        catch ( UnknownHostException e1 )
+        {
+            log.warn( "problem getting host address.  returning default: " + DEFAULT_INTERNET_ADDRESS_OCTET_AS_STRING );
+        }
+        return retval;
+    }
+}

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/props/AbstractPropertyContainer.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/props/AbstractPropertyContainer.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/props/AbstractPropertyContainer.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/props/AbstractPropertyContainer.java Sun Feb 23 10:37:48 2014
@@ -1,190 +1,190 @@
-package org.apache.commons.jcs.utils.props;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Properties;
-
-import org.apache.commons.jcs.access.exception.ConfigurationException;
-
-/**
- * Provides a mechanism to load properties into objects.
- * <p>
- * Functions that depend on properties should call ensureProperties() before it uses any properties.
- */
-public abstract class AbstractPropertyContainer
-{
-    /** File, db, etc */
-    private static final PropertiesFactory DEFAULT_PROPERTIES_FACTORY = new PropertiesFactoryFileImpl();
-
-    /**
-     * A property group is a subsection of properties. It's sent to the properties factory to
-     * specify which group of properties to pull back. This will probably mean different things to
-     * different property factories. For PropertiesFactoryFileImpl, the propertiesGroup maps to a
-     * filename.
-     */
-    private String propertiesGroup;
-
-    /**
-     * The property heading is used to specify a starting point in the properties object. This is
-     * used so that settings can be relative to this propertiesHeading, as opposed to being
-     * statically coded. There's no enforcement of this, but users are encouraged to call
-     * getProperties().get( getPropertiesHeading() + ".foo" );
-     */
-    private String propertiesHeading;
-
-    /** The factory to use. */
-    private PropertiesFactory propertiesFactory;
-
-    /** The loaded properties. */
-    private Properties properties;
-
-    /**
-     * Makes sure an AbstractPropertyClass has all the properties it needs.
-     * <p>
-     * Synchronized mutators so multiple threads cannot cause problems. We wouldn't want the
-     * properties heading to get changed as we were processing the properties.
-     * <p>
-     * @throws ConfigurationException on configuration failure
-     */
-    public synchronized void ensureProperties()
-        throws ConfigurationException
-    {
-        if ( getProperties() == null )
-        {
-            initializeProperties();
-        }
-    }
-
-    /**
-     * Loads the properties and then calls handleProperties. Typically, you don't need to call this.
-     * This is primarily intended for reinitialization.
-     * <p>
-     * If the properties object is null, when you call ensureProperties initialize will be called.
-     * <p>
-     * @throws ConfigurationException on configuration failure
-     */
-    public synchronized void initializeProperties()
-        throws ConfigurationException
-    {
-        loadProperties();
-
-        handleProperties();
-    }
-
-    /**
-     * This loads the properties regardless of whether or not they have already been loaded.
-     * <p>
-     * @throws ConfigurationException on configuration failure
-     */
-    private void loadProperties()
-        throws ConfigurationException
-    {
-        if ( getPropertiesGroup() == null )
-        {
-            throw new ConfigurationException( "Properties group is null and it shouldn't be" );
-        }
-
-        if ( getPropertiesHeading() == null )
-        {
-            throw new ConfigurationException( "Properties heading is null and it shouldn't be" );
-        }
-
-        if ( getPropertiesFactory() == null )
-        {
-            setProperties( DEFAULT_PROPERTIES_FACTORY.getProperties( getPropertiesGroup() ) );
-        }
-        else
-        {
-            setProperties( getPropertiesFactory().getProperties( getPropertiesGroup() ) );
-        }
-    }
-
-    /**
-     * Sets fields for properties, and verifies that all necessary properties are there.
-     * <p>
-     * @throws ConfigurationException on configuration failure
-     */
-    protected abstract void handleProperties()
-        throws ConfigurationException;
-
-    /**
-     * @return Returns the properties.
-     */
-    public synchronized Properties getProperties()
-    {
-        return properties;
-    }
-
-    /**
-     * @param properties The properties to set.
-     */
-    public synchronized void setProperties( Properties properties )
-    {
-        this.properties = properties;
-    }
-
-    /**
-     * @return Returns the propertiesHeading.
-     */
-    public synchronized String getPropertiesHeading()
-    {
-        return propertiesHeading;
-    }
-
-    /**
-     * @param propertiesHeading The propertiesHeading to set.
-     */
-    public synchronized void setPropertiesHeading( String propertiesHeading )
-    {
-        this.propertiesHeading = propertiesHeading;
-    }
-
-    /**
-     * @return Returns the propertiesFactory.
-     */
-    public PropertiesFactory getPropertiesFactory()
-    {
-        return propertiesFactory;
-    }
-
-    /**
-     * @param propertiesFactory The propertiesFactory to set.
-     */
-    public void setPropertiesFactory( PropertiesFactory propertiesFactory )
-    {
-        this.propertiesFactory = propertiesFactory;
-    }
-
-    /**
-     * @return Returns the propertiesGroup.
-     */
-    public String getPropertiesGroup()
-    {
-        return propertiesGroup;
-    }
-
-    /**
-     * @param propertiesGroup The propertiesGroup to set.
-     */
-    public void setPropertiesGroup( String propertiesGroup )
-    {
-        this.propertiesGroup = propertiesGroup;
-    }
-}
+package org.apache.commons.jcs.utils.props;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Properties;
+
+import org.apache.commons.jcs.access.exception.ConfigurationException;
+
+/**
+ * Provides a mechanism to load properties into objects.
+ * <p>
+ * Functions that depend on properties should call ensureProperties() before it uses any properties.
+ */
+public abstract class AbstractPropertyContainer
+{
+    /** File, db, etc */
+    private static final PropertiesFactory DEFAULT_PROPERTIES_FACTORY = new PropertiesFactoryFileImpl();
+
+    /**
+     * A property group is a subsection of properties. It's sent to the properties factory to
+     * specify which group of properties to pull back. This will probably mean different things to
+     * different property factories. For PropertiesFactoryFileImpl, the propertiesGroup maps to a
+     * filename.
+     */
+    private String propertiesGroup;
+
+    /**
+     * The property heading is used to specify a starting point in the properties object. This is
+     * used so that settings can be relative to this propertiesHeading, as opposed to being
+     * statically coded. There's no enforcement of this, but users are encouraged to call
+     * getProperties().get( getPropertiesHeading() + ".foo" );
+     */
+    private String propertiesHeading;
+
+    /** The factory to use. */
+    private PropertiesFactory propertiesFactory;
+
+    /** The loaded properties. */
+    private Properties properties;
+
+    /**
+     * Makes sure an AbstractPropertyClass has all the properties it needs.
+     * <p>
+     * Synchronized mutators so multiple threads cannot cause problems. We wouldn't want the
+     * properties heading to get changed as we were processing the properties.
+     * <p>
+     * @throws ConfigurationException on configuration failure
+     */
+    public synchronized void ensureProperties()
+        throws ConfigurationException
+    {
+        if ( getProperties() == null )
+        {
+            initializeProperties();
+        }
+    }
+
+    /**
+     * Loads the properties and then calls handleProperties. Typically, you don't need to call this.
+     * This is primarily intended for reinitialization.
+     * <p>
+     * If the properties object is null, when you call ensureProperties initialize will be called.
+     * <p>
+     * @throws ConfigurationException on configuration failure
+     */
+    public synchronized void initializeProperties()
+        throws ConfigurationException
+    {
+        loadProperties();
+
+        handleProperties();
+    }
+
+    /**
+     * This loads the properties regardless of whether or not they have already been loaded.
+     * <p>
+     * @throws ConfigurationException on configuration failure
+     */
+    private void loadProperties()
+        throws ConfigurationException
+    {
+        if ( getPropertiesGroup() == null )
+        {
+            throw new ConfigurationException( "Properties group is null and it shouldn't be" );
+        }
+
+        if ( getPropertiesHeading() == null )
+        {
+            throw new ConfigurationException( "Properties heading is null and it shouldn't be" );
+        }
+
+        if ( getPropertiesFactory() == null )
+        {
+            setProperties( DEFAULT_PROPERTIES_FACTORY.getProperties( getPropertiesGroup() ) );
+        }
+        else
+        {
+            setProperties( getPropertiesFactory().getProperties( getPropertiesGroup() ) );
+        }
+    }
+
+    /**
+     * Sets fields for properties, and verifies that all necessary properties are there.
+     * <p>
+     * @throws ConfigurationException on configuration failure
+     */
+    protected abstract void handleProperties()
+        throws ConfigurationException;
+
+    /**
+     * @return Returns the properties.
+     */
+    public synchronized Properties getProperties()
+    {
+        return properties;
+    }
+
+    /**
+     * @param properties The properties to set.
+     */
+    public synchronized void setProperties( Properties properties )
+    {
+        this.properties = properties;
+    }
+
+    /**
+     * @return Returns the propertiesHeading.
+     */
+    public synchronized String getPropertiesHeading()
+    {
+        return propertiesHeading;
+    }
+
+    /**
+     * @param propertiesHeading The propertiesHeading to set.
+     */
+    public synchronized void setPropertiesHeading( String propertiesHeading )
+    {
+        this.propertiesHeading = propertiesHeading;
+    }
+
+    /**
+     * @return Returns the propertiesFactory.
+     */
+    public PropertiesFactory getPropertiesFactory()
+    {
+        return propertiesFactory;
+    }
+
+    /**
+     * @param propertiesFactory The propertiesFactory to set.
+     */
+    public void setPropertiesFactory( PropertiesFactory propertiesFactory )
+    {
+        this.propertiesFactory = propertiesFactory;
+    }
+
+    /**
+     * @return Returns the propertiesGroup.
+     */
+    public String getPropertiesGroup()
+    {
+        return propertiesGroup;
+    }
+
+    /**
+     * @param propertiesGroup The propertiesGroup to set.
+     */
+    public void setPropertiesGroup( String propertiesGroup )
+    {
+        this.propertiesGroup = propertiesGroup;
+    }
+}

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/props/PropertiesFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/props/PropertiesFactory.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/props/PropertiesFactory.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/props/PropertiesFactory.java Sun Feb 23 10:37:48 2014
@@ -1,36 +1,36 @@
-package org.apache.commons.jcs.utils.props;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Properties;
-
-/**
- * Retrieves properties from a configurable source.
- */
-public interface PropertiesFactory
-{
-    /**
-     * Fetches a set of properties for the specified group.
-     * <p>
-     * @param groupName the group to pull properties from.
-     * @return a properties object.
-     */
-    Properties getProperties( String groupName );
-}
+package org.apache.commons.jcs.utils.props;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Properties;
+
+/**
+ * Retrieves properties from a configurable source.
+ */
+public interface PropertiesFactory
+{
+    /**
+     * Fetches a set of properties for the specified group.
+     * <p>
+     * @param groupName the group to pull properties from.
+     * @return a properties object.
+     */
+    Properties getProperties( String groupName );
+}

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/props/PropertiesFactoryFileImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/props/PropertiesFactoryFileImpl.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/props/PropertiesFactoryFileImpl.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/props/PropertiesFactoryFileImpl.java Sun Feb 23 10:37:48 2014
@@ -1,39 +1,39 @@
-package org.apache.commons.jcs.utils.props;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Properties;
-
-/**
- * Goes to the file system to load a properties file.
- */
-public class PropertiesFactoryFileImpl
-    implements PropertiesFactory
-{
-    /**
-     * Loads the properties using the property loader.
-     * @param groupName property group name
-     * @return Properties
-     */
-    public Properties getProperties( String groupName )
-    {
-        return PropertyLoader.loadProperties( groupName );
-    }
-}
+package org.apache.commons.jcs.utils.props;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Properties;
+
+/**
+ * Goes to the file system to load a properties file.
+ */
+public class PropertiesFactoryFileImpl
+    implements PropertiesFactory
+{
+    /**
+     * Loads the properties using the property loader.
+     * @param groupName property group name
+     * @return Properties
+     */
+    public Properties getProperties( String groupName )
+    {
+        return PropertyLoader.loadProperties( groupName );
+    }
+}

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/threadpool/PoolConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/threadpool/PoolConfiguration.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/threadpool/PoolConfiguration.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/threadpool/PoolConfiguration.java Sun Feb 23 10:37:48 2014
@@ -19,7 +19,6 @@ package org.apache.commons.jcs.utils.thr
  * under the License.
  */
 
-
 /**
  * This object holds configuration data for a thread pool.
  * <p>



Mime
View raw message