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 2009/12/09 00:42:15 UTC

svn commit: r888630 [1/2] - in /myfaces/extensions/scripting/trunk/core: core-java6/ core-java6/src/main/java/org/apache/myfaces/scripting/loaders/java/jsr199/ core-java6/src/test/java/org/apache/myfaces/javaloader/core/ core/src/main/groovy/org/apache...

Author: werpu
Date: Tue Dec  8 23:42:13 2009
New Revision: 888630

URL: http://svn.apache.org/viewvc?rev=888630&view=rev
Log:
https://issues.apache.org/jira/browse/EXTSCRIPT-20
ongoing works on the bean strategies, I have refactored a few names which point
towards the correct patterns used now,
also I added an request map accessor in our central WeavingContext
so that we can add per request block code easier encapsulating the long jsf api that way

Added:
    myfaces/extensions/scripting/trunk/core/core-java6/src/main/java/org/apache/myfaces/scripting/loaders/java/jsr199/JSR199Compiler.java   (contents, props changed)
      - copied, changed from r885883, myfaces/extensions/scripting/trunk/core/core-java6/src/main/java/org/apache/myfaces/scripting/loaders/java/jsr199/CompilerFacade.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ArtefactType.java   (with props)
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ReloadingStrategy.java   (with props)
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/GlobalReloadingStrategy.java   (with props)
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/ManagedBeanReloadingStrategy.java   (with props)
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/SimpleReloadingStrategy.java   (with props)
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/Strategy.java   (with props)
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/WeavingContext.java   (contents, props changed)
      - copied, changed from r885883, myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ProxyUtils.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/util/
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/util/DirStrategy.java
      - copied, changed from r885883, myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/FileUtils.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/util/JavaFileStrategy.java
      - copied, changed from r885883, myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/FileUtils.java
Removed:
    myfaces/extensions/scripting/trunk/core/core-java6/src/main/java/org/apache/myfaces/scripting/loaders/java/jsr199/CompilerFacade.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ProxyUtils.java
Modified:
    myfaces/extensions/scripting/trunk/core/core-java6/pom.xml
    myfaces/extensions/scripting/trunk/core/core-java6/src/test/java/org/apache/myfaces/javaloader/core/JavaDynamicClassIdentifierTest.java
    myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/Groovy2GroovyObjectReloadingProxy.groovy
    myfaces/extensions/scripting/trunk/core/core/src/main/java/ideas.txt
    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/api/ScriptingWeaver.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/ConstructorLevelReloadingHandler.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/CoreWeaver.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/MethodLevelReloadingHandler.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/ReloadingInvocationHandler.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/FileUtils.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ReflectUtil.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/JavaScriptingWeaver.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/jdk5/Compiler.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/jdk5/CompilerFacade.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/jdk5/JavacCompiler.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/refresh/FileChangedDaemon.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/servlet/CustomChainLoader.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/servlet/ScriptingServletFilter.java
    myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/factories/ScriptingApplicationFactory.java
    myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/factories/ScriptingFacesContextFactory.java
    myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/factories/ScriptingLifecycleFactory.java
    myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/factories/ScriptingRenderkitFactory.java
    myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java
    myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java
    myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/FacesContextProxy.java
    myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/LifefcycleProxy.java
    myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/NavigationHandlerProxy.java
    myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/RenderkitProxy.java
    myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/VariableResolverProxy.java
    myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ViewHandlerProxy.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/factories/ScriptingApplicationFactory.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/factories/ScriptingFacesContextFactory.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/factories/ScriptingLifecycleFactory.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/factories/ScriptingRenderkitFactory.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/FacesContextProxy.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/LifefcycleProxy.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/NavigationHandlerProxy.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/RenderkitProxy.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ResourceHandlerProxy.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/VariableResolverProxy.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ViewHandlerProxy.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/BeanImplementationListener.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ComponentImplementationListener.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/JavaAnnotationScanner.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/RendererImplementationListener.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/startup/IntialScanAnnotationListener.java

Modified: myfaces/extensions/scripting/trunk/core/core-java6/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core-java6/pom.xml?rev=888630&r1=888629&r2=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core-java6/pom.xml (original)
+++ myfaces/extensions/scripting/trunk/core/core-java6/pom.xml Tue Dec  8 23:42:13 2009
@@ -10,6 +10,7 @@
         myfaces extension core java6 lib
     </description>
 
+    
     <parent>
         <groupId>org.apache.myfaces.extension-scripting</groupId>
         <artifactId>core-root</artifactId>

Copied: myfaces/extensions/scripting/trunk/core/core-java6/src/main/java/org/apache/myfaces/scripting/loaders/java/jsr199/JSR199Compiler.java (from r885883, myfaces/extensions/scripting/trunk/core/core-java6/src/main/java/org/apache/myfaces/scripting/loaders/java/jsr199/CompilerFacade.java)
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core-java6/src/main/java/org/apache/myfaces/scripting/loaders/java/jsr199/JSR199Compiler.java?p2=myfaces/extensions/scripting/trunk/core/core-java6/src/main/java/org/apache/myfaces/scripting/loaders/java/jsr199/JSR199Compiler.java&p1=myfaces/extensions/scripting/trunk/core/core-java6/src/main/java/org/apache/myfaces/scripting/loaders/java/jsr199/CompilerFacade.java&r1=885883&r2=888630&rev=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core-java6/src/main/java/org/apache/myfaces/scripting/loaders/java/jsr199/CompilerFacade.java (original)
+++ myfaces/extensions/scripting/trunk/core/core-java6/src/main/java/org/apache/myfaces/scripting/loaders/java/jsr199/JSR199Compiler.java Tue Dec  8 23:42:13 2009
@@ -31,21 +31,38 @@
 import java.util.Locale;
 
 /**
+ * <p>
  * A compiler facade encapsulating the JSR 199
  * so that we can switch the implementations
  * of connecting to javac on the fly
+ * </p>
+ * <p>
+ * This class is applied to systems which can use the JSR199 compiler
+ * API. For older systems we have a javac compiler fallback and
+ * probably in the long run also an eclipse as well.
+ * </p>
+ * <p>
+ * We applied first the apache commons-jci project there, but the state
+ * of the project was not where we needed it to be for our implementation
+ * and fixing and changing it was more work than what was needed for this project.
+ * In the dawn of the usage of JSR 199 it simply did not make any more sense
+ * to use commons-jci so we rolled our own small specialized facade for this
+ * </p>
+ *
+ * TODO move this over to the unified compiler interface
+ *
  *
  * @author Werner Punz (latest modification by $Author: werpu $)
  * @version $Revision: 812255 $ $Date: 2009-09-07 20:51:39 +0200 (Mo, 07 Sep 2009) $
  */
