You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bridges-commits@portals.apache.org by wo...@apache.org on 2010/04/22 18:11:36 UTC

svn commit: r936927 [1/2] - in /portals/bridges/bridges-script/trunk: ./ dependencies/ dependencies/beanshell/ dependencies/groovy/ dependencies/jruby/ dependencies/jython/ dependencies/rhino/ src/main/java/org/apache/portals/bridges/script/ src/test/j...

Author: woonsan
Date: Thu Apr 22 16:11:35 2010
New Revision: 936927

URL: http://svn.apache.org/viewvc?rev=936927&view=rev
Log:
PB-104: Adding a generic script support for preferences validator

Added:
    portals/bridges/bridges-script/trunk/dependencies/
    portals/bridges/bridges-script/trunk/dependencies/beanshell/
    portals/bridges/bridges-script/trunk/dependencies/beanshell/pom.xml   (with props)
    portals/bridges/bridges-script/trunk/dependencies/groovy/
    portals/bridges/bridges-script/trunk/dependencies/groovy/pom.xml   (with props)
    portals/bridges/bridges-script/trunk/dependencies/jruby/
    portals/bridges/bridges-script/trunk/dependencies/jruby/pom.xml   (with props)
    portals/bridges/bridges-script/trunk/dependencies/jython/
    portals/bridges/bridges-script/trunk/dependencies/jython/pom.xml   (with props)
    portals/bridges/bridges-script/trunk/dependencies/pom.xml   (with props)
    portals/bridges/bridges-script/trunk/dependencies/rhino/
    portals/bridges/bridges-script/trunk/dependencies/rhino/pom.xml   (with props)
    portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptEngineUtils.java   (with props)
    portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptPortletPreferencesValidator.java   (with props)
    portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloBeanShellPrefsValidator.bsh
    portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloGroovyPrefsValidator.groovy
    portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloJRubyPrefsValidator.rb   (with props)
    portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloJythonPrefsValidator.py   (with props)
    portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloRhinoPrefsValidator.js   (with props)
Modified:
    portals/bridges/bridges-script/trunk/pom.xml
    portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptPortlet.java
    portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptSource.java
    portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/AbstractSimpleScriptPortletTestCase.java
    portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloBeanShellScriptPortlet.java
    portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloGroovyScriptPortlet.java
    portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloJRubyScriptPortlet.java
    portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloJythonScriptPortlet.java
    portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloRhinoScriptPortlet.java
    portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloBeanShell.bsh
    portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloGroovy.groovy
    portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloJRuby.rb
    portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloJython.py
    portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloRhino.js

Added: portals/bridges/bridges-script/trunk/dependencies/beanshell/pom.xml
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/dependencies/beanshell/pom.xml?rev=936927&view=auto
==============================================================================
--- portals/bridges/bridges-script/trunk/dependencies/beanshell/pom.xml (added)
+++ portals/bridges/bridges-script/trunk/dependencies/beanshell/pom.xml Thu Apr 22 16:11:35 2010
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+    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. 
+    
+    @version $Id$
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <prerequisites>
+    <maven>2.0.9</maven>
+  </prerequisites>
+  
+  <groupId>org.apache.portals.bridges.portals-bridges-script.dependencies</groupId>
+  <artifactId>beanshell</artifactId>
+  <name>Apache Portals Bridges Script Bridge Dependencies for BeanShell</name>
+  <parent>
+    <groupId>org.apache.portals.bridges.portals-bridges-script</groupId>
+    <artifactId>dependencies</artifactId>
+    <version>2.0-SNAPSHOT</version>
+  </parent>
+  <packaging>pom</packaging>
+
+  <!-- Dependency Configuration -->
+
+  <dependencies>
+  </dependencies>
+
+</project>

Propchange: portals/bridges/bridges-script/trunk/dependencies/beanshell/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/bridges/bridges-script/trunk/dependencies/beanshell/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/bridges/bridges-script/trunk/dependencies/beanshell/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/bridges/bridges-script/trunk/dependencies/groovy/pom.xml
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/dependencies/groovy/pom.xml?rev=936927&view=auto
==============================================================================
--- portals/bridges/bridges-script/trunk/dependencies/groovy/pom.xml (added)
+++ portals/bridges/bridges-script/trunk/dependencies/groovy/pom.xml Thu Apr 22 16:11:35 2010
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+    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. 
+    
+    @version $Id$
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <prerequisites>
+    <maven>2.0.9</maven>
+  </prerequisites>
+  
+  <groupId>org.apache.portals.bridges.portals-bridges-script.dependencies</groupId>
+  <artifactId>groovy</artifactId>
+  <name>Apache Portals Bridges Script Bridge Dependencies for Groovy</name>
+  <parent>
+    <groupId>org.apache.portals.bridges.portals-bridges-script</groupId>
+    <artifactId>dependencies</artifactId>
+    <version>2.0-SNAPSHOT</version>
+  </parent>
+  <packaging>pom</packaging>
+
+  <!-- Dependency Configuration -->
+
+  <dependencies>
+  </dependencies>
+
+</project>

Propchange: portals/bridges/bridges-script/trunk/dependencies/groovy/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/bridges/bridges-script/trunk/dependencies/groovy/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/bridges/bridges-script/trunk/dependencies/groovy/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/bridges/bridges-script/trunk/dependencies/jruby/pom.xml
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/dependencies/jruby/pom.xml?rev=936927&view=auto
==============================================================================
--- portals/bridges/bridges-script/trunk/dependencies/jruby/pom.xml (added)
+++ portals/bridges/bridges-script/trunk/dependencies/jruby/pom.xml Thu Apr 22 16:11:35 2010
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+    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. 
+    
+    @version $Id$
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <prerequisites>
+    <maven>2.0.9</maven>
+  </prerequisites>
+  
+  <groupId>org.apache.portals.bridges.portals-bridges-script.dependencies</groupId>
+  <artifactId>jruby</artifactId>
+  <name>Apache Portals Bridges Script Bridge Dependencies for JRuby</name>
+  <parent>
+    <groupId>org.apache.portals.bridges.portals-bridges-script</groupId>
+    <artifactId>dependencies</artifactId>
+    <version>2.0-SNAPSHOT</version>
+  </parent>
+  <packaging>pom</packaging>
+
+  <!-- Dependency Configuration -->
+
+  <dependencies>
+  </dependencies>
+
+</project>

Propchange: portals/bridges/bridges-script/trunk/dependencies/jruby/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/bridges/bridges-script/trunk/dependencies/jruby/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/bridges/bridges-script/trunk/dependencies/jruby/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/bridges/bridges-script/trunk/dependencies/jython/pom.xml
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/dependencies/jython/pom.xml?rev=936927&view=auto
==============================================================================
--- portals/bridges/bridges-script/trunk/dependencies/jython/pom.xml (added)
+++ portals/bridges/bridges-script/trunk/dependencies/jython/pom.xml Thu Apr 22 16:11:35 2010
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+    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. 
+    
+    @version $Id$
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <prerequisites>
+    <maven>2.0.9</maven>
+  </prerequisites>
+  
+  <groupId>org.apache.portals.bridges.portals-bridges-script.dependencies</groupId>
+  <artifactId>jython</artifactId>
+  <name>Apache Portals Bridges Script Bridge Dependencies for Jython</name>
+  <parent>
+    <groupId>org.apache.portals.bridges.portals-bridges-script</groupId>
+    <artifactId>dependencies</artifactId>
+    <version>2.0-SNAPSHOT</version>
+  </parent>
+  <packaging>pom</packaging>
+
+  <!-- Dependency Configuration -->
+
+  <dependencies>
+  </dependencies>
+
+</project>

