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/15 17:31:46 UTC

svn commit: r899687 - in /myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting: api/BaseWeaver.java api/ScriptingConst.java loaders/groovy/GroovyScriptingWeaver.java loaders/java/JavaScriptingWeaver.java

Author: werpu
Date: Fri Jan 15 16:31:46 2010
New Revision: 899687

URL: http://svn.apache.org/viewvc?rev=899687&view=rev
Log:
Simplification of the language weavers by moving a lot of code into the base

https://issues.apache.org/jira/browse/EXTSCRIPT-43

Modified:
    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/ScriptingConst.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/groovy/GroovyScriptingWeaver.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/java/JavaScriptingWeaver.java

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=899687&r1=899686&r2=899687&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 Fri Jan 15 16:31:46 2010
@@ -39,30 +39,34 @@
  */
 public abstract class BaseWeaver implements ScriptingWeaver {
 
-    private String fileEnding = null;
-    private int scriptingEngine = ScriptingConst.ENGINE_TYPE_NO_ENGINE;
     /**
      * only be set from the
      * initialisation code so no thread safety needed
      */
 
-
     protected ReloadingStrategy _reloadingStrategy = null;
     private static final String SCOPE_SESSION = "session";
     private static final String SCOPE_APPLICATION = "application";
     private static final String SCOPE_REQUEST = "request";
 
+    protected DynamicCompiler _compiler = null;
+    protected Log _log = LogFactory.getLog(this.getClass());
+    protected String _classPath = "";
+    protected ClassScanner _annotationScanner = null;
+    protected ClassScanner _dependencyScanner = null;
+    private String _fileEnding = null;
+    private int _scriptingEngine = ScriptingConst.ENGINE_TYPE_NO_ENGINE;
+
     public BaseWeaver() {
         _reloadingStrategy = new GlobalReloadingStrategy(this);
     }
 
     public BaseWeaver(String fileEnding, int scriptingEngine) {
-        this.fileEnding = fileEnding;
-        this.scriptingEngine = scriptingEngine;
+        this._fileEnding = fileEnding;
+        this._scriptingEngine = scriptingEngine;
         _reloadingStrategy = new GlobalReloadingStrategy(this);
     }
 
-
     /**
      * add custom source lookup paths
      *
@@ -74,9 +78,12 @@
         }
 
         WeavingContext.getConfiguration().addSourceDir(getScriptingEngine(), scriptPath);
+        if (_annotationScanner != null) {
+            _annotationScanner.addScanPath(scriptPath);
+        }
+        _dependencyScanner.addScanPath(scriptPath);
     }
 
-
     /**
      * condition which marks a metadata as reload candidate
      *
@@ -192,7 +199,6 @@
         return null;
     }
 
-
     protected Log getLog() {
         return LogFactory.getLog(this.getClass());
     }
@@ -201,38 +207,42 @@
         return reloadMeta.getScriptingEngine() == getScriptingEngine();
     }
 
-
     public String getFileEnding() {
-        return fileEnding;
+        return _fileEnding;
     }
 
     public void setFileEnding(String fileEnding) {
-        this.fileEnding = fileEnding;
+        this._fileEnding = fileEnding;
     }
 
     public final int getScriptingEngine() {
-        return scriptingEngine;
+        return _scriptingEngine;
     }
 
     public void setScriptingEngine(int scriptingEngine) {
-        this.scriptingEngine = scriptingEngine;
+        this._scriptingEngine = scriptingEngine;
     }
 
-
-    protected abstract Class loadScriptingClassFromFile(String sourceRoot, String file);
-
     public abstract boolean isDynamic(Class clazz);
 
-
     public ScriptingWeaver getWeaverInstance(Class weaverClass) {
         if (getClass().equals(weaverClass)) return this;
 
         return null;
     }
 
+    /**
+     * full scan, scans for all artefacts in all files
+     */
     public void fullClassScan() {
-    }
+        _dependencyScanner.scanPaths();
+
+        if (_annotationScanner == null || FacesContext.getCurrentInstance() == null) {
+            return;
+        }
+        _annotationScanner.scanPaths();
 
+    }
 
     public void requestRefresh() {
         if (WeavingContext.getRefreshContext().isRecompileRecommended(getScriptingEngine())) {
@@ -251,27 +261,6 @@
 
     }
 
-    private void personalScopeRefresh() {
-        //shortcut to avoid heavier operations in the beginning
-        long globalBeanRefreshTimeout = WeavingContext.getRefreshContext().getPersonalScopedBeanRefresh();
-        if (globalBeanRefreshTimeout == -1l) return;
-
-        Map sessionMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
-        Long timeOut = (Long) sessionMap.get(ScriptingConst.SESS_BEAN_REFRESH_TIMER);
-        if (timeOut == null || timeOut < globalBeanRefreshTimeout) {
-            refreshPersonalScopedBeans();
-        }
-    }
-
-    private void recompileRefresh() {
-        synchronized (RefreshContext.COMPILE_SYNC_MONITOR) {
-            fullRecompile();
-        }
-
-        refreshAllManagedBeans();
-    }
-
-
     protected void refreshAllManagedBeans() {
 
         if (FacesContext.getCurrentInstance() == null) {
@@ -330,38 +319,6 @@
     }
 
     /**
-     * MyFaces 2.0 keeps an immutable map over the session
-     * and request scoped beans
-     * if we alter that during our loop we get a concurrent modification exception
-     * taking a snapshot in time fixes that
-     *
-     * @param mbeans the internal managed bean map which has to be investigated
-     * @return a map with the class name as key and the managed bean info
-     *         as value of the current state of the internal runtime config bean map
-     */
-    private Map<String, ManagedBean> makeSnapshot(Map<String, ManagedBean> mbeans) {
-        Map<String, ManagedBean> workCopy;
-
-        workCopy = new HashMap<String, ManagedBean>(mbeans.size());
-        for (Map.Entry<String, ManagedBean> entry : mbeans.entrySet()) {
-            workCopy.put(entry.getKey(), entry.getValue());
-        }
-
-        return workCopy;
-    }
-
-    private void updateBeanRefreshTime() {
-        long sessionRefreshTime = System.currentTimeMillis();
-        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(ScriptingConst.SESS_BEAN_REFRESH_TIMER, sessionRefreshTime);
-    }
-
-    private void markSessionBeanRefreshRecommended() {
-        long sessionRefreshTime = System.currentTimeMillis();
-        WeavingContext.getRefreshContext().setPersonalScopedBeanRefresh(sessionRefreshTime);
-        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(ScriptingConst.SESS_BEAN_REFRESH_TIMER, sessionRefreshTime);
-    }
-
-    /**
      * refreshes all personal scoped beans (aka beans which
      * have an assumed lifecycle <= session)
      * <p/>
@@ -407,9 +364,7 @@
                 }
             }
             updateBeanRefreshTime();
-
         }
-
     }
 
     /**
@@ -438,20 +393,6 @@
     }
 
     /**
-     * jsf2 helper to remove custom scoped beans
-     *
-     * @param bean the managed bean which has to be removed from the custom scope from
-     */
-    private void removeCustomScopedBean(ManagedBean bean) {
-        Object scopeImpl = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get(bean.getManagedBeanScope());
-        if (scopeImpl == null) return; //scope not implemented
-        //we now have to revert to introspection here because scopes are a pure jsf2 construct
-        //so we use a messaging pattern here to cope with it
-
-        ReflectUtil.executeMethod(scopeImpl, "remove", bean.getManagedBeanName());
-    }
-
-    /**
      * Loads a list of possible dynamic classNames
      * for this scripting engine
      *
@@ -476,4 +417,183 @@
         return retVal;
 
     }
+
+    public void fullRecompile() {
+        if (isFullyRecompiled()) {
+            return;
+        }
+
+        if (_compiler == null) {
+            _compiler = instantiateCompiler();//new ReflectCompilerFacade();
+        }
+
+        for (String scriptPath : WeavingContext.getConfiguration().getSourceDirs(getScriptingEngine())) {
+            //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);
+            }
+
+        }
+
+        markAsFullyRecompiled();
+    }
+
+    protected boolean isFullyRecompiled() {
+        FacesContext context = FacesContext.getCurrentInstance();
+        if (context != null) {
+            return context.getExternalContext().getRequestMap().containsKey(this.getClass().getName() + "_recompiled");
+        }
+        return false;
+    }
+
+    protected void markAsFullyRecompiled() {
+        FacesContext context = FacesContext.getCurrentInstance();
+        if (context != null) {
+            //mark the request as tainted with recompile
+            if (context != null) {
+                Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
+                requestMap.put(this.getClass().getName() + "_recompiled", Boolean.TRUE);
+            }
+        }
+        WeavingContext.getRefreshContext().setRecompileRecommended(ScriptingConst.ENGINE_TYPE_GROOVY, Boolean.FALSE);
+    }
+
+    /**
+     * loads a class from a given sourceroot and filename
+     * note this method does not have to be thread safe
+     * it is called in a thread safe manner by the base class
+     * <p/>
+     *
+     * @param sourceRoot the source search lookup path
+     * @param file       the filename to be compiled and loaded
+     * @return a valid class if it could be found, null if none was found
+     */
+    protected Class loadScriptingClassFromFile(String sourceRoot, String file) {
+        //we load the scripting class from the given className
+
+        File currentClassFile = new File(sourceRoot + File.separator + file);
+        if (!currentClassFile.exists()) {
+            return null;
+        }
+
+        if (_log.isInfoEnabled()) {
+            _log.info(getLoadingInfo(file));
+        }
+
+        Iterator<String> it = WeavingContext.getConfiguration().getSourceDirs(getScriptingEngine()).iterator();
+        Class retVal = null;
+
+        try {
+            //we initialize the compiler lazy
+            //because the facade itself is lazy
+            if (_compiler == null) {
+                _compiler = instantiateCompiler();//new ReflectCompilerFacade();
+            }
+            retVal = _compiler.compileFile(sourceRoot, _classPath, file);
+
+            if (retVal == null) {
+                return retVal;
+            }
+        } catch (ClassNotFoundException e) {
+            //can be safely ignored
+        }
+
+        //no refresh needed because this is done in the case of java already by
+        //the classloader
+        //  if (retVal != null) {
+        //     refreshReloadingMetaData(sourceRoot, file, currentClassFile, retVal, ScriptingConst.ENGINE_TYPE_JAVA);
+        //  }
+
+        /**
+         * we now scan the return value and update its configuration parameters if needed
+         * this can help to deal with method level changes of class files like managed properties
+         * or scope changes from shorter running scopes to longer running ones
+         * if the annotation has been moved the class will be deregistered but still delivered for now
+         *
+         * at the next refresh the second step of the registration cycle should pick the new class up
+         * //TODO we have to mark the artefacting class as deregistered and then enforce
+         * //a reload this is however not the scope of the commit of this subtask
+         * //we only deal with class level reloading here
+         * //the deregistration notification should happen on artefact level (which will be the next subtask)
+         */
+        if (_annotationScanner != null && retVal != null) {
+            _annotationScanner.scanClass(retVal);
+        }
+
+        return retVal;
+    }
+
+    /**
+     * jsf2 helper to remove custom scoped beans
+     *
+     * @param bean the managed bean which has to be removed from the custom scope from
+     */
+    private void removeCustomScopedBean(ManagedBean bean) {
+        Object scopeImpl = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get(bean.getManagedBeanScope());
+        if (scopeImpl == null) return; //scope not implemented
+        //we now have to revert to introspection here because scopes are a pure jsf2 construct
+        //so we use a messaging pattern here to cope with it
+
+        ReflectUtil.executeMethod(scopeImpl, "remove", bean.getManagedBeanName());
+    }
+
+    /**
+     * MyFaces 2.0 keeps an immutable map over the session
+     * and request scoped beans
+     * if we alter that during our loop we get a concurrent modification exception
+     * taking a snapshot in time fixes that
+     *
+     * @param mbeans the internal managed bean map which has to be investigated
+     * @return a map with the class name as key and the managed bean info
+     *         as value of the current state of the internal runtime config bean map
+     */
+    private Map<String, ManagedBean> makeSnapshot(Map<String, ManagedBean> mbeans) {
+        Map<String, ManagedBean> workCopy;
+
+        workCopy = new HashMap<String, ManagedBean>(mbeans.size());
+        for (Map.Entry<String, ManagedBean> entry : mbeans.entrySet()) {
+            workCopy.put(entry.getKey(), entry.getValue());
+        }
+
+        return workCopy;
+    }
+
+    private void updateBeanRefreshTime() {
+        long sessionRefreshTime = System.currentTimeMillis();
+        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(ScriptingConst.SESS_BEAN_REFRESH_TIMER, sessionRefreshTime);
+    }
+
+    private void markSessionBeanRefreshRecommended() {
+        long sessionRefreshTime = System.currentTimeMillis();
+        WeavingContext.getRefreshContext().setPersonalScopedBeanRefresh(sessionRefreshTime);
+        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(ScriptingConst.SESS_BEAN_REFRESH_TIMER, sessionRefreshTime);
+    }
+
+    private void personalScopeRefresh() {
+        //shortcut to avoid heavier operations in the beginning
+        long globalBeanRefreshTimeout = WeavingContext.getRefreshContext().getPersonalScopedBeanRefresh();
+        if (globalBeanRefreshTimeout == -1l) return;
+
+        Map sessionMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
+        Long timeOut = (Long) sessionMap.get(ScriptingConst.SESS_BEAN_REFRESH_TIMER);
+        if (timeOut == null || timeOut < globalBeanRefreshTimeout) {
+            refreshPersonalScopedBeans();
+        }
+    }
+
+    private void recompileRefresh() {
+        synchronized (RefreshContext.COMPILE_SYNC_MONITOR) {
+            fullRecompile();
+        }
+
+        refreshAllManagedBeans();
+    }
+
+    protected abstract DynamicCompiler instantiateCompiler();
+
+    protected abstract String getLoadingInfo(String file);
+
 }

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ScriptingConst.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ScriptingConst.java?rev=899687&r1=899686&r2=899687&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ScriptingConst.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ScriptingConst.java Fri Jan 15 16:31:46 2010
@@ -67,4 +67,8 @@
     public static final String CTX_CONFIGURATION = "ExtScriptingConfig";
     public static final String INIT_PARAM_RESOURCE_PATH = "org.apache.myfaces.scripting.resources.LOADER_PATHS";
     public static final String FILE_EXTENSION_GROOVY = ".groovy";
+    public static final String GROOVY_FILE_ENDING = ".groovy";
+    public static final String JAVA_FILE_ENDING = ".java";
+    public static final String JSR199_COMPILER = "org.apache.myfaces.scripting.loaders.java.jsr199.JSR199Compiler";
+    public static final String JAVA5_COMPILER = "org.apache.myfaces.scripting.loaders.java.jdk5.CompilerFacade";
 }

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/groovy/GroovyScriptingWeaver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/groovy/GroovyScriptingWeaver.java?rev=899687&r1=899686&r2=899687&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/groovy/GroovyScriptingWeaver.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/groovy/GroovyScriptingWeaver.java Fri Jan 15 16:31:46 2010
@@ -2,14 +2,13 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.scripting.api.BaseWeaver;
-import org.apache.myfaces.scripting.api.ClassScanner;
-import org.apache.myfaces.scripting.api.ScriptingConst;
-import org.apache.myfaces.scripting.api.ScriptingWeaver;
+import org.apache.myfaces.groovyloader.core.StandardGroovyReloadingStrategy;
+import org.apache.myfaces.scripting.api.*;
 import org.apache.myfaces.scripting.core.util.Cast;
 import org.apache.myfaces.scripting.core.util.ClassUtils;
 import org.apache.myfaces.scripting.core.util.ReflectUtil;
 import org.apache.myfaces.scripting.core.util.WeavingContext;
