Author: nbelaevski
Date: 2010-09-06 21:08:23 -0400 (Mon, 06 Sep 2010)
New Revision: 19125
Modified:
branches/RF-7560/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/resource/handler/impl/DynamicResourceWrapper.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/resource/ResourceFactoryImpl.java
Log:
RF-7560
Modified:
branches/RF-7560/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/resource/handler/impl/DynamicResourceWrapper.java
===================================================================
---
branches/RF-7560/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/resource/handler/impl/DynamicResourceWrapper.java 2010-09-07
00:16:57 UTC (rev 19124)
+++
branches/RF-7560/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/resource/handler/impl/DynamicResourceWrapper.java 2010-09-07
01:08:23 UTC (rev 19125)
@@ -22,7 +22,6 @@
package org.richfaces.cdk.resource.handler.impl;
import static org.richfaces.cdk.strings.Constants.DASH_JOINER;
-import static org.richfaces.cdk.strings.Constants.DOT_JOINER;
import static org.richfaces.cdk.strings.Constants.SLASH_JOINER;
import java.io.IOException;
@@ -92,38 +91,6 @@
throw new UnsupportedOperationException();
}
- private String getMangledLibraryName() {
- String resourceName = getResourceName();
- if (Strings.isNullOrEmpty(getLibraryName()) &&
!resourceName.endsWith(ECSS_EXTENSION)) {
- int idx = resourceName.lastIndexOf('.');
- if (idx < 0) {
- return null;
- } else {
- return resourceName.substring(0, idx);
- }
- }
-
- return getLibraryName();
- }
-
- private String getMangledResourceName() {
- String resourceName = getResourceName();
- if (resourceName.endsWith(ECSS_EXTENSION)) {
- return resourceName.substring(0, resourceName.length() -
ECSS_EXTENSION.length());
- }
-
- if (Strings.isNullOrEmpty(getLibraryName())) {
- int idx = resourceName.lastIndexOf('.');
- if (idx < 0) {
- return resourceName;
- } else {
- return resourceName.substring(idx + 1);
- }
- } else {
- return resourceName;
- }
- }
-
private FileNameMapper getFileNameMapper() {
return ServiceTracker.getService(FileNameMapper.class);
}
@@ -138,12 +105,30 @@
@Override
public String getRequestPath() {
- String mangledLibraryName = getMangledLibraryName();
- String mangledResourceName = getMangledResourceName();
String resourceExtension = getResourceExtension();
+
+ String resourceName = getResourceName();
+ if (resourceName.endsWith(ECSS_EXTENSION)) {
+ resourceName = resourceName.substring(0, resourceName.length() -
ECSS_EXTENSION.length());
+ } else {
+ if (resourceExtension != null &&
resourceName.endsWith(resourceExtension)) {
+ resourceName = resourceName.substring(0, resourceName.length() -
resourceExtension.length());
+ }
+ }
- String resourceName = DOT_JOINER.join(DASH_JOINER.join(mangledResourceName,
getVersion()), resourceExtension);
- String resourcePath = SLASH_JOINER.join(mangledLibraryName, resourceName);
+ String libraryName = getLibraryName();
+
+ if (Strings.isNullOrEmpty(libraryName)) {
+ int idx = resourceName.lastIndexOf('.');
+
+ if (idx >= 0) {
+ libraryName = resourceName.substring(0, idx);
+ resourceName = resourceName.substring(idx + 1);
+ }
+ }
+
+ String versionedName = DASH_JOINER.join(resourceName, getVersion()) +
Strings.nullToEmpty(resourceExtension);
+ String resourcePath = SLASH_JOINER.join(libraryName, versionedName);
return ResourceFactory.SKINNED_RESOURCE_PREFIX +
getFileNameMapper().createName(resourcePath);
}
@@ -167,7 +152,7 @@
if (contentType.startsWith("text/") ||
contentType.startsWith("image/")) {
String[] split = contentType.split("/");
if (split.length == 2) {
- return split[1];
+ return '.' + split[1];
}
}
Modified:
branches/RF-7560/core/impl/src/main/java/org/richfaces/resource/ResourceFactoryImpl.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/resource/ResourceFactoryImpl.java 2010-09-07
00:16:57 UTC (rev 19124)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/resource/ResourceFactoryImpl.java 2010-09-07
01:08:23 UTC (rev 19125)
@@ -309,7 +309,7 @@
}
String libraryName = resourceData.getLibraryName();
- Resource resource = createDynamicResource(new ResourceKey(resourceName,
libraryName));
+ Resource resource = createDynamicResource(new ResourceKey(resourceName,
libraryName), false);
if (resource == null) {
logMissingResource(context, resourceData.getResourceKey());
@@ -355,28 +355,32 @@
return externalStaticResourceFactory.createResource();
}
- return createDynamicResource(resourceKey);
+ return createDynamicResource(resourceKey, true);
}
- protected Resource createDynamicResource(ResourceKey resourceKey) {
+ protected Resource createDynamicResource(ResourceKey resourceKey, boolean
useDependencyInjection) {
Resource result = null;
- Map<String, String> params;
+ Map<String, String> params = null;
MappedResourceData mappedResourceData = mappedResourceDataMap.get(resourceKey);
ResourceKey actualKey;
if (mappedResourceData != null) {
actualKey = mappedResourceData.getResourceKey();
- params = mappedResourceData.getParams();
+ if (useDependencyInjection) {
+ params = mappedResourceData.getParams();
+ }
} else {
actualKey = resourceKey;
- params = Collections.<String, String>emptyMap();
+ if (useDependencyInjection) {
+ params = Collections.<String, String>emptyMap();
+ }
}
-
+
if (Strings.isNullOrEmpty(resourceKey.getResourceName())) {
return null;
}
-
+
if (actualKey.getResourceName().endsWith(".ecss")) {
// TODO nick - params?
result = createCompiledCSSResource(actualKey);