Make overriding the built-in url handlers the default and only way. My last commit did remove the performance problems and it looks like this will become spec so we might as well already implement it (FELIX-756).

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@711578 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/URLHandlers.java b/framework/src/main/java/org/apache/felix/framework/URLHandlers.java
index 8253dab..5b4e797 100644
--- a/framework/src/main/java/org/apache/felix/framework/URLHandlers.java
+++ b/framework/src/main/java/org/apache/felix/framework/URLHandlers.java
@@ -66,15 +66,7 @@
 **/
 class URLHandlers implements URLStreamHandlerFactory, ContentHandlerFactory
 {
-    private static final String STREAM_HANDLER_PACKAGE_PROP = "java.protocol.handler.pkgs";
-    private static final String DEFAULT_STREAM_HANDLER_PACKAGE = "sun.net.www.protocol|com.ibm.oti.net.www.protocol|gnu.java.net.protocol|wonka.net|com.acunia.wonka.net|org.apache.harmony.luni.internal.net.www.protocol|weblogic.utils|weblogic.net|javax.net.ssl|COM.newmonics.www.protocols";
-    
-    private static final String CONTENT_HANDLER_PACKAGE_PROP = "java.content.handler.pkgs";
-    private static final String DEFAULT_CONTENT_HANDLER_PACKAGE = "sun.net.www.content|com.ibm.oti.net.www.content|gnu.java.net.content|org.apache.harmony.luni.internal.net.www.content|COM.newmonics.www.content";
-
     private static final SecureAction m_secureAction = new SecureAction();
-    private static final boolean OVERRIDE = m_secureAction.getSystemProperty(
-        "felix.service.urlhandlers.override", "false").equalsIgnoreCase("true");
 
     private static volatile SecurityManagerEx m_sm = null;
     private static volatile URLHandlers m_handler = null;
@@ -316,51 +308,9 @@
             });
         }
 
