You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jw...@apache.org on 2010/03/10 19:26:02 UTC

svn commit: r921502 - in /myfaces/trinidad/branches/trinidad-2.0.0.3: trinidad-api/src/main/java/org/apache/myfaces/trinidad/share/io/ trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/

Author: jwaldman
Date: Wed Mar 10 18:26:02 2010
New Revision: 921502

URL: http://svn.apache.org/viewvc?rev=921502&view=rev
Log:
TRINIDAD-1729 provide a hook for for an external decorator of Skin InputStreamProvider
NameResolver - changed the doc a little bit
StyleSheetEntry - figure out which InputStreamProvider to use (FileInputStreamProvider, URLInputStreamProvider, etc) based on the filename, then create the StyleSheetNameResolver. If an InputStreamProvider cannot be created with these methods, then we look at META-INF/services/org.apache.myfaces.trinidad.share.io.NameResolver for a custom NameResolver.
StyleSheetNameResolver - changed to take the InputStreamProvider object created in StyleSheetEntry rather than creating the ISP in this class.

Modified:
    myfaces/trinidad/branches/trinidad-2.0.0.3/trinidad-api/src/main/java/org/apache/myfaces/trinidad/share/io/NameResolver.java
    myfaces/trinidad/branches/trinidad-2.0.0.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/StyleSheetEntry.java
    myfaces/trinidad/branches/trinidad-2.0.0.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/StyleSheetNameResolver.java

Modified: myfaces/trinidad/branches/trinidad-2.0.0.3/trinidad-api/src/main/java/org/apache/myfaces/trinidad/share/io/NameResolver.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-2.0.0.3/trinidad-api/src/main/java/org/apache/myfaces/trinidad/share/io/NameResolver.java?rev=921502&r1=921501&r2=921502&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-2.0.0.3/trinidad-api/src/main/java/org/apache/myfaces/trinidad/share/io/NameResolver.java (original)
+++ myfaces/trinidad/branches/trinidad-2.0.0.3/trinidad-api/src/main/java/org/apache/myfaces/trinidad/share/io/NameResolver.java Wed Mar 10 18:26:02 2010
@@ -47,7 +47,8 @@ public interface NameResolver
 
   /**
    * Return the new NameResolver that should be used to resolve
-   * names relative to a given name.  This function should never
+   * names relative to a given name. For example, if a css file has an @import,
+   * you need to look for the imported file relative to the file. This function should never
    * return null - if the target cannot be resolved, return a
    * resolver that can only support absolute names.
    * @param name the name of the target

Modified: myfaces/trinidad/branches/trinidad-2.0.0.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/StyleSheetEntry.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-2.0.0.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/StyleSheetEntry.java?rev=921502&r1=921501&r2=921502&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-2.0.0.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/StyleSheetEntry.java (original)
+++ myfaces/trinidad/branches/trinidad-2.0.0.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/StyleSheetEntry.java Wed Mar 10 18:26:02 2010
@@ -18,13 +18,26 @@
  */
 package org.apache.myfaces.trinidadinternal.skin;
 
+import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.share.io.InputStreamProvider;
 import org.apache.myfaces.trinidad.share.io.NameResolver;
 
+import org.apache.myfaces.trinidad.util.ClassLoaderUtils;
 import org.apache.myfaces.trinidadinternal.share.io.CachingNameResolver;
+import org.apache.myfaces.trinidadinternal.share.io.FileInputStreamProvider;
+import org.apache.myfaces.trinidadinternal.share.io.URLInputStreamProvider;
 import org.apache.myfaces.trinidadinternal.share.xml.JaxpXMLProvider;
 import org.apache.myfaces.trinidadinternal.share.xml.ParseContextImpl;
 import org.apache.myfaces.trinidadinternal.share.xml.XMLProvider;
@@ -62,7 +75,7 @@ class StyleSheetEntry
     // In order to create the StyleSheetEntry, we need to locate and
     // parse the style sheet file.  We use a NameResolver to use to
     // find the style sheet.
-    NameResolver resolver = _getNameResolver(context);
+    NameResolver resolver = _getNameResolver(context, styleSheetName);
     if (resolver == null)
       return null;
 
@@ -144,6 +157,68 @@ class StyleSheetEntry
   {
     return false;
   }
