https://issues.apache.org/jira/browse/EXTSCRIPT-130




git-svn-id: https://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk@944467 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java
index e66cd50..409f09b 100644
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java
+++ b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java
@@ -653,10 +653,14 @@
     public ResourceHandler getResourceHandler() {
         weaveDelegate();
         ResourceHandler retVal = _delegate.getResourceHandler();
-        ResourceHandler newHandler = (ResourceHandler) reloadInstance(retVal, ScriptingConst.ARTIFACT_TYPE_RESOURCEHANDLER);
-        if (newHandler != retVal) {
-            return _delegate.getResourceHandler();
+        if(WeavingContext.isDynamic(retVal.getClass())) {
+            return new ResourceHandlerProxy(retVal);
         }
+
+        //ResourceHandler newHandler = (ResourceHandler) reloadInstance(retVal, ScriptingConst.ARTIFACT_TYPE_RESOURCEHANDLER);
+        //if (newHandler != retVal) {
+        //    return _delegate.getResourceHandler();
+        //}
         return retVal;
     }
 
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/BeanImplementationListener.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/BeanImplementationListener.java
index 364f259..cb610cf 100644
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/BeanImplementationListener.java
+++ b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/BeanImplementationListener.java
@@ -89,10 +89,13 @@
             scope = "session";
         } else if (clazz.isAnnotationPresent(ApplicationScoped.class)) {
             scope = "application";
+        } else if (clazz.isAnnotationPresent(ViewScoped.class)) {
+            scope = "view";    
         } else if (clazz.isAnnotationPresent(NoneScoped.class)) {
             scope = "none";
         } else if (clazz.isAnnotationPresent(CustomScoped.class)) {
-            scope = "custom";
+            CustomScoped customScoped = (CustomScoped) clazz.getAnnotation(CustomScoped.class);
+            scope = (customScoped != null) ? customScoped.value() : "custom";
         }
         mbean.setScope(scope);
     }
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/resources/META-INF/faces-config.xml b/extscript-core-root/extscript-myfaces2-extensions/src/main/resources/META-INF/faces-config.xml
index ea514b2..b740f34 100644
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/resources/META-INF/faces-config.xml
+++ b/extscript-core-root/extscript-myfaces2-extensions/src/main/resources/META-INF/faces-config.xml
@@ -77,12 +77,7 @@
 
     </factory>
 
-    <application>
-         <resource-handler>
-            org.apache.myfaces.extensions.scripting.jsf2.resources.SourceResourceHandler
-        </resource-handler>
-    </application>
-
+ 
     <!--
     <application>
         <system-event-listener>
diff --git a/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/faces-config.xml b/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/faces-config.xml
index fd13464..b6f103a 100644
--- a/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/faces-config.xml
+++ b/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/faces-config.xml
@@ -122,5 +122,8 @@
             <system-event-listener-class>org.apache.myfaces.javaloader.eventTest.TestListener</system-event-listener-class>
             <system-event-class>javax.faces.event.PreRenderViewEvent</system-event-class>
         </system-event-listener>
+        <!--
+        <resource-handler>org.apache.myfaces.groovyloader.test.TestResourceHandler</resource-handler>
+        -->
     </application>
 </faces-config>