Propchange: portals/bridges/bridges-script/trunk/dependencies/jython/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/bridges/bridges-script/trunk/dependencies/jython/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/bridges/bridges-script/trunk/dependencies/jython/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/bridges/bridges-script/trunk/dependencies/pom.xml
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/dependencies/pom.xml?rev=936927&view=auto
==============================================================================
--- portals/bridges/bridges-script/trunk/dependencies/pom.xml (added)
+++ portals/bridges/bridges-script/trunk/dependencies/pom.xml Thu Apr 22 16:11:35 2010
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+    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. 
+    
+    @version $Id$
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  
+  <modelVersion>4.0.0</modelVersion>
+  <prerequisites>
+    <maven>2.0.9</maven>
+  </prerequisites>
+  
+  <groupId>org.apache.portals.bridges.portals-bridges-script</groupId>
+  <artifactId>dependencies</artifactId>
+  <name>Apache Portals Bridges Script Bridge Dependencies</name>
+  <parent>
+    <groupId>org.apache.portals.bridges</groupId>
+    <artifactId>portals-bridges-script</artifactId>
+    <version>2.0-SNAPSHOT</version>
+  </parent>
+  <packaging>pom</packaging>
+
+  <modules>
+    <module>groovy</module>
+    <module>jruby</module>
+    <module>jython</module>
+    <module>beanshell</module>
+    <module>rhino</module>
+  </modules>
+  
+</project>

Propchange: portals/bridges/bridges-script/trunk/dependencies/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/bridges/bridges-script/trunk/dependencies/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/bridges/bridges-script/trunk/dependencies/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/bridges/bridges-script/trunk/dependencies/rhino/pom.xml
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/dependencies/rhino/pom.xml?rev=936927&view=auto
==============================================================================
--- portals/bridges/bridges-script/trunk/dependencies/rhino/pom.xml (added)
+++ portals/bridges/bridges-script/trunk/dependencies/rhino/pom.xml Thu Apr 22 16:11:35 2010
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+    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. 
+    
+    @version $Id$
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <prerequisites>
+    <maven>2.0.9</maven>
+  </prerequisites>
+  
+  <groupId>org.apache.portals.bridges.portals-bridges-script.dependencies</groupId>
+  <artifactId>rhino</artifactId>
+  <name>Apache Portals Bridges Script Bridge Dependencies for Rhino JavaScript</name>
+  <parent>
+    <groupId>org.apache.portals.bridges.portals-bridges-script</groupId>
+    <artifactId>dependencies</artifactId>
+    <version>2.0-SNAPSHOT</version>
+  </parent>
+  <packaging>pom</packaging>
+
+  <!-- Dependency Configuration -->
+
+  <dependencies>
+  </dependencies>
+
+</project>

Propchange: portals/bridges/bridges-script/trunk/dependencies/rhino/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/bridges/bridges-script/trunk/dependencies/rhino/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/bridges/bridges-script/trunk/dependencies/rhino/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/bridges/bridges-script/trunk/pom.xml
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/pom.xml?rev=936927&r1=936926&r2=936927&view=diff
==============================================================================
--- portals/bridges/bridges-script/trunk/pom.xml (original)
+++ portals/bridges/bridges-script/trunk/pom.xml Thu Apr 22 16:11:35 2010
@@ -1,12 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
   <!--
-    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. $Id$
+    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. 
+    
+    @version $Id$
   -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
@@ -43,6 +51,7 @@
     <bsh.version>2.0b5</bsh.version>
     <slf4j.version>1.5.6</slf4j.version>
     <junit.version>3.8.1</junit.version>
+    <easymock.version>2.5.2</easymock.version>
     <spring.version>2.5.6</spring.version>
     <commons-lang.version>2.4</commons-lang.version>
   </properties>
@@ -55,33 +64,196 @@
     </repository>
   </repositories>
   
+  <dependencyManagement>
+  
+    <dependencies>
+      
+      <dependency>
+        <groupId>org.apache.portals</groupId>
+        <artifactId>portlet-api_2.0_spec</artifactId>
+        <version>${portals.portlet2-api-spec.version}</version>
+      </dependency>
+      
+      <dependency>
+        <groupId>javax.servlet</groupId>
+        <artifactId>servlet-api</artifactId>
+        <version>${javax.servlet.version}</version>
+      </dependency>
+      
+      <dependency>
+        <groupId>org.apache.portals.bridges</groupId>
+        <artifactId>portals-bridges-common</artifactId>
+        <version>${org.apache.portals.bridges.common.version}</version>
+      </dependency>
+      
+      <dependency>
+        <groupId>javax.script</groupId>
+        <artifactId>script-api</artifactId>
+        <version>${javax.script.version}</version>
+      </dependency>
+      
+      <!-- ServiceMix Repo Script Engines -->
+      
+      <dependency>
+        <groupId>com.sun.script</groupId>
+        <artifactId>groovy-engine</artifactId>
+        <version>${javax.script.groovy-engine.version}</version>
+      </dependency>
+      
+      <dependency>
+        <groupId>com.sun.script</groupId>
+        <artifactId>js-engine</artifactId>
+        <version>${javax.script.js-engine.version}</version>
+      </dependency>
+      
+      <dependency>
+        <groupId>com.sun.script</groupId>
+        <artifactId>jython-engine</artifactId>
+        <version>${javax.script.jython-engine.version}</version>
+      </dependency>
+      
+      <dependency>
+        <groupId>com.sun.script</groupId>
+        <artifactId>jruby-engine</artifactId>
+        <version>${javax.script.jruby-engine.version}</version>
+      </dependency>
+      
+      <dependency>
+        <groupId>com.sun.script</groupId>
+        <artifactId>bsh-engine</artifactId>
+        <version>${javax.script.bsh-engine.version}</version>
+      </dependency>
+      
+      <!-- Script Libraries -->
+      
+      <dependency>
+        <groupId>org.codehaus.groovy</groupId>
+        <artifactId>groovy-all</artifactId>
+        <version>${groovy.version}</version>
+      </dependency>
+      
+      <dependency>
+        <groupId>rhino</groupId>
+        <artifactId>js</artifactId>
+        <version>${rhino.version}</version>
+      </dependency>
+      
+      <dependency>
+        <groupId>org.python</groupId>
+        <artifactId>jython</artifactId>
+        <version>${jython.version}</version>
+      </dependency>
+      
+      <dependency>
+        <groupId>org.jruby</groupId>
+        <artifactId>jruby</artifactId>
+        <version>${jruby.version}</version>
+      </dependency>
+      
+      <dependency>
+        <groupId>org.beanshell</groupId>
+        <artifactId>bsh</artifactId>
+        <version>${bsh.version}</version>
+      </dependency>
+      
+      <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-api</artifactId>
+        <version>${slf4j.version}</version>
+      </dependency>
+      
+      <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-log4j12</artifactId>
+        <version>${slf4j.version}</version>
+      </dependency>
+      
+      <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>jcl-over-slf4j</artifactId>
+        <version>${slf4j.version}</version>
+      </dependency>
+      
+      <dependency>
+        <groupId>junit</groupId>
+        <artifactId>junit</artifactId>
+        <version>${junit.version}</version>
+        <scope>test</scope>
+        <exclusions>
+          <exclusion>
+            <groupId>junit-addons</groupId>
+            <artifactId>junit-addons-runner</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      
+      <dependency>
+        <groupId>org.easymock</groupId>
+        <artifactId>easymock</artifactId>
+        <version>${easymock.version}</version>
+        <scope>test</scope>
+      </dependency>
+      
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-core</artifactId>
+        <version>${spring.version}</version>
+        <scope>test</scope>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-test</artifactId>
+        <version>${spring.version}</version>
+        <scope>test</scope>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      
+      <dependency>
+        <groupId>commons-lang</groupId>
+        <artifactId>commons-lang</artifactId>
+        <version>${commons-lang.version}</version>
+        <scope>test</scope>
+      </dependency>
+      
+    </dependencies>
+    
+  </dependencyManagement>
+  
   <dependencies>
     
     <dependency>
       <groupId>org.apache.portals</groupId>
       <artifactId>portlet-api_2.0_spec</artifactId>
-      <version>${portals.portlet2-api-spec.version}</version>
       <scope>provided</scope>
     </dependency>
     
     <dependency>
       <groupId>javax.servlet</groupId>
       <artifactId>servlet-api</artifactId>
-      <version>${javax.servlet.version}</version>
       <scope>provided</scope>
     </dependency>
     
     <dependency>
       <groupId>org.apache.portals.bridges</groupId>
       <artifactId>portals-bridges-common</artifactId>
-      <version>${org.apache.portals.bridges.common.version}</version>
       <scope>provided</scope>
     </dependency>
     
     <dependency>
       <groupId>javax.script</groupId>
       <artifactId>script-api</artifactId>