+  
+  // Gets a File for the specified name, or returns null if no file exists
+  // Try the local styles directory.
+  public static File resolveLocalFile(File localStylesDir, String name)
+  {
+    // Try the local styles directory
+    File file = new File(localStylesDir, name);
+    if (file.exists())
+      return file;
+
+    return null;
+  }
+
+  // Gets an URL for the specified name using ClassLoaderUtils.getResource
+  public static URL resolveClassLoaderURL(String name)
+  {
+    if (name == null)
+      return null;
+    return ClassLoaderUtils.getResource(name);
+
+  }
+
+  // Gets an URL for the non static urls -- that is, urls that could change after the
+  // server has started.
+  public static URL resolveNonStaticURL(String name)
+  {
+    if (name == null)
+      return null;
+    FacesContext fContext = FacesContext.getCurrentInstance();
+    if (fContext != null)
+    {
+      try
+      {
+        if (name.startsWith("http:") ||
+            name.startsWith("https:") ||
+            name.startsWith("file:") ||
+            name.startsWith("ftp:") ||
+            name.startsWith("jar:"))
+        {
+          URL url = new URL(name);
+          if (url != null)
+            return url;
+        }
+        else
+        {
+          String rootName = _getRootName(name);
+          // Return a URL for the application resource mapped to the specified path,
+          // if it exists; otherwise, return null.
+          URL url = fContext.getExternalContext().getResource(rootName);
+          if (url != null)
+            return url;
+        }
+      }
+      catch (MalformedURLException e)
+      {
+        // Eat the MalformedURLException - maybe the name isn't an URL
+        ;
+      }
+    }
+    return null;
+  }  
+  
 
   // Called by CheckModifiedEntry when the style sheet has changed
   void __setDocument(StyleSheetDocument document)
@@ -248,14 +323,36 @@ class StyleSheetEntry
 
 
 