\ No newline at end of file
diff --git a/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/groovy/org/apache/myfaces/groovyloader/test/TestResourceHandler.groovy b/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/groovy/org/apache/myfaces/groovyloader/test/TestResourceHandler.groovy
new file mode 100644
index 0000000..888759c
--- /dev/null
+++ b/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/groovy/org/apache/myfaces/groovyloader/test/TestResourceHandler.groovy
@@ -0,0 +1,61 @@
+package org.apache.myfaces.groovyloader.test
+
+import javax.faces.application.ResourceHandler
+
+import javax.faces.context.FacesContext
+import javax.faces.application.Resource
+/**
+ *
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class TestResourceHandler extends ResourceHandler {
+
+    TestResourceHandler _delegate
+
+    public TestResourceHandler(delegate) {
+        _delegate = delegate;
+    }
+
+    public TestResourceHandler() {
+        super();    //To change body of overridden methods use File | Settings | File Templates.
+    }
+
+    public Resource createResource(String resourceName) {
+        return _delegate.createResource(resourceName)
+    }
+
+    public Resource createResource(String resourceName, String libraryName) {
+        return _delegate.createResource(resourceName, libraryName)
+    }
+
+    public Resource createResource(String resourceName, String libraryName, String contentType) {
+        return _delegate.createResource(resourceName, libraryName, contentType)
+    }
+
+    public String getRendererTypeForResourceName(String resourceName) {
+        return _delegate.getRendererTypeForResourceName(resourceName)
+    }
+
+    public void handleResourceRequest(FacesContext context) throws IOException {
+        System.out.println("cggsfdlkghfsdkjlghkjfgds")
+        _delegate.handleResourceRequest(context)
+    }
+
+    public boolean isResourceRequest(FacesContext context) {
+        return _delegate.isResourceRequest(context)
+    }
+
+    public boolean libraryExists(String libraryName) {
+        return _delegate.libraryExists(libraryName)
+
+    }
+
+    public TestResourceHandler getDelegate() {
+        return _delegate
+    }
+
+    public void setDelegate(TestResourceHandler delegate) {
+        _delegate = delegate
+    }
+}
\ No newline at end of file
diff --git a/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/test/ViewScopedBean.java b/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/test/ViewScopedBean.java
new file mode 100644
index 0000000..1d28aed
--- /dev/null
+++ b/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/test/ViewScopedBean.java
@@ -0,0 +1,74 @@
+/*
+ * 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.javaloader.test;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ViewScoped;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+import java.util.logging.Logger;
+
+/**
+ * Testing case for a view scoped bean 
+ *
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+@ManagedBean
+@ViewScoped
+public class ViewScopedBean implements Serializable {
+
+    int cnt = 0;
+    String helloWorld = "hello world from my view scoped bean";
+    transient Logger _logger = Logger.getLogger(ViewScopedBean.class.getName());
+
+    public ViewScopedBean() {
+        cnt = 0;
+        _logger.info("Init bean");
+    }
+
+    public int getCnt() {
+        return cnt;
+    }
+
+    public void setCnt(int cnt) {
+        this.cnt = cnt;
+    }
+
+    public String getHelloWorld() {
+        return helloWorld + (cnt++);
+    }
+
+    public void setHelloWorld(String helloWorld) {
+        this.helloWorld = helloWorld;
+    }
+
+    private void readObject(ObjectInputStream ois) throws Exception {
+        _logger = Logger.getLogger(ViewScopedBean.class.getName());
+        _logger.info("Restoring bean which was savestated");
+        ois.defaultReadObject();
+    }
+
+    public String doAction() {
+        return null;
+    }
+
+}
diff --git a/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/sun-web.xml b/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/sun-web.xml
new file mode 100644
index 0000000..65f9b95
--- /dev/null
+++ b/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/sun-web.xml
@@ -0,0 +1,5 @@
+<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd">
+<sun-web-app >
+<class-loader delegate="false"/>
+<property name="useMyFaces" value="true"/>
+</sun-web-app>
\ No newline at end of file
diff --git a/extscript-examples/myfaces20-example/src/main/webapp/template.xhtml b/extscript-examples/myfaces20-example/src/main/webapp/template.xhtml
index a5c9708..d3dacb0 100644
--- a/extscript-examples/myfaces20-example/src/main/webapp/template.xhtml
+++ b/extscript-examples/myfaces20-example/src/main/webapp/template.xhtml
@@ -21,7 +21,6 @@
             <h:outputLink value="./javablog.jsf">Java Blogging Example</h:outputLink>
             <h:outputLink value="./componentTest.jsf">Component Testcase</h:outputLink>
             <h:outputLink value="./compilerWindow.jsf" target="_blank">Compiler Output</h:outputLink>
-
         </h:panelGroup>
     </div>
 
diff --git a/extscript-examples/myfaces20-example/src/main/webapp/viewscopeTest.xhtml b/extscript-examples/myfaces20-example/src/main/webapp/viewscopeTest.xhtml
new file mode 100644
index 0000000..2c9bc83
--- /dev/null
+++ b/extscript-examples/myfaces20-example/src/main/webapp/viewscopeTest.xhtml
@@ -0,0 +1,22 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
+      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:grv="http://myfaces.apache.org/groovy">
+<h:head>
+    <title>Hello World 2</title>
+</h:head>
+<h:body>
+    <ui:composition template="/template.xhtml">
+        <ui:define name="body">
+            <h1 style="color: yellow;">
+                This is a test case for the MyFaces view scope
+            </h1>
+            <h:form>
+                <h:outputText value="#{viewScopedBean.helloWorld}"/>
+                <h:commandLink action="#{viewScopedBean.doAction}" value="Press me for refresh"/>
+            </h:form>
+        </ui:define>
+    </ui:composition>
+</h:body>
+</html>
\ No newline at end of file
diff --git a/extscript-examples/pom.xml b/extscript-examples/pom.xml
index 603d0e8..e30c5ae 100644
--- a/extscript-examples/pom.xml
+++ b/extscript-examples/pom.xml
@@ -19,12 +19,15 @@
     </parent>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk/extscript-examples</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk/extscript-examples</developerConnection>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk/extscript-examples
+        </connection>
+        <developerConnection>
+            scm:svn:https://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk/extscript-examples
+        </developerConnection>
         <url>http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-examples</url>
     </scm>
 
-    
+
     <build>
         <plugins>
             <plugin>
@@ -41,6 +44,14 @@
                     <scanIntervalSeconds>1</scanIntervalSeconds>
                 </configuration>
             </plugin>
+            <!-- tomcat plugin as alternative testing ground -->
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>tomcat-maven-plugin</artifactId>
+                <version>1.0</version>
+            </plugin>
+          
+
         </plugins>
     </build>
     <modules>
@@ -49,8 +60,6 @@
         <module>spring-example</module>
     </modules>
 
-    
-
 
     <profiles>
         <!--
@@ -64,6 +73,6 @@
                 <maven.war.webxml>${basedir}/src/main/conf/dev/web.xml</maven.war.webxml>
             </properties>
         </profile>
-    </profiles>    
+    </profiles>
 
 </project>
diff --git a/pom.xml b/pom.xml
index ab678cb..0096ffa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,6 +55,12 @@
             <id>maven2-repository.dev.java.net</id>
             <name>Java.net Repository for Maven</name>
             <url>http://download.java.net/maven/2/</url>
+             <releases>
+                <enabled>true</enabled>
+            </releases>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
             <layout>default</layout>
         </repository>
         <repository>
@@ -65,6 +71,7 @@
             <id>apache-maven-snapshots</id>
             <url>http://people.apache.org/repo/m2-snapshot-repository</url>
         </repository>
+      
     </repositories>
 
     <dependencies>