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 2012/03/14 16:46:07 UTC

svn commit: r1300598 [7/10] - in /myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src: main/java/org/apache/myfaces/extensions/scripting/core/api/ main/java/org/apache/myfaces/extensions/scripting/core/common/ main/java/org/apache...

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/components/TaintHistoryRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/components/TaintHistoryRenderer.java?rev=1300598&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/components/TaintHistoryRenderer.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/components/TaintHistoryRenderer.java Wed Mar 14 15:46:00 2012
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.extensions.scripting.jsf.components;
+
+
+import org.apache.myfaces.extensions.scripting.core.api.WeavingContext;
+import org.apache.myfaces.extensions.scripting.core.monitor.ClassResource;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.util.Collection;
+
+/**
+ * A renderer which displays our taint history
+ *
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+@SuppressWarnings("unchecked")
+//we have to suppress here because of the component cast
+public class TaintHistoryRenderer extends Renderer {
+
+    @Override
+    public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
+        super.encodeBegin(context, component);
+
+        ResponseWriter responseWriter = FacesContext.getCurrentInstance().getResponseWriter();
+
+        startDiv(component, responseWriter, "historyBox");
+        int lastTainted = ((TaintHistory) component).getNoEntries();
+
+        Collection<ClassResource> result = WeavingContext.getInstance().getLastTainted(lastTainted);
+        if (result == null || result.isEmpty()) {
+            responseWriter.write(RendererConst.NO_TAINT_HISTORY_FOUND);
+        } else {
+            writeHistory(component, responseWriter, result);
+        }
+        endDiv(responseWriter);
+
+        responseWriter.flush();
+
+    }
+
+    private void writeHistory(UIComponent component, ResponseWriter responseWriter,
+                              Collection<ClassResource> result) throws IOException {
+        startDiv(component, responseWriter, "history");
+        for (ClassResource entry : result) {
+            startDiv(component, responseWriter, RendererConst.LINE);
+            writeDiv(component, responseWriter, RendererConst.TIMESTAMP, DateFormat.getInstance().format(entry.getFile().lastModified()));
+            writeDiv(component, responseWriter, RendererConst.CHANGED_FILE, entry.getFile().getAbsolutePath());
+            endDiv(responseWriter);
+        }
+
+        endDiv(responseWriter);
+    }
+
+    private String writeDiv(UIComponent component, ResponseWriter responseWriter, String styleClass, String value) throws IOException {
+        startDiv(component, responseWriter, styleClass);
+        responseWriter.write(value);
+        endDiv(responseWriter);
+        return "";
+    }
+
+    private void endDiv(ResponseWriter responseWriter) throws IOException {
+        responseWriter.endElement(RendererConst.HTML_DIV);
+    }
+
+    private void startDiv(UIComponent component, ResponseWriter responseWriter, String styleClass) throws IOException {
+        responseWriter.startElement(RendererConst.HTML_DIV, component);
+        responseWriter.writeAttribute(RendererConst.HTML_CLASS, styleClass, null);
+    }
+
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/factories/ScriptingApplicationFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/factories/ScriptingApplicationFactory.java?rev=1300598&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/factories/ScriptingApplicationFactory.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/factories/ScriptingApplicationFactory.java Wed Mar 14 15:46:00 2012
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories;
+
+import org.apache.myfaces.extensions.scripting.core.api.Decorated;
+import org.apache.myfaces.extensions.scripting.core.api.WeavingContext;
+import org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implementations.ApplicationProxy;
+
+import javax.faces.application.Application;
+import javax.faces.application.ApplicationFactory;
+
+/**
+ * Application factory which introduces
+ * scripting proxies for their artefacts
+ * <p/>
+ * We use a mix of AOP and helper constructs
+ * to reach the goal to be dynamic.
+ * For most artefacts we just need to
+ * check if the object is a Groovy object
+ * and then reload at their connection interfaces
+ * <p/>
+ * Some artefacts have a longer lifespan and/or are stateless
+ * for those we have to work with reloading AOP
+ *
+ * @author Werner Punz
+ */
+public class ScriptingApplicationFactory extends ApplicationFactory implements Decorated
+{
+
+    ApplicationFactory _delegate;
+
+
+    public ScriptingApplicationFactory(ApplicationFactory delegate) {
+        _delegate = delegate;
+
+    }
+
+    public Application getApplication() {
+        Application retVal = _delegate.getApplication();
+
+        if (WeavingContext.getInstance().isScriptingEnabled()  && !(retVal instanceof ApplicationProxy))
+            retVal = new ApplicationProxy(retVal);
+
+        return retVal;
+    }
+
+    public void setApplication(Application application) {
+        if (WeavingContext.getInstance().isScriptingEnabled() && !(application instanceof ApplicationProxy))
+            application = new ApplicationProxy(application);
+
+        _delegate.setApplication(application);
+    }
+
+    @Override
+    public ApplicationFactory getWrapped() {
+        return _delegate.getWrapped();
+    }
+
+    public Object getDelegate() {
+        return _delegate;
+    }
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/factories/ScriptingFacesContextFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/factories/ScriptingFacesContextFactory.java?rev=1300598&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/factories/ScriptingFacesContextFactory.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/factories/ScriptingFacesContextFactory.java Wed Mar 14 15:46:00 2012
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories;
+
+
+import org.apache.myfaces.extensions.scripting.core.api.Decorated;
+import org.apache.myfaces.extensions.scripting.core.api.WeavingContext;
+import org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implementations.FacesContextProxy;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import javax.faces.context.FacesContextFactory;
+import javax.faces.lifecycle.Lifecycle;
+
+/**
+ * Faces context weaver which builds
+ * our reloading proxy around the current faces context
+ *
+ * @author Werner Punz
+ */
+public class ScriptingFacesContextFactory extends FacesContextFactory implements Decorated
+{
+
+    public FacesContextFactory _delegate;
+
+    public ScriptingFacesContextFactory(FacesContextFactory delegate) {
+        _delegate = delegate;
+    }
+
+    public void setDelegate(FacesContextFactory delegate) {
+        _delegate = delegate;
+    }
+
+    public FacesContext getFacesContext(Object o, Object o1, Object o2, Lifecycle lifecycle) throws FacesException {
+        FacesContext retVal = _delegate.getFacesContext(o, o1, o2, lifecycle);
+
+        if (WeavingContext.getInstance().isScriptingEnabled()  && !(retVal instanceof FacesContextProxy))
+            return new FacesContextProxy(retVal);
+        return retVal;
+    }
+
+    @Override
+    public FacesContextFactory getWrapped() {
+        return _delegate.getWrapped();
+    }
+
+    public Object getDelegate() {
+        return _delegate;
+    }
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/factories/ScriptingLifecycleFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/factories/ScriptingLifecycleFactory.java?rev=1300598&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/factories/ScriptingLifecycleFactory.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/factories/ScriptingLifecycleFactory.java Wed Mar 14 15:46:00 2012
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories;
+
+import org.apache.myfaces.extensions.scripting.core.api.Decorated;
+import org.apache.myfaces.extensions.scripting.core.api.WeavingContext;
+import org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implementations.LifefcycleProxy;
+
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.lifecycle.LifecycleFactory;
+import java.util.Iterator;
+
+/**
+ * Lifecyclefactory which introduces scripting proxies
+ * for their artefacts
+ *
+ * @author Werner Punz
+ */
+public class ScriptingLifecycleFactory extends LifecycleFactory implements Decorated
+{
+
+    LifecycleFactory _delegate;
+
+
+    public ScriptingLifecycleFactory(LifecycleFactory delegate) {
+        _delegate = delegate;
+    }
+
+    public void addLifecycle(String s, Lifecycle lifecycle) {
+        if (WeavingContext.getInstance().isScriptingEnabled()  && !(lifecycle instanceof LifefcycleProxy))
+            lifecycle = new LifefcycleProxy(lifecycle);
+        _delegate.addLifecycle(s, lifecycle);
+    }
+
+    public Lifecycle getLifecycle(String s) {
+        Lifecycle retVal = _delegate.getLifecycle(s);
+        if (WeavingContext.getInstance().isScriptingEnabled()  && !(retVal instanceof LifefcycleProxy))
+            retVal = new LifefcycleProxy(retVal);
+
+        return retVal;
+    }
+
+    public Iterator getLifecycleIds() {
+        return _delegate.getLifecycleIds();
+    }
+
+    public void setDelegate(LifecycleFactory delegate) {
+        this._delegate = delegate;
+    }
+
+    @Override
+    public LifecycleFactory getWrapped() {
+        return _delegate.getWrapped();
+    }
+
+    public Object getDelegate() {
+        return _delegate;
+    }
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/factories/ScriptingRenderkitFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/factories/ScriptingRenderkitFactory.java?rev=1300598&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/factories/ScriptingRenderkitFactory.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/factories/ScriptingRenderkitFactory.java Wed Mar 14 15:46:00 2012
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories;
+
+
+import org.apache.myfaces.extensions.scripting.core.api.Decorated;
+import org.apache.myfaces.extensions.scripting.core.api.WeavingContext;
+import org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implementations.RenderkitProxy;
+
+import javax.faces.context.FacesContext;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+import java.util.Iterator;
+
+/**
+ * Scripting enabled renderkit factory
+ *
+ * @author Werner Punz
+ */
+public class ScriptingRenderkitFactory extends RenderKitFactory implements Decorated
+{
+
+
+    public ScriptingRenderkitFactory(RenderKitFactory delegate) {
+        _delegate = delegate;
+    }
+
+    public void addRenderKit(String s, RenderKit renderKit) {
+        if (WeavingContext.getInstance().isScriptingEnabled() && renderKit != null && !(renderKit instanceof RenderkitProxy))
+            renderKit = new RenderkitProxy(renderKit);
+
+        _delegate.addRenderKit(s, renderKit);
+    }
+
+    public RenderKit getRenderKit(FacesContext facesContext, String s) {
+        RenderKit retVal = _delegate.getRenderKit(facesContext, s);
+        if (WeavingContext.getInstance().isScriptingEnabled() && retVal != null && !(retVal instanceof RenderkitProxy))
+            retVal = new RenderkitProxy(retVal);
+        return retVal;
+    }
+
+    public Iterator getRenderKitIds() {
+        return _delegate.getRenderKitIds();
+    }
+
+    public void setDelegate(RenderKitFactory delegate) {
+        _delegate = delegate;
+    }
+
+    @Override
+    public RenderKitFactory getWrapped() {
+        return _delegate.getWrapped();
+    }
+
+    RenderKitFactory _delegate = null;
+
+    public Object getDelegate() {
+        return _delegate;
+    }
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/ApplicationProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/ApplicationProxy.java?rev=1300598&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/ApplicationProxy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/ApplicationProxy.java Wed Mar 14 15:46:00 2012
@@ -0,0 +1,957 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implementations;
+
+import org.apache.myfaces.extensions.scripting.core.api.Decorated;
+import org.apache.myfaces.extensions.scripting.core.api.WeavingContext;
+
+import javax.el.*;
+import javax.faces.FacesException;
+import javax.faces.application.*;
+import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.Behavior;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.el.*;
+import javax.faces.event.ActionListener;
+import javax.faces.event.SystemEvent;
+import javax.faces.event.SystemEventListener;
+import javax.faces.validator.Validator;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.apache.myfaces.extensions.scripting.core.api.ScriptingConst.*;
+
+/**
+ * @author Werner Punz
+ *         <p/>
+ *         our decorating applicstion
+ *         which should resolve our bean issues within a central
+ *         bean processing interceptor
+ */
+public class ApplicationProxy extends Application implements Decorated
+{
+
+    Application _delegate = null;
+
+    /*
+    * separate map needed for the behavior ids, because
+    * the original is immutable
+    * we have to do a double bookkeeping
+    * here
+    */
+    Map<String, String> _behaviors = new ConcurrentHashMap<String, String>();
+
+    /**
+     * special data structure to save our
+     * object -> proxy references
+     */
+    class EventHandlerProxyEntry
+    {
+        Class event;
+        Decorated proxy;
+
+        EventHandlerProxyEntry(Class event, Decorated proxy)
+        {
+            this.event = event;
+            this.proxy = proxy;
+        }
+
+        @SuppressWarnings("unused")
+        public Class getEvent()
+        {
+            return event;
+        }
+
+        @SuppressWarnings("unused")
+        public void setEvent(Class event)
+        {
+            this.event = event;
+        }
+
+        public Decorated getProxy()
+        {
+            return proxy;
+        }
+
+        @SuppressWarnings("unused")
+        public void setProxy(Decorated proxy)
+        {
+            this.proxy = proxy;
+        }
+
+        @Override
+        public boolean equals(Object o)
+        {
+            if (this == o) return true;
+            if (o == null || getClass() != o.getClass()) return false;
+
+            EventHandlerProxyEntry that = (EventHandlerProxyEntry) o;
+
+            return !(event != null ? !event.equals(that.event) : that.event != null) && !(proxy != null ? !proxy.getDelegate().getClass().getName().equals(that.proxy.getDelegate().getClass().getName()) : that.proxy != null);
+
+        }
+
+        @Override
+        public int hashCode()
+        {
+            int result = event.hashCode();
+            result = 31 * result + proxy.getDelegate().getClass().getName().hashCode();
+            return result;
+        }
+    }
+
+    /**
+     * now at the first look this looks like a weird construct
+     * but the standard java set imposes this limit since
+     * we have to iterate over the entire set to reach the correct element
+     * the trick is to save the same object in as both key and value
+     * and now if we generate a new key on an object
+     * we can fetch our proxy which might already contain
+     * the same object in a refreshed state from the value
+     * part of the set, in our case
+     * using hash maps should speed things up
+     * <p/>
+     * since we only have few write operations but access
+     * the map multithreaded we use concurrentHashMap here
+     */
+    Map<EventHandlerProxyEntry, EventHandlerProxyEntry> _eventHandlerIdx = new ConcurrentHashMap<EventHandlerProxyEntry, EventHandlerProxyEntry>();
+
+    volatile static boolean varResolverAdded = false;
+
+    ELResolverProxy finalResolver = null;
+
+    public ApplicationProxy(Application delegate)
+    {
+        _delegate = delegate;
+    }
+
+    public void addELResolver(ELResolver elResolver)
+    {
+        weaveDelegate();
+        //we do not need a proxy here anymore because
+        //we drop the beans directly
+        _delegate.addELResolver(elResolver);
+    }
+
+    private void weaveDelegate()
+    {
+        if (_delegate != null)
+        {
+            _delegate = (Application) WeavingContext.getInstance().reload(_delegate,
+                    ARTIFACT_TYPE_APPLICATION);
+        }
+    }
+
+    public ELResolver getELResolver()
+    {
+        weaveDelegate();
+
+        ELResolver retVal = _delegate.getELResolver();
+        return retVal;
+    }
+
+    //TOD add a weaving for resource bundles
+
+    public ResourceBundle getResourceBundle(FacesContext facesContext, String s) throws FacesException, NullPointerException
+    {
+        weaveDelegate();
+        return _delegate.getResourceBundle(facesContext, s);
+    }
+
+    public UIComponent createComponent(ValueExpression valueExpression, FacesContext facesContext, String componentType) throws FacesException, NullPointerException
+    {
+        weaveDelegate();
+        UIComponent component = _delegate.createComponent(valueExpression, facesContext, componentType);
+        UIComponent oldComponent = component;
+        //We can replace annotated components on the fly via
+        //ApplicationImpl.addComponent(final String componentType, final String componentClassName)
+
+        /*we are reweaving on the fly because we cannot be sure if
+        * the class is not recycled all the time in the creation
+        * code, in the renderer we do it on method base
+        * due to the fact that our renderers are recycled via
+        * a flyweight pattern
+        *
+        *
+        * Also we cannot proxy here because there is no UIComponent interface
+        * maybe in the long run we can make a decorator here instead
+        * but for now lets try it this way
+        */
+        component = (UIComponent) reloadInstance(component, ARTIFACT_TYPE_COMPONENT);
+
+        //we now have to check for an annotation change, but only in case a reload has happened
+        /*<> if (component.getClass().hashCode() != oldComponent.getClass().hashCode())
+        {
+            return handleAnnotationChange(component, valueExpression, facesContext, componentType);
+        } */
+
+        return component;
+
+    }
+
+    public ExpressionFactory getExpressionFactory()
+    {
+        weaveDelegate();
+        return _delegate.getExpressionFactory();
+    }
+
+    public void addELContextListener(ELContextListener elContextListener)
+    {
+        weaveDelegate();
+        if (WeavingContext.getInstance().isDynamic(elContextListener.getClass()))
+            elContextListener = (ELContextListener) WeavingContext.getInstance().createMethodReloadingProxyFromObject
+            (elContextListener, ELContextListener.class, ARTIFACT_TYPE_ELCONTEXTLISTENER);
+        _delegate.addELContextListener(elContextListener);
+    }
+
+    public void removeELContextListener(ELContextListener elContextListener)
+    {
+        weaveDelegate();
+        _delegate.removeELContextListener(elContextListener);
+    }
+
+    public ELContextListener[] getELContextListeners()
+    {
+        weaveDelegate();
+        return _delegate.getELContextListeners();
+    }
+
+    public ActionListener getActionListener()
+    {
+        weaveDelegate();
+        ActionListener retVal = _delegate.getActionListener();
+        if (WeavingContext.getInstance().isDynamic(retVal.getClass()))
+            retVal = (ActionListener) WeavingContext.getInstance().createMethodReloadingProxyFromObject(retVal,
+            ActionListener.class, ARTIFACT_TYPE_ACTIONLISTENER);
+        return retVal;
+    }
+
+    public void setActionListener(ActionListener actionListener)
+    {
+        weaveDelegate();
+        if (WeavingContext.getInstance().isDynamic(actionListener.getClass()))
+            actionListener = (ActionListener) WeavingContext.getInstance().createMethodReloadingProxyFromObject(actionListener,
+            ActionListener.class, ARTIFACT_TYPE_ACTIONLISTENER);
+        _delegate.setActionListener(actionListener);
+    }
+
+    public Locale getDefaultLocale()
+    {
+        weaveDelegate();
+        return _delegate.getDefaultLocale();
+    }
+
+    public void setDefaultLocale(Locale locale)
+    {
+        weaveDelegate();
+        _delegate.setDefaultLocale(locale);
+    }
+
+    public String getDefaultRenderKitId()
+    {
+        weaveDelegate();
+        return _delegate.getDefaultRenderKitId();
+    }
+
+    public void setDefaultRenderKitId(String s)
+    {
+        weaveDelegate();
+        _delegate.setDefaultRenderKitId(s);
+    }
+
+    public String getMessageBundle()
+    {
+        weaveDelegate();
+        return _delegate.getMessageBundle();
+    }
+
+    public void setMessageBundle(String s)
+    {
+        weaveDelegate();
+        _delegate.setMessageBundle(s);
+    }
+
+    public NavigationHandler getNavigationHandler()
+    {
+        weaveDelegate();
+        //defined in the setter to speed things up a little
+        NavigationHandler retVal = _delegate.getNavigationHandler();
+
+        //if (retVal != null && WeavingContext.isDynamic(retVal.getClass()))
+        //    retVal = new NavigationHandlerProxy(retVal);
+        return retVal;
+    }
+
+    public void setNavigationHandler(NavigationHandler navigationHandler)
+    {
+        weaveDelegate();
+
+        if (navigationHandler != null && WeavingContext.getInstance().isDynamic(navigationHandler.getClass()))
+            navigationHandler = new NavigationHandlerProxy(navigationHandler);
+        _delegate.setNavigationHandler(navigationHandler);
+    }
+
+    @SuppressWarnings("deprecation")
+    public PropertyResolver getPropertyResolver()
+    {
+        weaveDelegate();
+        return _delegate.getPropertyResolver();
+    }
+
+    @SuppressWarnings("deprecation")
+    public void setPropertyResolver(PropertyResolver propertyResolver)
+    {
+        weaveDelegate();
+        _delegate.setPropertyResolver(propertyResolver);
+    }
+
+    @SuppressWarnings("deprecation")
+    public VariableResolver getVariableResolver()
+    {
+        weaveDelegate();
+        return _delegate.getVariableResolver();
+    }
+
+    @SuppressWarnings("deprecation")
+    public void setVariableResolver(VariableResolver variableResolver)
+    {
+        weaveDelegate();
+        if (!varResolverAdded)
+        {
+            variableResolver = new VariableResolverProxy(variableResolver);
+            varResolverAdded = true;
+        }
+        _delegate.setVariableResolver(variableResolver);
+    }
+
+    public ViewHandler getViewHandler()
+    {
+        weaveDelegate();
+        ViewHandler handler = _delegate.getViewHandler();
+
+        /*
+        We proxy here to enable dynamic reloading for
+        methods in the long run, as soon as we hit
+        java all our groovy reloading code is lost
+        hence we have to work with proxies here
+        */
+        if (WeavingContext.getInstance().isDynamic(handler.getClass()))
+            handler = new ViewHandlerProxy(handler);
+        return handler;
+    }
+
+    public void setViewHandler(ViewHandler viewHandler)
+    {
+        weaveDelegate();
+        /*make sure you have the delegates as well in properties*/
+        if (WeavingContext.getInstance().isDynamic(viewHandler.getClass()))
+            viewHandler = new ViewHandlerProxy(viewHandler);
+
+        _delegate.setViewHandler(viewHandler);
+    }
+
+    public StateManager getStateManager()
+    {
+        weaveDelegate();
+        return _delegate.getStateManager();
+    }
+
+    public void setStateManager(StateManager stateManager)
+    {
+        weaveDelegate();
+        _delegate.setStateManager(stateManager);
+    }
+
+    public void addComponent(String componentType, String componentClass)
+    {
+        weaveDelegate();
+        _delegate.addComponent(componentType, componentClass);
+    }
+
+    public UIComponent createComponent(String componentType) throws FacesException
+    {
+        weaveDelegate();
+        //the components are generated anew very often
+        //we cannot do an on object weaving here
+        UIComponent oldComponent = _delegate.createComponent(componentType);
+
+        /*we are reweaving on the fly because we cannot be sure if
+        * the class is not recycled all the time in the creation
+        * code, in the renderer we do it on method base
+        * due to the fact that our renderers are recycled via
+        * a flyweight pattern*/
+        UIComponent component = (UIComponent) reloadInstance(oldComponent, ARTIFACT_TYPE_COMPONENT);
+
+        //we now have to check for an annotation change, but only in case a reload has happened
+        /*<> if (component.getClass().hashCode() != oldComponent.getClass().hashCode())
+        {
+            return handleAnnotationChange(component, componentType);
+        } */
+
+        return component;
+
+    }
+
+    @SuppressWarnings("deprecation")
+    public UIComponent createComponent(ValueBinding valueBinding, FacesContext facesContext, String componentType) throws FacesException
+    {
+        weaveDelegate();
+        UIComponent oldComponent = _delegate.createComponent(valueBinding, facesContext, componentType);
+
+        /*we are reweaving on the fly because we cannot be sure if
+         * the class is not recycled all the time in the creation
+         * code, in the renderer we do it on method base
+         * due to the fact that our renderers are recycled via
+         * a flyweight pattern*/
+        UIComponent component = (UIComponent) reloadInstance(oldComponent, ARTIFACT_TYPE_COMPONENT);
+
+        //we now have to check for an annotation change, but only in case a reload has happened
+        /*<>if (component.getClass().hashCode() != oldComponent.getClass().hashCode())
+        {
+            return handleAnnotationChange(component, valueBinding, facesContext, componentType);
+        }*/
+
+        return component;
+    }
+
+    public Iterator<String> getComponentTypes()
+    {
+        weaveDelegate();
+        return _delegate.getComponentTypes();
+    }
+
+    public void addConverter(String converterId, String converterClass)
+    {
+        weaveDelegate();
+        /* if (converterClass.equals(PurgedConverter.class.getName())) {
+            //purged case we do a full rescan
+            WeavingContext.getWeaver().fullClassScan();
+            Converter componentToChange = _delegate.createConverter(converterId);
+            if (componentToChange instanceof PurgedConverter) {
+                //Null not allowed here, but we set a purted converter to make
+                //sure that we get errors on the proper level
+                _delegate.addConverter(converterId, PurgedConverter.class.getName());
+            }
+            return;
+        }*/
+
+        _delegate.addConverter(converterId, converterClass);
+    }
+
+    public void addConverter(Class targetClass, String converterClass)
+    {
+        weaveDelegate();
+        _delegate.addConverter(targetClass, converterClass);
+    }
+
+    public Converter createConverter(String converterId)
+    {
+        weaveDelegate();
+        Converter retVal = _delegate.createConverter(converterId);
+
+        /**
+         * since createConverter is called only once
+         * we have to work with method reloading proxies
+         * we cannot use this technique extensively for speed reasons
+         * most of the time it is fine just to work with
+         *
+         * reloading objects at their interception points
+         */
+        Converter newRetVal = (Converter) reloadInstance(retVal, ARTIFACT_TYPE_CONVERTER);
+        if (newRetVal != retVal)
+        {
+            return _delegate.createConverter(converterId);
+        }
+
+        return retVal;
+    }
+
+    public Converter createConverter(Class aClass)
+    {
+        weaveDelegate();
+        Converter retVal = _delegate.createConverter(aClass);
+        Converter newRetVal = (Converter) reloadInstance(retVal, ARTIFACT_TYPE_CONVERTER);
+        if (newRetVal != retVal)
+        {
+            return _delegate.createConverter(aClass);
+        }
+
+        return retVal;
+    }
+
+    public Iterator<String> getConverterIds()
+    {
+        weaveDelegate();
+        return _delegate.getConverterIds();
+    }
+
+    public Iterator<Class<?>> getConverterTypes()
+    {
+        weaveDelegate();
+        return _delegate.getConverterTypes();
+    }
+
+    @SuppressWarnings("deprecation")
+    public MethodBinding createMethodBinding(String s, Class[] classes) throws ReferenceSyntaxException
+    {
+        weaveDelegate();
+        return _delegate.createMethodBinding(s, classes);
+    }
+
+    public Iterator<Locale> getSupportedLocales()
+    {
+        weaveDelegate();
+        return _delegate.getSupportedLocales();
+    }
+
+    public void setSupportedLocales(Collection<Locale> locales)
+    {
+        weaveDelegate();
+        _delegate.setSupportedLocales(locales);
+    }
+
+    public void addValidator(String validatorId, String validatorClass)
+    {
+        weaveDelegate();
+/*        if (validatorClass.equals(PurgedValidator.class.getName())) {
+            //purged case we do a full rescane
+            WeavingContext.getWeaver().fullClassScan();
+            Validator componentToChange = _delegate.createValidator(validatorId);
+            if (componentToChange instanceof PurgedValidator) {
+                //Null not allowed here, but we set a purted validator to make
+                //sure that we get errors on the proper level
+                _delegate.addValidator(validatorId, PurgedValidator.class.getName());
+
+            }
+            return;
+        } */
+        _delegate.addValidator(validatorId, validatorClass);
+    }
+
+    public Validator createValidator(String validatorId) throws FacesException
+    {
+        weaveDelegate();
+
+        Validator retVal = _delegate.createValidator(validatorId);
+
+        //the validators are recreated every request we do not have to deal with them on method level
+        Validator newRetVal = (Validator) reloadInstance(retVal, ARTIFACT_TYPE_VALIDATOR);
+        if (newRetVal != retVal)
+        {
+            _delegate.createValidator(validatorId);
+        }
+        return retVal;
+    }
+
+    public Iterator<String> getValidatorIds()
+    {
+        weaveDelegate();
+        return _delegate.getValidatorIds();
+    }
+
+    @SuppressWarnings("deprecation")
+    public ValueBinding createValueBinding(String s) throws ReferenceSyntaxException
+    {
+        weaveDelegate();
+        return _delegate.createValueBinding(s);
+    }
+
+
+  /*<> @Override  public void addBehavior(String behaviorId, String behaviorClass)
+    {
+        weaveDelegate();
+
+        if (behaviorClass.equals(PurgedValidator.class.getName()))
+        {
+            //purged case we do a full rescan
+            WeavingContext.getInstance().getWeaver().fullClassScan();
+            Behavior behavior = _delegate.createBehavior(behaviorId);
+            _behaviors.put(behaviorId, behaviorClass);
+            if (behavior instanceof PurgedBehavior)
+            {
+                //Null not allowed here, but we set a purged validator to make
+                //sure that we get errors on the proper level
+                _delegate.addBehavior(behaviorId, PurgedBehavior.class.getName());
+                _behaviors.remove(behaviorId);
+
+            }
+            return;
+        }
+
+        _delegate.addBehavior(behaviorId, behaviorClass);
+    } */
+
+    @Override
+    public void addDefaultValidatorId(String validatorId)
+    {
+        weaveDelegate();
+        _delegate.addDefaultValidatorId(validatorId);
+    }
+
+    @Override
+    public Behavior createBehavior(String behaviorId) throws FacesException
+    {
+        weaveDelegate();
+        Behavior retVal = _delegate.createBehavior(behaviorId);
+
+        //we might have casts here against one of the parents
+        //of this object
+        Behavior newBehavior = (Behavior) reloadInstance(retVal, ARTIFACT_TYPE_BEHAVIOR);
+        if (newBehavior != retVal)
+        {
+            return _delegate.createBehavior(behaviorId);
+        }
+
+        return retVal;
+    }
+
+    @Override
+    public UIComponent createComponent(FacesContext facesContext, Resource resource)
+    {
+        weaveDelegate();
+
+        UIComponent oldComponent = _delegate.createComponent(facesContext, resource);
+
+        /*we are reweaving on the fly because we cannot be sure if
+         * the class is not recycled all the time in the creation
+         * code, in the renderer we do it on method base
+         * due to the fact that our renderers are recycled via
+         * a flyweight pattern*/
+        UIComponent component = (UIComponent) reloadInstance(oldComponent, ARTIFACT_TYPE_COMPONENT);
+
+        //we now have to check for an annotation change, but only in case a reload has happened
+        /*<>if (component.getClass().hashCode() != oldComponent.getClass().hashCode())
+        {
+            return handleAnnotationChange(component, facesContext, resource);
+        }*/
+
+        return component;
+
+    }
+
+    @Override
+    public UIComponent createComponent(FacesContext facesContext, String componentType, String rendererType)
+    {
+        weaveDelegate();
+        UIComponent oldComponent = _delegate.createComponent(facesContext, componentType, rendererType);
+
+        /*we are reweaving on the fly because we cannot be sure if
+         * the class is not recycled all the time in the creation
+         * code, in the renderer we do it on method base
+         * due to the fact that our renderers are recycled via
+         * a flyweight pattern*/
+        UIComponent component = (UIComponent) reloadInstance(oldComponent, ARTIFACT_TYPE_COMPONENT);
+
+        //we now have to check for an annotation change, but only in case a reload has happened
+        /*<>if (component.getClass().hashCode() != oldComponent.getClass().hashCode())
+        {
+            return handleAnnotationChange(component, facesContext, componentType, rendererType);
+        } */
+
+        return component;
+    }
+
+    @Override
+    public UIComponent createComponent(ValueExpression valueExpression, FacesContext facesContext, String s, String s1)
+    {
+        weaveDelegate();
+        UIComponent oldComponent = _delegate.createComponent(valueExpression, facesContext, s, s1);
+
+        /*we are reweaving on the fly because we cannot be sure if
+     * the class is not recycled all the time in the creation
+     * code, in the renderer we do it on method base
+     * due to the fact that our renderers are recycled via
+     * a flyweight pattern*/
+        UIComponent component = (UIComponent) reloadInstance(oldComponent, ARTIFACT_TYPE_COMPONENT);
+
+        //we now have to check for an annotation change, but only in case a reload has happened
+        /*if (component.getClass().hashCode() != oldComponent.getClass().hashCode())
+        {
+            return handleAnnotationChange(component, valueExpression, facesContext, s, s1);
+        } <>*/
+
+        return component;
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public <T> T evaluateExpressionGet(FacesContext facesContext, String s, Class<? extends T> aClass) throws ELException
+    {
+        weaveDelegate();
+        //good place for a dynamic reloading check as well
+        T retVal = _delegate.evaluateExpressionGet(facesContext, s, aClass);
+        if (WeavingContext.getInstance().isDynamic(retVal.getClass()))
+            retVal = (T) WeavingContext.getInstance().reload(retVal, ARTIFACT_TYPE_MANAGEDBEAN);
+        return retVal;
+    }
+
+    @Override
+    public Iterator<String> getBehaviorIds()
+    {
+        weaveDelegate();
+        return _behaviors.keySet().iterator();
+        //return _delegate.getBehaviorIds();
+    }
+
+    @Override
+    public Map<String, String> getDefaultValidatorInfo()
+    {
+        weaveDelegate();
+        return _delegate.getDefaultValidatorInfo();
+    }
+
+    @Override
+    public ProjectStage getProjectStage()
+    {
+        weaveDelegate();
+        return _delegate.getProjectStage();
+    }
+
+    @Override
+    public ResourceHandler getResourceHandler()
+    {
+        weaveDelegate();
+        ResourceHandler retVal = _delegate.getResourceHandler();
+
+        /*if (WeavingContext.isDynamic(retVal.getClass())) {
+           ResourceHandler newHandler = (ResourceHandler) reloadInstance(retVal, ScriptingConst.ARTIFACT_TYPE_RESOURCEHANDLER);
+           if (newHandler != retVal) {
+               _delegate.setResourceHandler(newHandler);
+               return newHandler;
+           }
+       } */
+        return retVal;
+    }
+
+    @Override
+    public void publishEvent(FacesContext facesContext, Class<? extends SystemEvent> eventClass, Class<?> sourceBaseTye, Object source)
+    {
+        weaveDelegate();
+        _delegate.publishEvent(facesContext, eventClass, sourceBaseTye, source);
+    }
+
+    @Override
+    public void publishEvent(FacesContext facesContext, Class<? extends SystemEvent> eventClass, Object source)
+    {
+        weaveDelegate();
+        _delegate.publishEvent(facesContext, eventClass, source);
+    }
+
+    @Override
+    public void setResourceHandler(ResourceHandler resourceHandler)
+    {
+        weaveDelegate();
+        if (WeavingContext.getInstance().isDynamic(resourceHandler.getClass()))
+        {
+            ResourceHandler proxy = new ResourceHandlerProxy(resourceHandler);
+            resourceHandler = proxy;
+        }
+
+        _delegate.setResourceHandler(resourceHandler);
+        //ResourceHandler handler = _delegate.getResourceHandler();
+        //if (handler instanceof PurgedResourceHandler) {
+        //    WeavingContext.getWeaver().fullClassScan();
+        //}
+    }
+
+    @Override
+    public void subscribeToEvent(Class<? extends SystemEvent> eventClass, Class<?> aClass, SystemEventListener systemEventListener)
+    {
+        weaveDelegate();
+        systemEventListener = makeEventProxy(eventClass, systemEventListener);
+        _delegate.subscribeToEvent(eventClass, aClass, systemEventListener);
+    }
+
+    private SystemEventListener makeEventProxy(Class<? extends SystemEvent> eventClass, SystemEventListener systemEventListener)
+    {
+        if (WeavingContext.getInstance().isDynamic(systemEventListener.getClass()))
+        {
+            systemEventListener = new SystemEventListenerProxy(systemEventListener);
+            EventHandlerProxyEntry entry = new EventHandlerProxyEntry(eventClass, (Decorated) systemEventListener);
+            _eventHandlerIdx.put(entry, entry);
+        }
+        return systemEventListener;
+    }
+
+    @Override
+    public void subscribeToEvent(Class<? extends SystemEvent> eventClass, SystemEventListener systemEventListener)
+    {
+        weaveDelegate();
+        systemEventListener = makeEventProxy(eventClass, systemEventListener);
+        _delegate.subscribeToEvent(eventClass, systemEventListener);
+    }
+
+    @Override
+    public void unsubscribeFromEvent(Class<? extends SystemEvent> eventClass, Class<?> aClass, SystemEventListener systemEventListener)
+    {
+        weaveDelegate();
+        systemEventListener = resolveEventProxy(eventClass, systemEventListener);
+        _delegate.unsubscribeFromEvent(eventClass, aClass, systemEventListener);
+    }
+
+    private SystemEventListener resolveEventProxy(Class<? extends SystemEvent> eventClass, SystemEventListener systemEventListener)
+    {
+        if (WeavingContext.getInstance().isDynamic(systemEventListener.getClass()))
+        {
+            systemEventListener = new SystemEventListenerProxy(systemEventListener);
+            EventHandlerProxyEntry entry = new EventHandlerProxyEntry(eventClass, (Decorated) systemEventListener);
+            entry = _eventHandlerIdx.remove(entry);
+            if (entry != null)
+            {
+                systemEventListener = (SystemEventListener) entry.getProxy().getDelegate();
+            }
+        }
+        return systemEventListener;
+    }
+
+    @Override
+    public void unsubscribeFromEvent(Class<? extends SystemEvent> eventClass, SystemEventListener systemEventListener)
+    {
+        weaveDelegate();
+        systemEventListener = resolveEventProxy(eventClass, systemEventListener);
+        _delegate.unsubscribeFromEvent(eventClass, systemEventListener);
+    }
+
+    public Object getDelegate()
+    {
+        return _delegate;
+    }
+
+    private Object reloadInstance(Object instance, int artifactType)
+    {
+        if (instance == null)
+        {
+            return null;
+        }
+        if (WeavingContext.getInstance().isDynamic(instance.getClass()))
+        {
+            instance = WeavingContext.getInstance().reload(instance, artifactType);
+        }
+        return instance;
+    }
+
+   /* private boolean alreadyWovenInRequest(String clazz)
+    {
+        //portlets now can be enabled thanks to the jsf2 indirections regarding the external context
+        Map<String, Object> req = WeavingContext.getRequestMap();
+        if (req.get(SCRIPTING_REQUSINGLETON + clazz) == null)
+        {
+            req.put(SCRIPTING_REQUSINGLETON + clazz, "");
+            return false;
+        }
+        return true;
+    }*/
+
+   /*<> private UIComponent handleAnnotationChange(UIComponent oldComponent, ValueExpression valueExpression,
+                                                FacesContext facesContext, String componentType)
+    {
+        UIComponent componentToChange = _delegate.createComponent(valueExpression, facesContext, componentType);
+        if (componentToChange instanceof PurgedComponent)
+        {
+            WeavingContext.getWeaver().fullClassScan();
+            //via an additional create component we can check whether a purged component
+            //was registered after the reload because the annotation has been removed
+            componentToChange = _delegate.createComponent(valueExpression, facesContext, componentType);
+
+            return componentToChange;
+        }
+        return oldComponent;
+    }  */
+
+  /*<>  private UIComponent handleAnnotationChange(UIComponent oldComponent, String componentType)
+    {
+        UIComponent componentToChange = _delegate.createComponent(componentType);
+        if (componentToChange instanceof PurgedComponent)
+        {
+            WeavingContext.getWeaver().fullClassScan();
+            //via an additional create component we can check whether a purged component
+            //was registered after the reload because the annotation has been removed
+            componentToChange = _delegate.createComponent(componentType);
+
+            return componentToChange;
+        }
+        return oldComponent;
+    }*/
+
+
+   /*<>@SuppressWarnings("deprecation") private UIComponent handleAnnotationChange(UIComponent oldComponent, ValueBinding valueBinding,
+                                                FacesContext context, String componentType)
+    {
+        UIComponent componentToChange = _delegate.createComponent(valueBinding, context, componentType);
+        if (componentToChange instanceof PurgedComponent)
+        {
+            WeavingContext.getWeaver().fullClassScan();
+            //via an additional create component we can check whether a purged component
+            //was registered after the reload because the annotation has been removed
+            componentToChange = _delegate.createComponent(valueBinding, context, componentType);
+
+            return componentToChange;
+        }
+        return oldComponent;
+    } */
+
+   /*<> private UIComponent handleAnnotationChange(UIComponent oldComponent, FacesContext context, Resource resource)
+    {
+        UIComponent componentToChange = _delegate.createComponent(context, resource);
+        if (componentToChange instanceof PurgedComponent)
+        {
+            WeavingContext.getWeaver().fullClassScan();
+            //via an additional create component we can check whether a purged component
+            //was registered after the reload because the annotation has been removed
+            componentToChange = _delegate.createComponent(context, resource);
+
+            return componentToChange;
+        }
+        return oldComponent;
+    }
+
+    private UIComponent handleAnnotationChange(UIComponent oldComponent, FacesContext context, String componentType, String rendererType)
+    {
+        UIComponent componentToChange = _delegate.createComponent(context, componentType, rendererType);
+        if (componentToChange instanceof PurgedComponent)
+        {
+            WeavingContext.getWeaver().fullClassScan();
+            //via an additional create component we can check whether a purged component
+            //was registered after the reload because the annotation has been removed
+            componentToChange = _delegate.createComponent(context, componentType, rendererType);
+
+            return componentToChange;
+        }
+        return oldComponent;
+    }
+
+    private UIComponent handleAnnotationChange(UIComponent oldComponent, ValueExpression valueExpression, FacesContext facesContext, String s, String s1)
+    {
+        UIComponent componentToChange = _delegate.createComponent(valueExpression, facesContext, s, s1);
+        if (componentToChange instanceof PurgedComponent)
+        {
+            WeavingContext.getWeaver().fullClassScan();
+
+            //via an additional create component we can check whether a purged component
+            //was registered after the reload because the annotation has been removed
+
+            componentToChange = _delegate.createComponent(valueExpression, facesContext, s, s1);
+
+            return componentToChange;
+        }
+        return oldComponent;
+    } */
+
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/ELResolverProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/ELResolverProxy.java?rev=1300598&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/ELResolverProxy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/ELResolverProxy.java Wed Mar 14 15:46:00 2012
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implementations;
+
+
+import org.apache.myfaces.extensions.scripting.core.api.Decorated;
+import org.apache.myfaces.extensions.scripting.core.api.ScriptingConst;
+import org.apache.myfaces.extensions.scripting.core.api.WeavingContext;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.faces.context.FacesContext;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.util.Iterator;
+import java.util.logging.Logger;
+
+/**
+ * EL Resolver which is scripting enabled
+ *
+ * @author Werner Punz
+ *
+ * TODO not needed anymore because we drop the beans at request start directly which are tainted...
+ * they get reloaded because they are dropped entirely from the scope
+ * 
+ * The compile and load happens on classloader level
+ * @deprecated
+ */
+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 {
+
+        Object retVal = _delegate.getValue(elContext, base, property);
+
+      /*  Object newRetVal;
+        if (retVal != null && WeavingContext.getInstance().isDynamic(retVal.getClass())) {
+
+            newRetVal = WeavingContext.getInstance().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 {
+        Class<?> retVal = _delegate.getType(elContext, o, o1);
+        if (retVal != null && WeavingContext.getInstance().isDynamic(retVal)) {
+            return WeavingContext.getInstance().reload(retVal);
+        }
+        return retVal;
+    }
+
+    public void setValue(ELContext elContext, Object base, Object property, Object value) throws NullPointerException, ELException {
+        //now to more complex relations...
+        //TODO add dependency
+        if (base != null && WeavingContext.getInstance().isDynamic(base.getClass()) && WeavingContext.getInstance().isDynamic(value.getClass())) {
+            WeavingContext.getInstance().addDependency(ScriptingConst.ENGINE_TYPE_JSF_ALL, base.getClass().getName(),
+                    value.getClass().getName());
+        }
+        _delegate.setValue(elContext, base, property, value);
+    }
+
+    public boolean isReadOnly(ELContext elContext, Object o, Object o1) throws NullPointerException, ELException {
+        return _delegate.isReadOnly(elContext, o, o1);
+    }
+
+    public Iterator getFeatureDescriptors(ELContext elContext, Object o) {
+        return _delegate.getFeatureDescriptors(elContext, o);
+    }
+
+    public Class<?> getCommonPropertyType(ELContext elContext, Object o) {
+        return _delegate.getCommonPropertyType(elContext, o);
+    }
+
+
+    public ELResolverProxy() {
+        _delegate = FacesContext.getCurrentInstance().getELContext().getELResolver();
+    }
+
+    public ELResolverProxy(ELResolver delegate) {
+        _delegate = delegate;
+    }
+
+    public Object getDelegate() {
+        return _delegate;
+    }
+
+
+   private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
+   {
+     // our "pseudo-constructor"
+     in.defaultReadObject();
+     log = Logger.getLogger(ELResolverProxy.class.getName());
+
+   }
+
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/FacesContextProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/FacesContextProxy.java?rev=1300598&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/FacesContextProxy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/FacesContextProxy.java Wed Mar 14 15:46:00 2012
@@ -0,0 +1,221 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implementations;
+
+
+import org.apache.myfaces.extensions.scripting.core.api.Decorated;
+import org.apache.myfaces.extensions.scripting.core.api.ScriptingConst;
+import org.apache.myfaces.extensions.scripting.core.api.WeavingContext;
+
+import javax.el.ELContext;
+import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
+import javax.faces.application.ProjectStage;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.*;
+import javax.faces.event.PhaseId;
+import javax.faces.render.RenderKit;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A reloading, weaving  faces context
+ * this is needed because groovy fails on
+ * the introspection of the standard java myfaces
+ * faces context due to pending references
+ * of the _impl into the portlet context
+ * not sure if this works in portlets
+ * though
+ *
+ * @author Werner Punz
+ */
+public class FacesContextProxy extends FacesContext implements Decorated
+{
+
+    public FacesContext _delegate = null;
+
+    private void weaveDelegate() {
+        //in case of a context destroyed the weaver might be accessed a last time
+        //but is already null due to having no weaver in the shutdown thread
+        if (_delegate != null && WeavingContext.getInstance().isScriptingEnabled())
+            _delegate = (FacesContext) WeavingContext.getInstance().reload(_delegate,
+                    ScriptingConst.ARTIFACT_TYPE_FACESCONTEXT);
+    }
+
+    public ELContext getELContext() {
+        return _delegate.getELContext();
+    }
+
+    public Application getApplication() {
+        return _delegate.getApplication();
+    }
+
+    public Iterator<String> getClientIdsWithMessages() {
+        return _delegate.getClientIdsWithMessages();
+    }
+
+    public ExternalContext getExternalContext() {
+        return _delegate.getExternalContext();
+    }
+
+    public FacesMessage.Severity getMaximumSeverity() {
+        return _delegate.getMaximumSeverity();
+    }
+
+    public Iterator<FacesMessage> getMessages() {
+        return _delegate.getMessages();
+    }
+
+    public Iterator<FacesMessage> getMessages(String s) {
+        return _delegate.getMessages(s);
+    }
+
+    public RenderKit getRenderKit() {
+        return _delegate.getRenderKit();
+    }
+
+    public boolean getRenderResponse() {
+        return _delegate.getRenderResponse();
+    }
+
+    public boolean getResponseComplete() {
+        return _delegate.getResponseComplete();
+    }
+
+    public ResponseStream getResponseStream() {
+        return _delegate.getResponseStream();
+    }
+
+    public void setResponseStream(ResponseStream responseStream) {
+        _delegate.setResponseStream(responseStream);
+    }
+
+    public ResponseWriter getResponseWriter() {
+        return _delegate.getResponseWriter();
+    }
+
+    public void setResponseWriter(ResponseWriter responseWriter) {
+        _delegate.setResponseWriter(responseWriter);
+    }
+
+    public UIViewRoot getViewRoot() {
+        return _delegate.getViewRoot();
+    }
+
+    public void setViewRoot(UIViewRoot uiViewRoot) {
+        weaveDelegate();//perfect place no matter what the viewRoot is about once per request set
+        _delegate.setViewRoot(uiViewRoot);
+    }
+
+    public void addMessage(String s, FacesMessage facesMessage) {
+        _delegate.addMessage(s, facesMessage);
+    }
+
+    public void release() {
+        _delegate.release();
+    }
+
+    public void renderResponse() {
+        _delegate.renderResponse();
+    }
+
+    public void responseComplete() {
+        _delegate.responseComplete();
+    }
+
+    public FacesContextProxy(FacesContext delegate) {
+        _delegate = delegate;
+        weaveDelegate();
+    }
+
+    @Override
+    public Map<Object, Object> getAttributes() {
+        return _delegate.getAttributes();
+    }
+
+    @Override
+    public PhaseId getCurrentPhaseId() {
+        return _delegate.getCurrentPhaseId();
+    }
+
+    @Override
+    public ExceptionHandler getExceptionHandler() {
+        return _delegate.getExceptionHandler();
+    }
+
+    @Override
+    public List<FacesMessage> getMessageList() {
+        return _delegate.getMessageList();
+    }
+
+    @Override
+    public List<FacesMessage> getMessageList(String s) {
+        return _delegate.getMessageList(s);
+    }
+
+    @Override
+    public PartialViewContext getPartialViewContext() {
+        return _delegate.getPartialViewContext();
+    }
+
+    @Override
+    public boolean isValidationFailed() {
+        return _delegate.isValidationFailed();
+    }
+
+    @Override
+    public boolean isPostback() {
+        return _delegate.isPostback();
+    }
+
+    @Override
+    public boolean isProcessingEvents() {
+        return _delegate.isProcessingEvents();
+    }
+
+    @Override
+    public void setCurrentPhaseId(PhaseId phaseId) {
+        _delegate.setCurrentPhaseId(phaseId);
+    }
+
+    @Override
+    public void setExceptionHandler(ExceptionHandler exceptionHandler) {
+        _delegate.setExceptionHandler(exceptionHandler);
+    }
+
+    @Override
+    public void setProcessingEvents(boolean b) {
+        _delegate.setProcessingEvents(b);
+    }
+
+    @Override
+    public void validationFailed() {
+        _delegate.validationFailed();
+    }
+
+    @Override
+    public boolean isProjectStage(ProjectStage projectStage) {
+        return _delegate.isProjectStage(projectStage);
+    }
+
+    public Object getDelegate() {
+        return _delegate;
+    }
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/LifefcycleProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/LifefcycleProxy.java?rev=1300598&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/LifefcycleProxy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/LifefcycleProxy.java Wed Mar 14 15:46:00 2012
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implementations;
+
+
+import org.apache.myfaces.extensions.scripting.core.api.Decorated;
+import org.apache.myfaces.extensions.scripting.core.api.ScriptingConst;
+import org.apache.myfaces.extensions.scripting.core.api.WeavingContext;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseListener;
+import javax.faces.lifecycle.Lifecycle;
+
+/**
+ * Scripting enabled lifecycle
+ *
+ * @author Werner Punz
+ */
+public class LifefcycleProxy extends Lifecycle implements Decorated
+{
+
+    Lifecycle _delegate = null;
+
+    private void weaveDelegate() {
+        if (_delegate != null)
+            _delegate = (Lifecycle) WeavingContext.getInstance().reload(_delegate,
+                    ScriptingConst.ARTIFACT_TYPE_LIFECYCLE);
+    }
+
+    public LifefcycleProxy(Lifecycle delegate) {
+        _delegate = delegate;
+    }
+
+    public void addPhaseListener(PhaseListener phaseListener) {
+        weaveDelegate();
+        /*we can put our object weaving code into the add here*/
+        if (WeavingContext.getInstance().isDynamic(phaseListener.getClass()))
+            phaseListener = (PhaseListener) WeavingContext.getInstance().createMethodReloadingProxyFromObject(phaseListener,
+                PhaseListener.class, ScriptingConst.ARTIFACT_TYPE_PHASELISTENER);
+
+        _delegate.addPhaseListener(phaseListener);
+    }
+
+    public void execute(FacesContext facesContext) throws FacesException {
+        weaveDelegate();
+        _delegate.execute(facesContext);
+    }
+
+    public PhaseListener[] getPhaseListeners() {
+        weaveDelegate();
+        return _delegate.getPhaseListeners();
+    }
+
+    public void removePhaseListener(PhaseListener phaseListener) {
+        weaveDelegate();
+        _delegate.removePhaseListener(phaseListener);
+    }
+
+    public void render(FacesContext facesContext) throws FacesException {
+        weaveDelegate();
+        _delegate.render(facesContext);
+    }
+
+    public Object getDelegate() {
+        return _delegate;
+    }
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/NavigationHandlerProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/NavigationHandlerProxy.java?rev=1300598&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/NavigationHandlerProxy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/NavigationHandlerProxy.java Wed Mar 14 15:46:00 2012
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implementations;
+
+import org.apache.myfaces.extensions.scripting.core.api.Decorated;
+import org.apache.myfaces.extensions.scripting.core.api.ScriptingConst;
+import org.apache.myfaces.extensions.scripting.core.api.WeavingContext;
+
+import javax.faces.application.NavigationHandler;
+import javax.faces.context.FacesContext;
+
+/**
+ * A reloading navigation handler
+ *
+ * @author Werner Punz
+ */
+public class NavigationHandlerProxy extends NavigationHandler implements Decorated
+{
+
+    NavigationHandler _delegate;
+
+    private void weaveDelegate() {
+        _delegate = (NavigationHandler) WeavingContext.getInstance().reload(_delegate,
+                ScriptingConst.ARTIFACT_TYPE_NAVIGATIONHANDLER);
+    }
+
+    public NavigationHandlerProxy(NavigationHandler delegate) {
+        super();
+        _delegate = delegate;
+    }
+
+    public void handleNavigation(FacesContext facesContext, String s, String s1) {
+        weaveDelegate();
+        _delegate.handleNavigation(facesContext, s, s1);
+    }
+
+    public Object getDelegate() {
+        return _delegate;
+    }
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/RenderkitProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/RenderkitProxy.java?rev=1300598&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/RenderkitProxy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/RenderkitProxy.java Wed Mar 14 15:46:00 2012
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implementations;
+
+
+import org.apache.myfaces.extensions.scripting.core.api.Decorated;
+import org.apache.myfaces.extensions.scripting.core.api.ScriptingConst;
+import org.apache.myfaces.extensions.scripting.core.api.WeavingContext;
+
+import javax.faces.context.ResponseStream;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.ClientBehaviorRenderer;
+import javax.faces.render.RenderKit;
+import javax.faces.render.Renderer;
+import javax.faces.render.ResponseStateManager;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.Iterator;
+
+/**
+ * Weaving renderkit which
+ * acts as a proxy factory for
+ * our internal reloading referers
+ *
+ * @author Werner Punz
+ */
+public class    RenderkitProxy extends RenderKit implements Decorated
+{
+
+    RenderKit _delegate = null;
+
+    public RenderkitProxy(RenderKit delegate) {
+        _delegate = delegate;
+    }
+
+    public void addRenderer(String componentFamily, String rendererType, Renderer renderer) {
+        weaveDelegate();
+        //wo do it brute force here because we have sometimes casts and hence cannot rely on proxies
+        //renderers itself are flyweight patterns which means they are shared over objects
+
+        renderer = (Renderer) reloadInstance(renderer, ScriptingConst.ARTIFACT_TYPE_RENDERER);
+
+        _delegate.addRenderer(componentFamily, rendererType, renderer);
+    }
+
+    public Renderer getRenderer(String componentFamily, String rendererType) {
+        weaveDelegate();
+        Renderer rendr = _delegate.getRenderer(componentFamily, rendererType);
+        Renderer rendr2 = (Renderer) reloadInstance(rendr, ScriptingConst.ARTIFACT_TYPE_RENDERER);
+        if (rendr != rendr2) {
+            Renderer tempRenderer = _delegate.getRenderer(componentFamily, rendererType);
+            /**<></>if (tempRenderer instanceof PurgedRenderer) {
+                return handleAnnotationChange(componentFamily, rendererType);
+            } */
+
+            _delegate.addRenderer(componentFamily, rendererType, rendr2);
+            return rendr2;
+        }
+        return rendr;
+    }
+
+    private ClientBehaviorRenderer handleAnnotationChangeBehaviorRenderer(String s) {
+        ClientBehaviorRenderer rendr2;
+
+        rendr2 = _delegate.getClientBehaviorRenderer(s);
+        /*<>if (rendr2 instanceof PurgedClientBehaviorRenderer) {
+            throw new FacesException("Renderer not found");
+        } */
+        rendr2 = _delegate.getClientBehaviorRenderer(s);
+        return rendr2;
+    }
+
+    private Renderer handleAnnotationChange(String s, String s1) {
+        Renderer rendr2;
+
+        //WeavingContext.getWeaver().fullClassScan();
+        rendr2 = _delegate.getRenderer(s, s1);
+        /*<>if (rendr2 instanceof PurgedRenderer) {
+            throw new FacesException("Renderer not found");
+        }*/
+        rendr2 = _delegate.getRenderer(s, s1);
+        return rendr2;
+    }
+
+    public ResponseStateManager getResponseStateManager() {
+        weaveDelegate();
+        return _delegate.getResponseStateManager();
+    }
+
+    public ResponseWriter createResponseWriter(Writer writer, String s, String s1) {
+        weaveDelegate();
+        return (ResponseWriter) reloadInstance(_delegate.createResponseWriter(writer, s, s1), ScriptingConst.ARTIFACT_TYPE_RESPONSEWRITER);
+    }
+
+    public ResponseStream createResponseStream(OutputStream outputStream) {
+        weaveDelegate();
+        return (ResponseStream) reloadInstance(_delegate.createResponseStream(outputStream), ScriptingConst.ARTIFACT_TYPE_RESPONSESTREAM);
+    }
+
+    @Override
+    public void addClientBehaviorRenderer(String s, ClientBehaviorRenderer renderer) {
+
+        weaveDelegate();
+        renderer = (ClientBehaviorRenderer) reloadInstance(renderer, ScriptingConst.ARTIFACT_TYPE_CLIENTBEHAVIORRENDERER);
+        _delegate.addClientBehaviorRenderer(s, renderer);
+    }
+
+    @Override
+    public ClientBehaviorRenderer getClientBehaviorRenderer(String s) {
+        weaveDelegate();
+        ClientBehaviorRenderer rendr = _delegate.getClientBehaviorRenderer(s);
+        ClientBehaviorRenderer rendr2 = (ClientBehaviorRenderer) reloadInstance(rendr, ScriptingConst.ARTIFACT_TYPE_CLIENTBEHAVIORRENDERER);
+        if (rendr != rendr2) {
+
+            rendr2 = _delegate.getClientBehaviorRenderer(s);
+            /*<>if (rendr2 instanceof PurgedClientBehaviorRenderer) {
+                return handleAnnotationChangeBehaviorRenderer(s);
+            }*/
+            return rendr2;
+        }
+        return rendr;
+    }
+
+    @Override
+    public Iterator<String> getClientBehaviorRendererTypes() {
+        weaveDelegate();
+        return _delegate.getClientBehaviorRendererTypes();
+    }
+
+    @Override
+    public Iterator<String> getComponentFamilies() {
+        weaveDelegate();
+        return _delegate.getComponentFamilies();
+    }
+
+    @Override
+    public Iterator<String> getRendererTypes(String s) {
+        weaveDelegate();
+        return _delegate.getRendererTypes(s);
+    }
+
+    public Object getDelegate() {
+        return _delegate;
+    }
+
+    private void weaveDelegate() {
+        _delegate = (RenderKit) WeavingContext.getInstance().reload(_delegate, ScriptingConst.ARTIFACT_TYPE_RENDERKIT);
+    }
+
+    private Object reloadInstance(Object instance, int artefactType) {
+        if (instance == null) {
+            return null;
+        }
+        if (WeavingContext.getInstance().isDynamic(instance.getClass()) ) {
+            instance = WeavingContext.getInstance().reload(instance, artefactType);
+            //now the add should be done properly if possible
+        }
+        return instance;
+    }
+
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/ResourceHandlerProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/ResourceHandlerProxy.java?rev=1300598&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/ResourceHandlerProxy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/ResourceHandlerProxy.java Wed Mar 14 15:46:00 2012
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implementations;
+
+
+import org.apache.myfaces.extensions.scripting.core.api.ScriptingConst;
+import org.apache.myfaces.extensions.scripting.core.api.WeavingContext;
+
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ *
+ * Problem the resource request is issued on servlet level before
+ * our compile triggers can trigger from the phase listener
+ * this is evil
+ *
+ * We probably have to reissue the compile from the resource handler
+ * directly upfront :-( or mark the resource handler as something like double tainted!
+ *
+ * This problem will resolve itself with async compile
+ *
+ */
+
+public class ResourceHandlerProxy extends ResourceHandler {
+    private ResourceHandler _delegate;
+
+    public ResourceHandlerProxy(ResourceHandler delegate) {
+        _delegate = delegate;
+    }
+
+    public Resource createResource(String resourceName) {
+        weaveDelegate();
+        return _delegate.createResource(resourceName);
+    }
+
+    public Resource createResource(String resourceName, String libraryName) {
+        weaveDelegate();
+        return _delegate.createResource(resourceName, libraryName);
+    }
+
+    public Resource createResource(String resourceName, String libraryName, String contentType) {
+        weaveDelegate();
+        return _delegate.createResource(resourceName, libraryName, contentType);
+    }
+
+    public String getRendererTypeForResourceName(String resourceName) {
+        weaveDelegate();
+        return _delegate.getRendererTypeForResourceName(resourceName);
+    }
+
+    public void handleResourceRequest(FacesContext context) throws java.io.IOException {
+        weaveDelegate();
+        _delegate.handleResourceRequest(context);
+    }
+    
+    public boolean isResourceRequest(FacesContext context) {
+        weaveDelegate();
+        return _delegate.isResourceRequest(context);
+    }
+
+    public boolean libraryExists(String libraryName) {
+        weaveDelegate();
+        return _delegate.libraryExists(libraryName);
+    }
+
+    private final void weaveDelegate() {
+        _delegate = (ResourceHandler) WeavingContext.getInstance().reload(_delegate,
+                ScriptingConst.ARTIFACT_TYPE_RESOURCEHANDLER);
+    }
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/SystemEventListenerProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/SystemEventListenerProxy.java?rev=1300598&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/SystemEventListenerProxy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicDecorators/implementations/SystemEventListenerProxy.java Wed Mar 14 15:46:00 2012
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implementations;
+
+
+import org.apache.myfaces.extensions.scripting.core.api.Decorated;
+import org.apache.myfaces.extensions.scripting.core.api.ScriptingConst;
+import org.apache.myfaces.extensions.scripting.core.api.WeavingContext;
+
+import javax.faces.event.SystemEvent;
+import javax.faces.event.SystemEventListener;
+
+/**
+ * a method level reloading proxy class
+ * we do not use auto proxies here because
+ * this class needs special treatment
+ * over our decorated interface
+ *
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+public class SystemEventListenerProxy implements Decorated, SystemEventListener {
+
+    SystemEventListener _delegate;
+
+    public SystemEventListenerProxy(SystemEventListener delegate) {
+        _delegate = delegate;
+    }
+
+    public boolean isListenerForSource(Object source) {
+        weaveDelegate();
+        return _delegate.isListenerForSource(source);
+    }
+
+    public void processEvent(SystemEvent event) {
+        weaveDelegate();
+        _delegate.processEvent(event);
+    }
+
+    @Override
+    public Object getDelegate() {
+        return _delegate;
+    }
+
+    private void weaveDelegate() {
+        //TODO (1.1) add a speed optimization here by pushing something in the request map
+        if (_delegate != null) {
+            _delegate = (SystemEventListener) WeavingContext.getInstance().reload(_delegate,
+                    ScriptingConst.ARTIFACT_TYPE_SYSTEMEVENTLISTENER);
+        }
+    }
+}