You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/05/20 22:31:42 UTC
svn commit: r946779 - in /myfaces/core/trunk: api/ api/src/assembler/
api/src/main/javascript/META-INF/resources/myfaces/_impl/core/
impl/src/main/java/org/apache/myfaces/application/
impl/src/main/java/org/apache/myfaces/resource/
Author: lu4242
Date: Thu May 20 20:31:42 2010
New Revision: 946779
URL: http://svn.apache.org/viewvc?rev=946779&view=rev
Log:
MYFACES-2714 Include uncompressed jsf.js file and use it when development mode is used
Added:
myfaces/core/trunk/api/src/assembler/jsfscripts-uncompressed-compiler.xml
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/AliasResourceMetaImpl.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/InternalClassLoaderResourceLoader.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceMetaImpl.java
Modified:
myfaces/core/trunk/api/pom.xml
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/DefaultResourceHandlerSupport.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ClassLoaderResourceLoader.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ExternalContextResourceLoader.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceMeta.java
Modified: myfaces/core/trunk/api/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/pom.xml?rev=946779&r1=946778&r2=946779&view=diff
==============================================================================
--- myfaces/core/trunk/api/pom.xml (original)
+++ myfaces/core/trunk/api/pom.xml Thu May 20 20:31:42 2010
@@ -19,8 +19,27 @@
<url>http://svn.apache.org/repos/asf/myfaces/core/trunk/api</url>
</scm>
<build>
-
-
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <directory>src/main/javascript/META-INF/resources/myfaces/_impl/_util</directory>
+ <targetPath>META-INF/internal-resources/org.apache.myfaces.core.impl.util</targetPath>
+ </resource>
+ <resource>
+ <directory>src/main/javascript/META-INF/resources/myfaces/_impl/core</directory>
+ <targetPath>META-INF/internal-resources/org.apache.myfaces.core.impl.core</targetPath>
+ </resource>
+ <resource>
+ <directory>src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore</directory>
+ <targetPath>META-INF/internal-resources/org.apache.myfaces.core.impl.xhrCore</targetPath>
+ </resource>
+ <resource>
+ <directory>src/main/javascript/META-INF/resources/myfaces/api</directory>
+ <targetPath>META-INF/internal-resources/org.apache.myfaces.core.api</targetPath>
+ </resource>
+ </resources>
<plugins>
<!--
javascript plugin adjusted to our build process
@@ -29,10 +48,17 @@
<plugin>
+ <!-- we have to enforce a version for now which works due to the alpha stage of the plugin -->
+ <!--
+ <artifactId>myfaces-javascript-plugin</artifactId>
+ <groupId>org.apache.myfaces.buildtools</groupId>
+ <version>1.0.1-SNAPSHOT</version>
+ -->
<artifactId>javascript-maven-plugin</artifactId>
<groupId>org.codehaus.mojo.javascript</groupId>
- <!-- we have to enforce a version for now which works due to the alpha stage of the plugin -->
<version>1.0-alpha-1-20090530.211438-7</version>
+ <!-- version>1.0-alpha-1-SNAPSHOT</version -->
+
<extensions>true</extensions>
<executions>
<execution>
@@ -43,6 +69,27 @@
<phase>process-resources</phase>
<configuration>
<descriptor>${basedir}/src/assembler/jsfscripts-compiler.xml</descriptor>
+ <excludes>
+ <exclude>**/myfaces/_impl/core/jsf-uncompressed.js</exclude>
+ <exclude>**/myfaces/_impl/_util/_UnitTest.js</exclude>
+ </excludes>
+ </configuration>
+ </execution>
+ <execution>
+ <id>compile-uncompressed</id>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ <phase>process-resources</phase>
+ <configuration>
+ <descriptor>${basedir}/src/assembler/jsfscripts-uncompressed-compiler.xml</descriptor>
+ <outputDirectory>${basedir}/target/classes/META-INF/internal-resources/javax.faces/</outputDirectory>
+ <excludes>
+ <exclude>**/myfaces/_impl/core/jsf_impl.js</exclude>
+ <exclude>**/myfaces/_impl/_util/*</exclude>
+ <exclude>**/myfaces/_impl/xhrCore/*</exclude>
+ <exclude>**/myfaces/api/*</exclude>
+ </excludes>
</configuration>
</execution>
<execution>
@@ -54,11 +101,13 @@
<configuration>
<scripts>target/classes/META-INF/resources/javax.faces/</scripts>
+ <excludes><exclude>jsf-uncompressed.js</exclude></excludes>
<compressor>yahooUI</compressor>
</configuration>
</execution>
</executions>
<configuration>
+ <optimizationLevel>4</optimizationLevel>
<sourceDirectory>src/main/javascript</sourceDirectory>
<webappDirectory>${basedir}</webappDirectory>
<outputDirectory>${basedir}/target/classes/META-INF/resources/javax.faces/</outputDirectory>
Added: myfaces/core/trunk/api/src/assembler/jsfscripts-uncompressed-compiler.xml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/assembler/jsfscripts-uncompressed-compiler.xml?rev=946779&view=auto
==============================================================================
--- myfaces/core/trunk/api/src/assembler/jsfscripts-uncompressed-compiler.xml (added)
+++ myfaces/core/trunk/api/src/assembler/jsfscripts-uncompressed-compiler.xml Thu May 20 20:31:42 2010
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<assembler>
+ <scripts>
+ <!--
+ Assembly for our javascripts
+ if you want to include them manually use:
+
+
+ <script type="text/javascript" src="./myfaces/_impl/core/_Runtime.js"></script>
+ <script type = "text/javascript" src = "myfaces/_impl/_util/_Lang.js"></script>
+ <script type = "text/javascript" src = "./myfaces/_impl/_util/_ListenerQueue.js"></script>
+ <script type = "text/javascript" src = "./myfaces/_impl/_util/_Dom.js"></script>
+ <script type = "text/javascript" src = "./myfaces/_impl/_util/_HtmlStripper.js"></script>
+
+ <script type = "text/javascript" src = "./myfaces/_impl/xhrCore/_Exception.js"></script>
+ <script type = "text/javascript" src = "./myfaces/_impl/xhrCore/_AjaxUtils.js"></script>
+ <script type = "text/javascript" src = "./myfaces/_impl/xhrCore/_AjaxRequestQueue.js"></script>
+ <script type = "text/javascript" src = "./myfaces/_impl/xhrCore/_AjaxRequest.js"></script>
+ <script type = "text/javascript" src = "./myfaces/_impl/xhrCore/_AjaxResponse.js"></script>
+ <script type = "text/javascript" src = "./myfaces/_impl/xhrCore/_xhrCoreAdapter.js"></script>
+ <script type = "text/javascript" src = "./myfaces/_impl/core/jsf_impl.js"></script>
+ <script type = "text/javascript" src = "./myfaces/api/jsf.js"></script>
+ -->
+ <script>
+ <fileName>jsf-uncompressed.js</fileName>
+ <includes>
+ <include>**/_impl/core/_Runtime.js</include>
+ <include>**/_impl/core/jsf-uncompressed.js</include>
+ </includes>
+ </script>
+ </scripts>
+</assembler>
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js?rev=946779&r1=946778&r2=946779&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js Thu May 20 20:31:42 2010
@@ -399,6 +399,20 @@ if ('undefined' == typeof myfaces._impl
}
};
+ myfaces._impl.core._Runtime.loadScriptOnHeadElement = function(src, type, defer, charSet) {
+ var head = document.getElementsByTagName("head")[0];
+ if ('undefined' == typeof head || null == head)
+ {
+ head = document.createElement("head");
+ var html = document.getElementsByTagName("html");
+ html.appendChild(head);
+ }
+ var script = document.createElement("script");
+ script.type = "text/javascript";
+ script.src = src;
+ head.appendChild(script);
+ };
+
/**
* Extends a class and puts a singleton instance at the reserved namespace instead
* of its original class
Added: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js?rev=946779&view=auto
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js (added)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js Thu May 20 20:31:42 2010
@@ -0,0 +1,26 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * under the License.
+ */
+myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.util:_Lang.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.util:_Queue.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.util:_ListenerQueue.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.util:_Dom.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.util:_HtmlStripper.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxUtils.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxRequestQueue.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxRequest.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxResponse.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.xhrCore:_Transports.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.core:Impl.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.api:jsf.js']}", null, null, "UTF-8");
\ No newline at end of file
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/DefaultResourceHandlerSupport.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/DefaultResourceHandlerSupport.java?rev=946779&r1=946778&r2=946779&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/DefaultResourceHandlerSupport.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/DefaultResourceHandlerSupport.java Thu May 20 20:31:42 2010
@@ -20,12 +20,14 @@ package org.apache.myfaces.application;
import java.util.Map;
+import javax.faces.application.ProjectStage;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFWebConfigParam;
import org.apache.myfaces.resource.ClassLoaderResourceLoader;
import org.apache.myfaces.resource.ExternalContextResourceLoader;
+import org.apache.myfaces.resource.InternalClassLoaderResourceLoader;
import org.apache.myfaces.resource.ResourceLoader;
import org.apache.myfaces.shared_impl.application.FacesServletMapping;
@@ -118,10 +120,21 @@ public class DefaultResourceHandlerSuppo
{
//The ExternalContextResourceLoader has precedence over
//ClassLoaderResourceLoader, so it goes first.
- _resourceLoaders = new ResourceLoader[] {
- new ExternalContextResourceLoader("/resources"),
- new ClassLoaderResourceLoader("META-INF/resources")
- };
+ if (FacesContext.getCurrentInstance().isProjectStage(ProjectStage.Development))
+ {
+ _resourceLoaders = new ResourceLoader[] {
+ new ExternalContextResourceLoader("/resources"),
+ new ClassLoaderResourceLoader("META-INF/resources"),
+ new InternalClassLoaderResourceLoader("META-INF/internal-resources")
+ };
+ }
+ else
+ {
+ _resourceLoaders = new ResourceLoader[] {
+ new ExternalContextResourceLoader("/resources"),
+ new ClassLoaderResourceLoader("META-INF/resources")
+ };
+ }
}
return _resourceLoaders;
}
Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/AliasResourceMetaImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/AliasResourceMetaImpl.java?rev=946779&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/AliasResourceMetaImpl.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/AliasResourceMetaImpl.java Thu May 20 20:31:42 2010
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.resource;
+
+/**
+ * Contains the metadata information to reference a resource
+ *
+ * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
+ * @version $Revision: 700544 $ $Date: 2008-09-30 13:44:02 -0500 (Mar, 30 Sep 2008) $
+ */
+public class AliasResourceMetaImpl extends ResourceMetaImpl
+{
+ private String _realResourceName;
+
+ public AliasResourceMetaImpl(String prefix, String libraryName, String libraryVersion,
+ String resourceName, String resourceVersion, String realResourceName)
+ {
+ super(prefix, libraryName, libraryVersion,
+ resourceName, resourceVersion);
+ _realResourceName = realResourceName;
+ }
+
+ public String getRealResourceName()
+ {
+ return _realResourceName;
+ }
+
+ public void setRealResourceName(String realResourceName)
+ {
+ _realResourceName = realResourceName;
+ }
+
+ @Override
+ public String getResourceIdentifier()
+ {
+ StringBuilder builder = new StringBuilder();
+ boolean firstSlashAdded = false;
+ if (getLocalePrefix() != null && getLocalePrefix().length() > 0)
+ {
+ builder.append(getLocalePrefix());
+ firstSlashAdded = true;
+ }
+ if (getLibraryName() != null)
+ {
+ if (firstSlashAdded) builder.append('/');
+ builder.append(getLibraryName());
+ firstSlashAdded = true;
+ }
+ if (getLibraryVersion() != null)
+ {
+ if (firstSlashAdded) builder.append('/');
+ builder.append(getLibraryVersion());
+ firstSlashAdded = true;
+ }
+ if (getRealResourceName() != null)
+ {
+ if (firstSlashAdded) builder.append('/');
+ builder.append(getRealResourceName());
+ firstSlashAdded = true;
+ }
+ if (getResourceVersion() != null)
+ {
+ if (firstSlashAdded) builder.append('/');
+ builder.append(getResourceVersion());
+ builder.append(
+ getRealResourceName().substring(getRealResourceName().lastIndexOf('.')));
+ firstSlashAdded = true;
+ }
+ return builder.toString();
+ }
+
+ @Override
+ public boolean couldResourceContainValueExpressions()
+ {
+ return true;
+ }
+}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ClassLoaderResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ClassLoaderResourceLoader.java?rev=946779&r1=946778&r2=946779&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ClassLoaderResourceLoader.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ClassLoaderResourceLoader.java Thu May 20 20:31:42 2010
@@ -18,19 +18,11 @@
*/
package org.apache.myfaces.resource;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
import java.io.InputStream;
-import java.net.JarURLConnection;
-import java.net.URISyntaxException;
import java.net.URL;
-import java.util.Enumeration;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.regex.Pattern;
+
+import javax.faces.application.ProjectStage;
+import javax.faces.context.FacesContext;
import org.apache.myfaces.shared_impl.util.ClassUtils;
@@ -79,10 +71,13 @@ public class ClassLoaderResourceLoader e
return false;
}
};*/
+
+ private final boolean _developmentStage;
public ClassLoaderResourceLoader(String prefix)
{
super(prefix);
+ _developmentStage = FacesContext.getCurrentInstance().isProjectStage(ProjectStage.Development);
}
@Override
@@ -249,11 +244,11 @@ public class ClassLoaderResourceLoader e
{
if (getPrefix() != null && !"".equals(getPrefix()))
{
- return getClassLoader().getResourceAsStream(getPrefix() + '/' + resourceMeta.toString());
+ return getClassLoader().getResourceAsStream(getPrefix() + '/' + resourceMeta.getResourceIdentifier());
}
else
{
- return getClassLoader().getResourceAsStream(resourceMeta.toString());
+ return getClassLoader().getResourceAsStream(resourceMeta.getResourceIdentifier());
}
}
@@ -262,11 +257,11 @@ public class ClassLoaderResourceLoader e
{
if (getPrefix() != null && !"".equals(getPrefix()))
{
- return getClassLoader().getResource(getPrefix() + '/' + resourceMeta.toString());
+ return getClassLoader().getResource(getPrefix() + '/' + resourceMeta.getResourceIdentifier());
}
else
{
- return getClassLoader().getResource(resourceMeta.toString());
+ return getClassLoader().getResource(resourceMeta.getResourceIdentifier());
}
}
@@ -414,7 +409,17 @@ public class ClassLoaderResourceLoader e
public ResourceMeta createResourceMeta(String prefix, String libraryName, String libraryVersion,
String resourceName, String resourceVersion)
{
- return new ResourceMeta(prefix, libraryName, libraryVersion, resourceName, resourceVersion);
+ if (_developmentStage && libraryName != null &&
+ org.apache.myfaces.shared_impl.renderkit.html.util.ResourceUtils.JAVAX_FACES_LIBRARY_NAME.equals(libraryName) &&
+ org.apache.myfaces.shared_impl.renderkit.html.util.ResourceUtils.JSF_JS_RESOURCE_NAME.equals(resourceName))
+ {
+ // InternalClassLoaderResourceLoader will serve it, so return null in this case.
+ return null;
+ }
+ else
+ {
+ return new ResourceMetaImpl(prefix, libraryName, libraryVersion, resourceName, resourceVersion);
+ }
}
/**
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ExternalContextResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ExternalContextResourceLoader.java?rev=946779&r1=946778&r2=946779&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ExternalContextResourceLoader.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ExternalContextResourceLoader.java Thu May 20 20:31:42 2010
@@ -142,7 +142,7 @@ public class ExternalContextResourceLoad
try
{
return FacesContext.getCurrentInstance().getExternalContext().getResource(
- getPrefix() + '/' + resourceMeta.toString());
+ getPrefix() + '/' + resourceMeta.getResourceIdentifier());
}
catch (MalformedURLException e)
{
@@ -154,14 +154,14 @@ public class ExternalContextResourceLoad
public InputStream getResourceInputStream(ResourceMeta resourceMeta)
{
return FacesContext.getCurrentInstance().getExternalContext().getResourceAsStream(
- getPrefix() + '/' + resourceMeta.toString());
+ getPrefix() + '/' + resourceMeta.getResourceIdentifier());
}
@Override
public ResourceMeta createResourceMeta(String prefix, String libraryName, String libraryVersion,
String resourceName, String resourceVersion)
{
- return new ResourceMeta(prefix, libraryName, libraryVersion, resourceName, resourceVersion);
+ return new ResourceMetaImpl(prefix, libraryName, libraryVersion, resourceName, resourceVersion);
}
@Override
Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/InternalClassLoaderResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/InternalClassLoaderResourceLoader.java?rev=946779&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/InternalClassLoaderResourceLoader.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/InternalClassLoaderResourceLoader.java Thu May 20 20:31:42 2010
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.resource;
+
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.myfaces.shared_impl.util.ClassUtils;
+
+/**
+ * A resource loader implementation which loads resources from the thread ClassLoader.
+ *
+ */
+public class InternalClassLoaderResourceLoader extends ResourceLoader
+{
+
+ public InternalClassLoaderResourceLoader(String prefix)
+ {
+ super(prefix);
+ }
+
+ @Override
+ public String getLibraryVersion(String path)
+ {
+ return null;
+ }
+
+ @Override
+ public InputStream getResourceInputStream(ResourceMeta resourceMeta)
+ {
+ if (getPrefix() != null && !"".equals(getPrefix()))
+ {
+ return getClassLoader().getResourceAsStream(getPrefix() + '/' + resourceMeta.getResourceIdentifier());
+ }
+ else
+ {
+ return getClassLoader().getResourceAsStream(resourceMeta.getResourceIdentifier());
+ }
+ }
+
+ @Override
+ public URL getResourceURL(ResourceMeta resourceMeta)
+ {
+ if (getPrefix() != null && !"".equals(getPrefix()))
+ {
+ return getClassLoader().getResource(getPrefix() + '/' + resourceMeta.getResourceIdentifier());
+ }
+ else
+ {
+ return getClassLoader().getResource(resourceMeta.getResourceIdentifier());
+ }
+ }
+
+ @Override
+ public String getResourceVersion(String path)
+ {
+ return null;
+ }
+
+ @Override
+ public ResourceMeta createResourceMeta(String prefix, String libraryName, String libraryVersion,
+ String resourceName, String resourceVersion)
+ {
+ if (libraryName != null &&
+ org.apache.myfaces.shared_impl.renderkit.html.util.ResourceUtils.JAVAX_FACES_LIBRARY_NAME.equals(libraryName) &&
+ org.apache.myfaces.shared_impl.renderkit.html.util.ResourceUtils.JSF_JS_RESOURCE_NAME.equals(resourceName))
+ {
+ return new AliasResourceMetaImpl(prefix, libraryName, libraryVersion,
+ resourceName, resourceVersion, org.apache.myfaces.shared_impl.renderkit.html.util.ResourceUtils.JSF_UNCOMPRESSED_JS_RESOURCE_NAME);
+ }
+ else if (libraryName != null && libraryName.startsWith("org.apache.myfaces.core"))
+ {
+ return new ResourceMetaImpl(prefix, libraryName, libraryVersion, resourceName, resourceVersion);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Returns the ClassLoader to use when looking up resources under the top level package. By default, this is the
+ * context class loader.
+ *
+ * @return the ClassLoader used to lookup resources
+ */
+ protected ClassLoader getClassLoader()
+ {
+ return ClassUtils.getContextClassLoader();
+ }
+
+ @Override
+ public boolean libraryExists(String libraryName)
+ {
+ if (getPrefix() != null && !"".equals(getPrefix()))
+ {
+ URL url = getClassLoader().getResource(getPrefix() + '/' + libraryName);
+ if (url != null)
+ {
+ return true;
+ }
+ }
+ else
+ {
+ URL url = getClassLoader().getResource(libraryName);
+ if (url != null)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java?rev=946779&r1=946778&r2=946779&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java Thu May 20 20:31:42 2010
@@ -30,13 +30,18 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.el.ELContext;
+import javax.el.ELException;
import javax.el.ValueExpression;
import javax.faces.application.ProjectStage;
import javax.faces.application.Resource;
import javax.faces.application.ResourceHandler;
import javax.faces.context.FacesContext;
+import javax.faces.event.ExceptionQueuedEvent;
+import javax.faces.event.ExceptionQueuedEventContext;
import org.apache.myfaces.application.ResourceHandlerSupport;
@@ -85,9 +90,17 @@ public class ResourceImpl extends Resour
private boolean couldResourceContainValueExpressions()
{
- String contentType = getContentType();
-
- return ("text/css".equals(contentType));
+ if (_resourceMeta.couldResourceContainValueExpressions())
+ {
+ return true;
+ }
+ else
+ {
+ //By default only css resource contain value expressions
+ String contentType = getContentType();
+
+ return ("text/css".equals(contentType));
+ }
}
private class ValueExpressionFilterInputStream extends InputStream
@@ -142,18 +155,38 @@ public class ResourceImpl extends Resour
//the result into the stream
FacesContext context = FacesContext.getCurrentInstance();
ELContext elContext = context.getELContext();
- ValueExpression ve = context.getApplication().
- getExpressionFactory().createValueExpression(
- elContext,
- "#{"+convertToExpression(expressionList)+"}",
- String.class);
-
- String value = (String) ve.getValue(elContext);
-
- for (int i = value.length()-1; i >= 0 ; i--)
+ try
+ {
+ ValueExpression ve = context.getApplication().
+ getExpressionFactory().createValueExpression(
+ elContext,
+ "#{"+convertToExpression(expressionList)+"}",
+ String.class);
+ String value = (String) ve.getValue(elContext);
+
+ for (int i = value.length()-1; i >= 0 ; i--)
+ {
+ delegate.unread((int) value.charAt(i));
+ }
+ }
+ catch(ELException e)
{
- delegate.unread((int) value.charAt(i));
+ ExceptionQueuedEventContext equecontext = new ExceptionQueuedEventContext (context, e, null);
+ context.getApplication().publishEvent (context, ExceptionQueuedEvent.class, equecontext);
+
+ Logger log = Logger.getLogger(ResourceImpl.class.getName());
+ if (log.isLoggable(Level.SEVERE))
+ log.severe("Cannot evaluate EL expression "+convertToExpression(expressionList)+ " in resource " + getLibraryName()+":"+getResourceName());
+
+ delegate.unread(c3);
+ for (int i = expressionList.size()-1; i >= 0; i--)
+ {
+ delegate.unread(expressionList.get(i));
+ }
+ delegate.unread(c2);
+ return c1;
}
+
//read again
return delegate.read();
}
@@ -246,6 +279,13 @@ public class ResourceImpl extends Resour
lastModified < _resourceHandlerSupport.getStartupTime())
{
lastModified = _resourceHandlerSupport.getStartupTime();
+ }
+ else if (_resourceMeta instanceof AliasResourceMetaImpl &&
+ lastModified < _resourceHandlerSupport.getStartupTime())
+ {
+ // If the resource meta is aliased, the last modified time is the greatest
+ // value between application startup and the value from file.
+ lastModified = _resourceHandlerSupport.getStartupTime();
}
if (lastModified >= 0)
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceMeta.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceMeta.java?rev=946779&r1=946778&r2=946779&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceMeta.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceMeta.java Thu May 20 20:31:42 2010
@@ -24,113 +24,20 @@ package org.apache.myfaces.resource;
* @author Leonardo Uribe (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class ResourceMeta
+public abstract class ResourceMeta
{
-
- private String _prefix;
- private String _libraryName;
- private String _libraryVersion;
- private String _resourceName;
- private String _resourceVersion;
-
- public ResourceMeta(String prefix, String libraryName, String libraryVersion,
- String resourceName, String resourceVersion)
- {
- _prefix = prefix;
- _libraryName = libraryName;
- _libraryVersion = libraryVersion;
- _resourceName = resourceName;
- _resourceVersion = resourceVersion;
- }
-
- public String getLibraryName()
- {
- return _libraryName;
- }
- public void setLibraryName(String libraryName)
- {
- _libraryName = libraryName;
- }
+ public abstract String getLibraryName();
- public String getResourceName()
- {
- return _resourceName;
- }
-
- public void setResourceName(String resourceName)
- {
- _resourceName = resourceName;
- }
-
- public void setPrefix(String prefix)
- {
- this._prefix = prefix;
- }
+ public abstract String getResourceName();
- public String getPrefix()
- {
- return _prefix;
- }
+ public abstract String getLocalePrefix();
- public void setLibraryVersion(String libraryVersion)
- {
- this._libraryVersion = libraryVersion;
- }
+ public abstract String getLibraryVersion();
- public String getLibraryVersion()
- {
- return _libraryVersion;
- }
-
- public void setResourceVersion(String resourceVersion)
- {
- this._resourceVersion = resourceVersion;
- }
-
- public String getResourceVersion()
- {
- return _resourceVersion;
- }
+ public abstract String getResourceVersion();
- @Override
- public String toString()
- {
- StringBuilder builder = new StringBuilder();
- boolean firstSlashAdded = false;
- if (_prefix != null && _prefix.length() > 0)
- {
- builder.append(_prefix);
- firstSlashAdded = true;
- }
- if (_libraryName != null)
- {
- if (firstSlashAdded) builder.append('/');
- builder.append(_libraryName);
- firstSlashAdded = true;
- }
- if (_libraryVersion != null)
- {
- if (firstSlashAdded) builder.append('/');
- builder.append(_libraryVersion);
- firstSlashAdded = true;
- }
- if (_resourceName != null)
- {
- if (firstSlashAdded) builder.append('/');
- builder.append(_resourceName);
- firstSlashAdded = true;
- }
- if (_resourceVersion != null)
- {
- if (firstSlashAdded) builder.append('/');
- builder.append(_resourceVersion);
- builder.append(
- _resourceName.substring(_resourceName.lastIndexOf('.')));
- firstSlashAdded = true;
- }
-
- return builder.toString();
- }
-
+ public abstract String getResourceIdentifier();
+
+ public abstract boolean couldResourceContainValueExpressions();
}
Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceMetaImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceMetaImpl.java?rev=946779&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceMetaImpl.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceMetaImpl.java Thu May 20 20:31:42 2010
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.resource;
+
+/**
+ * Contains the metadata information to reference a resource
+ *
+ * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
+ * @version $Revision: 700544 $ $Date: 2008-09-30 13:44:02 -0500 (Mar, 30 Sep 2008) $
+ */
+public class ResourceMetaImpl extends ResourceMeta
+{
+
+ private final String _prefix;
+ private final String _libraryName;
+ private final String _libraryVersion;
+ private final String _resourceName;
+ private final String _resourceVersion;
+
+ public ResourceMetaImpl(String prefix, String libraryName, String libraryVersion,
+ String resourceName, String resourceVersion)
+ {
+ _prefix = prefix;
+ _libraryName = libraryName;
+ _libraryVersion = libraryVersion;
+ _resourceName = resourceName;
+ _resourceVersion = resourceVersion;
+ }
+
+ public String getLibraryName()
+ {
+ return _libraryName;
+ }
+
+ public String getResourceName()
+ {
+ return _resourceName;
+ }
+
+ public String getLocalePrefix()
+ {
+ return _prefix;
+ }
+
+ public String getLibraryVersion()
+ {
+ return _libraryVersion;
+ }
+
+ public String getResourceVersion()
+ {
+ return _resourceVersion;
+ }
+
+ @Override
+ public String getResourceIdentifier()
+ {
+ StringBuilder builder = new StringBuilder();
+ boolean firstSlashAdded = false;
+ if (_prefix != null && _prefix.length() > 0)
+ {
+ builder.append(_prefix);
+ firstSlashAdded = true;
+ }
+ if (_libraryName != null)
+ {
+ if (firstSlashAdded) builder.append('/');
+ builder.append(_libraryName);
+ firstSlashAdded = true;
+ }
+ if (_libraryVersion != null)
+ {
+ if (firstSlashAdded) builder.append('/');
+ builder.append(_libraryVersion);
+ firstSlashAdded = true;
+ }
+ if (_resourceName != null)
+ {
+ if (firstSlashAdded) builder.append('/');
+ builder.append(_resourceName);
+ firstSlashAdded = true;
+ }
+ if (_resourceVersion != null)
+ {
+ if (firstSlashAdded) builder.append('/');
+ builder.append(_resourceVersion);
+ builder.append(
+ _resourceName.substring(_resourceName.lastIndexOf('.')));
+ firstSlashAdded = true;
+ }
+
+ return builder.toString();
+ }
+
+ @Override
+ public boolean couldResourceContainValueExpressions()
+ {
+ return false;
+ }
+}