+import org.apache.myfaces.extensions.scripting.loaders.groovy.compiler.GroovyCompilerFacade;
 
 import javax.faces.context.FacesContext;
 import javax.servlet.ServletContext;
@@ -18,24 +17,11 @@
 import java.util.Map;
 
 /**
- * Created by IntelliJ IDEA.
- * User: werpu2
- * Date: 12.01.2010
- * Time: 18:25:27
- * To change this template use File | Settings | File Templates.
+ * A standard groovy weaver which isolates the weaving behavior
  */
 public class GroovyScriptingWeaver extends BaseWeaver {
 
-    Log log = LogFactory.getLog(GroovyScriptingWeaver.class);
-    String classPath = "";
-    org.apache.myfaces.scripting.loaders.groovy.DynamicClassIdentifier identifier = new org.apache.myfaces.scripting.loaders.groovy.DynamicClassIdentifier();
-
-    private static final String GROOVY_FILE_ENDING = ".groovy";
-
-    ClassScanner _annotationScanner = null;
-    ClassScanner _dependencyScanner = null;
-
-    org.apache.myfaces.extensions.scripting.loaders.groovy.compiler.GroovyCompilerFacade compiler = null;
+    org.apache.myfaces.scripting.loaders.groovy.DynamicClassIdentifier _identifier = new org.apache.myfaces.scripting.loaders.groovy.DynamicClassIdentifier();
 
     /**
      * helper to allow initial compiler classpath scanning
@@ -43,7 +29,17 @@
      * @param servletContext
      */
     public GroovyScriptingWeaver(ServletContext servletContext) {
-        super(GROOVY_FILE_ENDING, ScriptingConst.ENGINE_TYPE_GROOVY);
+        super(ScriptingConst.GROOVY_FILE_ENDING, ScriptingConst.ENGINE_TYPE_GROOVY);
+        init();
+
+    }
+
+    public GroovyScriptingWeaver() {
+        super(ScriptingConst.FILE_EXTENSION_GROOVY, ScriptingConst.ENGINE_TYPE_GROOVY);
+        init();
+    }
+
+    private void init() {
         //init classpath removed we can resolve that over the
         //url classloader at the time myfaces is initialized
         try {
@@ -55,136 +51,20 @@
         }
 
         this._dependencyScanner = new GroovyDependencyScanner(this);
-
-
-    }
-
-    @Override
-    public void appendCustomScriptPath(String scriptPath) {
-        super.appendCustomScriptPath(scriptPath);
-        if (_annotationScanner != null) {
-            _annotationScanner.addScanPath(scriptPath);
-        }
-        _dependencyScanner.addScanPath(scriptPath);
+        this._reloadingStrategy = new StandardGroovyReloadingStrategy();
+        ((StandardGroovyReloadingStrategy) this._reloadingStrategy).setWeaver(this);
     }
 
-    public GroovyScriptingWeaver() {
-        super(ScriptingConst.FILE_EXTENSION_GROOVY, ScriptingConst.ENGINE_TYPE_GROOVY);
-    }
-
-
-    /**
-     * loads a class from a given sourceroot and filename
-     * note this method does not have to be thread safe
-     * it is called in a thread safe manner by the base class
-     * <p/>
-     * //TODO eliminate the source root we have the roots now somewhere else
-     *
-     * @param sourceRoot the source search lookup path
-     * @param file       the filename to be compiled and loaded
-     * @return a valid class if it could be found, null if none was found
-     */
-    @Override
-    protected Class loadScriptingClassFromFile(String sourceRoot, String file) {
-        //we load the scripting class from the given className
-
-        File currentClassFile = new File(sourceRoot + File.separator + file);
-        if (!currentClassFile.exists()) {
-            return null;
-        }
-
-        if (log.isInfoEnabled()) {
-            log.info("[EXT-SCRIPTING] Loading Groovy file:" + file);
-        }
-
-        Iterator<String> it = WeavingContext.getConfiguration().getSourceDirs(getScriptingEngine()).iterator();
-        Class retVal = null;
-
-        try {
-            //we initialize the compiler lazy
-            //because the facade itself is lazy
-            if (compiler == null) {
-                compiler = new org.apache.myfaces.extensions.scripting.loaders.groovy.compiler.GroovyCompilerFacade();
-            }
-            retVal = compiler.compileFile(sourceRoot, classPath, file);
-
-            if (retVal == null) {
-                return retVal;
-            }
-        } catch (ClassNotFoundException e) {
-            //can be safely ignored
-        }
-
-
-        if (_annotationScanner != null && retVal != null) {
-            _annotationScanner.scanClass(retVal);
-        }
-
-        return retVal;
+    protected String getLoadingInfo(String file) {
+        return "[EXT-SCRIPTING] Loading Groovy file:" + file;
     }
 
-   
-
     public boolean isDynamic(Class clazz) {
-        return identifier.isDynamic(clazz);  //To change body of implemented methods use File | Settings | File Templates.
+        return _identifier.isDynamic(clazz);  //To change body of implemented methods use File | Settings | File Templates.
     }
 
-
-    /**
-     * full scan, scans for all artefacts in all files
-     */
-    public void fullClassScan() {
-        _dependencyScanner.scanPaths();
-
-
-        if (_annotationScanner == null || FacesContext.getCurrentInstance() == null) {
-            return;
-        }
-        _annotationScanner.scanPaths();
-
+    protected DynamicCompiler instantiateCompiler() {
+        return new GroovyCompilerFacade();
     }
 
-    public void fullRecompile() {
-        if (isFullyRecompiled()) {
-            return;
-        }
-
-        if (compiler == null) {
-            compiler = new org.apache.myfaces.extensions.scripting.loaders.groovy.compiler.GroovyCompilerFacade();//new ReflectCompilerFacade();
-        }
-
-        for (String scriptPath : WeavingContext.getConfiguration().getSourceDirs(getScriptingEngine())) {
-            //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);
-            }
-
-        }
-
-        markAsFullyRecompiled();
-    }
-
-
-    private void markAsFullyRecompiled() {
-        FacesContext context = FacesContext.getCurrentInstance();
-        if (context != null) {
-            //mark the request as tainted with recompile
-            if (context != null) {
-                Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
-                requestMap.put(GroovyScriptingWeaver.class.getName() + "_recompiled", Boolean.TRUE);
-            }
-        }
-        WeavingContext.getRefreshContext().setRecompileRecommended(ScriptingConst.ENGINE_TYPE_GROOVY, Boolean.FALSE);
-    }
-
-    private boolean isFullyRecompiled() {
-        FacesContext context = FacesContext.getCurrentInstance();
-        if (context != null) {
-            return context.getExternalContext().getRequestMap().containsKey(GroovyScriptingWeaver.class.getName() + "_recompiled");
-        }
-        return false;
-    }
 }

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=899687&r1=899686&r2=899687&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 Fri Jan 15 16:31:46 2010
@@ -18,8 +18,6 @@
  */
 package org.apache.myfaces.scripting.loaders.java;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.scripting.api.*;
 import org.apache.myfaces.scripting.core.util.*;
 //import org.apache.myfaces.scripting.loaders.java.jsr199.ReflectCompilerFacade;
@@ -49,26 +47,20 @@
  */
 public class JavaScriptingWeaver extends BaseWeaver implements ScriptingWeaver, Serializable {
 
-    Log log = LogFactory.getLog(JavaScriptingWeaver.class);
-    String classPath = "";
     DynamicClassIdentifier identifier = new DynamicClassIdentifier();
 
-    private static final String JAVA_FILE_ENDING = ".java";
-    private static final String JSR199_COMPILER = "org.apache.myfaces.scripting.loaders.java.jsr199.JSR199Compiler";
-    private static final String JAVA5_COMPILER = "org.apache.myfaces.scripting.loaders.java.jdk5.CompilerFacade";
-
-    ClassScanner _annotationScanner = null;
-    ClassScanner _dependencyScanner = null;
-
-    DynamicCompiler compiler = null;
-
     /**
      * helper to allow initial compiler classpath scanning
      *
      * @param servletContext
      */
     public JavaScriptingWeaver(ServletContext servletContext) {
-        super(JAVA_FILE_ENDING, ScriptingConst.ENGINE_TYPE_JAVA);
+        super(ScriptingConst.JAVA_FILE_ENDING, ScriptingConst.ENGINE_TYPE_JAVA);
+        init();
+
+    }
+
+    private void init() {
         //init classpath removed we can resolve that over the
         //url classloader at the time myfaces is initialized
         try {
@@ -80,90 +72,19 @@
         }
 
         this._dependencyScanner = new JavaDependencyScanner(this);
-
-
     }
 
-    @Override
-    public void appendCustomScriptPath(String scriptPath) {
-        super.appendCustomScriptPath(scriptPath);
-        if (_annotationScanner != null) {
-            _annotationScanner.addScanPath(scriptPath);
-        }
-        _dependencyScanner.addScanPath(scriptPath);
-    }
+   
 
     public JavaScriptingWeaver() {
-        super(JAVA_FILE_ENDING, ScriptingConst.ENGINE_TYPE_JAVA);
+        super(ScriptingConst.JAVA_FILE_ENDING, ScriptingConst.ENGINE_TYPE_JAVA);
     }
 
 
-    /**
-     * loads a class from a given sourceroot and filename
-     * note this method does not have to be thread safe
-     * it is called in a thread safe manner by the base class
-     * <p/>
-     * //TODO eliminate the source root we have the roots now somewhere else
-     *
-     * @param sourceRoot the source search lookup path
-     * @param file       the filename to be compiled and loaded
-     * @return a valid class if it could be found, null if none was found
-     */
-    @Override
-    protected Class loadScriptingClassFromFile(String sourceRoot, String file) {
-        //we load the scripting class from the given className
-
-        File currentClassFile = new File(sourceRoot + File.separator + file);
-        if (!currentClassFile.exists()) {
-            return null;
-        }
-
-        if (log.isInfoEnabled()) {
-            log.info("[EXT-SCRIPTING] Loading Java file:" + file);
-        }
-
-        Iterator<String> it = WeavingContext.getConfiguration().getSourceDirs(getScriptingEngine()).iterator();
-        Class retVal = null;
+   
 
-        try {
-            //we initialize the compiler lazy
-            //because the facade itself is lazy
-            if (compiler == null) {
-                compiler = (DynamicCompiler) ReflectUtil.instantiate(getScriptingFacadeClass());//new ReflectCompilerFacade();
-            }
-            retVal = compiler.compileFile(sourceRoot, classPath, file);
-
-            if (retVal == null) {
-                return retVal;
-            }
-        } catch (ClassNotFoundException e) {
-            //can be safely ignored
-        }
-
-
-        //no refresh needed because this is done in the case of java already by
-        //the classloader
-        //  if (retVal != null) {
-        //     refreshReloadingMetaData(sourceRoot, file, currentClassFile, retVal, ScriptingConst.ENGINE_TYPE_JAVA);
-        //  }
-
-        /**
-         * we now scan the return value and update its configuration parameters if needed
-         * this can help to deal with method level changes of class files like managed properties
-         * or scope changes from shorter running scopes to longer running ones
-         * if the annotation has been moved the class will be deregistered but still delivered for now
-         *
-         * at the next refresh the second step of the registration cycle should pick the new class up
-         * //TODO we have to mark the artefacting class as deregistered and then enforce
-         * //a reload this is however not the scope of the commit of this subtask
-         * //we only deal with class level reloading here
-         * //the deregistration notification should happen on artefact level (which will be the next subtask)
-         */
-        if (_annotationScanner != null && retVal != null) {
-            _annotationScanner.scanClass(retVal);
-        }
-
-        return retVal;
+    protected String getLoadingInfo(String file) {
+        return "[EXT-SCRIPTING] Loading Java file:" + file;
     }
 
     private String getScriptingFacadeClass() {
@@ -174,10 +95,10 @@
 
         if (major > 5) {
             //jsr199 compliant jdk
-            return JSR199_COMPILER;
+            return ScriptingConst.JSR199_COMPILER;
         }
         //otherwise
-        return JAVA5_COMPILER;
+        return ScriptingConst.JAVA5_COMPILER;
     }
 
     public boolean isDynamic(Class clazz) {
@@ -185,62 +106,10 @@
     }
 
 
-    /**
-     * full scan, scans for all artefacts in all files
-     */
-    public void fullClassScan() {
-        _dependencyScanner.scanPaths();
-
-
-        if (_annotationScanner == null || FacesContext.getCurrentInstance() == null) {
-            return;
-        }
-        _annotationScanner.scanPaths();
-
-    }
-
-    public void fullRecompile() {
-        if (isFullyRecompiled()) {
-            return;
-        }
-
-        if (compiler == null) {
-            compiler = (DynamicCompiler) ReflectUtil.instantiate(getScriptingFacadeClass());//new ReflectCompilerFacade();
-        }
-
-        for (String scriptPath : WeavingContext.getConfiguration().getSourceDirs(getScriptingEngine())) {
-            //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);
-            }
-
-        }
-
-        markAsFullyRecompiled();
-    }
-
-
-    private void markAsFullyRecompiled() {
-        FacesContext context = FacesContext.getCurrentInstance();
-        if (context != null) {
-            //mark the request as tainted with recompile
-            if (context != null) {
-                Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
-                requestMap.put(JavaScriptingWeaver.class.getName() + "_recompiled", Boolean.TRUE);
-            }
-        }
-        WeavingContext.getRefreshContext().setRecompileRecommended(ScriptingConst.ENGINE_TYPE_JAVA, Boolean.FALSE);
-    }
+   
 
-    private boolean isFullyRecompiled() {
-        FacesContext context = FacesContext.getCurrentInstance();
-        if (context != null) {
-            return context.getExternalContext().getRequestMap().containsKey(JavaScriptingWeaver.class.getName() + "_recompiled");
-        }
-        return false;
+    protected DynamicCompiler instantiateCompiler() {
+        return (DynamicCompiler) ReflectUtil.instantiate(getScriptingFacadeClass());
     }
 
 }