fixing an issue with the combination of CDI and Managed beans
git-svn-id: https://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk@1416883 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/extscript-bundles/pom.xml b/extscript-bundles/pom.xml
index bea0260..635f6f0 100644
--- a/extscript-bundles/pom.xml
+++ b/extscript-bundles/pom.xml
@@ -47,9 +47,7 @@
<modules>
<module>extscript-myfaces20-bundle</module>
- <!--
<module>extscript-mojarra-bundle</module>
- -->
</modules>
diff --git a/extscript-core-root/extscript-cdi/src/main/java/org/apache/myfaces/extensions/scripting/cdi/core/CDIThrowAwayClassloader.java b/extscript-core-root/extscript-cdi/src/main/java/org/apache/myfaces/extensions/scripting/cdi/core/CDIThrowAwayClassloader.java
index c89f080..7fe2c2c 100644
--- a/extscript-core-root/extscript-cdi/src/main/java/org/apache/myfaces/extensions/scripting/cdi/core/CDIThrowAwayClassloader.java
+++ b/extscript-core-root/extscript-cdi/src/main/java/org/apache/myfaces/extensions/scripting/cdi/core/CDIThrowAwayClassloader.java
@@ -21,9 +21,12 @@
import org.apache.myfaces.extensions.scripting.core.api.WeavingContext;
import org.apache.myfaces.extensions.scripting.core.engine.ThrowAwayClassloader;
+import org.apache.myfaces.extensions.scripting.core.monitor.ClassResource;
+import javax.inject.Named;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.annotation.Annotation;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -56,7 +59,25 @@
@Override
public Class<?> loadClass(String className) throws ClassNotFoundException
{
- return _delegate.loadClass(className);
+ Class clazz = _delegate.loadClass(className);
+ ClassResource res = (ClassResource) WeavingContext.getInstance().getResource(className);
+ if(res == null) {
+ return clazz;
+ }
+ //TODO check if the resource is a cdi resource or a jsf resource
+ //and in case of a jsf resource keep it tainted
+ Annotation[] anns = clazz.getAnnotations();
+ boolean cdiAnnotation = false;
+ if(anns == null || anns.length == 0) {
+ cdiAnnotation = true;
+ } else {
+ for(Annotation ann: anns) {
+ cdiAnnotation = ann instanceof Named;
+ if(cdiAnnotation) break;
+ }
+ }
+ res.setTainted(!cdiAnnotation);
+ return clazz;
}
@Override
diff --git a/extscript-core-root/pom.xml b/extscript-core-root/pom.xml
index 2a595ac..b366ad5 100644
--- a/extscript-core-root/pom.xml
+++ b/extscript-core-root/pom.xml
@@ -45,9 +45,7 @@
<module>extscript-cdi</module>
<module>extscript-spring</module>
<module>extscript-myfaces</module>
- <!--
<module>extscript-mojarra</module>
- -->
<!--
<module>extscript-weld</module>
-->