-      <version>${javax.script.version}</version>
       <scope>provided</scope>
     </dependency>
     
@@ -90,35 +262,30 @@
     <dependency>
       <groupId>com.sun.script</groupId>
       <artifactId>groovy-engine</artifactId>
-      <version>${javax.script.groovy-engine.version}</version>
       <scope>test</scope>
     </dependency>
     
     <dependency>
       <groupId>com.sun.script</groupId>
       <artifactId>js-engine</artifactId>
-      <version>${javax.script.js-engine.version}</version>
       <scope>test</scope>
     </dependency>
     
     <dependency>
       <groupId>com.sun.script</groupId>
       <artifactId>jython-engine</artifactId>
-      <version>${javax.script.jython-engine.version}</version>
       <scope>test</scope>
     </dependency>
     
     <dependency>
       <groupId>com.sun.script</groupId>
       <artifactId>jruby-engine</artifactId>
-      <version>${javax.script.jruby-engine.version}</version>
       <scope>test</scope>
     </dependency>
     
     <dependency>
       <groupId>com.sun.script</groupId>
       <artifactId>bsh-engine</artifactId>
-      <version>${javax.script.bsh-engine.version}</version>
       <scope>test</scope>
     </dependency>
     
@@ -127,107 +294,83 @@
     <dependency>
       <groupId>org.codehaus.groovy</groupId>
       <artifactId>groovy-all</artifactId>
-      <version>${groovy.version}</version>
       <scope>test</scope>
     </dependency>
     
     <dependency>
       <groupId>rhino</groupId>
       <artifactId>js</artifactId>
-      <version>${rhino.version}</version>
       <scope>test</scope>
     </dependency>
     
     <dependency>
       <groupId>org.python</groupId>
       <artifactId>jython</artifactId>
-      <version>${jython.version}</version>
       <scope>test</scope>
     </dependency>
     
     <dependency>
       <groupId>org.jruby</groupId>
       <artifactId>jruby</artifactId>
-      <version>${jruby.version}</version>
       <scope>test</scope>
     </dependency>
     
     <dependency>
       <groupId>org.beanshell</groupId>
       <artifactId>bsh</artifactId>
-      <version>${bsh.version}</version>
       <scope>test</scope>
     </dependency>
     
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
-      <version>${slf4j.version}</version>
       <scope>test</scope>
     </dependency>
     
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
-      <version>${slf4j.version}</version>
       <scope>test</scope>
     </dependency>
     
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>jcl-over-slf4j</artifactId>
-      <version>${slf4j.version}</version>
       <scope>test</scope>
     </dependency>
     
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>${junit.version}</version>
       <scope>test</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>junit-addons</groupId>
-          <artifactId>junit-addons-runner</artifactId>
-        </exclusion>
-      </exclusions>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.easymock</groupId>
+      <artifactId>easymock</artifactId>
+      <scope>test</scope>
     </dependency>
     
     <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-core</artifactId>
-      <version>${spring.version}</version>
       <scope>test</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>commons-logging</groupId>
-          <artifactId>commons-logging</artifactId>
-        </exclusion>
-      </exclusions>
     </dependency>
     
     <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-test</artifactId>
-      <version>${spring.version}</version>
       <scope>test</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>commons-logging</groupId>
-          <artifactId>commons-logging</artifactId>
-        </exclusion>
-      </exclusions>
     </dependency>
     
     <dependency>
       <groupId>commons-lang</groupId>
       <artifactId>commons-lang</artifactId>
-      <version>${commons-lang.version}</version>
       <scope>test</scope>
     </dependency>
     
   </dependencies>
-
+  
   <scm>
     <connection>scm:svn:http://svn.apache.org/repos/asf/portals/bridges/bridges-script/trunk</connection>
     <developerConnection>scm:svn:https://svn.apache.org/repos/asf/portals/bridges/bridges-script/trunk</developerConnection>

Added: portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptEngineUtils.java
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptEngineUtils.java?rev=936927&view=auto
==============================================================================
--- portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptEngineUtils.java (added)
+++ portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptEngineUtils.java Thu Apr 22 16:11:35 2010
@@ -0,0 +1,189 @@
+/*
+ * 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.portals.bridges.script;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+
+/**
+ * ScriptEngineUtils
+ * 
+ * @author <a href="mailto:woonsan@apache.org">Woonsan Ko</a>
+ * @version $Id$
+ */
+public class ScriptEngineUtils
+{
+    private ScriptEngineUtils()
+    {
+        
+    }
+    
+    /**
+     * Creates script engine based on scriptEngineName and scriptSource.
+     * <P>
+     * When scriptEngineName is not null, it creates a script engine by the scriptEngineName.
+     * When scriptEngineName is not null, it creates a script engine by the mimeType of the scriptSource if available.
+     * Otherwise, it creates a script engine by the script extension.
+     * </P>
+     * 
+     * @param scriptEngineName
+     * @param scriptSource
+     * @return
+     * @throws ScriptException
+     */
+    public static ScriptEngine createScriptEngine(final String scriptEngineName, final ScriptSource scriptSource) throws ScriptException
+    {
+        ScriptEngine scriptEngine = null;
+        ScriptEngineManager manager = new ScriptEngineManager();
+        
+        if (scriptEngineName != null)
+        {
+            scriptEngine = manager.getEngineByName(scriptEngineName);
+        }
+        else
+        {
+            if (scriptSource.getMimeType() != null)
+            {
+                scriptEngine = manager.getEngineByMimeType(scriptSource.getMimeType());
+            }
+            
+            if (scriptEngine == null)
+            {
+                if (scriptSource.getExtension() != null)
+                {
+                    scriptEngine = manager.getEngineByExtension(scriptSource.getExtension());
+                }
+            }
+        }
+        
+        if (scriptEngine == null)
+        {
+            throw new ScriptException("Cannot create script engine. { scriptEngineName: " + scriptEngineName + ", scriptSource: " + scriptSource);
+        }
+        
+        return scriptEngine;
+    }
+    
+    /**
+     * Evaluates the scriptSource through the scriptEngine and returns the evaluated object.
+     * <P>
+     * If the evalKey is null, it returns the last evaluated object.
+     * Otherwise, it retrieves the object by the evalKey from the scriptEngine.
+     * </P>
+     * 
+     * @param scriptEngine
+     * @param scriptSource
+     * @param evalKey
+     * @param fallback
+     * @return
+     * @throws ScriptException
+     * @throws IOException
+     */
+    public static Object evaluateScript(final ScriptEngine scriptEngine, final ScriptSource scriptSource, final String evalKey, final boolean fallback) throws ScriptException, IOException
+    {
+        Object evaledObject = null;
+        
+        InputStream input = null;
+        InputStreamReader isr = null;
+        BufferedReader br = null;
+        
+        try
+        {
+            input = scriptSource.getInputStream();
+            
+            if (scriptSource.getCharacterEncoding() != null)
+            {
+                isr = new InputStreamReader(input, scriptSource.getCharacterEncoding());
+            }
+            else
+            {
+                isr = new InputStreamReader(input);
+            }
+            
+            br = new BufferedReader(isr);
+            
+            Object ret = scriptEngine.eval(br);
+            
+            if (evalKey != null)
+            {
+                evaledObject = scriptEngine.get(evalKey);
+                
+                if (evaledObject == null && fallback)
+                {
+                    evaledObject = ret;
+                }
+            }
+            
+            if (evaledObject == null)
+            {
+                evaledObject = ret;
+            }
+            
+            if (evaledObject == null)
+            {
+                throw new ScriptException("The evaluated object is null. (" + evalKey + ")");
+            }
+        }
+        finally
+        {
+            if (br != null)
+            {
+                try
+                {
+                    br.close();
+                }
+                catch (Exception ignore) { }
+            }
+            if (isr != null)
+            {
+                try
+                {
+                    isr.close();
+                }
+                catch (Exception ignore) { }
+            }
+            if (input != null)
+            {
+                try
+                {
+                    input.close();
+                }
+                catch (Exception ignore) { }
+            }
+        }
+        
+        return evaledObject;
+    }
+    
+    /**
+     * Checks if the script source has been modified after the specified time.
+     * 
+     * @param scriptSource
+     * @param after
+     * @return
+     */
+    public static boolean isScriptModified(final ScriptSource scriptSource, final long after)
+    {
+        return (scriptSource.lastModified() > after);
+    }
+}

