Author: nbelaevski
Date: 2010-05-19 20:10:53 -0400 (Wed, 19 May 2010)
New Revision: 17151
Added:
root/core/trunk/api/src/main/java/org/richfaces/resource/DynamicResource.java
root/core/trunk/impl/src/main/java/org/richfaces/resource/LegacyResourceCodec.java
Removed:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.Base2WayGradient.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.BaseGradient.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.CustomizeableGradient.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.GradientA.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.gradientimages.ButtonGradientImage.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.gradientimages.ButtonInverseGradientImage.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.gradientimages.HeaderGradientImage.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.gradientimages.HeaderInverseGradientImage.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.gradientimages.InputGradientImage.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.gradientimages.MenuGradientImage.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.gradientimages.MenuInverseGradientImage.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.gradientimages.TabGradientImage.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.gradientimages.TabInverseGradientImage.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.images.BaseControlBackgroundImage.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.images.ButtonBackgroundImage.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.images.ButtonDisabledBackgroundImage.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.images.GradientAlignment.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.images.GradientType.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.images.InputBackgroundImage.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.images.StandardButtonBgImage.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.images.StandardButtonPressedBgImage.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.resource.AnimatedTestResource.resource.properties
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.resource.TestResource2.resource.properties
root/core/trunk/impl/src/test/resources/META-INF/org.richfaces.resource.CacheableResourceImpl.resource.properties
root/core/trunk/impl/src/test/resources/META-INF/org.richfaces.resource.NonCacheableResourceImpl.resource.properties
root/core/trunk/impl/src/test/resources/META-INF/org.richfaces.resource.StateHolderResourceImpl.resource.properties
root/core/trunk/impl/src/test/resources/META-INF/org.richfaces.resource.VersionedResourceImpl.resource.properties
Modified:
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/CustomizeableGradient.java
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/CancelControlIcon.java
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java
root/core/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java
root/core/trunk/impl/src/main/java/org/richfaces/resource/DefaultResourceCodec.java
root/core/trunk/impl/src/main/java/org/richfaces/resource/ResourceCodec.java
root/core/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java
root/core/trunk/impl/src/main/java/org/richfaces/resource/TestResource2.java
root/core/trunk/impl/src/main/java/org/richfaces/util/Util.java
root/core/trunk/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java
root/core/trunk/impl/src/test/java/org/richfaces/resource/CacheableResourceImpl.java
root/core/trunk/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java
root/core/trunk/impl/src/test/java/org/richfaces/resource/StateHolderResourceImpl.java
root/core/trunk/impl/src/test/java/org/richfaces/resource/VersionedResourceImpl.java
root/core/trunk/impl/src/test/resources/resources/full.css
root/core/trunk/impl/src/test/resources/resources/importedEL.css
root/core/trunk/impl/src/test/resources/resources/resource.css
Log:
https://jira.jboss.org/browse/RF-8665
Added: root/core/trunk/api/src/main/java/org/richfaces/resource/DynamicResource.java
===================================================================
--- root/core/trunk/api/src/main/java/org/richfaces/resource/DynamicResource.java
(rev 0)
+++
root/core/trunk/api/src/main/java/org/richfaces/resource/DynamicResource.java 2010-05-20
00:10:53 UTC (rev 17151)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.resource;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.TYPE)
+@Inherited
+public @interface DynamicResource {
+
+}
Modified:
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java 2010-05-19
23:16:19 UTC (rev 17150)
+++
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java 2010-05-20
00:10:53 UTC (rev 17151)
@@ -21,14 +21,6 @@
package org.richfaces.renderkit.html;
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.util.NumericDataInputStream;
-import org.ajax4jsf.util.NumericDataOutputStream;
-import org.richfaces.renderkit.html.images.GradientType;
-import org.richfaces.renderkit.html.images.GradientType.BiColor;
-import org.richfaces.skin.Skin;
-
-import javax.faces.context.FacesContext;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
@@ -37,10 +29,21 @@
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.util.NumericDataInputStream;
+import org.ajax4jsf.util.NumericDataOutputStream;
+import org.richfaces.renderkit.html.images.GradientType;
+import org.richfaces.renderkit.html.images.GradientType.BiColor;
+import org.richfaces.resource.DynamicResource;
+import org.richfaces.skin.Skin;
+
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
* created 02.02.2007
*/
+@DynamicResource
public class BaseGradient extends Java2Dresource {
protected Integer headerBackgroundColor;
Modified:
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/CustomizeableGradient.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/CustomizeableGradient.java 2010-05-19
23:16:19 UTC (rev 17150)
+++
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/CustomizeableGradient.java 2010-05-20
00:10:53 UTC (rev 17151)
@@ -21,14 +21,6 @@
package org.richfaces.renderkit.html;
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.util.NumericDataInputStream;
-import org.richfaces.renderkit.html.images.GradientAlignment;
-import org.richfaces.renderkit.html.images.GradientType;
-import org.richfaces.renderkit.html.images.GradientType.BiColor;
-import org.richfaces.skin.Skin;
-
-import javax.faces.context.FacesContext;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
@@ -38,10 +30,21 @@
import java.awt.geom.Rectangle2D;
import java.util.Map;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.util.NumericDataInputStream;
+import org.richfaces.renderkit.html.images.GradientAlignment;
+import org.richfaces.renderkit.html.images.GradientType;
+import org.richfaces.renderkit.html.images.GradientType.BiColor;
+import org.richfaces.resource.DynamicResource;
+import org.richfaces.skin.Skin;
+
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
* created 02.02.2007
*/
+@DynamicResource
public class CustomizeableGradient extends Java2Dresource {
private static final String BASE_COLOR = "baseColor";
Modified:
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/CancelControlIcon.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/CancelControlIcon.java 2010-05-19
23:16:19 UTC (rev 17150)
+++
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/CancelControlIcon.java 2010-05-20
00:10:53 UTC (rev 17151)
@@ -20,23 +20,26 @@
*/
package org.richfaces.renderkit.html.images;
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.util.HtmlColor;
-import org.ajax4jsf.util.NumericDataInputStream;
-
-import javax.faces.context.FacesContext;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.util.HtmlColor;
+import org.ajax4jsf.util.NumericDataInputStream;
+import org.richfaces.resource.DynamicResource;
+
/**
* implementation of the default CANCEL icon renderer
*
* @author Anton Belevich
* @since 3.2.0
*/
+@DynamicResource
public class CancelControlIcon extends Java2Dresource {
protected static final String ALTERNATE_COLOR = "#ED6161";
Modified:
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java 2010-05-19
23:16:19 UTC (rev 17150)
+++
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java 2010-05-20
00:10:53 UTC (rev 17151)
@@ -21,11 +21,14 @@
package org.richfaces.renderkit.html.images;
+import java.awt.Color;
+import java.awt.Dimension;
+
import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceContext;
+import org.richfaces.resource.DynamicResource;
-import java.awt.*;
-
+@DynamicResource
public abstract class OneColorBasedResource extends Java2Dresource {
private Dimension dimension;
Modified:
root/core/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java 2010-05-19
23:16:19 UTC (rev 17150)
+++
root/core/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java 2010-05-20
00:10:53 UTC (rev 17151)
@@ -204,7 +204,7 @@
String resourceVersion = getVersion();
String resourceUri = ResourceHandlerImpl.RICHFACES_RESOURCE_IDENTIFIER
- + resourceCodec.encodeResource(resourceName, resourceData, resourceVersion);
+ + resourceCodec.encodeResource(context, resourceName, resourceData,
resourceVersion);
resourceUri = Util.encodeResourceURL(context, resourceUri);
Modified:
root/core/trunk/impl/src/main/java/org/richfaces/resource/DefaultResourceCodec.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/resource/DefaultResourceCodec.java 2010-05-19
23:16:19 UTC (rev 17150)
+++
root/core/trunk/impl/src/main/java/org/richfaces/resource/DefaultResourceCodec.java 2010-05-20
00:10:53 UTC (rev 17151)
@@ -21,31 +21,109 @@
package org.richfaces.resource;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
import org.richfaces.util.Util;
final class DefaultResourceCodec implements ResourceCodec {
+
+ private static final String RESOURCE_VERSION_PARAM = "v";
+
+ private static final String RESOURCE_DATA_BYTES_ARRAY_PARAM = "db";
+
+ private static final String RESOURCE_DATA_OBJECT_PARAM = "do";
+
private static final ResourceCodec CODEC = new DefaultResourceCodec();
private DefaultResourceCodec() {
}
- public String decodeResourceName(String resourceKey) {
- return Util.getResourceName(resourceKey);
+ public String decodeResourceName(FacesContext context, String requestPath) {
+ return requestPath;
}
- public Object decodeResourceData(String resourceKey) {
- return Util.getResourceData(resourceKey);
+ public Object decodeResourceData(FacesContext context, String requestPath) {
+ Map<String, String> paramMap =
context.getExternalContext().getRequestParameterMap();
+
+ String encodedData = paramMap.get(RESOURCE_DATA_BYTES_ARRAY_PARAM);
+ if (encodedData != null) {
+ return Util.decodeBytesData(encodedData);
+ } else {
+ encodedData = paramMap.get(RESOURCE_DATA_OBJECT_PARAM);
+ if (encodedData != null) {
+ return Util.decodeObjectData(encodedData);
+ }
+ }
+
+ return null;
}
public static ResourceCodec getInstance() {
return CODEC;
}
- public String decodeResourceVersion(String resourceKey) {
- return Util.getResourceVersion(resourceKey);
+ public String decodeResourceVersion(FacesContext context, String requestPath) {
+ return
context.getExternalContext().getRequestParameterMap().get(RESOURCE_VERSION_PARAM);
}
- public String encodeResource(String resourceName, Object resourceData, String
resourceVersion) {
- return Util.encodeResourceData(resourceName, resourceData, resourceVersion);
+ public String encodeResource(FacesContext context, String resourceName, Object
resourceData, String resourceVersion) {
+ boolean parameterAppended = false;
+
+ StringBuilder sb = new StringBuilder();
+ sb.append(resourceName);
+
+ if (resourceVersion != null && resourceVersion.length() != 0) {
+ if (!parameterAppended) {
+ sb.append('?');
+ parameterAppended = true;
+ }
+
+ sb.append(RESOURCE_VERSION_PARAM);
+ sb.append('=');
+ sb.append(Util.encodeURIQueryPart(resourceVersion));
+ }
+
+ if (resourceData != null) {
+ String encodedDataString = null;
+ boolean isBytesArray = false;
+
+ if (resourceData instanceof byte[]) {
+ isBytesArray = true;
+ encodedDataString = Util.encodeBytesData((byte[]) resourceData);
+ } else {
+ encodedDataString = Util.encodeObjectData(resourceData);
+ }
+
+ if (encodedDataString != null) {
+ if (!parameterAppended) {
+ sb.append('?');
+ parameterAppended = true;
+ } else {
+ sb.append('&');
+ }
+
+ sb.append(isBytesArray ? RESOURCE_DATA_BYTES_ARRAY_PARAM :
RESOURCE_DATA_OBJECT_PARAM);
+ sb.append('=');
+ sb.append(Util.encodeURIQueryPart(encodedDataString));
+ }
+ }
+
+ return sb.toString();
}
+
+ public String getResourceKey(FacesContext context, String requestPath) {
+ Map<String, String> paramMap =
context.getExternalContext().getRequestParameterMap();
+
+ String resourceDataString = paramMap.get(RESOURCE_DATA_BYTES_ARRAY_PARAM);
+ if (resourceDataString == null) {
+ resourceDataString = paramMap.get(RESOURCE_DATA_OBJECT_PARAM);
+ }
+
+ String resourceVersionString = paramMap.get(RESOURCE_VERSION_PARAM);
+
+ return encodeResource(context, decodeResourceName(context, requestPath),
+ resourceDataString, resourceVersionString);
+ }
}
Added: root/core/trunk/impl/src/main/java/org/richfaces/resource/LegacyResourceCodec.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/resource/LegacyResourceCodec.java
(rev 0)
+++
root/core/trunk/impl/src/main/java/org/richfaces/resource/LegacyResourceCodec.java 2010-05-20
00:10:53 UTC (rev 17151)
@@ -0,0 +1,59 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.resource;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.util.Util;
+
+final class LegacyResourceCodec implements ResourceCodec {
+
+ private static final ResourceCodec CODEC = new LegacyResourceCodec();
+
+ private LegacyResourceCodec() {
+ }
+
+ public String decodeResourceName(FacesContext context, String requestPath) {
+ return Util.legacyDecodeResourceName(requestPath);
+ }
+
+ public Object decodeResourceData(FacesContext context, String requestPath) {
+ return Util.legacyDecodeResourceData(requestPath);
+ }
+
+ public static ResourceCodec getInstance() {
+ return CODEC;
+ }
+
+ public String decodeResourceVersion(FacesContext context, String requestPath) {
+ return Util.legacyDecodeResourceVersion(requestPath);
+ }
+
+ public String encodeResource(FacesContext context, String resourceName, Object
resourceData, String resourceVersion) {
+ return Util.legacyEncodeResourceData(resourceName, resourceData,
resourceVersion);
+ }
+
+ public String getResourceKey(FacesContext context, String requestPath) {
+ return requestPath;
+ }
+}
+
Modified: root/core/trunk/impl/src/main/java/org/richfaces/resource/ResourceCodec.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/resource/ResourceCodec.java 2010-05-19
23:16:19 UTC (rev 17150)
+++
root/core/trunk/impl/src/main/java/org/richfaces/resource/ResourceCodec.java 2010-05-20
00:10:53 UTC (rev 17151)
@@ -3,16 +3,21 @@
*/
package org.richfaces.resource;
+import javax.faces.context.FacesContext;
+
/**
* @author Nick Belaevski
* @since 4.0
*/
public interface ResourceCodec {
- public String encodeResource(String resourceName, Object resourceData, String
resourceVersion);
+
+ public String encodeResource(FacesContext context, String resourceName, Object
resourceData, String resourceVersion);
- public String decodeResourceName(String resourceKey);
+ public String decodeResourceName(FacesContext context, String requestPath);
- public Object decodeResourceData(String resourceKey);
+ public Object decodeResourceData(FacesContext context, String requestPath);
- public String decodeResourceVersion(String resourceKey);
+ public String decodeResourceVersion(FacesContext context, String requestPath);
+
+ public String getResourceKey(FacesContext context, String requestPath);
}
Modified:
root/core/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java 2010-05-19
23:16:19 UTC (rev 17150)
+++
root/core/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java 2010-05-20
00:10:53 UTC (rev 17151)
@@ -44,6 +44,7 @@
import org.ajax4jsf.cache.Cache;
import org.ajax4jsf.cache.CacheManager;
import org.ajax4jsf.resource.Java2Dresource;
+import org.richfaces.application.ServiceTracker;
import org.richfaces.context.AttributesContext;
import org.richfaces.context.SingletonsContext;
import org.richfaces.log.RichfacesLogger;
@@ -60,7 +61,6 @@
public static final String RESOURCE_CACHE_NAME = ResourceHandlerImpl.class.getName()
+ ":CACHE";
public static final String HANDLER_START_TIME_ATTRIBUTE =
ResourceHandlerImpl.class.getName() + ":StartTime";
- private static final String RESOURCE_CODEC_ATTRIBUTE_NAME =
ResourceHandlerImpl.class.getName() + ":ResourceCodec";
private static final Logger LOGGER = RichfacesLogger.RESOURCE.getLogger();
// TODO - review - do we need this?
@@ -110,19 +110,12 @@
protected static void setResourceCodec(ResourceCodec codec) {
FacesContext facesContext = FacesContext.getCurrentInstance();
- Map<String, Object> applicationMap =
facesContext.getExternalContext().getApplicationMap();
- Object oldCodec = applicationMap.put(RESOURCE_CODEC_ATTRIBUTE_NAME, codec);
-
- if ((oldCodec != null) && (codec != null) &&
!oldCodec.equals(codec)
- && facesContext.isProjectStage(ProjectStage.Development)) {
- LOGGER.warn("Resource codec should be typically set once per application
lifetime");
- }
+
+ ServiceTracker.setService(facesContext, ResourceCodec.class, codec);
}
public static ResourceCodec getResourceCodec(FacesContext context) {
- Map<String, Object> applicationMap =
context.getExternalContext().getApplicationMap();
- ResourceCodec resourceCodec = (ResourceCodec)
applicationMap.get(RESOURCE_CODEC_ATTRIBUTE_NAME);
-
+ ResourceCodec resourceCodec = ServiceTracker.getService(context,
ResourceCodec.class);
if (resourceCodec == null) {
resourceCodec = DefaultResourceCodec.getInstance();
}
@@ -130,7 +123,7 @@
return resourceCodec;
}
- protected static String getResourceKey(FacesContext context) {
+ protected static String getResourcePathFromRequest(FacesContext context) {
String resourceName = Util.decodeResourceURL(context);
if (resourceName != null) {
@@ -140,7 +133,6 @@
return null;
}
} else {
-
LOGGER.warn("Resource key not found" + resourceName);
return null;
}
@@ -150,14 +142,14 @@
Boolean resourceRequest =
BooleanRequestStateVariable.ResourceRequest.get(context);
if (resourceRequest == null) {
- String resourceKey = getResourceKey(context);
+ String resourcePath = getResourcePathFromRequest(context);
// TODO handle exclusions
- resourceRequest = (resourceKey != null) && (resourceKey.length() >
0);
+ resourceRequest = (resourcePath != null) && (resourcePath.length()
> 0);
BooleanRequestStateVariable.ResourceRequest.set(context, resourceRequest);
if (LOGGER.isDebugEnabled() && resourceRequest) {
- LOGGER.debug(MessageFormat.format("Resource request detected:
{0}", resourceKey));
+ LOGGER.debug(MessageFormat.format("Resource request detected:
{0}", resourcePath));
}
}
@@ -222,15 +214,20 @@
@Override
public void handleResourceRequest(FacesContext context) throws IOException {
if (isThisHandlerResourceRequest(context)) {
- String resourceKey = getResourceKey(context);
+ ResourceCodec resourceCodec = ResourceHandlerImpl.getResourceCodec(context);
+ String resourcePath = getResourcePathFromRequest(context);
+
+ assert (resourcePath != null) && (resourcePath.length() != 0);
+
+ String resourceKey = resourceCodec.getResourceKey(context, resourcePath);
+
assert (resourceKey != null) && (resourceKey.length() != 0);
Resource resource = lookupInCache(context, resourceKey);
if (resource == null) {
- ResourceCodec resourceCodec =
ResourceHandlerImpl.getResourceCodec(context);
- String resourceName = resourceCodec.decodeResourceName(resourceKey);
+ String resourceName = resourceCodec.decodeResourceName(context,
resourcePath);
if ((resourceName == null) || (resourceName.length() == 0)) {
logMissingResource(context, resourceKey);
@@ -239,14 +236,16 @@
return;
}
- if (isResourceExists(resourceName)) {
- Map<String, String> params =
Util.parseResourceParameters(resourceKey);
- resource = createHandlerDependentResource(resourceName, params);
- }
- if (resource == null &&
resourceName.lastIndexOf(".ecss") != -1) {
+ if (resourceName.lastIndexOf(".ecss") != -1) {
resource = new CompiledCSSResource(resourceName);
}
+
if (resource == null) {
+ resource = createHandlerDependentResource(resourceName,
+ context.getExternalContext().getRequestParameterMap());
+ }
+
+ if (resource == null) {
logMissingResource(context, resourceName);
sendResourceNotFound(context);
@@ -256,7 +255,7 @@
if (resource instanceof VersionedResource) {
VersionedResource versionedResource = (VersionedResource) resource;
String existingVersion = versionedResource.getVersion();
- String requestedVersion =
resourceCodec.decodeResourceVersion(resourceKey);
+ String requestedVersion =
resourceCodec.decodeResourceVersion(context, resourcePath);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
@@ -277,7 +276,7 @@
if (resource instanceof StateHolder) {
StateHolder stateHolder = (StateHolder) resource;
- Object decodedData = resourceCodec.decodeResourceData(resourceKey);
+ Object decodedData = resourceCodec.decodeResourceData(context,
resourcePath);
if (LOGGER.isDebugEnabled()) {
if (decodedData != null) {
@@ -401,29 +400,6 @@
}
}
- protected static boolean isResourceExists(String resourceName) {
- boolean result = false;
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
-
- if (contextClassLoader != null) {
-
- // TODO resource marker extension name?
- URL resourceMarkerUrl = contextClassLoader.getResource("META-INF/"
+ resourceName + ".resource.properties");
-
- result = resourceMarkerUrl != null;
-
- if (LOGGER.isDebugEnabled()) {
- if (result) {
- LOGGER.debug(MessageFormat.format("Marker file for {0} resource
found in classpath", resourceName));
- } else {
- LOGGER.debug(MessageFormat.format("Marker file for {0} resource
does not exist", resourceName));
- }
- }
- }
-
- return result;
- }
-
/**
* Should be called only if {@link #isResourceExists(String)} returns
<code>true</code>
*
@@ -437,9 +413,40 @@
if (contextClassLoader != null) {
try {
- Class<?> resourceClass = Class.forName(resourceName, false,
contextClassLoader);
+ Class<?> loadedClass = Class.forName(resourceName, false,
contextClassLoader);
+
+ Class<? extends Resource> resourceClass =
loadedClass.asSubclass(Resource.class);
+
+ boolean legitimateResource = false;
+
+ DynamicResource annotation =
resourceClass.getAnnotation(DynamicResource.class);
+ legitimateResource = (annotation != null);
+ if (legitimateResource) {
+ LOGGER.debug(
+ MessageFormat.format("Dynamic resource annotation is present
on resource class {0}", resourceName));
+ } else {
+ LOGGER.debug(
+ MessageFormat.format("Dynamic resource annotation is not
present on resource class {0}", resourceName));
+ }
+
+ if (!legitimateResource) {
+ // TODO resource marker extension name?
+ URL resourceMarkerUrl =
contextClassLoader.getResource("META-INF/" + resourceName +
".resource.properties");
- if (Resource.class.isAssignableFrom(resourceClass)) {
+ legitimateResource = resourceMarkerUrl != null;
+
+ if (LOGGER.isDebugEnabled()) {
+ if (legitimateResource) {
+ LOGGER.debug(
+ MessageFormat.format("Marker file for {0} resource
found in classpath", resourceName));
+ } else {
+ LOGGER.debug(
+ MessageFormat.format("Marker file for {0} resource
does not exist", resourceName));
+ }
+ }
+ }
+
+ if (legitimateResource) {
resource = (Resource) resourceClass.newInstance();
resource.setResourceName(resourceName);
if (resource instanceof Java2Dresource) {
@@ -451,11 +458,11 @@
LOGGER.debug(MessageFormat.format("Successfully created
instance of {0} resource",
resourceName));
}
- } else {
- throw new ClassCastException(resourceClass.getName());
}
- } catch (Throwable t) {
- logResourceProblem(FacesContext.getCurrentInstance(), t, "Error
creating resource {0}", resourceName);
+ } catch (Exception e) {
+ logResourceProblem(FacesContext.getCurrentInstance(), e, "Error
creating resource {0}", resourceName);
+ } catch (LinkageError e) {
+ logResourceProblem(FacesContext.getCurrentInstance(), e, "Error
creating resource {0}", resourceName);
}
}
@@ -467,13 +474,16 @@
Resource result = null;
Map<String, String> params = Util.parseResourceParameters(resourceName);
resourceName = extractParametersFromResourceName(resourceName);
- if ((resourceName != null) && ((libraryName == null) ||
(libraryName.length() == 0))
- && isResourceExists(resourceName)) {
- result = createHandlerDependentResource(resourceName, params);
- } else if (resourceName.lastIndexOf(".ecss") != -1) {
+ if (resourceName.lastIndexOf(".ecss") != -1) {
result = new CompiledCSSResource(resourceName);
} else {
- result = defaultHandler.createResource(resourceName, libraryName,
contentType);
+ if ((resourceName != null) && ((libraryName == null) ||
(libraryName.length() == 0))) {
+ result = createHandlerDependentResource(resourceName, params);
+ }
+
+ if (result == null) {
+ result = defaultHandler.createResource(resourceName, libraryName,
contentType);
+ }
}
return result;
Modified: root/core/trunk/impl/src/main/java/org/richfaces/resource/TestResource2.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/resource/TestResource2.java 2010-05-19
23:16:19 UTC (rev 17150)
+++
root/core/trunk/impl/src/main/java/org/richfaces/resource/TestResource2.java 2010-05-20
00:10:53 UTC (rev 17151)
@@ -21,6 +21,13 @@
package org.richfaces.resource;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+
+import javax.faces.context.FacesContext;
+
import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.util.HtmlColor;
import org.ajax4jsf.util.NumericDataInputStream;
@@ -29,9 +36,7 @@
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
-import javax.faces.context.FacesContext;
-import java.awt.*;
-
+@DynamicResource
public class TestResource2 extends Java2Dresource {
private static final int MASK_FOR_COLOR_WITHOUT_ALPHA_CHANNEL = 0x00FFFFFF;
Modified: root/core/trunk/impl/src/main/java/org/richfaces/util/Util.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/util/Util.java 2010-05-19 23:16:19
UTC (rev 17150)
+++ root/core/trunk/impl/src/main/java/org/richfaces/util/Util.java 2010-05-20 00:10:53
UTC (rev 17151)
@@ -41,15 +41,6 @@
package org.richfaces.util;
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.util.base64.Codec;
-import org.richfaces.log.RichfacesLogger;
-import org.slf4j.Logger;
-
-import javax.faces.FacesException;
-import javax.faces.application.ViewHandler;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -61,9 +52,12 @@
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetEncoder;
import java.text.Format;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -77,6 +71,16 @@
import java.util.zip.Deflater;
import java.util.zip.Inflater;
+import javax.faces.FacesException;
+import javax.faces.application.ViewHandler;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.util.base64.Codec;
+import org.richfaces.log.RichfacesLogger;
+import org.slf4j.Logger;
+
/**
* @author Nick Belaevski
* @since 4.0
@@ -205,41 +209,96 @@
}
}
- public static String encodeResourceData(String resourceName, Object storeData, String
resourceVersion) {
+ public static byte[] decodeBytesData(String encodedData) {
+ byte[] objectArray = null;
+
+ try {
+ byte[] dataArray = encodedData.getBytes("ISO-8859-1");
+
+ objectArray = decrypt(dataArray);
+ } catch (UnsupportedEncodingException e1) {
+
+ // default encoding always presented.
+ }
+
+ return objectArray;
+ }
+
+ public static Object decodeObjectData(String encodedData) {
+ byte[] objectArray = decodeBytesData(encodedData);
+
+ try {
+ ObjectInputStream in = new ObjectInputStream(new
ByteArrayInputStream(objectArray));
+
+ return in.readObject();
+ } catch (StreamCorruptedException e) {
+ RESOURCE_LOGGER.error(Messages.getMessage(Messages.STREAM_CORRUPTED_ERROR),
e);
+ } catch (IOException e) {
+
RESOURCE_LOGGER.error(Messages.getMessage(Messages.DESERIALIZE_DATA_INPUT_ERROR), e);
+ } catch (ClassNotFoundException e) {
+
RESOURCE_LOGGER.error(Messages.getMessage(Messages.DATA_CLASS_NOT_FOUND_ERROR), e);
+ }
+
+ return null;
+ }
+
+ public static String encodeBytesData(byte[] data) {
+ if (data != null) {
+ try {
+ byte[] dataArray = encrypt(data);
+
+ return new String(dataArray, "ISO-8859-1");
+ } catch (Exception e) {
+
RESOURCE_LOGGER.error(Messages.getMessage(Messages.QUERY_STRING_BUILDING_ERROR), e);
+ }
+ }
+
+ return null;
+ }
+
+ public static String encodeObjectData(Object data) {
+ if (data != null) {
+ try {
+ ByteArrayOutputStream dataStream = new ByteArrayOutputStream(1024);
+ ObjectOutputStream objStream = new ObjectOutputStream(dataStream);
+
+ objStream.writeObject(data);
+ objStream.flush();
+ objStream.close();
+ dataStream.close();
+
+ return encodeBytesData(dataStream.toByteArray());
+ } catch (Exception e) {
+
RESOURCE_LOGGER.error(Messages.getMessage(Messages.QUERY_STRING_BUILDING_ERROR), e);
+ }
+ }
+
+ return null;
+ }
+
+ public static String legacyEncodeResourceData(String resourceName, Object storeData,
String resourceVersion) {
StringBuilder uri = new StringBuilder(); //
ResourceServlet.DEFAULT_SERVLET_PATH).append("/");
uri.append(resourceName);
// append serialized data as Base-64 encoded request string.
if (storeData != null) {
- try {
- byte[] objectData;
-
- if (storeData instanceof byte[]) {
- objectData = (byte[]) storeData;
+ String encodedData;
+ if (storeData instanceof byte[]) {
+ encodedData = encodeBytesData((byte[]) storeData);
+
+ if (encodedData != null) {
uri.append(DATA_BYTES_SEPARATOR);
- } else {
- ByteArrayOutputStream dataSteram = new ByteArrayOutputStream(1024);
- ObjectOutputStream objStream = new ObjectOutputStream(dataSteram);
+ uri.append(encodedData);
+ }
+
+ } else {
+ encodedData = encodeObjectData(storeData);
- objStream.writeObject(storeData);
- objStream.flush();
- objStream.close();
- dataSteram.close();
- objectData = dataSteram.toByteArray();
+ if (encodedData != null) {
uri.append(DATA_SEPARATOR);
+ uri.append(encodedData);
}
-
- byte[] dataArray = encrypt(objectData);
-
- uri.append(new String(dataArray, "ISO-8859-1"));
-
- // / byte[] objectData = dataSteram.toByteArray();
- // / uri.append("?").append(new
- // String(Base64.encodeBase64(objectData),
- // / "ISO-8859-1"));
- } catch (Exception e) {
-
RESOURCE_LOGGER.error(Messages.getMessage(Messages.QUERY_STRING_BUILDING_ERROR), e);
}
}
@@ -263,7 +322,7 @@
return uri.toString(); //
context.getExternalContext().encodeResourceURL(resourceURL);
}
- public static String getResourceName(String resourceUri) {
+ public static String legacyDecodeResourceName(String resourceUri) {
String resourceName = resourceUri;
Matcher matcher = DATA_SEPARATOR_PATTERN.matcher(resourceName);
@@ -282,7 +341,7 @@
return resourceName;
}
- public static String getResourceVersion(String resourceUri) {
+ public static String legacyDecodeResourceVersion(String resourceUri) {
int idx = resourceUri.indexOf(VERSION_SEPARATOR);
if (idx > 0) {
@@ -292,7 +351,7 @@
return null;
}
- public static Object getResourceData(String resourceUri) {
+ public static Object legacyDecodeResourceData(String resourceUri) {
Object data = null;
Matcher matcher = DATA_SEPARATOR_PATTERN.matcher(resourceUri);
@@ -305,31 +364,11 @@
}
String dataString = matcher.group(DATA_SEPARATOR_DATA_GROUP_INDEX);
- byte[] objectArray = null;
- try {
- byte[] dataArray = dataString.getBytes("ISO-8859-1");
-
- objectArray = decrypt(dataArray);
- } catch (UnsupportedEncodingException e1) {
-
- // default encoding always presented.
- }
-
if ("B".equals(matcher.group(DATA_SEPARATOR_TYPE_GROUP_INDEX))) {
- data = objectArray;
+ data = decodeBytesData(dataString);
} else {
- try {
- ObjectInputStream in = new ObjectInputStream(new
ByteArrayInputStream(objectArray));
-
- data = in.readObject();
- } catch (StreamCorruptedException e) {
-
RESOURCE_LOGGER.error(Messages.getMessage(Messages.STREAM_CORRUPTED_ERROR), e);
- } catch (IOException e) {
-
RESOURCE_LOGGER.error(Messages.getMessage(Messages.DESERIALIZE_DATA_INPUT_ERROR), e);
- } catch (ClassNotFoundException e) {
-
RESOURCE_LOGGER.error(Messages.getMessage(Messages.DATA_CLASS_NOT_FOUND_ERROR), e);
- }
+ data = decodeObjectData(dataString);
}
return data;
@@ -344,7 +383,18 @@
resourcePath = mapping + url;
}
} else {
- resourcePath += mapping;
+ int paramsSeparator = resourcePath.indexOf(QUESTION_SIGN);
+ if (paramsSeparator >= 0) {
+ StringBuilder resourcePathBuilder = new
StringBuilder(resourcePath.length() + mapping.length());
+
+ resourcePathBuilder.append(resourcePath.substring(0, paramsSeparator));
+ resourcePathBuilder.append(mapping);
+ resourcePathBuilder.append(resourcePath.substring(paramsSeparator));
+
+ resourcePath = resourcePathBuilder.toString();
+ } else {
+ resourcePath += mapping;
+ }
}
ViewHandler viewHandler = context.getApplication().getViewHandler();
@@ -416,4 +466,83 @@
buffer.clear();
}
}
+
+ private static boolean isLegalURIQueryChar(char c) {
+ //http://java.sun.com/j2se/1.5.0/docs/api/java/net/URI.html
+
+ //alphanum
+ if (('a' <= c && c <= 'z') || ('A' <= c
&& c <= 'Z') || ('0' <= c && c <= '9'))
{
+ return true;
+ }
+
+ //reserved
+ //if (c == ';' || c == '/' || c == '?' || c ==
':' || c == '@' || c == '&' || c == '=' || c ==
'+' || c == ',' || c == '$' ) {
+ // return true;
+ //}
+
+ //mark
+ if (c == '-' || c == '_' || c == '.' || c == '!'
|| c == '~' || c == '*' || c == '\'' || c == '(' || c
== ')') {
+ return true;
+ }
+
+ return false;
+ }
+
+ private static final String escapeURIByte(int b) {
+ if (0x10 <= b) {
+ return "%" + Integer.toHexString(b);
+ } else {
+ return "%0" + Integer.toHexString(b);
+ }
+ }
+
+ public static String encodeURIQueryPart(String s) {
+ StringBuilder builder = new StringBuilder();
+
+ int start = 0;
+ int idx = 0;
+
+ int length = s.length();
+ CharsetEncoder encoder = null;
+ ByteBuffer byteBuffer = null;
+ CharBuffer buffer = null;
+
+ for (; idx < length; idx++) {
+ char c = s.charAt(idx);
+
+ if (!isLegalURIQueryChar(c)) {
+ builder.append(s.substring(start, idx));
+
+ if (encoder == null) {
+ encoder = Charset.forName("UTF-8").newEncoder();
+ }
+ if (buffer == null) {
+ buffer = CharBuffer.allocate(1);
+ byteBuffer = ByteBuffer.allocate(6); //max bytes size in UTF-8
+ } else {
+ byteBuffer.limit(6);
+ }
+
+ buffer.put(0, c);
+
+ buffer.rewind();
+ byteBuffer.rewind();
+ encoder.encode(buffer, byteBuffer, true);
+
+ byteBuffer.flip();
+
+ int limit = byteBuffer.limit();
+ for (int i = 0; i < limit; i++) {
+ int b = (0xFF & byteBuffer.get());
+ builder.append(escapeURIByte(b));
+ }
+
+ start = idx + 1;
+ }
+ }
+
+ builder.append(s.substring(start, idx));
+
+ return builder.toString();
+ }
}
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.Base2WayGradient.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.BaseGradient.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.CustomizeableGradient.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.GradientA.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.gradientimages.ButtonGradientImage.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.gradientimages.ButtonInverseGradientImage.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.gradientimages.HeaderGradientImage.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.gradientimages.HeaderInverseGradientImage.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.gradientimages.InputGradientImage.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.gradientimages.MenuGradientImage.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.gradientimages.MenuInverseGradientImage.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.gradientimages.TabGradientImage.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.gradientimages.TabInverseGradientImage.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.images.BaseControlBackgroundImage.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.images.ButtonBackgroundImage.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.images.ButtonDisabledBackgroundImage.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.images.GradientAlignment.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.images.GradientType.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.images.InputBackgroundImage.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.images.StandardButtonBgImage.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.renderkit.html.images.StandardButtonPressedBgImage.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.resource.AnimatedTestResource.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/main/resources/META-INF/org.richfaces.resource.TestResource2.resource.properties
===================================================================
Modified:
root/core/trunk/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java
===================================================================
---
root/core/trunk/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java 2010-05-19
23:16:19 UTC (rev 17150)
+++
root/core/trunk/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java 2010-05-20
00:10:53 UTC (rev 17151)
@@ -127,12 +127,15 @@
Object resourceState = new Object();
ResourceCodec resourceCodec = EasyMock.createMock(ResourceCodec.class);
-
EasyMock.expect(resourceCodec.encodeResource(EasyMock.eq("org.richfaces.resource.MockStateAwareResource"),
- EasyMock.same(resourceState),
EasyMock.eq("4_0_alpha"))).andReturn("Resource0/4_0_alpha/data");
-
EasyMock.expect(resourceCodec.encodeResource(EasyMock.eq("org.richfaces.resource.MockStateAwareResource"),
- EasyMock.eq(null),
EasyMock.eq("4_0_alpha"))).andReturn("Resource1/4_0_alpha");
-
EasyMock.expect(resourceCodec.encodeResource(EasyMock.eq("org.richfaces.resource.MockResource"),
- EasyMock.eq(null),
EasyMock.eq("4_0_alpha"))).andReturn("Resource2/4_0_alpha");
+ EasyMock.expect(resourceCodec.encodeResource(EasyMock.same(facesContext),
+ EasyMock.eq("org.richfaces.resource.MockStateAwareResource"),
+ EasyMock.same(resourceState),
EasyMock.eq("4_0_alpha"))).andReturn("Resource0/4_0_alpha/data");
+ EasyMock.expect(resourceCodec.encodeResource(EasyMock.same(facesContext),
+ EasyMock.eq("org.richfaces.resource.MockStateAwareResource"),
+ EasyMock.eq(null),
EasyMock.eq("4_0_alpha"))).andReturn("Resource1/4_0_alpha");
+ EasyMock.expect(resourceCodec.encodeResource(EasyMock.same(facesContext),
+ EasyMock.eq("org.richfaces.resource.MockResource"),
+ EasyMock.eq(null),
EasyMock.eq("4_0_alpha"))).andReturn("Resource2/4_0_alpha");
EasyMock.replay(resourceCodec);
ResourceHandlerImpl.setResourceCodec(resourceCodec);
Modified:
root/core/trunk/impl/src/test/java/org/richfaces/resource/CacheableResourceImpl.java
===================================================================
---
root/core/trunk/impl/src/test/java/org/richfaces/resource/CacheableResourceImpl.java 2010-05-19
23:16:19 UTC (rev 17150)
+++
root/core/trunk/impl/src/test/java/org/richfaces/resource/CacheableResourceImpl.java 2010-05-20
00:10:53 UTC (rev 17151)
@@ -38,6 +38,7 @@
* @author Nick Belaevski
* @since 4.0
*/
+@DynamicResource
public class CacheableResourceImpl extends AbstractBaseResource {
/*
Modified:
root/core/trunk/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java
===================================================================
---
root/core/trunk/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java 2010-05-19
23:16:19 UTC (rev 17150)
+++
root/core/trunk/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java 2010-05-20
00:10:53 UTC (rev 17151)
@@ -34,6 +34,7 @@
import java.util.TimeZone;
import javax.faces.application.ResourceHandler;
+import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletResponse;
import org.easymock.classextension.EasyMock;
@@ -219,16 +220,19 @@
ResourceCodec mockedCodec = EasyMock.createNiceMock(ResourceCodec.class);
-
EasyMock.expect(mockedCodec.decodeResourceName(EasyMock.eq("StateHolderResource/DATA/1"))).andReturn(
- "org.richfaces.resource.StateHolderResourceImpl");
-
EasyMock.expect(mockedCodec.decodeResourceData(EasyMock.eq("StateHolderResource/DATA/1"))).andReturn(
- "test text");
-
EasyMock.expect(mockedCodec.decodeResourceVersion(EasyMock.eq("StateHolderResource/DATA/1"))).andReturn(null);
+
EasyMock.expect(mockedCodec.decodeResourceName(EasyMock.<FacesContext>notNull(),
+
EasyMock.eq("StateHolderResource"))).andReturn("org.richfaces.resource.StateHolderResourceImpl");
+
EasyMock.expect(mockedCodec.decodeResourceData(EasyMock.<FacesContext>notNull(),
+ EasyMock.eq("StateHolderResource"))).andReturn("test
text");
+
EasyMock.expect(mockedCodec.decodeResourceVersion(EasyMock.<FacesContext>notNull(),
+ EasyMock.eq("StateHolderResource"))).andReturn(null);
+
EasyMock.expect(mockedCodec.getResourceKey(EasyMock.<FacesContext>notNull(),
+
EasyMock.eq("StateHolderResource"))).andReturn("StateHolderResource.jsf?do=1");
EasyMock.replay(mockedCodec);
ResourceHandlerImpl.setResourceCodec(mockedCodec);
WebRequestSettings settings =
- new WebRequestSettings(new
URL("http://localhost/rfRes/StateHolderResource/DATA/1.jsf"));
+ new WebRequestSettings(new
URL("http://localhost/rfRes/StateHolderResource.jsf?do=1"));
WebResponse resourceResponse = webClient.loadWebResponse(settings);
assertEquals(HttpServletResponse.SC_OK, resourceResponse.getStatusCode());
@@ -242,11 +246,11 @@
assertEquals(HttpServletResponse.SC_OK, resourceResponse.getStatusCode());
settings = new WebRequestSettings(
- new
URL("http://localhost/rfRes/org.richfaces.resource.VersionedResourceImpl/VER1_0_2.jsf"));
+ new
URL("http://localhost/rfRes/org.richfaces.resource.VersionedResourceImpl.jsf?v=1_0_2"));
resourceResponse = webClient.loadWebResponse(settings);
assertEquals(HttpServletResponse.SC_OK, resourceResponse.getStatusCode());
settings = new WebRequestSettings(
- new
URL("http://localhost/rfRes/org.richfaces.resource.VersionedResourceImpl/VER1_0_3.jsf"));
+ new
URL("http://localhost/rfRes/org.richfaces.resource.VersionedResourceImpl.jsf?v=1_0_3"));
resourceResponse = webClient.loadWebResponse(settings);
assertEquals(HttpServletResponse.SC_NOT_FOUND,
resourceResponse.getStatusCode());
}
@@ -262,9 +266,9 @@
new WebRequestSettings(new URL(resourceName));
WebResponse resourceResponse = webClient.loadWebResponse(settings);
- assertEquals(HttpServletResponse.SC_OK, resourceResponse.getStatusCode());
+ assertEquals(resource, HttpServletResponse.SC_OK,
resourceResponse.getStatusCode());
String expected =
readFileAsString(getResourceExpectedOutputFileName(resource));
- assertEquals(expected.trim(), resourceResponse.getContentAsString().trim());
+ assertEquals(resource, expected.trim(),
resourceResponse.getContentAsString().trim());
}
}
Modified:
root/core/trunk/impl/src/test/java/org/richfaces/resource/StateHolderResourceImpl.java
===================================================================
---
root/core/trunk/impl/src/test/java/org/richfaces/resource/StateHolderResourceImpl.java 2010-05-19
23:16:19 UTC (rev 17150)
+++
root/core/trunk/impl/src/test/java/org/richfaces/resource/StateHolderResourceImpl.java 2010-05-20
00:10:53 UTC (rev 17151)
@@ -36,6 +36,7 @@
* @author Nick Belaevski
* @since 4.0
*/
+@DynamicResource
public class StateHolderResourceImpl extends AbstractBaseResource implements StateHolder
{
private Object state = "";
Modified:
root/core/trunk/impl/src/test/java/org/richfaces/resource/VersionedResourceImpl.java
===================================================================
---
root/core/trunk/impl/src/test/java/org/richfaces/resource/VersionedResourceImpl.java 2010-05-19
23:16:19 UTC (rev 17150)
+++
root/core/trunk/impl/src/test/java/org/richfaces/resource/VersionedResourceImpl.java 2010-05-20
00:10:53 UTC (rev 17151)
@@ -27,6 +27,7 @@
* @author Nick Belaevski
* @since 4.0
*/
+@DynamicResource
public class VersionedResourceImpl extends EmptyStreamResource {
@Override
public String getVersion() {
Deleted:
root/core/trunk/impl/src/test/resources/META-INF/org.richfaces.resource.CacheableResourceImpl.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/test/resources/META-INF/org.richfaces.resource.NonCacheableResourceImpl.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/test/resources/META-INF/org.richfaces.resource.StateHolderResourceImpl.resource.properties
===================================================================
Deleted:
root/core/trunk/impl/src/test/resources/META-INF/org.richfaces.resource.VersionedResourceImpl.resource.properties
===================================================================
Modified: root/core/trunk/impl/src/test/resources/resources/full.css
===================================================================
--- root/core/trunk/impl/src/test/resources/resources/full.css 2010-05-19 23:16:19 UTC
(rev 17150)
+++ root/core/trunk/impl/src/test/resources/resources/full.css 2010-05-20 00:10:53 UTC
(rev 17151)
@@ -22,5 +22,5 @@
padding: 10px !important;
border: 1px solid green;
background-image: url(image.png);
- background: red
url(/rfRes/org.richfaces.renderkit.html.images.ButtonBackgroundImage/DATB/eAF79urt!-Pnr!xn4mZgYAAAREsHMw__.jsf);
+ background: red
url(/rfRes/org.richfaces.renderkit.html.images.ButtonBackgroundImage.jsf?db=eAF79urt!-Pnr!xn4mZgYAAAREsHMw__);
}
Modified: root/core/trunk/impl/src/test/resources/resources/importedEL.css
===================================================================
--- root/core/trunk/impl/src/test/resources/resources/importedEL.css 2010-05-19 23:16:19
UTC (rev 17150)
+++ root/core/trunk/impl/src/test/resources/resources/importedEL.css 2010-05-20 00:10:53
UTC (rev 17151)
@@ -22,5 +22,5 @@
padding: 10px !important;
border: 1px solid green;
background-image: url(image.png);
- background: red
url(/rfRes/org.richfaces.renderkit.html.images.ButtonBackgroundImage/DATB/eAF79urt!-Pnr!xn4mZgYAAAREsHMw__.jsf);
+ background: red
url(/rfRes/org.richfaces.renderkit.html.images.ButtonBackgroundImage.jsf?db=eAF79urt!-Pnr!xn4mZgYAAAREsHMw__);
}
\ No newline at end of file
Modified: root/core/trunk/impl/src/test/resources/resources/resource.css
===================================================================
--- root/core/trunk/impl/src/test/resources/resources/resource.css 2010-05-19 23:16:19 UTC
(rev 17150)
+++ root/core/trunk/impl/src/test/resources/resources/resource.css 2010-05-20 00:10:53 UTC
(rev 17151)
@@ -1,3 +1,3 @@
body {
- background: red
url(/rfRes/org.richfaces.renderkit.html.images.ButtonBackgroundImage/DATB/eAF79urt!-Pnr!xn4mZgYAAAREsHMw__.jsf);
+ background: red
url(/rfRes/org.richfaces.renderkit.html.images.ButtonBackgroundImage.jsf?db=eAF79urt!-Pnr!xn4mZgYAAAREsHMw__);
}
\ No newline at end of file