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/10/01 17:26:41 UTC

svn commit: r820687 - in /myfaces/extensions/scripting/trunk/core: core/src/main/groovy/org/apache/myfaces/groovyloader/core/ core/src/main/java/org/apache/myfaces/scripting/api/ core/src/main/java/org/apache/myfaces/scripting/core/scanEvents/ core/src...

Author: werpu
Date: Thu Oct  1 15:26:40 2009
New Revision: 820687

URL: http://svn.apache.org/viewvc?rev=820687&view=rev
Log:
https://issues.apache.org/jira/browse/EXTSCRIPT-25
save state of affairs before we remove the listener from the bean handler we probably wont need it

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/api/ScriptingWeaver.java
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/scanEvents/SystemEventProcessor.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/ReloadingMetadata.java
    myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java
    myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java
    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/JavaAnnotationScanner.java

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=820687&r1=820686&r2=820687&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 Thu Oct  1 15:26:40 2009
@@ -153,4 +153,8 @@
         return identifier.isDynamic(clazz)
     }
 
+    public void fullRecompile() {
+        //TODO implement this
+    }
+
 }

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ScriptingWeaver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ScriptingWeaver.java?rev=820687&r1=820686&r2=820687&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ScriptingWeaver.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/ScriptingWeaver.java Thu Oct  1 15:26:40 2009
@@ -26,17 +26,18 @@
  * this class is a weaver which allows to trigger
  * the scripting layer in various situations
  * of the JSF interception points
- *
+ * <p/>
  * The scripting weaver replaces the classloader for those instances
  * because custom classloaders are inherently problematic in web containers
  */
-public interface ScriptingWeaver  {
+public interface ScriptingWeaver {
 
-  /**
+    /**
      * appends a custom script search path to the original one
-      * @param scriptPaths
+     *
+     * @param scriptPaths
      */
-   public void appendCustomScriptPath(String  scriptPaths); 
+    public void appendCustomScriptPath(String scriptPaths);
 
 
     /**
@@ -54,23 +55,24 @@
      * if no new class exists the original class is given back
      *
      * @param aclass the class which is likely to be reloaded
-     * @return   a new class or the same if no refresh has to be performed
+     * @return a new class or the same if no refresh has to be performed
      */
     public Class reloadScriptingClass(Class aclass);
 
     /**
-     *  loads a scripting class from a given className
+     * loads a scripting class from a given className
      * note, this method probably will be dropped in the long
      * run
+     *
      * @param className the classname including the package
-     * @return  a class instance of the file
+     * @return a class instance of the file
      */
     public Class loadScriptingClassFromName(String className);
 
 
     /**
      * returns the engine type for this weaver
-     * 
+     *
      * @return
      */
     public int getScriptingEngine();
@@ -95,6 +97,10 @@
     public void fullAnnotationScan();
 
 
-    //TODO add file annotation scan capabilities here
+    /**
+     * do a full recompile of changed resources instead of a
+     * simply compile per file
+     */
+    public void fullRecompile();
 
 }

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/scanEvents/SystemEventProcessor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/scanEvents/SystemEventProcessor.java?rev=820687&r1=820686&r2=820687&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/scanEvents/SystemEventProcessor.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/scanEvents/SystemEventProcessor.java Thu Oct  1 15:26:40 2009
@@ -42,6 +42,10 @@
         _listeners.add(listener);
     }
 
+    public boolean hasListener(SystemEventListener listener) {
+        return _listeners.contains(listener);
+    }
+
     public void removeListener(SystemEventListener listener) {
         _listeners.remove(listener);
     }

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=820687&r1=820686&r2=820687&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 Thu Oct  1 15:26:40 2009
@@ -27,10 +27,12 @@
 //import org.apache.myfaces.scripting.loaders.java.jsr199.ReflectCompilerFacade;
 
 import javax.servlet.ServletContext;
+import javax.faces.context.FacesContext;
 import java.io.File;
 import java.io.Serializable;
 import java.lang.reflect.InvocationTargetException;
 import java.util.Iterator;
