Revision: 7763
Author: victormote
Date: 2006-07-07 19:14:44 -0700 (Fri, 07 Jul 2006)
ViewCVS: http://svn.sourceforge.net/foray/?rev=7763&view=rev
Log Message:
-----------
Move HashMap and related code from the abstract class to the only subclass that uses it.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/url/AbstractProtocolRegistration.java
trunk/foray/foray-common/src/java/org/foray/common/url/PropertyProtocolRegistration.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/url/AbstractProtocolRegistration.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/url/AbstractProtocolRegistration.java 2006-07-08 02:07:37 UTC (rev 7762)
+++ trunk/foray/foray-common/src/java/org/foray/common/url/AbstractProtocolRegistration.java 2006-07-08 02:14:44 UTC (rev 7763)
@@ -27,8 +27,6 @@
package org.foray.common.url;
import java.net.URLStreamHandler;
-import java.util.HashMap;
-import java.util.Map;
/**
* Abstract implementation of ProtocolHandlerRegistry which factorizes out
@@ -39,14 +37,6 @@
implements ProtocolRegistrationStrategy {
/**
- * Map of already registered protocols.
- * The key is a String containing the protocol name.
- * The value is the {@link URLStreamHandler} which should be used for that
- * protocol.
- */
- protected Map protocols = new HashMap();
-
- /**
* Package-private constructor. To obtain an instance of this class, use
* the {@link ProtocolRegistrationBroker#getRegistry()} method.
*/
@@ -60,7 +50,7 @@
abstract void doRegister(String protocol, URLStreamHandler handler);
public synchronized void registerProtocolHandler(String protocol,
- URLStreamHandler handler) {
+ URLStreamHandler handler) {
if (protocol == null) {
throw new IllegalArgumentException("Cannot register a null "
+ "protocol.");
@@ -69,9 +59,7 @@
throw new IllegalArgumentException("Cannot register a null "
+ "URLStreamHandler.");
}
- if (!this.protocols.containsKey(protocol)) {
- this.protocols.put(protocol, handler);
- doRegister(protocol, handler);
- }
+ doRegister(protocol, handler);
}
+
}
Modified: trunk/foray/foray-common/src/java/org/foray/common/url/PropertyProtocolRegistration.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/url/PropertyProtocolRegistration.java 2006-07-08 02:07:37 UTC (rev 7762)
+++ trunk/foray/foray-common/src/java/org/foray/common/url/PropertyProtocolRegistration.java 2006-07-08 02:14:44 UTC (rev 7763)
@@ -27,6 +27,8 @@
package org.foray.common.url;
import java.net.URLStreamHandler;
+import java.util.HashMap;
+import java.util.Map;
import java.util.StringTokenizer;
/**
@@ -37,6 +39,14 @@
extends AbstractProtocolRegistration {
/**
+ * Map of already registered protocols.
+ * The key is a String containing the protocol name.
+ * The value is the {@link URLStreamHandler} which should be used for that
+ * protocol.
+ */
+ protected Map protocols = new HashMap();
+
+ /**
* Package-private constructor.
* @see ProtocolRegistrationBroker#getRegistry
*/
@@ -44,7 +54,10 @@
}
void doRegister(String protocol, URLStreamHandler handler) {
- propertyRegistration(protocol, handler);
+ if (! this.protocols.containsKey(protocol)) {
+ this.protocols.put(protocol, handler);
+ propertyRegistration(protocol, handler);
+ }
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|