Propchange: portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptEngineUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptEngineUtils.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptEngineUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptPortlet.java
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptPortlet.java?rev=936927&r1=936926&r2=936927&view=diff
==============================================================================
--- portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptPortlet.java (original)
+++ portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptPortlet.java Thu Apr 22 16:11:35 2010
@@ -16,11 +16,8 @@
  */
 package org.apache.portals.bridges.script;
 
-import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 
@@ -33,13 +30,13 @@ import javax.portlet.GenericPortlet;
 import javax.portlet.Portlet;
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletException;
+import javax.portlet.PreferencesValidator;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.portlet.ResourceRequest;
 import javax.portlet.ResourceResponse;
 import javax.portlet.ResourceServingPortlet;
 import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
 import javax.script.ScriptException;
 
 /**
@@ -62,7 +59,7 @@ import javax.script.ScriptException;
  *   If this init parameter is not set, the ScriptPortlet will look up a script engine automatically
  *   by the mimeType or the extension of the script source file. -->
  *   <init-param>
- *     <name>script-engine</name>
+ *     <name>engine</name>
  *     <!-- 
  *       Note: You can set other script engine which support JSR-223 ScriptEngine
  *       such as 'groovy', 'jruby', 'jython'.
@@ -70,18 +67,18 @@ import javax.script.ScriptException;
  *     <value>groovy</value>
  *   </init-param>
  *   
- *   <!-- Optional init parameter for the key for portlet class or portlet instance which is evaluated and returned by the script.
+ *   <!-- Optional init parameter for the key for portlet/preferencesValidator class or portlet/preferencesValidator instance which is evaluated and returned by the script.
  *   By default, when this init parameter is not set, ScriptPortlet retrieves the last evaluated object from the script.
- *   If you set this to 'portlet', then ScriptPortlet retrieves an object named 'portlet' from the script engine.
+ *   If you set this to 'value', then ScriptPortlet retrieves an object named 'value' from the bindings of the script engine.
  *   Depending on script engines, this init parameter should be properly configured because some script engines do not return the last evaluated object. -->
  *   <init-param>
- *     <name>eval-portlet-key</name>
- *     <value>portlet</value>
+ *     <name>eval-key</name>
+ *     <value>value</value>
  *   </init-param>
  *   
  *   <!-- Required init parameter for script source path -->
  *   <init-param>
- *     <name>script-source</name>
+ *     <name>source</name>
  *     <!--
  *       Note: You can set script source in three ways. 
  *       The first is to use context relative path,
@@ -99,7 +96,7 @@ import javax.script.ScriptException;
  *   
  *   <!-- Optional init parameter for script file content encoding. The default value is 'UTF-8'. -->
  *   <init-param>
- *     <name>script-source-encoding</name>
+ *     <name>encoding</name>
  *     <value>UTF-8</value>
  *   </init-param>
  *   
@@ -111,6 +108,24 @@ import javax.script.ScriptException;
  *     <value>true</value>
  *   </init-param>
  *   
+ *   <!-- Optional init parameter for script preferences validator path -->
+ *   <init-param>
+ *     <name>validator</name>
+ *     <!--
+ *       Note: You can set script preferences validator source in three ways. 
+ *       The first is to use context relative path,
+ *       the second is to use file: url, 
+ *       and the third is to classpath: uri.
+ *       Here are the examples for each way.
+ *     -->
+ *     <!--
+ *       <value>/WEB-INF/groovy/HelloGroovyPrefsValidator.groovy</value>
+ *       <value>file:/C:/Program Files/Apache Software Foundation/Tomcat/webapps/demo/WEB-INF/groovy/HelloGroovyPrefsValidator.groovy</value>
+ *       <value>classpath:org/apache/portals/bridges/script/HelloGroovyPrefsValidator.groovy</value>
+ *     -->
+ *     <value>classpath:org/apache/portals/bridges/script/HelloGroovyPrefsValidator.groovy</value>
+ *   </init-param>
+ *   
  *   <!-- The followings are not special for ScriptPortlet, but normal configurations for a portlet. -->
  *   <supports>
  *     <mime-type>text/html</mime-type>
@@ -129,6 +144,7 @@ import javax.script.ScriptException;
  *       <name>message</name>
  *       <value>Hello, Groovy!</value>
  *     </preference>
+ *     <preferences-validator>org.apache.portals.bridges.script.ScriptPortletPreferencesValidator</preferences-validator>
  *   </portlet-preferences>
  *   
  * </portlet>
@@ -139,31 +155,33 @@ import javax.script.ScriptException;
  */
 public class ScriptPortlet extends GenericPortlet
 {
-    public static final String SCRIPT_ENGINE_INIT_PARAM = "script-engine";
+    public static final String ENGINE = "engine";
+    
+    public static final String EVAL_KEY = "eval-key";
     
-    public static final String EVAL_PORTLET_KEY_INIT_PARAM = "eval-portlet-key";
+    public static final String SOURCE = "source";
     
-    public static final String SCRIPT_SOURCE_INIT_PARAM = "script-source";
+    public static final String VALIDATOR = "validator";
     
-    public static final String SCRIPT_SOURCE_URL_ENCODING_INIT_PARAM = "script-source-uri-encoding";
+    public static final String URI_ENCODING = "uri-encoding";
     
-    public static final String SCRIPT_SOURCE_ENCODING_INIT_PARAM = "script-source-encoding";
+    public static final String ENCODING = "encoding";
     
-    public static final String AUTO_REFRESH_INIT_PARAM = "auto-refresh";
+    public static final String AUTO_REFRESH = "auto-refresh";
     
     protected PortletConfig portletConfig;
     
     protected String scriptEngineName;
     
-    protected String evalPortletKey;
+    protected String evalKey;
     
     protected ScriptEngine scriptEngine;
     
     protected String scriptSourceUri;
     
-    protected String scriptSourceUriEncoding = "UTF-8";
+    protected String scriptSourceUriEncoding;
     
-    protected String scriptSourceEncoding = "UTF-8";
+    protected String scriptSourceCharacterEncoding;
     
     protected boolean autoRefresh;
     
@@ -179,6 +197,18 @@ public class ScriptPortlet extends Gener
     
     protected Method portletDoEditMethod;
     
+    protected String validatorSourceUri;
+    
+    protected ScriptSource validatorSource;
+    
+    protected long validatorSourceLastModified;
+    
+    protected long validatorSourceLastEvaluated;
+    
+    protected PreferencesValidator validatorInstance;
+    
+    private static ThreadLocal<PreferencesValidator> tlValidatorInstance = new ThreadLocal<PreferencesValidator>();
+    
     public ScriptPortlet()
     {
         super();
@@ -189,34 +219,41 @@ public class ScriptPortlet extends Gener
     {
         portletConfig = config;
         
-        autoRefresh = "true".equals(config.getInitParameter(AUTO_REFRESH_INIT_PARAM));
+        autoRefresh = "true".equals(config.getInitParameter(AUTO_REFRESH));
         
-        String param = config.getInitParameter(SCRIPT_ENGINE_INIT_PARAM);
+        String param = config.getInitParameter(ENGINE);
         
         if (param != null && !"".equals(param.trim()))
         {
             scriptEngineName = param;
         }
         
-        param = config.getInitParameter(EVAL_PORTLET_KEY_INIT_PARAM);
+        param = config.getInitParameter(EVAL_KEY);
         
         if (param != null && !"".equals(param.trim()))
         {
-            evalPortletKey = param;
+            evalKey = param;
         }
         
-        param = config.getInitParameter(SCRIPT_SOURCE_URL_ENCODING_INIT_PARAM);
+        param = config.getInitParameter(ENCODING);
+        
+        if (param != null && !"".equals(param.trim()))
+        {
+            scriptSourceCharacterEncoding = param;
+        }
+        
+        param = config.getInitParameter(URI_ENCODING);
         
         if (param != null && !"".equals(param.trim()))
         {
             scriptSourceUriEncoding = param;
         }
         
-        scriptSourceUri = config.getInitParameter(SCRIPT_SOURCE_INIT_PARAM);
+        scriptSourceUri = config.getInitParameter(SOURCE);
 
         if (scriptSourceUri == null)
         {
-            throw new PortletException("Configuration failed: " + SCRIPT_SOURCE_INIT_PARAM + " should be set properly!");
+            throw new PortletException("Configuration failed: " + SOURCE + " should be set properly!");
         }
         else
         {
@@ -224,32 +261,53 @@ public class ScriptPortlet extends Gener
             {
                 if (scriptSourceUri.startsWith("/"))
                 {
-                    scriptSource = new ScriptSource(new File(config.getPortletContext().getRealPath(scriptSourceUri)).toURL().toString(), scriptSourceUriEncoding);
+                    scriptSource = new ScriptSource(new File(config.getPortletContext().getRealPath(scriptSourceUri)).toURL().toString(), scriptSourceUriEncoding, scriptSourceCharacterEncoding);
                 }
                 else
                 {
-                    scriptSource = new ScriptSource(scriptSourceUri, scriptSourceUriEncoding);
+                    scriptSource = new ScriptSource(scriptSourceUri, scriptSourceUriEncoding, scriptSourceCharacterEncoding);
                 }
+                
+                scriptSource.setMimeType(config.getPortletContext().getMimeType(scriptSource.getName()));
             }
             catch (Exception e)
             {
-                throw new PortletException("File not found: " + this.scriptSourceUri, e);
+                throw new PortletException("Script not found: " + this.scriptSourceUri, e);
             }
         }
         
-        param = config.getInitParameter(SCRIPT_SOURCE_ENCODING_INIT_PARAM);
-        
-        if (param != null && !"".equals(param.trim()))
-        {
-            scriptSourceEncoding = param;
-        }
-        
         refreshPortletInstance();
 
         if (scriptPortletInstance == null)
         {
             throw new PortletException("Script portlet is not available!");
         }
+        
+        validatorSourceUri = config.getInitParameter(VALIDATOR);
+
+        if (validatorSourceUri != null)
+        {
+            try
+            {
+                if (validatorSourceUri.startsWith("/"))
+                {
+                    validatorSource = new ScriptSource(new File(config.getPortletContext().getRealPath(validatorSourceUri)).toURL().toString(), scriptSourceUriEncoding, scriptSourceCharacterEncoding);
+                }
+                else
+                {
+                    validatorSource = new ScriptSource(validatorSourceUri, scriptSourceUriEncoding, scriptSourceCharacterEncoding);
+                }
+                
+                validatorSource.setMimeType(config.getPortletContext().getMimeType(validatorSource.getName()));
+            }
+            catch (Exception e)
+            {
+                throw new PortletException("Script not found: " + validatorSourceUri, e);
+            }
+            
+            refreshValidatorInstance();
+        }
+        
     }
     
     @Override
@@ -291,7 +349,24 @@ public class ScriptPortlet extends Gener
         }
         else
         {
-            scriptPortletInstance.processAction(request, response);
+            try
+            {
+                refreshValidatorInstance();
+                
+                if (validatorInstance != null)
+                {
+                    tlValidatorInstance.set(validatorInstance);
+                }
+                
+                scriptPortletInstance.processAction(request, response);
+            }
+            finally
+            {
+                if (validatorInstance != null)
+                {
+                    tlValidatorInstance.set(null);
+                }
+            }
         }
     }
     
