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/15 12:29:45 UTC
svn commit: r890768 - in /myfaces/extensions/scripting/trunk:
core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/
core/core/src/main/java/org/apache/myfaces/scripting/core/
core/core/src/main/java/org/apache/myfaces/scripting/core/util/ cor...
Author: werpu
Date: Tue Dec 15 11:29:44 2009
New Revision: 890768
URL: http://svn.apache.org/viewvc?rev=890768&view=rev
Log:
https://issues.apache.org/jira/browse/EXTSCRIPT-28
https://issues.apache.org/jira/browse/EXTSCRIPT-36
added an atomic commit counter so that we deal with the compile trigger time correctly
fixed the submit issue, in the myfaces 1.2 example
Modified:
myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/GroovyWeaver.groovy
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/util/WeavingContext.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/refresh/RefreshContext.java
myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java
myfaces/extensions/scripting/trunk/examples/myfaces12-example/src/main/webapp/WEB-INF/groovy/org/apache/myfaces/groovyloader/test/TestValidator.groovy
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/GroovyWeaver.groovy
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/GroovyWeaver.groovy?rev=890768&r1=890767&r2=890768&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/GroovyWeaver.groovy (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/groovy/org/apache/myfaces/groovyloader/core/GroovyWeaver.groovy Tue Dec 15 11:29:44 2009
@@ -136,7 +136,7 @@
//TODO probably not needed because the groovy classloader takes care of everything itself
//the tainting does the rest but we have to check it for the annotations
- WeavingContext.getRefreshContext().setRecompileRecommended(ScriptingConst.ENGINE_TYPE_JAVA, Boolean.FALSE);
+ WeavingContext.getRefreshContext().setRecompileRecommended(ScriptingConst.ENGINE_TYPE_GROOVY, Boolean.FALSE);
}
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=890768&r1=890767&r2=890768&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 15 11:29:44 2009
@@ -40,9 +40,12 @@
* @author Werner Punz
*/
public class MethodLevelReloadingHandler extends ReloadingInvocationHandler implements Serializable {
- ScriptingWeaver _weaver = null;
+ transient ScriptingWeaver _weaver = null;
int _artefactType;
+
+
+
public MethodLevelReloadingHandler(Object rootObject, int artefactType) {
_loadedClass = rootObject.getClass();
_delegate = rootObject;
@@ -114,4 +117,14 @@
objects[cnt] = WeavingContext.getDelegateFromProxy(objects[cnt]);
}
}
+
+
+
+ public int getArtefactType() {
+ return _artefactType;
+ }
+
+ public void setArtefactType(int artefactType) {
+ _artefactType = artefactType;
+ }
}
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/WeavingContext.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/WeavingContext.java?rev=890768&r1=890767&r2=890768&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/WeavingContext.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/WeavingContext.java Tue Dec 15 11:29:44 2009
@@ -32,11 +32,15 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
/**
* A set of weaving context class called
* by the various subsystems
*
+ * TODO move this away from static methods into a singleton which is kept
+ * in the application context, to keep the context pattern.
+ *
* @author Werner Punz
*/
public class WeavingContext {
@@ -64,12 +68,14 @@
static protected ThreadLocal _refreshContextHolder = new ThreadLocal();
+
public static void init() {
}
+
/**
* general shutdown clean
*/
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=890768&r1=890767&r2=890768&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 15 11:29:44 2009
@@ -119,6 +119,9 @@
@Override
protected Class loadScriptingClassFromFile(String sourceRoot, String file) {
//we load the scripting class from the given className
+ if(file.indexOf("TestBean2") != -1) {
+ System.out.println("debugpoint found");
+ }
File currentClassFile = new File(sourceRoot + File.separator + file);
if (!currentClassFile.exists()) {
return null;
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/refresh/RefreshContext.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/refresh/RefreshContext.java?rev=890768&r1=890767&r2=890768&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/refresh/RefreshContext.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/refresh/RefreshContext.java Tue Dec 15 11:29:44 2009
@@ -23,19 +23,32 @@
/**
* @author Werner Punz (latest modification by $Author$)
* @version $Revision$ $Date$
- *
- * a context which holds information regarding the refresh cycle
- * which can be picked up by the request filter
- * for refreshing strategies
- *
- * That way we can avoid a separate session filter and a push system
- * we use a pull system instead
+ * <p/>
+ * a context which holds information regarding the refresh cycle
+ * which can be picked up by the request filter
+ * for refreshing strategies
+ * <p/>
+ * That way we can avoid a separate session filter and a push system
+ * we use a pull system instead
*/
public class RefreshContext {
+ /**
+ * this is a timed marker which is
+ * a point in time the last bean refresh was issued
+ * every request has to dump its personal scoped
+ * (aka session, or custom) scoped beans
+ * if the point in time is newer than the personal refresh time
+ * application scoped beans are refreshed at the first refresh cycle
+ * by the calling request issuing the compile
+ */
private long personalScopedBeanRefresh = -1l;
- private boolean recompileRecommended = false;
+ /**
+ * the daemon thread which marks the scripting classes
+ * depending on the state, changed => tainted == true, not changed
+ * tainted == false!
+ */
FileChangedDaemon daemon = FileChangedDaemon.getInstance();
public long getPersonalScopedBeanRefresh() {
@@ -46,6 +59,13 @@
this.personalScopedBeanRefresh = personalScopedBeanRefresh;
}
+ /**
+ * checks whether it would make sense at the current point
+ * in time to enforce a recompile or not
+ *
+ * @param scriptingEngine
+ * @return
+ */
public boolean isRecompileRecommended(int scriptingEngine) {
Boolean recommended = daemon.getSystemRecompileMap().get(scriptingEngine);
return recommended == null || recommended.booleanValue();
@@ -62,4 +82,33 @@
public void setDaemon(FileChangedDaemon daemon) {
this.daemon = daemon;
}
+
+ /**
+ * @return true if a compile currently is in progress
+ */
+ public static boolean isCompileInProgress(int engineType) {
+ //TODO implement this
+ return false;
+ }
+
+ /**
+ * returns whether a recompile now at the current point
+ * in time for this engine is allowed or not
+ * This state depends on the state of the application
+ * if non locked compiles is enabled it always will return true
+ * <p/>
+ * if a synchronized locking compile is enabled
+ * it will return true if the calling request is the only
+ * one currently issued because no request is allowed to compile
+ * until others have run out
+ *
+ * @param engineType
+ * @return
+ */
+ public static boolean isComileAllowed(int engineType) {
+ //TODO implement synchronized locking logic to avoid
+ //race conditions in multiuser environments
+ return true;
+ }
+
}
Modified: myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java?rev=890768&r1=890767&r2=890768&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java (original)
+++ myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java Tue Dec 15 11:29:44 2009
@@ -36,10 +36,7 @@
import javax.faces.validator.Validator;
import javax.servlet.ServletRequest;
import java.lang.reflect.Proxy;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.ResourceBundle;
+import java.util.*;
/**
* our decorating applicstion
@@ -384,7 +381,8 @@
Validator retVal = _delegate.createValidator(s);
if (WeavingContext.isDynamic(retVal.getClass()) && !Proxy.isProxyClass(retVal.getClass())) {
- retVal = (Validator) WeavingContext.createMethodReloadingProxyFromObject(retVal, Validator.class, ScriptingConst.ARTEFACT_TYPE_VALIDATOR);
+ //todo bypass the serialisation problem on validators
+ retVal = (Validator) reloadInstance(retVal, ScriptingConst.ARTEFACT_TYPE_VALIDATOR); //WeavingContext.createMethodReloadingProxyFromObject(retVal, Validator.class, ScriptingConst.ARTEFACT_TYPE_VALIDATOR);
}
return retVal;
}
@@ -418,9 +416,9 @@
private final boolean alreadyWovenInRequest(String clazz) {
//portlets now can be enabled thanks to the jsf2 indirections regarding the external context
- ServletRequest req = (ServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
- if (req.getAttribute(ScriptingConst.SCRIPTING_REQUSINGLETON + clazz) == null) {
- req.setAttribute(ScriptingConst.SCRIPTING_REQUSINGLETON + clazz, "");
+ Map reqMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
+ if (reqMap.get(ScriptingConst.SCRIPTING_REQUSINGLETON + clazz) == null) {
+ reqMap.put(ScriptingConst.SCRIPTING_REQUSINGLETON + clazz, "");
return false;
}
return true;
Modified: myfaces/extensions/scripting/trunk/examples/myfaces12-example/src/main/webapp/WEB-INF/groovy/org/apache/myfaces/groovyloader/test/TestValidator.groovy
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/examples/myfaces12-example/src/main/webapp/WEB-INF/groovy/org/apache/myfaces/groovyloader/test/TestValidator.groovy?rev=890768&r1=890767&r2=890768&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/examples/myfaces12-example/src/main/webapp/WEB-INF/groovy/org/apache/myfaces/groovyloader/test/TestValidator.groovy (original)
+++ myfaces/extensions/scripting/trunk/examples/myfaces12-example/src/main/webapp/WEB-INF/groovy/org/apache/myfaces/groovyloader/test/TestValidator.groovy Tue Dec 15 11:29:44 2009
@@ -28,7 +28,7 @@
class TestValidator implements Validator {
public void validate(FacesContext facesContext, UIComponent uiComponent, Object o) {
- println "validating aaaa "
+ println "validating testvalidation "
}
}
\ No newline at end of file