+import java.util.Map;
 
 /**
  * @author werpu
@@ -50,6 +52,7 @@
 
     AnnotationScanner _scanner = null;
 
+
     /**
      * helper to allow initial compiler classpath scanning
      *
@@ -189,4 +192,38 @@
         _scanner.scanPaths();
     }
 
+    public void fullRecompile() {
+        if (isFullyRecompiled()) {
+            return;
+        }
+
+        DynamicCompiler compiler = (DynamicCompiler) ReflectUtil.instantiate(getScriptingFacadeClass());//new ReflectCompilerFacade();
+        for (String scriptPath : getScriptPaths()) {
+            //compile via javac dynamically, also after this block dynamic compilation
+            //for the entire length of the request,
+
+        }
+
+        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);
+            }
+        }
+    }
+
+    private boolean isFullyRecompiled() {
+        FacesContext context = FacesContext.getCurrentInstance();
+        if (context != null) {
+            return context.getExternalContext().getRequestMap().containsKey(JavaScriptingWeaver.class.getName() + "_recompiled");
+        }
+        return false;
+    }
+
 }

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/refresh/ReloadingMetadata.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/refresh/ReloadingMetadata.java?rev=820687&r1=820686&r2=820687&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/refresh/ReloadingMetadata.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/refresh/ReloadingMetadata.java Thu Oct  1 15:26:40 2009
@@ -29,13 +29,14 @@
 public class ReloadingMetadata {
 
     boolean tainted = false;
+    boolean annotated = false;
     boolean taintedOnce = false;
     String fileName = "";
     String sourcePath = "";
     Class aClass = null;
     long timestamp = 0l;
     int scriptingEngine = ScriptingConst.ENGINE_TYPE_NO_ENGINE;
-    
+
 
     public boolean isTainted() {
         return tainted;
@@ -92,4 +93,12 @@
     public void setSourcePath(String sourcePath) {
         this.sourcePath = sourcePath;
     }
+
+    public boolean isAnnotated() {
+        return annotated;
+    }
+
+    public void setAnnotated(boolean annotated) {
+        this.annotated = annotated;
+    }
 }
\ No newline at end of file

Modified: myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java?rev=820687&r1=820686&r2=820687&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java (original)
+++ myfaces/extensions/scripting/trunk/core/myfaces12-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java Thu Oct  1 15:26:40 2009
@@ -20,6 +20,8 @@
 
 import java.beans.FeatureDescriptor;
 import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
 
 import javax.el.ELContext;
 import javax.el.ELException;
@@ -31,13 +33,16 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.scripting.api.Decorated;
 import org.apache.myfaces.scripting.core.util.ProxyUtils;
+import org.apache.myfaces.scripting.core.scanEvents.SystemEventListener;
+import org.apache.myfaces.scripting.core.scanEvents.SystemEvent;
+import org.apache.myfaces.scripting.core.scanEvents.events.BeanLoadedEvent;
 
 /**
  * EL Resolver which is scripting enabled
  *
  * @author Werner Punz
  */
