felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject svn commit: r711578 - in /felix/trunk/framework/src/main/java/org/apache/felix/framework: URLHandlers.java URLHandlersContentHandlerProxy.java URLHandlersStreamHandlerProxy.java
Date Wed, 05 Nov 2008 14:48:20 GMT
Author: pauls
Date: Wed Nov  5 06:48:19 2008
New Revision: 711578

URL: http://svn.apache.org/viewvc?rev=711578&view=rev
Log:
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).

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlers.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersContentHandlerProxy.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersStreamHandlerProxy.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlers.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlers.java?rev=711578&r1=711577&r2=711578&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlers.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlers.java Wed Nov
 5 06:48:19 2008
@@ -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)

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersContentHandlerProxy.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersContentHandlerProxy.java?rev=711578&r1=711577&r2=711578&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersContentHandlerProxy.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersContentHandlerProxy.java
Wed Nov  5 06:48:19 2008
@@ -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();
             }

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersStreamHandlerProxy.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersStreamHandlerProxy.java?rev=711578&r1=711577&r2=711578&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersStreamHandlerProxy.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersStreamHandlerProxy.java
Wed Nov  5 06:48:19 2008
@@ -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)
             {



Mime
View raw message