-        if (!OVERRIDE)
-        {
-            // If there was a custom factory then try to get the handler form it
-            if (m_streamHandlerFactory != this)
-            {
-                handler = 
-                    addToStreamCache(protocol, m_streamHandlerFactory.createURLStreamHandler(protocol));
-    
-                if (handler != null)
-                {
-                    return handler;
-                }
-            }
-            // Check for built-in handlers for the protocol.
-            String pkgs = m_secureAction.getSystemProperty(STREAM_HANDLER_PACKAGE_PROP, "");
-            pkgs = (pkgs.equals(""))
-                ? DEFAULT_STREAM_HANDLER_PACKAGE
-                : pkgs + "|" + DEFAULT_STREAM_HANDLER_PACKAGE;
-    
-            // Iterate over built-in packages.
-            StringTokenizer pkgTok = new StringTokenizer(pkgs, "| ");
-            while (pkgTok.hasMoreTokens())
-            {
-                String pkg = pkgTok.nextToken().trim();
-                String className = pkg + "." + protocol + ".Handler";
-                try
-                {
-                    // If a built-in handler is found then let the
-                    // JRE handle it.
-                    if (m_secureAction.forName(className) != null)
-                    {
-                        return null;
-                    }
-                }
-                catch (Exception ex)
-                {
-                    // This could be a class not found exception or an
-                    // instantiation exception, not much we can do in either
-                    // case other than ignore it.
-                }
-            }
-        }
         // If built-in content handler, then create a proxy handler.
         return addToStreamCache(protocol, new URLHandlersStreamHandlerProxy(protocol, m_secureAction, 
-            (m_streamHandlerFactory != this) ? m_streamHandlerFactory : null, OVERRIDE));
+            (m_streamHandlerFactory != this) ? m_streamHandlerFactory : null));
     }
 
     /**
@@ -387,56 +337,10 @@
         {
             return handler;
         }
-        if (!OVERRIDE)
-        {
-            // If there was a custom factory then try to get the handler form it
-            if (m_contentHandlerFactory != this)
-            {
-                handler = addToContentCache(mimeType, 
-                    m_contentHandlerFactory.createContentHandler(mimeType));
-                
-                if (handler != null)
-                {
-                    return handler;
-                }
-            }
-    
-            // Check for built-in handlers for the mime type.
-            String pkgs = m_secureAction.getSystemProperty(CONTENT_HANDLER_PACKAGE_PROP, "");
-            pkgs = (pkgs.equals(""))
-                ? DEFAULT_CONTENT_HANDLER_PACKAGE
-                : pkgs + "|" + DEFAULT_CONTENT_HANDLER_PACKAGE;
-    
-            // Remove periods, slashes, and dashes from mime type.
-            String fixedType = mimeType.replace('.', '_').replace('/', '.').replace('-', '_');
-    
-            // Iterate over built-in packages.
-            StringTokenizer pkgTok = new StringTokenizer(pkgs, "| ");
-            while (pkgTok.hasMoreTokens())
-            {
-                String pkg = pkgTok.nextToken().trim();
-                String className = pkg + "." + fixedType;
-                try
-                {
-                    // If a built-in handler is found then let the
-                    // JRE handle it.
-                    if (m_secureAction.forName(className) != null)
-                    {
-                        return null;
-                    }
-                }
-                catch (Exception ex)
-                {
-                    // This could be a class not found exception or an
-                    // instantiation exception, not much we can do in either
-                    // case other than ignore it.
-                }
-            }
-        }
-            
+
         return addToContentCache(mimeType, 
             new URLHandlersContentHandlerProxy(mimeType, m_secureAction, 
-            (m_contentHandlerFactory != this) ? m_contentHandlerFactory : null, OVERRIDE));
+            (m_contentHandlerFactory != this) ? m_contentHandlerFactory : null));
     }
 
     private synchronized ContentHandler addToContentCache(String mimeType, ContentHandler handler)
diff --git a/framework/src/main/java/org/apache/felix/framework/URLHandlersContentHandlerProxy.java b/framework/src/main/java/org/apache/felix/framework/URLHandlersContentHandlerProxy.java
index f436ba5..4f956b3 100644
--- a/framework/src/main/java/org/apache/felix/framework/URLHandlersContentHandlerProxy.java
+++ b/framework/src/main/java/org/apache/felix/framework/URLHandlersContentHandlerProxy.java
@@ -62,15 +62,13 @@
     private final Map m_trackerMap = new HashMap();
     private final String m_mimeType;
     private final SecureAction m_action;
-    private final boolean m_override;
 
     public URLHandlersContentHandlerProxy(String mimeType, SecureAction action, 
-        ContentHandlerFactory factory, boolean override)
+        ContentHandlerFactory factory)
     {
         m_mimeType = mimeType;
         m_action = action;
         m_factory = factory;
-        m_override = override;
     }
 
     //
@@ -105,7 +103,7 @@
 
         if (framework == null) 
         {
-            return m_override ? getBuiltIn() : null;
+            return getBuiltIn();
         }
 
         // Get the service tracker for the framework instance or create one.
@@ -159,7 +157,7 @@
                     m_action.getMethod(tracker.getClass(), "getService", null), 
                     tracker, null);
             }
-            if ((result == null) && m_override)
+            if (result == null)
             {
                 result = getBuiltIn();
             }
diff --git a/framework/src/main/java/org/apache/felix/framework/URLHandlersStreamHandlerProxy.java b/framework/src/main/java/org/apache/felix/framework/URLHandlersStreamHandlerProxy.java
index 57a6c54..f4ff511 100644
--- a/framework/src/main/java/org/apache/felix/framework/URLHandlersStreamHandlerProxy.java
+++ b/framework/src/main/java/org/apache/felix/framework/URLHandlersStreamHandlerProxy.java
@@ -105,16 +105,14 @@
     private final String m_protocol;
     private final Object m_service;
     private final SecureAction m_action;
-    private final boolean m_override;
 
     public URLHandlersStreamHandlerProxy(String protocol, SecureAction action, 
-        URLStreamHandlerFactory factory, boolean override)
+        URLStreamHandlerFactory factory)
     {
         m_protocol = protocol;
         m_service = null;
         m_action = action;
         m_factory = factory;
-        m_override = override;
     }
     
     private URLHandlersStreamHandlerProxy(Object service, SecureAction action)
@@ -123,7 +121,6 @@
         m_service = service;
         m_action = action;
         m_factory = null;
-        m_override = false;
     }
 
     //
@@ -377,7 +374,7 @@
 
         if (framework == null) 
         {
-            return m_override ? getBuiltIn() : null;
+            return getBuiltIn();
         }
 
         // Get the service tracker for the framework instance or create one.
@@ -432,7 +429,7 @@
             }
             if (service == null) 
             {
-                return m_override ? getBuiltIn() : null;
+                return getBuiltIn();
             }
             if (service instanceof URLStreamHandlerService)
             {