myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From we...@apache.org
Subject svn commit: r815758 - in /myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src: main/java/org/apache/myfaces/scripting/jsf2/annotation/ test/java/org/apache/myfaces/scripting/
Date Wed, 16 Sep 2009 13:17:13 GMT
Author: werpu
Date: Wed Sep 16 13:17:12 2009
New Revision: 815758

URL: http://svn.apache.org/viewvc?rev=815758&view=rev
Log:
http://issues.apache.org/jira/browse/EXTSCRIPT-18

ongoing implementation works on the qdox source scanner

Added:
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/test/java/org/apache/myfaces/scripting/Probe.java
      - copied, changed from r815757, myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/test/java/org/apache/myfaces/scripting/QDoxTest.java
Modified:
    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/BehaviorImplementationListener.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/ConverterImplementationListener.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/jsf2/annotation/SourceAnnotationScanner.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/SourceClassAnnotationListener.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ValidatorImplementationListener.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/test/java/org/apache/myfaces/scripting/QDoxTest.java

Modified: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/BeanImplementationListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/BeanImplementationListener.java?rev=815758&r1=815757&r2=815758&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/BeanImplementationListener.java
(original)
+++ myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/BeanImplementationListener.java
Wed Sep 16 13:17:12 2009
@@ -27,9 +27,12 @@
 
 public class BeanImplementationListener implements SourceClassAnnotationListener {
 
-  
+    
 
-    public void register(String annotationName, Map<String, String> params) {
-        //To change body of implemented methods use File | Settings | File Templates.
+    public boolean supportsAnnotation(Class annotation) {
+        return annotation.equals(javax.faces.bean.ManagedBean.class);
+    }
+
+    public void register(String className, String annotationName, Map<String, String>
params) {
     }
 }

Modified: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/BehaviorImplementationListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/BehaviorImplementationListener.java?rev=815758&r1=815757&r2=815758&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/BehaviorImplementationListener.java
(original)
+++ myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/BehaviorImplementationListener.java
Wed Sep 16 13:17:12 2009
@@ -18,10 +18,19 @@
  */
 package org.apache.myfaces.scripting.jsf2.annotation;
 
+import java.util.Map;
+
 /**
  * @author Werner Punz (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
 
-public class BehaviorImplementationListener {
+public class BehaviorImplementationListener implements SourceClassAnnotationListener {
+    public boolean supportsAnnotation(Class annotation) {
+        return false;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+    public void register(String className, String annotationName, Map<String, String>
params) {
+        //To change body of implemented methods use File | Settings | File Templates.
+    }
 }

Modified: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ComponentImplementationListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ComponentImplementationListener.java?rev=815758&r1=815757&r2=815758&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ComponentImplementationListener.java
(original)
+++ myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ComponentImplementationListener.java
Wed Sep 16 13:17:12 2009
@@ -26,7 +26,11 @@
  */
 
 public class ComponentImplementationListener implements SourceClassAnnotationListener {
-    public void register(String annotationName, Map<String, String> params) {
-        //To change body of implemented methods use File | Settings | File Templates.
+    public boolean supportsAnnotation(Class annotation) {
+        return false;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+    public void register(String className, String annotationName, Map<String, String>
params) {
+         //To change body of implemented methods use File | Settings | File Templates.
     }
 }

Modified: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ConverterImplementationListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ConverterImplementationListener.java?rev=815758&r1=815757&r2=815758&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ConverterImplementationListener.java
(original)
+++ myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ConverterImplementationListener.java
Wed Sep 16 13:17:12 2009
@@ -18,10 +18,21 @@
  */
 package org.apache.myfaces.scripting.jsf2.annotation;
 
+import java.util.Map;
+
 /**
  * @author Werner Punz (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
 
-public class ConverterImplementationListener {
+public class ConverterImplementationListener implements SourceClassAnnotationListener {
+
+    public boolean supportsAnnotation(Class annotation) {
+        return false;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+    public void register(String className, String annotationName, Map<String, String>
params) {
+        //To change body of implemented methods use File | Settings | File Templates.
+    }
+
 }

Modified: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/RendererImplementationListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/RendererImplementationListener.java?rev=815758&r1=815757&r2=815758&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/RendererImplementationListener.java
(original)
+++ myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/RendererImplementationListener.java
Wed Sep 16 13:17:12 2009
@@ -26,7 +26,11 @@
  */
 
 public class RendererImplementationListener implements SourceClassAnnotationListener {
-    public void register(String annotationName, Map<String, String> params) {
-        //To change body of implemented methods use File | Settings | File Templates.
+    public boolean supportsAnnotation(Class annotation) {
+        return false;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+    public void register(String className, String annotationName, Map<String, String>
params) {
+         //To change body of implemented methods use File | Settings | File Templates.
     }
 }

Modified: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/SourceAnnotationScanner.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/SourceAnnotationScanner.java?rev=815758&r1=815757&r2=815758&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/SourceAnnotationScanner.java
(original)
+++ myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/SourceAnnotationScanner.java
Wed Sep 16 13:17:12 2009
@@ -22,6 +22,7 @@
 import com.thoughtworks.qdox.model.JavaSource;
 import com.thoughtworks.qdox.model.JavaClass;
 import com.thoughtworks.qdox.model.Type;
+import com.thoughtworks.qdox.model.Annotation;
 
 import java.util.List;
 import java.util.LinkedList;
@@ -44,15 +45,28 @@
 
     public SourceAnnotationScanner(String... sourcePaths) {
 
+        initSourcePaths(sourcePaths);
+
+        initDefaultListeners();
+
+    }
+
+    private void initSourcePaths(String... sourcePaths) {
         for (String sourcePath : sourcePaths) {
             File sourcePathFile = new File(sourcePath);
             if (sourcePathFile.exists()) {
                 _builder.addSourceTree(sourcePathFile);
             }
         }
+    }
 
+    private void initDefaultListeners() {
         _listeners.add(new BeanImplementationListener());
-
+        _listeners.add(new BehaviorImplementationListener());
+        _listeners.add(new ComponentImplementationListener());
+        _listeners.add(new ConverterImplementationListener());
+        _listeners.add(new RendererImplementationListener());
+        _listeners.add(new ValidatorImplementationListener());
     }
 
 
@@ -60,23 +74,31 @@
      * builds up the parsing chain and then notifies its observers
      * on the found data
      */
-    public void doiIt() {
-        JavaSource []sources = _builder.getSources();
-        for(JavaSource source: sources) {
-            String packageName = source.getPackage();
+    public void scanSources() {
+        JavaSource[] sources = _builder.getSources();
+        for (JavaSource source : sources) {
+            String packageName = source.getPackage().toString();
             JavaClass[] classes = source.getClasses();
-            for(JavaClass clazz: classes) {
-                Type[] annotations = clazz.getImplements();
-                if(clazz.getName().contains("Bean2")) {
-                    //todo to reverse engineer the missing
-                    //  annotation detection docs of qdox
-                    System.out.println("debugpoint found");
+            for (JavaClass clazz : classes) {
+                Annotation[] anns = clazz.getAnnotations();
+                for (Annotation ann : anns) {
+
+                    for (SourceClassAnnotationListener listener : _listeners) {
+                        if (listener.supportsAnnotation(ann.getClass())) {
+                            listener.register(clazz.getName(), ann.getType().getValue(),
ann.getPropertyMap());
+                        }
+                    }
                 }
             }
         }
+    }
 
-
+    public void clearListeners() {
+        _listeners.clear();
     }
 
+    public void addListener(SourceClassAnnotationListener listener) {
+        _listeners.add(listener);
+    }
 
 }

Modified: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/SourceClassAnnotationListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/SourceClassAnnotationListener.java?rev=815758&r1=815757&r2=815758&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/SourceClassAnnotationListener.java
(original)
+++ myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/SourceClassAnnotationListener.java
Wed Sep 16 13:17:12 2009
@@ -30,7 +30,9 @@
 
 public interface SourceClassAnnotationListener {
 
-    public void register(String annotationName, Map<String, String> params);
+    public boolean supportsAnnotation(Class annotation);
+
+    public void register(String className, String annotationName, Map<String, String>
params);
 
 
 }

Modified: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ValidatorImplementationListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ValidatorImplementationListener.java?rev=815758&r1=815757&r2=815758&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ValidatorImplementationListener.java
(original)
+++ myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ValidatorImplementationListener.java
Wed Sep 16 13:17:12 2009
@@ -18,10 +18,19 @@
  */
 package org.apache.myfaces.scripting.jsf2.annotation;
 
+import java.util.Map;
+
 /**
  * @author Werner Punz (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
 
-public class ValidatorImplementationListener {
+public class ValidatorImplementationListener implements SourceClassAnnotationListener {
+    public boolean supportsAnnotation(Class annotation) {
+        return false;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+    public void register(String className, String annotationName, Map<String, String>
params) {
+        //To change body of implemented methods use File | Settings | File Templates.
+    }
 }

Copied: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/test/java/org/apache/myfaces/scripting/Probe.java
(from r815757, myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/test/java/org/apache/myfaces/scripting/QDoxTest.java)
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/test/java/org/apache/myfaces/scripting/Probe.java?p2=myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/test/java/org/apache/myfaces/scripting/Probe.java&p1=myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/test/java/org/apache/myfaces/scripting/QDoxTest.java&r1=815757&r2=815758&rev=815758&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/test/java/org/apache/myfaces/scripting/QDoxTest.java
(original)
+++ myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/test/java/org/apache/myfaces/scripting/Probe.java
Wed Sep 16 13:17:12 2009
@@ -18,10 +18,23 @@
  */
 package org.apache.myfaces.scripting;
 
+import org.junit.Ignore;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+
 /**
  * @author Werner Punz (latest modification by $Author$)
  * @version $Revision$ $Date$
+ *
+ * Testprobe for the qdox evaluation testbed
  */
 
-public class QDoxTest {
+@ManagedBean(name = "TestProbe")
+@SessionScoped
+@Ignore
+public class Probe {
+
+    
+    
 }

Modified: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/test/java/org/apache/myfaces/scripting/QDoxTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/test/java/org/apache/myfaces/scripting/QDoxTest.java?rev=815758&r1=815757&r2=815758&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/test/java/org/apache/myfaces/scripting/QDoxTest.java
(original)
+++ myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/test/java/org/apache/myfaces/scripting/QDoxTest.java
Wed Sep 16 13:17:12 2009
@@ -18,10 +18,76 @@
  */
 package org.apache.myfaces.scripting;
 
+import com.thoughtworks.qdox.JavaDocBuilder;
+import com.thoughtworks.qdox.model.JavaSource;
+import com.thoughtworks.qdox.model.JavaPackage;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.Annotation;
+import static junit.framework.Assert.fail;
+import static junit.framework.Assert.assertTrue;
+import org.junit.Test;
+import org.junit.Ignore;
+
+import java.io.File;
+import java.io.IOException;
+
 /**
  * @author Werner Punz (latest modification by $Author$)
  * @version $Revision$ $Date$
+ *          <p/>
+ *          Testing ground for qdox evaluation
+ *
+ *
+ * we set it to ignore because it is a testing
+ * 
+ * class to evaluate how to handle qdox
+ * on java sources
  */
 
+@Ignore
 public class QDoxTest {
+
+    //TODO replace this with maven specific dirs
+    static final String sourceProbe = "/Users/werpu2/development/workspace/extensions-scripting3/core/myfaces2-extensions/src/test/java/org/apache/myfaces/scripting/Probe.java";
+
+    private JavaSource[] scanIt() throws IOException {
+        JavaDocBuilder _builder = new JavaDocBuilder();
+        _builder.addSource(new File(sourceProbe));
+        JavaSource[] sources = _builder.getSources();
+
+        return sources;
+
+    }
+
+    //@Test
+    public void probeSource() {
+
+        try {
+            JavaSource[] sources = scanIt();
+
+            boolean managedBeanFound = false;
+            for (JavaSource source : sources) {
+                JavaPackage pckg = source.getPackage();
+                assertTrue(pckg.getName().equals("org.apache.myfaces.scripting"));
+                JavaClass[] classes = source.getClasses();
+                for (JavaClass clazz : classes) {
+                    Annotation[] annotations = clazz.getAnnotations();
+                    for (Annotation annot : annotations) {
+                        System.out.println(annot.toString());
+                        managedBeanFound |= annot.getType().getValue().equals("javax.faces.bean.ManagedBean");
+                        if(managedBeanFound) {
+                            break;
+                        }
+                    }
+                }
+            }
+
+            assertTrue(managedBeanFound);
+
+        } catch (IOException e) {
+            fail(e.toString());
+        }
+
+    }
+
 }



Mime
View raw message