@@ -350,168 +425,128 @@ public class ScriptPortlet extends Gener
     
     protected void refreshPortletInstance() throws PortletException
     {
-        if (scriptPortletInstance == null)
-        {
-            try
-            {
-                createScriptPortletInstance();
-            }
-            catch (Exception ex)
-            {
-                throw new PortletException("Could not evaluate script: " + scriptSourceUri, ex);
-            }
-        }
-        else if (autoRefresh && isScriptFileModified())
-        {
-            synchronized (scriptPortletInstance)
-            {
-                try
-                {
-                    createScriptPortletInstance();
-                }
-                catch (Exception ex)
-                {
-                    throw new PortletException("Could not evaluate script: " + scriptSourceUri, ex);
-                }
-            }
-        }
-    }
-    
-    protected boolean isScriptFileModified()
-    {
-        return (scriptSource.lastModified() > scriptSourceLastModified);
-    }
-    
-    protected void createScriptPortletInstance() throws Exception
-    {
-        if (scriptEngine == null)
+        boolean createNew = (scriptPortletInstance == null);
+        
+        if (!createNew)
         {
-            ScriptEngineManager manager = new ScriptEngineManager();
+            createNew = (autoRefresh && ScriptEngineUtils.isScriptModified(scriptSource, scriptSourceLastModified));
             
-            if (scriptEngineName != null)
+            if (!createNew)
             {
-                scriptEngine = manager.getEngineByName(scriptEngineName);
-            }
-            else
-            {
-                String mimeType = portletConfig.getPortletContext().getMimeType(scriptSource.getName());
-                
-                if (mimeType != null)
-                {
-                    scriptEngine = manager.getEngineByMimeType(mimeType);
-                }
-                
-                if (scriptEngine == null)
-                {
-                    String extension = scriptSource.getExtension();
-                    
-                    if (extension != null)
-                    {
-                        scriptEngine = manager.getEngineByExtension(extension);
-                    }
-                }
+                return;
             }
         }
         
-        if (scriptEngine == null)
-        {
-            throw new ScriptException("Cannot create script engine. { scriptEngineName: " + scriptEngineName + ", scriptSource: " + scriptSource);
-        }
-        
-        InputStream input = null;
-        InputStreamReader isr = null;
-        BufferedReader br = null;
-        
         try
         {
-            input = scriptSource.getInputStream();
-            isr = new InputStreamReader(input, scriptSourceEncoding);
-            br = new BufferedReader(isr);
-            
-            Object evalPortlet = null;
-            Object ret = scriptEngine.eval(br);
-            
-            if (evalPortletKey != null)
-            {
-                evalPortlet = scriptEngine.get(evalPortletKey);
-            }
+            Portlet tempScriptPortletInstance = null;
             
-            if (evalPortlet == null)
+            if (scriptEngine == null)
             {
-                evalPortlet = ret;
-            }
-            
-            if (evalPortlet == null)
-            {
-                throw new ScriptException("The evaluated return is null. (" + evalPortletKey + ")");
+                scriptEngine = ScriptEngineUtils.createScriptEngine(scriptEngineName, scriptSource);
             }
             
+            Object evalPortlet = ScriptEngineUtils.evaluateScript(scriptEngine, scriptSource, evalKey, true);
             scriptSourceLastEvaluated = System.currentTimeMillis();
-            
+                
             if (evalPortlet instanceof Portlet)
             {
-                scriptPortletInstance = (Portlet) evalPortlet;
+                tempScriptPortletInstance = (Portlet) evalPortlet;
             }
             else if (evalPortlet instanceof Class)
             {
                 Class<? extends Portlet> scriptPortletClass = (Class<? extends Portlet>) evalPortlet;
-                scriptPortletInstance = (Portlet) scriptPortletClass.newInstance();
+                tempScriptPortletInstance = (Portlet) scriptPortletClass.newInstance();
             }
             else
             {
                 throw new ScriptException("The evaluated return is neither class nor instance of javax.portlet.Portlet. " + evalPortlet);
             }
-        }
-        finally
-        {
-            if (br != null)
-            {
-                try
-                {
-                    br.close();
-                }
-                catch (Exception ignore) { }
-            }
-            if (isr != null)
+            
+            scriptGenericPortletInstance = null;
+            portletDoEditMethod = null;
+            
+            if (tempScriptPortletInstance instanceof GenericPortlet)
             {
+                scriptGenericPortletInstance = (GenericPortlet) tempScriptPortletInstance;
+                
                 try
                 {
-                    isr.close();
+                    Method doEditMethod = scriptGenericPortletInstance.getClass().getMethod("doEdit", new Class [] { RenderRequest.class, RenderResponse.class });
+                    
+                    if (Modifier.isPublic(doEditMethod.getModifiers()))
+                    {
+                        portletDoEditMethod = doEditMethod;
+                    }
                 }
-                catch (Exception ignore) { }
-            }
-            if (input != null)
-            {
-                try
+                catch (NoSuchMethodException e)
                 {
-                    input.close();
                 }
-                catch (Exception ignore) { }
             }
+            
+            scriptSourceLastModified = scriptSource.lastModified();
+            tempScriptPortletInstance.init(portletConfig);
+            
+            scriptPortletInstance = tempScriptPortletInstance;
+        }
+        catch (Exception ex)
+        {
+            throw new PortletException("Could not evaluate script: " + scriptSourceUri, ex);
+        }
+    }
+    
+    protected void refreshValidatorInstance() throws PortletException
+    {
+        if (validatorSource == null)
+        {
+            return;
         }
         
-        scriptGenericPortletInstance = null;
-        portletDoEditMethod = null;
+        boolean createNew = (validatorInstance == null);
         
-        if (scriptPortletInstance instanceof GenericPortlet)
+        if (!createNew)
         {
-            scriptGenericPortletInstance = (GenericPortlet) scriptPortletInstance;
+            createNew = (autoRefresh && ScriptEngineUtils.isScriptModified(validatorSource, validatorSourceLastModified));
             
-            try
+            if (!createNew)
             {
-                Method doEditMethod = scriptGenericPortletInstance.getClass().getMethod("doEdit", new Class [] { RenderRequest.class, RenderResponse.class });
+                return;
+            }
+        }
+        
+        try
+        {
+            PreferencesValidator tempValidatorInstance = null;
+            
+            Object evalPortlet = ScriptEngineUtils.evaluateScript(scriptEngine, validatorSource, evalKey, true);
+            validatorSourceLastEvaluated = System.currentTimeMillis();
                 
-                if (Modifier.isPublic(doEditMethod.getModifiers()))
-                {
-                    portletDoEditMethod = doEditMethod;
-                }
+            if (evalPortlet instanceof PreferencesValidator)
+            {
+                tempValidatorInstance = (PreferencesValidator) evalPortlet;
             }
-            catch (NoSuchMethodException e)
+            else if (evalPortlet instanceof Class)
             {
+                Class<? extends PreferencesValidator> validatorClass = (Class<? extends PreferencesValidator>) evalPortlet;
+                tempValidatorInstance = (PreferencesValidator) validatorClass.newInstance();
             }
+            else
+            {
+                throw new ScriptException("The evaluated return is neither class nor instance of javax.portlet.PreferencesValidator. " + evalPortlet);
+            }
+            
+            validatorSourceLastModified = validatorSource.lastModified();
+            
+            validatorInstance = tempValidatorInstance;
         }
-        
-        scriptSourceLastModified = scriptSource.lastModified();
-        scriptPortletInstance.init(portletConfig);
+        catch (Exception ex)
+        {
+            throw new PortletException("Could not evaluate script: " + validatorSourceUri, ex);
+        }
+    }
+    
+    protected static PreferencesValidator getScriptPreferencesValidator()
+    {
+        return (PreferencesValidator) tlValidatorInstance.get();
     }
 }

