geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r767241 - /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/namespace/NamespaceHandlerRegistryImpl.java
Date Tue, 21 Apr 2009 17:57:37 GMT
Author: gnodet
Date: Tue Apr 21 17:57:37 2009
New Revision: 767241

URL: http://svn.apache.org/viewvc?rev=767241&view=rev
Log:
Extract method for cleaner code

Modified:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/namespace/NamespaceHandlerRegistryImpl.java

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/namespace/NamespaceHandlerRegistryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/namespace/NamespaceHandlerRegistryImpl.java?rev=767241&r1=767240&r2=767241&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/namespace/NamespaceHandlerRegistryImpl.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/namespace/NamespaceHandlerRegistryImpl.java
Tue Apr 21 17:57:37 2009
@@ -86,6 +86,18 @@
 
     public void registerHandler(NamespaceHandler handler, Map properties) throws Exception
{
         Object ns = properties != null ? properties.get(NAMESPACE) : null;
+        URI[] namespaces = getNamespaces(ns);
+        for (URI uri : namespaces) {
+            if (handlers.containsKey(uri)) {
+                throw new IllegalArgumentException("A NamespaceHandler service is already
registered for namespace " + uri);
+            }
+        }
+        for (URI uri : namespaces) {
+            handlers.put(uri, handler);
+        }
+    }
+
+    private URI[] getNamespaces(Object ns) {
         URI[] namespaces;
         if (ns == null) {
             throw new IllegalArgumentException("NamespaceHandler service does not have an
associated " + NAMESPACE + " property defined");
@@ -115,14 +127,7 @@
         } else {
             throw new IllegalArgumentException("NamespaceHandler service has an associated
" + NAMESPACE + " property defined which can not be converted to an array of URI");
         }
-        for (URI uri : namespaces) {
-            if (handlers.containsKey(uri)) {
-                throw new IllegalArgumentException("A NamespaceHandler service is already
registered for namespace " + uri);
-            }
-        }
-        for (URI uri : namespaces) {
-            handlers.put(uri, handler);
-        }
+        return namespaces;
     }
 
     public void unregisterHandler(NamespaceHandler handler, Map properties) throws Exception
{



Mime
View raw message