-public class CompilerFacade implements DynamicCompiler {
+public class JSR199Compiler implements DynamicCompiler {
 
     JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
     DiagnosticCollector<JavaFileObject> diagnosticCollector = new DiagnosticCollector();
     ContainerFileManager fileManager = null;
     private static final String FILE_SEPARATOR = File.separator;
 
-    public CompilerFacade() {
+    public JSR199Compiler() {
         super();
         fileManager = new ContainerFileManager(javaCompiler.getStandardFileManager(diagnosticCollector, null, null));
         if (javaCompiler == null) {

Propchange: myfaces/extensions/scripting/trunk/core/core-java6/src/main/java/org/apache/myfaces/scripting/loaders/java/jsr199/JSR199Compiler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/extensions/scripting/trunk/core/core-java6/src/main/java/org/apache/myfaces/scripting/loaders/java/jsr199/JSR199Compiler.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: myfaces/extensions/scripting/trunk/core/core-java6/src/test/java/org/apache/myfaces/javaloader/core/JavaDynamicClassIdentifierTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core-java6/src/test/java/org/apache/myfaces/javaloader/core/JavaDynamicClassIdentifierTest.java?rev=888630&r1=888629&r2=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core-java6/src/test/java/org/apache/myfaces/javaloader/core/JavaDynamicClassIdentifierTest.java (original)
+++ myfaces/extensions/scripting/trunk/core/core-java6/src/test/java/org/apache/myfaces/javaloader/core/JavaDynamicClassIdentifierTest.java Tue Dec  8 23:42:13 2009
@@ -21,10 +21,8 @@
 import org.junit.Test;
 import org.junit.Before;
 import static org.junit.Assert.*;
-import org.apache.myfaces.scripting.core.util.ProxyUtils;
+import org.apache.myfaces.scripting.core.util.WeavingContext;
 import org.apache.myfaces.scripting.core.CoreWeaver;
-import org.apache.myfaces.scripting.api.ScriptingConst;
-import org.apache.myfaces.scripting.loaders.java.DynamicClassIdentifier;
 import org.apache.myfaces.scripting.loaders.java.JavaScriptingWeaver;
 
 
@@ -43,14 +41,14 @@
         probe1 = new Probe1();
         probe2 = new Probe2();
         weaver = new CoreWeaver(new JavaScriptingWeaver());
-        ProxyUtils.setWeaver(weaver); 
+        WeavingContext.setWeaver(weaver);
     }
 
 
      @Test
      public void isDynamic() {
-        assertFalse("Class should be static",ProxyUtils.isDynamic(probe1.getClass()));
-        assertTrue("Class should be dynamic",ProxyUtils.isDynamic(probe2.getClass()));
+        assertFalse("Class should be static", WeavingContext.isDynamic(probe1.getClass()));
+        assertTrue("Class should be dynamic", WeavingContext.isDynamic(probe2.getClass()));
      }
 
 

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=888630&r1=888629&r2=888630&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 Tue Dec  8 23:42:13 2009
@@ -20,8 +20,8 @@
 
 import org.apache.myfaces.groovyloader.core.GroovyWeaver
 import org.apache.myfaces.scripting.loaders.groovy.MetaclassStubcompilerFix
-import org.apache.myfaces.scripting.core.util.ProxyUtils
-import org.apache.myfaces.scripting.core.util.ProxyUtils
+import org.apache.myfaces.scripting.core.util.WeavingContext
+import org.apache.myfaces.scripting.core.util.WeavingContext
 
 /**
  * A proxying class doing constructor interceoption
@@ -85,7 +85,7 @@
         Object a_object = super.invokeConstructor(objects);    //To change body of overridden methods use File | Settings | File Templates.
 
         if (weaver == null)
-            weaver = ProxyUtils.getWeaver();
+            weaver = WeavingContext.getWeaver();
 
         a_object = weaver.reloadScriptingInstance(a_object);
 

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/ideas.txt
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/ideas.txt?rev=888630&r1=888629&r2=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/ideas.txt (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/ideas.txt Tue Dec  8 23:42:13 2009
@@ -90,6 +90,107 @@
 track of the annotation states so that we can unregister deleted ones )
 
 
+----------------
+
+idea of a better compile cycle...
+problem currently, we do a class by class compile
+this strategy has been proven to be problematic, too many sidedependencies are not
+found and result in way too many classcast exceptions
+
+better option, since we cannot exchange the classes fully without getting exceptions
+from time to time on existing objects we try to minimize the problem the following ways
+
+beans: reload the classes which need to be reloaded, full bean tree reload with probably an annotation
+for beans which should be kept
+
+others full reload
+
+full recompilation if we have dirty classes at the beginning of the lifecycle so that
+we get fresh compilates at the time we access the page, no more on demand reload.
+
+We should keep a dirty marker centrally for artefacts which have changed.
+
+Additional advantage of the full recompile, we can deal with annotation scans on
+binary level instead of source level because and hence can support annotations
+on the fly,
+
+We still can get classcast exceptions because we cannot reload all artefacts newly compiled
+but we have less problems with classcasts than in our single file reloading strategy
+
+--------------
+
+clearing of the managed bean map:
+
+   public Object getValue(final ELContext context, final Object base, final Object property)
+        throws NullPointerException, PropertyNotFoundException, ELException
+    {
+
+        if (base != null)
+            return null;
+
+        if (property == null)
+        {
+            throw new PropertyNotFoundException();
+        }
+
+        final ExternalContext extContext = externalContext(context);
+
+        if (extContext == null)
+            return null;
+        if (extContext.getRequestMap().containsKey(property))
+            return null;
+        if (extContext.getSessionMap().containsKey(property))
+            return null;
+        if (extContext.getApplicationMap().containsKey(property))
+            return null;
+
+        if (!(property instanceof String))
+            return null;
+
+        final String strProperty = (String)property;
+
+        final ManagedBean managedBean = runtimeConfig(context).getManagedBean(strProperty);
+        Object beanInstance = null;
+        if (managedBean != null)
+        {
+            FacesContext facesContext = facesContext(context);
+            context.setPropertyResolved(true);
+            beanInstance = createManagedBean(managedBean, facesContext);
+        }
+
+        return beanInstance;
+
+        we have to clear the entire property from the request map, the session map and the application
+        map, once we have identified which managed beans are invalidated, so that
+        we can refresh all of them at request.
+
+        We also drop all properties there so and do not keep anything
+
+Ok lets sum everything up
+a) Strategy 1: we reload only the object affected and keep the properties intact,
+  positive: simple
+  negative: too limiting
+
+b) fine grained control of the reloading, we cascade over the entire object tree and invalidate the objects
+  touched by the dependency resolution while trying to keep the properties intact
+  positive: probably the best control over everything which has to be reloaded
+  negative: very complicated and slowest
+
+c) we drop all managed beans we have in the system only the ones we mark as not droppable are kept
+  (login handlers for testing etc...)
+  positive: very simple to implement by simply nulling all managed bean entries in the session application and request map
+  and then simply assigning the new managed beans to the objects kept
+  negative, way too much data loss in this case, we cannot keep the properties
+  
+
+
+
+
+
+
+
+
+
 
 
 

Added: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ArtefactType.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ArtefactType.java?rev=888630&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ArtefactType.java (added)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ArtefactType.java Tue Dec  8 23:42:13 2009
@@ -0,0 +1,26 @@
+package org.apache.myfaces.scripting.api;
+
+/**
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ *          <p/>
+ *          A set of artefact types which are used internally
+ *          so that the reloading strategies and other parts of the system
+ *          can adapt to the type of the artefact which has to be reloaded
+ */
+public enum ArtefactType {
+    MANAGED_BEAN,
+    COMPONENT,
+    BEHAVIOR,
+    VALIDATOR,
+    RENDERER,
+    NAV_HANDLER,
+    RENDERKIT,
+    VIEWHANDLER,
+    LIFECYCLE,
+    FACESCONTEXT,
+    ELRESOLVER,
+    VARIABLERESOLVER,
+    SCOPE,
+    RESOURCEHANDLER
+}

Propchange: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ArtefactType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ArtefactType.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

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=888630&r1=888629&r2=888630&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 Tue Dec  8 23:42:13 2009
@@ -4,6 +4,8 @@
 import org.apache.myfaces.scripting.api.ScriptingConst;
 import org.apache.myfaces.scripting.refresh.ReloadingMetadata;
 import org.apache.myfaces.scripting.refresh.FileChangedDaemon;
+import org.apache.myfaces.scripting.core.reloading.SimpleReloadingStrategy;
+import org.apache.myfaces.scripting.core.reloading.GlobalReloadingStrategy;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -27,9 +29,11 @@
      */
     protected List<String> scriptPaths = new LinkedList<String>();
 
+    ReloadingStrategy _reloadingStrategy = null;
+
 
     public BaseWeaver() {
-        //work around for yet another groovy bug
+        _reloadingStrategy = new GlobalReloadingStrategy(this);
     }
 
     public BaseWeaver(String fileEnding, int scriptingEngine) {
@@ -55,7 +59,7 @@
     /**
      * condition which marks a metadata as reload candidate
      */
-    protected boolean isReloadCandidate(ReloadingMetadata reloadMeta) {
+    public boolean isReloadCandidate(ReloadingMetadata reloadMeta) {
         return reloadMeta != null && assertScriptingEngine(reloadMeta) && reloadMeta.isTaintedOnce();
     }
 
@@ -87,27 +91,11 @@
         //not tained even once == not even considered to be reloaded
         if (isReloadCandidate(reloadMeta)) {
 
-            //reload the class to get new static content if needed
-            Class aclass = reloadScriptingClass(scriptingInstance.getClass());
-            if (aclass.hashCode() == scriptingInstance.getClass().hashCode()) {
-                //class of this object has not changed although
-                // reload is enabled we can skip the rest now
-                return scriptingInstance;
-            }
-            getLog().info("possible reload for " + scriptingInstance.getClass().getName());
-            /*only recreation of empty constructor classes is possible*/
-            try {
-                //reload the object by instiating a new class and
-                // assigning the attributes properly
-                Object newObject = aclass.newInstance();
-
-                /*now we shuffle the properties between the objects*/
-                mapProperties(newObject, scriptingInstance);
-
-                return newObject;
-            } catch (Exception e) {
-                getLog().error(e);
+            Object reloaded = _reloadingStrategy.reload(scriptingInstance);
+            if (reloaded != null) {
+                return reloaded;
             }
+
         }
         return scriptingInstance;
 
@@ -234,7 +222,7 @@
     }
 
     public ScriptingWeaver getWeaverInstance(Class weaverClass) {
-        if(getClass().equals(weaverClass)) return this;
+        if (getClass().equals(weaverClass)) return this;
 
         return null;
     }

Added: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ReloadingStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ReloadingStrategy.java?rev=888630&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ReloadingStrategy.java (added)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ReloadingStrategy.java Tue Dec  8 23:42:13 2009
@@ -0,0 +1,16 @@
+package org.apache.myfaces.scripting.api;
+
+/**
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ *
+ * Generic strategy for reloading
+ * this should encapsule various
+ * reloading strategies
+ * which have to be applied depending
+ * on the artefact
+ * 
+ */
+public interface ReloadingStrategy {
+    public Object reload(Object toReload);
+}

Propchange: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ReloadingStrategy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ReloadingStrategy.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ScriptingWeaver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ScriptingWeaver.java?rev=888630&r1=888629&r2=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ScriptingWeaver.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ScriptingWeaver.java Tue Dec  8 23:42:13 2009
@@ -42,6 +42,7 @@
 
     /**
      * @param o
+     * 
      * @return reloads an existing objects with its attributes
      *         and assigns the reloaded class to the new object
      *         <p/>

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/ConstructorLevelReloadingHandler.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/ConstructorLevelReloadingHandler.java?rev=888630&r1=888629&r2=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/ConstructorLevelReloadingHandler.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/ConstructorLevelReloadingHandler.java Tue Dec  8 23:42:13 2009
@@ -18,12 +18,11 @@
  */
 package org.apache.myfaces.scripting.core;
 
-import org.apache.myfaces.scripting.core.util.ProxyUtils;
+import org.apache.myfaces.scripting.core.util.WeavingContext;
 import org.apache.myfaces.scripting.api.Decorated;
 import org.apache.myfaces.scripting.api.ScriptingWeaver;
 
 import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
@@ -61,7 +60,7 @@
 
     protected Object reloadInvoke(Method method, Object[] objects) throws InstantiationException, IllegalAccessException, InvocationTargetException {
         if (_weaver == null)
-            _weaver = ProxyUtils.getWeaver();
+            _weaver = WeavingContext.getWeaver();
 
         if (_delegate == null) {
             //stateless or lost state due to a lifecycle iteration we trigger anew
@@ -80,7 +79,7 @@
 
     private void unmapProxies(Object[] objects) {
         for (int cnt = 0; cnt < objects.length; cnt++) {
-            objects[cnt] = ProxyUtils.getDelegateFromProxy(objects[cnt]);
+            objects[cnt] = WeavingContext.getDelegateFromProxy(objects[cnt]);
         }
     }
 

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/CoreWeaver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/CoreWeaver.java?rev=888630&r1=888629&r2=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/CoreWeaver.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/CoreWeaver.java Tue Dec  8 23:42:13 2009
@@ -20,7 +20,6 @@
 
 import org.apache.myfaces.scripting.api.ScriptingConst;
 import org.apache.myfaces.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.scripting.core.util.ProxyUtils;
 
 import java.io.Serializable;
 import java.util.ArrayList;
@@ -42,6 +41,8 @@
 
     List<ScriptingWeaver> _weavers = new ArrayList<ScriptingWeaver>();
 
+    
+
     public CoreWeaver(ScriptingWeaver... weavers) {
         for (ScriptingWeaver weaver : weavers) {
             _weavers.add(weaver);

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/MethodLevelReloadingHandler.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/MethodLevelReloadingHandler.java?rev=888630&r1=888629&r2=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/MethodLevelReloadingHandler.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/MethodLevelReloadingHandler.java Tue Dec  8 23:42:13 2009
@@ -19,13 +19,10 @@
 package org.apache.myfaces.scripting.core;
 
 
-import org.apache.myfaces.scripting.api.Decorated;
 import org.apache.myfaces.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.scripting.core.util.ProxyUtils;
-import org.apache.myfaces.scripting.core.util.ReflectUtil;
+import org.apache.myfaces.scripting.core.util.WeavingContext;
 
 import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
@@ -81,7 +78,7 @@
 
     protected Object reloadInvoke(Method method, Object[] objects) throws InstantiationException, IllegalAccessException, InvocationTargetException {
         if (_weaver == null)
-            _weaver = ProxyUtils.getWeaver();
+            _weaver = WeavingContext.getWeaver();
 
         if (_delegate == null) {
             //stateless or lost state due to a lifecycle iteration we trigger anew
@@ -91,7 +88,7 @@
             _delegate = _weaver.reloadScriptingInstance(_delegate);
 
             //we work our way through all proxies and fetch the class for further reference
-            Object delegate = ProxyUtils.getDelegateFromProxy(_delegate);
+            Object delegate = WeavingContext.getDelegateFromProxy(_delegate);
             _loadedClass = delegate.getClass();
         }
         //check for proxies and unproxy them before calling the methods
@@ -112,7 +109,7 @@
     private void unmapProxies(Object[] objects) {
         if (objects == null) return;
         for (int cnt = 0; cnt < objects.length; cnt++) {
-            objects[cnt] = ProxyUtils.getDelegateFromProxy(objects[cnt]);
+            objects[cnt] = WeavingContext.getDelegateFromProxy(objects[cnt]);
         }
     }
 }

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/ReloadingInvocationHandler.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/ReloadingInvocationHandler.java?rev=888630&r1=888629&r2=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/ReloadingInvocationHandler.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/ReloadingInvocationHandler.java Tue Dec  8 23:42:13 2009
@@ -1,12 +1,9 @@
 package org.apache.myfaces.scripting.core;
 
 import org.apache.myfaces.scripting.api.Decorated;
-import org.apache.myfaces.scripting.core.util.ProxyUtils;
 import org.apache.myfaces.scripting.core.util.ReflectUtil;
 
-import java.lang.reflect.Method;
 import java.lang.reflect.InvocationHandler;
-import java.util.Collection;
 
 /**
  * @author Werner Punz (latest modification by $Author$)

Added: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/GlobalReloadingStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/GlobalReloadingStrategy.java?rev=888630&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/GlobalReloadingStrategy.java (added)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/GlobalReloadingStrategy.java Tue Dec  8 23:42:13 2009
@@ -0,0 +1,51 @@
+/*
+ * 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.scripting.core.reloading;
+
+import org.apache.myfaces.scripting.api.ReloadingStrategy;
+import org.apache.myfaces.scripting.api.BaseWeaver;
+
+/**
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ *          <p/>
+ *          A reloading strategy chain of responsibility which switches
+ *          depending on the artefact type to the correct
+ *          strategy
+ */
+
+public class GlobalReloadingStrategy implements ReloadingStrategy {
+
+    private BaseWeaver _weaver = null;
+
+    private ReloadingStrategy _beanStrategy;
+    private ReloadingStrategy _allOthers;
+
+    public GlobalReloadingStrategy(BaseWeaver weaver) {
+        _weaver = weaver;
+        _beanStrategy = new ManagedBeanReloadingStrategy(weaver);
+        _allOthers = new SimpleReloadingStrategy(weaver);
+    }
+
+    public Object reload(Object toReload) {
+        //TODO add the managed bean identification code here
+        //so that we can switch strategies on the fly
+        return _allOthers.reload(toReload);
+    }
+}

Propchange: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/GlobalReloadingStrategy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/GlobalReloadingStrategy.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/ManagedBeanReloadingStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/ManagedBeanReloadingStrategy.java?rev=888630&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/ManagedBeanReloadingStrategy.java (added)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/ManagedBeanReloadingStrategy.java Tue Dec  8 23:42:13 2009
@@ -0,0 +1,134 @@
+/*
+ * 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.scripting.core.reloading;
+
+import org.apache.myfaces.scripting.api.ReloadingStrategy;
+import org.apache.myfaces.scripting.api.BaseWeaver;
+import org.apache.myfaces.config.element.ManagedBean;
+import org.apache.myfaces.config.RuntimeConfig;
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.context.FacesContext;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Map;
+import java.util.List;
+import java.util.HashMap;
+import java.util.ArrayList;
+
+/**
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ *          <p/>
+ *          The managed beans have a different reloading
+ *          strategy, TODO
+ *          we have to figure out which strategy to follow
+ */
+
+public class ManagedBeanReloadingStrategy implements ReloadingStrategy {
+
+    BaseWeaver _weaver;
+    Map<String, List<ManagedBean>> _managedBeanIdx = null;
+
+
+    public ManagedBeanReloadingStrategy(BaseWeaver weaver) {
+        _weaver = weaver;
+        buildupManagedBeanIdx();
+    }
+
+
+    private void buildupManagedBeanIdx() {
+        /**
+         * we build up a reverse index for the managed beans to resolve
+         * make it easier for dependency reloading
+         * the current loading strategy is simple
+         * normal attribute, we do shift from the old object to the new one
+         * managed bean we refresh on the managed bean as well
+         * we need the reverse index to identify whether the attribute class justifies for being a
+         * managed bean or not
+         */
+        _managedBeanIdx = new HashMap<String, List<ManagedBean>>();
+        Map<String, ManagedBean> beans = RuntimeConfig.getCurrentInstance(FacesContext.getCurrentInstance().getExternalContext()).getManagedBeans();
+        for (Map.Entry<String, ManagedBean> entry : beans.entrySet()) {
+            String className = entry.getValue().getManagedBeanClassName();
+            if (!_managedBeanIdx.containsKey(className)) {
+                List<ManagedBean> beanListForClass = new ArrayList<ManagedBean>();
+                _managedBeanIdx.put(className, beanListForClass);
+                beanListForClass.add(entry.getValue());
+            } else {
+                _managedBeanIdx.get(className).add(entry.getValue());
+            }
+        }
+    }
+
+    public Object reload(Object scriptingInstance) {
+        //TODO build up the managed bean idx at request time or make a request blocker
+        //so that we build up the idx only once per request
+
+        //reload the class to get new static content if needed
+        Class aclass = _weaver.reloadScriptingClass(scriptingInstance.getClass());
+        if (aclass.hashCode() == scriptingInstance.getClass().hashCode()) {
+            //class of this object has not changed although
+            // reload is enabled we can skip the rest now
+            return scriptingInstance;
+        }
+        getLog().info("possible reload for " + scriptingInstance.getClass().getName());
+        /*only recreation of empty constructor classes is possible*/
+        try {
+            //reload the object by instiating a new class and
+            // assigning the attributes properly
+            Object newObject = aclass.newInstance();
+
+            /*now we shuffle the properties between the objects*/
+            mapProperties(newObject, scriptingInstance);
+
+            return newObject;
+        } catch (Exception e) {
+            getLog().error(e);
+        }
+        return null;
+
+    }
+
+
+    /**
+     * helper to map the properties wherever possible
+     *
+     * @param target
+     * @param src
+     */
+    protected void mapProperties(Object target, Object src) {
+        try {
+            
+
+            BeanUtils.copyProperties(target, src);
+        } catch (IllegalAccessException e) {
+            getLog().debug(e);
+            //this is wanted
+        } catch (InvocationTargetException e) {
+            getLog().debug(e);
+            //this is wanted
+        }
+    }
+
+    protected Log getLog() {
+        return LogFactory.getLog(this.getClass());
+    }
+}

Propchange: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/ManagedBeanReloadingStrategy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/ManagedBeanReloadingStrategy.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/SimpleReloadingStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/SimpleReloadingStrategy.java?rev=888630&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/SimpleReloadingStrategy.java (added)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/SimpleReloadingStrategy.java Tue Dec  8 23:42:13 2009
@@ -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.scripting.core.reloading;
+
+import org.apache.myfaces.scripting.api.ReloadingStrategy;
+import org.apache.myfaces.scripting.api.BaseWeaver;
+import org.apache.myfaces.scripting.refresh.ReloadingMetadata;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.beanutils.BeanUtils;
+
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+public class SimpleReloadingStrategy implements ReloadingStrategy {
+
+    BaseWeaver _weaver;
+
+    public SimpleReloadingStrategy(BaseWeaver weaver) {
+        _weaver = weaver;
+    }
+
+    public Object reload(Object scriptingInstance) {
+
+        //reload the class to get new static content if needed
+        Class aclass = _weaver.reloadScriptingClass(scriptingInstance.getClass());
+        if (aclass.hashCode() == scriptingInstance.getClass().hashCode()) {
+            //class of this object has not changed although
+            // reload is enabled we can skip the rest now
+            return scriptingInstance;
+        }
+        getLog().info("possible reload for " + scriptingInstance.getClass().getName());
+        /*only recreation of empty constructor classes is possible*/
+        try {
+            //reload the object by instiating a new class and
+            // assigning the attributes properly
+            Object newObject = aclass.newInstance();
+
+            /*now we shuffle the properties between the objects*/
+            mapProperties(newObject, scriptingInstance);
+
+            return newObject;
+        } catch (Exception e) {
+            getLog().error(e);
+        }
+        return null;
+        
+    }
+
+
+    /**
+     * helper to map the properties wherever possible
+     *
+     * @param target
+     * @param src
+     */
+    protected void mapProperties(Object target, Object src) {
+        try {
+            BeanUtils.copyProperties(target, src);
+        } catch (IllegalAccessException e) {
+            getLog().debug(e);
+            //this is wanted
+        } catch (InvocationTargetException e) {
+            getLog().debug(e);
+            //this is wanted
+        }
+    }
+
+    protected Log getLog() {
+        return LogFactory.getLog(this.getClass());
+    }
+
+}

Propchange: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/SimpleReloadingStrategy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/SimpleReloadingStrategy.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/FileUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/FileUtils.java?rev=888630&r1=888629&r2=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/FileUtils.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/FileUtils.java Tue Dec  8 23:42:13 2009
@@ -50,4 +50,52 @@
         return tempDir;
     }
 
+
+    /**
+     * we roll our own treewalker here
+     * to avoid a dependency into commons fileutils
+     * and to apply an easier pattern than
+     * commons fileutils uses
+     *
+     * @param rootDir
+     * @param strategy
+     */
+    public static void listFiles(File rootDir, Strategy strategy) {
+        if(!rootDir.isDirectory()) {
+            strategy.apply(rootDir);
+            return;
+        }
+
+        //TODO apply a filter here instead of doing the check directly
+        File [] files = rootDir.listFiles();
+        for(File file: files) {
+            boolean isDirectory = file.isDirectory();
+            if(isDirectory && !file.getName().endsWith(".")) {
+                listFiles(file, strategy);
+                strategy.apply(file);
+            } else if (!isDirectory) {
+                strategy.apply(file);
+            }
+        }
+    }
+
+    /**
+     * <p>
+     * target path check to check if the targetPath is valid or can be created
+     * </p>
+     *
+     * @param path
+     */
+    public static void assertPath(File path) {
+        // The destination directory must already exist as javac will not create the destination directory.
+        if (!path.exists()) {
+            if (!path.mkdirs()) {
+                throw new IllegalStateException("It wasn't possible to create the target " +
+                                                "directory for the compiler ['" + path.getAbsolutePath() + "'].");
+            }
+
+            // If we've created the destination directory, we'll delete it as well once the application exits
+            path.deleteOnExit();
+        }
+    }
 }

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ReflectUtil.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ReflectUtil.java?rev=888630&r1=888629&r2=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ReflectUtil.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ReflectUtil.java Tue Dec  8 23:42:13 2009
@@ -26,7 +26,6 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.InvocationHandler;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 
 /**
@@ -165,7 +164,7 @@
         if (obj instanceof InvocationHandler) {
             InvocationHandler objToInvoke = (InvocationHandler) obj;
 
-            Object realTarget = ProxyUtils.getDelegateFromProxy(objToInvoke);
+            Object realTarget = WeavingContext.getDelegateFromProxy(objToInvoke);
 
             //first we try only the public because they are the most likely ones
             //to be accessed

Added: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/Strategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/Strategy.java?rev=888630&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/Strategy.java (added)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/Strategy.java Tue Dec  8 23:42:13 2009
@@ -0,0 +1,34 @@
+/*
+ * 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.scripting.core.util;
+
+/**
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ *
+ * Applied strategy class for iteration walkers
+ * to make the handling of iterated objects
+ * more scripty al
+ *
+ */
+public interface Strategy {
+
+    public void apply(Object element);
+
+}

Propchange: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/Strategy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/Strategy.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Copied: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/WeavingContext.java (from r885883, myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ProxyUtils.java)
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/WeavingContext.java?p2=myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/WeavingContext.java&p1=myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ProxyUtils.java&r1=885883&r2=888630&rev=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ProxyUtils.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/WeavingContext.java Tue Dec  8 23:42:13 2009
@@ -20,8 +20,6 @@
 
 import org.apache.myfaces.scripting.api.Decorated;
 import org.apache.myfaces.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.scripting.api.DynamicClassIdentifier;
-import org.apache.myfaces.scripting.api.BaseWeaver;
 import org.apache.myfaces.scripting.core.MethodLevelReloadingHandler;
 import org.apache.myfaces.scripting.core.DummyWeaver;
 import org.apache.myfaces.scripting.core.scanEvents.SystemEventProcessor;
@@ -29,27 +27,34 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.logging.Log;
 
+import javax.faces.context.FacesContext;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
- * A set of proxy utils called
+ * A set of weaving context class called
  * by the various subsystems
  *
  * @author Werner Punz
  */
-public class ProxyUtils {
+public class WeavingContext {
+
 
     /**
+     * <p>
      * we push our _weaver into the thread local
      * to avoid too many calls into the
      * context classloading hierarchy
      * this should speed things up a little bit.
-     * <p/>
+     * </p>
+     * <p>
      * Note we could work with this with static
      * objects as well but since we also have to work with context
      * reloading we probably are safer with filters
      * a reference in the context and a threadLocal variable
+     * </p>
      */
     static ThreadLocal _weaverHolder = new ThreadLocal();
 
@@ -60,10 +65,25 @@
 
     }
 
+
+    /**
+     * general shutdown clean
+     */
     public static void clean() {
         _weaverHolder.set(null);
     }
 
+    /**
+     * fetches the generic request map if available
+     *
+     * @return the request map if available, null otherwise
+     */
+    public Map<String, Object> getRequestAttributesMap() {
+        FacesContext ctx = FacesContext.getCurrentInstance();
+        if (ctx == null) return null;
+        return ctx.getExternalContext().getRequestMap();
+    }
+
 
     /**
      * @return returns the thread bound system event processor
@@ -77,6 +97,14 @@
         return retVal;
     }
 
+
+    /**
+     * the weavers are set from outside
+     * we have to provide the weaver facade
+     * for very thread accessing this system
+     *
+     * @param weaver
+     */
     public static void setWeaver(Object weaver) {
         _weaverHolder.set(weaver);
         if (FileChangedDaemon.getInstance().getWeavers() == null) {
@@ -84,20 +112,33 @@
         }
     }
 
+    /**
+     * checks whether the system
+     * has scripting enabled or not
+     *
+     * @return true in case of being scriptable
+     */
     public static boolean isScriptingEnabled() {
         return _weaverHolder.get() != null;
     }
 
+    /**
+     * fetches the weavers
+     * for this current thread
+     *
+     * @return a ScriptingWeaver chain for all weavers currently supported
+     */
     public static ScriptingWeaver getWeaver() {
         ScriptingWeaver weaver = (ScriptingWeaver) _weaverHolder.get();
         if (weaver == null) {
-            Log log = LogFactory.getLog(ProxyUtils.class);
+            Log log = LogFactory.getLog(WeavingContext.class);
             log.warn("Scripting Weaver is not set. Disabling script reloading subsystem. Make sure you have the scripting servlet filter enabled in your web.xml");
             _weaverHolder.set(new DummyWeaver());
         }
         return (ScriptingWeaver) _weaverHolder.get();
     }
 
+
     /**
      * we create a proxy to an existing object
      * which does reloading of the internal class
@@ -140,7 +181,7 @@
      * @return the unproxied object
      */
     public static Object getDelegateFromProxy(Object o) {
-        if(o == null) {
+        if (o == null) {
             return null;
         }
         if (o instanceof Decorated)

Propchange: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/WeavingContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/WeavingContext.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/JavaScriptingWeaver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/JavaScriptingWeaver.java?rev=888630&r1=888629&r2=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/JavaScriptingWeaver.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/JavaScriptingWeaver.java Tue Dec  8 23:42:13 2009
@@ -158,7 +158,7 @@
          * //we only deal with class level reloading here
          * //the deregistration notification should happen on artefact level (which will be the next subtask)
          */
-        if(_scanner != null) {
+        if (_scanner != null) {
             _scanner.scanClass(retVal);
         }
 
@@ -203,6 +203,11 @@
         for (String scriptPath : getScriptPaths()) {
             //compile via javac dynamically, also after this block dynamic compilation
             //for the entire length of the request,
+            try {
+                compiler.compileAllFiles(scriptPath, classPath);
+            } catch (ClassNotFoundException e) {
+                log.error(e);
+            }
 
         }
 

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/jdk5/Compiler.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/jdk5/Compiler.java?rev=888630&r1=888629&r2=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/jdk5/Compiler.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/jdk5/Compiler.java Tue Dec  8 23:42:13 2009
@@ -6,17 +6,27 @@
 /**
  *
  */
-interface Compiler {
+public interface Compiler {
 
     /**
      * <p>Compiles the given file and creates an according class file in the given target path.</p>
      *
      * @param sourcePath the path to the source directory
      * @param targetPath the path to the target directory
-     * @param file the relative file name of the class you want to compile
-     * 
+     * @param file       the relative file name of the class you want to compile
      * @return the compilation result, i.e. the compiler output, a list of errors and a list of warnings
      */
     public CompilationResult compile(File sourcePath, File targetPath, String file, String classPath) throws CompilationException;
 
+
+    /**
+     * <p>Compiles the given sources and creates an according class files in the given target path.</p>
+     *
+     * @param sourcePath the path to the source directory
+     * @param targetPath the path to the target directory
+     * @param file       the relative file name of the class you want to compile
+     * @return the compilation result, i.e. the compiler output, a list of errors and a list of warnings
+     */
+    public CompilationResult compile(File sourcePath, File targetPath, String classPath) throws CompilationException;
+
 }

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/jdk5/CompilerFacade.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/jdk5/CompilerFacade.java?rev=888630&r1=888629&r2=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/jdk5/CompilerFacade.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/jdk5/CompilerFacade.java Tue Dec  8 23:42:13 2009
@@ -49,6 +49,31 @@
     }
 
 
+    /**
+     * does a compilation of all files one compile per request
+     * is allowed for performance reasons, the request blocking will be done
+     * probably on the caller side of things
+     *
+     * @param sourceRoot
+     * @param classPath
+     */
+    public void compileAll(String sourceRoot, String classPath) {
+        try {
+            //TODO do a full compile and block the compile for the rest of the request
+            //so that we do not run into endless compile cycles
+
+            CompilationResult result = compiler.compile(new File(sourceRoot), fileManager.getTempDir(), fileManager.getClassPath());
+            displayMessages(result);
+            if(result.hasErrors()) {
+                log.error("Compiler output:" + result.getCompilerOutput());
+            }
+
+        } catch (CompilationException e) {
+            log.error(e);
+        }
+    }
+
+
     public Class compileFile(String sourceRoot, String classPath, String filePath) throws ClassNotFoundException {
 
         String className = filePath.replaceAll(File.separator, ".");
@@ -59,7 +84,7 @@
 
             displayMessages(result);
 
-            if (result.getErrors().size() == 0) {
+            if (!result.hasErrors()) {
                 ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
                 if (!(oldClassLoader instanceof RecompiledClassLoader)) {
                     try {
@@ -74,7 +99,7 @@
                     }
                 }
             } else {
-                log.error("Compiler output:"+result.getCompilerOutput());
+                log.error("Compiler output:" + result.getCompilerOutput());
             }
 
         } catch (CompilationException e) {
@@ -89,7 +114,7 @@
 
     private void displayMessages(CompilationResult result) {
         for (CompilationResult.CompilationMessage error : result.getErrors()) {
-            log.error(error.getLineNumber()+"-"+error.getMessage());
+            log.error(error.getLineNumber() + "-" + error.getMessage());
 
         }
         for (CompilationResult.CompilationMessage error : result.getWarnings()) {

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/jdk5/JavacCompiler.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/jdk5/JavacCompiler.java?rev=888630&r1=888629&r2=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/jdk5/JavacCompiler.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/jdk5/JavacCompiler.java Tue Dec  8 23:42:13 2009
@@ -3,6 +3,8 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.scripting.core.util.ClassUtils;
+import org.apache.myfaces.scripting.core.util.FileUtils;
+import org.apache.myfaces.scripting.loaders.java.util.DirStrategy;
 
 import java.io.File;
 import java.io.PrintWriter;
@@ -43,6 +45,7 @@
      * The class reference to the internal Javac compiler.
      */
     private Class compilerClass;
+    private static final String JAVA_WILDCARD = "*.java ";
 
     // ------------------------------------------ Constructors
 
@@ -80,26 +83,58 @@
 
     // ------------------------------------------ Compiler methods
 
+
     /**
      * <p>Compiles the given file and creates an according class file in the given target path.</p>
      *
      * @param sourcePath the path to the source directory
      * @param targetPath the path to the target directory
-     * @param file       the relative file name of the class you want to compile
      * @return the compilation result, i.e. as of now only the compiler output
      */
-    public CompilationResult compile(File sourcePath, File targetPath, String file, String classPath) throws CompilationException {
-        // The destination directory must already exist as javac will not create the destination directory.
-        if (!targetPath.exists()) {
-            if (!targetPath.mkdirs()) {
-                throw new IllegalStateException("It wasn't possible to create the target " +
-                                                "directory for the compiler ['" + targetPath.getAbsolutePath() + "'].");
+    public CompilationResult compile(File sourcePath, File targetPath, String classPath) throws CompilationException {
+        FileUtils.assertPath(targetPath);
+
+        try {
+            StringWriter compilerOutput = new StringWriter();
+
+            // Invoke the Javac compiler
+            Method compile = compilerClass.getMethod("compile", new Class[]{String[].class, PrintWriter.class});
+            Integer returnCode = (Integer) compile.invoke(null,
+                                                          new Object[]{buildCompilerArguments(sourcePath, targetPath, classPath), new PrintWriter(compilerOutput)});
+
+            CompilationResult result = new CompilationResult(compilerOutput.toString());
+            if (returnCode == null || returnCode.intValue() != 0) {
+                result.registerError(new CompilationResult.CompilationMessage(-1,
+                                                                              "Executing the javac compiler failed. The return code is '" + returnCode + "'."));
             }
 
-            // If we've created the destination directory, we'll delete it as well once the application exits
-            targetPath.deleteOnExit();
+            return result;
+        } catch (NoSuchMethodException ex) {
+            throw new IllegalStateException("The Javac compiler class '" + compilerClass + "' doesn't provide the method " +
+                                            "compile(String, PrintWriter). Are you sure that you're using a valid Sun JDK?", ex);
+        } catch (InvocationTargetException ex) {
+            throw new IllegalStateException("An error occured while invoking the compile(String, PrintWriter) method of the " +
+                                            "Javac compiler class '" + compilerClass + "'. Are you sure that you're using a valid Sun JDK?", ex);
+        } catch (IllegalAccessException ex) {
+            throw new IllegalStateException("An error occured while invoking the compile(String, PrintWriter) method of the " +
+                                            "Javac compiler class '" + compilerClass + "'. Are you sure that you're using a valid Sun JDK?", ex);
         }
 
+    }
+
+
+    /**
+     * <p>Compiles the given file and creates an according class file in the given target path.</p>
+     *
+     * @param sourcePath the path to the source directory
+     * @param targetPath the path to the target directory
+     * @param file       the relative file name of the class you want to compile
+     * @return the compilation result, i.e. as of now only the compiler output
+     */
+    public CompilationResult compile(File sourcePath, File targetPath, String file, String classPath) throws CompilationException {
+        // The destination directory must already exist as javac will not create the destination directory.
+        FileUtils.assertPath(targetPath);
+
         try {
             StringWriter compilerOutput = new StringWriter();
 
@@ -130,15 +165,71 @@
     // ------------------------------------------ Utility methods
 
     /**
+     * <p/>
+     * Creates the arguments for the compiler, i.e. builds up an array of arguments
+     * that one would pass to the javac compiler to compile a full path instead of a single file
+     *
+     * @param sourcePath the path to the source directory
+     * @param targetPath the path to the target directory
+     * @return an array of arguments that you have to pass to the Javac compiler
+     */
+    protected String[] buildCompilerArguments(File sourcePath, File targetPath, String classPath) {
+        DirStrategy dirStrategy = new DirStrategy();
+        FileUtils.listFiles(sourcePath, dirStrategy);
+
+        StringBuilder sourcesList = new StringBuilder(512);
+
+        String root = sourcePath.getAbsolutePath();
+        int rootLen = root.length() + 1;
+        for (File foundDir : dirStrategy.getFoundFiles()) {
+            String dirName = foundDir.getAbsolutePath();
+            dirName = dirName.substring(rootLen);
+            sourcesList.append(dirName);
+            sourcesList.append(File.separator);
+            sourcesList.append(JAVA_WILDCARD);
+        }
+        sourcesList.append(JAVA_WILDCARD);
+
+        List arguments = getDefaultArguments(sourcePath, targetPath, classPath);
+
+        // Append the source file that is to be compiled. Note that the user specifies only a relative file location.
+        arguments.add(sourcesList.toString());
+
+        return (String[]) arguments.toArray(new String[0]);
+    }
+
+    /**
      * <p>Creates the arguments for the compiler, i.e. it builds an array of arguments that one would pass to
      * the Javac compiler on the command line.</p>
      *
      * @param sourcePath the path to the source directory
      * @param targetPath the path to the target directory
+     * @param classPath  the classpath for the compiler
      * @param file       the relative file name of the class you want to compile
      * @return an array of arguments that you have to pass to the Javac compiler
      */
     protected String[] buildCompilerArguments(File sourcePath, File targetPath, String file, String classPath) {
+        List arguments = getDefaultArguments(sourcePath, targetPath, classPath);
+
+        // Append the source file that is to be compiled. Note that the user specifies only a relative file location.
+        arguments.add(new File(sourcePath, file).getAbsolutePath());
+
+        return (String[]) arguments.toArray(new String[0]);
+    }
+
+    /**
+     * <p>
+     * Determination of the default arguments
+     * which have to be the same over all
+     * different compilation strategies
+     * </p>
+     *
+     * @param sourcePath the path to the source directory
+     * @param targetPath the path to the target directory
+     * @param classPath  the classpath for the compiler
+     * @return
+     */
+    private List getDefaultArguments(File sourcePath, File targetPath, String classPath) {
         List arguments = new ArrayList();
 
         // Set both the source code path to search for class or interface
@@ -148,18 +239,14 @@
         arguments.add("-d");
         arguments.add(targetPath.getAbsolutePath());
         arguments.add("-cp");
-        arguments.add(classPath);       
+        arguments.add(classPath);
 
         // Enable verbose output.
         arguments.add("-verbose");
 
         // Generate all debugging information, including local variables.
         arguments.add("-g");
-
-        // Append the source file that is to be compiled. Note that the user specifies only a relative file location.
-        arguments.add(new File(sourcePath, file).getAbsolutePath());
-
-        return (String[]) arguments.toArray(new String[0]);
+        return arguments;
     }
 
     /**

Copied: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/util/DirStrategy.java (from r885883, myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/FileUtils.java)
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/util/DirStrategy.java?p2=myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/util/DirStrategy.java&p1=myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/FileUtils.java&r1=885883&r2=888630&rev=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/FileUtils.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/util/DirStrategy.java Tue Dec  8 23:42:13 2009
@@ -16,38 +16,35 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.myfaces.scripting.core.util;
+package org.apache.myfaces.scripting.loaders.java.util;
+
+import org.apache.myfaces.scripting.core.util.Strategy;
 
 import java.io.File;
+import java.util.List;
+import java.util.LinkedList;
 
 /**
  * @author Werner Punz (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
 
-public class FileUtils {
-    static double _tempMarker = Math.random();
-
-    public static File getTempDir() {
-        File tempDir = null;
+public class DirStrategy implements Strategy {
+    List<File> _foundFiles = new LinkedList<File>();
 
-        String baseTempPath = System.getProperty("java.io.tmpdir");
-        String tempDirName = "myfaces_compilation_" + _tempMarker;
-
-        tempDir = new File(baseTempPath + File.separator + tempDirName);
-        while (tempDir.exists()) {
-            tempDirName = "myfaces_compilation_" + System.currentTimeMillis() + Math.random();
-            tempDir = new File(baseTempPath + File.separator + tempDirName);
+    public void apply(Object element) {
+        File foundFile = (File) element;
+        if (foundFile.isDirectory()) {
+            _foundFiles.add(foundFile);
         }
+    }
 
-        synchronized (FileUtils.class) {
-            if (tempDir.exists()) {
-                return tempDir;
-            }
-            tempDir.mkdirs();
-            tempDir.deleteOnExit();
-        }
-        return tempDir;
+    public List<File> getFoundFiles() {
+        return _foundFiles;
     }
 
+    public void setFoundFiles(List<File> foundFiles) {
+        _foundFiles = foundFiles;
+    }
 }
+

Copied: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/util/JavaFileStrategy.java (from r885883, myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/FileUtils.java)
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/util/JavaFileStrategy.java?p2=myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/util/JavaFileStrategy.java&p1=myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/FileUtils.java&r1=885883&r2=888630&rev=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/FileUtils.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/util/JavaFileStrategy.java Tue Dec  8 23:42:13 2009
@@ -16,38 +16,38 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.myfaces.scripting.core.util;
+package org.apache.myfaces.scripting.loaders.java.util;
 
+import org.apache.myfaces.scripting.core.util.Strategy;
+
+import java.util.List;
+import java.util.LinkedList;
 import java.io.File;
 
 /**
  * @author Werner Punz (latest modification by $Author$)
  * @version $Revision$ $Date$
+ *          <p/>
+ *          Java file strategy pattern to filter out all java files which are possible sources
+ *          so that we can recompile them
  */
 
-public class FileUtils {
-    static double _tempMarker = Math.random();
+public class JavaFileStrategy implements Strategy {
 
-    public static File getTempDir() {
-        File tempDir = null;
+    List<File> _foundFiles = new LinkedList<File>();
 
-        String baseTempPath = System.getProperty("java.io.tmpdir");
-        String tempDirName = "myfaces_compilation_" + _tempMarker;
+    public void apply(Object element) {
+        File foundFile = (File) element;
+        String fileName = foundFile.getName().toLowerCase();
+        if (!fileName.endsWith(".java")) return;
+        _foundFiles.add(foundFile);
+    }
 
-        tempDir = new File(baseTempPath + File.separator + tempDirName);
-        while (tempDir.exists()) {
-            tempDirName = "myfaces_compilation_" + System.currentTimeMillis() + Math.random();
-            tempDir = new File(baseTempPath + File.separator + tempDirName);
-        }
-
-        synchronized (FileUtils.class) {
-            if (tempDir.exists()) {
-                return tempDir;
-            }
-            tempDir.mkdirs();
-            tempDir.deleteOnExit();
-        }
-        return tempDir;
+    public List<File> getFoundFiles() {
+        return _foundFiles;
     }
 
+    public void setFoundFiles(List<File> foundFiles) {
+        _foundFiles = foundFiles;
+    }
 }

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/refresh/FileChangedDaemon.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/refresh/FileChangedDaemon.java?rev=888630&r1=888629&r2=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/refresh/FileChangedDaemon.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/refresh/FileChangedDaemon.java Tue Dec  8 23:42:13 2009
@@ -52,7 +52,18 @@
     // ConcurrentHashMap<String, Renderer>(8, 0.75f, 1)
     // segmented map here because we have to deal with multithreaded access
     Map<String, ReloadingMetadata> classMap = new ConcurrentHashMap<String, ReloadingMetadata>(8, 0.75f, 1);
-    
+
+    /**
+     * this map is a shortcut for the various scripting engines
+     * it keeps track whether the engines source paths
+     * have dirty files or not and if true we enforce a recompile at the
+     * next refresh!
+     * <p/>
+     * We keep track on engine level to avoid to search the classMap for every refresh
+     * the classMap still is needed for various identification tasks which are reload
+     * related
+     */
+    Map<Integer, Boolean> systemRecompileMap = new ConcurrentHashMap<Integer, Boolean>(8, 0.75f, 1);
 
 
     boolean running = false;
@@ -60,7 +71,6 @@
     ScriptingWeaver _weavers = null;
 
 
-
     public static synchronized FileChangedDaemon getInstance() {
         if (instance == null) {
             instance = new FileChangedDaemon();
@@ -85,21 +95,37 @@
             if (classMap == null || classMap.size() == 0)
                 continue;
 
+            /**
+             * centrail tainted mark method which keeps
+             * track if some file in one of the supported engines has changed
+             * and if yes marks the file as tainted as well
+             * as marks the engine as having to do a full recompile
+             */
             for (Map.Entry<String, ReloadingMetadata> it : this.classMap.entrySet()) {
                 if (!it.getValue().isTainted()) {
 
                     File proxyFile = new File(it.getValue().getSourcePath() + File.separator + it.getValue().getFileName());
                     it.getValue().setTainted(proxyFile.lastModified() != it.getValue().getTimestamp());
                     if (it.getValue().isTainted()) {
+                        systemRecompileMap.put(it.getValue().getScriptingEngine(), Boolean.TRUE);
                         it.getValue().setTaintedOnce(true);
-                        log.info("comparing" + it.getKey() + "Dates:" + proxyFile.lastModified() + "-" + it.getValue().getTimestamp());
-                        log.info("Tainting:" + it.getValue().getFileName());
+                        printInfo(it, proxyFile);
                     }
                     it.getValue().setTimestamp(proxyFile.lastModified());
+
                 }
             }
         }
-        log.info("Dynamic reloading watch daemon is shutting down");
+        if (log.isInfoEnabled()) {
+            log.info("Dynamic reloading watch daemon is shutting down");
+        }
+    }
+
+    private void printInfo(Map.Entry<String, ReloadingMetadata> it, File proxyFile) {
+        if (log.isInfoEnabled()) {
+            log.info("comparing" + it.getKey() + "Dates:" + proxyFile.lastModified() + "-" + it.getValue().getTimestamp());
+            log.info("Tainting:" + it.getValue().getFileName());
+        }
     }
 
     public boolean isRunning() {
@@ -111,6 +137,14 @@
     }
 
 
+    public Map<Integer, Boolean> getSystemRecompileMap() {
+        return systemRecompileMap;
+    }
+
+    public void setSystemRecompileMap(Map<Integer, Boolean> systemRecompileMap) {
+        this.systemRecompileMap = systemRecompileMap;
+    }
+
     public Map<String, ReloadingMetadata> getClassMap() {
         return classMap;
     }

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/servlet/CustomChainLoader.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/servlet/CustomChainLoader.java?rev=888630&r1=888629&r2=888630&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/servlet/CustomChainLoader.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/servlet/CustomChainLoader.java Tue Dec  8 23:42:13 2009
@@ -20,7 +20,7 @@
 
 import org.apache.myfaces.groovyloader.core.GroovyWeaver;
 import org.apache.myfaces.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.scripting.core.util.ProxyUtils;
+import org.apache.myfaces.scripting.core.util.WeavingContext;
 import org.apache.myfaces.scripting.core.CoreWeaver;
 import org.apache.myfaces.scripting.loaders.java.JavaScriptingWeaver;
 import org.apache.myfaces.shared_impl.util.ClassLoaderExtension;
@@ -67,7 +67,7 @@
         this.scriptingWeaver = new CoreWeaver(groovyWeaver, javaWeaver);
         //we have to store it because our filter
         //does not trigger upon initialisation
-        ProxyUtils.setWeaver(this.scriptingWeaver);
+        WeavingContext.setWeaver(this.scriptingWeaver);
     }
 
     private void setupScriptingPaths(ServletContext servletContext, ScriptingWeaver weaver, String contextRootKey, String initParams) {