-public class ELResolverProxy extends ELResolver implements Decorated {
+public class ELResolverProxy extends ELResolver implements Decorated, SystemEventListener {
     Log log = LogFactory.getLog(ELResolverProxy.class);
 
 
@@ -48,7 +53,7 @@
         Object retVal = _delegate.getValue(elContext, base, property);
 
         if (retVal != null && ProxyUtils.isDynamic(retVal.getClass())) {
-            
+
 
             Object newRetVal = ProxyUtils.getWeaver().reloadScriptingInstance(retVal); /*once it was tainted or loaded by
                  our classloader we have to recreate all the time to avoid classloader issues*/
@@ -96,4 +101,15 @@
     public Object getDelegate() {
         return _delegate;  //To change body of implemented methods use File | Settings | File Templates.
     }
+
+    public Set<Integer> supportsEvents() {
+        Set<Integer> supports = new HashSet<Integer>();
+        supports.add(BeanLoadedEvent.ARTEFACT_TYPE_MANAGEDBEAN);
+
+        return supports;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public void handleEvent(SystemEvent evt) {
+        //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/jsf/dynamicdecorators/implemetations/ELResolverProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java?rev=820687&r1=820686&r2=820687&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java (original)
+++ myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java Thu Oct  1 15:26:40 2009
@@ -19,7 +19,7 @@
 package org.apache.myfaces.scripting.jsf.dynamicdecorators.implemetations;
 
 import java.beans.FeatureDescriptor;
-import java.util.Iterator;
+import java.util.*;
 
 import javax.el.ELContext;
 import javax.el.ELException;
@@ -31,6 +31,10 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.scripting.api.Decorated;
 import org.apache.myfaces.scripting.core.util.ProxyUtils;
+import org.apache.myfaces.scripting.core.scanEvents.SystemEventListener;
+import org.apache.myfaces.scripting.core.scanEvents.SystemEvent;
+import org.apache.myfaces.scripting.core.scanEvents.events.BeanLoadedEvent;
+import org.apache.myfaces.scripting.core.scanEvents.events.BeanRemovedEvent;
 
 /**
  * EL Resolver which is scripting enabled
@@ -42,18 +46,51 @@
     Log log = LogFactory.getLog(ELResolverProxy.class);
     ELResolver _delegate = null;
 
+    StackingBeanEventListener _listenerStack = new StackingBeanEventListener();
+
+    private void registerListenerStack() {
+        if (!ProxyUtils.getEventProcessor().hasListener(_listenerStack)) {
+            ProxyUtils.getEventProcessor().addListener(_listenerStack);
+        }
+    }
+
 
     public Object getValue(ELContext elContext, final Object base, final Object property) throws NullPointerException, PropertyNotFoundException, ELException {
         Object retVal = _delegate.getValue(elContext, base, property);
-
+        Object newRetVal = null;
         if (retVal != null && ProxyUtils.isDynamic(retVal.getClass())) {
-            
 
-            Object newRetVal = ProxyUtils.getWeaver().reloadScriptingInstance(retVal); /*once it was tainted or loaded by
+            //We have to register one listener per el instance
+            //because we have to deal with nesting of
+            //el locading caused by beans referencing other beans
+            //via inversion of object control
+
+            //onfurtunately this flow is somewhat strange because
+            //we shift logic into dynamically registered events
+            //but the event system is the only means of communication
+            //attached modules have to the core
+
+            //the flow is this -> try to load bean bean loading failes because
+            //annotation has moved -> this is notified about it ->
+            //we have to do a full recompile
+            //retry to load but this time without our referencing listener
+            registerListenerStack();
+            BeanEventListener eventListener = new BeanEventListener();
+            _listenerStack.pushListener(eventListener);
+            try {
+                //We register for annotation scanning events
+
+                newRetVal = ProxyUtils.getWeaver().reloadScriptingInstance(retVal); /*once it was tainted or loaded by
                  our classloader we have to recreate all the time to avoid classloader issues*/
+                fullRecompileReload(eventListener);
+            } finally {
+                _listenerStack.popListener();
+            }
+
             if (newRetVal != retVal) {
                 _delegate.setValue(elContext, base, property, newRetVal);
             }
+
             return newRetVal;
             //reinstantiated.put(retVal.getClass().getName(), retVal.getClass());
         }
@@ -62,6 +99,22 @@
 
     }
 
+
+    private void fullRecompileReload(BeanEventListener eventListener) {
+        if (eventListener.getBeanEventIssued().size() > 0) {
+            //last was the first event issued
+            SystemEvent beanEvent = eventListener.getBeanEventIssued().removeLast();
+            eventListener.getBeanEventIssued().clear();
+            if (beanEvent instanceof BeanRemovedEvent) {
+
+                if (log.isDebugEnabled()) {
+                    log.debug("ElResolverProxy.getValue bean removed we have to issue a recompile and then try to load the bean anew");
+
+                }
+            }
+        }
+    }
+
     public Class<?> getType(ELContext elContext, Object o, Object o1) throws NullPointerException, PropertyNotFoundException, ELException {
         Class<?> retVal = _delegate.getType(elContext, o, o1);
         if (retVal != null && ProxyUtils.isDynamic((Class) retVal)) {
@@ -87,8 +140,6 @@
     }
 
 
-
-
     public ELResolverProxy(ELResolver delegate) {
         _delegate = delegate;
     }
@@ -97,4 +148,79 @@
     public Object getDelegate() {
         return _delegate;  //To change body of implemented methods use File | Settings | File Templates.
     }
+
+
+    //TODO replace the stack with a direct check for the bean name,
+    //this should be sufficient and should make the code much easier to deal with
+    /**
+     * We stack our event listeners, because only the one currently
+     * active should receive the bean events
+     * This is because the IOC Resolving can happen during reload
+     * and only the current level within the object
+     * resolution should trigger the recompile and reload!
+     */
+    class StackingBeanEventListener implements SystemEventListener {
+        private LinkedList<BeanEventListener> _stack = new LinkedList<BeanEventListener>();
+
+
+        public void pushListener(BeanEventListener listener) {
+            _stack.addFirst(listener);
+        }
+
+        public BeanEventListener popListener() {
+            return _stack.removeFirst();
+        }
+
+        public Set<Integer> supportsEvents() {
+            if (_stack.isEmpty()) {
+                return Collections.EMPTY_SET;
+            }
+            return _stack.getFirst().supportsEvents();  //To change body of implemented methods use File | Settings | File Templates.
+        }
+
+        public void handleEvent(SystemEvent evt) {
+            if (_stack.isEmpty()) {
+                return;
+            }
+            _stack.getFirst().handleEvent(evt);
+        }
+    }
+
+
+    class BeanEventListener implements SystemEventListener {
+
+        private LinkedList<SystemEvent> _beanEventIssued = new LinkedList<SystemEvent>();
+        //Map reinstantiated = new HashMap();
+
+
+        BeanEventListener() {
+        }
+
+        public Set<Integer> supportsEvents() {
+            Set<Integer> supports = new HashSet<Integer>();
+            supports.add(BeanLoadedEvent.ARTEFACT_TYPE_MANAGEDBEAN);
+
+            return supports;  //To change body of implemented methods use File | Settings | File Templates.
+        }
+
+        /**
+         * bean loaded and unloaded can trigger an applicationState
+         *
+         * @param evt
+         */
+        public void handleEvent(SystemEvent evt) {
+            if (evt instanceof BeanLoadedEvent || evt instanceof BeanRemovedEvent) {
+                _beanEventIssued.addFirst(evt);
+            }
+        }
+
+
+        public LinkedList<SystemEvent> getBeanEventIssued() {
+            return _beanEventIssued;
+        }
+
+        public void setBeanEventIssued(LinkedList<SystemEvent> beanEventIssued) {
+            _beanEventIssued = beanEventIssued;
+        }
+    }
 }

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=820687&r1=820686&r2=820687&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 Thu Oct  1 15:26:40 2009
@@ -65,7 +65,7 @@
         String annotationName = ann.getClass().getName();
 
         RuntimeConfig config = getRuntimeConfig();
-        String beanName = (String) ReflectUtil.executeMethod(ann, "getName");
+        String beanName = (String) ReflectUtil.executeMethod(ann.annotationType(), "getName");
         beanName = beanName.replaceAll("\"", "");
         if (!hasToReregister(beanName, clazz)) {
             return;
@@ -317,7 +317,7 @@
 
         for (Map.Entry mbean : managedBeans.entrySet()) {
             org.apache.myfaces.config.element.ManagedBean bean = (org.apache.myfaces.config.element.ManagedBean) mbean.getValue();
-            if (!bean.getClass().getName().equals(className)) {
+            if (!bean.getManagedBeanClass().getName().equals(className)) {
                 config.addManagedBean((String) mbean.getKey(), (org.apache.myfaces.config.element.ManagedBean) mbean.getValue());
             } else {
                 mbeanFound = (org.apache.myfaces.config.element.ManagedBean) mbean.getValue();

Modified: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/JavaAnnotationScanner.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/JavaAnnotationScanner.java?rev=820687&r1=820686&r2=820687&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/JavaAnnotationScanner.java (original)
+++ myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/JavaAnnotationScanner.java Thu Oct  1 15:26:40 2009
@@ -27,12 +27,11 @@
 import org.apache.myfaces.scripting.core.util.ProxyUtils;
 
 import java.io.File;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
+import java.util.*;
 
 import org.apache.myfaces.scripting.core.scanEvents.events.AnnotatedArtefactRemovedEvent;
+import org.apache.myfaces.scripting.refresh.FileChangedDaemon;
+import org.apache.myfaces.scripting.refresh.ReloadingMetadata;
 
 /**
  * @author Werner Punz (latest modification by $Author$)
@@ -68,11 +67,39 @@
         }
     }
 
+    Collection<Annotation> filterAnnotations(Annotation[] anns) {
+        List<Annotation> retVal = new ArrayList<Annotation>(anns.length);
+        if (anns == null) {
+            return retVal;
+        }
+        for (Annotation ann : anns) {
+            if (ann.getType().getValue().startsWith("javax.faces")) {
+                retVal.add(ann);
+            }
+        }
+        return retVal;
+    }
+
+    Collection<java.lang.annotation.Annotation> filterAnnotations(java.lang.annotation.Annotation[] anns) {
+        List<java.lang.annotation.Annotation> retVal = new ArrayList<java.lang.annotation.Annotation>(anns.length);
+        if (anns == null) {
+            return retVal;
+        }
+        for (java.lang.annotation.Annotation ann : anns) {
+            if (ann.annotationType().getName().startsWith("javax.faces")) {
+                retVal.add(ann);
+            }
+
+        }
+        return retVal;
+    }
+
     public void scanClass(Class clazz) {
         //java.lang.annotation.Annotation[] anns = clazz.getAnnotations();
 
         java.lang.annotation.Annotation[] anns = clazz.getAnnotations();
-        if (anns != null || anns.length > 0) {
+        Collection<java.lang.annotation.Annotation> annCol = filterAnnotations(anns);
+        if (!annCol.isEmpty()) {
             addOrMoveAnnotations(clazz);
         } else {
             removeAnnotations(clazz);
@@ -130,9 +157,10 @@
                             clazz, ann.getType().getValue(), ann.getPropertyMap());
 
                     _registeredAnnotations.put(clazz.getFullyQualifiedName(), ann.getType().getValue());
-                } else {
-                    annotationMoved(clazz, ann, listener);
-
+                    ReloadingMetadata metaData = FileChangedDaemon.getInstance().getClassMap().get(clazz.getFullyQualifiedName());
+                    if (metaData != null) {
+                        metaData.setAnnotated(true);
+                    }
                 }
             }
         }
@@ -148,16 +176,16 @@
         java.lang.annotation.Annotation[] anns = clazz.getAnnotations();
         for (java.lang.annotation.Annotation ann : anns) {
             for (AnnotationScanListener listener : _listeners) {
-                if (listener.supportsAnnotation(ann.getClass().getName())) {
+                if (listener.supportsAnnotation(ann.annotationType().getName())) {
                     listener.register(clazz, ann);
 
-                    _registeredAnnotations.put(clazz.getName(), ann.getClass().getName());
-
+                    _registeredAnnotations.put(clazz.getName(), ann.annotationType().getName());
 
-                } else {
-                    annotationMoved(clazz, ann, listener);
-
-                }
+                    ReloadingMetadata metaData = FileChangedDaemon.getInstance().getClassMap().get(clazz.getName());
+                    if (metaData != null) {
+                        metaData.setAnnotated(true);
+                    }
+                } 
             }
         }
     }
@@ -177,6 +205,7 @@
                     listener.purge(clazz.getFullyQualifiedName());
                     _registeredAnnotations.remove(clazz.getFullyQualifiedName());
                     ProxyUtils.getEventProcessor().dispatchEvent(new AnnotatedArtefactRemovedEvent(clazz.getFullyQualifiedName()));
+                    FileChangedDaemon.getInstance().getClassMap().remove(clazz.getFullyQualifiedName());
                 }
             }
         }
@@ -196,6 +225,7 @@
                 if (listener.supportsAnnotation(registeredAnnotation)) {
                     listener.purge(clazz.getName());
                     _registeredAnnotations.remove(clazz.getName());
+                    FileChangedDaemon.getInstance().getClassMap().remove(clazz.getName());
                 }
             }
         }
@@ -215,7 +245,7 @@
         //case class exists but it has been moved to anoter annotation
         String registeredAnnotation = _registeredAnnotations.get(clazz.getFullyQualifiedName());
         if (registeredAnnotation != null && registeredAnnotation.equals(ann.getType().getValue())) {
-            listener.purge(clazz.getFullyQualifiedName());
+            removeAnnotations(clazz);
         }
     }
 
@@ -223,7 +253,7 @@
         //case class exists but it has been moved to anoter annotation
         String registeredAnnotation = _registeredAnnotations.get(clazz.getName());
         if (registeredAnnotation != null && registeredAnnotation.equals(ann.getClass().getName())) {
-            listener.purge(clazz.getName());
+            removeAnnotations(clazz);
         }
     }