You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2010/01/09 17:14:25 UTC
svn commit: r897484 - in /myfaces/extensions/scripting/trunk:
core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/
core/core/src/main/java/org/apache/myfaces/extensions/scripting/compiler/
core/core/src/main/java/org/apache/myfaces/scripting...
Author: werpu
Date: Sat Jan 9 16:14:25 2010
New Revision: 897484
URL: http://svn.apache.org/viewvc?rev=897484&view=rev
Log:
finishing the implementations of the source redirecting resource handlers for ext-scripting
removal of many typos
Added:
myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceHandler.java (with props)
myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceHandlerSupport.java (with props)
myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceLoader.java (with props)
Modified:
myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/Groovy2GroovyObjectReloadingProxy.groovy
myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/GroovyGlobalReloadingStrategy.groovy
myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/GroovyWeaver.groovy
myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/StandardGroovyReloadingStrategy.groovy
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/extensions/scripting/compiler/CompilationException.java
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/extensions/scripting/compiler/Compiler.java
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/extensions/scripting/compiler/CompilerFactory.java
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/AnnotationScanListener.java
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/BaseWeaver.java
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/refresh/RefreshContext.java
myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/HelloWorldController.java
myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/faces-config.xml
myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/Blog.java
myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/BlogService.java
myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/JSFUtil.java
myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/web.xml
myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/helloWorld.xhtml
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/Groovy2GroovyObjectReloadingProxy.groovy
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/Groovy2GroovyObjectReloadingProxy.groovy?rev=897484&r1=897483&r2=897484&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/Groovy2GroovyObjectReloadingProxy.groovy (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/Groovy2GroovyObjectReloadingProxy.groovy Sat Jan 9 16:14:25 2010
@@ -24,13 +24,13 @@
import org.apache.myfaces.scripting.core.util.WeavingContext
/**
- * A proxying class doing constructor interceoption
+ * A proxying class doing constructor interception
* to enable dynamic reload of groovy classes
* on constructor setup
*
* Every groovy class
* generated is marked with this
- * procy on its metaclass
+ * proxy on its metaclass
* however java omits the meta data
* this proxy is only used for groovy 2 groovy
* references and should allow code reloading
@@ -45,10 +45,10 @@
*
*/
class Groovy2GroovyObjectReloadingProxy extends MetaclassStubcompilerFix {
-/*
-due to a bug in the groovy meta stub compiler
-we have to derive from our own object here
-*/
+ /*
+ due to a bug in the groovy meta stub compiler
+ we have to derive from our own object here
+ */
boolean tainted = false
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/GroovyGlobalReloadingStrategy.groovy
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/GroovyGlobalReloadingStrategy.groovy?rev=897484&r1=897483&r2=897484&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/GroovyGlobalReloadingStrategy.groovy (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/GroovyGlobalReloadingStrategy.groovy Sat Jan 9 16:14:25 2010
@@ -17,7 +17,7 @@
*
* so er have to set the all others instance var to a specialized reloading strategy
* and cope with the rest the standard java way by not doing anything
- *
+ *
*/
public class GroovyGlobalReloadingStrategy extends org.apache.myfaces.scripting.core.reloading.GlobalReloadingStrategy {
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/GroovyWeaver.groovy
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/GroovyWeaver.groovy?rev=897484&r1=897483&r2=897484&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/GroovyWeaver.groovy (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/GroovyWeaver.groovy Sat Jan 9 16:14:25 2010
@@ -34,7 +34,7 @@
/**
* Weaver which does dynamic class reloading
- * and in groovy2groovy encironments also adds
+ * and in groovy2groovy environments also adds
* a transparent reloading proxy
* that way we get a dynamic reloading
* upon file change
@@ -68,7 +68,7 @@
_reloadingStrategy.setWeaver(this)
//init classpath removed we can resolve that over the
- //url classloader at the time myfaces is initialized
+ //url classloader at the time MyFaces is initialized
try {
Class scanner = ClassUtils.getContextClassLoader().loadClass("org.apache.myfaces.scripting.jsf2.annotation.GenericAnnotationScanner");
Class[] params = new Class[1];
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/StandardGroovyReloadingStrategy.groovy
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/StandardGroovyReloadingStrategy.groovy?rev=897484&r1=897483&r2=897484&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/StandardGroovyReloadingStrategy.groovy (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/StandardGroovyReloadingStrategy.groovy Sat Jan 9 16:14:25 2010
@@ -29,6 +29,10 @@
super(weaver);
}
+ public StandardGroovyReloadingStrategy() {
+ super();
+ }
+
/**
* central algorithm which determines which property values are overwritten and which are not
*/
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/extensions/scripting/compiler/CompilationException.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/extensions/scripting/compiler/CompilationException.java?rev=897484&r1=897483&r2=897484&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/extensions/scripting/compiler/CompilationException.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/extensions/scripting/compiler/CompilationException.java Sat Jan 9 16:14:25 2010
@@ -19,12 +19,12 @@
package org.apache.myfaces.extensions.scripting.compiler;
/**
- * <p>This exception will usually be thrown if an error occured while compiling a
+ * <p>This exception will usually be thrown if an error occurred while compiling a
* set of source files. However, note that it doesn't mean that the source files
* themselves contained errors but rather that the system couldn't managed to
* find an appropriate compiler implementation, etc.</p>
* <p/>
- * <p>In order to determine whether the compiler sucessfully compiled a certain
+ * <p>In order to determine whether the compiler successfully compiled a certain
* source file you have to look for the compilation result instead.</p>
*/
public class CompilationException extends Exception {
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/extensions/scripting/compiler/Compiler.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/extensions/scripting/compiler/Compiler.java?rev=897484&r1=897483&r2=897484&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/extensions/scripting/compiler/Compiler.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/extensions/scripting/compiler/Compiler.java Sat Jan 9 16:14:25 2010
@@ -52,7 +52,7 @@
* @param file the relative file name of the class you want to compile
* @param classLoader the class loader for dependent classes
* @return the compilation result, i.e. the compiler output, a list of errors and a list of warnings
- * @throws CompilationException if a severe error occured while trying to compile a file
+ * @throws CompilationException if a severe error occurred while trying to compile a file
*/
public CompilationResult compile(File sourcePath, File targetPath, String file, ClassLoader classLoader)
throws CompilationException;
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/extensions/scripting/compiler/CompilerFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/extensions/scripting/compiler/CompilerFactory.java?rev=897484&r1=897483&r2=897484&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/extensions/scripting/compiler/CompilerFactory.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/extensions/scripting/compiler/CompilerFactory.java Sat Jan 9 16:14:25 2010
@@ -7,7 +7,7 @@
* <p>This factory chooses and creates an instance of the according compiler
* implementation based on the current JVM for you. If you're using a Java 6
* VM, it will return a compiler using the JSR-199 API, otherwise it will
- * return a compiler that uses the Javac tool.</p>
+ * return a compiler that uses the JavaC tool.</p>
*/
public class CompilerFactory {
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/AnnotationScanListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/AnnotationScanListener.java?rev=897484&r1=897483&r2=897484&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/AnnotationScanListener.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/AnnotationScanListener.java Sat Jan 9 16:14:25 2010
@@ -19,14 +19,13 @@
package org.apache.myfaces.scripting.api;
-import java.util.Map;
import java.lang.annotation.Annotation;
/**
* @author Werner Punz (latest modification by $Author$)
* @version $Revision$ $Date$
* <p/>
- * We use a source code artefact observer here to register the
+ * We use a source code artifact observer here to register the
* meta data in the correct registry entries
*/
@@ -35,8 +34,8 @@
/**
* returns true if the annotation marked by the incoming parameter is supported by this scanner
*
- * @param annotation the supported annotation as neutral string representation of its class
- * @return in case of support
+ * @param annotation the supported annotation as neutral string representation of its class
+ * @return in case of support
*/
public boolean supportsAnnotation(String annotation);
@@ -44,16 +43,16 @@
/**
* class file registration of the supported annotation
*
- * @param clazz
- * @param annotationName
+ * @param clazz the class to be registered
+ * @param annotationName the annotation for the class
*/
public void register(Class clazz, Annotation annotationName);
/**
* purges the class from the correct places of the myfaces registry
- * so that the artefact is not reachable anymore
+ * so that the artifact is not reachable anymore
*
- * @param className
+ * @param className the class name for the class which needs to be purged
*/
public void purge(String className);
}
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/BaseWeaver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/BaseWeaver.java?rev=897484&r1=897483&r2=897484&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/BaseWeaver.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/BaseWeaver.java Sat Jan 9 16:14:25 2010
@@ -87,7 +87,7 @@
/**
* helper for accessing the reloading metadata map
*
- * @return
+ * @return a map with the class name as key and the reloading meta data as value
*/
protected Map<String, ReloadingMetadata> getClassMap() {
return WeavingContext.getFileChangedDaemon().getClassMap();
@@ -96,10 +96,11 @@
/**
* reloads a scripting instance object
*
- * @param scriptingInstance the object which has to be reloaded
- * @return the reloaded object with all properties transferred or the original object if no reloading was needed
+ * @param scriptingInstance the object which has to be reloaded
+ * @param artifactType integer value indication which type of JSF artifact we have to deal with
+ * @return the reloaded object with all properties transferred or the original object if no reloading was needed
*/
- public Object reloadScriptingInstance(Object scriptingInstance, int artefactType) {
+ public Object reloadScriptingInstance(Object scriptingInstance, int artifactType) {
Map<String, ReloadingMetadata> classMap = getClassMap();
if (classMap.size() == 0) {
return scriptingInstance;
@@ -109,10 +110,10 @@
//This gives a minor speedup because we jump out as soon as possible
//files never changed do not even have to be considered
- //not tained even once == not even considered to be reloaded
+ //not tainted even once == not even considered to be reloaded
if (isReloadCandidate(reloadMeta)) {
- Object reloaded = _reloadingStrategy.reload(scriptingInstance, artefactType);
+ Object reloaded = _reloadingStrategy.reload(scriptingInstance, artifactType);
if (reloaded != null) {
return reloaded;
}
@@ -151,9 +152,9 @@
}
/**
- * recompiles and loads a scripting class from a given classname
+ * recompiles and loads a scripting class from a given class name
*
- * @param className the classname including the package
+ * @param className the class name including the package
* @return a valid class if the sources could be found null if nothing could be found
*/
public Class loadScriptingClassFromName(String className) {
@@ -175,7 +176,7 @@
if (metadata != null) {
return reloadScriptingClass(metadata.getAClass());
}
- Class retVal = (Class) loadScriptingClassFromFile(pathEntry, fileName);
+ Class retVal = loadScriptingClassFromFile(pathEntry, fileName);
if (retVal != null) {
return retVal;
}
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/refresh/RefreshContext.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/refresh/RefreshContext.java?rev=897484&r1=897483&r2=897484&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/refresh/RefreshContext.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/refresh/RefreshContext.java Sat Jan 9 16:14:25 2010
@@ -64,15 +64,15 @@
* and also a global refresh has to be atomic and no other
* refreshes should happen
*/
- public volatile static Boolean BEAN_SYNC_MONITOR = new Boolean(true);
+ public final static Boolean BEAN_SYNC_MONITOR = new Boolean(true);
/**
* second synchronisation monitor
- * all other artefacts can only be refreshed outside of a
- * compile cycle othwise the classloader would get
+ * all other artifacts can only be refreshed outside of a
+ * compile cycle otherwise the classloader would get
* half finished compile states to load
*/
- public volatile static Boolean COMPILE_SYNC_MONITOR = new Boolean(true);
+ public final static Boolean COMPILE_SYNC_MONITOR = new Boolean(true);
private volatile AtomicInteger currentlyRunningRequests = null;
Modified: myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/HelloWorldController.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/HelloWorldController.java?rev=897484&r1=897483&r2=897484&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/HelloWorldController.java (original)
+++ myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/HelloWorldController.java Sat Jan 9 16:14:25 2010
@@ -20,34 +20,34 @@
/**
* A typical simple backing bean, that is backed to <code>helloworld.jsp</code>
- *
*/
public class HelloWorldController {
-
//properties
private String name;
-
+
/**
* default empty constructor
*/
- public HelloWorldController(){
+ public HelloWorldController() {
}
-
+
//-------------------getter & setter
+
public String getName() {
ClassLoader cls = Thread.currentThread().getContextClassLoader();
return name;
}
+
public void setName(String name) {
ClassLoader cls = Thread.currentThread().getContextClassLoader();
this.name = name;
}
-
+
/**
* Method that is backed to a submit button of a form.
*/
- public String send(){
+ public String send() {
//do real logic, return a string which will be used for the navigation system of JSF
return "success";
}
Added: myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceHandler.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceHandler.java?rev=897484&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceHandler.java (added)
+++ myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceHandler.java Sat Jan 9 16:14:25 2010
@@ -0,0 +1,98 @@
+/*
+ * 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.blank;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.application.ResourceHandlerImpl;
+import org.apache.myfaces.application.ResourceHandlerSupport;
+import org.apache.myfaces.scripting.api.Decorated;
+
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
+import javax.faces.context.FacesContext;
+import java.io.IOException;
+
+/**
+ * A simple delegating resource handler
+ * which is supposed to pick up resources from a
+ * given location if the Weaving configuration
+ * has the parameter present
+ */
+class SourceResourceHandler extends ResourceHandlerImpl implements Decorated {
+
+ ResourceHandler _delegate = null;
+ Log log = LogFactory.getLog(this.getClass());
+ ResourceHandlerSupport _sourceHandlerSupport = null;
+
+ public SourceResourceHandler(ResourceHandler delegate) {
+ _delegate = delegate;
+ }
+
+ public Resource createResource(String resourceName) {
+ log.info("[EXT-SCRIPTUNG]" + resourceName);
+ return _delegate.createResource(resourceName);
+ }
+
+ public Resource createResource(String resourceName, String libraryName) {
+ log.info("[EXT-SCRIPTUNG]" + resourceName + "-" + libraryName);
+ return _delegate.createResource(resourceName, libraryName);
+ }
+
+ public Resource createResource(String resourceName, String libraryName, String contentType) {
+ log.info("[EXT-SCRIPTUNG]" + resourceName);
+ return _delegate.createResource(resourceName, libraryName, contentType);
+ }
+
+ public String getRendererTypeForResourceName(String resourceName) {
+ return _delegate.getRendererTypeForResourceName(resourceName);
+ }
+
+ public void handleResourceRequest(FacesContext context) throws IOException {
+ _delegate.handleResourceRequest(context);
+ }
+
+ public boolean isResourceRequest(FacesContext context) {
+ return _delegate.isResourceRequest(context);
+ }
+
+ public boolean libraryExists(String libraryName) {
+ return _delegate.libraryExists(libraryName);
+ }
+
+ public ResourceHandler getDelegate() {
+ return _delegate;
+ }
+
+ @Override
+ /**
+ * central override of this class it provides a new handler
+ * support class which allows source pickups after the
+ * JSF2 specified restful algorithms
+ *
+ * @return A support instance which allows also source pickups from resources additionally to the
+ * default deployment and jar pickups
+ */
+ protected ResourceHandlerSupport getResourceHandlerSupport() {
+ if (_sourceHandlerSupport == null) {
+ _sourceHandlerSupport = new SourceResourceHandlerSupport();
+ }
+ return _sourceHandlerSupport;
+ }
+}
Propchange: myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceHandler.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceHandlerSupport.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceHandlerSupport.java?rev=897484&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceHandlerSupport.java (added)
+++ myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceHandlerSupport.java Sat Jan 9 16:14:25 2010
@@ -0,0 +1,89 @@
+/*
+ * 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.blank;
+
+import org.apache.myfaces.application.DefaultResourceHandlerSupport;
+import org.apache.myfaces.application.ResourceHandlerSupport;
+import org.apache.myfaces.resource.ClassLoaderResourceLoader;
+import org.apache.myfaces.resource.ExternalContextResourceLoader;
+import org.apache.myfaces.resource.ResourceLoader;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * impl specific handler support which attaches
+ * the source resource loader upfront before
+ * checking the other ones
+ * <p/>
+ * a delegate is used to limit the binding between
+ * the "parent" class and the child class
+ * in this case it simply makes sense to avoid any internal sideeffects
+ * between getResourceLoaders and the other methods (there aren«t any in the
+ * current implementation, but we cannot rely on it fully for future implementations)
+ */
+public class SourceResourceHandlerSupport implements ResourceHandlerSupport {
+
+ private ResourceLoader[] _supportResourceLoaders;
+ private ResourceHandlerSupport _delegate = new DefaultResourceHandlerSupport();
+
+ @Override
+ /**
+ * Delivers a list of resource loaders in a binding order
+ * of the resource lookup algorithms
+ *
+ * @return a list of resource loaders with following order,
+ * <ul>
+ * <li>source lookup paths if present</li>
+ * <li>/resources directory</li>
+ * <li>META-INF/resources directory</li>
+ * </ul>
+ */
+ public ResourceLoader[] getResourceLoaders() {
+ if (_supportResourceLoaders == null) {
+ //The ExternalContextResourceLoader has precedence over
+ //ClassLoaderResourceLoader, so it goes first.
+ _supportResourceLoaders = new ResourceLoader[]{
+ new SourceResourceLoader(""),
+ new ExternalContextResourceLoader("/resources"),
+ new ClassLoaderResourceLoader("META-INF/resources")
+ };
+ }
+ return _supportResourceLoaders;
+ }
+
+ public String calculateResourceBasePath(FacesContext facesContext) {
+ return _delegate.calculateResourceBasePath(facesContext);
+ }
+
+ public boolean isExtensionMapping() {
+ return _delegate.isExtensionMapping();
+ }
+
+ public String getMapping() {
+ return _delegate.getMapping();
+ }
+
+ public long getStartupTime() {
+ return _delegate.getStartupTime();
+ }
+
+ public long getMaxTimeExpires() {
+ return _delegate.getMaxTimeExpires();
+ }
+}
Propchange: myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceHandlerSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceHandlerSupport.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceLoader.java?rev=897484&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceLoader.java (added)
+++ myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceLoader.java Sat Jan 9 16:14:25 2010
@@ -0,0 +1,54 @@
+/*
+ * 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.blank;
+
+import org.apache.myfaces.resource.ExternalContextResourceLoader;
+import org.apache.myfaces.scripting.core.util.WeavingContext;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * internal resource loader to be used with our custom resource handler
+ * the resource loader is added to the list of available loaders
+ * so that the resource gets loaded properly from our source path
+ * instead of the web context if present, the source paths as usual
+ * are picked up by our context params.
+ */
+class SourceResourceLoader extends ExternalContextResourceLoader {
+
+ public SourceResourceLoader(String prefix) {
+ super(prefix);
+ }
+
+ @Override
+ protected Set<String> getResourcePaths(String path) {
+ List<String> resourceRoots = WeavingContext.getConfiguration().getResourceDirs();
+ if (resourceRoots == null || resourceRoots.isEmpty()) {
+ return Collections.EMPTY_SET;
+ }
+ Set<String> retVals = new HashSet<String>(resourceRoots.size());
+ for (String resourceRoot : resourceRoots) {
+ retVals.add(resourceRoot + "/" + path);
+ }
+ return retVals;
+ }
+}
Propchange: myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceLoader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SourceResourceLoader.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/faces-config.xml?rev=897484&r1=897483&r2=897484&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/faces-config.xml Sat Jan 9 16:14:25 2010
@@ -61,6 +61,9 @@
<navigation-handler>
org.apache.myfaces.groovyloader.test.TestNavigationHandler
</navigation-handler>
+ <resource-handler>
+ org.apache.myfaces.blank.SourceResourceHandler
+ </resource-handler>
</application>
@@ -103,6 +106,11 @@
<component-type>org.apache.myfaces.groovyloader.test.TestComponent</component-type>
<component-class>org.apache.myfaces.groovyloader.test.TestComponent</component-class>
</component>
+
+
+
+
+
<render-kit>
<renderer>
<component-family>javax.faces.Input</component-family>
Modified: myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/Blog.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/Blog.java?rev=897484&r1=897483&r2=897484&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/Blog.java (original)
+++ myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/Blog.java Sat Jan 9 16:14:25 2010
@@ -20,10 +20,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.scripting.loaders.java.ScriptingClass;
import static org.apache.myfaces.javaloader.blog.JSFUtil.*;
-import static org.apache.myfaces.scripting.core.util.ReflectUtil.*;
/**
* @author werpu2
Modified: myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/BlogService.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/BlogService.java?rev=897484&r1=897483&r2=897484&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/BlogService.java (original)
+++ myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/BlogService.java Sat Jan 9 16:14:25 2010
@@ -18,11 +18,9 @@
*/
package org.apache.myfaces.javaloader.blog;
-import org.apache.myfaces.scripting.loaders.java.ScriptingClass;
-
-import java.util.List;
-import java.util.LinkedList;
import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
/**
* @author werpu2
Modified: myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/JSFUtil.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/JSFUtil.java?rev=897484&r1=897483&r2=897484&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/JSFUtil.java (original)
+++ myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/JSFUtil.java Sat Jan 9 16:14:25 2010
@@ -21,10 +21,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import javax.faces.context.FacesContext;
-import static org.apache.myfaces.scripting.core.util.ReflectUtil.*;
+import static org.apache.myfaces.scripting.core.util.ReflectUtil.executeMethod;
/**
* @author werpu2
Modified: myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/web.xml?rev=897484&r1=897483&r2=897484&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/web.xml (original)
+++ myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/web.xml Sat Jan 9 16:14:25 2010
@@ -72,9 +72,28 @@
<param-name>org.apache.myfaces.scripting.java.LOADER_PATHS</param-name>
<param-value>D:/dev/work/ideaprojects/threads/extscript/examples/myfaces20-example/src/main/webapp/WEB-INF/java</param-value>
</context-param>
+
+
+ <context-param>
+ <description>additional comma separated resource pickup paths</description>
+ <param-name>org.apache.myfaces.scripting.resources.LOADER_PATHS</param-name>
+ <param-value>D:/dev/work/ideaprojects/threads/extscript/examples/myfaces20-example/src/main/webapp/WEB-INF/java</param-value>
+ </context-param>
-->
<context-param>
+ <description>resource paths for our custom facelet resource resolver</description>
+ <param-name>org.apache.myfaces.scripting.resources.LOADER_PATHS</param-name>
+ <param-value>/Users/werpu2/development/workspace/extensions-scripting3/examples/myfaces20-example/src/main/webapp</param-value>
+ </context-param>
+
+ <context-param>
+ <description>a redirecting Facelet resource resolver which allows to pick up templates and resources from our source dir</description>
+ <param-name>facelets.RESOURCE_RESOLVER</param-name>
+ <param-value>org.apache.myfaces.scripting.facelet.ReroutingResourceResolver</param-value>
+ </context-param>
+
+ <context-param>
<description>State saving method: "client" or "server" (= default)
See JSF Specification 2.5.3
</description>
Modified: myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/helloWorld.xhtml
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/helloWorld.xhtml?rev=897484&r1=897483&r2=897484&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/helloWorld.xhtml (original)
+++ myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/helloWorld.xhtml Sat Jan 9 16:14:25 2010
@@ -10,7 +10,7 @@
<ui:composition template = "/template.xhtml">
<ui:define name = "body">
- <h:form id = "form">
+ <h:form id = "form">
<h:panelGrid id = "grid" columns = "2">
<h:outputText id = "output1" value = "Please enter your name" />
<h:inputText id = "input1" value = "#{helloWorld.name}" required = "true">