https://issues.apache.org/jira/browse/EXTSCRIPT-134
git-svn-id: https://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk@952744 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java b/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java
index 9a514a9..0134f27 100644
--- a/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java
+++ b/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java
@@ -49,18 +49,23 @@
public class ApplicationProxy extends Application implements Decorated {
volatile Application _delegate;
+ volatile static boolean elResolverAdded = false;
+ volatile static boolean varResolverAdded = false;
public ApplicationProxy(Application delegate) {
_delegate = delegate;
}
-
public void addELResolver(ELResolver elResolver) {
weaveDelegate();
-
- //the same goes for the rest of the factory stuff
- if (!(elResolver instanceof ELResolverProxy))
+ if (!elResolverAdded) {
+ //ordering hints are unsufficient here we make
+ //sure our proxy is added as second in the chain
+ //also this method works as well on
+ //jsf 1.2 while hints only work in jsf2
elResolver = new ELResolverProxy(elResolver);
+ elResolverAdded = true;
+ }
_delegate.addELResolver(elResolver);
}
@@ -73,10 +78,7 @@
public ELResolver getELResolver() {
weaveDelegate();
ELResolver retVal = _delegate.getELResolver();
- if (!(retVal instanceof ELResolverProxy))
- retVal = new ELResolverProxy(retVal);
return retVal;
-
}
//TOD add a weaving for resource bundles
@@ -219,17 +221,16 @@
public VariableResolver getVariableResolver() {
weaveDelegate();
VariableResolver variableResolver = _delegate.getVariableResolver();
- if (!(variableResolver instanceof VariableResolverProxy))
- variableResolver = new VariableResolverProxy(variableResolver);
return variableResolver;
}
@SuppressWarnings("deprecation")
public void setVariableResolver(VariableResolver variableResolver) {
weaveDelegate();
- if (!(variableResolver instanceof VariableResolverProxy))
+ if (!varResolverAdded) {
variableResolver = new VariableResolverProxy(variableResolver);
-
+ varResolverAdded = true;
+ }
_delegate.setVariableResolver(variableResolver);
}
@@ -412,7 +413,7 @@
private boolean alreadyWovenInRequest(String clazz) {
//portlets now can be enabled thanks to the jsf2 indirections regarding the external context
- Map<String,Object> reqMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
+ Map<String, Object> reqMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
if (reqMap.get(ScriptingConst.SCRIPTING_REQUSINGLETON + clazz) == null) {
reqMap.put(ScriptingConst.SCRIPTING_REQUSINGLETON + clazz, "");
return false;
diff --git a/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java b/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java
index 6ec0c76..7121273 100644
--- a/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java
+++ b/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java
@@ -25,7 +25,10 @@
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.ELResolver;
+import java.io.IOException;
+import java.io.ObjectInputStream;
import java.util.Iterator;
+import java.util.logging.Logger;
/**
* EL Resolver which is scripting enabled
@@ -34,33 +37,30 @@
*/
public class ELResolverProxy extends ELResolver implements Decorated {
+ Logger log = Logger.getLogger(ELResolverProxy.class.getName());
ELResolver _delegate = null;
+ // static ThreadLocal<Boolean> _getValue = new ThreadLocal<Boolean>();
+
public Object getValue(ELContext elContext, final Object base, final Object property) throws NullPointerException, ELException {
- //request, class is loaded anew hence we already have picked up the new code
Object retVal = _delegate.getValue(elContext, base, property);
- if (retVal != null && WeavingContext.isDynamic(retVal.getClass())) {
- //now here we have something special which is implicit
- //if the bean is only request scoped we dont have to reload anything
- //so just run through this code without having anything happening here
- //reloadScriptingInstance will return the same object we already had before
- //the reason is for request or none scoped beans we get a new
- //freshly reloaded and compiled instance on every request
- //the problem starts with session application or custom scoped beans
- //There nothing is compiled and we have to do the further bean processing
+ Object newRetVal;
- Object newRetVal = WeavingContext.getWeaver().reloadScriptingInstance(retVal, ScriptingConst.ARTIFACT_TYPE_MANAGEDBEAN); /*once it was tainted or loaded by
- our classloader we have to recreate all the time to avoid classloader issues*/
+ if (retVal != null && WeavingContext.isDynamic(retVal.getClass())) {
+
+ newRetVal = WeavingContext.getWeaver().reloadScriptingInstance(retVal, ScriptingConst.ARTIFACT_TYPE_MANAGEDBEAN);
+
if (newRetVal != retVal) {
setValue(elContext, base, property, newRetVal);
}
+
return newRetVal;
+
}
return retVal;
-
}
public Class<?> getType(ELContext elContext, Object o, Object o1) throws NullPointerException, ELException {
@@ -71,12 +71,12 @@
return retVal;
}
- public void setValue(ELContext elContext, Object base, Object property, Object newRetVal) throws NullPointerException, ELException {
+ public void setValue(ELContext elContext, Object base, Object property, Object value) throws NullPointerException, ELException {
//now to more complex relations...
if (base != null) {
- WeavingContext.getRefreshContext().getDependencyRegistry().addDependency(ScriptingConst.ENGINE_TYPE_JSF_ALL, base.getClass().getName(), base.getClass().getName(), newRetVal.getClass().getName());
+ WeavingContext.getRefreshContext().getDependencyRegistry().addDependency(ScriptingConst.ENGINE_TYPE_JSF_ALL, base.getClass().getName(), base.getClass().getName(), value.getClass().getName());
}
- _delegate.setValue(elContext, base, property, newRetVal);
+ _delegate.setValue(elContext, base, property, value);
}
public boolean isReadOnly(ELContext elContext, Object o, Object o1) throws NullPointerException, ELException {
@@ -99,4 +99,11 @@
return _delegate; //To change body of implemented methods use File | Settings | File Templates.
}
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ // our "pseudo-constructor"
+ in.defaultReadObject();
+ log = Logger.getLogger(ELResolverProxy.class.getName());
+
+ }
+
}