Added: portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptPortletPreferencesValidator.java
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptPortletPreferencesValidator.java?rev=936927&view=auto
==============================================================================
--- portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptPortletPreferencesValidator.java (added)
+++ portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptPortletPreferencesValidator.java Thu Apr 22 16:11:35 2010
@@ -0,0 +1,40 @@
+/*
+ * 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.portals.bridges.script;
+
+import javax.portlet.PortletPreferences;
+import javax.portlet.PreferencesValidator;
+import javax.portlet.ValidatorException;
+
+/**
+ * ScriptPortletPreferencesValidator
+ * 
+ * @author <a href="mailto:woonsan@apache.org">Woonsan Ko</a>
+ * @version $Id$
+ */
+public class ScriptPortletPreferencesValidator implements PreferencesValidator
+{
+    public void validate(PortletPreferences preferences) throws ValidatorException
+    {
+        PreferencesValidator delegatee = ScriptPortlet.getScriptPreferencesValidator();
+        
+        if (delegatee != null)
+        {
+            delegatee.validate(preferences);
+        }
+    }
+}

Propchange: portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptPortletPreferencesValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptPortletPreferencesValidator.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptPortletPreferencesValidator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptSource.java
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptSource.java?rev=936927&r1=936926&r2=936927&view=diff
==============================================================================
--- portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptSource.java (original)
+++ portals/bridges/bridges-script/trunk/src/main/java/org/apache/portals/bridges/script/ScriptSource.java Thu Apr 22 16:11:35 2010
@@ -26,23 +26,48 @@ import java.io.InputStream;
 import java.net.URL;
 import java.net.URLDecoder;
 
