myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1485917 [4/4] - in /myfaces/core/trunk: api/src/main/java/javax/faces/application/ api/src/main/java/javax/faces/context/ api/src/main/java/javax/faces/view/ impl/src/main/java/org/apache/myfaces/application/ impl/src/main/java/org/apache/...
Date Fri, 24 May 2013 01:27:33 GMT
Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerSupport.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerSupport.java?rev=1485917&r1=1485916&r2=1485917&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerSupport.java
(original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerSupport.java
Fri May 24 01:27:31 2013
@@ -48,13 +48,32 @@ public abstract class ResourceHandlerSup
     public abstract String calculateResourceBasePath(FacesContext facesContext);
 
     /**
-     * Return an array of resource loaders used to find resources
-     * using the standard. The order of ResourceLoaders define
-     * its precedence. 
+     * Return an array of resource loaders used to find resources.
+     * The order of ResourceLoaders define its precedence. 
      * 
      * @return
      */
     public abstract ResourceLoader[] getResourceLoaders();
+
+    /**
+     * Return an array of resource loaders used to find resources 
+     * associated with a contract. The order of ContractResourceLoaders 
+     * define its precedence. 
+     * 
+     * @since 2.2
+     * @return 
+     */
+    public abstract ContractResourceLoader[] getContractResourceLoaders();
+
+    /**
+     * Return an array of resource loaders used to find resources
+     * that can be located using ResourceHandler.createViewResource().
+     * The order of ResourceLoaders define its precedence. 
+     * 
+     * @since 2.2
+     * @return 
+     */
+    public abstract ResourceLoader[] getViewResourceLoaders();
     
     /**
      * Check if the mapping used is done using extensions (.xhtml, .jsf)

Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceImpl.java?rev=1485917&r1=1485916&r2=1485917&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceImpl.java
(original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceImpl.java
Fri May 24 01:27:31 2013
@@ -35,7 +35,7 @@ import javax.faces.context.FacesContext;
  * @author Leonardo Uribe (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
-public class ResourceImpl extends Resource
+public class ResourceImpl extends Resource implements ContractResource
 {
     protected final static String JAVAX_FACES_LIBRARY_NAME = "javax.faces";
     protected final static String JSF_JS_RESOURCE_NAME = "jsf.js";
@@ -129,6 +129,11 @@ public class ResourceImpl extends Resour
             path = path + (useAmp ? '&' : '?') + "loc=" + _resourceMeta.getLocalePrefix();
             useAmp = true;
         }
+        if (_resourceMeta.getContractName() != null)
+        {
+            path = path + (useAmp ? '&' : '?') + "con=" + _resourceMeta.getContractName();
+            useAmp = true;
+        }
         return facesContext.getApplication().getViewHandler().getResourceURL(facesContext,
path);
     }
 
@@ -275,4 +280,14 @@ public class ResourceImpl extends Resour
     {
         return _resourceMeta;
     }
+
+    public boolean isContractResource()
+    {
+        return _resourceMeta.getContractName() != null;
+    }
+    
+    public String getContractName()
+    {
+        return _resourceMeta.getContractName();
+    }
 }

Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceLoader.java?rev=1485917&r1=1485916&r2=1485917&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceLoader.java
(original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceLoader.java
Fri May 24 01:27:31 2013
@@ -59,6 +59,12 @@ public abstract class ResourceLoader
     
     public abstract ResourceMeta createResourceMeta(String prefix, String libraryName, String
libraryVersion,
             String resourceName, String resourceVersion);
+
+    public ResourceMeta createResourceMeta(String prefix, String libraryName, 
+            String libraryVersion, String resourceName, String resourceVersion, String contractName)
+    {
+        return createResourceMeta(prefix, libraryName, libraryVersion, resourceName, resourceVersion);
+    }
     
     public abstract boolean libraryExists(String libraryName);
     
@@ -66,6 +72,18 @@ public abstract class ResourceLoader
     {
         return (getResourceURL(resourceMeta) != null);
     }
+
+    /*
+    public URL getResourceURL(String resourceId)
+    {
+        throw new UnsupportedOperationException(
+            "An implementation for getResourceURL(String resourceId) method is required for
JSF 2.2");
+    }
+    
+    public boolean resourceIdExists(String resourceId)
+    {
+        return (getResourceURL(resourceId) != null);
+    }*/
     
     private Comparator<String> _versionComparator = null;
 

Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderWrapper.java?rev=1485917&r1=1485916&r2=1485917&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderWrapper.java
(original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderWrapper.java
Fri May 24 01:27:31 2013
@@ -85,6 +85,19 @@ public abstract class ResourceLoaderWrap
         return getWrapped().resourceExists(resourceMeta);
     }
 
+    /*
+    @Override
+    public boolean resourceIdExists(String resourceId)
+    {
+        return getWrapped().resourceIdExists(resourceId);
+    }
+
+    @Override
+    public URL getResourceURL(String resourceId)
+    {
+        return getWrapped().getResourceURL(resourceId);
+    }*/
+
     @Override
     protected Comparator<String> getVersionComparator()
     {

Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceMeta.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceMeta.java?rev=1485917&r1=1485916&r2=1485917&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceMeta.java
(original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceMeta.java
Fri May 24 01:27:31 2013
@@ -40,4 +40,13 @@ public abstract class ResourceMeta
     public abstract String getResourceIdentifier();
     
     public abstract boolean couldResourceContainValueExpressions();
+    
+    /**
+     * @since 2.2
+     * @return 
+     */
+    public String getContractName()
+    {
+        return null;
+    }
 }

Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceMetaImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceMetaImpl.java?rev=1485917&r1=1485916&r2=1485917&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceMetaImpl.java
(original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceMetaImpl.java
Fri May 24 01:27:31 2013
@@ -32,15 +32,23 @@ public class ResourceMetaImpl extends Re
     private final String _libraryVersion;
     private final String _resourceName;
     private final String _resourceVersion;
-    
+    private final String _contractName;
+
     public ResourceMetaImpl(String prefix, String libraryName, String libraryVersion,
             String resourceName, String resourceVersion)
     {
+        this(prefix, libraryName, libraryVersion, resourceName, resourceVersion, null);
+    }
+    
+    public ResourceMetaImpl(String prefix, String libraryName, String libraryVersion,
+            String resourceName, String resourceVersion, String contractName)
+    {
         _prefix = prefix;
         _libraryName = libraryName;
         _libraryVersion = libraryVersion;
         _resourceName = resourceName;
         _resourceVersion = resourceVersion;
+        _contractName = contractName;
     }
 
     public String getLibraryName()
@@ -67,6 +75,11 @@ public class ResourceMetaImpl extends Re
     {
         return _resourceVersion;
     }
+
+    public String getContractName()
+    {
+        return _contractName;
+    }
     
     @Override
     public String getResourceIdentifier()
@@ -125,4 +138,5 @@ public class ResourceMetaImpl extends Re
     {
         return false;
     }
+
 }

Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceValidationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceValidationUtils.java?rev=1485917&r1=1485916&r2=1485917&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceValidationUtils.java
(original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceValidationUtils.java
Fri May 24 01:27:31 2013
@@ -35,6 +35,26 @@ public class ResourceValidationUtils
         return validate(libraryName, allowSlash);
     }
     
+    public static boolean isValidResourceId(String resourceId)
+    {
+        // Follow the same rules as for resourceName, but check resourceId does not
+        // start with '/'
+        return validateResourceName(resourceId, true) && 
+            resourceId.length() > 0 && !(resourceId.charAt(0) != '/');
+    }
+    
+    public static boolean isValidViewResource(String resourceId)
+    {
+        // Follow the same rules as for resourceName, but check resourceId does not
+        // start with '/'
+        return validateResourceName(resourceId, true);
+    }
+    
+    public static boolean isValidContractName(String contractName)
+    {
+        return validate(contractName, false);
+    }    
+    
     public static boolean isValidLocalePrefix(String localePrefix)
     {
         for (int i = 0; i < localePrefix.length(); i++)



Mime
View raw message