-  // Returns the NameResolver to use for locating style sheet files
+  // Returns the NameResolver to use for locating and loading style sheet file.
+  // Depending upon what the styleSheetName is, we load the file different way: local file,
+  // url, etc.
   private static NameResolver _getNameResolver(
-    StyleContext context
+    StyleContext context,
+    String       styleSheetName
     )
   {
-    // First, get a NameResolver that we can use to resolve
-    // locate the style sheet file.
-    NameResolver resolver = StyleSheetNameResolver.createResolver(context);
+    // get localStylesDirectory
+    File localStylesDir = _getStylesDir(context);
+
+    // Make sure we have some styles directory
+    if ((localStylesDir == null))
+    {
+      _LOG.warning(_STYLES_DIR_ERROR);
+      return null;
+    }
+    NameResolver resolver = null;
+
+    try
+    {
+      resolver =
+          _getNameResolverForStyleSheetFile(context, localStylesDir, styleSheetName);
+    }
+    catch (IOException e)
+    {
+      if (_LOG.isSevere())
+        _LOG.severe("CANNOT_LOAD_STYLESHEET", styleSheetName);
+        _LOG.severe(e);
+    }
     if (resolver == null)
     {
       // If we can't get a NameResolver, something is seriously wrong.
@@ -267,6 +364,80 @@ class StyleSheetEntry
     // can use to check for updates to imported style sheets
     return new CachingNameResolver(resolver, null, true);
   }
+  
+  /**
+   * <p>
+   * This method tries to find the Skin's stylesheet file (e.g., purple-desktop.css). 
+   * It creates a NameResolver object, and it returns the NameResolver object. 
+   * A NameResolver object contains an
+   * InputStreamProvider (this object loads the file) and a sub- NameResolver 
+   * that finds files that are relative to the base file, like an @import file in a .css file.
+   * </p>
+   * <p>
+   * This method tries to find the stylesheet file, first locally, or using an url, or a static url, 
+   * then we create a StyleSheetNameResolver and we pass in the InputStreamProvider we created that
+   * we know can find the file. If we can't find the file any of these ways, then we check 
+   * META-INF/services for a NameResolver service. This is how a third party can customize
+   * how they can find files, by supplying a META-INF/services NameResolver implementation. 
+   * </p>
+   * @param context
+   * @param localStylesDir File the local styles directory
+   * @param filename the stylesheet name
+   * @return NameResolver - either a StyleSheetNameResolver or the META-INF/services NameResolver
+   * implementation. The META-INF/services NameResolver implementation is the way a third party
+   * can customize the way they find and load files.
+   * @throws IOException when the file could not be found in all of the ways we tried to find it.
+   */
+  private static NameResolver _getNameResolverForStyleSheetFile(
+    StyleContext context, 
+    File         localStylesDir,
+    String       filename) throws IOException
+  {
+    InputStreamProvider provider = null;
+    
+    File file = StyleSheetEntry.resolveLocalFile(localStylesDir, filename);
+    if (file != null)
+      provider = new FileInputStreamProvider(file);
+    
+    if (provider == null)
+    {
+      // Gets an URL for the specified name.
+      // Try a few different means to get the file as an url and then create the appropriate
+      // InputStreamProvider from that URL.
+      URL url = resolveNonStaticURL(filename);
+      if (url != null)
+        provider = new URLInputStreamProvider(url);
+      else
+      {
+        // see if it is an URL that can be loaded by the ClassLoader.
+        // We create a StaticURLInputStreamProvider from the url because we consider the
+        // url static because it can't be changed without restarting the server, so we don't
+        // need to check if the source has changed.
+        url = resolveClassLoaderURL(filename);
+        if (url != null)
+          provider = new StaticURLInputStreamProvider(url);
+      }
+    }
+    // If at this point we have found an InputStreamProvider, then we will create a 
+    // StyleSheetNameResolver. Otherwise, we need to check for a custom NameResolver.
+    if (provider != null)
+      return StyleSheetNameResolver.createResolver(context, localStylesDir, provider);
+
+    // If we still can't locate the file at this point, then look for a custom
+    // NameResolver specified as a META-INF\services.
+    NameResolver servicesNameResolver = _loadNameResolverFromServices(filename);
+    if (servicesNameResolver != null)
+    {
+      if (_LOG.isFine())
+      {
+        _LOG.fine("Using the InputStreamProvider from META-INF\\services");
+      }
+      return servicesNameResolver;
+    }
+
+    // If we couldn't locate the file, throw an IOException
+    throw new FileNotFoundException(_getFileNotFoundMessage(localStylesDir, filename));
+  }
 
 
   // Subclass of StyleSheetEntry which recreates the StyleSheetEntry
@@ -301,10 +472,11 @@ class StyleSheetEntry
         __setDocument(null);
 
         // Get a new NameResolver
-        NameResolver resolver = _getNameResolver(context);
+        String name = getStyleSheetName();
+        NameResolver resolver = _getNameResolver(context, name);
         if (resolver != null)
         {
-          String name = getStyleSheetName();
+          
 
           // Recreate the StyleSheetEntry for the styleSheet using the new NameResolver
           // (e.g., if purpleSkin.css
@@ -358,11 +530,153 @@ class StyleSheetEntry
 
     private InputStreamProvider _provider;
   }
+  
 
-  private String              _name;
-  private StyleSheetDocument  _document;
 
+  // Construct error message for the specified file name
+  private static String _getFileNotFoundMessage(File localStylesDir, String name)
+  {
+    StringBuffer buffer = new StringBuffer();
+    buffer.append("Unable to locate style sheet \"");
+    buffer.append(name);
+    buffer.append("\" in ");
+
+    if (localStylesDir != null)
+    {
+      buffer.append("local styles directory (");
+      buffer.append(localStylesDir.getPath());
+      buffer.append("), ");
+    }
+
+    buffer.append("or on the class path.\n");
+    buffer.append("Please be sure that this style sheet is installed.");
+
+    return buffer.toString();
+  }
+
+  // Returns the File corresponding to the styles directory - either
+  // the local directory or the shared directory - depending on the
+  // shared value
+  private static File _getStylesDir(
+    StyleContext context)
+  {
+    String contextPath = context.getGeneratedFilesPath();
+
+    // We only need to look up the shared styles path if the shared
+    // context path is non-null.  If the shared context path is null,
+    // we don't have a shared styles directory (and calling
+    // Configuration.getPath() may throw a DirectoryUnavailableException).
+    if (contextPath == null)
+      return null;
+
+    String stylesPath = contextPath + "/adf/styles";
+
+    // Convert the path to a File
+    File stylesDir = new File(stylesPath);
+
+    // Make sure the directory actually exists
+    if (stylesDir.exists())
+       return stylesDir;
+
+    return null;
+  }
+
+  // Returns a name which can be resolved relative to the
+  // ServletContext root.
+  private static String _getRootName(String name)
+  {
+    // Tack on a starting "/" if the name doesn't already have one -
+    // seems to be required by ServletContext.getRealPath() and
+    // ServletContext.getResource() - at least on OC4J.
+    return (name.startsWith("/")) ? name : ("/" + name);
+  }
+
+  /**
+   * Returns an instance of NameResolver that was set in META-INF\services.
+   * This is used only if the stylesheet cannot be found any other way.
+   * This way third party users can create their own way to find the file e.g., MDS.
+   *
+   * @return a NameResolver instance that has been defined in META-INF\services\
+   * org.apache.myfaces.trinidad.share.io.NameResolver
+  // In this file they will have a line like "org.mycompany.io.MyNameResolverImpl".
+   * null if no NameResolver is found.
+   */
+  static private NameResolver _loadNameResolverFromServices(String name)
+  {
+    // We don't want to check services every time, so instead store it on the applicationMap.
+    FacesContext context = FacesContext.getCurrentInstance();
+    Map<String, Object> appMap = context.getExternalContext().getApplicationMap();
+
+    // Is it stored on the application map already? If so, use it.
+    NameResolver savedResolver = (NameResolver)appMap.get(_SERVICES_RESOLVER_KEY);
+    if (savedResolver != null)
+      return savedResolver;
+
+    List<NameResolver> resolvers = ClassLoaderUtils.getServices(
+                                      _NAME_RESOLVER_CLASS_NAME);
+
+    for (NameResolver customNameResolver : resolvers)
+    {
+      InputStreamProvider provider = null;
+      try
+      {
+        provider = customNameResolver.getProvider(name);
+      }
+      catch (IOException e)
+      {
+        // Log fine message. Try the next factory to get a provider
+        if (_LOG.isFine())
+          _LOG.fine(_SERVICES_RESOLVER_IOEXCEPTION_MSG);       
+      }
+      // Found a provider. So store it away and return it from the method.
+      if (provider != null)
+      {
+        appMap.put(_SERVICES_RESOLVER_KEY, provider);
+        return customNameResolver;
+      }
+    }
+    
+    return null;
+
+  }
+
+  // A subclass of URLInputStreamProvider which never checks for
+  // modifications
+  private static class StaticURLInputStreamProvider
+    extends URLInputStreamProvider
+  {
+    public StaticURLInputStreamProvider(URL url)
+    {
+      super(url);
+    }
+
+    @Override
+    public boolean hasSourceChanged()
+    {
+      return false;
+    }
+  }
+
+  // for META-INF\services\org.apache.myfaces.trinidad.share.io.NameResolver
+  // In this file they will have a line like "org.mycompany.io.MyNameResolverImpl"
+  static private final String _NAME_RESOLVER_CLASS_NAME =
+    NameResolver.class.getName();
+
+  // Error messages
+  private static final String _STYLES_DIR_ERROR =
+    "Could not locate the Trinidad styles directory."
+    + "Please be sure that the Trinidad installable resources are installed.";
+  
+  private static final String _SERVICES_RESOLVER_IOEXCEPTION_MSG =
+    "IOException when calling the META-INF/services NameResolver's getProvider method. " +
+    "Trying next nameResolver.";
+
+  private static final String _SERVICES_RESOLVER_KEY =
+    "org.apache.myfaces.trinidadinternal.skin.SERVICES_RESOLVER_KEY";  
 
   private static final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(StyleSheetEntry.class);
+  
+  private String              _name;
+  private StyleSheetDocument  _document;
 
 }