+/**
+ * ScriptSource
+ * <P>
+ * Representing a script source which could be loaded from a file system, classpath resource. 
+ * </P>
+ * 
+ * @author <a href="mailto:woonsan@apache.org">Woonsan Ko</a>
+ * @version $Id$
+ */
 public class ScriptSource
 {
+    
+    /** Script source URI. e.g., "file://path", "classpath:path" or "file_relative_path". */
     private String uri;
+    
+    /** The file name part of the script source. */
     private String name;
+    
+    /** The file extension of the script source without dot prefix. */
     private String extension;
     
+    /** The mime type of this script. */
+    private String mimeType;
+    
+    /** The character encoding of the content of this script. */
+    private String characterEncoding;
+    
+    /** Phyical file of this script source if acessible. */
     private File scriptFile;
+    
+    /** The script content bytes if the script source file is not accessible. */
     private byte [] scriptBytes;
     
     public ScriptSource(String uri) throws IOException
     {
-        this(uri, null);
+        this(uri, null, null);
     }
     
-    public ScriptSource(String uri, String uriEncoding) throws IOException
+    public ScriptSource(String uri, String uriEncoding, String characterEncoding) throws IOException
     {
         this.uri = uri;
+        this.characterEncoding = characterEncoding;
         
         if (uri.startsWith("file:"))
         {
@@ -166,6 +191,21 @@ public class ScriptSource
         return extension;
     }
     
+    public String getCharacterEncoding()
+    {
+        return characterEncoding;
+    }
+    
+    public void setMimeType(String mimeType)
+    {
+        this.mimeType = mimeType;
+    }
+    
+    public String getMimeType()
+    {
+        return mimeType;
+    }
+    
     public long lastModified()
     {
         if (scriptFile != null)

Modified: portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/AbstractSimpleScriptPortletTestCase.java
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/AbstractSimpleScriptPortletTestCase.java?rev=936927&r1=936926&r2=936927&view=diff
==============================================================================
--- portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/AbstractSimpleScriptPortletTestCase.java (original)
+++ portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/AbstractSimpleScriptPortletTestCase.java Thu Apr 22 16:11:35 2010
@@ -27,6 +27,8 @@ import javax.portlet.PortletException;
 import junit.framework.TestCase;
 
 import org.springframework.core.io.DefaultResourceLoader;
+import org.springframework.mock.web.portlet.MockActionRequest;
+import org.springframework.mock.web.portlet.MockActionResponse;
 import org.springframework.mock.web.portlet.MockPortletConfig;
 import org.springframework.mock.web.portlet.MockPortletContext;
 import org.springframework.mock.web.portlet.MockPortletPreferences;
@@ -41,11 +43,11 @@ import org.springframework.mock.web.port
  */
 public abstract class AbstractSimpleScriptPortletTestCase extends TestCase
 {
-    private PortletContext portletContext;
-    private MockPortletConfig portletConfig;
-    private ScriptPortlet scriptPortlet;
-    private Portlet scriptPortletInstance;
-    private long scriptSourceLastEvaluated;
+    protected PortletContext portletContext;
+    protected MockPortletConfig portletConfig;
+    protected ScriptPortlet scriptPortlet;
+    protected Portlet scriptPortletInstance;
+    protected long scriptSourceLastEvaluated;
     
     abstract protected Map<String, String> getPortletInitParameters();
     
@@ -90,11 +92,11 @@ public abstract class AbstractSimpleScri
         }
     }
     
-    public void testInitialization() throws Exception
+    public void testInit() throws Exception
     {
-        String scriptEngine = getPortletInitParameters().get("script-engine");
-        String evalPortletKey = getPortletInitParameters().get("eval-portlet-key");
-        String scriptSource = getPortletInitParameters().get("script-source");
+        String scriptEngine = getPortletInitParameters().get(ScriptPortlet.ENGINE);
+        String evalPortletKey = getPortletInitParameters().get(ScriptPortlet.EVAL_KEY);
+        String scriptSource = getPortletInitParameters().get(ScriptPortlet.SOURCE);
         
         /*
          * 1. initialize script engine by script engine name
@@ -102,12 +104,12 @@ public abstract class AbstractSimpleScri
         
         PortletContext portletContext = new MockPortletContext(new DefaultResourceLoader());
         MockPortletConfig portletConfig = new MockPortletConfig(portletContext);
-        portletConfig.addInitParameter("script-engine", scriptEngine);
+        portletConfig.addInitParameter(ScriptPortlet.ENGINE, scriptEngine);
         if (evalPortletKey != null)
         {
-            portletConfig.addInitParameter("eval-portlet-key", evalPortletKey);
+            portletConfig.addInitParameter(ScriptPortlet.EVAL_KEY, evalPortletKey);
         }
-        portletConfig.addInitParameter("script-source", scriptSource);
+        portletConfig.addInitParameter(ScriptPortlet.SOURCE, scriptSource);
         
         ScriptPortlet helloScriptPortlet = new ScriptPortlet();
         
@@ -130,9 +132,9 @@ public abstract class AbstractSimpleScri
         portletConfig = new MockPortletConfig(portletContext);
         if (evalPortletKey != null)
         {
-            portletConfig.addInitParameter("eval-portlet-key", evalPortletKey);
+            portletConfig.addInitParameter(ScriptPortlet.EVAL_KEY, evalPortletKey);
         }
-        portletConfig.addInitParameter("script-source", scriptSource);
+        portletConfig.addInitParameter(ScriptPortlet.SOURCE, scriptSource);
         
         helloScriptPortlet = new ScriptPortlet();
         
@@ -162,9 +164,9 @@ public abstract class AbstractSimpleScri
         portletConfig = new MockPortletConfig(portletContext);
         if (evalPortletKey != null)
         {
-            portletConfig.addInitParameter("eval-portlet-key", evalPortletKey);
+            portletConfig.addInitParameter(ScriptPortlet.EVAL_KEY, evalPortletKey);
         }
-        portletConfig.addInitParameter("script-source", scriptSource);
+        portletConfig.addInitParameter(ScriptPortlet.SOURCE, scriptSource);
         
         helloScriptPortlet = new ScriptPortlet();
         
@@ -180,7 +182,7 @@ public abstract class AbstractSimpleScri
         }
     }
     
-    public void testHelloScriptPortlet() throws Exception
+    public void testRender() throws Exception
     {
         MockRenderRequest request = new MockRenderRequest(portletContext);
         MockPortletPreferences preferences = new MockPortletPreferences();
@@ -190,6 +192,10 @@ public abstract class AbstractSimpleScri
         MockRenderResponse response = new MockRenderResponse();
         
         scriptPortlet.render(request, response);
+        assertFalse("The script is refreshed " +
+                   "(scriptSourceLastEvaluated: " + scriptPortlet.scriptSourceLastEvaluated + ", " +
+                   "initial-scriptSourceLastEvaluated: " + scriptSourceLastEvaluated + ")",
+                   scriptPortlet.scriptSourceLastEvaluated > scriptSourceLastEvaluated);
         
         String content = response.getContentAsString();
         assertNotNull(content);
@@ -209,4 +215,34 @@ public abstract class AbstractSimpleScri
                    "initial-scriptSourceLastEvaluated: " + scriptSourceLastEvaluated + ")",
                    scriptPortlet.scriptSourceLastEvaluated > scriptSourceLastEvaluated);
     }
+    
+    public void testProcessAction() throws Exception
+    {
+        MockActionRequest request = new MockActionRequest(portletContext);
+        MockPortletPreferences preferences = new MockPortletPreferences();
+        
+        if (scriptPortlet.validatorInstance != null)
+        {
+            preferences.setPreferencesValidator(scriptPortlet.validatorInstance);
+        }
+        
+        request.setPreferences(preferences);
+        request.addLocale(Locale.ENGLISH);
+        
+        MockActionResponse response = new MockActionResponse();
+        
+        try
+        {
+            scriptPortlet.processAction(request, response);
+            fail("Validator exception should occur here!!!");
+        }
+        catch (Exception e)
+        {
+            // expected ...
+        }
+        
+        request.addParameter("message", "hello");
+        
+        scriptPortlet.processAction(request, response);
+    }
 }

Modified: portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloBeanShellScriptPortlet.java
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloBeanShellScriptPortlet.java?rev=936927&r1=936926&r2=936927&view=diff
==============================================================================
--- portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloBeanShellScriptPortlet.java (original)
+++ portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloBeanShellScriptPortlet.java Thu Apr 22 16:11:35 2010
@@ -33,9 +33,10 @@ public class TestHelloBeanShellScriptPor
     protected Map<String, String> getPortletInitParameters()
     {
         Map<String, String> initParams = new HashMap<String, String>();
-        initParams.put("script-engine", "beanshell");
-        initParams.put("script-source", "classpath:org/apache/portals/bridges/script/HelloBeanShell.bsh");
-        initParams.put("auto-refresh", "true");
+        initParams.put(ScriptPortlet.ENGINE, "beanshell");
+        initParams.put(ScriptPortlet.SOURCE, "classpath:org/apache/portals/bridges/script/HelloBeanShell.bsh");
+        initParams.put(ScriptPortlet.VALIDATOR, "classpath:org/apache/portals/bridges/script/HelloBeanShellPrefsValidator.bsh");
+        initParams.put(ScriptPortlet.AUTO_REFRESH, "true");
         return initParams;
     }
     
@@ -60,4 +61,22 @@ public class TestHelloBeanShellScriptPor
     {
         return "application/x-beanshell";
     }
+    
+    @Override
+    public void testInit() throws Exception
+    {
+        super.testInit();
+    }
+    
+    @Override
+    public void testRender() throws Exception
+    {
+        super.testRender();
+    }
+    
+    @Override
+    public void testProcessAction() throws Exception
+    {
+        super.testProcessAction();
+    }
 }

Modified: portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloGroovyScriptPortlet.java
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloGroovyScriptPortlet.java?rev=936927&r1=936926&r2=936927&view=diff
==============================================================================
--- portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloGroovyScriptPortlet.java (original)
+++ portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloGroovyScriptPortlet.java Thu Apr 22 16:11:35 2010
@@ -33,9 +33,10 @@ public class TestHelloGroovyScriptPortle
     protected Map<String, String> getPortletInitParameters()
     {
         Map<String, String> initParams = new HashMap<String, String>();
-        initParams.put("script-engine", "groovy");
-        initParams.put("script-source", "classpath:org/apache/portals/bridges/script/HelloGroovy.groovy");
-        initParams.put("auto-refresh", "true");
+        initParams.put(ScriptPortlet.ENGINE, "groovy");
+        initParams.put(ScriptPortlet.SOURCE, "classpath:org/apache/portals/bridges/script/HelloGroovy.groovy");
+        initParams.put(ScriptPortlet.VALIDATOR, "classpath:org/apache/portals/bridges/script/HelloGroovyPrefsValidator.groovy");
+        initParams.put(ScriptPortlet.AUTO_REFRESH, "true");
         return initParams;
     }
     
@@ -60,4 +61,22 @@ public class TestHelloGroovyScriptPortle
     {
         return "application/x-groovy";
     }
+    
+    @Override
+    public void testInit() throws Exception
+    {
+        super.testInit();
+    }
+    
+    @Override
+    public void testRender() throws Exception
+    {
+        super.testRender();
+    }
+    
+    @Override
+    public void testProcessAction() throws Exception
+    {
+        super.testProcessAction();
+    }
 }

Modified: portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloJRubyScriptPortlet.java
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloJRubyScriptPortlet.java?rev=936927&r1=936926&r2=936927&view=diff
==============================================================================
--- portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloJRubyScriptPortlet.java (original)
+++ portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloJRubyScriptPortlet.java Thu Apr 22 16:11:35 2010
@@ -33,9 +33,10 @@ public class TestHelloJRubyScriptPortlet
     protected Map<String, String> getPortletInitParameters()
     {
         Map<String, String> initParams = new HashMap<String, String>();
-        initParams.put("script-engine", "jruby");
-        initParams.put("script-source", "classpath:org/apache/portals/bridges/script/HelloJRuby.rb");
-        initParams.put("auto-refresh", "true");
+        initParams.put(ScriptPortlet.ENGINE, "jruby");
+        initParams.put(ScriptPortlet.SOURCE, "classpath:org/apache/portals/bridges/script/HelloJRuby.rb");
+        initParams.put(ScriptPortlet.VALIDATOR, "classpath:org/apache/portals/bridges/script/HelloJRubyPrefsValidator.rb");
+        initParams.put(ScriptPortlet.AUTO_REFRESH, "true");
         return initParams;
     }
     
@@ -60,4 +61,22 @@ public class TestHelloJRubyScriptPortlet
     {
         return "application/x-ruby";
     }
+    
+    @Override
+    public void testInit() throws Exception
+    {
+        super.testInit();
+    }
+    
+    @Override
+    public void testRender() throws Exception
+    {
+        super.testRender();
+    }
+    
+    @Override
+    public void testProcessAction() throws Exception
+    {
+        super.testProcessAction();
+    }
 }

Modified: portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloJythonScriptPortlet.java
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloJythonScriptPortlet.java?rev=936927&r1=936926&r2=936927&view=diff
==============================================================================
--- portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloJythonScriptPortlet.java (original)
+++ portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloJythonScriptPortlet.java Thu Apr 22 16:11:35 2010
@@ -33,10 +33,11 @@ public class TestHelloJythonScriptPortle
     protected Map<String, String> getPortletInitParameters()
     {
         Map<String, String> initParams = new HashMap<String, String>();
-        initParams.put("script-engine", "jython");
-        initParams.put("eval-portlet-key", "portlet");
-        initParams.put("script-source", "classpath:org/apache/portals/bridges/script/HelloJython.py");
-        initParams.put("auto-refresh", "true");
+        initParams.put(ScriptPortlet.ENGINE, "jython");
+        initParams.put(ScriptPortlet.EVAL_KEY, "value");
+        initParams.put(ScriptPortlet.SOURCE, "classpath:org/apache/portals/bridges/script/HelloJython.py");
+        initParams.put(ScriptPortlet.VALIDATOR, "classpath:org/apache/portals/bridges/script/HelloJythonPrefsValidator.py");
+        initParams.put(ScriptPortlet.AUTO_REFRESH, "true");
         return initParams;
     }
     
@@ -61,4 +62,22 @@ public class TestHelloJythonScriptPortle
     {
         return "application/x-jython";
     }
+    
+    @Override
+    public void testInit() throws Exception
+    {
+        super.testInit();
+    }
+    
+    @Override
+    public void testRender() throws Exception
+    {
+        super.testRender();
+    }
+    
+    @Override
+    public void testProcessAction() throws Exception
+    {
+        super.testProcessAction();
+    }
 }

Modified: portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloRhinoScriptPortlet.java
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloRhinoScriptPortlet.java?rev=936927&r1=936926&r2=936927&view=diff
==============================================================================
--- portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloRhinoScriptPortlet.java (original)
+++ portals/bridges/bridges-script/trunk/src/test/java/org/apache/portals/bridges/script/TestHelloRhinoScriptPortlet.java Thu Apr 22 16:11:35 2010
@@ -47,9 +47,10 @@ public class TestHelloRhinoScriptPortlet
     protected Map<String, String> getPortletInitParameters()
     {
         Map<String, String> initParams = new HashMap<String, String>();
-        initParams.put("script-engine", "rhino");
-        initParams.put("script-source", "classpath:org/apache/portals/bridges/script/HelloRhino.js");
-        initParams.put("auto-refresh", "true");
+        initParams.put(ScriptPortlet.ENGINE, "rhino");
+        initParams.put(ScriptPortlet.SOURCE, "classpath:org/apache/portals/bridges/script/HelloRhino.js");
+        initParams.put(ScriptPortlet.VALIDATOR, "classpath:org/apache/portals/bridges/script/HelloRhinoPrefsValidator.js");
+        initParams.put(ScriptPortlet.AUTO_REFRESH, "true");
         return initParams;
     }
     
@@ -76,7 +77,7 @@ public class TestHelloRhinoScriptPortlet
     }
     
     @Override
-    public void testInitialization() throws Exception
+    public void testInit() throws Exception
     {
         if (SystemUtils.isJavaVersionAtLeast(160))
         {
@@ -84,11 +85,11 @@ public class TestHelloRhinoScriptPortlet
             return;
         }
         
-        super.testInitialization();
+        super.testInit();
     }
     
     @Override
-    public void testHelloScriptPortlet() throws Exception
+    public void testRender() throws Exception
     {
         if (SystemUtils.isJavaVersionAtLeast(160))
         {
@@ -96,6 +97,18 @@ public class TestHelloRhinoScriptPortlet
             return;
         }
         
-        super.testHelloScriptPortlet();
+        super.testRender();
+    }
+    
+    @Override
+    public void testProcessAction() throws Exception
+    {
+        if (SystemUtils.isJavaVersionAtLeast(160))
+        {
+            System.out.println("[WARNING] Rhino script engine embedded in the default Java 1.6+ has not fully tested yet.");
+            return;
+        }
+        
+        super.testProcessAction();
     }
 }

Modified: portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloBeanShell.bsh
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloBeanShell.bsh?rev=936927&r1=936926&r2=936927&view=diff
==============================================================================
--- portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloBeanShell.bsh (original)
+++ portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloBeanShell.bsh Thu Apr 22 16:11:35 2010
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 import javax.portlet.GenericPortlet;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 
@@ -29,6 +31,12 @@ class HelloBeanShell extends GenericPort
         String greeting = "<H1>" + getTitle(request) + "</H1>";
         response.getWriter().println(greeting);
     }
+    
+    public void processAction(ActionRequest request, ActionResponse response)
+    {
+        request.getPreferences().setValue("message", request.getParameter("message"));
+        request.getPreferences().store();
+    }
 }
 
 // Return portlet instance as a last evaluated object

Added: portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloBeanShellPrefsValidator.bsh
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloBeanShellPrefsValidator.bsh?rev=936927&view=auto
==============================================================================
--- portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloBeanShellPrefsValidator.bsh (added)
+++ portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloBeanShellPrefsValidator.bsh Thu Apr 22 16:11:35 2010
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+import javax.portlet.PortletPreferences;
+import javax.portlet.PreferencesValidator;
+import javax.portlet.ValidatorException;
+
+/**
+ * @author <a href="mailto:woonsan@apache.org">Woonsan Ko</a>
+ * @version $Id$
+ */
+class HelloBeanShellPrefsValidator implements PreferencesValidator
+{
+    public void validate(PortletPreferences preferences)
+    {
+        String message = preferences.getValue("message", null);
+        
+        if (message == null)
+        {
+            // no idea on how to throw exception in beanshell
+            // just cause an intended exception here...
+            invalid_message = null;
+            invalid_message.length();
+        }
+    }
+}
+
+// Return validator instance as a last evaluated object
+new HelloBeanShellPrefsValidator();

Modified: portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloGroovy.groovy
URL: http://svn.apache.org/viewvc/portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloGroovy.groovy?rev=936927&r1=936926&r2=936927&view=diff
==============================================================================
--- portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloGroovy.groovy (original)
+++ portals/bridges/bridges-script/trunk/src/test/resources/org/apache/portals/bridges/script/HelloGroovy.groovy Thu Apr 22 16:11:35 2010
@@ -17,6 +17,8 @@
 package org.apache.portals.bridges.script;
 
 import javax.portlet.GenericPortlet;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 
@@ -31,6 +33,12 @@ public class HelloGroovy extends Generic
         String greeting = "<H1>" + getTitle(request) + "</H1>";
         response.getWriter().println(greeting);
     }
+    
+    public void processAction(ActionRequest request, ActionResponse response)
+    {
+        request.getPreferences().setValue("message", request.getParameter("message"));
+        request.getPreferences().store();
+    }
 }
 
 // Return portlet instance as a last evaluated object



---------------------------------------------------------------------
To unsubscribe, e-mail: bridges-commits-unsubscribe@portals.apache.org
For additional commands, e-mail: bridges-commits-help@portals.apache.org