Modified: myfaces/trinidad/branches/trinidad-2.0.0.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/StyleSheetNameResolver.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-2.0.0.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/StyleSheetNameResolver.java?rev=921502&r1=921501&r2=921502&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-2.0.0.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/StyleSheetNameResolver.java (original)
+++ myfaces/trinidad/branches/trinidad-2.0.0.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/StyleSheetNameResolver.java Wed Mar 10 18:26:02 2010
@@ -42,29 +42,30 @@ import org.apache.myfaces.trinidadintern
 
 /**
  * Package-private utility class used by StyleSheetEntry to
- * locate style sheet source files.  We look for style sheets
- * in both the local and the shared "styles" directory.
+ * locate style sheet source files. The NameResolver in the StyleSheetNameResolver looks for
+ * the imported stylesheets relative to the base stylesheet.
  *
  * @version $Name:  $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/skin/StyleSheetNameResolver.java#0 $) $Date: 10-nov-2005.18:59:02 $
  */
 class StyleSheetNameResolver implements NameResolver
 {
   /**
-   * Creates a NameResolver which can locate style sheets
-   * for the specified StyleContext
+   * Creates a NameResolver which can locate style sheets in the local styles directory. 
+   * This method is called from StyleSheetEntry which loads and parses stylesheets (xss or css).
+   * The localStylesDir has already been checked to be valid before this method is called.
+   * @param context StyleContext
+   * @param localStylesDir File
+   * @param provider InputStreamProvider. This object was created in StyleSheetEntry based on
+   * the best way to load the particular stylesheet file. 
+   * It can be an FileInputStreamProvider, an URLInputStreamProvider, etc.
+   * @return
    */
-  public static NameResolver createResolver(StyleContext context)
-  {
-    File localStylesDir = _getStylesDir(context);
-
-    // Make sure we have some styles directory
-    if ((localStylesDir == null))
-    {
-      _LOG.warning(_STYLES_DIR_ERROR);
-      return null;
-    }
-
-    return new StyleSheetNameResolver(localStylesDir);
+  public static NameResolver createResolver(
+    StyleContext        context, 
+    File                localStylesDir,
+    InputStreamProvider provider)
+  {   
+    return new StyleSheetNameResolver(localStylesDir, provider);
   }
 
   /**
@@ -72,219 +73,68 @@ class StyleSheetNameResolver implements 
    * styles directories.  Note that the constructor is private since
    * StyleSheetEntry always calls createResolver().
    * @param localStylesDirectory The location of the local styles directory
+   * @param provider The InputStreamProvider. e.g., FileInputStreamProvider, URLInputStreamProvider,
+   * etc.
    */
   private StyleSheetNameResolver(
-    File localStylesDirectory
+    File                localStylesDirectory,
+    InputStreamProvider provider
     )
   {
     // We should always have some directory
     assert ((localStylesDirectory != null));
+    
+    // We should always have some provider
+    assert ((provider != null));
+
 
     _localStylesDir = localStylesDirectory;
+    _provider = provider;
 
   }
 
   /**
-   * Implementation of NameResolver.getProvider().
-   * Given the name of the file, create an InputStreamProvider. I
+   * Returns the InputStreamProvider for this StyleSheetNameResolver.
+   * @param name the stylesheet name.
+   * @return the InputStreamProvider. The InputStreamProvider knows how to return an InputStream
+   * of the file, it knows if the source has changed, etc.
+   * @throws IOException
+   * @see InputStreamProvider
    */
   public InputStreamProvider getProvider(String name) throws IOException
   {
-    File file = _resolveLocalFile(name);
-    if (file != null)
-      return new FileInputStreamProvider(file);
-      
-    // Gets an URL for the specified name. 
-    // Try a few different means to get the file as an url and then create the appropriate
-    // InputStreamProvider from that URL.
-    URL url = _resolveNonStaticURL(name);
-    if (url != null)
-      return new URLInputStreamProvider(url);
-    else
-    {
-      // see if it is an URL that can be loaded by the ClassLoader. 
-      // We create a StaticURLInputStreamProvider from the url because we consider the
-      // url static because it can't be changed without restarting the server, so we don't
-      // need to check if the source has changed.
-      url = _resolveClassLoaderURL(name);
-      if (url != null)
-        return new StaticURLInputStreamProvider(url);
-    }
-      
-
-
-    // If we couldn't locate the file, throw an IOException
-    throw new FileNotFoundException(_getFileNotFoundMessage(name));
+    return _provider;
   }
 
   /**
-   * Implementation of NameResolver.getResolver()
+   * Implementation of NameResolver.getResolver(). This gets the file that is relative to
+   * the base file.
+   * @param name  String name of the file that is the imported stylesheet.
+   * @return NameResolver. A resolver that knows how to resolve files relative to a base file.
+   * e.g., DefaultNameResolver
    */
   public NameResolver getResolver(String name)
   {
     URL url = null;
-    File file = _resolveLocalFile(name);
+    File file = StyleSheetEntry.resolveLocalFile(_localStylesDir, name);
     if (file == null)
     {
       // Gets an URL for the specified name. 
       // Try a few different means to get the file as an url: 
       // new URL, ExternalContext's getResource, ClassLoaderUtils getResource
-      
-      url = _resolveNonStaticURL(name);
+
+      url = StyleSheetEntry.resolveNonStaticURL(name);
       if (url == null)
-        url =_resolveClassLoaderURL(name);
+        url =StyleSheetEntry.resolveClassLoaderURL(name);
     }
 
-    // Just use a DefaultNameResolver to resolve relative files
     return new DefaultNameResolver(file, url);
   }
 
-  // Gets a File for the specified name, or returns null if no file exists
-  // Try the local styles directory.
-  private File _resolveLocalFile(String name)
-  {
-    // Try the local styles directory
-    File file = new File(_localStylesDir, name);
-    if (file.exists())
-      return file;
-
-    return null;
-  }
-
-  // Gets an URL for the specified name using ClassLoaderUtils.getResource
-  private URL _resolveClassLoaderURL(String name)
-  {
-    if (name == null)
-      return null;
-    return ClassLoaderUtils.getResource(name);
-    
-  }
-  
-  // Gets an URL for the non static urls -- that is, urls that could change after the 
-  // server has started.
-  private URL _resolveNonStaticURL(String name)
-  {
-    if (name == null)
-      return null;
-    FacesContext fContext = FacesContext.getCurrentInstance();
-    if (fContext != null)
-    {
-      try
-      {
-        if (name.startsWith("http:") ||
-            name.startsWith("https:") ||
-            name.startsWith("file:") ||
-            name.startsWith("ftp:") ||
-            name.startsWith("jar:"))
-        {
-          URL url = new URL(name);
-          if (url != null)
-            return url;
-        }
-        else
-        {
-          String rootName = _getRootName(name);
-          // Return a URL for the application resource mapped to the specified path, 
-          // if it exists; otherwise, return null.
-          URL url = fContext.getExternalContext().getResource(rootName);
-          if (url != null)
-            return url;
-        }
-      }
-      catch (MalformedURLException e)
-      {
-        // Eat the MalformedURLException - maybe the name isn't an URL
-        ;
-      }
-    }
-    return null;
-  }
-
-  // Construct error message for the specified file name
-  private String _getFileNotFoundMessage(String name)
-  {
-    StringBuffer buffer = new StringBuffer();
-    buffer.append("Unable to locate style sheet \"");
-    buffer.append(name);
-    buffer.append("\" in ");
-
-    if (_localStylesDir != null)
-    {
-      buffer.append("local styles directory (");
-      buffer.append(_localStylesDir.getPath());
-      buffer.append("), ");
-    }
-
-    buffer.append("or on the class path.\n");
-    buffer.append("Please be sure that this style sheet is installed.");
-
-    return buffer.toString();
-  }
-
-  // Returns the File corresponding to the styles directory - either
-  // the local directory or the shared directory - depending on the
-  // shared value
-  private static File _getStylesDir(
-    StyleContext context)
-  {
-    String contextPath = context.getGeneratedFilesPath();
-
-    // We only need to look up the shared styles path if the shared
-    // context path is non-null.  If the shared context path is null,
-    // we don't have a shared styles directory (and calling
-    // Configuration.getPath() may throw a DirectoryUnavailableException).
-    if (contextPath == null)
-      return null;
-
-    String stylesPath = contextPath + "/adf/styles";
-
-    // Convert the path to a File
-    File stylesDir = new File(stylesPath);
-
-    // Make sure the directory actually exists
-    if (stylesDir.exists())
-       return stylesDir;
-
-    return null;
-  }
-
-  // Returns a name which can be resolved relative to the
-  // ServletContext root.
-  private static String _getRootName(String name)
-  {
-    // Tack on a starting "/" if the name doesn't already have one -
-    // seems to be required by ServletContext.getRealPath() and
-    // ServletContext.getResource() - at least on OC4J.
-    return (name.startsWith("/")) ? name : ("/" + name);
-  }
-
-
-
-  // A subclass of URLInputStreamProvider which never checks for
-  // modifications
-  private static class StaticURLInputStreamProvider
-    extends URLInputStreamProvider
-  {
-    public StaticURLInputStreamProvider(URL url)
-    {
-      super(url);
-    }
-
-    @Override
-    public boolean hasSourceChanged()
-    {
-      return false;
-    }
-  }
-
-
   private File _localStylesDir;
-
-  // Error messages
-  private static final String _STYLES_DIR_ERROR =
-    "Could not locate the Trinidad styles directory."
-    + "Please be sure that the Trinidad installable resources are installed.";
-
+  private InputStreamProvider _provider;
   private static final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(StyleSheetNameResolver.class);
+  private static final String _SERVICES_PROVIDER_KEY =
+    "org.apache.myfaces.trinidadinternal.skin.SERVICES_PROVIDER_KEY";
 }