https://issues.apache.org/jira/browse/EXTSCRIPT-154 removing old code
git-svn-id: https://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk@1300587 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/extscript-bundles/extscript-myfaces12-bundle/pom.xml b/extscript-bundles/extscript-myfaces12-bundle/pom.xml
deleted file mode 100644
index b92e4de..0000000
--- a/extscript-bundles/extscript-myfaces12-bundle/pom.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-<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>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-myfaces12-bundle</artifactId>
- <packaging>jar</packaging>
- <name>MyFaces Extension Scripting MyFaces 1.2 convenience meta bundle</name>
- <version>1.0.3-SNAPSHOT</version>
-
- <description>
- The meta bundle bundeling all needed core runtimes
- for a full myfaces 1.2.8+ build
- </description>
-
- <parent>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-bundles</artifactId>
- <version>1.0.3-SNAPSHOT</version>
- </parent>
-
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk/extscript-bundles/extscript-myfaces12-bundle</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk/extscript-bundles/extscript-myfaces12-bundle</developerConnection>
- <url>http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-bundles/extscript-myfaces12-bundle</url>
- </scm>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-core</artifactId>
- <version>1.0.3-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-core-java6</artifactId>
- <version>1.0.3-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-myfaces12-extensions</artifactId>
- <version>1.0.3-SNAPSHOT</version>
- </dependency>
- </dependencies>
-
- <!-- we use the maven shade plugin to bundle our subprojects into bundles -->
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>1.3.1</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <artifactSet>
- <includes>
- <artifact>org.apache.myfaces.extensions.scripting:extscript-core</artifact>
- <artifact>org.apache.myfaces.extensions.scripting:extscript-core-java6</artifact>
- <artifact>org.apache.myfaces.extensions.scripting:extscript-myfaces12-extensions</artifact>
- </includes>
- </artifactSet>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-
-</project>
diff --git a/extscript-bundles/extscript-myfaces20-bundle/pom.xml b/extscript-bundles/extscript-myfaces20-bundle/pom.xml
deleted file mode 100644
index 097ae99..0000000
--- a/extscript-bundles/extscript-myfaces20-bundle/pom.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-<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>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-myfaces20-bundle</artifactId>
- <packaging>jar</packaging>
- <name>MyFaces Extension Scripting MyFaces 2.0 convenience meta bundle</name>
- <version>1.0.3-SNAPSHOT</version>
-
- <description>
- The meta bundle bundeling all needed core runtimes
- for a full myfaces 2.0 build
- </description>
-
- <parent>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-bundles</artifactId>
- <version>1.0.3-SNAPSHOT</version>
- </parent>
-
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk/extscript-bundles/extscript-myfaces20-bundle</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk/extscript-bundles/extscript-myfaces20-bundle</developerConnection>
- <url>http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-bundles/extscript-myfaces20-bundle</url>
- </scm>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-core</artifactId>
- <version>1.0.3-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-core-java6</artifactId>
- <version>1.0.3-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-myfaces2-extensions</artifactId>
- <version>1.0.3-SNAPSHOT</version>
- </dependency>
- </dependencies>
-
- <!-- we use the maven shade plugin to bundle our subprojects into bundles -->
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>1.3.1</version>
- <!--
- todo use the shade plugin
- to rename references from
- util.shared_impl into impl
- -->
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <artifactSet>
- <includes>
- <artifact>org.apache.myfaces.extensions.scripting:extscript-core</artifact>
- <artifact>org.apache.myfaces.extensions.scripting:extscript-core-java6</artifact>
- <artifact>org.apache.myfaces.extensions.scripting:extscript-myfaces2-extensions</artifact>
- </includes>
- </artifactSet>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-
-</project>
diff --git a/extscript-bundles/extscript12-assembly/pom.xml b/extscript-bundles/extscript12-assembly/pom.xml
deleted file mode 100644
index a97ed87..0000000
--- a/extscript-bundles/extscript12-assembly/pom.xml
+++ /dev/null
@@ -1,164 +0,0 @@
-<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>
- <artifactId>extscript12-assembly</artifactId>
- <packaging>pom</packaging>
- <name>Apache MyFaces Extensions Scripting MyFaces 1.2 Assembly</name>
- <description>MyFaces Extensions Scripting Assembly is used to generate
- .zip and .tar.gz distributions
- </description>
-
- <parent>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-bundles</artifactId>
- <version>1.0.2-SNAPSHOT</version>
- </parent>
-
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk/extscript-bundles/extscript12-assembly</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk/extscript-bundles/extscript12-assembly</developerConnection>
- <url>http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-bundles/extscript12-assembly</url>
- </scm>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>dependency-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-javadoc</id>
- <phase>package</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-core</artifactId>
- <version>${version}</version>
- <classifier>javadoc</classifier>
- </artifactItem>
- <artifactItem>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-core-java6</artifactId>
- <version>${version}</version>
- <classifier>javadoc</classifier>
- </artifactItem>
-
- <artifactItem>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-myfaces12-extensions</artifactId>
- <version>${version}</version>
- <classifier>javadoc</classifier>
- </artifactItem>
-
- </artifactItems>
- <outputDirectory>${project.build.directory}/javadoc</outputDirectory>
- </configuration>
- </execution>
- <execution>
- <id>copy-source</id>
- <phase>package</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <artifactItems>
-
- <artifactItem>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-core</artifactId>
- <version>${version}</version>
- <classifier>sources</classifier>
- </artifactItem>
- <artifactItem>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-core-java6</artifactId>
- <version>${version}</version>
- <classifier>sources</classifier>
- </artifactItem>
-
- <artifactItem>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-myfaces12-extensions</artifactId>
- <version>${version}</version>
- <classifier>sources</classifier>
- </artifactItem>
-
- </artifactItems>
- <outputDirectory>${project.build.directory}/src</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <!-- EXECUTE mvn package to generate assembly files -->
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>make_assembly_src</id>
- <configuration>
- <descriptors>
- <descriptor>src/main/assembly/coresrc.xml</descriptor>
- </descriptors>
- <finalName>myfaces-extscript12-${version}-src</finalName>
- <appendAssemblyId>false</appendAssemblyId>
- <outputDirectory>target/assembly/out</outputDirectory>
- <workDirectory>target/assembly/work</workDirectory>
- </configuration>
- <phase>package</phase>
- <goals>
- <goal>attached</goal>
- </goals>
- </execution>
- <execution>
- <id>make_assembly_bin</id>
- <configuration>
- <descriptors>
- <descriptor>${basedir}/src/main/assembly/corebin.xml</descriptor>
- </descriptors>
- <finalName>myfaces-extscript12-${version}-bin</finalName>
- <appendAssemblyId>false</appendAssemblyId>
- <outputDirectory>target/assembly/out</outputDirectory>
- <workDirectory>target/assembly/work</workDirectory>
- </configuration>
- <phase>package</phase>
- <goals>
- <goal>attached</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencies>
-
-
- <dependency>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-core</artifactId>
- <version>1.0.2-SNAPSHOT</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-core-java6</artifactId>
- <version>1.0.2-SNAPSHOT</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-myfaces12-extensions</artifactId>
- <version>1.0.2-SNAPSHOT</version>
- <scope>compile</scope>
- </dependency>
-
- </dependencies>
-
- <properties>
- <version>1.0.2-SNAPSHOT</version>
- </properties>
-</project>
diff --git a/extscript-bundles/extscript12-assembly/src/main/assembly/corebin.xml b/extscript-bundles/extscript12-assembly/src/main/assembly/corebin.xml
deleted file mode 100644
index cb6795b..0000000
--- a/extscript-bundles/extscript12-assembly/src/main/assembly/corebin.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<assembly>
- <id>corebin</id>
- <formats>
- <format>tar.gz</format>
- <format>zip</format>
- </formats>
- <dependencySets>
- <dependencySet>
- <outputDirectory>lib</outputDirectory>
- <scope>runtime</scope>
- </dependencySet>
- </dependencySets>
- <fileSets>
- <fileSet>
- <directory>src/main/resources</directory>
- <outputDirectory></outputDirectory>
- <includes>
- <include>README*</include>
- <include>LICENSE*</include>
- <include>NOTICE*</include>
- <include>RELEASE*</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>target/javadoc</directory>
- <outputDirectory>javadoc</outputDirectory>
- <includes>
- <include>*.jar</include>
- </includes>
- </fileSet>
- </fileSets>
-</assembly>
diff --git a/extscript-bundles/extscript12-assembly/src/main/assembly/coresrc.xml b/extscript-bundles/extscript12-assembly/src/main/assembly/coresrc.xml
deleted file mode 100644
index 11918ba..0000000
--- a/extscript-bundles/extscript12-assembly/src/main/assembly/coresrc.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<assembly>
- <id>coresrc</id>
- <formats>
- <format>tar.gz</format>
- <format>zip</format>
- </formats>
- <fileSets>
- <fileSet>
- <directory>src/main/resources</directory>
- <outputDirectory></outputDirectory>
- <includes>
- <include>README*</include>
- <include>LICENSE*</include>
- <include>NOTICE*</include>
- <include>RELEASE*</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>target/src</directory>
- <outputDirectory>src</outputDirectory>
- <includes>
- <include>*.jar</include>
- </includes>
- </fileSet>
- </fileSets>
-</assembly>
-
diff --git a/extscript-bundles/extscript12-assembly/src/main/resources/LICENSE.txt b/extscript-bundles/extscript12-assembly/src/main/resources/LICENSE.txt
deleted file mode 100644
index dd5b3a5..0000000
--- a/extscript-bundles/extscript12-assembly/src/main/resources/LICENSE.txt
+++ /dev/null
@@ -1,174 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
diff --git a/extscript-bundles/extscript12-assembly/src/main/resources/NOTICE.txt b/extscript-bundles/extscript12-assembly/src/main/resources/NOTICE.txt
deleted file mode 100644
index e9a0e16..0000000
--- a/extscript-bundles/extscript12-assembly/src/main/resources/NOTICE.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-Apache MyFaces Extensions Scripting
-Copyright 2007-2010 The Apache Software Foundation
-
-This product includes software developed by
-The Apache Software Foundation (http://www.apache.org/).
-
-------------------------------------------------------------------------
-See the file LICENSE.txt
-------------------------------------------------------------------------
\ No newline at end of file
diff --git a/extscript-bundles/extscript20-assembly/pom.xml b/extscript-bundles/extscript20-assembly/pom.xml
deleted file mode 100644
index 795e4c7..0000000
--- a/extscript-bundles/extscript20-assembly/pom.xml
+++ /dev/null
@@ -1,164 +0,0 @@
-<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>
- <artifactId>extscript20-assembly</artifactId>
- <packaging>pom</packaging>
- <name>Apache MyFaces Extensions Scripting MyFaces 2.0 Assembly</name>
- <description>MyFaces Extensions Scripting Assembly is used to generate
- .zip and .tar.gz distributions
- </description>
-
- <parent>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-bundles</artifactId>
- <version>1.0.2-SNAPSHOT</version>
- </parent>
-
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk/extscript-bundles/extscript20-assembly</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk/extscript-bundles/extscript20-assembly</developerConnection>
- <url>http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-bundles/extscript20-assembly</url>
- </scm>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>dependency-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-javadoc</id>
- <phase>package</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-core</artifactId>
- <version>${version}</version>
- <classifier>javadoc</classifier>
- </artifactItem>
- <artifactItem>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-core-java6</artifactId>
- <version>${version}</version>
- <classifier>javadoc</classifier>
- </artifactItem>
-
- <artifactItem>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-myfaces12-extensions</artifactId>
- <version>${version}</version>
- <classifier>javadoc</classifier>
- </artifactItem>
-
- </artifactItems>
- <outputDirectory>${project.build.directory}/javadoc</outputDirectory>
- </configuration>
- </execution>
- <execution>
- <id>copy-source</id>
- <phase>package</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <artifactItems>
-
- <artifactItem>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-core</artifactId>
- <version>${version}</version>
- <classifier>sources</classifier>
- </artifactItem>
- <artifactItem>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-core-java6</artifactId>
- <version>${version}</version>
- <classifier>sources</classifier>
- </artifactItem>
-
- <artifactItem>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-myfaces12-extensions</artifactId>
- <version>${version}</version>
- <classifier>sources</classifier>
- </artifactItem>
-
- </artifactItems>
- <outputDirectory>${project.build.directory}/src</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <!-- EXECUTE mvn package to generate assembly files -->
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>make_assembly_src</id>
- <configuration>
- <descriptors>
- <descriptor>src/main/assembly/coresrc.xml</descriptor>
- </descriptors>
- <finalName>myfaces-extscript20-${version}-src</finalName>
- <appendAssemblyId>false</appendAssemblyId>
- <outputDirectory>target/assembly/out</outputDirectory>
- <workDirectory>target/assembly/work</workDirectory>
- </configuration>
- <phase>package</phase>
- <goals>
- <goal>attached</goal>
- </goals>
- </execution>
- <execution>
- <id>make_assembly_bin</id>
- <configuration>
- <descriptors>
- <descriptor>${basedir}/src/main/assembly/corebin.xml</descriptor>
- </descriptors>
- <finalName>myfaces-extscript20-${version}-bin</finalName>
- <appendAssemblyId>false</appendAssemblyId>
- <outputDirectory>target/assembly/out</outputDirectory>
- <workDirectory>target/assembly/work</workDirectory>
- </configuration>
- <phase>package</phase>
- <goals>
- <goal>attached</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencies>
-
-
- <dependency>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-core</artifactId>
- <version>1.0-SNAPSHOT</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-core-java6</artifactId>
- <version>1.0-SNAPSHOT</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-myfaces2-extensions</artifactId>
- <version>1.0-SNAPSHOT</version>
- <scope>compile</scope>
- </dependency>
-
- </dependencies>
-
- <properties>
- <version>1.0-SNAPSHOT</version>
- </properties>
-</project>
diff --git a/extscript-bundles/extscript20-assembly/src/main/assembly/corebin.xml b/extscript-bundles/extscript20-assembly/src/main/assembly/corebin.xml
deleted file mode 100644
index cb6795b..0000000
--- a/extscript-bundles/extscript20-assembly/src/main/assembly/corebin.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<assembly>
- <id>corebin</id>
- <formats>
- <format>tar.gz</format>
- <format>zip</format>
- </formats>
- <dependencySets>
- <dependencySet>
- <outputDirectory>lib</outputDirectory>
- <scope>runtime</scope>
- </dependencySet>
- </dependencySets>
- <fileSets>
- <fileSet>
- <directory>src/main/resources</directory>
- <outputDirectory></outputDirectory>
- <includes>
- <include>README*</include>
- <include>LICENSE*</include>
- <include>NOTICE*</include>
- <include>RELEASE*</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>target/javadoc</directory>
- <outputDirectory>javadoc</outputDirectory>
- <includes>
- <include>*.jar</include>
- </includes>
- </fileSet>
- </fileSets>
-</assembly>
diff --git a/extscript-bundles/extscript20-assembly/src/main/assembly/coresrc.xml b/extscript-bundles/extscript20-assembly/src/main/assembly/coresrc.xml
deleted file mode 100644
index 11918ba..0000000
--- a/extscript-bundles/extscript20-assembly/src/main/assembly/coresrc.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<assembly>
- <id>coresrc</id>
- <formats>
- <format>tar.gz</format>
- <format>zip</format>
- </formats>
- <fileSets>
- <fileSet>
- <directory>src/main/resources</directory>
- <outputDirectory></outputDirectory>
- <includes>
- <include>README*</include>
- <include>LICENSE*</include>
- <include>NOTICE*</include>
- <include>RELEASE*</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>target/src</directory>
- <outputDirectory>src</outputDirectory>
- <includes>
- <include>*.jar</include>
- </includes>
- </fileSet>
- </fileSets>
-</assembly>
-
diff --git a/extscript-bundles/extscript20-assembly/src/main/resources/LICENSE.txt b/extscript-bundles/extscript20-assembly/src/main/resources/LICENSE.txt
deleted file mode 100644
index dd5b3a5..0000000
--- a/extscript-bundles/extscript20-assembly/src/main/resources/LICENSE.txt
+++ /dev/null
@@ -1,174 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
diff --git a/extscript-bundles/extscript20-assembly/src/main/resources/NOTICE.txt b/extscript-bundles/extscript20-assembly/src/main/resources/NOTICE.txt
deleted file mode 100644
index e9a0e16..0000000
--- a/extscript-bundles/extscript20-assembly/src/main/resources/NOTICE.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-Apache MyFaces Extensions Scripting
-Copyright 2007-2010 The Apache Software Foundation
-
-This product includes software developed by
-The Apache Software Foundation (http://www.apache.org/).
-
-------------------------------------------------------------------------
-See the file LICENSE.txt
-------------------------------------------------------------------------
\ No newline at end of file
diff --git a/extscript-bundles/pom.xml b/extscript-bundles/pom.xml
deleted file mode 100644
index b5b6d65..0000000
--- a/extscript-bundles/pom.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<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>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-bundles</artifactId>
- <packaging>pom</packaging>
- <name>MyFaces Extension Scripting meta bundles</name>
- <version>1.0.3-SNAPSHOT</version>
-
- <description>
- Meta bundles bundling the various ext-script
- combinations into one coherent package per
- jsf version
- </description>
-
- <parent>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-root</artifactId>
- <version>1.0.3-SNAPSHOT</version>
- </parent>
-
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk/extscript-bundles</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk/extscript-bundles</developerConnection>
- <url>http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-bundles</url>
- </scm>
-
- <modules>
- <module>extscript-myfaces12-bundle</module>
- <module>extscript-myfaces20-bundle</module>
- </modules>
-
-
- <profiles>
- <!-- This profile is invoked by -DprepareRelease=true. This allows mvn release:prepare to
- run successfully on the assembly projects. -->
- <profile>
- <id>prepare-release</id>
- <activation>
- <property>
- <name>prepareRelease</name>
- </property>
- </activation>
- <modules>
- <module>extscript12-assembly</module>
- <module>extscript20-assembly</module>
- </modules>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-release-plugin</artifactId>
- <configuration>
- <arguments>-DprepareRelease</arguments>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-</project>
diff --git a/extscript-core-root/extscript-core/src/main_old/groovy/org/apache/myfaces/extensions/scripting/groovyloader/core/GroovyGlobalReloadingStrategy.groovy b/extscript-core-root/extscript-core/src/main_old/groovy/org/apache/myfaces/extensions/scripting/groovyloader/core/GroovyGlobalReloadingStrategy.groovy
deleted file mode 100644
index 6b6e156..0000000
--- a/extscript-core-root/extscript-core/src/main_old/groovy/org/apache/myfaces/extensions/scripting/groovyloader/core/GroovyGlobalReloadingStrategy.groovy
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.apache.myfaces.extensions.scripting.groovyloader.core
-
-import org.apache.myfaces.extensions.scripting.api.ReloadingStrategy
-import org.apache.myfaces.extensions.scripting.core.reloading.SimpleReloadingStrategy
-import org.apache.myfaces.extensions.scripting.api.BaseWeaver
-import org.apache.myfaces.extensions.scripting.core.reloading.NoMappingReloadingStrategy
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-
-/**
- * Reloading strategy for the groovy
- * connectors
- *
- * Groovy has a different behavior, because
- * every attribute normally is reachable even
- * some introspection ones which under no circumstances
- * should be overwritten
- *
- * so er have to set the all others instance var to a specialized reloading strategy
- * and cope with the rest the standard java way by not doing anything
- *
- */
-public class GroovyGlobalReloadingStrategy extends org.apache.myfaces.extensions.scripting.core.reloading.GlobalReloadingStrategy {
-
- //we cannot use a constructor here to bypass a groovy bug
- //we use an explicit call to setWeaver instead
-
- public GroovyGlobalReloadingStrategy() {
- super();
- _allOthers = new StandardGroovyReloadingStrategy()
- }
-
- public void setWeaver(ScriptingWeaver weaver) {
- super.setWeaver(weaver)
- _allOthers.setWeaver(weaver)
- }
-
-}
\ No newline at end of file
diff --git a/extscript-core-root/extscript-core/src/main_old/groovy/org/apache/myfaces/extensions/scripting/groovyloader/core/readme.txt b/extscript-core-root/extscript-core/src/main_old/groovy/org/apache/myfaces/extensions/scripting/groovyloader/core/readme.txt
deleted file mode 100644
index f2de993..0000000
--- a/extscript-core-root/extscript-core/src/main_old/groovy/org/apache/myfaces/extensions/scripting/groovyloader/core/readme.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-This is the core of the groovy loader
-we have two things in here
-a groovy proxy which allows the reloading
-of groovy objects loaded via our classloader under certain circumstances
-The proxy on the groovy side loads itself into the class metadata
-so that the objects under the best circumstances
-can run new code or run a new instance
-
-
-secondly our threaded filewatcher
-and object reloader
-which checks if files have changed and then reloads
-objects wherever possible
-
-
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/AnnotationScanListener.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/AnnotationScanListener.java
deleted file mode 100644
index d4f07e3..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/AnnotationScanListener.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.api;
-
-import java.lang.annotation.Annotation;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * We use a source code artifact observer here to register the
- * meta data in the correct registry entries
- */
-
-public interface AnnotationScanListener extends ClassScanListener {
-
- /**
- * returns true if the annotation marked by the incoming parameter is supported by this scanner
- *
- * @param annotation the supported annotation as neutral string representation of its class
- * @return in case of support
- */
- public boolean supportsAnnotation(String annotation);
-
- /**
- * returns true if the annotation marked by the incoming parameter is supported by this scanner
- *
- * @param annotation the supported annotation as neutral string representation of its class
- * @return in case of support
- */
- public boolean supportsAnnotation(Class annotation);
-
-
- /**
- * Class file registration of the supported annotation
- *
- * @param clazz the class to be registered
- * @param annotationName the annotation for the class
- */
- public void register(Class clazz, Annotation annotationName);
-
- /**
- * Purges the class from the correct places of the myfaces registry
- * so that the artifact is not reachable anymore
- *
- * @param className the class name for the class which needs to be purged
- */
- public void purge(String className);
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/BaseWeaver.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/BaseWeaver.java
deleted file mode 100644
index 55bb93a..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/BaseWeaver.java
+++ /dev/null
@@ -1,564 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.api;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.myfaces.extensions.scripting.core.reloading.GlobalReloadingStrategy;
-import org.apache.myfaces.extensions.scripting.core.util.ClassUtils;
-import org.apache.myfaces.extensions.scripting.core.util.FileUtils;
-import org.apache.myfaces.extensions.scripting.core.util.StringUtils;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.monitor.ClassResource;
-import org.apache.myfaces.extensions.scripting.monitor.RefreshContext;
-import org.apache.myfaces.extensions.scripting.api.extensionevents.FullRecompileRecommended;
-import org.apache.myfaces.extensions.scripting.api.extensionevents.FullScanRecommended;
-
-import javax.faces.context.FacesContext;
-import java.io.File;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Refactored the common weaver code into a base class
- * <p/>
- * Note we added a bean dropping code, the bean dropping works that way
- * if we are the first request after a compile issued
- * we drop all beans
- * <p/>
- * every other request has to drop only the session
- * and custom scoped beans
- * <p/>
- * we set small mutexes to avoid at least in our code synchronisation issues
- * the mutexes are as atomic as possible to avoid speed problems.
- * <p/>
- * Unfortunately if someone alters the bean map from outside while we reload
- * we for now cannot do anything until we have covered that in the myfaces core!
- * <p/>
- * Since all weavers are application scoped we can handle the mutexes properly *
- *
- * @author Werner Punz
- * <p/>
- * <p/>
- * TODO once we have moved over to asynchronous compilation
- * we can drop a load of the local code
- */
-public abstract class BaseWeaver implements ScriptingWeaver {
-
- /**
- * only be set from the
- * initialisation code so no thread safety needed
- */
-
- protected ReloadingStrategy _reloadingStrategy = null;
-
- protected DynamicCompiler _compiler = null;
- protected ClassScanner _annotationScanner = null;
- protected ClassScanner _dependencyScanner = null;
-
- private BeanHandler _beanHandler;
- protected String _classPath = "";
-
- Logger _log = Logger.getLogger(this.getClass().getName());
-
- private String _fileEnding = null;
- private int _scriptingEngine = ScriptingConst.ENGINE_TYPE_JSF_NO_ENGINE;
-
- public BaseWeaver() {
- _reloadingStrategy = new GlobalReloadingStrategy(this);
- _beanHandler = new MyFacesBeanHandler(getScriptingEngine());
- }
-
- public BaseWeaver(String fileEnding, int scriptingEngine) {
- this._fileEnding = fileEnding;
- this._scriptingEngine = scriptingEngine;
- _reloadingStrategy = new GlobalReloadingStrategy(this);
- _beanHandler = new MyFacesBeanHandler(getScriptingEngine());
- }
-
- /**
- * add custom source lookup paths
- *
- * @param scriptPath the new path which has to be added
- */
- public void appendCustomScriptPath(String scriptPath) {
- String normalizedScriptPath = FilenameUtils.normalize(scriptPath);
- if (normalizedScriptPath.endsWith(File.separator)) {
- normalizedScriptPath = normalizedScriptPath.substring(0, normalizedScriptPath.length() - File.separator.length());
- }
-
- WeavingContext.getConfiguration().addSourceDir(getScriptingEngine(), normalizedScriptPath);
- if (_annotationScanner != null) {
- _annotationScanner.addScanPath(normalizedScriptPath);
- }
- _dependencyScanner.addScanPath(normalizedScriptPath);
- }
-
- /**
- * condition which marks a metadata as reload candidate
- *
- * @param reloadMeta the metadata to be investigated for reload candidacy
- * @return true if it is a reload candidate
- */
- private boolean isReloadCandidate(ClassResource reloadMeta) {
- return reloadMeta != null && assertScriptingEngine(reloadMeta) && reloadMeta.getRefreshAttribute().getRequestedRefreshDate() != 0L;
- }
-
- /**
- * helper for accessing the reloading metadata map
- *
- * @return a map with the class name as key and the reloading meta data as value
- */
- protected Map<String, ClassResource> getClassMap() {
- return WeavingContext.getFileChangedDaemon().getClassMap();
- }
-
- /**
- * reloads a scripting instance object
- *
- * @param scriptingInstance the object which has to be reloaded
- * @param artifactType integer value indication which type of JSF artifact we have to deal with
- * @return the reloaded object with all properties transferred or the original object if no reloading was needed
- */
- public Object reloadScriptingInstance(Object scriptingInstance, int artifactType) {
- Map<String, ClassResource> classMap = getClassMap();
- if (classMap.size() == 0) {
- return scriptingInstance;
- }
-
- //TODO reload candidate does not necessarily need to
- //parse the meta data we also can work
- //over the class information
-
- //the main problem is we need the meta data
- //for the graph refreshing, so we probably
- //have to keep it that way
- ClassResource reloadMeta = classMap.get(scriptingInstance.getClass().getName());
- try {
- //This gives a minor speedup because we jump out as soon as possible
- //files never changed do not even have to be considered
- //not tainted even once == not even considered to be reloaded
- if (isReloadCandidate(reloadMeta)) {
-
- Object reloaded = _reloadingStrategy.reload(scriptingInstance, artifactType);
- if (reloaded != null) {
- return reloaded;
- }
-
- }
- return scriptingInstance;
- } finally {
- //just in case the executed refresh is not triggered by
- //the classloader we issue another timestamp here
- reloadMeta.getRefreshAttribute().executedRefresh();
- }
-
- }
-
- /**
- * reweaving of an existing woven class
- * by reloading its file contents and then reweaving it
- */
- public Class reloadScriptingClass(Class aclass) {
-
- ClassResource metadata = getClassMap().get(aclass.getName());
-
- if (metadata == null)
- return aclass;
-
- if (!assertScriptingEngine(metadata)) {
- return null;
- }
-
- if (!metadata.getRefreshAttribute().requiresRefresh()) {
- //if not tainted then we can recycle the last class loaded
- return metadata.getAClass();
- }
- synchronized (RefreshContext.COMPILE_SYNC_MONITOR) {
- //another chance just in case someone has reloaded between
- //the last if and synchronized, that way we can reduce the number of waiting threads
- if (!metadata.getRefreshAttribute().requiresRefresh()) {
- //if not tainted then we can recycle the last class loaded
- return metadata.getAClass();
- }
-
- return loadScriptingClassFromFile(metadata.getSourceDir(), metadata.getSourceFile());
- }
- }
-
- /**
- * recompiles and loads a scripting class from a given class name
- *
- * @param className the class name including the package
- * @return a valid class if the sources could be found null if nothing could be found
- */
- public Class loadScriptingClassFromName(String className) {
-
- Map<String, ClassResource> classMap = getClassMap();
- ClassResource metadata = classMap.get(className);
- if (metadata == null) {
- String separator = FileUtils.getFileSeparatorForRegex();
- String fileName = className.replaceAll("\\.", separator) + getFileEnding();
-
- for (String pathEntry : WeavingContext.getConfiguration().getSourceDirs(getScriptingEngine())) {
- /**
- * the reload has to be performed synchronized
- * hence there is no chance to do it unsynchronized
- */
- synchronized (RefreshContext.COMPILE_SYNC_MONITOR) {
- Class retVal = loadScriptingClassFromFile(pathEntry, fileName);
- if (retVal != null) {
- return retVal;
- }
- }
- }
-
- } else {
- return reloadScriptingClass(metadata.getAClass());
- }
- return null;
- }
-
- protected boolean assertScriptingEngine(ClassResource reloadMeta) {
- return reloadMeta.getScriptingEngine() == getScriptingEngine();
- }
-
- public String getFileEnding() {
- return _fileEnding;
- }
-
- @SuppressWarnings("unused")
- public void setFileEnding(String fileEnding) {
- this._fileEnding = fileEnding;
- }
-
- public final int getScriptingEngine() {
- return _scriptingEngine;
- }
-
- @SuppressWarnings("unused")
- public void setScriptingEngine(int scriptingEngine) {
- this._scriptingEngine = scriptingEngine;
- }
-
- public abstract boolean isDynamic(Class clazz);
-
- public ScriptingWeaver getWeaverInstance(Class weaverClass) {
- if (getClass().equals(weaverClass)) return this;
-
- return null;
- }
-
- /**
- * full scan, scans for all artifacts in all files
- */
- public void fullClassScan() {
-
- WeavingContext.getExtensionEventRegistry().sendEvent(new FullScanRecommended());
-
- //now we scan the classes which are under our domain
- _dependencyScanner.scanPaths();
-
-
- }
-
- public void postStartupActions() {
- if (WeavingContext.getRefreshContext().isRecompileRecommended(getScriptingEngine())) {
- // we set a lock over the compile and bean refresh
- //and an inner check again to avoid unneeded compile triggers
- synchronized (RefreshContext.BEAN_SYNC_MONITOR) {
- if (WeavingContext.getConfiguration().isInitialCompile() && WeavingContext.getRefreshContext().isRecompileRecommended(getScriptingEngine())) {
- recompileRefresh();
- return;
- }
- }
- }
- _beanHandler.personalScopeRefresh();
- }
-
- public void requestRefresh() {
- if (WeavingContext.getRefreshContext().isRecompileRecommended(getScriptingEngine())) {
- // we set a lock over the compile and bean refresh
- //and an inner check again to avoid unneeded compile triggers
- synchronized (RefreshContext.BEAN_SYNC_MONITOR) {
- if (WeavingContext.getRefreshContext().isRecompileRecommended(getScriptingEngine())) {
- //TODO move this over to application events once they are in place
- WeavingContext.getRequestMap().put("REFRESH_JSF_PHASE", Boolean.TRUE);
- //
-
- recompileRefresh();
- return;
- }
- }
- }
-
-
- }
-
- public void jsfRequestRefresh() {
- if (WeavingContext.getRequestMap().get("REFRESH_JSF_PHASE") != null) {
- clearExtvalCache();
-
- /*
- * we scan all intra bean dependencies
- * which are not covered by our
- * class dependency scan
- */
- _beanHandler.scanDependencies();
-
- /*
- * Now it is time to refresh the tainted managed beans
- * by now we should have a good grasp about which beans
- * need to to be refreshed (note we cannot cover all corner cases
- * but our extended dependency scan should be able to cover
- * most refreshing cases.
- */
- _beanHandler.refreshAllManagedBeans();
- }
- if(_annotationScanner != null)
- _annotationScanner.scanPaths();
-
-
- _beanHandler.personalScopeRefresh();
- }
-
- /**
- * this clears the attached EXT-VAL cache in case of a refresh,
- * note this is a temporarily hack once our application
- * event system is in place this will be moved over to a specialized event handler
- * <p/>
- * TODO move this call into a phase listener
- */
- private void clearExtvalCache() {
-
- Map fcRequestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
- //TODO do this for the faces context in a phase listener
-
-
- if (fcRequestMap.containsKey(ScriptingConst.EXT_VAL_REQ_KEY)) {
- return;
- }
- //we have to remove the Validator Factory to clear its cache
- //ext-val does basically the same with a replacement one
- //but in case of a normal bean validation impl this has to be done
- //this is somewhat brute force, but it will be tested it it works out
-
- fcRequestMap.put(ScriptingConst.EXT_VAL_REQ_KEY, Boolean.TRUE);
-
- Set<String> keySet = WeavingContext.getApplicationMap().keySet();
- boolean extValPresent = false;
- for (String key : keySet) {
- if (key.startsWith(ScriptingConst.EXT_VAL_MARKER)) {
- WeavingContext.getApplicationMap().remove(key);
- extValPresent = true;
- }
- }
- if (!extValPresent) {
- fcRequestMap.remove("javax.faces.validator.beanValidator.ValidatorFactory");
- }
- }
-
- /**
- * Loads a list of possible dynamic classNames
- * for this scripting engine
- *
- * @return a list of classNames which are dynamic classes
- * for the current compile state on the filesystem
- */
- public Collection<String> loadPossibleDynamicClasses() {
-
- Collection<String> scriptPaths = WeavingContext.getConfiguration().getSourceDirs(getScriptingEngine());
- List<String> retVal = new LinkedList<String>();
-
- for (String scriptPath : scriptPaths) {
- List<File> tmpList = FileUtils.fetchSourceFiles(new File(scriptPath), "*" + getFileEnding());
- int lenRoot = scriptPath.length();
- //ok O(n2) but we are lazy for now if this imposes a problem we can flatten the inner loop out
- for (File sourceFile : tmpList) {
- String relativeFile = sourceFile.getAbsolutePath().substring(lenRoot + 1);
- String className = ClassUtils.relativeFileToClassName(relativeFile);
- retVal.add(className);
- }
- }
- return retVal;
-
- }
-
- public void fullRecompile() {
-
- if (isFullyRecompiled() || !isRecompileRecommended()) {
- return;
- }
-
- //we now issue the full recompile event here:
- WeavingContext.getExtensionEventRegistry().sendEvent(new FullRecompileRecommended(getScriptingEngine()));
-
- //we now issue the recompile for the resources under our domain, TODO it might be wise to move that to an event listener as well
-
- if (_compiler == null) {
- _compiler = instantiateCompiler();//new ReflectCompilerFacade();
- }
-
- for (String scriptPath : WeavingContext.getConfiguration().getSourceDirs(getScriptingEngine())) {
- //compile via javac dynamically, also after this block dynamic compilation
- //for the entire length of the request,
- try {
- if (!StringUtils.isBlank(scriptPath))
- _compiler.compileAllFiles(scriptPath, _classPath);
- } catch (ClassNotFoundException e) {
- _log.logp(Level.SEVERE, "BaseWeaver", "fullyRecompile", e.getMessage(), e);
- }
-
- }
-
- markAsFullyRecompiled();
- }
-
- protected boolean isRecompileRecommended() {
- return WeavingContext.getRefreshContext().isRecompileRecommended(getScriptingEngine());
- }
-
- protected boolean isFullyRecompiled() {
- try {
- return WeavingContext.getRequestMap() != null && WeavingContext.getRequestMap().containsKey(this.getClass().getName() + "_recompiled");
- } catch (UnsupportedOperationException ex) {
- //still in startup
- return false;
- }
- }
-
- public void markAsFullyRecompiled() {
- try {
- FacesContext context = FacesContext.getCurrentInstance();
- if (context != null) {
- //mark the request as tainted with recompile
- Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
- requestMap.put(this.getClass().getName() + "_recompiled", Boolean.TRUE);
- }
- } catch (UnsupportedOperationException ex) {
- }
-
- touchTaintedClasses();
- WeavingContext.getRefreshContext().setRecompileRecommended(getScriptingEngine(), Boolean.FALSE);
- }
-
- /**
- * helper which returns all tainted classes
- *
- * @return the tainted classes
- */
- private void touchTaintedClasses() {
- for (Map.Entry<String, ClassResource> it : WeavingContext.getFileChangedDaemon().getClassMap().entrySet()) {
- if (it.getValue().getScriptingEngine() == getScriptingEngine() && it.getValue().getRefreshAttribute().requiresRefresh()) {
- FileUtils.touch(ClassUtils.classNameToFile(WeavingContext.getConfiguration().getCompileTarget().getAbsolutePath(), it.getValue().getAClass().getName()));
- }
- }
- }
-
-
- /**
- * loads a class from a given sourceroot and filename
- * note this method does not have to be thread safe
- * it is called in a thread safe manner by the base class
- * <p/>
- *
- * @param sourceRoot the source search lookup path
- * @param file the filename to be compiled and loaded
- * @return a valid class if it could be found, null if none was found
- */
- protected Class loadScriptingClassFromFile(String sourceRoot, String file) {
- //we load the scripting class from the given className
- File currentSourceFile = new File(sourceRoot + File.separator + file);
- if (!currentSourceFile.exists()) {
- return null;
- }
-
- if (_log.isLoggable(Level.INFO)) {
- _log.info(getLoadingInfo(file));
- }
-
- Class retVal = null;
-
- try {
- //we initialize the compiler lazy
- //because the facade itself is lazy
- if (_compiler == null) {
- _compiler = instantiateCompiler();//new ReflectCompilerFacade();
- }
- retVal = _compiler.loadClass(sourceRoot, _classPath, file);
-
- if (retVal == null) {
- return retVal;
- }
- } catch (ClassNotFoundException e) {
- //can be safely ignored
- if (_log.isLoggable(Level.FINEST)) {
- _log.log(Level.FINEST, "loadScriptingClassFromFile(), can be ignored", e);
- }
- }
-
- //no refresh needed because this is done in the case of java already by
- //the classloader
- // if (retVal != null) {
- // refreshReloadingMetaData(sourceRoot, file, currentClassFile, retVal, ScriptingConst.ENGINE_TYPE_JSF_JAVA);
- // }
-
- /**
- * we now scan the return value and update its configuration parameters if needed
- * this can help to deal with method level changes of class files like managed properties
- * or scope changes from shorter running scopes to longer running ones
- * if the annotation has been moved the class will be de-registered but still delivered for now
- *
- * at the next refresh the second step of the registration cycle should pick the new class up
- *
- */
- try {
- if (!scanAnnotation.containsKey(retVal.getName()) && _annotationScanner != null && FacesContext.getCurrentInstance() != null && retVal != null) {
- scanAnnotation.put(retVal.getName(), "");
- _annotationScanner.scanClass(retVal);
- }
- } finally {
- scanAnnotation.remove(retVal.getName());
- }
-
- return retVal;
- }
-
- //blocker to prevent recursive calls to the annotation scan which can be triggered by subsequent calls of scanAnnotation and loadClass
- //a simple boolean check does not suffice here because scanClass might trigger subsequent calls to other classes
- Map<String, String> scanAnnotation = new ConcurrentHashMap<String, String>();
-
- private void recompileRefresh() {
- synchronized (RefreshContext.COMPILE_SYNC_MONITOR) {
- fullRecompile();
- //we update our dependencies and annotation info prior to going
- //into the refresh cycle
-
- fullClassScan();
- }
-
-
- }
-
- protected abstract DynamicCompiler instantiateCompiler();
-
- protected abstract String getLoadingInfo(String file);
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/BeanHandler.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/BeanHandler.java
deleted file mode 100644
index a3f3436..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/BeanHandler.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.api;
-
-/**
- * interface for a bean handler
- * which in the long run will allow
- * to hook different frameworks into the core
- * (aka Mojarra, MyFaces)
- */
-public interface BeanHandler {
-
- /**
- * scans all bean dependencies according to
- * their IoC information stored by the runtime
- * (in our case the MyFaces runtime config)
- * and adds those into our backward referencing dependency map
- * to add further dependency information on IoC level
- * (we can have IoC dependencies which are bound by object
- * types, this is a corner case but it still can happen)
- */
- public void scanDependencies();
-
- /**
- * refreshes all managed beans,
- * Application, Session,Request and Custom beans
- * <p/>
- * internally a check is performed whether the refresh has to be done or not
- */
- public void refreshAllManagedBeans();
-
- /**
- * refreshes all personal scoped beans (aka beans which
- * have an assumed lifecycle <= session)
- * <p/>
- * This is needed for multiuser purposes because if one user alters some beans
- * other users have to drop their non application scoped beans as well!
- * <p/>
- * internally a check is performed whether the refresh has to be performed or not
- */
- public void personalScopeRefresh();
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/ClassScanListener.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/ClassScanListener.java
deleted file mode 100644
index 317cb1a..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/ClassScanListener.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.api;
-
-/**
- * Observer interface which will be the base
- * of a future event system
- * (note currently unused)
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-public interface ClassScanListener {
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/ClassScanner.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/ClassScanner.java
deleted file mode 100644
index fcf2680..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/ClassScanner.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.api;
-
-/**
- * Generic class scanner interface
- * which is a helper to plug in external scanners
- * as adapters for the annotation and dependency handling
- * we cannot deal with annotations directly in the core
- * because we are bound by the jsf 1.2 lower threshold limit
- * hence this indirection
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-public interface ClassScanner {
-
- public void scanPaths();
-
- @SuppressWarnings("unused")
- public void clearListeners();
-
- @SuppressWarnings("unused")
- public void addListener(ClassScanListener listener);
-
- public void addScanPath(String scanPath);
-
- @SuppressWarnings("unchecked")
- public void scanClass(Class clazz);
-
- public void scanAndMarkChange();
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/CompilationException.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/CompilationException.java
deleted file mode 100644
index 49512c1..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/CompilationException.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.api;
-
-/**
- * <p>This exception will usually be thrown if an error occurred while compiling a
- * set of source files. However, note that it doesn't mean that the source files
- * themselves contained errors but rather that the system couldn't managed to
- * find an appropriate compiler implementation, etc.</p>
- * <p/>
- * <p>In order to determine whether the compiler successfully compiled a certain
- * source file you have to look for the compilation result instead.</p>
- */
-public class CompilationException extends Exception {
-
- // ------------------------------------------ Constructors
-
- /**
- * <p>Constructs a new compilation exception with the specified detail message.</p>
- *
- * @param message the detail message. The detail message is saved for
- * later retrieval by the {@link #getMessage()} method.
- */
- public CompilationException(String message) {
- super(message);
- }
-
- /**
- * <p>Constructs a compilation new exception with the specified detail message
- * and cause. <p>Note that the detail message associated with
- * <code>cause</code> is <i>not</i> automatically incorporated in
- * this exception's detail message.</p>
- *
- * @param message the detail message (which is saved for later retrieval
- * by the {@link #getMessage()} method).
- * @param cause the cause (which is saved for later retrieval by the
- * {@link #getCause()} method). (A <tt>null</tt> value is
- * permitted, and indicates that the cause is nonexistent or
- * unknown.)
- */
- public CompilationException(String message, Throwable cause) {
- super(message, cause);
- }
-
- /**
- * <p>Constructs a new compilation exception with the specified cause and
- * a detail message of <tt>(cause==null ? null : cause.toString())</tt>
- * (which typically contains the class and detail message of
- * <tt>cause</tt>).</p>
- *
- * @param cause the cause (which is saved for later retrieval by the
- * {@link #getCause()} method). (A <tt>null</tt> value is
- * permitted, and indicates that the cause is nonexistent or
- * unknown.)
- */
- public CompilationException(Throwable cause) {
- super(cause);
- }
-
-}
-
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/CompilationResult.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/CompilationResult.java
deleted file mode 100644
index d7363ce..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/CompilationResult.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.api;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * <p>Contains all information regarding the result of a particular compilation process.</p>
- */
-public class CompilationResult {
-
- /**
- * The compiler output, i.e. simply everything that the compiler would usually
- * print to the console, if you executed the same process on the command line
- * instead.
- */
- private String _compilerOutput;
-
- /**
- * A list of error messages that the compiler has produced. Note that if there
- * are no error messages, it's safe to assume that compilation succeeded.
- */
- private List<CompilationMessage> _errors;
-
- /**
- * A list of warnings that the compiler has produced.
- */
- private List<CompilationMessage> _warnings;
-
- // ------------------------------------------ Constructors
-
- /**
- * <p>Constructs a new compilation result object using the compiler output. However,
- * note that this constructor doesn't attempt to parse the compiler output to get the
- * error messages and warnings. You'll have to register those messages yourself
- * afterwards.</p>
- *
- * @param compilerOutput the compiler output, i.e. simply everything that the compiler would
- * usually print to the console, if you executed the same process on
- * the command line instead
- */
- public CompilationResult(String compilerOutput) {
- this._compilerOutput = compilerOutput;
-
- this._errors = new ArrayList<CompilationMessage>();
- this._warnings = new ArrayList<CompilationMessage>();
- }
-
- // ------------------------------------------ Public methods
-
- /**
- * <p>Returns the compiler output, i.e. simply everything that the compiler would usually
- * print to the console, if you executed the same process on the command line
- * instead.</p>
- *
- * @return the compiler output
- */
- public String getCompilerOutput() {
- return _compilerOutput;
- }
-
- /**
- * <p>Determines whether any error messages have been registered, i.e. whether compilation
- * was successful.</p>
- *
- * @return <code>true</code if no error messages have been registered, i.e. if compilation
- * was sucessful; <code>false</code> otherwise
- */
- public boolean hasErrors() {
- return !_errors.isEmpty();
- }
-
- /**
- * <p>Registers the given message as an error message.</p>
- *
- * @param message the error message you want to register
- */
- public void registerError(CompilationMessage message) {
- if (message != null) {
- _errors.add(message);
- }
- }
-
- /**
- * <p>Returns a list of error messages that the compiler has produced,
- * i.e. the error messages that have been registered previously.</p>
- *
- * @return a list of error messages
- */
- public List<CompilationMessage> getErrors() {
- return _errors;
- }
-
- /**
- * <p>Registers the given message as a warning. You can register as many warnings as you want
- * and it won't affect whether compilation was sucessful or not.</p>
- *
- * @param message the warning you want to register
- */
- public void registerWarning(CompilationMessage message) {
- if (message != null) {
- _warnings.add(message);
- }
- }
-
- /**
- * <p>Returns a list of warnings that the compiler has produced,
- * i.e. the warnings that have been registered previously.</p>
- *
- * @return a list of warnings
- */
- public List<CompilationMessage> getWarnings() {
- return _warnings;
- }
-
- // ------------------------------------------ Public static classes
-
- /**
- * <p>Utility class that contains all the required information regarding
- * a single compilation message.</p>
- */
- public static class CompilationMessage {
-
- /**
- * the line number of this compilation message
- */
- private long lineNumber;
-
- /**
- * the actual compilation message
- */
- private String message;
-
- // -------------------------------------- Constructors
-
- /**
- * <p>Constructs a new compilation message using the line number
- * and the actual compilation message as a string.</p>
- *
- * @param lineNumber the line number
- * @param message the actual compilation message
- */
- public CompilationMessage(long lineNumber, String message) {
- this.lineNumber = lineNumber;
- this.message = message;
- }
-
- // -------------------------------------- Public methods
-
- /**
- * <p>The number of the relevant line where this warning or error
- * has occured, or <code>-1</code> if it is not known.</p>
- *
- * @return the line number
- */
- public long getLineNumber() {
- return lineNumber;
- }
-
- /**
- * <p>Returns the message itself as a string, i.e. the textual content
- * of whatever the compiler complained about.</p>
- *
- * @return the message itself as a string
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * <p>Returns a string representation of this compilation message.</p>
- *
- * @return a string representation of this compilation message
- */
- @Override
- public String toString() {
- return String.format(
- "CompilationMessage[lineNumber='%s', message='%s']", lineNumber, message);
- }
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/Compiler.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/Compiler.java
deleted file mode 100644
index 3db1cf1..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/Compiler.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.api;
-
-import org.apache.myfaces.extensions.scripting.api.CompilationResult;
-
-import java.io.File;
-
-/**
- * <p>An abstract compiler interface that enables you to compile one particular file at a time.</p>
- */
-public interface Compiler {
-
- /**
- * <p>Compiles the given file and creates an according class file in the given target path. Note that
- * it is possible for the given class to reference any other classes as long as the dependent classes
- * are available on the classpath. The given class loader determines the classes that are available
- * on the classpath.</p>
- *
- * @param sourcePath the path to the source directory
- * @param targetPath the path to the target directory
- * @param file the file of the class you want to compile
- * @param classLoader the class loader for dependent classes
- * @return the compilation result, i.e. the compiler output, a list of errors and a list of warnings
- * @throws org.apache.myfaces.extensions.scripting.api.CompilationException
- * if a severe error occurred while trying to compile a file
- */
- public CompilationResult compile(File sourcePath, File targetPath, File file, ClassLoader classLoader)
- throws org.apache.myfaces.extensions.scripting.api.CompilationException;
-
- /**
- * <p>Compiles the given file and creates an according class file in the given target path. Note that
- * it is possible for the given class to reference any other classes as long as the dependent classes
- * are available on the classpath. The given class loader determines the classes that are available
- * on the classpath.</p>
- *
- * @param sourcePath the path to the source directory
- * @param targetPath the path to the target directory
- * @param classLoader the class loader for dependent classes
- * @return the compilation result, i.e. the compiler output, a list of errors and a list of warnings
- * @throws org.apache.myfaces.extensions.scripting.api.CompilationException
- * if a severe error occurred while trying to compile a file
- */
- public CompilationResult compile(File sourcePath, File targetPath, ClassLoader classLoader)
- throws org.apache.myfaces.extensions.scripting.api.CompilationException;
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/CompilerConst.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/CompilerConst.java
deleted file mode 100644
index bb94fee..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/CompilerConst.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.api;
-
-/**
- * Various constants shared over the various compiler implementations
- * JSR or non JSR!
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class CompilerConst {
- public static final String STD_ERROR_HEAD = "Java Compiler, error on line: ";
- public static final String STD_WARN_HEAD = "Java Compiler, warning on line: ";
- public static final String STD_MANDATORY_WARN_HEAD = "Java Compiler, mandatory warning on line: ";
- public static final String STD_OTHER_HEAD = "Java Compiler, other diagnostic on line: ";
- public static final String STD_NOTE_HEAD = "Java Compiler, Info on line: ";
- public static final String JC_CLASSPATH = "-cp";
- public static final String JC_TARGET_PATH = "-d";
- public static final String JC_SOURCEPATH = "-sourcepath";
- public static final String JC_DEBUG = "-g";
- public static final String JAVA_WILDCARD = "*.java ";
- public static final String JC_VERBOSE = "-verbose";
- @SuppressWarnings("unused")
- public static final String JC_SOURCE = "-source";
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/Configuration.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/Configuration.java
deleted file mode 100644
index 2637fac..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/Configuration.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.api;
-
-import org.apache.myfaces.extensions.scripting.core.util.FileUtils;
-
-import java.io.File;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-/**
- * Configuration class for our ext-scripting system.
- * It keeps all internal configuration data needed
- * by the various part of the system.
- * <p/>
- * It is pre initialized in our init stages
- * and later accessed only readonly.
- */
-
-public class Configuration {
-
- /**
- * the source dirs per scripting engine
- */
- volatile Map<Integer, CopyOnWriteArrayList<String>> _sourceDirs = new ConcurrentHashMap<Integer, CopyOnWriteArrayList<String>>();
-
- /**
- * the target compile path
- */
- volatile File _compileTarget = FileUtils.getTempDir();
-
- /**
- * if set to true we do an initial compile step upon loading
- */
- boolean _initialCompile = true;
-
- /**
- * the package whitelist used by our system
- * to determine which packages are under control.
- * <p/>
- * Note an empty whitelist means, all packages with sourcedirs attached to.
- */
- Set<String> _packageWhiteList = new HashSet<String>();
-
- /**
- * Optional additional classpath for the compilers
- * to be able to pick up additional compile jars
- */
- List<String> _additionalClassPath = new LinkedList<String>();
-
- /**
- * we keep track of separate resource dirs
- * for systems which can use resource loaders
- * <p/>
- * so that we can load various resources as well
- * from separate source directories instead
- */
- volatile List<String> _resourceDirs = new CopyOnWriteArrayList<String>();
-
- @SuppressWarnings("unchecked")
- public Collection<String> getSourceDirs(int scriptingEngine) {
- Collection<String> retVal = _sourceDirs.get(scriptingEngine);
- if (retVal == null) return Collections.EMPTY_SET;
- return retVal;
- }
-
- public Collection<String> getAllSourceDirs() {
- Set<String> retVal = new HashSet(10);
- for (Map.Entry<Integer, CopyOnWriteArrayList<String>> entry : _sourceDirs.entrySet()) {
- for (String dir : entry.getValue()) {
- retVal.add(dir);
- }
- }
- return retVal;
- }
-
- /**
- * returns a set of whitelisted subdirs hosting the source
- *
- * @param scriptingEngine the scripting engine for which the dirs have to be determined
- * (note every scripting engine has a unique integer value)
- * @return the current whitelisted dirs hosting the sources
- */
- public Collection<String> getWhitelistedSourceDirs(int scriptingEngine) {
- List<String> origSourceDirs = _sourceDirs.get(scriptingEngine);
- if (_packageWhiteList.isEmpty()) {
- return origSourceDirs;
- }
-
- return mergeWhitelisted(origSourceDirs);
- }
-
- /**
- * merges the whitelisted packages with the sourcedirs and generates a final list
- * which left join of both sets - the ones which do not exist in reality
- *
- * @param origSourceDirs the original source dirs
- * @return the joined existing subset of all directories which exist
- */
- private Collection<String> mergeWhitelisted(List<String> origSourceDirs) {
- List<String> retVal = new ArrayList<String>(_packageWhiteList.size() * origSourceDirs.size() + origSourceDirs.size());
-
- for (String whitelisted : _packageWhiteList) {
- whitelisted = whitelisted.replaceAll("\\.", FileUtils.getFileSeparatorForRegex());
- for (String sourceDir : origSourceDirs) {
- String newSourceDir = sourceDir + File.separator + whitelisted;
- if ((new File(newSourceDir)).exists()) {
- retVal.add(newSourceDir);
- }
- }
- }
- return retVal;
- }
-
- /**
- * Add a new source dir for the corresponding scripting engine
- *
- * @param scriptingEngine integer value marking the corresponding engine
- * @param sourceDir the source directory added to the existing source dir list
- */
- public void addSourceDir(int scriptingEngine, String sourceDir) {
- CopyOnWriteArrayList<String> dirs = _sourceDirs.get(scriptingEngine);
- if (dirs == null) {
- dirs = new CopyOnWriteArrayList<String>();
- _sourceDirs.put(scriptingEngine, dirs);
- }
- dirs.add(sourceDir);
- }
-
- /**
- * <p>Resolves and returns a File handle that represents the class file of
- * the given class on the file system. However, note that this method only
- * returns <code>null</code> if an error occured while resolving the class
- * file. A non-null valuee doesn't necessarily mean that the class file
- * actually exists. In oder to check the existence call the according
- * method on the returned object.</p>
- *
- * @param className the name of the class that you want to resolve
- * @return a File handle that represents the class file of the given class
- * on the file system
- * @see java.io.File#exists()
- */
- public File resolveClassFile(String className) {
- //if(className.contains("rg/apache/myfaces/javaloader/componentTest/JavaTestComponent$PropertyKeys")) {
- // System.out.println("Debuginfo found");
- //}
- //int subClassPos = className.indexOf("$");
- //className = (subClassPos != -1)? className.substring(0, subClassPos) :className;
- return new File(getCompileTarget(),
- className.replaceAll("\\.", "/").concat(".class"));
- }
-
- public File getCompileTarget() {
- return _compileTarget;
- }
-
- public void addResourceDir(String dir) {
- _resourceDirs.add(dir);
- }
-
- public List<String> getResourceDirs() {
- return _resourceDirs;
- }
-
- public boolean isInitialCompile() {
- return _initialCompile;
- }
-
- public void setInitialCompile(boolean initialCompile) {
- this._initialCompile = initialCompile;
- }
-
- public void addWhitelistPackage(String pkg) {
- _packageWhiteList.add(pkg);
- }
-
- public Set<String> getPackageWhiteList() {
- return _packageWhiteList;
- }
-
- public void setPackageWhiteList(Set<String> packageWhiteList) {
- this._packageWhiteList = packageWhiteList;
- }
-
- public void addAdditionalClassPath(String path) {
- _additionalClassPath.add(path);
- }
-
- public List<String> getAdditionalClassPath() {
- return _additionalClassPath;
- }
-
- public void setAdditionalClassPath(List<String> additionalClassPath) {
- this._additionalClassPath = additionalClassPath;
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/Decorated.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/Decorated.java
deleted file mode 100644
index 78b3443..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/Decorated.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.api;
-
-/**
- * General decoration interface
- * for the Decorator pattern
- *
- * @author Werner Punz
- */
-public interface Decorated {
- public Object getDelegate();
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/DynamicClassIdentifier.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/DynamicClassIdentifier.java
deleted file mode 100644
index 96578b1..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/DynamicClassIdentifier.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.api;
-
-/**
- * Generic class identifier interface
- * has to be implemented by all identifiers
- *
- * @author Werner Punz
- */
-public interface DynamicClassIdentifier {
- /**
- * identifies whether a given class is dynamic or not
- *
- * @param clazz the class which has to be investigates
- * @return true if it is dynamic false if not
- */
- public boolean isDynamic(Class clazz);
-
- /**
- * gets the engine type for the corresponding class
- * (note every scripting engine is identified over a unique integer value)
- *
- * @param clazz the class which the engine type has to be determined for
- * @return the engine type as integer value
- */
- @SuppressWarnings("unused")
- public int getEngineType(Class clazz);
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/DynamicCompiler.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/DynamicCompiler.java
deleted file mode 100644
index b94d52e..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/DynamicCompiler.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.api;
-
-import java.io.File;
-
-/**
- * @author Werner Punz
- * Interface marking generic compiler facades which can
- * plug various compiler backends into our system
- * (for now jsr 199 is supported but in the long run JCI will
- * be integrated for pre 1.6 jdks)
- * <p/>
- * Note the class does not have to be thread safe, the
- * callers have to take care of the synchronisation
- * the class is definitely called synchronized to avoid
- * the windows file locking issues
- */
-public interface DynamicCompiler {
-
- /**
- * compiles a single file
- *
- *
- * @param sourceRoot the source search path (root of our source)
- * @param classPath the classpath for the compiler
- * @param filePath the relative path of our file
- * @return a valid java class of our file
- * @throws ClassNotFoundException in case of the class neither could be found
- * in our sources nor could be referenced in binary form from the classloader
- */
- public File compileFile(String sourceRoot, String classPath, String filePath);
-
- /**
- * loads a single class in its newest version
- * //TODO we probably move this code over
- *
- * @param sourceRoot the source search path (root of our source)
- * @param classPath the classpath for the compiler
- * @param filePath the relative path of our file
- * @return a valid java class of our file
- * @throws ClassNotFoundException in case of the class neither could be found
- * in our sources nor could be referenced in binary form from the classloader
- */
- public Class loadClass(String sourceRoot, String classPath, String filePath) throws ClassNotFoundException;
-
- /**
- * compile all files from a given source root
- *
- * @param sourceRoot the source root directory for the compile step to be performed
- * @param classPath the classpath
- * @return
- * @throws ClassNotFoundException in case of an error
- */
- public File compileAllFiles(String sourceRoot, String classPath) throws ClassNotFoundException;
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/MyFacesBeanHandler.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/MyFacesBeanHandler.java
deleted file mode 100644
index d433e02..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/MyFacesBeanHandler.java
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.api;
-
-import org.apache.myfaces.config.RuntimeConfig;
-import org.apache.myfaces.config.annotation.LifecycleProvider;
-import org.apache.myfaces.config.annotation.LifecycleProviderFactory;
-import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.monitor.ClassResource;
-import org.apache.myfaces.extensions.scripting.monitor.RefreshContext;
-import org.apache.myfaces.extensions.scripting.monitor.RefreshAttribute;
-import org.apache.myfaces.util.ContainerUtils;
-
-import javax.el.ELContext;
-import javax.el.ExpressionFactory;
-import javax.faces.context.FacesContext;
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Bean handler implementation
- * which encapsulates the myfaces specific parts
- * of the bean processing
- */
-public class MyFacesBeanHandler implements BeanHandler {
-
- final Logger _logger = Logger.getLogger(MyFacesBeanHandler.class.getName());
-
- /**
- * scripting engine for this bean handler
- */
- int _scriptingEngine;
-
- /**
- * constructor
- *
- * @param scriptingEngine the scripting engine the bean handler
- * currently has to attach to for its
- * operations
- */
- public MyFacesBeanHandler(int scriptingEngine) {
- this._scriptingEngine = scriptingEngine;
- }
-
- /**
- * scans all bean dependencies according to
- * their IoC information stored by the runtime
- * (in our case the MyFaces runtime confing)
- * and adds those into our backward referencing dependency map
- * to add further dependency information on IoC level
- * (we can have IoC dependencies which are bound by object
- * types, this is a corner case but it still can happen)
- */
- public void scanDependencies() {
-
- }
-
- /**
- * scans the dependencies on el level
- * Not working out for now
- */
- /* public void scanElDependencies() {
- Map<String, ManagedBean> mbeans = RuntimeConfig.getCurrentInstance(FacesContext.getCurrentInstance().getExternalContext()).getManagedBeans();
- for(Map.Entry<String, ManagedBean> entry: mbeans.entrySet()) {
- Object bean = entry.getValue();
- if(bean instanceof org.apache.myfaces.config.impl.digester.elements.ManagedBean) {
- org.apache.myfaces.config.impl.digester.elements.ManagedBean workBean = (org.apache.myfaces.config.impl.digester.elements.ManagedBean) bean;
-
- Object props = ReflectUtil.executeMethod(workBean,"getManagedProperties");
- if(props instanceof Iterator) {
- //myfaces 1.2
- } else {
- for(ManagedProperty prop: ((Collection<ManagedProperty>) props)) {
- ExpressionFactory expFactory = FacesContext.getCurrentInstance().getApplication().getExpressionFactory();
- ELContext elContext = FacesContext.getCurrentInstance().getELContext();
- expFactory.coerceToType("#{myFactory['booga']}");
- //if(ContainerUtils.isValueReference((String) prop.getV))
- elContext.getELResolver().getType(elContext,"myFactory","booga");
- }
- }
-
-
- }
- //Iterator<ManagedProperty> it = bean.getManagedProperties();
- //we rescan all managed props to cover pure object
- //references as well as class references
- //while(it.hasNext()) {
- // ManagedProperty prop = it.next();
- //}
- }
- } */
-
- /**
- * Refreshes all managed beans
- * session, and personal scoped ones
- * <p/>
- * personal scoped beans are beans which
- * have either
- * <li> session scope </li>
- * <li> page scope </li>
- * <li> custom scope </li>
- */
- public void refreshAllManagedBeans() {
- if (FacesContext.getCurrentInstance() == null) {
- return;//no npe allowed
- }
-
- Set<String> tainted = getTaintedClasses();
-
- //scanElDependencies();
-
- if (tainted.size() > 0) {
- //We now have to check if the tainted classes belong to the managed beans
- Set<String> managedBeanClasses = new HashSet<String>();
-
- Map mbeans = RuntimeConfig.getCurrentInstance(FacesContext.getCurrentInstance().getExternalContext()).getManagedBeans();
- Map mbeansSnapshotView;
-
- synchronized (RefreshContext.BEAN_SYNC_MONITOR) {
- mbeansSnapshotView = makeSnapshot(mbeans);
- }
-
- for (Object entry : mbeansSnapshotView.entrySet()) {
- Object bean = (Object) ((Map.Entry)entry).getValue();
-
- managedBeanClasses.add((String)ReflectUtil.executeMethod(bean, "getManagedBeanClassName"));//bean.getManagedBeanClassName());
- }
-
- boolean managedBeanTainted = isAnyManagedBeanTainted(tainted, managedBeanClasses);
- markPersonalScopeRefreshRecommended();
- getLog().info("[EXT-SCRIPTING] Tainting all beans to avoid classcast exceptions");
- if (managedBeanTainted) {
- globalManagedBeanRefresh(mbeansSnapshotView);
- //personalScopeRefresh();
- }
- }
- }
-
- /**
- * Exposed personal scope refresh
- */
- public void personalScopeRefresh() {
- //shortcut to avoid heavier operations in the beginning
- long globalBeanRefreshTimeout = WeavingContext.getRefreshContext().getPersonalScopedBeanRefresh();
- if (globalBeanRefreshTimeout == -1L) return;
-
- Map sessionMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
- Long timeOut = (Long) sessionMap.get(ScriptingConst.SESS_BEAN_REFRESH_TIMER);
- if (timeOut == null || timeOut <= globalBeanRefreshTimeout) {
- refreshPersonalScopedBeans();
- }
- }
-
- /**
- * removes all bean references which have been tainted
- * (note for now we remove all dynamic references until we
- * get a more sophisticated handling of managed beans)
- *
- * @param workCopy the managed beam snapshot view
- */
- private void globalManagedBeanRefresh(Map workCopy) {
- Set<String> tainted = getTaintedClasses();
-
- for (Object entry : workCopy.entrySet()) {
- Object bean = ((Map.Entry) entry).getValue();
- Class managedBeanClass = (Class) ReflectUtil.executeMethod(bean, "getManagedBeanClass");
- if (hasToBeRefreshed(tainted, managedBeanClass)) {
- //managed bean class found we drop the class from our session
- removeBeanReferences(bean);
- }
- //one bean tainted we have to taint all dynamic beans otherwise we will get classcast
- //exceptions
- /*getLog().info("[EXT-SCRIPTING] Tainting ");
- RefreshAttribute metaData = WeavingContext.getFileChangedDaemon().getClassMap().get(managedBeanClass.getName());
- if (metaData != null) {
- metaData.requestRefresh();
- }*/
- }
- }
-
- /**
- * determines whether any bean in our managed bean list
- * is tainted or not
- *
- * @param tainted a list of classes which are tainted in this iteration
- * @param managedBeanClasses a ist of classes which are our managed beans
- * @return true if one of the beans is tainted
- */
- private boolean isAnyManagedBeanTainted(Set<String> tainted, Set<String> managedBeanClasses) {
- boolean managedBeanTainted = false;
- for (String taintedClass : tainted) {
- if (managedBeanClasses.contains(taintedClass)) {
- managedBeanTainted = true;
- break;
- }
- }
- return managedBeanTainted;
- }
-
- /**
- * helper which returns all tainted classes
- *
- * @return the tainted classes
- */
- private Set<String> getTaintedClasses() {
- Set<String> tainted = new HashSet<String>();
-
- for (Map.Entry<String, ClassResource> it : WeavingContext.getFileChangedDaemon().getClassMap().entrySet()) {
- if (it.getValue().getScriptingEngine() == getScriptingEngine() && it.getValue().getRefreshAttribute().requiresRefresh()) {
- tainted.add(it.getKey());
- }
- }
- return tainted;
- }
-
- /**
- * refreshes all personal scoped beans (aka beans which
- * have an assumed lifecycle <= session)
- * <p/>
- * This is needed for multiuser purposes because if one user alters some beans
- * other users have to drop their non application scoped beans as well!
- */
- private void refreshPersonalScopedBeans() {
- //the refreshing is only allowed if no compile is in progress
- //and vice versa
- Map sessionMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
- Long taintingPeriod = (Long) sessionMap.get(ScriptingConst.SESS_BEAN_REFRESH_TIMER);
- if (taintingPeriod == null) {
- taintingPeriod = -1L;
- }
- Set<String> taintedInTime = WeavingContext.getRefreshContext().getTaintHistoryClasses(taintingPeriod);
-
- synchronized (RefreshContext.BEAN_SYNC_MONITOR) {
- Map mbeans = RuntimeConfig.getCurrentInstance(FacesContext.getCurrentInstance().getExternalContext()).getManagedBeans();
- //the map is immutable but in between scanning might change it so we make a full copy of the map
-
- //We can synchronized the refresh, but if someone alters
- //the bean map from outside we still get race conditions
- //But for most cases this mutex should be enough
- Map mbeansSnapshotView = makeSnapshot(mbeans);
-
- for (Object entry : mbeansSnapshotView.entrySet()) {
- Object value = ((Map.Entry) entry).getValue();
- Class managedBeanClass = (Class) ReflectUtil.executeMethod(value,"getManagedBeanClass");
- if (hasToBeRefreshed(taintedInTime, managedBeanClass)) {
- FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove(ReflectUtil.executeMethod(value,"getManagedBeanName"));
- removeCustomScopedBean( value );
- }
- }
- updateBeanRefreshTime();
- }
- }
-
- /**
- * removes the references from out static scope
- * for jsf2 we probably have some kind of notification mechanism
- * which notifies custom scopes
- *
- * @param bean the managed bean which all references have to be removed from
- */
-
- private void removeBeanReferences(Object bean) {
- String managedBeanName = (String) ReflectUtil.executeMethod(bean, "getManagedBeanName");
-
- if (getLog().isLoggable(Level.FINE)) {
- getLog().log(Level.FINE, "[EXT-SCRIPTING] JavaScriptingWeaver.removeBeanReferences({0})", managedBeanName);
- }
-
- FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove(managedBeanName);
- FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().remove(managedBeanName);
- removeCustomScopedBean(bean);
- }
-
- /**
- * @return the log for this class
- */
- protected Logger getLog() {
- return Logger.getLogger(this.getClass().getName());
- }
-
-
-
- /**
- * jsf2 helper to remove custom scoped beans
- *
- * @param bean the managed bean which has to be removed from the custom scope from
- */
- private void removeCustomScopedBean(Object bean) {
- Object scopeImpl = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get(ReflectUtil.executeMethod(bean,"getManagedBeanScope"));
- if (scopeImpl == null) return; //scope not implemented
- //we now have to revert to introspection here because scopes are a pure jsf2 construct
- //so we use a messaging pattern here to cope with it
-
- Object beanInstance = ReflectUtil.executeMethod(scopeImpl, "get", ReflectUtil.executeMethod(bean, "getManagedBeanName"));
- LifecycleProvider lifecycleProvider =
- LifecycleProviderFactory.getLifecycleProviderFactory().getLifecycleProvider(FacesContext.getCurrentInstance().getExternalContext());
- try {
- lifecycleProvider.destroyInstance(beanInstance);
- } catch (IllegalAccessException e) {
- _logger.log(Level.WARNING, "removeCustomScopedBean():", e);
- } catch (InvocationTargetException e) {
- _logger.log(Level.WARNING, "removeCustomScopedBean():", e);
- }
- }
-
- /**
- * MyFaces 2.0 keeps an immutable map over the session
- * and request scoped beans
- * if we alter that during our loop we get a concurrent modification exception
- * taking a snapshot in time fixes that
- *
- * @param mbeans the internal managed bean map which has to be investigated
- * @return a map with the class name as key and the managed bean info
- * as value of the current state of the internal runtime config bean map
- */
- private Map makeSnapshot(Map mbeans) {
- Map workCopy;
-
- workCopy = new HashMap(mbeans.size());
- for (Object elem: mbeans.entrySet()) {
- Map.Entry entry = (Map.Entry) elem;
- workCopy.put(entry.getKey(), entry.getValue());
- }
-
- return workCopy;
- }
-
- /**
- * updates the internal timer
- * for our personal scoped beans so that
- * we dont get updates on beans we have refreshed already
- */
- private void updateBeanRefreshTime() {
- long sessionRefreshTime = System.currentTimeMillis();
- FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(ScriptingConst.SESS_BEAN_REFRESH_TIMER, sessionRefreshTime);
- }
-
- /**
- * sets the internal timer for other processes
- * to update their beans as well
- */
- private void markPersonalScopeRefreshRecommended() {
- long sessionRefreshTime = System.currentTimeMillis();
- WeavingContext.getRefreshContext().setPersonalScopedBeanRefresh(sessionRefreshTime);
- FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(ScriptingConst.SESS_BEAN_REFRESH_TIMER, sessionRefreshTime);
- }
-
- /**
- * important, this method determines whether a managed bean class
- * has to be refreshed or not
- *
- * @param tainted set of tainted classes
- * @param managedBeanClass the class to be checked for refresh criteria
- * @return true if the current bean class fulfills our refresh criteria
- */
- protected boolean hasToBeRefreshed(Set<String> tainted, Class managedBeanClass) {
-
- return WeavingContext.isDynamic(managedBeanClass) && tainted.contains(managedBeanClass.getName());
- }
-
- /**
- * returns the scripting engine which is attached
- * to this bean handler
- *
- * @return the current scripting engine
- */
- private int getScriptingEngine() {
- return _scriptingEngine;
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/ReloadingStrategy.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/ReloadingStrategy.java
deleted file mode 100644
index 34bf84f..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/ReloadingStrategy.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.api;
-
-/**
- * <p/>
- * Generic strategy for reloading
- * this should encapsulate various
- * reloading strategies
- * which have to be applied depending
- * on the artifact
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-public interface ReloadingStrategy {
- /**
- * Reload method which is the central point for this
- * strategy pattern
- *
- * @param toReload the object to be reloaded
- * @param artifactType the artifact type to be reloaded (so that the pattern either can ignore it or use it)
- * @return either the original or the reloaded artifact depending on its type and state
- */
- public Object reload(Object toReload, int artifactType);
-
- /**
- * Now this looks weird, but some scripting languages
- * have problems in a mixed environment so we allow
- * the calling weaver to be set lazily
- *
- * @param weaver the calling weaver to be set
- */
- public void setWeaver(ScriptingWeaver weaver);
-
- /**
- * getter for completeness
- *
- * @return the calling weaver
- */
- public ScriptingWeaver getWeaver();
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/ScriptingConst.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/ScriptingConst.java
deleted file mode 100644
index 8658e37..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/ScriptingConst.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.api;
-
-/**
- * Various constants being used by the
- * system
- *
- * @author Werner Punz
- */
-@SuppressWarnings("unused")
-public class ScriptingConst {
-
-
-
- public static final String SCRIPTING_CLASSLOADER = "org.apache.myfaces.extensions.SCRIPTING_CLASSLOADER";
- public static final String SCRIPTING_GROOVFACTORY = "org.apache.myfaces.extensions.SCRIPTING_GROOVYFACTORY";
- public static final String SCRIPTING_REQUSINGLETON = "org.apache.myfaces.extensions.SCRIPTING_REQUSINGLETON";
-
- public static final String INIT_PARAM_SCRIPTING_PACKAGE_WHITELIST = "org.apache.myfaces.extensions.scripting.PGK_WHITELIST";
- public static final String INIT_PARAM_SCRIPTING_ADDITIONAL_CLASSPATH = "org.apache.myfaces.extensions.scripting.ADDITIONAL_CLASSPATH";
- public static final String INIT_PARAM_RESOURCE_PATH = "org.apache.myfaces.extensions.scripting.resources.LOADER_PATHS";
- public static final String INIT_PARAM_CUSTOM_GROOVY_LOADER_PATHS = "org.apache.myfaces.extensions.scripting.groovy.LOADER_PATHS";
- public static final String INIT_PARAM_CUSTOM_JAVA_LOADER_PATHS = "org.apache.myfaces.extensions.scripting.java.LOADER_PATHS";
- public static final String INIT_PARAM_INITIAL_COMPILE="org.apache.myfaces.extensions.scripting.INITIAL_COMPILE_AND_SCAN";
- public static final String INIT_PARAM_MYFACES_PLUGIN = "org.apache.myfaces.FACES_INIT_PLUGINS";
-
- public static final String EXT_VAL_MARKER="org.apache.myfaces.extensions.validator";
-
- public static final String CONTEXT_VALUE_DIVIDER = ",";
-
- public static final String RELOAD_MAP = "reloadMap";
- public static final String SESS_BEAN_REFRESH_TIMER = "sessbeanrefrsh";
-
- public static final int TAINT_INTERVAL = 2000;
-
- public static final int ENGINE_TYPE_JSF_ALL = -2;
- public static final int ENGINE_TYPE_JSF_NO_ENGINE = -1;
- public static final int ENGINE_TYPE_JSF_GROOVY = 0;
- public static final int ENGINE_TYPE_JSF_JAVA = 1;
- public static final int ARTIFACT_TYPE_UNKNOWN = -1;
- public static final int ARTIFACT_TYPE_MANAGEDBEAN = 1;
- public static final int ARTIFACT_TYPE_MANAGEDPROPERTY = 2;
- public static final int ARTIFACT_TYPE_RENDERKIT = 3;
- public static final int ARTIFACT_TYPE_VIEWHANDLER = 4;
- public static final int ARTIFACT_TYPE_RENDERER = 5;
- public static final int ARTIFACT_TYPE_COMPONENT = 6;
- public static final int ARTIFACT_TYPE_VALIDATOR = 7;
- public static final int ARTIFACT_TYPE_BEHAVIOR = 8;
- public static final int ARTIFACT_TYPE_APPLICATION = 9;
- public static final int ARTIFACT_TYPE_ELCONTEXTLISTENER = 10;
- public static final int ARTIFACT_TYPE_ACTIONLISTENER = 11;
- public static final int ARTIFACT_TYPE_VALUECHANGELISTENER = 12;
- public static final int ARTIFACT_TYPE_CONVERTER = 13;
- public static final int ARTIFACT_TYPE_LIFECYCLE = 14;
- public static final int ARTIFACT_TYPE_PHASELISTENER = 15;
- public static final int ARTIFACT_TYPE_FACESCONTEXT = 16;
- public static final int ARTIFACT_TYPE_NAVIGATIONHANDLER = 17;
- public static final int ARTIFACT_TYPE_RESPONSEWRITER = 18;
- public static final int ARTIFACT_TYPE_RESPONSESTREAM = 19;
- public static final int ARTIFACT_TYPE_RESOURCEHANDLER = 19;
- public static final int ARTIFACT_TYPE_CLIENTBEHAVIORRENDERER = 20;
- public static final int ARTIFACT_TYPE_SYSTEMEVENTLISTENER = 21;
-
- //faclets artifacts
- public static final int ARTIFACT_TYPE_TAG_HANDLER = 22;
- public static final int ARTIFACT_TYPE_COMPONENT_HANDLER = 23;
- public static final int ARTIFACT_TYPE_VALIDATOR_HANDLER = 24;
- public static final int ARTIFACT_TYPE_CONVERTER_HANDLER = 25;
- public static final int ARTIFACT_TYPE_BEHAVIOR_HANDLER = 26;
-
- public static final String CTX_ATTR_REQUEST_CNT = "RequestCnt";
- public static final String CTX_ATTR_CONFIGURATION = "ExtScriptingConfig";
- public static final String CTX_ATTR_STARTUP = "ExtScriptingStartup";
- public static final String CTX_ATTR_SCRIPTING_WEAVER = "ScriptingWeaver";
- public static final String CTX_ATTR_REFRESH_CONTEXT = "RefreshContext";
- public static final String CTX_ATTR_EXTENSION_EVENT_SYSTEM = "ExtEventSystem";
-
- public static final String FILE_EXTENSION_GROOVY = ".groovy";
- public static final String GROOVY_FILE_ENDING = ".groovy";
- public static final String JAVA_FILE_ENDING = ".java";
- public static final String JSR199_COMPILER = "org.apache.myfaces.extensions.scripting.loaders.java.jsr199.JSR199Compiler";
- public static final String JAVA5_COMPILER = "org.apache.myfaces.extensions.scripting.loaders.java.compiler.JavacCompiler";
- public static final String SCOPE_SESSION = "session";
- public static final String SCOPE_APPLICATION = "application";
- public static final String SCOPE_REQUEST = "request";
- public static final String GROOVY_SOURCE_ROOT = "/WEB-INF/groovy/";
- public static final String JAVA_SOURCE_ROOT = "/WEB-INF/java/";
- public static final String ERR_SERVLET_FILTER = "[EXT-SCRIPTING] The servlet filter has not been set, please check your web.xml for following entries:" +
- "\n <filter>\n" +
- " <filter-name>scriptingFilter</filter-name>\n" +
- " <filter-class>org.apache.myfaces.extensions.scripting.servlet.ScriptingServletFilter</filter-class>\n" +
- " </filter>\n" +
- " <filter-mapping>\n" +
- " <filter-name>scriptingFilter</filter-name>\n" +
- " <url-pattern>/*</url-pattern>\n" +
- " <dispatcher>REQUEST</dispatcher>\n" +
- " <dispatcher>FORWARD</dispatcher>\n" +
- " <dispatcher>INCLUDE</dispatcher>\n" +
- " <dispatcher>ERROR</dispatcher>\n" +
- " </filter-mapping>";
- static final String EXT_VAL_REQ_KEY = "org.apache.myfaces.extension.scripting.clearExtvalCache_Done";
- public static final String JAVAX_FACES = "javax.faces";
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/ScriptingWeaver.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/ScriptingWeaver.java
deleted file mode 100644
index 959d858..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/ScriptingWeaver.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.api;
-
-import java.util.Collection;
-
-/**
- * @author werpu
- * <p/>
- * <p/>
- * Central interface to the scripting layer
- * this class is a weaver which allows to trigger
- * the scripting layer in various situations
- * of the JSF interception points
- * <p/>
- * The scripting weaver replaces the classloader for those instances
- * because custom classloaders are inherently problematic in web containers
- */
-public interface ScriptingWeaver {
-
- /**
- * appends a custom script search path to the original one
- *
- * @param scriptPath a script path to be appended
- */
- public void appendCustomScriptPath(String scriptPath);
-
- /**
- * @param o the object which has to be reloaded
- * @param artifactType an identifier for the artifact type so that its reloading strategies can
- * be adjusted depending on the type of artifact which has to be processed, we have to pass down
- * this artifact because we cannot rely on instanceof here for several reasons first we do not know
- * if a managed bean does not implement as well one of the artifact interfaces for one reason or the other
- * secondly how do we deal with future extensions which provide new artifacts we cannot
- * bind the code to just one implementation, hence we add some kind of type identifier here as well
- * @return reloads an existing objects with its attributes
- * and assigns the reloaded class to the new object
- * <p/>
- * note, the new object must not be the same as the original one
- * it can be a shallow clone with a new class instead
- */
- public Object reloadScriptingInstance(Object o, int artifactType);
-
- /**
- * reloads an existing class if needed
- * if no new class exists the original class is given back
- *
- * @param aclass the class which is likely to be reloaded
- * @return a new class or the same if no refresh has to be performed
- */
- public Class reloadScriptingClass(Class aclass);
-
- /**
- * loads a scripting class from a given className
- * note, this method probably will be dropped in the long
- * run
- *
- * @param className the classname including the package
- * @return a class instance of the file
- */
- public Class loadScriptingClassFromName(String className);
-
- /**
- * returns the engine type for this weaver
- *
- * @return the supported scripting engine of this weaver
- */
- public int getScriptingEngine();
-
- /**
- * checks whether a given class can be reloaded
- * from this weaver or not
- *
- * @param clazz the class which has to be investigated
- * @return true if the class is dynamic false otherwise
- */
- public boolean isDynamic(Class clazz);
-
- /**
- * @param weaverClass the weaver class
- * @return an instance of the weaver class (mostly singleton)
- */
- public ScriptingWeaver getWeaverInstance(Class weaverClass);
-
- /**
- * full annotation scan
- * at startup once the system is initialized
- */
- public void fullClassScan();
-
- /**
- * do a full recompile of changed resources instead of a
- * simply compile per file
- */
- public void fullRecompile();
-
- /**
- * allows to mark the current weaving state as fully recompiled
- */
- public void markAsFullyRecompiled();
-
- /**
- * initiates all post startup actions which have to be performed
- * on the scripting subsystems after the entire scripting engine
- * configuration has been activated (in most cases
- * it comes down to an annotation parsing and compilation)
- */
- public void postStartupActions();
-
- /**
- * callback for artifact request refreshes
- * some artifacts should be refreshed or cleared upon
- * request time, others can be dealt with on on demand time
- */
- public void requestRefresh();
-
-
- /**
- * refreshes which only can be done under a fully initialized jsf
- * request
- */
- public void jsfRequestRefresh();
-
- /**
- * loads a list of possible dynamic classes
- * for the current given state of the source dirs
- *
- * @return a list of classes representing the current source state
- */
- public Collection<String> loadPossibleDynamicClasses();
-
- /**
- * scan for taint check
- */
- public void scanForAddedClasses();
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/ClassScanRecommended.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/ClassScanRecommended.java
deleted file mode 100644
index 0ce277a..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/ClassScanRecommended.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.api.extensionevents;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- *
- * TODO to be further specified once we have everything in place
- */
-
-public class ClassScanRecommended extends ExtensionEvent {
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/ClassTaintedEvent.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/ClassTaintedEvent.java
deleted file mode 100644
index 0821e0d..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/ClassTaintedEvent.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.api.extensionevents;
-
-import org.apache.myfaces.extensions.scripting.monitor.ClassResource;
-import org.apache.myfaces.extensions.scripting.monitor.RefreshAttribute;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ClassTaintedEvent extends ExtensionEvent {
- ClassResource _metaData;
-
- public ClassTaintedEvent(ClassResource metaData) {
- this._metaData = metaData;
- }
-
- public ClassResource getResource() {
- return _metaData;
- }
-
- public void setResource(ClassResource metaData) {
- this._metaData = metaData;
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/ExtensionEvent.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/ExtensionEvent.java
deleted file mode 100644
index 5e0c603..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/ExtensionEvent.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.api.extensionevents;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- *
- * Extension event class.
- *
- * The idea is that extensions attach themselves
- * over an event/messaging system to achieve loose coupling
- * between the core and an extension.
- *
- * Extensions will get following events.
- *
- * ScanRecommended
- * CompileRecommended (for their own compilation directories)
- * UpdateConfigurationRecommended
- *
- */
-
-public class ExtensionEvent {
-
- public ExtensionEvent() {
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/ExtensionEventListener.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/ExtensionEventListener.java
deleted file mode 100644
index e53520e..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/ExtensionEventListener.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.api.extensionevents;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * Central external listener interface for the extension events
- */
-public interface ExtensionEventListener {
-
- /**
- * The central event handling callback which gets
- * the callback back
- *
- * @param ev
- */
- public void handleEvent(ExtensionEvent ev);
-
- /**
- * returns the event identifiers this listener
- * is a listener for (additional hints which will speed up the event handling)
- *
- * @param evt the event to be triggered for
- * @return true if the listener is a listener for the specific event
- */
- public boolean isListenerFor(ExtensionEvent evt);
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/ExtensionEventRegistry.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/ExtensionEventRegistry.java
deleted file mode 100644
index b320139..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/ExtensionEventRegistry.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.api.extensionevents;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.concurrent.ConcurrentLinkedQueue;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ExtensionEventRegistry {
-
- Collection<ExtensionEventListener> _listeners = new ConcurrentLinkedQueue<ExtensionEventListener>();
-
- public void addListener(ExtensionEventListener listener) {
- _listeners.add(listener);
- }
-
- public void removeListener(ExtensionEvent listener) {
- _listeners.remove(listener);
- }
-
- public void removeAllListeners(Class eventType) {
- Iterator<ExtensionEventListener> it = _listeners.iterator();
- while (it.hasNext()) {
- if (it.next().getClass() == eventType) {
- it.remove();
- }
- }
- }
-
- public void clear() {
- _listeners.clear();
- }
-
- public void sendEvent(ExtensionEvent evt) {
- for (ExtensionEventListener listener : _listeners) {
- if (listener.isListenerFor(evt)) {
- listener.handleEvent(evt);
- }
- }
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/FullRecompileRecommended.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/FullRecompileRecommended.java
deleted file mode 100644
index f1f7c0c..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/FullRecompileRecommended.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.api.extensionevents;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class FullRecompileRecommended extends ExtensionEvent {
- int scriptingEngine;
-
- public FullRecompileRecommended(int scriptingEngine) {
- this.scriptingEngine = scriptingEngine;
- }
-
- public int getScriptingEngine() {
- return scriptingEngine;
- }
-
- public void setScriptingEngine(int scriptingEngine) {
- this.scriptingEngine = scriptingEngine;
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/FullScanRecommended.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/FullScanRecommended.java
deleted file mode 100644
index ec4c0aa..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/FullScanRecommended.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.api.extensionevents;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class FullScanRecommended extends ExtensionEvent {
-
- int engineType;
-
- public FullScanRecommended() {
- }
-
- public int getEngineType() {
- return engineType;
- }
-
- public void setEngineType(int engineType) {
- this.engineType = engineType;
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/SystemInitializedEvent.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/SystemInitializedEvent.java
deleted file mode 100644
index 9875abb..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/api/extensionevents/SystemInitializedEvent.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.api.extensionevents;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class SystemInitializedEvent extends ExtensionEvent {
- public SystemInitializedEvent() {
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/components/CompilerComponent.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/components/CompilerComponent.java
deleted file mode 100644
index b9874dd..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/components/CompilerComponent.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.components;
-
-import org.apache.myfaces.extensions.scripting.core.util.StringUtils;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-
-import javax.el.ValueExpression;
-import javax.faces.component.UIOutput;
-import javax.faces.context.FacesContext;
-import java.util.Locale;
-
-/**
- * Compiler component which currently
- * just shows the last compile output in the system
- * <p/>
- * Not to keep backwards compatibility to JSF 1.2
- * we do not use the StateHelper but go the old route
- * instead
- */
-@SuppressWarnings("unused")
-public class CompilerComponent extends UIOutput {
-
- String _scriptingLanguage = null;
- String _errorsLabel = null;
- String _warningsLabel = null;
- private static final String RENDERER_TYPE = "org.apache.myfaces.extensions.scripting.components.CompilerComponentRenderer";
- private static final String ERRORS_LABEL = "errorsLabel";
- private static final String WARNINGS_LABEL = "warningsLabel";
- private static final String SCRIPTING_LANGUAGE = "scriptingLanguage";
-
- public CompilerComponent() {
- super();
- setRendererType(RENDERER_TYPE);
- }
-
- @Override
- public boolean isTransient() {
- return true;
- }
-
- @Override
- public Object saveState(FacesContext facesContext) {
- Object values[] = new Object[4];
- values[0] = super.saveState(facesContext); //To change body of overridden methods use File | Settings | File Templates.
- values[1] = _scriptingLanguage;
- values[2] = _errorsLabel;
- values[3] = _warningsLabel;
- return values;
- }
-
- @Override
- public void restoreState(FacesContext facesContext, Object state) {
- Object[] values = (Object[]) state;
- super.restoreState(facesContext, values[0]);
-
- _scriptingLanguage = (String) values[1];
- _errorsLabel = (String) values[2];
- _warningsLabel = (String) values[3];
- }
-
-
- public String getScriptingLanguage() {
- if (_scriptingLanguage != null) {
- return _scriptingLanguage;
- }
- ValueExpression vb = getValueExpression(SCRIPTING_LANGUAGE);
- return vb != null ? ((String) vb.getValue(getFacesContext().getELContext())) : null;
- }
-
- public Integer getScriptingLanguageAsInt() {
- if (StringUtils.isBlank(_scriptingLanguage)) {
- return ScriptingConst.ENGINE_TYPE_JSF_ALL;
- } else {
- String scriptingLanguage = _scriptingLanguage.toLowerCase(Locale.getDefault()).trim();
- if (scriptingLanguage.equals("java")) {
- return ScriptingConst.ENGINE_TYPE_JSF_JAVA;
- } else if (_scriptingLanguage.toLowerCase(Locale.getDefault()).trim().equals("groovy")) {
- return ScriptingConst.ENGINE_TYPE_JSF_GROOVY;
- }
- }
- return ScriptingConst.ENGINE_TYPE_JSF_NO_ENGINE;
- }
-
- public void setScriptingLanguage(String scriptingLanguage) {
- _scriptingLanguage = scriptingLanguage;
- }
-
- public String getErrorsLabel() {
- if (_errorsLabel != null) {
- return _errorsLabel;
- }
- ValueExpression vb = getValueExpression(ERRORS_LABEL);
- return vb != null ? ((String) vb.getValue(getFacesContext().getELContext())) : null;
- }
-
- public void setErrorsLabel(String _errorsLabel) {
- this._errorsLabel = _errorsLabel;
- }
-
- public String getWarningsLabel() {
- if (_warningsLabel != null) {
- return _warningsLabel;
- }
- ValueExpression vb = getValueExpression(WARNINGS_LABEL);
- return vb != null ? ((String) vb.getValue(getFacesContext().getELContext())) : null;
- }
-
- public void setWarningsLabel(String _warningsLabel) {
- this._warningsLabel = _warningsLabel;
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/components/CompilerComponentRenderer.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/components/CompilerComponentRenderer.java
deleted file mode 100644
index d184bec..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/components/CompilerComponentRenderer.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.components;
-
-import org.apache.myfaces.extensions.scripting.api.CompilationResult;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.StringUtils;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.render.Renderer;
-import java.io.IOException;
-import java.util.logging.Logger;
-
-/**
- * Renderer for the compiler component
- * <p/>
- * This renderer is responsible for rendering the last compiler output
- * hosted in our weavingContext
- */
-@SuppressWarnings("unchecked")
-public class CompilerComponentRenderer extends Renderer {
-
- @Override
- public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
- super.encodeBegin(context, component);
-
- ResponseWriter responseWriter = FacesContext.getCurrentInstance().getResponseWriter();
- CompilerComponent compilerComp = (CompilerComponent) component;
-
- Integer scriptingLanguage = compilerComp.getScriptingLanguageAsInt();
- CompilationResult result = null;
- switch (scriptingLanguage) {
- case ScriptingConst.ENGINE_TYPE_JSF_JAVA:
- result = WeavingContext.getCompilationResult(ScriptingConst.ENGINE_TYPE_JSF_JAVA);
- break;
- case ScriptingConst.ENGINE_TYPE_JSF_GROOVY:
- result = WeavingContext.getCompilationResult(ScriptingConst.ENGINE_TYPE_JSF_GROOVY);
- break;
- case ScriptingConst.ENGINE_TYPE_JSF_ALL:
- result = new CompilationResult("");
- CompilationResult tempResult = WeavingContext.getCompilationResult(ScriptingConst.ENGINE_TYPE_JSF_JAVA);
- if (tempResult != null) {
- copyCompilationResult(result, tempResult);
- }
-
- tempResult = WeavingContext.getCompilationResult(ScriptingConst.ENGINE_TYPE_JSF_GROOVY);
- if (tempResult != null) {
- copyCompilationResult(result, tempResult);
- }
-
- break;
- case ScriptingConst.ENGINE_TYPE_JSF_NO_ENGINE:
- Logger log = Logger.getLogger(this.getClass().getName());
- log.warning(RendererConst.WARNING_ENGINE_NOT_FOUND);
- break;
- }
-
- startDiv(component, responseWriter, RendererConst.ERROR_BOX);
- if (result == null || (!result.hasErrors() && result.getWarnings().isEmpty())) {
- responseWriter.write(RendererConst.NO_COMPILE_ERRORS);
- } else {
- writeErrorsLabel(component, responseWriter, compilerComp);
- writeErrors(component, responseWriter, result);
- writeWarningsLabel(component, responseWriter, compilerComp);
- writeWarnings(component, responseWriter, result);
- }
- endDiv(responseWriter);
-
- responseWriter.flush();
-
- }
-
- private void writeWarnings(UIComponent component, ResponseWriter responseWriter, CompilationResult result) throws IOException {
- startDiv(component, responseWriter, RendererConst.WARNINGS);
- for (CompilationResult.CompilationMessage msg : result.getWarnings()) {
- startDiv(component, responseWriter, RendererConst.LINE);
- writeDiv(component, responseWriter, RendererConst.LINE_NO, String.valueOf(msg.getLineNumber()));
- writeDiv(component, responseWriter, RendererConst.MESSAGE, msg.getMessage());
- endDiv(responseWriter);
- }
- endDiv(responseWriter);
- }
-
- private void writeWarningsLabel(UIComponent component, ResponseWriter responseWriter, CompilerComponent compilerComp) throws IOException {
- if (!StringUtils.isBlank(compilerComp.getWarningsLabel())) {
- startDiv(component, responseWriter, RendererConst.WARNINGS_LABEL);
- responseWriter.write(compilerComp.getWarningsLabel());
- endDiv(responseWriter);
- }
- }
-
- private void writeErrors(UIComponent component, ResponseWriter responseWriter, CompilationResult result) throws IOException {
- startDiv(component, responseWriter, RendererConst.ERRORS);
- for (CompilationResult.CompilationMessage msg : result.getErrors()) {
- startDiv(component, responseWriter, RendererConst.LINE);
- writeDiv(component, responseWriter, RendererConst.LINE_NO, String.valueOf(msg.getLineNumber()));
- writeDiv(component, responseWriter, RendererConst.MESSAGE, msg.getMessage());
- endDiv(responseWriter);
- }
- endDiv(responseWriter);
- }
-
- private String writeDiv(UIComponent component, ResponseWriter responseWriter, String styleClass, String value) throws IOException {
- startDiv(component, responseWriter, styleClass);
- responseWriter.write(value);
- endDiv(responseWriter);
- return "";
- }
-
- private void endDiv(ResponseWriter responseWriter) throws IOException {
- responseWriter.endElement(RendererConst.HTML_DIV);
- }
-
- private void startDiv(UIComponent component, ResponseWriter responseWriter, String styleClass) throws IOException {
- responseWriter.startElement(RendererConst.HTML_DIV, component);
- responseWriter.writeAttribute(RendererConst.HTML_CLASS, styleClass, null);
- }
-
- private void writeErrorsLabel(UIComponent component, ResponseWriter responseWriter, CompilerComponent compilerComp) throws IOException {
- if (!StringUtils.isBlank(compilerComp.getErrorsLabel())) {
- startDiv(component, responseWriter, RendererConst.ERRORS_LABEL);
- responseWriter.write(compilerComp.getErrorsLabel());
- endDiv(responseWriter);
- }
- }
-
- private void copyCompilationResult(CompilationResult result, CompilationResult tempResult) {
- result.getErrors().addAll(tempResult.getErrors());
- result.getWarnings().addAll(tempResult.getWarnings());
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/components/RendererConst.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/components/RendererConst.java
deleted file mode 100644
index 3e38736..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/components/RendererConst.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.components;
-
-/**
- * Renderer Constant shared by both renderers
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class RendererConst {
- static final String ERROR_BOX = "errorBox";
- static final String WARNING_ENGINE_NOT_FOUND = "Warning engine not found";
- static final String LINE_NO = "lineNo";
- static final String MESSAGE = "message";
- static final String NO_COMPILE_ERRORS = "No compile errors";
- static final String HTML_DIV = "div";
- static final String HTML_CLASS = "class";
- static final String NO_TAINT_HISTORY_FOUND = "No taint history found";
- static final String LINE = "line";
- static final String TIMESTAMP = "timestamp";
- static final String CHANGED_FILE = "changedFile";
- static final String ERRORS_LABEL = "errorsLabel";
- static final String WARNINGS_LABEL = "warningsLabel";
- static final String ERRORS = "errors";
- static final String WARNINGS = "warnings";
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/components/TaintHistory.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/components/TaintHistory.java
deleted file mode 100644
index e5afb36..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/components/TaintHistory.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.components;
-
-import javax.el.ValueExpression;
-import javax.faces.component.UIOutput;
-import javax.faces.context.FacesContext;
-
-/**
- * Component which allows to check which files
- * have been marked as possibly modified in the recent history
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class TaintHistory extends UIOutput {
-
- public static final int DEFAULT_NO_ENTRIES = 10;
-
- Integer _noEntries;
- String _filter;
- private static final String RENDERER_TYPE = "org.apache.myfaces.extensions.scripting.components.TaintHistoryRenderer";
- private static final String NO_ENTRIES = "noEntries";
-
- public TaintHistory() {
- setRendererType(RENDERER_TYPE);
- }
-
- @SuppressWarnings("unused")
- public void setNoEntries(Integer entries) {
- _noEntries = entries;
- }
-
- @Override
- public Object saveState(FacesContext facesContext) {
- Object values[] = new Object[3];
- values[0] = super.saveState(facesContext); //To change body of overridden methods use File | Settings | File Templates.
- values[1] = _noEntries;
- values[2] = _filter;
- return values;
- }
-
- @Override
- public void restoreState(FacesContext facesContext, Object state) {
- Object[] values = (Object[]) state;
- super.restoreState(facesContext, values[0]);
- _noEntries = (Integer) values[1];
- _filter = (String) values[2];
- }
-
- public Integer getNoEntries() {
- if (_noEntries != null) {
- return _noEntries;
- }
- ValueExpression vb = getValueExpression(NO_ENTRIES);
- return vb != null ? ((Integer) vb.getValue(getFacesContext().getELContext())) : DEFAULT_NO_ENTRIES;
- }
-
- @SuppressWarnings("unused")
- public void setFilter(String filter) {
- _filter = filter;
- }
-
- @SuppressWarnings("unused")
- public String getFilter() {
- if (_filter != null) {
- return _filter;
- }
- ValueExpression vb = getValueExpression(NO_ENTRIES);
- return vb != null ? ((String) vb.getValue(getFacesContext().getELContext())) : null;
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/components/TaintHistoryRenderer.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/components/TaintHistoryRenderer.java
deleted file mode 100644
index 73d6840..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/components/TaintHistoryRenderer.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.components;
-
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.monitor.ClassResource;
-import org.apache.myfaces.extensions.scripting.monitor.RefreshAttribute;
-import org.apache.myfaces.extensions.scripting.monitor.WatchedResource;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.render.Renderer;
-import java.io.IOException;
-import java.text.DateFormat;
-import java.util.Collection;
-import java.util.Date;
-
-/**
- * A renderer which displays our taint history
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-@SuppressWarnings("unchecked")
-//we have to suppress here because of the component cast
-public class TaintHistoryRenderer extends Renderer {
-
- @Override
- public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
- super.encodeBegin(context, component);
-
- ResponseWriter responseWriter = FacesContext.getCurrentInstance().getResponseWriter();
-
- startDiv(component, responseWriter, "historyBox");
- int lastTainted = ((TaintHistory) component).getNoEntries();
-
- Collection<WatchedResource> result = WeavingContext.getRefreshContext().getLastTainted(lastTainted);
- if (result == null || result.isEmpty()) {
- responseWriter.write(RendererConst.NO_TAINT_HISTORY_FOUND);
- } else {
- writeHistory(component, responseWriter, result);
- }
- endDiv(responseWriter);
-
- responseWriter.flush();
-
- }
-
- private void writeHistory(UIComponent component, ResponseWriter responseWriter, Collection<WatchedResource> result) throws IOException {
- startDiv(component, responseWriter, "history");
- for (WatchedResource entry : result) {
- startDiv(component, responseWriter, RendererConst.LINE);
- writeDiv(component, responseWriter, RendererConst.TIMESTAMP, DateFormat.getInstance().format(entry.getFile().lastModified()));
- writeDiv(component, responseWriter, RendererConst.CHANGED_FILE, entry.getFile().getAbsolutePath());
- endDiv(responseWriter);
- }
-
- endDiv(responseWriter);
- }
-
- private String writeDiv(UIComponent component, ResponseWriter responseWriter, String styleClass, String value) throws IOException {
- startDiv(component, responseWriter, styleClass);
- responseWriter.write(value);
- endDiv(responseWriter);
- return "";
- }
-
- private void endDiv(ResponseWriter responseWriter) throws IOException {
- responseWriter.endElement(RendererConst.HTML_DIV);
- }
-
- private void startDiv(UIComponent component, ResponseWriter responseWriter, String styleClass) throws IOException {
- responseWriter.startElement(RendererConst.HTML_DIV, component);
- responseWriter.writeAttribute(RendererConst.HTML_CLASS, styleClass, null);
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/CoreWeaver.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/CoreWeaver.java
deleted file mode 100644
index 937766d..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/CoreWeaver.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-import java.io.Serializable;
-import java.util.*;
-
-/**
- * @author werpu
- * <p/>
- * Facade which holds multiple weavers
- * and implements a chain of responsibility pattern
- * on them
- */
-public class CoreWeaver implements Serializable, ScriptingWeaver {
-
- /**
- *
- */
- private static final long serialVersionUID = -3034995032644947216L;
-
- List<ScriptingWeaver> _weavers = new ArrayList<ScriptingWeaver>();
-
- public CoreWeaver(Collection<ScriptingWeaver> weavers) {
- _weavers.addAll(weavers);
- }
-
- public CoreWeaver(ScriptingWeaver... weavers) {
- _weavers.addAll(Arrays.asList(weavers));
- }
-
- public void appendCustomScriptPath(String scriptPaths) {
- throw new RuntimeException("Method not supported from this facade");
- }
-
- public Object reloadScriptingInstance(Object o, int artefactType) {
-
- for (ScriptingWeaver weaver : _weavers) {
- if (weaver.isDynamic(o.getClass())) {
- return weaver.reloadScriptingInstance(o, artefactType);
- }
- }
- return o;
-
- }
-
- public Class reloadScriptingClass(Class aclass) {
-
- for (ScriptingWeaver weaver : _weavers) {
- if (weaver.isDynamic(aclass)) {
- return weaver.reloadScriptingClass(aclass);
- }
- }
- return aclass;
-
- }
-
- public void markAsFullyRecompiled() {
- for (ScriptingWeaver weaver : _weavers) {
- weaver.markAsFullyRecompiled();
- }
- }
-
- public Class loadScriptingClassFromName(String className) {
- for (ScriptingWeaver weaver : _weavers) {
- Class retVal = weaver.loadScriptingClassFromName(className);
- if (retVal != null) {
- return retVal;
- }
- }
- return null;
- }
-
- public int getScriptingEngine() {
- return ScriptingConst.ENGINE_TYPE_JSF_ALL;
- }
-
- public boolean isDynamic(Class clazz) {
- for (ScriptingWeaver weaver : _weavers) {
- if (weaver.isDynamic(clazz)) {
- return true;
- }
- }
- return false;
- }
-
- public ScriptingWeaver getWeaverInstance(Class weaverClass) {
- for (ScriptingWeaver weaver : _weavers) {
- ScriptingWeaver retVal = weaver.getWeaverInstance(weaverClass);
- if (retVal != null) {
- return retVal;
- }
- }
- return null;
- }
-
- public void fullClassScan() {
- for (ScriptingWeaver weaver : _weavers) {
- weaver.fullClassScan();
- }
- }
-
- /**
- * @deprecated the full recompile now is done at the beginning of a request
- */
- public void fullRecompile() {
- for (ScriptingWeaver weaver : _weavers) {
- weaver.fullRecompile();
- }
- }
-
- public void postStartupActions() {
- for (ScriptingWeaver weaver : _weavers) {
- weaver.postStartupActions();
- }
- }
-
- public void requestRefresh() {
- for (ScriptingWeaver weaver : _weavers) {
- weaver.requestRefresh();
- }
- }
-
- @Override
- public void jsfRequestRefresh() {
- for (ScriptingWeaver weaver : _weavers) {
- weaver.jsfRequestRefresh();
- }
- }
-
- public Collection<String> loadPossibleDynamicClasses() {
- LinkedList<String> retVal = new LinkedList<String>();
- for (ScriptingWeaver weaver : _weavers) {
- retVal.addAll(weaver.loadPossibleDynamicClasses());
- }
- return retVal;
- }
-
- public void scanForAddedClasses() {
- for (ScriptingWeaver weaver : _weavers) {
- weaver.scanForAddedClasses();
- }
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/DummyWeaver.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/DummyWeaver.java
deleted file mode 100644
index 07b5d65..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/DummyWeaver.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.ClassUtils;
-
-import java.io.Serializable;
-import java.util.Collection;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * a dummy weaver in case the filter has not been set
- */
-
-public class DummyWeaver implements Serializable, ScriptingWeaver {
- /**
- *
- */
- private static final long serialVersionUID = -1504583349449148143L;
-
- public void appendCustomScriptPath(String scriptPaths) {
- }
-
- public Object reloadScriptingInstance(Object o, int artifactType) {
- return o;
- }
-
- public Class reloadScriptingClass(Class aclass) {
- return aclass;
- }
-
- public Class loadScriptingClassFromName(String className) {
- return ClassUtils.forName(className);
- }
-
- public int getScriptingEngine() {
- return ScriptingConst.ENGINE_TYPE_JSF_ALL;
- }
-
- public boolean isDynamic(Class clazz) {
- return false;
- }
-
- public ScriptingWeaver getWeaverInstance(Class weaverClass) {
- return this;
- }
-
- public void fullClassScan() {
- }
-
- public void fullRecompile() {
-
- }
-
- public void markAsFullyRecompiled() {
-
- }
-
- public void postStartupActions() {
- }
-
- public void requestRefresh() {
- }
-
- @Override
- public void jsfRequestRefresh() {
- }
-
- public Collection<String> loadPossibleDynamicClasses() {
- return null;
- }
-
- public void scanForAddedClasses() {
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/MethodLevelReloadingHandler.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/MethodLevelReloadingHandler.java
deleted file mode 100644
index 5d91ded..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/MethodLevelReloadingHandler.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.Serializable;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * Generic artifact invocation handler
- * which should be able to cover
- * all interfaceable artifacts which
- * only have reloading logic
- * and can cope with reloading on method level
- * <p/>
- * Note this works only for a minority of the artifacts
- * the reason, most artifacts do not rely on interfaces but
- * on base classes
- *
- * @author Werner Punz
- */
-@SuppressWarnings("unused")
-public class MethodLevelReloadingHandler extends ReloadingInvocationHandler implements Serializable {
-
- private static final long serialVersionUID = -3034995032644947216L;
-
- transient ScriptingWeaver _weaver = null;
- int _artifactType;
-
- public MethodLevelReloadingHandler(Object rootObject, int artifactType) {
- _loadedClass = rootObject.getClass();
- _delegate = rootObject;
- _artifactType = artifactType;
- }
-
- /**
- * outside interface to the invoke method
- * which gets called every time a method
- * is called
- *
- * @param object the object holding the method
- * @param method the method
- * @param paramHolders the param holders
- * @return the return value of the operation
- * @throws Throwable in case of an error
- */
- public Object invoke(Object object, Method method, Object[] paramHolders) throws Throwable {
- return reloadInvoke(method, paramHolders);
- }
-
- /**
- * invoke handler which is triggered
- * by every method call which takes care of the reload
- *
- * @param method the method to call
- * @param paramHolders the params
- * @return the return value of the operation
- * @throws InstantiationException standard throw caused by reflection
- * @throws IllegalAccessException standard throw caused by reflection
- * @throws InvocationTargetException standard throw caused by reflection
- */
-
- protected Object reloadInvoke(Method method, Object[] paramHolders) throws InstantiationException, IllegalAccessException, InvocationTargetException {
- if (_weaver == null)
- _weaver = WeavingContext.getWeaver();
-
- if (_delegate == null) {
- //stateless or lost state due to a lifecycle iteration we trigger anew
- _delegate = (_weaver.reloadScriptingClass(_loadedClass)).newInstance();
- } else {
- //if we are stateful only a tainted artifact is reloaded
- _delegate = _weaver.reloadScriptingInstance(_delegate, _artifactType);
-
- //we work our way through all proxies and fetch the class for further reference
- Object delegate = WeavingContext.getDelegateFromProxy(_delegate);
- _loadedClass = delegate.getClass();
- }
- //check for proxies and unproxy them before calling the methods
- //to avoid unnecessary cast problems
- //this is slow on long param lists but it is better
- //to be slow than to have casts an calls in the code
- //for production we can compile the classes anyway and avoid
- //this
- unmapProxies(paramHolders);
- return method.invoke(_delegate, paramHolders);
- }
-
- /**
- * unmap proxied objects
- *
- * @param objects the objects to be unmapped
- */
- private void unmapProxies(Object[] objects) {
- if (objects == null) return;
- for (int cnt = 0; cnt < objects.length; cnt++) {
- objects[cnt] = WeavingContext.getDelegateFromProxy(objects[cnt]);
- }
- }
-
- public int getArtifactType() {
- return _artifactType;
- }
-
- public void setArtifactType(int artifactType) {
- _artifactType = artifactType;
- }
-
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
- in.defaultReadObject();
- _weaver = null;
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/ReloadingInvocationHandler.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/ReloadingInvocationHandler.java
deleted file mode 100644
index a272b44..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/ReloadingInvocationHandler.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core;
-
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
-
-import java.lang.reflect.InvocationHandler;
-
-/**
- * <p/>
- * We set our own invocation handler
- * here to allow reflection utils directly targeting our
- * _delegate.
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-@SuppressWarnings("unused")
-public abstract class ReloadingInvocationHandler implements InvocationHandler, Decorated {
- Class _loadedClass = null;
- Object _delegate = null;
-
- /**
- * simplified invoke for more dynamic upon invocation
- * on our reloading objects
- *
- * @param object the object to be invoked on
- * @param method the method to be invoked
- * @param arguments the arguments passed down
- * @return the return value of the operation
- */
- public Object invoke(Object object, String method, Object... arguments) {
- return ReflectUtil.executeMethod(object, method, arguments);
- }
-
- public Class getLoadedClass() {
- return _loadedClass;
- }
-
- public Object getDelegate() {
- return _delegate;
- }
-
- public void setDelegate(Object delegate) {
- _delegate = delegate;
- }
-
- public void setLoadedClassName(Class loadedClass) {
- this._loadedClass = loadedClass;
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/StandardDependencyScanner.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/StandardDependencyScanner.java
deleted file mode 100644
index 12387df..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/StandardDependencyScanner.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan;
-
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.api.DependencyRegistry;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.api.DependencyScanner;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.core.ClassScanUtils;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.core.ClassScanVisitor;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.core.ExtendedClassReader;
-import org.objectweb.asm.ClassReader;
-
-import java.io.IOException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * A dependency scanner for
- * our classes. This class is thread save on object level
- * and can be used as a singleton
- * <p/>
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-public class StandardDependencyScanner implements DependencyScanner {
- final ClassScanVisitor _cp = new ClassScanVisitor();
- Logger _logger = Logger.getLogger(this.getClass().getName());
-
- public StandardDependencyScanner() {
-
- }
-
- public synchronized final void fetchDependencies(ClassLoader loader, Integer engineType, String className, DependencyRegistry registry) {
- _cp.setEngineType(engineType);
- _cp.setRootClass(className);
- _cp.setDependencyRegistry(registry);
- investigateInheritanceHierarchy(loader, className);
- registry.flush(engineType);
- }
-
- /**
- * this investigates the classes inheritance hierarchy for
- * more dependencies, for now annotations and interfaces
- * are omitted since they are not vital to our jsf dependency checks
- * (maybe in the long run we will add interfaces and annotations as well
- * but for now we will leave them away for speed reasons)
- *
- * @param loader the classLoader which should be used for the hierarchy scanning
- * @param className the className which has to be investigated
- */
- private void investigateInheritanceHierarchy(ClassLoader loader, String className) {
- //we now have to fetch the parent hierarchy
-
- try {
- Class toCheck = loader.loadClass(className);
- if (toCheck == null) {
- return;
- }
- scanCurrentClass(loader, className);
-
- //we scan the hierarchy because we might have compiled-uncompiled-compiled connections, the same goes for the interfaces
- //the basic stuff can be covered by our class scanning but for more advanced usecase we have to walk the entire hierarchy per class!
- scanHierarchy(loader, toCheck);
- //our asm code normally covers this but since the scanner has to work outside of asm we do it twice, the same goes for the hierarchy
- scanInterfaces(loader, toCheck);
- } catch (ClassNotFoundException e) {
- _logger.log(Level.SEVERE, "DefaultDependencyScanner.investigateInheritanceHierarchy() ", e);
- }
- }
-
- private void scanInterfaces(ClassLoader loader, Class toCheck) {
- Class[] interfaces = toCheck.getInterfaces();
- if (interfaces == null || interfaces.length == 0) {
- return;
- }
-
- for (Class currentInterface : interfaces) {
- if (ClassScanUtils.isStandardNamespace(currentInterface.getName())) {
- continue;
- }
- scanCurrentClass(loader, currentInterface.getName());
-
- //We scan also our parent interfaces to get a full coverage
- //but since interfaces do not implement anything we can cover
- //the parents
- scanHierarchy(loader, currentInterface);
- }
- }
-
- /**
- * scans the parent child relationship hierarchy
- * We have to go through the entire hierarchy except for standard
- * namespaces due to the fact that we have to cover source <->binary<->source
- * dependencies with binary being binary classes never to be refreshed
- * <p/>
- * Note we can optionally do some interface checks here
- * for now annotations are only processed by the class scanner itself
- * so we do not process any annotation inheritance on this level
- * we will add the feature later
- *
- * @param loader the infrastructural classloader
- * @param toCheck the class which needs to be checked
- */
- private void scanHierarchy(ClassLoader loader, Class toCheck) {
- Class parent = toCheck.getSuperclass();
-
- while (parent != null && !ClassScanUtils.isStandardNamespace(parent.getName())) {
- scanCurrentClass(loader, parent.getName());
- parent = parent.getSuperclass();
- }
- }
-
- /**
- * scans one level of the inheritance hierarchy
- *
- * @param loader the classLoader which should be used for the hierarchy scanning
- * @param currentClassName the className which has to be investigated
- */
- private void scanCurrentClass(ClassLoader loader, String currentClassName) {
- ClassReader cr;
- try {
- cr = new ExtendedClassReader(loader, currentClassName);
- cr.accept(_cp, 0);
- } catch (IOException e) {
- _logger.log(Level.SEVERE, "scanCurrentClass() ", e);
- }
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/api/ClassFilter.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/api/ClassFilter.java
deleted file mode 100644
index e585227..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/api/ClassFilter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.api;
-
-/**
- * Generic filter pattern interface
- * used by our dependency registry to pre-filter the classes
- */
-public interface ClassFilter {
-
- /**
- * checks whether the class is allowed to be processed by the filter or not
- *
- * @param engineType integer value of the engine type of the class
- * @param clazz the class itself to be processed by the filter
- * @return true if it is allowed to be processed false otherwise
- */
- public boolean isAllowed(Integer engineType, String clazz);
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/api/DependencyRegistry.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/api/DependencyRegistry.java
deleted file mode 100644
index 21c3a4a..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/api/DependencyRegistry.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.api;
-
-/**
- * General contractual interface for a dependency registry
- * The dependency registry is a class which stores dependencies
- * according to an internal whitelisting system.
- * <p/>
- * Only classes which pass the whitelisting check will be processed
- */
-public interface DependencyRegistry {
- /**
- * adds a source dependency if it is able to pass the
- * filters
- * A dependency is only allowed to pass if it is able
- * to pass the internal filter list
- *
- * @param engineType the engine type for this dependency
- * @param rootClass the root class of this scan which all dependencies are referenced from
- * @param currentlyVisitedClass the source which includes or casts the dependencies
- * @param dependency the dependency to be added
- */
- void addDependency(Integer engineType, String rootClass, String currentlyVisitedClass, String dependency);
-
- /**
- * Flush which is issued at the end of processing to flush
- * any content which has not been yet processed into our content holding
- * data structures
- *
- * @param engineType the engine type which has issued the flush operation
- */
- void flush(Integer engineType);
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/api/DependencyScanner.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/api/DependencyScanner.java
deleted file mode 100644
index 8799b66..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/api/DependencyScanner.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.api;
-
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.api.DependencyRegistry;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.registry.ExternalFilterDependencyRegistry;
-
-/**
- * Standard dependency scanner interface
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-public interface DependencyScanner {
- /**
- * main method every dependency scanner has to implement
- *
- * @param loader the classloader which is able to serve the requested class resources
- * @param engineType integer value of the scanning triggering engine type
- * @param className of the class to be scanned
- * @param registry the registry which should receive the results of the scan
- */
- public void fetchDependencies(ClassLoader loader, Integer engineType, String className, DependencyRegistry registry);
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ClassDependencies.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ClassDependencies.java
deleted file mode 100644
index 27ea9a5..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ClassDependencies.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.core;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * class dependency maps
- * note this class is thread save
- */
-public class ClassDependencies {
-
- /**
- * reverse index which shows which
- * a class name and which classes in the system depend on that
- * classname
- * <p/>
- * <p/>
- * the key is a dependency a class has the _value is a set of classes which depend on the current class
- */
- private Map<String, Set<String>> reverseIndex = new ConcurrentHashMap<String, Set<String>>();
-
- public void addDependency(String referencingClass, String referencedClass) {
- Set<String> reverseDependencies = getReverseDependencies(referencedClass);
- reverseDependencies.add(referencingClass);
- }
-
- /**
- * adds a set of dependencies to the
- * reverse lookup index
- *
- * @param referencingClass the referencing class of this dependency
- * @param referencedClasses the referenced class of this dependency
- */
- public void addDependencies(String referencingClass, Collection<String> referencedClasses) {
- for (String referencedClass : referencedClasses) {
- addDependency(referencingClass, referencedClass);
- }
- }
-
- /**
- * removes a referenced class an all its referencing classes!
- *
- * @param clazz the referenced class to be deleted
- */
- public void removeReferenced(String clazz) {
- reverseIndex.remove(clazz);
- }
-
- /**
- * removes a referencing class
- * and deletes the referenced
- * entry if it is not referenced anymore
- *
- * @param clazz the referencing class to delete
- */
- @SuppressWarnings("unused")
- public void removeReferrer(String clazz) {
- List<String> emptyReferences = new ArrayList<String>(reverseIndex.size());
- for (Map.Entry<String, Set<String>> entry : reverseIndex.entrySet()) {
- Set<String> entrySet = entry.getValue();
- entrySet.remove(clazz);
- if (entrySet.isEmpty()) {
- emptyReferences.add(entry.getKey());
- }
- }
- for (String toDelete : emptyReferences) {
- removeReferenced(toDelete);
- }
- }
-
- public Set<String> getReferringClasses(String referencedClass) {
- return reverseIndex.get(referencedClass);
- }
-
- private Set<String> getReverseDependencies(String dependency) {
- Set<String> dependencies = reverseIndex.get(dependency);
- if (dependencies == null) {
- dependencies = Collections.synchronizedSet(new HashSet<String>());
- reverseIndex.put(dependency, dependencies);
- }
- return dependencies;
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ClassScanUtils.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ClassScanUtils.java
deleted file mode 100644
index 69ea62e..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ClassScanUtils.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.core;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * Utils which store the shared code
- */
-public class ClassScanUtils {
-
- private static final String DOMAIN_JAVA = "java.";
- private static final String DOMAIN_JAVAX = "javax.";
- private static final String DOMAIN_COM_SUN = "com.sun";
- private static final String DOMAIN_APACHE = "org.apache.";
- private static final String DOMAIN_MYFACES = "org.apache.myfaces";
- private static final String DOMAIN_JBOSS = "org.jboss";
- private static final String DOMAIN_SPRING = "org.springframework";
- private static final String DOMAIN_JUNIT = "org.junit";
- private static final String DOMAIN_ECLIPSE = "org.eclipse";
- private static final String DOMAIN_NETBEANS = "org.netbeans";
- private static final String DOMAIN_GROOVY = "groovy.";
- private static final String DOMAIN_SCALA = "scala.";
- private static final String DOMAIN_JYTHON = "jython.";
- private static final String DOMAIN_JRUBY = "jruby.";
-
- /**
- * checks if a given package or class
- * belongs to a standard namespaces which is
- * untouchable by an implementer
- *
- * @param in the page or fully qualified classname
- * @return true if it belongs to one of the standard namespaces, false if not
- */
- public static boolean isStandardNamespace(String in) {
- //We don't use a regexp here, because an test has shown that direct startsWith is 5 times as fast as applying
- //a precompiled regexp with match
-
- //shortcuts for a faster killing of the add before going into the heavier
- //whitelist check, this one kills off classes which belong to standard
- //and semi standard namespaces before whitelisting the rest
- return in.startsWith(DOMAIN_JAVA) ||
- in.startsWith(DOMAIN_JAVAX) ||
- in.startsWith(DOMAIN_COM_SUN) ||
- in.startsWith(DOMAIN_GROOVY) ||
- in.startsWith(DOMAIN_JYTHON) ||
- in.startsWith(DOMAIN_JRUBY) ||
- in.startsWith(DOMAIN_SCALA) ||
- in.startsWith(DOMAIN_JBOSS) ||
- in.startsWith(DOMAIN_SPRING) ||
- in.startsWith(DOMAIN_JUNIT) ||
- in.startsWith(DOMAIN_ECLIPSE) ||
- in.startsWith(DOMAIN_NETBEANS) ||
-
- //apache domain has to be treated specially myfaces can be referenced due to our tests and demos, otherwise this one
- //is also treated as taboo zone
- ((in.startsWith(DOMAIN_APACHE) &&
- !in.startsWith(DOMAIN_MYFACES)));
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ClassScanVisitor.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ClassScanVisitor.java
deleted file mode 100644
index 603c3b6..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ClassScanVisitor.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.core;
-
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.api.DependencyRegistry;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.registry.ExternalFilterDependencyRegistry;
-import org.objectweb.asm.*;
-import org.objectweb.asm.signature.SignatureReader;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * The central visitor for the class scanner. ASM uses a visitor interface for high performance
- * to step through classes.
- * <p/>
- * We reuse this pattern to get the best performance possible in this critical part of the application
- * which also is triggered by the startup process.
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-public class ClassScanVisitor implements ClassVisitor {
-
- DependencyRegistry _dependencyRegistry;
- String _currentlyVistedClass;
- Integer _engineType;
- String _rootClass;
- static final Logger _log = Logger.getLogger(ClassScanVisitor.class.getName());
-
- public ClassScanVisitor() {
- }
-
- public ClassScanVisitor(Integer engineType, String rootClass, ExternalFilterDependencyRegistry registry) {
- _dependencyRegistry = registry;
- _engineType = engineType;
- _rootClass = rootClass;
- }
-
- public void visit(int version, int access, String name,
- String signature, String superName, String[] interfaces) {
- _currentlyVistedClass = Type.getObjectType(name).getClassName();
- if (superName != null)
- registerDependency(Type.getObjectType(superName));
-
- handleGenerics(signature, true);
-
- if (interfaces != null && interfaces.length > 0) {
- for (String currInterface : interfaces) {
- if (currInterface != null)
- registerDependency(Type.getObjectType(currInterface));
- }
- }
- }
-
- public void visitSource(String source, String debug) {
- _log.log(Level.FINEST, "visitSource: {0}", source);
- }
-
- public void visitOuterClass(String owner, String name, String description) {
- //nothing has to be done here I guess because
- //we only try to fetch the dependencies
- _log.log(Level.FINEST, "visitOuterClass: {0} {1} {2}", new String[]{owner, name, description});
-
- }
-
- public AnnotationVisitor visitAnnotation(String description,
- boolean visible) {
- if (description != null)
- registerDependency(Type.getType(description));
-
- return null;
- }
-
- public void visitAttribute(Attribute attribute) {
- }
-
- public void visitInnerClass(String name, String outerName,
- String innerName, int access) {
- //same as outer class
- _log.log(Level.FINEST, "visitInnerClass: {0} {1} {2} ", new String[]{name, outerName, innerName});
- }
-
- public FieldVisitor visitField(int access, String name, String description,
- String signature, Object value) {
- //_log._log(Level.INFO, "Field:{0} {1} ", new Object[]{description, name});
- handleGenerics(signature, false);
- if (description != null)
- registerDependency(Type.getType(description));
-
- return null;
- }
-
- private void registerDependency(Type dependency) {
- String className = dependency.getClassName();
- if (className.endsWith("[]")) {
- className = className.substring(0, className.indexOf("["));
- }
-
- if (_dependencyRegistry != null) {
- _dependencyRegistry.addDependency(_engineType, _rootClass, _currentlyVistedClass, className);
- }
-
- }
-
- public MethodVisitor visitMethod(int access, String name,
- String description, String signature, String[] exceptions) {
-
- if (description != null)
- registerDependency(Type.getReturnType(description));
-
- handleGenerics(signature, true);
-
- if (description != null) {
- for (Type argumentType : Type.getArgumentTypes(description)) {
- registerDependency(argumentType);
- }
- }
- return new MethodScanVisitor(_engineType, _rootClass, _currentlyVistedClass, _dependencyRegistry);
- }
-
- private void handleGenerics(String signature, boolean accept) {
- if (signature != null && signature.contains("<")) {
- SignatureReader reader = new SignatureReader(signature);
- if (accept)
- reader.accept(new DependencySignatureVisitor(_dependencyRegistry, _engineType, _rootClass, _currentlyVistedClass));
- else
- reader.acceptType(new DependencySignatureVisitor(_dependencyRegistry, _engineType, _rootClass, _currentlyVistedClass));
- }
- }
-
- public void visitEnd() {
- //_log.info("}");
- }
-
- public void setDependencyRegistry(DependencyRegistry dependencyRegistry) {
- _dependencyRegistry = dependencyRegistry;
- }
-
- public void setEngineType(Integer engineType) {
- _engineType = engineType;
- }
-
- public void setRootClass(String rootClass) {
- _rootClass = rootClass;
- }
-}
-
-
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/DependencySignatureVisitor.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/DependencySignatureVisitor.java
deleted file mode 100644
index 661e52a..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/DependencySignatureVisitor.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.core;
-
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.api.DependencyRegistry;
-import org.objectweb.asm.signature.SignatureVisitor;
-import org.objectweb.asm.*;
-
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * We need the signature visitor to get a grip on generics
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class DependencySignatureVisitor implements SignatureVisitor {
-
- static final Logger _log = Logger.getLogger(DependencySignatureVisitor.class.getName());
-
- String _rootClass;
- String _currentClass;
- DependencyRegistry _registry;
- Integer _engineType;
-
- public DependencySignatureVisitor(DependencyRegistry registry, Integer engineType, String currentClass, String rootClass) {
- _registry = registry;
- _currentClass = currentClass;
- _rootClass = rootClass;
- _engineType = engineType;
- }
-
- public void visitFormalTypeParameter(String className) {
- if (_log.isLoggable(Level.FINEST))
- _log.log(Level.FINEST, "visitFormalTypeParameter: {0}", className);
- //the information is lacking the package information on this level no fully qualified name here
- // _registry.addDependency(_engineType, _rootClass, _currentClass, Type.getObjectType(className).getClassName());
- }
-
- public SignatureVisitor visitClassBound() {
- return this;
- }
-
- public SignatureVisitor visitInterfaceBound() {
- return this;
- }
-
- public SignatureVisitor visitSuperclass() {
- return this;
- }
-
- public SignatureVisitor visitInterface() {
- return this;
- }
-
- public SignatureVisitor visitParameterType() {
- return this;
- }
-
- public SignatureVisitor visitReturnType() {
- return this;
- }
-
- public SignatureVisitor visitExceptionType() {
- return this;
- }
-
- public void visitBaseType(char c) {
-
- }
-
- public void visitTypeVariable(String className) {
- if (_log.isLoggable(Level.FINEST))
- _log.log(Level.FINEST, "visitTypeVariable: {0}", className);
- }
-
- public SignatureVisitor visitArrayType() {
- return this;
- }
-
- public void visitClassType(String className) {
- if (_log.isLoggable(Level.FINEST))
- _log.log(Level.FINEST, "visitClassType: {0}", className);
- _registry.addDependency(_engineType, _rootClass, _currentClass, Type.getObjectType(className).getClassName());
- }
-
- public void visitInnerClassType(String className) {
- if (_log.isLoggable(Level.FINEST))
- _log.log(Level.FINEST, "visitInnerClassType: {0}", className);
- }
-
- public void visitTypeArgument() {
-
- }
-
- public SignatureVisitor visitTypeArgument(char c) {
- return this;
- }
-
- public void visitEnd() {
-
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ExtendedClassReader.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ExtendedClassReader.java
deleted file mode 100644
index e19bd49..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ExtendedClassReader.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.core;
-
-import org.objectweb.asm.ClassReader;
-
-import java.io.IOException;
-
-/**
- * Class reader for ASM which allows to plug our own loader instead
- * of the default one
- * <p/>
- * (ASM makes too many assumptions regarding the loader)
- */
-public class ExtendedClassReader extends ClassReader {
- /**
- * classloader pluggable classreader
- *
- * @param loader the loader which has to be plugged into the system
- * @param className the class name for the class which has to be investigated
- * @throws IOException in case of a loading error (class cannot be loaded for whatever reason)
- */
- public ExtendedClassReader(ClassLoader loader, String className) throws IOException {
- super(loader.getResourceAsStream(className.replace('.', '/')
- + ".class"));
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/MethodScanVisitor.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/MethodScanVisitor.java
deleted file mode 100644
index 1d48db1..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/MethodScanVisitor.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.core;
-
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.api.DependencyRegistry;
-import org.objectweb.asm.*;
-import org.objectweb.asm.signature.SignatureReader;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * A scan visitor on method level
- * to cope with method scoped dependencies like inlined
- * fully qualified names, annotations, local variables
- * etc...
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-class MethodScanVisitor implements MethodVisitor {
-
- // static final Logger log = Logger.getLogger("ClassScanVisitor");
-
- String _currentlyVisitedClass = null;
- String _rootClass;
- Integer _engineType = null;
- DependencyRegistry _dependencyRegistry = null;
-
- static Logger _log = Logger.getLogger(MethodScanVisitor.class.getName());
-
- public MethodScanVisitor(Integer engineType, String rootClass, String currentlyVisitedClass, DependencyRegistry registry) {
- _currentlyVisitedClass = currentlyVisitedClass;
- _dependencyRegistry = registry;
- _engineType = engineType;
- _rootClass = rootClass;
- }
-
- public AnnotationVisitor visitAnnotationDefault() {
- return null;
- }
-
- public AnnotationVisitor visitAnnotation(String description, boolean b) {
- if(description != null) {
- registerDependency(Type.getType(description));
- }
- return null;
- }
-
- public AnnotationVisitor visitParameterAnnotation(int opCode, String description, boolean b) {
- if(description != null) {
- registerDependency(Type.getType(description));
- }
- return null;
- }
-
- public void visitAttribute(Attribute attribute) {
- if (_log.isLoggable(Level.FINEST))
- _log.log(Level.FINEST, "visitAttribute {0}", attribute.type);
- }
-
- public void visitCode() {
- //log.log(Level.INFO, "Method code");
- }
-
- public void visitFrame(int opCode1, int opCode2, Object[] objects, int opCode3, Object[] objects1) {
- if (_log.isLoggable(Level.FINEST))
- _log.log(Level.FINEST, "visitFrame {0}", "");
-
- }
-
- public void visitInsn(int opCode) {
- }
-
- public void visitIntInsn(int opCode1, int opCode2) {
- }
-
- public void visitVarInsn(int opCode1, int opCode2) {
- }
-
- public void visitTypeInsn(int opCode, String castType) {
- //cast
- // log.log(Level.INFO, "TypeInsn: {0} ", new String[]{castType});
- if (castType != null) {
- registerDependency(Type.getObjectType(castType));
- if (_log.isLoggable(Level.FINEST))
- _log.log(Level.FINEST, "visitTypeInsn {0}", castType);
- }
- }
-
- private void registerDependency(Type dependency) {
-
- String className = dependency.getClassName();
- if (className.endsWith("[]")) {
- className = className.substring(0, className.indexOf("["));
- }
-
- if (_dependencyRegistry != null) {
- _dependencyRegistry.addDependency(_engineType, _rootClass, _currentlyVisitedClass, className);
- }
- }
-
- /**
- * @param opCode the opCode of the insert statement
- * @param owner hosting classname of field (always the calling class afaik)
- * @param name internal descriptor
- * @param descriptor field type
- */
- public void visitFieldInsn(int opCode, String owner, String name, String descriptor) {
- // log.log(Level.INFO, "visitFieldInsn {0} {1} {2}", new Object[]{owner, name, descriptor});
- //we have to deal with static imports as special case of field insertions
- if (name != null && name.length() > 6 && name.startsWith("class$")) {
- //special fallback for groovy static imports which are added as fields
- name = "L" + name.substring(6).replaceAll("\\$", ".") + ";";
- registerDependency(Type.getType(name));
- }
- if (descriptor != null) {
- registerDependency(Type.getType(descriptor));
- }
-
- if (_log.isLoggable(Level.FINEST))
- _log.log(Level.FINEST, "visitFieldInsn {0}", descriptor);
-
- }
-
- /**
- * Method call
- *
- * @param opc internal opcode
- * @param owner hosting classname of the method
- * @param name method name
- * @param desc descriptor string
- */
- public void visitMethodInsn(int opc, String owner, String name, String desc) {
- //s2 arguments list
- if (desc != null) {
- registerDependency(Type.getReturnType(desc));
- Type[] argumentTypes = Type.getArgumentTypes(desc);
- if (argumentTypes != null) {
- for (Type argumentType : argumentTypes) {
- registerDependency(argumentType);
- }
- }
- }
-
- if (owner != null)
- registerDependency(Type.getObjectType(owner));
-
- }
-
- public void visitJumpInsn(int i, Label label) {
-
- }
-
- public void visitLabel(Label label) {
-
- }
-
- public void visitLdcInsn(Object o) {
-
- }
-
- public void visitIincInsn(int i, int i1) {
-
- }
-
- public void visitTableSwitchInsn(int i, int i1, Label label, Label[] labels) {
-
- }
-
- public void visitLookupSwitchInsn(Label label, int[] ints, Label[] labels) {
-
- }
-
- public void visitMultiANewArrayInsn(String s, int i) {
- if (_log.isLoggable(Level.FINEST))
- _log.log(Level.FINEST, "visitMultiANewArrayInsn {0}", s);
- }
-
- public void visitTryCatchBlock(Label label, Label label1, Label label2, String catchType) {
- //try catch block type information in the last string
- //log.log(Level.INFO, "visitTryCatchBlock: {0} {1} {2} {3}", new Object[]{label.toString(), label1.toString(), label2.toString(), catchType});
- if (catchType != null) {
- registerDependency(Type.getObjectType(catchType));
- }
- }
-
- public void visitLocalVariable(String name, String description, String signature, Label label, Label label1, int i) {
- //local variable on method level
- if (description != null) {
- registerDependency(Type.getType(description));
- }
- if (signature != null) {
- handleGenerics(signature);
- }
- }
-
- public void visitLineNumber(int i, Label label) {
-
- }
-
- public void visitMaxs(int i, int i1) {
-
- }
-
- public void visitEnd() {
-
- }
-
- private void handleGenerics(String signature) {
- if (signature != null && signature.contains("<")) {
- SignatureReader reader = new SignatureReader(signature);
- reader.acceptType(new DependencySignatureVisitor(_dependencyRegistry, _engineType, _rootClass, _currentlyVisitedClass));
- }
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/filter/ScanIdentifierFilter.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/filter/ScanIdentifierFilter.java
deleted file mode 100644
index d684d7c..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/filter/ScanIdentifierFilter.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.filter;
-
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.api.ClassFilter;
-
-import java.util.Arrays;
-
-/**
- * a filter which works on the scan identifiers
- * only classes which trigger on the same identifier
- * are allowed to be passed through
- */
-public class ScanIdentifierFilter implements ClassFilter {
-
- private final int [] _engineType;
-
- public ScanIdentifierFilter(int ... engineType) {
- _engineType = Arrays.copyOf(engineType, engineType.length);
- }
-
- public boolean isAllowed(Integer identifier, String clazz) {
- int id = identifier;
- for(int engineType: _engineType) {
- boolean allowed = engineType == id;
- if(allowed) return true;
- }
- return false;
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/filter/StandardNamespaceFilter.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/filter/StandardNamespaceFilter.java
deleted file mode 100644
index 664c03a..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/filter/StandardNamespaceFilter.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.filter;
-
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.core.ClassScanUtils;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.api.ClassFilter;
-
-/**
- * Filter facade for our standard namespace check
- */
-public class StandardNamespaceFilter implements ClassFilter {
-
- /**
- * is allowed implementation for our standard namespace filter
- *
- * @param engineType integer value of the engine type of the class
- * @param clazz the class itself to be processed by the filter
- * @return true if it is not in the standard namespaces false otherwise
- */
- public final boolean isAllowed(Integer engineType, String clazz) {
- return !ClassScanUtils.isStandardNamespace(clazz);
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/filter/WhitelistFilter.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/filter/WhitelistFilter.java
deleted file mode 100644
index 053d3a0..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/filter/WhitelistFilter.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.filter;
-
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.api.ClassFilter;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Filter class which depends upon a list of whitelisted packages
- * wildcards in this filter are implicit which means
- * <p/>
- * org.apache.myfaces includes all files
- * under org.apache.myfaces
- */
-public class WhitelistFilter implements ClassFilter {
-
- WhiteListNode _whiteList = new WhiteListNode();
-
- /*we use a package tree here to make the whitelist check as performant as possible*/
-
- class WhiteListNode {
- Map<String, WhiteListNode> _value = new ConcurrentHashMap<String, WhiteListNode>();
-
- public WhiteListNode addEntry(String key) {
- if (_value.containsKey(key)) {
- return _value.get(key);
- }
- WhiteListNode retVal = new WhiteListNode();
- _value.put(key, retVal);
- return retVal;
- }
-
- public boolean hasChildren() {
- return !_value.isEmpty();
- }
-
- public Map<String, WhiteListNode> getValue() {
- return _value;
- }
-
- public void setValue(Map<String, WhiteListNode> value) {
- this._value = value;
- }
-
- public WhiteListNode get(String key) {
- return _value.get(key);
- }
- }
-
- public WhitelistFilter(String... whiteList) {
- for (String singlePackage : whiteList) {
- addEntry(singlePackage);
- }
- }
-
- public WhitelistFilter(Collection<String> whiteList) {
- for (String singlePackage : whiteList) {
- addEntry(singlePackage);
- }
- }
-
- /**
- * whitespace is allowed implementation
- *
- * @param engineType integer value of the engine type of the class
- * @param clazz the class itself to be processed by the filter
- * @return true if it is white-spaced, false otherwise
- */
- public final boolean isAllowed(Integer engineType, String clazz) {
- String[] subParts = clazz.split("\\.");
- WhiteListNode currPackage = _whiteList;
- WhiteListNode parentPackage = null;
- for (String subPart : subParts) {
- currPackage = currPackage.get(subPart);
- if (isRootPackageMismatch(currPackage, parentPackage)) {
- return false;
- } else if (isSubpackage(currPackage, parentPackage)) {
- return true;
- } else if (isMismatch(currPackage)) {
- return false;
- }
-
- parentPackage = currPackage;
- }
- return true;
- }
-
- private void addEntry(String singlePackage) {
- String[] subPackages = singlePackage.split("\\.");
- WhiteListNode currPackage = _whiteList;
- for (String subPackage : subPackages) {
- currPackage = currPackage.addEntry(subPackage);
- }
- }
-
- //special conditions extracted for readability reasons in the core
- //algorithm
-
- private boolean isMismatch(WhiteListNode currPackage) {
- return currPackage == null;
- }
-
- private boolean isSubpackage(WhiteListNode currPackage, WhiteListNode parentPackage) {
- return currPackage == null && parentPackage != null && !parentPackage.hasChildren();
- }
-
- private boolean isRootPackageMismatch(WhiteListNode currPackage, WhiteListNode parentPackage) {
- return currPackage == null && parentPackage == null;
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/registry/DependencyRegistryImpl.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/registry/DependencyRegistryImpl.java
deleted file mode 100644
index e3dae28..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/registry/DependencyRegistryImpl.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.registry;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.api.ClassFilter;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.core.ClassDependencies;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.filter.ScanIdentifierFilter;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.filter.StandardNamespaceFilter;
-import org.apache.myfaces.extensions.scripting.core.util.StringUtils;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * registry facade which is used to track our dependencies
- */
-public class DependencyRegistryImpl implements ExternalFilterDependencyRegistry {
- List<ClassFilter> _filters = new LinkedList<ClassFilter>();
-
- ClassDependencies _dependencMap;
-
- //private volatile Strategy _registrationStrategy;
- final Integer _engineType;
-
- /**
- * constructor for our facade
- *
- * @param engineType the engine type this registry should support
- * @param dependencyMap the dependency map which stores the dependencies
- */
- public DependencyRegistryImpl(Integer engineType, ClassDependencies dependencyMap) {
- _dependencMap = dependencyMap;
- _engineType = engineType;
-
- _filters.add(new ScanIdentifierFilter(_engineType, ScriptingConst.ENGINE_TYPE_JSF_ALL, ScriptingConst.ENGINE_TYPE_JSF_NO_ENGINE));
- _filters.add(new StandardNamespaceFilter());
- }
-
- /**
- * Clears the entire filter map
- */
- public void clearFilters() {
- _filters.clear();
- _filters.add(new ScanIdentifierFilter(_engineType, ScriptingConst.ENGINE_TYPE_JSF_ALL, ScriptingConst.ENGINE_TYPE_JSF_NO_ENGINE));
- _filters.add(new StandardNamespaceFilter());
- }
-
- /**
- * adds a new filter
- *
- * @param filter the filter to be added
- */
- public void addFilter(ClassFilter filter) {
- _filters.add(filter);
- }
-
- /**
- * checks if the className is allowed in the current filter chain
- *
- * @param engineType an identifier for the current scan type (jsf java scan for instance)
- * @param className the classname to be checked
- * @return true if a filter triggers false if not
- */
- public boolean isAllowed(Integer engineType, String className) {
- for (ClassFilter filter : _filters) {
- if (!filter.isAllowed(_engineType, className)) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * adds a dependency to our dependency map (usually rootclass -> dependency and currentClass -> dependency)
- *
- * @param engineType the engine type for this dependency
- * @param rootClass the root class of this scan which all dependencies are referenced from
- * @param currentlyVisitedClass the source which includes or casts the dependencies
- * @param dependency the dependency to be added
- */
- public void addDependency(Integer engineType, String rootClass, String currentlyVisitedClass, String dependency) {
-
- if (StringUtils.isBlank(dependency)) {
- return;
- }
-
- if (currentlyVisitedClass != null && currentlyVisitedClass.equals(dependency)) {
- return;
- }
-
-
-
- if (!isAllowed(engineType, dependency)) {
- return;
- }
-
- //not needed
- //if(!StringUtils.isBlank(currentlyVisitedClass)) {
- // _dependencMap.addDependency(currentlyVisitedClass, dependency);
- //}
-
- //for now we code it into a list like we used to do before
- //but in the long run we have to directly register
- //to save one step
- //getDependencySet(source).add(dependency);
- if(!StringUtils.isBlank(rootClass)) {
- _dependencMap.addDependency(rootClass, dependency);
- }
- }
-
- /**
- * flush to flush down our stored dependencies into our final map
- */
- public void flush(Integer engineType) {
- //_registrationStrategy.apply(_dependencies);
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/registry/ExternalFilterDependencyRegistry.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/registry/ExternalFilterDependencyRegistry.java
deleted file mode 100644
index eaf3307..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/registry/ExternalFilterDependencyRegistry.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.registry;
-
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.api.DependencyRegistry;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.api.ClassFilter;
-
-/**
- * General contractual interface for a dependency registry with external filters
- * being settable
- * <p/>
- * The dependency registry is a class which stores dependencies
- * according to an internal whitelisting system.
- * <p/>
- * Only classes which pass the whitelisting check will be processed
- */
-public interface ExternalFilterDependencyRegistry extends DependencyRegistry {
-
- /**
- * Clears the internal filters
- * for the registry
- */
- void clearFilters();
-
- /**
- * adds another filter to the internal filter list
- *
- * @param filter the filter to be added
- */
- void addFilter(ClassFilter filter);
-
- /**
- * Allowance check for external shortcutting
- * This check triggers into the internal filters
- * to pre-check if a class is allowed to pass or not
- *
- * @param className the classname to be checked
- * @param engineType an identifier for the current scan type (jsf java scan for instance)
- * @return true if it is false otherwise
- */
- public boolean isAllowed(Integer engineType, String className);
-
- /**
- * Flush operation to batch sync
- * the current dependencies against a storage
- * <p/>
- * (will be removed later once we have all the code transitioned
- * to the registry system)
- */
- void flush(Integer engineType);
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/registry/MasterDependencyRegistry.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/registry/MasterDependencyRegistry.java
deleted file mode 100644
index 481c48a..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/registry/MasterDependencyRegistry.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.registry;
-
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.api.DependencyRegistry;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * A master dependency registry which keeps track of various
- * sub-registries in our dependency scanning system
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-public class MasterDependencyRegistry implements DependencyRegistry {
-
- /**
- * We keep our central registry in a map
- * with the engineType as key value to detect which
- * registry needs to be triggered
- */
- private Map<Integer, DependencyRegistry> _subRegistries = new ConcurrentHashMap<Integer, DependencyRegistry>();
-
- /**
- * adds a new dependency to all registered registries
- *
- * @param engineType the engine type which holds the registry
- * @param rootClass the root class of this scan which all dependencies are referenced from
- * @param currentClass the current class scanned
- * @param dependency the dependency to be added relative to the current class
- */
- public void addDependency(Integer engineType, String rootClass, String currentClass, String dependency) {
- for (Map.Entry<Integer, DependencyRegistry> entry : _subRegistries.entrySet()) {
- entry.getValue().addDependency(engineType, rootClass, currentClass, dependency);
- }
- }
-
- /**
- * Flush which is issued at the end of processing to flush
- * any content which has not been yet processed into our content holding
- * data structures
- *
- * @param engineType the engine type which has issued the flush operation
- */
- public void flush(Integer engineType) {
- for (Map.Entry<Integer, DependencyRegistry> entry : _subRegistries.entrySet()) {
- entry.getValue().flush(engineType);
- }
- }
-
- /**
- * adds a subregistry to our current master registry
- *
- * @param engineType the engine type which is the key to our subregistry
- * @param registry the subregistry which has to be added
- */
- public void addSubregistry(Integer engineType, DependencyRegistry registry) {
- _subRegistries.put(engineType, registry);
- }
-
- /**
- * Getter for getting a subregistry from our given registry
- *
- * @param engineType the engine type to search for
- * @return the subregistry according to the engine type, or null if none is found
- */
- public DependencyRegistry getSubregistry(Integer engineType) {
- return _subRegistries.get(engineType);
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/reloading/GlobalReloadingStrategy.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/reloading/GlobalReloadingStrategy.java
deleted file mode 100644
index fc52e7d..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/reloading/GlobalReloadingStrategy.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.reloading;
-
-import org.apache.myfaces.extensions.scripting.api.ReloadingStrategy;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.extensions.scripting.core.util.Cast;
-import org.apache.myfaces.extensions.scripting.core.util.ClassUtils;
-import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * A reloading strategy chain of responsibility which switches
- * depending on the artifact type to the correct
- * strategy
- * <p/>
- * TODO make the reloading strategy pluggable from outside (1.1)!
- */
-
-public class GlobalReloadingStrategy implements ReloadingStrategy {
-
- final Logger _logger = Logger.getLogger(GlobalReloadingStrategy.class.getName());
-
- protected ScriptingWeaver _weaver = null;
-
- protected ReloadingStrategy _beanStrategy;
- protected ReloadingStrategy _noMappingStrategy;
- protected ReloadingStrategy _allOthers;
-
- /*loaded dynamically for myfaces 2+*/
- protected ReloadingStrategy _componentHandlerStrategy;
- protected ReloadingStrategy _validatorHandlerStrategy;
- protected ReloadingStrategy _converterHandlerStrategy;
- protected ReloadingStrategy _behaviorHandlerStrategy;
-
- public GlobalReloadingStrategy(ScriptingWeaver weaver) {
- setWeaver(weaver);
- }
-
- public GlobalReloadingStrategy() {
-
- }
-
- /**
- * the strategy callback which switches between various strategies
- * we have in our system
- *
- * @param toReload the object which has to be reloaded
- * @param artifactType the artifact type for which the reloading strategy has to be applied to
- * @return either the same or a reloading object depending on the current state of the object
- */
- public Object reload(Object toReload, int artifactType) {
-
- switch (artifactType) {
- case ScriptingConst.ARTIFACT_TYPE_MANAGEDBEAN:
- return _beanStrategy.reload(toReload, artifactType);
-
- case ScriptingConst.ARTIFACT_TYPE_RENDERER:
- return _noMappingStrategy.reload(toReload, artifactType);
- case ScriptingConst.ARTIFACT_TYPE_BEHAVIOR:
- return _noMappingStrategy.reload(toReload, artifactType);
- case ScriptingConst.ARTIFACT_TYPE_CLIENTBEHAVIORRENDERER:
- return _noMappingStrategy.reload(toReload, artifactType);
- case ScriptingConst.ARTIFACT_TYPE_COMPONENT:
- return _noMappingStrategy.reload(toReload, artifactType);
- case ScriptingConst.ARTIFACT_TYPE_VALIDATOR:
- return _noMappingStrategy.reload(toReload, artifactType);
-
- case ScriptingConst.ARTIFACT_TYPE_COMPONENT_HANDLER:
- return dynaReload(toReload, _componentHandlerStrategy, artifactType);
- case ScriptingConst.ARTIFACT_TYPE_CONVERTER_HANDLER:
- return dynaReload(toReload, _converterHandlerStrategy, artifactType);
- case ScriptingConst.ARTIFACT_TYPE_VALIDATOR_HANDLER:
- return dynaReload(toReload, _validatorHandlerStrategy, artifactType);
- case ScriptingConst.ARTIFACT_TYPE_BEHAVIOR_HANDLER:
- return dynaReload(toReload, _behaviorHandlerStrategy, artifactType);
-
- default:
- return _allOthers.reload(toReload, artifactType);
- }
- }
-
- public void setWeaver(ScriptingWeaver weaver) {
- _weaver = weaver;
- _beanStrategy = new ManagedBeanReloadingStrategy(weaver);
- _noMappingStrategy = new NoMappingReloadingStrategy(weaver);
- _allOthers = new SimpleReloadingStrategy(weaver);
-
- /*
- * external handlers coming from various submodules
- */
- _componentHandlerStrategy = dynaload(weaver, "org.apache.myfaces.extensions.scripting.facelet.ComponentHandlerReloadingStrategy");
- _validatorHandlerStrategy = dynaload(weaver, "org.apache.myfaces.extensions.scripting.facelet.ValidatorHandlerReloadingStrategy");
- _converterHandlerStrategy = dynaload(weaver, "org.apache.myfaces.extensions.scripting.facelet.ConverterHandlerReloadingStrategy");
- _behaviorHandlerStrategy = dynaload(weaver, "org.apache.myfaces.extensions.scripting.facelet.BehaviorHandlerReloadingStrategy");
- }
-
- public Object dynaReload(Object toReload, ReloadingStrategy strategy, int artifactType) {
- if (strategy == null) {
- //no strategy no reload
- return toReload;
- } else {
- return strategy.reload(toReload, artifactType);
- }
- }
-
- /**
- * load dynamically the given strategy class
- *
- * @param weaver the weaver which the new strategy class is applied to
- * @param strategyClass the strategy class which has to be loaded and instantiated
- * @return an instance of the strategy class if found otherwise null
- */
- private ReloadingStrategy dynaload(ScriptingWeaver weaver, String strategyClass) {
- try {
- Class componentStrategyClass = ClassUtils.forName(strategyClass);
- return (ReloadingStrategy) ReflectUtil.instantiate(componentStrategyClass, new Cast(ScriptingWeaver.class, weaver));
- } catch (RuntimeException ex) {
- //in this case swallowing the exception is expected
- if (_logger.isLoggable(Level.FINEST)) {
- _logger.log(Level.FINEST, "Expected Exception: ", ex);
- }
- }
- return null;
- }
-
- public ScriptingWeaver getWeaver() {
- return _weaver;
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/reloading/ManagedBeanReloadingStrategy.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/reloading/ManagedBeanReloadingStrategy.java
deleted file mode 100644
index 3c45942..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/reloading/ManagedBeanReloadingStrategy.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.reloading;
-
-import org.apache.myfaces.extensions.scripting.api.ReloadingStrategy;
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-
-/**
- * The managed beans have a different reloading
- * strategy. The dependencies of a managed bean
- * are managed by the IOC container and
- * not transferred over the reloading strategy
- * like for all other artifacts.
- * Hence the bean handler removes the bean and its
- * referring backward dependencies, and the runtime system
- * rebuilds the tree anew.
- *
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ManagedBeanReloadingStrategy implements ReloadingStrategy {
-
- ScriptingWeaver _weaver;
-
- public ManagedBeanReloadingStrategy(ScriptingWeaver weaver) {
- _weaver = weaver;
- }
-
- public ManagedBeanReloadingStrategy() {
- }
-
- /**
- * In our case the dropping already has happened at request time
- * no need for another reloading here
- *
- * @param scriptingInstance the instance which has to be reloaded
- * @param artifactType the type of artifact
- * @return does nothing in this case and returns only the original instance, the reloading is handled
- * for managed beans on another level
- */
- public Object reload(Object scriptingInstance, int artifactType) {
- return scriptingInstance;
- }
-
- public ScriptingWeaver getWeaver() {
- return _weaver;
- }
-
- public void setWeaver(ScriptingWeaver weaver) {
- _weaver = weaver;
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/reloading/NoMappingReloadingStrategy.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/reloading/NoMappingReloadingStrategy.java
deleted file mode 100644
index eb006e0..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/reloading/NoMappingReloadingStrategy.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.reloading;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * <p/>
- * The renderer is a stateless flyweight pattern the reloading strategy is
- * to do nothing, this should give optimal results
- * <p/>
- * <p/>
- * The components are a similar case they are not flyweight
- * but the properties usually are preserved by the lifecycle if possible
- * or assigned by the tag handlers
- * <p/>
- * <p/>
- * The same also applies to other flyweight patterned classes
- * like converters or validators
- * <p/>
- * <p/>
- * The only ones which need to keep some state are the ones
- * which keep delegates, like the NavHandler
- */
-public class NoMappingReloadingStrategy extends SimpleReloadingStrategy {
-
- public NoMappingReloadingStrategy(ScriptingWeaver weaver) {
- super(weaver);
- }
-
- @Override
- protected void mapProperties(Object target, Object src) {
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/reloading/SimpleReloadingStrategy.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/reloading/SimpleReloadingStrategy.java
deleted file mode 100644
index dcccb02..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/reloading/SimpleReloadingStrategy.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.reloading;
-
-import org.apache.commons.beanutils.BeanUtils;
-import org.apache.myfaces.extensions.scripting.api.ReloadingStrategy;
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * A simple implementation of our reloading strategy
- * pattern this is the most basic implementation
- * covering our reloading.
- * <p/>
- * Applicable for most artifacts except for now managed beans
- * <p/> *
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class SimpleReloadingStrategy implements ReloadingStrategy {
-
- protected ScriptingWeaver _weaver;
-
- public SimpleReloadingStrategy(ScriptingWeaver weaver) {
- _weaver = weaver;
- }
-
- public SimpleReloadingStrategy() {
-
- }
-
- /**
- * <p>
- * the central callback for our strategy here
- * it has to handle the reload of the scriptingInstance
- * if possible, otherwise it has to return the
- * original object if no reload was necessary or possible
- * </p>
- *
- * @param scriptingInstance the instance to be reloaded by the system
- * @return either the same object or a new instance utilizing the changed code
- */
- public Object reload(Object scriptingInstance, int artefactType) {
-
- //reload the class to get new static content if needed
- Class aclass = _weaver.reloadScriptingClass(scriptingInstance.getClass());
- if (aclass.hashCode() == scriptingInstance.getClass().hashCode()) {
- //class of this object has not changed although
- // reload is enabled we can skip the rest now
- return scriptingInstance;
- }
- getLog().info("[EXT-SCRIPTING] possible reload for " + scriptingInstance.getClass().getName());
- /*only recreation of empty constructor classes is possible*/
- try {
- //reload the object by instantiating a new class and
- // assigning the attributes properly
- Object newObject = aclass.newInstance();
-
- /*now we shuffle the properties between the objects*/
- mapProperties(newObject, scriptingInstance);
-
- return newObject;
- } catch (Exception e) {
- getLog().log(Level.SEVERE, "reload ", e);
- }
- return null;
-
- }
-
- /**
- * helper to map the properties wherever possible
- * <p/>
- * This is the simplest solution for now,
- * we apply only a copy properties here, which should be enough
- * for all artifacts except the managed beans and the ones
- * which have to preserve some kind of delegate before instantiation.
- *
- * @param target the target which has to receive the properties
- * @param src the source which has the original properties
- */
- protected void mapProperties(Object target, Object src) {
- try {
- BeanUtils.copyProperties(target, src);
- } catch (IllegalAccessException e) {
- getLog().log(Level.FINEST, e.toString());
- //this is wanted
- } catch (InvocationTargetException e) {
- getLog().log(Level.FINEST, e.toString());
- //this is wanted
- }
- }
-
- protected Logger getLog() {
- return Logger.getLogger(this.getClass().getName());
- }
-
- public ScriptingWeaver getWeaver() {
- return _weaver;
- }
-
- public void setWeaver(ScriptingWeaver weaver) {
- _weaver = weaver;
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/Array.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/Array.java
deleted file mode 100644
index dd63c16..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/Array.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.util;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-@SuppressWarnings("unused")
-public class Array extends Cast {
- public Array(Class clazz, Object... value) {
-
- super(java.lang.reflect.Array.newInstance(clazz, 0).getClass(), value);
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/Cast.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/Cast.java
deleted file mode 100644
index ecb2862..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/Cast.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.util;
-
-/**
- * Simple casting representation for introspection
- * calls
- */
-public class Cast {
-
- Class clazz;
- Object value;
-
- public Cast(Class clazz, Object value) {
- this.clazz = clazz;
- this.value = value;
- }
-
- public Class getClazz() {
- return clazz;
- }
-
- public Object getValue() {
- return value;
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/ClassLoaderUtils.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/ClassLoaderUtils.java
deleted file mode 100644
index 4141eea..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/ClassLoaderUtils.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.util;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * <p>Utility class for class loading purposes, e.g. to determine the classpath of a
- * class loader hierarchy.</p>
- */
-public class ClassLoaderUtils {
-
-
- // ------------------------------------------ Public methods
-
- /**
- * CompilationResult
- * <p>Returns the default class loader to use.</p>
- *
- * @return the default class loader to use
- */
- public static ClassLoader getDefaultClassLoader() {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- if (classLoader != null) {
- return classLoader;
- } else {
- return ClassLoaderUtils.class.getClassLoader();
- }
- }
-
- /**
- * <p>Determines whether the given class is loadable by the given class loader.</p>
- *
- * @param className the class you want to check
- * @param classLoader the class loader to use for that check
- * @return <code>true</code>, if the given class is loadable by the given class loader
- */
- public static boolean isClassAvailable(String className, ClassLoader classLoader) {
- try {
- classLoader.loadClass(className);
- return true;
- }
- catch (Throwable ex) {
- return false;
- }
- }
-
- /**
- * <p>Resolves the classpath by walking up the hierachy of class loaders. Assuming
- * that we're only dealing with URLClassLoaders it's possible to determine the
- * classpath. This method, however, returns the classpath as a String, where each
- * classpath entry is separated by a ';', i.e. it returns the classpath in a format
- * that Java tools usually expect it to be.</p>
- * <p/>
- * it also adds the additional classpaths issued by our configuration to the list
- *
- * @param classLoader the class loader which you want to resolve the class path for
- * @return the final classpath
- */
- public static String buildClasspath(ClassLoader classLoader) {
- StringBuffer classpath = new StringBuffer();
-
- URL[] urls = resolveClasspath(classLoader);
- for (URL url : urls) {
- classpath.append(url.getPath());
-
- // Note that the classpath separator character is platform
- // dependent. On Windows systems it's ";" whereas on other
- // UNIX systems it's ":".
- classpath.append(File.pathSeparatorChar);
- }
-
- String retVal = classpath.toString();
- if (retVal.endsWith(File.pathSeparator)) {
- retVal = retVal.substring(0, retVal.length() - 1);
- }
- return retVal;
- }
-
- /**
- * <p>Resolves the classpath by walking up the hierarchy of class loaders. Assuming
- * that we're only dealing with URLClassLoaders it's possible to determine the
- * classpath.</p>
- *
- * @param parent the class loader which you want to resolve the class path for
- * @return the final classpath
- */
- public static URL[] resolveClasspath(ClassLoader parent) {
- List<URL> classpath = new ArrayList<URL>();
-
- ClassLoader classLoader = parent;
- // Walk up the hierachy of class loaders in order to determine the current classpath.
- File target = WeavingContext.getConfiguration().getCompileTarget();
- if (target != null) {
- addFile(classpath, target);
- }
-
- while (classLoader != null) {
- if (classLoader instanceof URLClassLoader) {
- URLClassLoader urlClassLoader = (URLClassLoader) classLoader;
-
- URL[] urls = urlClassLoader.getURLs();
- if (urls != null) {
- classpath.addAll(Arrays.asList(urls));
- }
- } /*else {
- if (logger.isWarnEnabled()) {
- logger.warn("Resolving the classpath of the classloader '" + parent + "' - One of its parent class"
- + " loaders is no URLClassLoader '" + classLoader + "', which means it's possible that"
- + " some classpath entries aren't in the final outcome of this method call.");
- }
- } */
-
- //we disable this warning entirely for now because our own url classloader
- //can deal with this properly, due to extra startup context classpath determination
-
- // Inspect the parent class loader next.
- classLoader = classLoader.getParent();
- }
-
- List<String> additionalClassPaths = WeavingContext.getConfiguration().getAdditionalClassPath();
- if (!(additionalClassPaths == null || additionalClassPaths.isEmpty())) {
- for (String additionalClassPath : additionalClassPaths) {
- File additionalPath = new File(additionalClassPath);
- addFile(classpath, additionalPath);
- }
- }
-
- return classpath.toArray(new URL[classpath.size()]);
- }
-
- private static void addFile(List<URL> classpath, File additionalPath) {
- if (additionalPath.exists()) {
- try {
- classpath.add(additionalPath.toURI().toURL());
- } catch (MalformedURLException e) {
- Logger log = Logger.getLogger(ClassLoaderUtils.class.getName());
- log.log(Level.SEVERE, "Additionalclasspath wrong url", e);
- }
- }
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/ClassUtils.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/ClassUtils.java
deleted file mode 100644
index 1cbc473..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/ClassUtils.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.util;
-
-//TODO this needs to be moved into the JSF 2.0 and 1.2 packages
-//reason due to the changes caused by the shade plugin it the ClassLoader
-//Extensions is in shared_impl in 1.2 and in shared in 2.x
-
-import java.io.File;
-
-/**
- * A generic utils class dealing with different aspects
- * (naming and reflection) of java classes
- *
- * @author werpu
- * <p/>
- */
-public class ClassUtils
-{
-
- public static Class forName(String name)
- {
- try
- {
- return Class.forName(name);
- }
- catch (ClassNotFoundException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public static boolean isPresent(String clazz)
- {
- try
- {
- getContextClassLoader().loadClass(clazz);
- }
- catch (ClassNotFoundException e)
- {
- return false;
- }
- return true;
- }
-
- public static File classNameToFile(String classPath, String className)
- {
- String classFileName = classNameToRelativeFileName(className);
- return new File(classPath + File.separator + classFileName);
- }
-
- private static String classNameToRelativeFileName(String className)
- {
- String separator = FileUtils.getFileSeparatorForRegex();
-
- return className.replaceAll("\\.", separator) + ".class";
- }
-
- public static String relativeFileToClassName(String relativeFileName)
- {
- String className = relativeFileName.replaceAll("\\\\", ".").replaceAll("\\/", ".");
- className = className.substring(0, className.lastIndexOf("."));
- return className;
- }
-
- public static void addClassLoadingExtension(Object extension, boolean top)
- {
- try
- {
- ReflectUtil.executeStaticMethod(forName("org.apache.myfaces.shared_impl.util.ClassUtils"),
- "addClassLoadingExtension");
- }
- catch (Exception e)
- {
- ReflectUtil.executeStaticMethod(forName("org.apache.myfaces.shared.util.ClassUtils"),
- "addClassLoadingExtension", extension, top);
- }
-
- //ClassUtils.addClassLoadingExtension(extension, top);
- }
-
- public static ClassLoader getContextClassLoader()
- {
- try
- {
- return (ClassLoader) ReflectUtil.executeStaticMethod(forName("org.apache.myfaces.shared_impl.util.ClassUtils"),
- "getContextClassLoader");
- }
- catch (Exception e)
- {
- return (ClassLoader) ReflectUtil.executeStaticMethod(forName("org.apache.myfaces.shared.util.ClassUtils"),
- "getContextClassLoader");
- }
-
- //return (ClassLoader) ReflectUtil.executeStaticMethod(forName("org.apache.myfaces.extensions.scripting.util" +
- // ".ClassUtils"),
- // "getContextClassLoader");
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/DirStrategy.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/DirStrategy.java
deleted file mode 100644
index 5e84b20..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/DirStrategy.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.util;
-
-import org.apache.myfaces.extensions.scripting.core.util.Strategy;
-
-import java.io.File;
-import java.util.List;
-import java.util.LinkedList;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class DirStrategy implements Strategy {
- List<File> _foundFiles = new LinkedList<File>();
-
- public void apply(Object element) {
- File foundFile = (File) element;
- if (foundFile.isDirectory()) {
- _foundFiles.add(foundFile);
- }
- }
-
- public List<File> getFoundFiles() {
- return _foundFiles;
- }
-
- public void setFoundFiles(List<File> foundFiles) {
- _foundFiles = foundFiles;
- }
-}
-
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/FileStrategy.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/FileStrategy.java
deleted file mode 100644
index 57e3652..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/FileStrategy.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.util;
-
-import java.io.File;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * Java file strategy pattern to filter out all java files which are possible sources
- * so that we can recompile them
- */
-
-public class FileStrategy implements Strategy {
- Pattern _rePattern;
-
- public FileStrategy(String pattern) {
- pattern = pattern.trim().replaceAll("\\.", "\\\\.");
- pattern = "." + pattern;
-
- _rePattern = Pattern.compile(pattern);
-
- }
-
- List<File> _foundFiles = new LinkedList<File>();
-
- public void apply(Object element) {
- File foundFile = (File) element;
- String fileName = foundFile.getName().toLowerCase(Locale.getDefault());
- Matcher matcher = _rePattern.matcher(fileName);
-
- if (!matcher.matches()) return;
- _foundFiles.add(foundFile);
- }
-
- public List<File> getFoundFiles() {
- return _foundFiles;
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/FileUtils.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/FileUtils.java
deleted file mode 100644
index a4c9d46..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/FileUtils.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.util;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class FileUtils {
- static double _tempMarker = Math.random();
-
- /**
- * Get the file separator for this platform.
- *
- * @return The file separator.
- */
- public static String getFileSeparator() {
- return File.separator;
- }
-
- /**
- * touch functionality to mark
- * compiles and dependencies as changed
- * to get a clean reloading state
- * <p/>
- * the touch is basically just the same as unix touch
- *
- * @param fileToTouch
- */
- public static void touch(File fileToTouch) {
- //we change our lastMofied to the current system time
- if (!fileToTouch.exists()) return;
- fileToTouch.setLastModified(System.currentTimeMillis());
- }
-
- /**
- * Get the file separator for this platform, properly escaped for usage in a regular expression.
- * workaround for http://bugs.sun.com/view_bug.do?bug_id=4626653 another workaround would be
- * to use the Matcher.quoteReplacement as of http://bugs.sun.com/view_bug.do?bug_id=5024613 instead
- * of using String.replaceAll
- *
- * @return The file separator, escaped for in a regex.
- */
- public static String getFileSeparatorForRegex() {
- String sep = getFileSeparator();
-
- if ("\\".equals(sep)) {
- sep = "\\\\";
- }
-
- return sep;
- }
-
- public static File getTempDir() {
- File tempDir;
-
- String baseTempPath = System.getProperty("java.io.tmpdir");
- String tempDirName = "myfaces_compilation_" + _tempMarker;
-
- tempDir = new File(baseTempPath + File.separator + tempDirName);
- while (tempDir.exists()) {
- tempDirName = "myfaces_compilation_" + System.currentTimeMillis() + Math.random();
- tempDir = new File(baseTempPath + File.separator + tempDirName);
- }
-
- synchronized (FileUtils.class) {
- if (tempDir.exists()) {
- return tempDir;
- }
- if (tempDir.mkdirs()) {
- tempDir.deleteOnExit();
- }
- }
- return tempDir;
- }
-
- /**
- * we roll our own tree walker here
- * to avoid a dependency into commons fileutils
- * and to apply an easier pattern than
- * commons fileutils uses
- *
- * @param rootDir the root dir for our walking
- * @param strategy the strategy to apply to for our walking
- */
- public static void listFiles(File rootDir, Strategy strategy) {
- if (!rootDir.isDirectory()) {
- strategy.apply(rootDir);
- return;
- }
-
- File[] files = rootDir.listFiles();
- for (File file : files) {
- boolean isDirectory = file.isDirectory();
- if (isDirectory && !file.getName().endsWith(".")) {
- listFiles(file, strategy);
- strategy.apply(file);
- } else if (!isDirectory) {
- strategy.apply(file);
- }
- }
- }
-
- /**
- * <p>
- * target path check to check if the targetPath is valid or can be created
- * </p>
- *
- * @param path the path to be investigated
- */
- public static void assertPath(File path) {
- // The destination directory must already exist as javac will not create the destination directory.
- if (!path.exists()) {
- if (!path.mkdirs()) {
- throw new IllegalStateException("It wasn't possible to create the target " +
- "directory for the compiler ['" + path.getAbsolutePath() + "'].");
- }
-
- // If we've created the destination directory, we'll delete it as well once the application exits
- path.deleteOnExit();
- }
- }
-
- /**
- * fetches recursively the files under the current root
- *
- * @param sourcePath the source path from which the walker should start from
- * @param fileType the pattern upon which the file has to be matched to aka *.java etc...
- * @return a list of source files
- */
- public static List<File> fetchSourceFiles(File sourcePath, String fileType) {
- FileStrategy strategy = new FileStrategy(fileType);
- listFiles(sourcePath, strategy);
-
- return strategy.getFoundFiles();
- }
-
- /**
- * fetches the source files from a list of source paths
- *
- * @param sourcePaths the collection of paths to be searched for
- * @param fileType the filetype to be searched for
- * @return a list of files found
- */
- public static List<File> fetchSourceFiles(Collection<String> sourcePaths, String fileType) {
- FileStrategy strategy = new FileStrategy(fileType);
-
- for (String sourcePath : sourcePaths) {
- File fSourcePath = new File(sourcePath);
- if (fSourcePath.exists()) {
- listFiles(fSourcePath, strategy);
- }
- }
-
- return strategy.getFoundFiles();
- }
-
- /**
- * fetches the source paths from a given root directory in the format
- * <path>/<appendix>;...
- *
- * @param sourcePath the sourcePath from which the directory traversal should happen from
- * @param appendix the appendix which has to be appended to every path found
- * @return a string builder of the paths found
- */
- @SuppressWarnings("unused")
- public static StringBuilder fetchSourcePaths(File sourcePath, String appendix) {
- DirStrategy dirStrategy = new DirStrategy();
- StringBuilder sourcesList = new StringBuilder(512);
-
- listFiles(sourcePath, dirStrategy);
- for (File foundDir : dirStrategy.getFoundFiles()) {
- String dirName = foundDir.getAbsolutePath();
- sourcesList.append(dirName);
- sourcesList.append(File.separator);
- sourcesList.append(appendix);
- }
- return sourcesList;
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/Null.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/Null.java
deleted file mode 100644
index 746391c..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/Null.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.util;
-
-/**
- * @Author Werner Punz
- * Null representation for easier introspection calls
- */
-public class Null extends Cast {
-
- public Null(Class clazz) {
- super(clazz, null);
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/ReflectUtil.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/ReflectUtil.java
deleted file mode 100644
index 3ffa0aa..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/ReflectUtil.java
+++ /dev/null
@@ -1,429 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.util;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ReflectUtil {
-
- static final Logger _logger = Logger.getLogger(ReflectUtil.class.getName());
-
- public static Object instantiate(String clazz, Object... varargs) {
- return instantiate(ClassUtils.forName(clazz), varargs);
- }
-
- /**
- * A simplified instantiation over reflection
- *
- * @param clazz the class to be instantiated
- * @param varargs the instantiation parameters
- * @return the instantiated object
- */
- public static Object instantiate(Class clazz, Object... varargs) {
- Class[] classes = new Class[varargs.length];
- for (int cnt = 0; cnt < varargs.length; cnt++) {
-
- if (varargs[cnt] instanceof Cast) {
- classes[cnt] = ((Cast) varargs[cnt]).getClazz();
- varargs[cnt] = ((Cast) varargs[cnt]).getValue();
- } else {
- classes[cnt] = varargs[cnt].getClass();
- }
- }
-
- try {
- Constructor constr = clazz.getConstructor(classes);
- return constr.newInstance(varargs);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- } catch (InvocationTargetException e) {
- throw new RuntimeException(e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- } catch (InstantiationException e) {
- throw new RuntimeException(e);
- }
- }/*this is mostly just a helper to bypass a groovy bug in a more
- * complex delegation environment. Groovy throws a classcast
- * exception wrongly, delegating the instantiation code to java
- * fixes that
- * */
-
- public static Object newObject(Class clazz) throws IllegalAccessException, InstantiationException {
- return clazz.newInstance();
- }
-
- /**
- * Generic execute method which simplifies the reflection api
- * down to a usable system
- *
- * @param obj the target object the method has to be executed upon
- * @param methodName the method name
- * @param varargs the arguments which have to be passed to the method
- * @return the return value of the method
- */
- public static Object executeStaticMethod(Class obj, String methodName, Object... varargs) {
-
- Collection<Method> methods = getMethods(obj, methodName, varargs.length);
-
- Object retVal = handleStaticMethod(obj, methodName, methods, varargs);
- if (!methodNotFound(retVal)) {
- return retVal;
- }
-
- methods = getAllMethods(obj, methodName, varargs.length);
- retVal = handleStaticMethod(obj, methodName, methods, varargs);
- if (!methodNotFound(retVal)) {
- return retVal;
- }
-
- throw new RuntimeException("Static Method of :" + methodName + " from class " + obj.getClass().getName() + " not found");
-
- }
-
- public static Collection<Method> getAllMethods(Class clazz, String methodName, int varargLength) {
- ArrayList<Method> retVal = new ArrayList<Method>(30);
- while (clazz != null) {
- for (Method m : clazz.getDeclaredMethods()) {
- if (m.getParameterTypes().length == varargLength && m.getName().equals(methodName)) {
- retVal.add(m);
- }
- }
- clazz = clazz.getSuperclass();
- }
-
- return retVal;
- }
-
- public static Collection<Method> getMethods(Class clazz, String methodName, int varargLength) {
- ArrayList<Method> retVal = new ArrayList<Method>(30);
- for (Method m : clazz.getDeclaredMethods()) {
- if (m.getParameterTypes().length == varargLength && m.getName().equals(methodName)) {
- retVal.add(m);
- }
- }
-
- return retVal;
- }
-
- /**
- * Generic execute method which simplifies the reflection api
- * down to a usable system
- *
- * @param obj the target object the method has to be executed upon
- * @param methodName the method name
- * @param varargs the arguments which have to be passed to the method
- * @return the return value of the method
- * @throws RuntimeException a generic runtime exception in case of a failure
- * we use unmanaged exceptions here to get a behavior similar to scripting
- * language execution where failures can happen but method executions
- * should not enforce exception handling
- */
- public static Object executeMethod(Object obj, String methodName, Object... varargs) {
-
- Collection<Method> methods;
- //if we have an invocationHandler here we
- //can work over the generic invoke interface
- //That way we can cover more dynamic stuff
- //our reload invocation handler is treated differently here
-
- if (obj instanceof InvocationHandler) {
- InvocationHandler objToInvoke = (InvocationHandler) obj;
-
- Object realTarget = WeavingContext.getDelegateFromProxy(objToInvoke);
-
- //first we try only the public because they are the most likely ones
- //to be accessed
- methods = getMethods(realTarget.getClass(), methodName, varargs.length);
- Object retVal = handleInvHandlerMethod(objToInvoke, methodName, methods, varargs);
- if (!methodNotFound(retVal)) {
- return retVal;
- }
- //if not we try all of them until we have a match
- methods = getAllMethods(realTarget.getClass(), methodName, varargs.length);
- retVal = handleInvHandlerMethod(objToInvoke, methodName, methods, varargs);
- if (!(methodNotFound(retVal))) {
- return retVal;
- }
-
- throw new RuntimeException("Method of :" + methodName + " from class " + obj.getClass().getName() + " not found");
- }
-
- Class clazz = obj.getClass();
-
- //first we try only the public because they are the most likely ones
- //to be accessed
- methods = getMethods(clazz, methodName, varargs.length);
- Object retVal = handleObjMethod(obj, methodName, methods, varargs);
- if (!methodNotFound(retVal)) {
- return retVal;
- }
-
- //if not we try all of them until we have a match
- methods = getAllMethods(clazz, methodName, varargs.length);
- retVal = handleObjMethod(obj, methodName, methods, varargs);
- if (!methodNotFound(retVal)) {
- return retVal;
- }
-
- throw new RuntimeException("Method of :" + methodName + " from class " + obj.getClass().getName() + " not found");
- }
-
- /**
- * special marker class which is a special return value indicating
- * that not method has been found which can be executed
- */
- static class _MethodNotFound {
- }
-
- /**
- * check if the return value is a method not found return val which
- * indicates we have to follow the next workflow step
- *
- * @param retVal the retVal which has to be investigated
- * @return true if the retVal is instance of _MethodNotFound false otherwise
- */
- private static boolean methodNotFound(Object retVal) {
- return retVal instanceof _MethodNotFound;
- }
-
- /**
- * executes a method in an invocation handler with a set of
- * methods which are canidates for execution
- *
- * @param objToInvoke the invokee object
- * @param methodName the method name
- * @param methods the methods which are under investigation for invoking
- * @param varargs the list of varargs to be passed to the method
- * @return the result of the invocation, or an object of type _MethodNotFound otherwise
- */
- static private Object handleInvHandlerMethod(InvocationHandler objToInvoke, String methodName, Collection<Method> methods, Object... varargs) {
- for (Method m : methods) {
- if (!m.getName().equals(methodName) || m.getParameterTypes().length != varargs.length) {
- continue;
- }
- try {
- return objToInvoke.invoke(objToInvoke, m, varargs);
- } catch (Throwable e) {
- handleException(e);
- }
- }
- return new _MethodNotFound();
- }
-
- /**
- * executes a method on an object
- *
- * @param objToInvoke the invokee object
- * @param methodName the method name
- * @param methods the methods which are under investigation for invoking
- * @param varargs the list of varargs to be passed to the method
- * @return the result of the invocation, or an object of type _MethodNotFound otherwise
- */
- static private Object handleObjMethod(Object objToInvoke, String methodName, Collection<Method> methods, Object... varargs) {
- for (Method m : methods) {
- if (!m.getName().equals(methodName) || m.getParameterTypes().length != varargs.length) {
- continue;
- }
- try {
- return m.invoke(objToInvoke, varargs);
- } catch (Throwable e) {
- handleException(e);
- }
- }
- return new _MethodNotFound();
- }
-
- /**
- * executes a static method on a class
- *
- * @param objToInvoke the invokee object
- * @param methodName the method name
- * @param methods the methods which are under investigation for invoking
- * @param varargs the list of varargs to be passed to the method
- * @return the result of the invocation, or an object of type _MethodNotFound otherwise
- */
- static private Object handleStaticMethod(Class objToInvoke, String methodName, Collection<Method> methods, Object... varargs) {
- for (Method m : methods) {
- if (!m.getName().equals(methodName) || m.getParameterTypes().length != varargs.length) {
- continue;
- }
- try {
- return m.invoke(objToInvoke, varargs);
- } catch (Throwable e) {
- handleException(e);
- }
- }
- return new _MethodNotFound();
- }
-
- private static void handleException(Throwable e) {
- if (e instanceof IllegalAccessException) {
- if (_logger.isLoggable(Level.FINEST)) {
- _logger.log(Level.FINEST, "", e);
- }
- } else if (e instanceof IllegalArgumentException) {
- if (_logger.isLoggable(Level.FINEST)) {
- _logger.log(Level.FINEST, "", e);
- }
- } else {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * executes a function method on a target object
- *
- * @param obj the target object
- * @param methodName the method name
- * @param varargs a list of objects casts or nulls defining the parameter classes and its values
- * if something occurs on introspection level an unmanaged exception is throw, just like
- * it would happen in a scripting class
- * @return the result object for the Method(method) call
- * @throws RuntimeException an unmanaged runtime exception in case of an introspection error
- */
- public static Object fastExecuteMethod(Object obj, String methodName, Object... varargs) {
- Class[] classes = new Class[varargs.length];
- for (int cnt = 0; cnt < varargs.length; cnt++) {
-
- if (varargs[cnt] instanceof Cast) {
- classes[cnt] = ((Cast) varargs[cnt]).getClazz();
- varargs[cnt] = ((Cast) varargs[cnt]).getValue();
- } else {
- classes[cnt] = varargs[cnt].getClass();
- }
- }
-
- try {
- Method m = fastGetMethod(obj, methodName, classes);
- return m.invoke(obj, varargs);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- } catch (InvocationTargetException e) {
- throw new RuntimeException(e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
-
- }
-
- /**
- * faster reflection call
- * if we know the data types exactly we can
- * trigger a direct call instead of walking through all methods
- * note this method only allows to trigger against directly declared methods
- * it ignores the inheritance hierarchy for faster access
- *
- * @param obj the invokee object
- * @param methodName the metod name
- * @param classes the parameter type classes
- * @return the method if found
- * @throws NoSuchMethodException in case it could not be found
- */
- public static Method fastGetMethod(Object obj, String methodName, Class[] classes) throws NoSuchMethodException {
- Method m;
- try {
- m = obj.getClass().getDeclaredMethod(methodName, classes);
- } catch (NoSuchMethodException e) {
- m = obj.getClass().getMethod(methodName, classes);
- }
- return m;
- }
-
- /**
- * executes a function method on a target object
- *
- * @param obj the target object
- * @param methodName the method name
- * @param varargs a list of objects casts or nulls defining the parameter classes and its values
- * if something occurs on introspection level an unmanaged exception is throw, just like
- * it would happen in a scripting class
- * @return the result object for the Method(method) call
- * @throws RuntimeException an unmanaged runtime exception in case of an introspection error
- */
- public static Object fastExecuteStaticMethod(Class obj, String methodName, Object... varargs) {
- Class[] classes = new Class[varargs.length];
- for (int cnt = 0; cnt < varargs.length; cnt++) {
-
- if (varargs[cnt] instanceof Cast) {
- classes[cnt] = ((Cast) varargs[cnt]).getClazz();
- varargs[cnt] = ((Cast) varargs[cnt]).getValue();
- } else {
- classes[cnt] = varargs[cnt].getClass();
- }
- }
-
- try {
- Method m = fastGetStaticMethod(obj, methodName, classes);
- return m.invoke(obj, varargs);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- } catch (InvocationTargetException e) {
- throw new RuntimeException(e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
-
- }
-
- public static Method fastGetStaticMethod(Class obj, String methodName, Class[] classes) throws NoSuchMethodException {
- Method m;
- try {
- m = obj.getDeclaredMethod(methodName, classes);
- } catch (NoSuchMethodException e) {
- m = obj.getMethod(methodName, classes);
- }
- return m;
- }
-
- /**
- * convenience method which makes the code a little bit more readable
- * use it in conjunction with static imports
- *
- * @param clazz the cast target for the method call
- * @param value the value object to be used as param
- * @return a Cast object of the parameters
- */
- public static Cast cast(Class clazz, Object value) {
- return new Cast(clazz, value);
- }
-
- /**
- * convenience method which makes the code a little bit more readable
- * use it in conjunction with static imports
- *
- * @param clazz the cast target for the method call
- * @return a null value Cast object of the parameters
- */
- public static Null nullCast(Class clazz) {
- return new Null(clazz);
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/Strategy.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/Strategy.java
deleted file mode 100644
index 2a0f7da..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/Strategy.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.util;
-
-/**
- * Applied strategy class for iteration walkers
- * to make the handling of iterated objects
- * more scripting language like (aka a pattern similar to closures)
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-public interface Strategy {
-
- public void apply(Object element);
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/StringUtils.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/StringUtils.java
deleted file mode 100644
index 695e5f4..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/StringUtils.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.util;
-
-/**
- * Replacement for commons lang
- * because we want to get the dependency out
- * after all we only used StringUtils
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class StringUtils {
- public static boolean isBlank(String in) {
- return in == null || in.trim().equals("");
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/WeavingContext.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/WeavingContext.java
deleted file mode 100644
index 93e064e..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/WeavingContext.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.util;
-
-import org.apache.myfaces.context.servlet.ApplicationMap;
-import org.apache.myfaces.extensions.scripting.api.*;
-import org.apache.myfaces.extensions.scripting.core.DummyWeaver;
-import org.apache.myfaces.extensions.scripting.core.MethodLevelReloadingHandler;
-import org.apache.myfaces.extensions.scripting.monitor.ResourceMonitor;
-import org.apache.myfaces.extensions.scripting.monitor.RefreshContext;
-import org.apache.myfaces.extensions.scripting.api.CompilationResult;
-import org.apache.myfaces.extensions.scripting.api.extensionevents.ExtensionEventRegistry;
-import org.apache.myfaces.extensions.scripting.jsf.*;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletRequest;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.logging.Logger;
-
-/**
- * A set of weaving context class called
- * by the various subsystems
- * <p/>
- * TODO (1.1) move this away from static methods into a singleton which is kept
- * in the application context, to keep the context pattern.
- *
- * @author Werner Punz
- */
-public class WeavingContext {
-
- /**
- * <p>
- * we push our weaver into the thread local
- * to avoid too many calls into the
- * context class loading hierarchy
- * this should speed things up a little bit.
- * </p>
- * <p>
- * Note we could work with this with static
- * objects as well but since we also have to work with context
- * reloading we probably are safer with filters
- * a reference in the context and a threadLocal variable
- * </p>
- */
- static final protected ThreadLocal<Object> _weaverHolder = new ThreadLocal<Object>();
- static final protected ThreadLocal<Object> _refreshContextHolder = new ThreadLocal<Object>();
- static final protected ThreadLocal<Object> _configuration = new ThreadLocal<Object>();
- static final protected ThreadLocal<Object> _externalContext = new ThreadLocal<Object>();
- static final protected ThreadLocal<Object> _extensionEventSystem = new ThreadLocal<Object>();
-
- static final protected ThreadLocal<ServletRequest> _request = new ThreadLocal();
- static final protected ThreadLocal<Map<String, Object>> _requestMap = new ThreadLocal();
-
- private static final String WARN_WEAVER_NOT_SET = "[EXT-SCRIPTING] Scripting Weaver is not set. Disabling script reloading subsystem. Make sure you have the scripting servlet filter enabled in your web.xml";
-
- private static final Map<Integer, CompilationResult> _compilationResults = new ConcurrentHashMap<Integer, CompilationResult>();
-
- /**
- * per default the weaver is not set up
- */
- private static AtomicBoolean _enabled = new AtomicBoolean(false);
-
- /**
- * per default the weaver is not set up
- */
- private static AtomicBoolean _filterEnabled = new AtomicBoolean(false);
-
- /**
- * external helper which helps to initialize
- * the scripting engine runtime system
- * and to discover configuration mistakes early on
- *
- * @param servletContext the servlet context which holds the config data
- */
- public static void startup(ServletContext servletContext) {
- WeavingContextInitializer.initWeavingContext(servletContext);
- }
-
- public static void initThread(ServletContext context) {
- WeavingContext.setWeaver(context.getAttribute(ScriptingConst.CTX_ATTR_SCRIPTING_WEAVER));
- WeavingContext.setRefreshContext((RefreshContext) context.getAttribute(ScriptingConst.CTX_ATTR_REFRESH_CONTEXT));
- WeavingContext.setConfiguration((Configuration) context.getAttribute(ScriptingConst.CTX_ATTR_CONFIGURATION));
- WeavingContext.setExtensionEventRegistry((ExtensionEventRegistry) context.getAttribute(ScriptingConst.CTX_ATTR_EXTENSION_EVENT_SYSTEM));
- WeavingContext.setExternalContext(context);
- }
-
-
- public static CompilationResult getCompilationResult(Integer scriptingEngine) {
- return _compilationResults.get(scriptingEngine);
- }
-
- public static void setCompilationResult(Integer scriptingEngine, CompilationResult result) {
- _compilationResults.put(scriptingEngine, result);
- }
-
- public static void setExternalContext(Object context) {
- _externalContext.set(context);
- }
-
- public static Object getExternalContext() {
- return _externalContext.get();
- }
-
- /**
- * general shutdown clean
- */
- public static void clean() {
- _weaverHolder.set(null);
- }
-
- public static void setRefreshContext(RefreshContext rContext) {
- _refreshContextHolder.set(rContext);
- }
-
- public static RefreshContext getRefreshContext() {
- return (RefreshContext) _refreshContextHolder.get();
- }
-
- public static Configuration getConfiguration() {
- return (Configuration) _configuration.get();
- }
-
- public static void setConfiguration(Configuration configuration) {
- _configuration.set(configuration);
- }
-
- public static void setExtensionEventRegistry(ExtensionEventRegistry reg) {
- _extensionEventSystem.set(reg);
- }
-
- public static ExtensionEventRegistry getExtensionEventRegistry() {
- return (ExtensionEventRegistry) _extensionEventSystem.get();
- }
-
- public static void setRequest(ServletRequest req) {
- _request.set(req);
- _requestMap.set(new RequestMap(req));
- }
-
- public static ServletRequest getRequest() {
- return (ServletRequest) _request.get();
- }
-
-
- public static Map getRequestMap() {
- Map ret = (Map) _requestMap.get();
- if (ret == null) {
- //for startup we need a simulation
- _requestMap.set(new HashMap<String, Object>());
- ret = (Map) _requestMap.get();
- }
- return ret;
- }
-
- /**
- * the weavers are set from outside
- * we have to provide the weaver facade
- * for very thread accessing this system
- *
- * @param weaver the weaver object to be set from outside
- */
- public static void setWeaver(Object weaver) {
- _weaverHolder.set(weaver);
-
- }
-
- /**
- * some artefacts need a full request refresh
- */
- public static void doRequestRefreshes() {
- //TODO emit an application event here
- //which enforces attached libraries to refresh themselves
- if (isScriptingEnabled())
- getWeaver().requestRefresh();
- }
-
- public static void jsfRequestRefresh() {
- if (isScriptingEnabled())
- getWeaver().jsfRequestRefresh();
- }
-
- /**
- * checks whether the system
- * has scripting enabled or not
- *
- * @return true in case of being scriptable
- */
- public static boolean isScriptingEnabled() {
- return _enabled != null && _enabled.get();
- }
-
- public static void setScriptingEnabled(boolean enabled) {
- _enabled.set(enabled);
- }
-
- /**
- * the filter has to be treated differently
- * if the filter is not enabled we do not have
- * a chance to access our singletons properly
- * <p/>
- * The servlet api in 2.5 seems to lack a filter
- * accessor, so we have to set this from our filter and then
- * do periodic checks within our system
- *
- * @param enabled true set from out filter init
- */
- public static void setFilterEnabled(boolean enabled) {
- _filterEnabled.set(enabled);
- }
-
- /**
- * @return true if our filter is enabled
- */
- @SuppressWarnings("unused")
- public static boolean isFilterEnabled() {
- return _filterEnabled != null && _filterEnabled.get();
- }
-
- /**
- * fetches the weavers
- * for this current thread
- *
- * @return a ScriptingWeaver chain for all weavers currently supported
- */
- public static ScriptingWeaver getWeaver() {
- //shutting down condition _weaverHolder == null due to separate thread
- if (_weaverHolder == null) {
- return null;
- }
- ScriptingWeaver weaver = (ScriptingWeaver) _weaverHolder.get();
- if (weaver == null) {
- Logger log = Logger.getLogger(WeavingContext.class.getName());
- log.warning(WARN_WEAVER_NOT_SET);
- _weaverHolder.set(new DummyWeaver());
- }
- return weaver;
- }
-
- /**
- * we create a proxy to an existing object
- * which does reloading of the internal class
- * on method level
- * <p/>
- * this works only on classes which implement contractual interfaces
- * it cannot work on things like the navigation handler
- * which rely on base classes
- *
- * @param o the source object to be proxied
- * @param theInterface the proxying interface
- * @param artifactType the artifact type to be reloaded
- * @return a proxied reloading object of type theInterface
- */
- public static Object createMethodReloadingProxyFromObject(Object o, Class theInterface, int artifactType) {
- if (!isScriptingEnabled()) {
- return o;
- }
- return Proxy.newProxyInstance(o.getClass().getClassLoader(),
- new Class[]{theInterface},
- new MethodLevelReloadingHandler(o, artifactType));
- }
-
- /**
- * we create a proxy to an existing object
- * which does reloading of the internal class
- * on newInstance level
- *
- * @param o the original object
- * @param theInterface the proxy interface
- * @param artifactType the artifact type to be handled
- * @return the proxy of the object if scripting is enabled, the original one otherwise
- */
- @SuppressWarnings("unused")
- public static Object createConstructorReloadingProxyFromObject(Object o, Class theInterface, int artifactType) {
- if (!isScriptingEnabled()) {
- return o;
- }
- return Proxy.newProxyInstance(o.getClass().getClassLoader(),
- new Class[]{theInterface},
- new MethodLevelReloadingHandler(o, artifactType));
- }
-
- public static ResourceMonitor getFileChangedDaemon() {
- ResourceMonitor daemon = getRefreshContext().getDaemon();
- if (daemon.getWeavers() == null) {
- daemon.setWeavers(getWeaver());
- }
- return daemon;
- }
-
- /**
- * un-mapping of a proxied object
- *
- * @param o the proxied object
- * @return the un-proxied object
- */
- public static Object getDelegateFromProxy(Object o) {
- if (o == null) {
- return null;
- }
- if (o instanceof Decorated)
- return ((Decorated) o).getDelegate();
-
- if (!Proxy.isProxyClass(o.getClass())) return o;
- InvocationHandler handler = Proxy.getInvocationHandler(o);
- if (handler instanceof Decorated) {
- return ((Decorated) handler).getDelegate();
- }
- return o;
- }
-
- /**
- * checks if a class is dynamic
- *
- * @param clazz the class to be checked
- * @return true if the class is of
- * dynamic nature and our scripting system is enabled
- */
- public static boolean isDynamic(Class clazz) {
- return isScriptingEnabled() && getWeaver().isDynamic(clazz);
- }
-
- public static AbstractThreadSafeAttributeMap<Object> getApplicationMap() {
- return new ServletApplicationMap((ServletContext) getExternalContext());
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/WeavingContextInitializer.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/WeavingContextInitializer.java
deleted file mode 100644
index b7bcdc9..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/WeavingContextInitializer.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.util;
-
-import org.apache.myfaces.extensions.scripting.api.Configuration;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.extensions.scripting.core.CoreWeaver;
-import org.apache.myfaces.extensions.scripting.core.util.stax.FilterClassDigester;
-import org.apache.myfaces.extensions.scripting.loaders.groovy.GroovyScriptingWeaver;
-import org.apache.myfaces.extensions.scripting.loaders.java.JavaScriptingWeaver;
-import org.apache.myfaces.extensions.scripting.loaders.java.RecompiledClassLoader;
-import org.apache.myfaces.extensions.scripting.monitor.ResourceMonitor;
-import org.apache.myfaces.extensions.scripting.monitor.RefreshContext;
-import org.apache.myfaces.extensions.scripting.api.extensionevents.ExtensionEventRegistry;
-import org.apache.myfaces.extensions.scripting.servlet.ScriptingServletFilter;
-
-import javax.servlet.ServletContext;
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Central initializer class for our
- * WeavingContext which does some semantic checking of the web.xml
- * and initializes everything in proper order
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class WeavingContextInitializer {
-
- static class StartupException extends Exception {
- StartupException(String message) {
- super(message);
- }
- }
-
- static final Logger _logger = Logger.getLogger(WeavingContextInitializer.class.getName());
-
- static final PrivilegedExceptionAction<RecompiledClassLoader> LOADER_ACTION = new PrivilegedExceptionAction<RecompiledClassLoader>() {
- public RecompiledClassLoader run() {
- return new RecompiledClassLoader(ClassUtils.getContextClassLoader(), ScriptingConst.ENGINE_TYPE_JSF_JAVA, ".java");
- }
- };
- private static final String GROOVY_NOT_FOUND = "[EXT-SCRIPTING] Groovy not found disabling Ext-Scripting Groovy support";
- private static final String GROOVY_OBJECT = "groovy.lang.GroovyObject";
-
- public static void initWeavingContext(ServletContext servletContext) {
- try {
- WeavingContext.setScriptingEnabled(true);
- validateWebXml(servletContext);
- initConfiguration(servletContext);
- initExtensionEventSystem(servletContext);
- validateSecurityConstraints();
- initWeavers(servletContext);
- validateSourcePaths();
- initRefreshContext(servletContext);
-
- initFileChangeDaemon(servletContext);
- initExternalContext(servletContext);
- } catch (StartupException ex) {
- _logger.severe("[EXT-SCRIPTING] " + ex.getMessage());
- WeavingContext.setScriptingEnabled(false);
- }
-
- }
-
- /**
- * validates the source paths which were determined by the
- * startup for failures
- */
- private static void validateSourcePaths() throws StartupException {
-
- Collection<String> dirs = WeavingContext.getConfiguration().getAllSourceDirs();
- for (String currentDir : dirs) {
- File probe = new File(currentDir);
- if (!probe.exists()) {
- throw new StartupException("The directory " + probe + " does not exist, disabling scripting support");
- }
- }
- }
-
- /**
- * asserts the security constraints
- * the only security which has to be allowed
- * is the creation of classloaders
- */
- private static void validateSecurityConstraints() throws StartupException {
-
- try {
- AccessController.doPrivileged(LOADER_ACTION);
- } catch (PrivilegedActionException e) {
- throw new StartupException("Class loader creation is prohibited by your security settings, I am going to disable Ext-Scripting");
- }
- }
-
- private static void initExternalContext(ServletContext servletContext) {
-
- WeavingContext.setExternalContext(servletContext);
- }
-
- private static void initFileChangeDaemon(ServletContext servletContext) {
-
- ResourceMonitor.startup(servletContext);
- WeavingContext.getRefreshContext().setDaemon(ResourceMonitor.getInstance());
- }
-
- private static void initExtensionEventSystem(ServletContext servletContext) {
- ExtensionEventRegistry registry = new ExtensionEventRegistry();
- servletContext.setAttribute(ScriptingConst.CTX_ATTR_EXTENSION_EVENT_SYSTEM, registry);
- WeavingContext.setExtensionEventRegistry(registry);
- }
-
-
-
-
- private static void initConfiguration(ServletContext servletContext) {
-
- final Configuration configuration = new Configuration();
- servletContext.setAttribute(ScriptingConst.CTX_ATTR_CONFIGURATION, configuration);
- WeavingContext.setConfiguration(configuration);
- //we now add the resource loader path here
-
- /*
- * we define a set of closures (inner classes) which make
- * our code more reusable we define a strategy
- * for each comma delimited set of values
- */
- Strategy addResourceDirStrategy = new Strategy() {
- public void apply(Object element) {
- configuration.addResourceDir((String) element);
- }
- };
- Strategy addAdditionalClassPathStrategy = new Strategy() {
- public void apply(Object element) {
- configuration.addAdditionalClassPath((String) element);
- }
- };
- Strategy addWhiteListPackageStrategy = new Strategy() {
- public void apply(Object element) {
- configuration.addWhitelistPackage((String) element);
- }
- };
-
- /**
- * We now apply the values into our own lists
- */
- applyEntries(servletContext.getInitParameter(ScriptingConst.INIT_PARAM_RESOURCE_PATH), addResourceDirStrategy);
- applyEntries(servletContext.getInitParameter(ScriptingConst.INIT_PARAM_SCRIPTING_ADDITIONAL_CLASSPATH), addAdditionalClassPathStrategy);
- applyEntries(servletContext.getInitParameter(ScriptingConst.INIT_PARAM_SCRIPTING_PACKAGE_WHITELIST), addWhiteListPackageStrategy);
-
- String initialCompile = servletContext.getInitParameter(ScriptingConst.INIT_PARAM_INITIAL_COMPILE);
-
- configuration.setInitialCompile((initialCompile == null) || initialCompile.trim().toLowerCase().equals("true"));
-
- }
-
- private static void applyEntries(String val, Strategy strategy) {
- if (!StringUtils.isBlank(val)) {
- String[] splitVal = val.split(ScriptingConst.CONTEXT_VALUE_DIVIDER);
- for (String singleVal : splitVal) {
- strategy.apply(singleVal);
- }
- }
- }
-
- private static void validateWebXml(ServletContext context) throws StartupException {
- try {
- URL webXml = context.getResource("/WEB-INF/web.xml");
-
- if (webXml != null) {
- if (!FilterClassDigester.findFilter(webXml, ScriptingServletFilter.class)) {
- throw new StartupException(ScriptingConst.ERR_SERVLET_FILTER);
- }
- }
-
- } catch (IOException e) {
- throw new StartupException("Web.xml could not be parsed disabling scripting");
- }
- }
-
- /**
- * inits the weaver chain which depends on the scripting
- * language supported by the internal jars
- *
- * @param servletContext the standard servlet context
- */
- private static void initWeavers(ServletContext servletContext) throws StartupException {
- _logger.fine("[EXT-SCRIPTING] initializing the weaving contexts");
-
- List<ScriptingWeaver> weavers = new ArrayList<ScriptingWeaver>(2);
-
- initGroovyWeaver(servletContext, weavers);
- initJavaWeaver(servletContext, weavers);
- if (WeavingContext.isFilterEnabled() && weavers.size() == 0) {
- throw new StartupException("No scripting languages initialized disabling EXT-SCRIPTING");
- }
-
- WeavingContext.setWeaver(new CoreWeaver(weavers));
- servletContext.setAttribute(ScriptingConst.CTX_ATTR_SCRIPTING_WEAVER, WeavingContext.getWeaver());
- }
-
- /**
- * inits the standard java weaver
- * for weaving and recompiling java classes on the fly
- *
- * @param servletContext the standard servlet context
- * @param weavers our list of weavers which should receive the resulting weaver
- */
- private static void initJavaWeaver(ServletContext servletContext, List<ScriptingWeaver> weavers) throws StartupException {
- ScriptingWeaver javaWeaver = new JavaScriptingWeaver(servletContext);
- setupScriptingPaths(servletContext, javaWeaver, ScriptingConst.JAVA_SOURCE_ROOT, ScriptingConst.INIT_PARAM_CUSTOM_JAVA_LOADER_PATHS);
- if (WeavingContext.getConfiguration().getSourceDirs(ScriptingConst.ENGINE_TYPE_JSF_JAVA).size() > 0) {
- weavers.add(javaWeaver);
- } else {
- _logger.log(Level.WARNING, "[EXT-SCRIPTING] No valid source path for Java found either add WEB-INF/java to your filesystem, or add a custom Java source path, disabling EXT-SCRIPTING Java support");
- }
- }
-
- /**
- * initializes our groovy weaver
- *
- * @param servletContext the servlet context
- * @param weavers the list of weavers receiving the resulting weaver if an initialization is possoble
- */
- private static void initGroovyWeaver(ServletContext servletContext, List<ScriptingWeaver> weavers) {
- //check if groovy can be enabled:
- try {
- Class groovyObject = ClassUtils.forName(GROOVY_OBJECT);
- if (groovyObject != null) {
- //groovy found ewe now enabled our groovy weaving support
- ScriptingWeaver groovyWeaver = new GroovyScriptingWeaver(servletContext);
- setupScriptingPaths(servletContext, groovyWeaver, ScriptingConst.GROOVY_SOURCE_ROOT, ScriptingConst.INIT_PARAM_CUSTOM_GROOVY_LOADER_PATHS);
- if (WeavingContext.getConfiguration().getSourceDirs(ScriptingConst.ENGINE_TYPE_JSF_GROOVY).size() > 0) {
- weavers.add(groovyWeaver);
- } else {
- _logger.log(Level.WARNING, "[EXT-SCRIPTING] No valid source path for Groovy found either add WEB-INF/groovy to your filesystem, or add a custom Groovy source path, disabling EXT-SCRIPTING Groovy support");
- }
- }
-
- } catch (Exception e) {
- _logger.info(GROOVY_NOT_FOUND);
- }
- }
-
- /**
- * initialisation of the refresh context object
- * the refresh context, is a context object which keeps
- * the refresh information (refresh time, needs refresh) etc...
- *
- * @param servletContext the servlet context singleton which keeps
- * the context for distribution
- */
- private static void initRefreshContext(ServletContext servletContext) {
- _logger.fine("[EXT-SCRIPTING] initializing the refresh context");
-
- RefreshContext rContext = new RefreshContext();
- servletContext.setAttribute(ScriptingConst.CTX_ATTR_REFRESH_CONTEXT, rContext);
- WeavingContext.setRefreshContext(rContext);
- }
-
- private static void setupScriptingPaths(ServletContext servletContext, ScriptingWeaver weaver, String contextRootKey, String initParams) throws StartupException {
-
- String classRoot = "";
- String scriptingRoot;
-
- String additionalLoaderPaths;
-
- String contextRoot = servletContext.getRealPath(contextRootKey);
-
- if (contextRoot == null) {
- _logger.warning("[EXT-SCRIPTING] one of the standard paths could not be resolved: " + contextRootKey + " this is either due to the path is missing or due to a configuration error! You can bypass the problem by setting additional loader paths if they are not set already!");
- contextRoot = "";
-
- }
-
- contextRoot = contextRoot.trim();
- scriptingRoot = contextRoot;
-
- additionalLoaderPaths = servletContext.getInitParameter(initParams);
- appendAdditionalPaths(additionalLoaderPaths, weaver);
- if (additionalLoaderPaths == null || additionalLoaderPaths.trim().equals("")) {
- if (contextRoot.equals("")) {
- throw new StartupException("Standard paths (WEB-INF/groovy and WEB-INF/java could not be determined, also no additional loader paths are set, I cannot start properly, please set additional loader paths for Ext-Scripting to work correctly! I am disabling Ext-Scripting!");
- }
- if (!StringUtils.isBlank(scriptingRoot)) {
- File probe = new File(scriptingRoot);
- if (probe.exists()) {
- weaver.appendCustomScriptPath(scriptingRoot);
-
- } else {
- _logger.log(Level.WARNING, "[EXT-SCRIPING] path {0} could not be found this might cause compile problems ", scriptingRoot);
- }
- }
- if (!StringUtils.isBlank(classRoot)) {
- weaver.appendCustomScriptPath(classRoot);
- }
- }
-
- }
-
- private static void appendAdditionalPaths(String additionalLoaderPaths, ScriptingWeaver workWeaver) {
- if (!StringUtils.isBlank(additionalLoaderPaths)) {
- String[] additionalPaths = additionalLoaderPaths.split(",");
- for (String path : additionalPaths) {
- workWeaver.appendCustomScriptPath(path);
- }
- }
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/stax/FilterClassDigester.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/stax/FilterClassDigester.java
deleted file mode 100644
index a037e94..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/core/util/stax/FilterClassDigester.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.util.stax;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * A web.xml filter class digester based on StaX
- * We use stax here for speed reasons, this is a highly
- * specialized stax based scanner which does only one thing,
- * it scans for the existence of a filter with a specified filter
- * class.
- * We use it currently only for error checking.
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class FilterClassDigester {
- private static final String ATTR_FILTER_CLASS = "filter-class";
-
- static final Logger _logger = Logger.getLogger(FilterClassDigester.class.getName());
-
- /**
- * checks if the filter with the specified filter class exists
- * in the current web.xml
- *
- * @param webXml the web.xml to be searched
- * @param filterClass the filter class to be searched for
- * @return true in case it is found false otherwise
- */
- public static boolean findFilter(URL webXml, Class filterClass) {
- StringBuilder filterClassFound = new StringBuilder();
- Set<String> filterClasses = new HashSet<String>();
- XMLStreamReader parser = null;
- try {
- InputStream in = webXml.openStream();
- XMLInputFactory factory = XMLInputFactory.newInstance();
- parser = factory.createXMLStreamReader(in);
- boolean inFilter = false;
- for (int event = parser.next();
- event != XMLStreamConstants.END_DOCUMENT;
- event = parser.next()) {
- switch (event) {
- case XMLStreamConstants.START_ELEMENT:
- if (isFilterClass(parser.getLocalName())) {
- inFilter = true;
- }
- break;
- case XMLStreamConstants.END_ELEMENT:
- if (isFilterClass(parser.getLocalName())) {
- inFilter = false;
- if (filterClassFound.toString().equals(filterClass.getName())) {
- filterClasses.add(filterClassFound.toString());
- return true;
- }
- filterClassFound = new StringBuilder();
- }
- break;
- case XMLStreamConstants.CHARACTERS:
- if (inFilter) filterClassFound.append(parser.getText());
- break;
- } // end switch
- } // end while
-
- }
- catch (XMLStreamException ex) {
- _logger.log(Level.WARNING, "", ex);
- }
- catch (IOException ex) {
- _logger.log(Level.WARNING, "", ex);
- } finally {
- try {
- if (parser != null) {
- parser.close();
- }
- } catch (XMLStreamException e) {
- _logger.log(Level.WARNING, "", e);
-
- }
- }
-
- return false;
- }
-
- private static boolean isFilterClass(String name) {
- return (name.equals(ATTR_FILTER_CLASS));
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/jsf/AbstractThreadSafeAttributeMap.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/jsf/AbstractThreadSafeAttributeMap.java
deleted file mode 100644
index bb729c7..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/jsf/AbstractThreadSafeAttributeMap.java
+++ /dev/null
@@ -1,409 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.jsf;
-
-import java.util.*;
-
-
-/**
- * Helper Map implementation for use with different Attribute Maps.
- *
- * @author Anton Koinov (latest modification by $Author: lu4242 $)
- * @version $Revision: 982465 $ $Date: 2010-08-05 06:39:32 +0200 (Do, 05 Aug 2010) $
- */
-public abstract class AbstractThreadSafeAttributeMap<V> extends AbstractMap<String, V>
-{
- private Set<String> _keySet;
- private Collection<V> _values;
- private Set<Entry<String, V>> _entrySet;
-
- @Override
- public void clear()
- {
- final List<String> names = Collections.list(getAttributeNames());
-
- for (String name : names)
- {
- removeAttribute(name);
- }
- }
-
- @Override
- public final boolean containsKey(final Object key)
- {
- return getAttribute(key.toString()) != null;
- }
-
- @Override
- public boolean containsValue(final Object findValue)
- {
- if (findValue == null)
- {
- return false;
- }
-
- for (final Enumeration<String> e = getAttributeNames(); e.hasMoreElements();)
- {
- final Object value = getAttribute(e.nextElement());
- if (findValue.equals(value))
- {
- return true;
- }
- }
-
- return false;
- }
-
- @Override
- public Set<Entry<String, V>> entrySet()
- {
- return (_entrySet != null) ? _entrySet : (_entrySet = new EntrySet());
- }
-
- @Override
- public V get(final Object key)
- {
- return getAttribute(key.toString());
- }
-
- @Override
- public boolean isEmpty()
- {
- return !getAttributeNames().hasMoreElements();
- }
-
- @Override
- public Set<String> keySet()
- {
- return (_keySet != null) ? _keySet : (_keySet = new KeySet());
- }
-
- @Override
- public final V put(final String key, final V value)
- {
- final V retval = getAttribute(key);
- setAttribute(key, value);
- return retval;
- }
-
- @Override
- public void putAll(final Map<? extends String, ? extends V> t)
- {
- for (final Entry<? extends String, ? extends V> entry : t.entrySet())
- {
- setAttribute(entry.getKey(), entry.getValue());
- }
- }
-
- @Override
- public final V remove(final Object key)
- {
- final String key_ = key.toString();
- final V retval = getAttribute(key_);
- removeAttribute(key_);
- return retval;
- }
-
- @Override
- public int size()
- {
- int size = 0;
- for (final Enumeration<String> e = getAttributeNames(); e.hasMoreElements();)
- {
- size++;
- e.nextElement();
- }
- return size;
- }
-
- @Override
- public Collection<V> values()
- {
- return (_values != null) ? _values : (_values = new Values());
- }
-
- abstract protected V getAttribute(String key);
-
- abstract protected void setAttribute(String key, V value);
-
- abstract protected void removeAttribute(String key);
-
- abstract protected Enumeration<String> getAttributeNames();
-
- private abstract class AbstractAttributeSet<E> extends AbstractSet<E>
- {
- @Override
- public boolean isEmpty()
- {
- return AbstractThreadSafeAttributeMap.this.isEmpty();
- }
-
- @Override
- public int size()
- {
- return AbstractThreadSafeAttributeMap.this.size();
- }
-
- @Override
- public void clear()
- {
- AbstractThreadSafeAttributeMap.this.clear();
- }
- }
-
- private final class KeySet extends AbstractAttributeSet<String>
- {
- @Override
- public Iterator<String> iterator()
- {
- return new KeyIterator();
- }
-
- @Override
- public boolean contains(final Object o)
- {
- return AbstractThreadSafeAttributeMap.this.containsKey(o);
- }
-
- @Override
- public boolean remove(final Object o)
- {
- return AbstractThreadSafeAttributeMap.this.remove(o) != null;
- }
-
- }
-
- private abstract class AbstractAttributeIterator<E> implements Iterator<E>
- {
- // We use a copied version of the Enumeration from getAttributeNames()
- // here, because directly using it might cause a ConcurrentModificationException
- // when performing remove(). Note that we can do this since the Enumeration
- // from getAttributeNames() will contain exactly the attribute names from the time
- // getAttributeNames() was called and it will not be updated if attributes are
- // removed or added.
- protected final Iterator<String> _i = Collections.list(getAttributeNames()).iterator();
- protected String _currentKey;
-
- public void remove()
- {
- if (_currentKey == null)
- {
- throw new NoSuchElementException("You must call next() at least once");
- }
- AbstractThreadSafeAttributeMap.this.remove(_currentKey);
- }
-
- public boolean hasNext()
- {
- return _i.hasNext();
- }
-
- public E next()
- {
- return getValue(_currentKey = _i.next());
- }
-
- protected abstract E getValue(String attributeName);
- }
-
- private final class KeyIterator extends AbstractAttributeIterator<String>
- {
- @Override
- protected String getValue(final String attributeName)
- {
- return attributeName;
- }
- }
-
- private class Values extends AbstractAttributeSet<V>
- {
- @Override
- public Iterator<V> iterator()
- {
- return new ValuesIterator();
- }
-
- @Override
- public boolean contains(final Object o)
- {
- if (o == null)
- {
- return false;
- }
-
- for (final Iterator<V> it = iterator(); it.hasNext();)
- {
- if (o.equals(it.next()))
- {
- return true;
- }
- }
-
- return false;
- }
-
- @Override
- public boolean remove(final Object o)
- {
- if (o == null)
- {
- return false;
- }
-
- for (final Iterator<V> it = iterator(); it.hasNext();)
- {
- if (o.equals(it.next()))
- {
- it.remove();
- return true;
- }
- }
-
- return false;
- }
- }
-
- private class ValuesIterator extends AbstractAttributeIterator<V>
- {
- @Override
- protected V getValue(final String attributeName)
- {
- return AbstractThreadSafeAttributeMap.this.get(attributeName);
- }
- }
-
- private final class EntrySet extends AbstractAttributeSet<Entry<String, V>>
- {
- @Override
- public Iterator<Entry<String, V>> iterator()
- {
- return new EntryIterator();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public boolean contains(final Object o)
- {
- if (!(o instanceof Entry))
- {
- return false;
- }
-
- final Entry<String, V> entry = (Entry<String, V>)o;
- final Object key = entry.getKey();
- final Object value = entry.getValue();
- if (key == null || value == null)
- {
- return false;
- }
-
- return value.equals(AbstractThreadSafeAttributeMap.this.get(key));
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public boolean remove(final Object o)
- {
- if (!(o instanceof Entry))
- {
- return false;
- }
-
- final Entry<String, V> entry = (Entry<String, V>)o;
- final Object key = entry.getKey();
- final Object value = entry.getValue();
- if (key == null || value == null || !value.equals(AbstractThreadSafeAttributeMap.this.get(key)))
- {
- return false;
- }
-
- return AbstractThreadSafeAttributeMap.this.remove(((Entry<String, V>)o).getKey()) != null;
- }
- }
-
- /**
- * Not very efficient since it generates a new instance of <code>Entry</code> for each element and still internaly
- * uses the <code>KeyIterator</code>. It is more efficient to use the <code>KeyIterator</code> directly.
- */
- private final class EntryIterator extends AbstractAttributeIterator<Entry<String, V>>
- {
- @Override
- protected Entry<String, V> getValue(final String attributeName)
- {
- // Must create new Entry every time--value of the entry must stay
- // linked to the same attribute name
- return new EntrySetEntry(attributeName);
- }
- }
-
- private final class EntrySetEntry implements Entry<String, V>
- {
- private final String _currentKey;
-
- public EntrySetEntry(final String currentKey)
- {
- _currentKey = currentKey;
- }
-
- public String getKey()
- {
- return _currentKey;
- }
-
- public V getValue()
- {
- return AbstractThreadSafeAttributeMap.this.get(_currentKey);
- }
-
- public V setValue(final V value)
- {
- return AbstractThreadSafeAttributeMap.this.put(_currentKey, value);
- }
-
- @Override
- public int hashCode()
- {
- int result = 1;
- result = 31 * result + ((_currentKey == null) ? 0 : _currentKey.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(final Object obj)
- {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final EntrySetEntry other = (EntrySetEntry)obj;
- if (_currentKey == null)
- {
- if (other._currentKey != null)
- return false;
- }
- else if (!_currentKey.equals(other._currentKey))
- return false;
- return true;
- }
-
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/jsf/RefreshPhaseListener.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/jsf/RefreshPhaseListener.java
deleted file mode 100644
index 17ca58d..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/jsf/RefreshPhaseListener.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf;
-
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-import javax.faces.event.PhaseListener;
-import javax.faces.event.PhaseEvent;
-import javax.faces.event.PhaseId;
-import javax.faces.context.FacesContext;
-import java.util.Map;
-
-/**
- * We use a phase listener here for all parts of the refresh
- * which have to rely on jsf access
- * <p/>
- * Which means all parts which need some kind of FacesConfig have
- * to rely on this one, we trigger before the first phase
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- *
- */
-
-public class RefreshPhaseListener implements PhaseListener {
-
- public static final String EQ_KEY = "RefreshPhaseListenerDone";
-
- /**
- * this eases testing, because in our
- * absence of intelligence we have
- * not done yet the WeavingContext as singleton
- * like it should be
- */
- static Runnable _action = new Runnable() {
- public void run() {
- WeavingContext.jsfRequestRefresh();
- }
- };
-
- public void afterPhase(PhaseEvent event) {
- }
-
- @SuppressWarnings("unchecked")
- public void beforePhase(PhaseEvent event) {
- //we fetch the earliest phase possible, in case of a normal get it is the render phase
- //in every other case it is the restore view phase
- Map requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
- if (requestMap.containsKey(EQ_KEY)) return;
- requestMap.put(EQ_KEY, Boolean.TRUE);
-
- RefreshPhaseListener._action.run();
- }
-
- public PhaseId getPhaseId() {
- return PhaseId.ANY_PHASE;
- }
-
- @SuppressWarnings("unused")
- public static void applyAction(Runnable newAction) {
- _action = newAction;
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/jsf/RequestMap.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/jsf/RequestMap.java
deleted file mode 100644
index 09dd729..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/jsf/RequestMap.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.jsf;
-
-import javax.servlet.ServletRequest;
-import java.util.Enumeration;
-import java.util.Map;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class RequestMap extends AbstractThreadSafeAttributeMap
-{
- final ServletRequest _request;
-
- public RequestMap(ServletRequest request)
- {
- _request = request;
- }
-
- protected Object getAttribute(String key)
- {
- return _request.getAttribute(key);
- }
-
- protected void setAttribute(String key, Object value)
- {
- _request.setAttribute(key, value);
- }
-
- protected void removeAttribute(String key)
- {
- _request.removeAttribute(key);
- }
-
- protected Enumeration getAttributeNames()
- {
- return _request.getAttributeNames();
- }
-
- public void putAll(Map t)
- {
- throw new UnsupportedOperationException();
- }
-
-
- public void clear()
- {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/jsf/ServletApplicationMap.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/jsf/ServletApplicationMap.java
deleted file mode 100644
index 90ffe7e..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/jsf/ServletApplicationMap.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf;
-
-import javax.servlet.ServletContext;
-import java.util.Enumeration;
-import java.util.Map;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public final class ServletApplicationMap extends AbstractThreadSafeAttributeMap<Object>
-{
- final ServletContext _servletContext;
-
- public ServletApplicationMap(final ServletContext servletContext)
- {
- _servletContext = servletContext;
- }
-
- @Override
- protected Object getAttribute(final String key)
- {
- return _servletContext.getAttribute(key);
- }
-
- @Override
- protected void setAttribute(final String key, final Object value)
- {
- _servletContext.setAttribute(key, value);
- }
-
- @Override
- protected void removeAttribute(final String key)
- {
- _servletContext.removeAttribute(key);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- protected Enumeration<String> getAttributeNames()
- {
- return _servletContext.getAttributeNames();
- }
-
-
- @Override
- public void putAll(final Map<? extends String, ? extends Object> t)
- {
- throw new UnsupportedOperationException();
- }
-
-
- @Override
- public void clear()
- {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/DynamicClassIdentifier.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/DynamicClassIdentifier.java
deleted file mode 100644
index 53d6b68..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/DynamicClassIdentifier.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.loaders.groovy;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * This class checks for reloadable class patterns
- * we do it on the java side for existing groovy objects
- *
- * @author Werner Punz
- */
-public class DynamicClassIdentifier implements org.apache.myfaces.extensions.scripting.api.DynamicClassIdentifier {
- static ThreadLocal _checked = new ThreadLocal();
-
- public boolean isDynamic(Class clazz) {
- Map<String, Boolean> alreadyChecked = getAlreadyChecked();
- if (alreadyChecked.containsKey(clazz.getName())) {
- return alreadyChecked.get(clazz.getName());
- }
-
- Class[] interfaces = clazz.getInterfaces();
- for (Class anInterface : interfaces) {
- if (anInterface.getName().startsWith("groovy.lang")) {
- alreadyChecked.put(clazz.getName(), Boolean.TRUE);
- return true;
- }
- }
- alreadyChecked.put(clazz.getName(), Boolean.FALSE);
- return false;
- }
-
- @SuppressWarnings("unchecked")
- private Map<String, Boolean> getAlreadyChecked() {
- Map<String, Boolean> checked = (Map<String, Boolean>) _checked.get();
- if (checked == null) {
- checked = new HashMap<String, Boolean>();
- }
- return checked;
- }
-
- public int getEngineType(Class clazz) {
- if (isDynamic(clazz)) {
- return ScriptingConst.ENGINE_TYPE_JSF_GROOVY;
- } else {
- return ScriptingConst.ENGINE_TYPE_JSF_NO_ENGINE;
- }
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/GroovyDependencyScanner.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/GroovyDependencyScanner.java
deleted file mode 100644
index 7bc3617..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/GroovyDependencyScanner.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.loaders.groovy;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.loaders.java.JavaDependencyScanner;
-import org.apache.myfaces.extensions.scripting.loaders.java.ScannerClassloader;
-
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Dependency scanner for groovy
- * basically the same as the java dependency scanner
- * but we use a different class here to fulfill
- * our contractual obligations with the chain
- * pattern we use for chaining different scanners
- * depending on the scripting implementation
- */
-public class GroovyDependencyScanner extends JavaDependencyScanner {
-
- public GroovyDependencyScanner(ScriptingWeaver weaver) {
- super(weaver);
- }
-
- static PrivilegedExceptionAction<ScannerClassloader> CLASSLOADER_PRIVILEGED = new PrivilegedExceptionAction<ScannerClassloader>() {
- public ScannerClassloader run() {
- return new ScannerClassloader(Thread.currentThread().getContextClassLoader(), ScriptingConst.ENGINE_TYPE_JSF_GROOVY, ScriptingConst.FILE_EXTENSION_GROOVY, WeavingContext.getConfiguration().getCompileTarget());
- }
- };
-
- @Override
- protected ClassLoader getClassLoader() {
- //TODO move the temp dir handling into the configuration
- try {
- return AccessController.doPrivileged(CLASSLOADER_PRIVILEGED);
- } catch (PrivilegedActionException e) {
- Logger _logger = Logger.getLogger(this.getClass().getName());
- _logger.log(Level.SEVERE, "", e);
- }
- return null;
- }
-
- @Override
- protected int getEngineType() {
- return ScriptingConst.ENGINE_TYPE_JSF_GROOVY;
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/GroovyRecompiledClassloader.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/GroovyRecompiledClassloader.java
deleted file mode 100644
index dfaa366..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/GroovyRecompiledClassloader.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.loaders.groovy;
-
-import org.apache.myfaces.extensions.scripting.loaders.java.RecompiledClassLoader;
-
-/**
- * The reloading throw away classloader
- * for groovy artifacts
- */
-public class GroovyRecompiledClassloader extends RecompiledClassLoader {
- public GroovyRecompiledClassloader(ClassLoader classLoader, int scriptingEngine, String engineExtension) {
- super(classLoader, scriptingEngine, engineExtension);
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/GroovyScriptingWeaver.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/GroovyScriptingWeaver.java
deleted file mode 100644
index eb48cfd..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/GroovyScriptingWeaver.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.loaders.groovy;
-
-import org.apache.myfaces.extensions.scripting.groovyloader.core.StandardGroovyReloadingStrategy;
-import org.apache.myfaces.extensions.scripting.api.*;
-import org.apache.myfaces.extensions.scripting.core.util.Cast;
-import org.apache.myfaces.extensions.scripting.core.util.ClassUtils;
-import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
-import org.apache.myfaces.extensions.scripting.loaders.groovy.compiler.GroovyCompilerFacade;
-
-import javax.servlet.ServletContext;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * A standard groovy weaver which isolates the weaving behavior
- */
-public class GroovyScriptingWeaver extends BaseWeaver {
-
- org.apache.myfaces.extensions.scripting.loaders.groovy.DynamicClassIdentifier _identifier = new org.apache.myfaces.extensions.scripting.loaders.groovy.DynamicClassIdentifier();
-
- final Logger _logger = Logger.getLogger(GroovyScriptingWeaver.class.getName());
-
- /**
- * helper to allow initial compiler classpath scanning
- *
- * @param servletContext servlet context to be passed down
- */
- @SuppressWarnings("unused")
- public GroovyScriptingWeaver(ServletContext servletContext) {
- super(ScriptingConst.GROOVY_FILE_ENDING, ScriptingConst.ENGINE_TYPE_JSF_GROOVY);
- init();
-
- }
-
- public GroovyScriptingWeaver() {
- super(ScriptingConst.FILE_EXTENSION_GROOVY, ScriptingConst.ENGINE_TYPE_JSF_GROOVY);
- init();
- }
-
- private void init() {
- //init classpath removed we can resolve that over the
- //url classloader at the time myfaces is initialized
- try {
- Class scanner = ClassUtils.getContextClassLoader().loadClass("org.apache.myfaces.extensions.scripting.jsf2.annotation.GenericAnnotationScanner");
- this._annotationScanner = (ClassScanner) ReflectUtil.instantiate(scanner, new Cast(ScriptingWeaver.class, this));
-
- } catch (ClassNotFoundException e) {
- //we do nothing here
- //generic annotation scanner can be missing in jsf1 environments
- _logger.log(Level.FINER, "", e);
- }
-
- this._dependencyScanner = new GroovyDependencyScanner(this);
- this._reloadingStrategy = new StandardGroovyReloadingStrategy();
- this._reloadingStrategy.setWeaver(this);
- }
-
- protected String getLoadingInfo(String file) {
- return "[EXT-SCRIPTING] Loading Groovy file:" + file;
- }
-
- public boolean isDynamic(Class clazz) {
- return _identifier.isDynamic(clazz);
- }
-
- protected DynamicCompiler instantiateCompiler() {
- return new GroovyCompilerFacade();
- }
-
- /**
- * checks outside of the request scope for changes and taints the corresponding engine
- */
- public void scanForAddedClasses() {
- _dependencyScanner.scanAndMarkChange();
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/MetaclassStubcompilerFix.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/MetaclassStubcompilerFix.java
deleted file mode 100644
index 8004254..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/MetaclassStubcompilerFix.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.loaders.groovy;
-
-import groovy.lang.DelegatingMetaClass;
-import groovy.lang.MetaClass;
-
-/**
- * TODO check if this is deprecated
- *
- * @author Werner Punz
- */
-public class MetaclassStubcompilerFix extends DelegatingMetaClass {
-
- public MetaclassStubcompilerFix(Class aClass) {
- super(aClass);
- initialize();
- }
-
- public MetaclassStubcompilerFix(MetaClass metaClass) {
- super(metaClass); //To change body of overridden methods use File | Settings | File Templates.
- }
-
- /*dummy constructor do not use it it bypasses
- * a bug in the maven-groovy stub compiler regarding
- * base classes*/
-
- @SuppressWarnings("unused")
- public MetaclassStubcompilerFix() {
- super(MetaclassStubcompilerFix.class);
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/compiler/GroovyCompiler.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/compiler/GroovyCompiler.java
deleted file mode 100644
index 290ec60..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/compiler/GroovyCompiler.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.loaders.groovy.compiler;
-
-import org.apache.myfaces.extensions.scripting.api.CompilationException;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.ClassLoaderUtils;
-import org.apache.myfaces.extensions.scripting.core.util.FileUtils;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.api.CompilationResult;
-import org.codehaus.groovy.control.CompilationFailedException;
-import org.codehaus.groovy.control.CompilationUnit;
-import org.codehaus.groovy.control.CompilerConfiguration;
-import org.codehaus.groovy.control.ErrorCollector;
-import org.codehaus.groovy.control.messages.Message;
-import org.codehaus.groovy.control.messages.SimpleMessage;
-import org.codehaus.groovy.control.messages.SyntaxErrorMessage;
-
-import java.io.File;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * <p>A compiler implementation that can be used to compile Groovy source files.</p>
- */
-public class GroovyCompiler implements org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler {
-
- /**
- * The logger instance for this class.
- */
- private static final Logger _logger = Logger.getLogger(GroovyCompiler.class.getName());
-
- // ------------------------------------------ Compiler methods
-
- /**
- * <p>Compiles the given file and creates an according class file in the given target path.</p>
- *
- * @param sourcePath the path to the source directory
- * @param targetPath the path to the target directory
- * @param file the file of the class you want to compile
- * @param classLoader the class loader to use to determine the classpath
- * @return the compilation result
- */
- public CompilationResult compile(File sourcePath, File targetPath, String file, ClassLoader classLoader)
- throws CompilationException {
- return compile(sourcePath, targetPath, new File(sourcePath, file), classLoader);
- }
-
- public CompilationResult compile(File sourcePath, File targetPath, ClassLoader classLoader) {
-
- List<File> sourceFiles = FileUtils.fetchSourceFiles(WeavingContext.getConfiguration().getWhitelistedSourceDirs(ScriptingConst.ENGINE_TYPE_JSF_GROOVY), "*.groovy");
-
- StringWriter compilerOutput = new StringWriter();
-
- CompilationUnit compilationUnit = new CompilationUnit(
- buildCompilerConfiguration(sourcePath, targetPath, classLoader));
- compilationUnit.getConfiguration().setOutput(new PrintWriter(compilerOutput));
-
- for (File sourceFile : sourceFiles) {
- compilationUnit.addSource(sourceFile);
- }
-
- CompilationResult result;
-
- try {
- compilationUnit.compile();
-
- result = new CompilationResult(compilerOutput.toString());
- WeavingContext.setCompilationResult(ScriptingConst.ENGINE_TYPE_JSF_GROOVY, result);
-
- } catch (CompilationFailedException ex) {
- // Register all collected error messages from the Groovy compiler
- result = new CompilationResult(compilerOutput.toString());
- ErrorCollector collector = compilationUnit.getErrorCollector();
- for (int i = 0; i < collector.getErrorCount(); ++i) {
- result.registerError(convertMessage(collector.getError(i)));
- }
- }
-
- // Register all collected warnings from the Groovy compiler
- ErrorCollector collector = compilationUnit.getErrorCollector();
- for (int i = 0; i < collector.getWarningCount(); ++i) {
- result.registerWarning(convertMessage(collector.getWarning(i)));
- }
-
- return result;
- }
-
- /**
- * <p>Compiles the given file and creates an according class file in the given target path.</p>
- *
- * @param sourcePath the path to the source directory
- * @param targetPath the path to the target directory
- * @param file the file of the class you want to compile
- * @param classLoader the class loader to use to determine the classpath
- * @return the compilation result
- */
- public CompilationResult compile(File sourcePath, File targetPath, File file, ClassLoader classLoader)
- throws CompilationException {
- StringWriter compilerOutput = new StringWriter();
-
- //TODO add whitelist check here
-
- CompilationUnit compilationUnit = new CompilationUnit(
- buildCompilerConfiguration(sourcePath, targetPath, classLoader));
- compilationUnit.getConfiguration().setOutput(new PrintWriter(compilerOutput));
- compilationUnit.addSource(file);
-
- CompilationResult result;
-
- try {
- compilationUnit.compile();
-
- result = new CompilationResult(compilerOutput.toString());
-
- WeavingContext.setCompilationResult(ScriptingConst.ENGINE_TYPE_JSF_GROOVY, result);
- } catch (CompilationFailedException ex) {
- // Register all collected error messages from the Groovy compiler
- result = new CompilationResult(compilerOutput.toString());
- ErrorCollector collector = compilationUnit.getErrorCollector();
- for (int i = 0; i < collector.getErrorCount(); ++i) {
- result.registerError(convertMessage(collector.getError(i)));
- }
- }
-
- // Register all collected warnings from the Groovy compiler
- ErrorCollector collector = compilationUnit.getErrorCollector();
- for (int i = 0; i < collector.getWarningCount(); ++i) {
- result.registerWarning(convertMessage(collector.getWarning(i)));
- }
-
- return result;
- }
-
- // ------------------------------------------ Utility methods
-
- /**
- * <p>Converts the given Groovy compiler message into a compilation message that
- * our compilation API consists of.</p>
- *
- * @param message the Groovy compiler message you want to convert
- * @return the final converted compilation message
- */
- protected CompilationResult.CompilationMessage convertMessage(Message message) {
- if (message instanceof SimpleMessage) {
- SimpleMessage simpleMessage = (SimpleMessage) message;
- return new CompilationResult.CompilationMessage(-1, simpleMessage.getMessage());
- } else if (message instanceof SyntaxErrorMessage) {
- SyntaxErrorMessage syntaxErrorMessage = (SyntaxErrorMessage) message;
- return new CompilationResult.CompilationMessage(
- syntaxErrorMessage.getCause().getLine(), syntaxErrorMessage.getCause().getMessage());
- } else {
- if (_logger.isLoggable(Level.FINE)) {
- _logger.log(Level.FINE,
- "This compiler came across an unknown message kind ['{0}']. It will be ignored.", message);
- }
-
- return null;
- }
- }
-
- /**
- * <p>Configures the compiler by building its configuration object.</p>
- *
- * @param sourcePath the path to the source directory
- * @param targetPath the path to the target directory
- * @param classLoader the class loader to use to determine the classpath
- * @return the compiler configuration
- */
- protected CompilerConfiguration buildCompilerConfiguration(File sourcePath, File targetPath, ClassLoader classLoader) {
- CompilerConfiguration configuration = new CompilerConfiguration();
-
- // Set the destination / target directory for the compiled .class files.
- configuration.setTargetDirectory(targetPath.getAbsoluteFile());
-
- // Specify the classpath of the given class loader. This enables the user to write new Java
- // "scripts" that depend on classes that have already been loaded previously. Otherwise he
- // wouldn't be able to use for example classes that are available in a library.
- configuration.setClasspath(ClassLoaderUtils.buildClasspath(classLoader));
-
- // Enable verbose output.
- configuration.setVerbose(true);
-
- // Generate debugging information.
- configuration.setDebug(true);
-
- return configuration;
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/compiler/GroovyCompilerFacade.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/compiler/GroovyCompilerFacade.java
deleted file mode 100644
index 2fe71e8..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/groovy/compiler/GroovyCompilerFacade.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.loaders.groovy.compiler;
-
-import org.apache.myfaces.extensions.scripting.api.CompilationResult;
-import org.apache.myfaces.extensions.scripting.api.DynamicCompiler;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.ClassUtils;
-import org.apache.myfaces.extensions.scripting.core.util.FileUtils;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.loaders.groovy.GroovyRecompiledClassloader;
-import org.apache.myfaces.extensions.scripting.sandbox.compiler.GroovyCompiler;
-
-import java.io.File;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * Custom compiler call for jdk5
- * we can call javac directly
- */
-
-public class GroovyCompilerFacade implements DynamicCompiler {
-
- Logger _log = Logger.getLogger(this.getClass().getName());
- GroovyCompiler compiler;
-
- static final PrivilegedExceptionAction<GroovyRecompiledClassloader> LOADER_ACTION = new PrivilegedExceptionAction<GroovyRecompiledClassloader>() {
- public GroovyRecompiledClassloader run() {
- return new GroovyRecompiledClassloader(ClassUtils.getContextClassLoader(), ScriptingConst.ENGINE_TYPE_JSF_GROOVY, ".groovy");
- }
- };
-
- public GroovyCompilerFacade() {
- super();
-
- compiler = new GroovyCompiler();
- }
-
- public Class loadClass(String sourceRoot, String classPath, String filePath) throws ClassNotFoundException {
-
- String separator = FileUtils.getFileSeparatorForRegex();
- String className = filePath.replaceAll(separator, ".");
- className = ClassUtils.relativeFileToClassName(className);
-
- GroovyRecompiledClassloader classLoader;
- try {
- classLoader = AccessController.doPrivileged(LOADER_ACTION);
- } catch (PrivilegedActionException e) {
- _log.log(Level.SEVERE, "", e);
- return null;
- }
-
- ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- classLoader.setSourceRoot(sourceRoot);
- Thread.currentThread().setContextClassLoader(classLoader);
-
- return classLoader.loadClass(className);
- } finally {
- Thread.currentThread().setContextClassLoader(oldClassLoader);
- }
- }
-
-
- public File compileFile(String sourceRoot, String classPath, String filePath) {
- //TODO do a full compile and block the compile for the rest of the request
- //so that we do not run into endless compile cycles
-
- /*
- * privilege block to allow custom classloading only
- * in case of having the privileges,
- * this was proposed by the checkstyle plugin
- */
- GroovyRecompiledClassloader classLoader;
- try {
- classLoader = AccessController.doPrivileged(LOADER_ACTION);
- } catch (PrivilegedActionException e) {
- _log.log(Level.SEVERE, "", e);
- return null;
- }
-
-
- classLoader.setSourceRoot(sourceRoot);
- CompilationResult result = compiler.compile(new File(sourceRoot), WeavingContext.getConfiguration().getCompileTarget(), new File(sourceRoot + File.separator + filePath), classLoader);
-
- displayMessages(result);
-
- return new File(WeavingContext.getConfiguration().getCompileTarget() + File.separator + filePath.substring(0, filePath.lastIndexOf('.')) + ".class");
- }
-
-
-
- /**
- * compiles all files
- *
- * @param sourceRoot the source root
- * @param classPath the class path
- * @return the root target path for the classes which are compiled
- * so that they later can be picked up by the classloader
- */
- public File compileAllFiles(String sourceRoot, String classPath) {
- GroovyRecompiledClassloader classLoader;
- try {
- classLoader = AccessController.doPrivileged(LOADER_ACTION);
- } catch (PrivilegedActionException e) {
- _log.log(Level.SEVERE, "", e);
- return null;
- }
-
- classLoader.setSourceRoot(sourceRoot);
- CompilationResult result = compiler.compile(new File(sourceRoot), WeavingContext.getConfiguration().getCompileTarget(), classLoader);
-
- displayMessages(result);
- return WeavingContext.getConfiguration().getCompileTarget();
- }
-
- private void displayMessages(CompilationResult result) {
- for (CompilationResult.CompilationMessage error : result.getErrors()) {
- _log.log(Level.WARNING, "[EXT-SCRIPTING] Groovy compiler error: {0} - {1}", new String[]{Long.toString(error.getLineNumber()), error.getMessage()});
- }
- for (CompilationResult.CompilationMessage error : result.getWarnings()) {
- _log.log(Level.WARNING, "[EXT-SCRIPTING] Groovy compiler warning: {0}", error.getMessage());
- }
- WeavingContext.setCompilationResult(ScriptingConst.ENGINE_TYPE_JSF_GROOVY, result);
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/DynamicClassIdentifier.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/DynamicClassIdentifier.java
deleted file mode 100644
index b7a4eca..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/DynamicClassIdentifier.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.loaders.java;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-
-import java.lang.annotation.Annotation;
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * @author werpu
- * A dynamic class identifier for java classes
- * <p/>
- * TODO the algorithm of this class probably is obsolete, normally
- * a check for the classloader of the class being an instance
- * of our custom classloader ought to be enough, this has to be tested
- * though
- */
-public class DynamicClassIdentifier implements org.apache.myfaces.extensions.scripting.api.DynamicClassIdentifier {
- static ThreadLocal _checked = new ThreadLocal();
-
- public boolean isDynamic(Class clazz) {
- Map<String, Boolean> alreadyChecked = getAlreadyChecked();
- if (alreadyChecked.containsKey(clazz.getName())) {
- return alreadyChecked.get(clazz.getName());
- }
- if (checkForAnnotation(clazz)) {
- alreadyChecked.put(clazz.getName(), Boolean.TRUE);
- return true;
- }
-
- alreadyChecked.put(clazz.getName(), Boolean.FALSE);
- return false;
- }
-
- private Map<String, Boolean> getAlreadyChecked() {
- Map<String, Boolean> checked = (Map<String, Boolean>) _checked.get();
- if (checked == null) {
- checked = new HashMap<String, Boolean>();
- _checked.set(checked);
- }
- return checked;
- }
-
- private final boolean checkForAnnotation(Class clazz) {
- //Annotation identifier = clazz.getAnnotation(ScriptingClass.class);
- if (clazz.getClassLoader() == null) return false;
-
- Annotation identifier = clazz.getClassLoader().getClass().getAnnotation(JavaThrowAwayClassloader.class);
- boolean annotated = identifier != null;
-
- return annotated;
- }
-
- public int getEngineType(Class clazz) {
- if (isDynamic(clazz)) {
- return ScriptingConst.ENGINE_TYPE_JSF_JAVA;
- } else {
- return ScriptingConst.ENGINE_TYPE_JSF_NO_ENGINE;
- }
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/JavaDependencyScanner.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/JavaDependencyScanner.java
deleted file mode 100644
index d971313..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/JavaDependencyScanner.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.loaders.java;
-
-import org.apache.myfaces.extensions.scripting.api.ClassScanListener;
-import org.apache.myfaces.extensions.scripting.api.ClassScanner;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.StandardDependencyScanner;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.api.DependencyScanner;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.filter.WhitelistFilter;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.registry.DependencyRegistryImpl;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.registry.ExternalFilterDependencyRegistry;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.monitor.ClassResource;
-import org.apache.myfaces.extensions.scripting.monitor.RefreshAttribute;
-
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * A dependency scanner which utilizes the scan infrastructure
- * from the core
- */
-public class JavaDependencyScanner implements ClassScanner {
-
- List<String> _scanPaths = new LinkedList<String>();
-
- DependencyScanner _depencyScanner = new StandardDependencyScanner();
-
- ScriptingWeaver _weaver;
- Logger _log = Logger.getLogger(JavaDependencyScanner.class.getName());
-
- public JavaDependencyScanner(ScriptingWeaver weaver) {
- this._weaver = weaver;
-
- }
-
- public synchronized void scanPaths() {
- //only one dependency check per refresh makes sense in our case
- if (WeavingContext.getRefreshContext().isDependencyScanned(getEngineType())) {
- return;
- } else {
- WeavingContext.getRefreshContext().setDependencyScanned(getEngineType(), true);
- }
-
- if (_log.isLoggable(Level.INFO)) {
- _log.info("[EXT-SCRITPING] starting class dependency scan");
- }
- long start = System.currentTimeMillis();
- final Set<String> possibleDynamicClasses = new HashSet<String>(_weaver.loadPossibleDynamicClasses());
-
- final ClassLoader loader = getClassLoader();
- for (String dynamicClass : possibleDynamicClasses) {
- runScan(possibleDynamicClasses, loader, dynamicClass);
- }
-
- long end = System.currentTimeMillis();
- if (_log.isLoggable(Level.FINE)) {
- _log.log(Level.FINE, "[EXT-SCRITPING] class dependency scan finished, duration: {0} ms", Long.toString(end - start));
- }
-
- }
-
- protected int getEngineType() {
- return ScriptingConst.ENGINE_TYPE_JSF_JAVA;
- }
-
- private void runScan(final Set<String> possibleDynamicClasses, final ClassLoader loader, String dynamicClass) {
-
- ExternalFilterDependencyRegistry scanRegistry = (ExternalFilterDependencyRegistry) WeavingContext.getRefreshContext().getDependencyRegistry(getEngineType());
- if (scanRegistry == null) {
- scanRegistry = new DependencyRegistryImpl(getEngineType(), WeavingContext.getFileChangedDaemon().getDependencyMap());
- WeavingContext.getRefreshContext().setDependencyRegistry(getEngineType(), scanRegistry);
- } else {
- scanRegistry.clearFilters();
- }
-
- //We have to dynamically readjust the filters
- scanRegistry.addFilter(new WhitelistFilter(possibleDynamicClasses));
-
- _depencyScanner.fetchDependencies(loader, getEngineType(), dynamicClass, WeavingContext.getRefreshContext().getDependencyRegistry());
- }
-
- protected ClassLoader getClassLoader() {
- try {
- return AccessController.doPrivileged(new PrivilegedExceptionAction<ScannerClassloader>() {
- public ScannerClassloader run() {
- return new ScannerClassloader(Thread.currentThread().getContextClassLoader(), getEngineType(), ".java", WeavingContext.getConfiguration().getCompileTarget());
- }
- });
- } catch (PrivilegedActionException e) {
- _log.log(Level.SEVERE,"", e);
- }
- return null;
- }
-
- public void clearListeners() {
- }
-
- public void addListener(ClassScanListener listener) {
-
- }
-
- public void addScanPath(String scanPath) {
- _scanPaths.add(scanPath);
- }
-
- public synchronized void scanClass(Class clazz) {
- //not needed anymore since we only rely on full scans and full recompile now
- }
-
- public void scanAndMarkChange() {
-
- final Set<String> possibleDynamicClasses = new HashSet<String>(_weaver.loadPossibleDynamicClasses());
- Map<Integer, Boolean> recompileMap = WeavingContext.getRefreshContext().getDaemon().getSystemRecompileMap();
- Map<String, ClassResource> classMap = WeavingContext.getRefreshContext().getDaemon().getClassMap();
- Boolean alreadyTainted = recompileMap.get(getEngineType());
- if (alreadyTainted != null && alreadyTainted) {
- return;
- }
-
- for (String clazz : possibleDynamicClasses) {
- if (!classMap.containsKey(clazz)) {
- recompileMap.put(getEngineType(), Boolean.TRUE);
- }
- }
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/JavaScriptingWeaver.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/JavaScriptingWeaver.java
deleted file mode 100644
index b045f93..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/JavaScriptingWeaver.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.loaders.java;
-
-import org.apache.myfaces.extensions.scripting.api.*;
-import org.apache.myfaces.extensions.scripting.core.util.*;
-import org.apache.myfaces.extensions.scripting.loaders.java.compiler.CompilerFacade;
-//import org.apache.myfaces.extensions.scripting.loaders.java.jsr199.ReflectCompilerFacade;
-
-import javax.servlet.ServletContext;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.Serializable;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * @author werpu
- * <p/>
- * The Scripting Weaver for the java core which reloads the java scripts
- * dynamically upon change
- * <p/>
- * <p/>
- * Note this is the central focus point for all reloading related activity
- * this class introduces the correct class loader
- * it manages the bean reloading on the proper stage of the lifecyle,
- * calls the compilers single and all compile,
- * it adds the strategies for the property handling of the reloaded instance
- * <p/>
- * Every language implementation has to implement this weaver
- * and (if not done differently) also the proper compiler bindings
- * and property handling strategies.
- */
-public class JavaScriptingWeaver extends BaseWeaver implements Serializable {
-
- private static final long serialVersionUID = -3024995032644947216L;
-
- transient DynamicClassIdentifier _identifier = new DynamicClassIdentifier();
-
- transient Logger _logger = Logger.getLogger(JavaScriptingWeaver.class.getName());
-
- /**
- * helper to allow initial compiler classpath scanning
- *
- * @param servletContext the servlet context
- */
- @SuppressWarnings("unused")
- public JavaScriptingWeaver(ServletContext servletContext) {
- super(ScriptingConst.JAVA_FILE_ENDING, ScriptingConst.ENGINE_TYPE_JSF_JAVA);
- init();
-
- }
-
- private void init() {
- //init classpath removed we can resolve that over the
- //url classloader at the time myfaces is initialized
- try {
- Class scanner = ClassUtils.getContextClassLoader().loadClass("org.apache.myfaces.extensions.scripting.jsf2.annotation.GenericAnnotationScanner");
- this._annotationScanner = (ClassScanner) ReflectUtil.instantiate(scanner, new Cast(ScriptingWeaver.class, this));
-
- } catch (ClassNotFoundException e) {
- //we do nothing here
- //generic annotation scanner can be missing in jsf 1.2 environments
- _logger.log(Level.FINER, "", e);
- }
-
- this._dependencyScanner = new JavaDependencyScanner(this);
- }
-
- public JavaScriptingWeaver() {
- super(ScriptingConst.JAVA_FILE_ENDING, ScriptingConst.ENGINE_TYPE_JSF_JAVA);
- }
-
- protected String getLoadingInfo(String file) {
- return "[EXT-SCRIPTING] Loading Java file:" + file;
- }
-
- public boolean isDynamic(Class clazz) {
- return _identifier.isDynamic(clazz);
- }
-
- /**
- * checks outside of the request scope for changes and taints the corresponding engine
- */
- public void scanForAddedClasses() {
- _dependencyScanner.scanAndMarkChange();
- }
-
- protected DynamicCompiler instantiateCompiler() {
- return new CompilerFacade();
- }
-
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
- in.defaultReadObject();
- _identifier = new DynamicClassIdentifier();
- Logger.getLogger(JavaScriptingWeaver.class.getName());
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/JavaThrowAwayClassloader.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/JavaThrowAwayClassloader.java
deleted file mode 100644
index 3b1c011..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/JavaThrowAwayClassloader.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.loaders.java;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * A marker interface which marks throw away classloaders
- * which only load java classes (we replace the current
- * class altering code with the one for
- */
-
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface JavaThrowAwayClassloader {
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/RecompiledClassLoader.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/RecompiledClassLoader.java
deleted file mode 100644
index 17c57ac..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/RecompiledClassLoader.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.loaders.java;
-
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.monitor.ClassResource;
-
-import java.io.InputStream;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * <p/>
- * Classloader which loads the compiled files of the corresponding scripting engine
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-@JavaThrowAwayClassloader
-public class RecompiledClassLoader extends ClassLoader {
- int _scriptingEngine;
- String _engineExtension;
- boolean _unTaintClasses = true;
- String _sourceRoot;
- ThrowawayClassloader _throwAwayLoader = null;
-
- static class _Action implements PrivilegedExceptionAction<ThrowawayClassloader> {
-
- ClassLoader _parent;
- Integer _scriptingEngine;
- String _engineExtension;
- Boolean _untaint;
-
- _Action(ClassLoader parent, Integer scriptingEngine, String engineExtension, Boolean untaint) {
- _parent = parent;
- this._scriptingEngine = scriptingEngine;
- this._engineExtension = engineExtension;
- this._untaint = untaint;
- }
-
- _Action(ClassLoader parent, Integer scriptingEngine, String engineExtension) {
- _parent = parent;
- _scriptingEngine = scriptingEngine;
- _engineExtension = engineExtension;
- _untaint = null;
- }
-
- public ThrowawayClassloader run() {
- if (_untaint != null)
- return new ThrowawayClassloader(_parent, _scriptingEngine, _engineExtension, _untaint);
- else
- return new ThrowawayClassloader(_parent, _scriptingEngine, _engineExtension);
- }
- }
-
- RecompiledClassLoader() {
- }
-
-
- public RecompiledClassLoader(final ClassLoader classLoader, final int scriptingEngine, final String engineExtension) {
- super(classLoader);
- _scriptingEngine = scriptingEngine;
- _engineExtension = engineExtension;
- try {
- _throwAwayLoader = AccessController.doPrivileged(new _Action(classLoader, scriptingEngine, engineExtension));
- } catch (PrivilegedActionException e) {
- logSevere(e);
- }
- }
-
- public RecompiledClassLoader(ClassLoader classLoader, final int scriptingEngine, final String engineExtension, final boolean untaint) {
- this(classLoader, scriptingEngine, engineExtension);
- _unTaintClasses = untaint;
- final ClassLoader _parent = getParent();
- try {
- _throwAwayLoader = AccessController.doPrivileged(
- new _Action(_parent, scriptingEngine, engineExtension, untaint)
- );
- } catch (PrivilegedActionException e) {
- logSevere(e);
- }
- }
-
- private void logSevere(PrivilegedActionException e) {
- Logger _logger = Logger.getLogger(this.getClass().getName());
- _logger.log(Level.SEVERE, "", e);
- }
-
-
- public InputStream getResourceAsStream(String name) {
- return _throwAwayLoader.getResourceAsStream(name);
- }
-
- @Override
- public Class<?> loadClass(String className) throws ClassNotFoundException {
- //check if our class exists in the tempDir
- final ClassLoader _parent = getParent();
-
- ClassResource resource = WeavingContext.getFileChangedDaemon().getClassMap().get(className);
-
- //preemptive check if the resource either is not loaded or requires a refresh
- //if yes we generated a new classloader to load the class anew
- if(resource == null || resource.getAClass() == null || resource.isRecompiled()) {
- return _loadClass(className, _parent);
- }
- return resource.getAClass();
- }
-
- private Class<?> _loadClass(String className, ClassLoader _parent) throws ClassNotFoundException {
- try {
- _throwAwayLoader = AccessController.doPrivileged(
- new _Action(_parent, _scriptingEngine, _engineExtension, _unTaintClasses)
- );
- return _throwAwayLoader.loadClass(className);
- } catch (PrivilegedActionException e) {
- logSevere(e);
- return null;
- }
- }
-
-
- protected Class<?> findClass(String name) throws ClassNotFoundException {
- return _throwAwayLoader.findClassExposed(name);
- }
-
- @SuppressWarnings("unused")
- public String getSourceRoot() {
- return _sourceRoot;
- }
-
- public void setSourceRoot(String sourceRoot) {
- this._sourceRoot = sourceRoot;
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/ScannerClassloader.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/ScannerClassloader.java
deleted file mode 100644
index 0f389f6..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/ScannerClassloader.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.loaders.java;
-
-import org.apache.myfaces.extensions.scripting.core.util.ClassUtils;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.monitor.ClassResource;
-import org.apache.myfaces.extensions.scripting.monitor.RefreshAttribute;
-import org.apache.myfaces.extensions.scripting.monitor.RefreshContext;
-
-import java.io.*;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * A specialized non tainting classloader for our scanners
- */
-@SuppressWarnings("unused")
-public class ScannerClassloader extends ClassLoader {
-
- File _tempDir = null;
-
- Map<String, Class> _alreadyScanned = new HashMap<String, Class>();
-
- final Logger _logger = Logger.getLogger(ScannerClassloader.class.getName());
-
-
- public ScannerClassloader(ClassLoader classLoader, int scriptingEngine, String engineExtension, File tempDir) {
- super(classLoader);
-
- this._tempDir = tempDir;
- }
-
- @Override
- public InputStream getResourceAsStream(String name) {
- File resource = new File(_tempDir.getAbsolutePath() + File.separator + name);
- if (resource.exists()) {
- try {
- return new FileInputStream(resource);
- } catch (FileNotFoundException e) {
- return super.getResourceAsStream(name);
- }
- }
- return super.getResourceAsStream(name);
- }
-
- public File getClassFile(String className) {
- return ClassUtils.classNameToFile(_tempDir.getAbsolutePath(), className);
- }
-
- @Override
- public Class<?> loadClass(String className) throws ClassNotFoundException {
- //check if our class exists in the tempDir
-
- if (_alreadyScanned.containsKey(className)) {
- return _alreadyScanned.get(className);
- }
-
- File target = getClassFile(className);
- if (!target.exists()) {
- return super.loadClass(className);
- }
-
- ClassResource data = WeavingContext.getFileChangedDaemon().getClassMap().get(className);
- if (data != null && !data.getRefreshAttribute().requiresRefresh()) {
- return data.getAClass();
- }
-
- FileInputStream iStream = null;
-
- int fileLength;
- byte[] fileContent;
- try {
- //we cannot load while a compile is in progress
- //we have to wait until it is one
- synchronized (RefreshContext.COMPILE_SYNC_MONITOR) {
- fileLength = (int) target.length();
- fileContent = new byte[fileLength];
- iStream = new FileInputStream(target);
- int len = iStream.read(fileContent);
- if (_logger.isLoggable(Level.FINER)) {
- _logger.log(Level.FINER, "class read {0}� bytes read", String.valueOf(len));
- }
- }
-
- //we have to do it here because just in case
- //a dependent class is loaded as well we run into classcast exceptions
- Class retVal = super.defineClass(className, fileContent, 0, fileLength);
- _alreadyScanned.put(className, retVal);
- return retVal;
-
- } catch (FileNotFoundException e) {
- throw new ClassNotFoundException(e.toString());
- } catch (IOException e) {
- throw new ClassNotFoundException(e.toString());
- } finally {
- if (iStream != null) {
- try {
- iStream.close();
- } catch (Exception e) {
- _logger.log(Level.SEVERE, "", e);
- }
- }
- }
-
- }
-
-}
-
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/ThrowawayClassloader.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/ThrowawayClassloader.java
deleted file mode 100644
index ff91b39..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/ThrowawayClassloader.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.loaders.java;
-
-import org.apache.myfaces.extensions.scripting.core.util.ClassUtils;
-import org.apache.myfaces.extensions.scripting.core.util.FileUtils;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.monitor.ClassResource;
-import org.apache.myfaces.extensions.scripting.monitor.RefreshAttribute;
-import org.apache.myfaces.extensions.scripting.monitor.RefreshContext;
-
-import java.io.*;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collection;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import static java.util.logging.Level.*;
-
-/**
- * we move the throw away mechanism into our classloader for cleaner code coverage
- * the idea is to throw away classloaders on demand if a class is reloaded
- * we throw it away at two stages
- * <p/>
- * first at call stage from outside if we manually load a class
- * and secondly internally if a class is reloaded by the system
- * or if something calls loadClass directly
- */
-@JavaThrowAwayClassloader
-@SuppressWarnings("unused")
-public class ThrowawayClassloader extends ClassLoader {
-
- static final Logger _logger = Logger.getLogger(ThrowawayClassloader.class.getName());
-
- int _scriptingEngine;
- String _engineExtension;
-
- public ThrowawayClassloader(ClassLoader classLoader, int scriptingEngine, String engineExtension) {
- super(classLoader);
-
- synchronized (this.getClass()) {
- _scriptingEngine = scriptingEngine;
- _engineExtension = engineExtension;
- }
- }
-
- public ThrowawayClassloader(ClassLoader classLoader, int scriptingEngine, String engineExtension, boolean untaint) {
- this(classLoader, scriptingEngine, engineExtension);
-
- }
-
- ThrowawayClassloader() {
- }
-
-
- @Override
- public InputStream getResourceAsStream(String name) {
- File resource = new File(WeavingContext.getConfiguration().getCompileTarget().getAbsolutePath() + File.separator + name);
- if (resource.exists()) {
- try {
- return new FileInputStream(resource);
- } catch (FileNotFoundException e) {
- return super.getResourceAsStream(name);
- }
- }
- return super.getResourceAsStream(name);
- }
-
- @Override
- /**
- * load called either if the class is not loaded at all
- * or if the class has been recompiled (check upfront)
- */
- public Class<?> loadClass(String className) throws ClassNotFoundException {
- //check if our class exists in the tempDir
- //we have to register ourselves temporarily because the trhow away classloader
- //can be called implicitely
-
-
- File target = WeavingContext.getConfiguration().resolveClassFile(className);
- if (target.exists()) {
-
- _logger.log(Level.FINE, "[EXT-SCRIPTING] target {0} exists", className);
-
- ClassResource data = WeavingContext.getFileChangedDaemon().getClassMap().get(className);
-
- //this check must be present because
- //the vm recycles old classloaders to load classes a anew
- //if we dont do it we get an exception
- //we cannot check here for the file timestamps because if we have import dependencies
- //it can happen that the compiler refreshes the forward dependend file as well
- //and then we reload the class in one file but reference it from an artifact
- //in another, it is better to check for the taint state instead
- if (data != null && !data.getRefreshAttribute().requiresRefresh()) {
-
- return data.getAClass();
- }
- //a load must happen anyway because the target was recompiled
- int fileLength;
- byte[] fileContent;
- FileInputStream iStream = null;
- try {
- //we cannot load while a compile is in progress
- //we have to wait until it is one
- synchronized (RefreshContext.COMPILE_SYNC_MONITOR) {
- fileLength = (int) target.length();
- fileContent = new byte[fileLength];
- iStream = new FileInputStream(target);
- int result = iStream.read(fileContent);
- _logger.log(Level.FINER, "read {0} bytes", String.valueOf(result));
- }
-
- } catch (FileNotFoundException e) {
- throw new ClassNotFoundException(e.toString());
- } catch (IOException e) {
- throw new ClassNotFoundException(e.toString());
- } finally {
- if (iStream != null) {
- try {
- iStream.close();
- } catch (Exception e) {
- Logger log = Logger.getLogger(this.getClass().getName());
- log.log(SEVERE, "", e);
- }
- }
- }
-
-
- if (data != null) {
- File sourceFile = data.getFile();
-
- _logger.log(Level.FINER, "[EXT-SCRIPTING] loading class {0} from filesystem", className);
-
- Class retVal;
-
- //sometimes the classloader is recycled between requests due to being bound to the old class, we have to open a new classloader here just for the sake
- //to avoid conflicts
- retVal = (new ThrowawayClassloader(getParent(), _scriptingEngine, _engineExtension)).defineClass(className, fileContent, 0, fileLength);
- data.setAClass(retVal);
- data.getRefreshAttribute().executedRefresh();
- data.executeLastLoaded();
- return retVal;
-
- } else {
- //we store the initial reloading meta data information so that it is refreshed
- //later on, this we we cover dependent classes on the initial load
- return storeReloadableDefinitions(className, fileLength, fileContent);
- }
- }
- _logger.log(Level.FINER, "[EXT-SCRIPTING] target {0} does not exist", target.getAbsolutePath());
- return super.loadClass(className);
- }
-
-
-
- private Class<?> storeReloadableDefinitions(String className, int fileLength, byte[] fileContent) {
- Class retVal;
- retVal = super.defineClass(className, fileContent, 0, fileLength);
- ClassResource reloadingMetaData = new ClassResource();
- reloadingMetaData.setAClass(retVal);
- //find the source for the given class and then
- //store the filename
- String separator = FileUtils.getFileSeparatorForRegex();
- String fileName = className.replaceAll("\\.", separator);
- fileName = (fileName.indexOf("$") != -1) ? fileName.substring(0, fileName.indexOf("$")) : fileName;
-
- fileName = fileName.replaceAll("\\.", separator) + getStandardFileExtension();
- Collection<String> sourceDirs = WeavingContext.getConfiguration().getSourceDirs(_scriptingEngine);
- String rootDir = null;
- File sourceFile = null;
- for (String sourceDir : sourceDirs) {
- String fullPath = sourceDir + File.separator + fileName;
- sourceFile = new File(fullPath);
- if (sourceFile.exists()) {
- rootDir = sourceDir;
- break;
- }
- }
-
- if (rootDir == null) {
- Logger log = Logger.getLogger(this.getClass().getName());
- log.log(WARNING, "Warning source for class: {0} could not be found", className);
- return retVal;
- }
-
- reloadingMetaData.setFile(new File(rootDir + File.separator + fileName));
- reloadingMetaData.getRefreshAttribute().requestRefresh();
- reloadingMetaData.getRefreshAttribute().executedRefresh();
-
- reloadingMetaData.setScriptingEngine(_scriptingEngine);
-
- WeavingContext.getFileChangedDaemon().getClassMap().put(className, reloadingMetaData);
- reloadingMetaData.executeLastLoaded();
- return retVal;
- }
-
- protected String getStandardFileExtension() {
- return _engineExtension;
- }
-
- protected Class<?> findClassExposed(String name) throws ClassNotFoundException {
- return super.findClass(name);
- }
-
- //some classloaders fail to resolve the resource properly, we have
- //to drag our local paths in to keep track of the compiled resources
- //for different scripting languages
-
- public URL getResource(String resource) {
- URL res = super.getResource(resource);
- if (res != null) return res;
- //if we do get a null value we try to remap to our custom paths
- if (!resource.endsWith(".class")) return null;
- resource = resource.substring(0, resource.length() - 6);
- resource = resource.replaceAll("\\/", ".");
-
- File clsFile = WeavingContext.getConfiguration().resolveClassFile(resource);
- if (!clsFile.exists()) return null;
- try {
- return clsFile.toURI().toURL();
- } catch (MalformedURLException e) {
- e.printStackTrace();
- return null;
- }
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/compiler/CompilerFacade.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/compiler/CompilerFacade.java
deleted file mode 100644
index 4603a2a..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/compiler/CompilerFacade.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.loaders.java.compiler;
-
-import org.apache.myfaces.extensions.scripting.api.CompilationException;
-import org.apache.myfaces.extensions.scripting.api.CompilationResult;
-import org.apache.myfaces.extensions.scripting.api.DynamicCompiler;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.ClassUtils;
-import org.apache.myfaces.extensions.scripting.core.util.FileUtils;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.loaders.java.RecompiledClassLoader;
-
-import java.io.File;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * Custom compiler call for jdk5
- * we can call javac directly
- */
-@SuppressWarnings("unused")
-public class CompilerFacade implements DynamicCompiler {
- protected org.apache.myfaces.extensions.scripting.api.Compiler _compiler = null;
-
- Logger _log = Logger.getLogger(this.getClass().getName());
-
- static final PrivilegedExceptionAction<RecompiledClassLoader> CLASSLOADER_ACTION = new PrivilegedExceptionAction<RecompiledClassLoader>() {
- public RecompiledClassLoader run() {
- return new RecompiledClassLoader(ClassUtils.getContextClassLoader(), ScriptingConst.ENGINE_TYPE_JSF_JAVA, ".java");
-
- }
- };
-
- public CompilerFacade() {
- super();
-
- _compiler = JavaCompilerFactory.getInstance().getCompilerInstance();
- }
-
- public CompilerFacade(boolean allowJSR) {
- super();
-
- _compiler = JavaCompilerFactory.getInstance().getCompilerInstance(allowJSR);
- }
-
- /**
- * does a compilation of all files one compile per request
- * is allowed for performance reasons, the request blocking will be done
- * probably on the caller side of things
- *
- * @param sourceRoot the source root of our files to be compiled
- * @param classPath the corresponding classpath
- */
-
- public void compileAll(String sourceRoot, String classPath) {
- try {
- //TODO do a full compile and block the compile for the rest of the request
- //so that we do not run into endless compile cycles
-
- /*
- * privilege block to allow custom classloading only
- * in case of having the privileges,
- * this was proposed by the checkstyle plugin
- */
- RecompiledClassLoader classLoader = getRecompiledClassLoader();
-
- classLoader.setSourceRoot(sourceRoot);
- CompilationResult result = _compiler.compile(new File(sourceRoot), WeavingContext.getConfiguration().getCompileTarget(), classLoader);
- displayMessages(result);
- if (result.hasErrors()) {
- _log.log(Level.WARNING, "Compiler output:{0}", result.getCompilerOutput());
- }
-
- } catch (org.apache.myfaces.extensions.scripting.api.CompilationException e) {
- _log.log(Level.SEVERE, "CompilationException : ", e);
- }
- }
-
- private RecompiledClassLoader getRecompiledClassLoader() {
- try {
- return AccessController.doPrivileged(CLASSLOADER_ACTION);
- } catch (PrivilegedActionException e) {
- _log.log(Level.SEVERE, "", e);
- }
- return null;
- }
-
-
- public File compileFile(String sourceRoot, String classPath, String filePath) {
- try {
- //TODO do a full compile and block the compile for the rest of the request
- //so that we do not run into endless compile cycles
-
- /*
- * privilege block to allow custom classloading only
- * in case of having the privileges,
- * this was proposed by the checkstyle plugin
- */
- RecompiledClassLoader classLoader = getRecompiledClassLoader();
-
- classLoader.setSourceRoot(sourceRoot);
- CompilationResult result = _compiler.compile(new File(sourceRoot), WeavingContext.getConfiguration().getCompileTarget(), new File(sourceRoot+ File.separator+ filePath), classLoader);
- displayMessages(result);
- if (result.hasErrors()) {
- _log.log(Level.WARNING, "Compiler output:{0}", result.getCompilerOutput());
- }
-
- return new File(WeavingContext.getConfiguration().getCompileTarget()+File.separator+ filePath.substring(0, filePath.lastIndexOf('.'))+".class" );
- } catch (org.apache.myfaces.extensions.scripting.api.CompilationException e) {
- _log.log(Level.SEVERE, "CompilationException : ", e);
- }
- return null;
- }
-
- public Class loadClass(String sourceRoot, String classPath, String filePath) throws ClassNotFoundException {
-
- String separator = FileUtils.getFileSeparatorForRegex();
- String className = filePath.replaceAll(separator, ".");
- className = ClassUtils.relativeFileToClassName(className);
- RecompiledClassLoader classLoader = getRecompiledClassLoader();
-
- ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
- try
-
- {
- classLoader.setSourceRoot(sourceRoot);
- Thread.currentThread().setContextClassLoader(classLoader);
-
- return classLoader.loadClass(className);
- }
-
- finally
-
- {
- Thread.currentThread().setContextClassLoader(oldClassLoader);
- }
-
- }
-
- /**
- * compiles all files
- *
- * @param sourceRoot the source root
- * @param classPath the class path
- * @return the root target path for the classes which are compiled
- * so that they later can be picked up by the classloader
- * @throws ClassNotFoundException
- */
-
- public File compileAllFiles(String sourceRoot, String classPath) throws ClassNotFoundException {
- try {
- RecompiledClassLoader classLoader = getRecompiledClassLoader();
-
- CompilationResult result = _compiler.compile(new File(sourceRoot), WeavingContext.getConfiguration().getCompileTarget(), classLoader);
-
- classLoader.setSourceRoot(sourceRoot);
- displayMessages(result);
- return WeavingContext.getConfiguration().getCompileTarget();
- } catch (CompilationException e) {
- _log.log(Level.SEVERE, "CompilationException :", e);
- }
- return null;
- }
-
- private void displayMessages(CompilationResult result) {
- for (CompilationResult.CompilationMessage error : result.getErrors()) {
- _log.log(Level.WARNING, "[EXT-SCRIPTING] Compile Error: {0} - {1}", new String[]{Long.toString(error.getLineNumber()), error.getMessage()});
-
- }
- for (CompilationResult.CompilationMessage error : result.getWarnings()) {
- _log.warning(error.getMessage());
- }
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/compiler/JavaCompilerFactory.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/compiler/JavaCompilerFactory.java
deleted file mode 100644
index 3b2bfb2..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/compiler/JavaCompilerFactory.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.loaders.java.compiler;
-
-import org.apache.myfaces.extensions.scripting.api.*;
-import org.apache.myfaces.extensions.scripting.api.Compiler;
-import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
-
-/**
- *
- */
-public class JavaCompilerFactory {
- /**
- * since the object is stateless
- * declaring it volatile should be enough instead
- * of using synchronized blocks
- * please if you introduce statefulness here
- * we have to add synchronized
- */
- private static volatile JavaCompilerFactory _instance = new JavaCompilerFactory();
-
- public static JavaCompilerFactory getInstance() {
- if (_instance == null) {
- _instance = new JavaCompilerFactory();
- }
- return _instance;
- }
-
- private String getScriptingFacadeClass(boolean allowJSR) {
- String javaVer = System.getProperty("java.version");
- String[] versionArr = javaVer.split("\\.");
-
- int major = Integer.parseInt(versionArr[Math.min(versionArr.length, 1)]);
-
- if (major > 5 && allowJSR) {
- //jsr199 compliant jdk
- return ScriptingConst.JSR199_COMPILER;
- }
- //otherwise
- return ScriptingConst.JAVA5_COMPILER;
- }
-
- public org.apache.myfaces.extensions.scripting.api.Compiler getCompilerInstance() {
- return (Compiler) ReflectUtil.instantiate(getScriptingFacadeClass(true));
- }
-
- public org.apache.myfaces.extensions.scripting.api.Compiler getCompilerInstance(boolean allowJSR) {
- return (Compiler) ReflectUtil.instantiate(getScriptingFacadeClass(allowJSR));
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/compiler/JavacCompiler.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/compiler/JavacCompiler.java
deleted file mode 100644
index 1daf3ef..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/loaders/java/compiler/JavacCompiler.java
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.loaders.java.compiler;
-
-import org.apache.myfaces.extensions.scripting.api.CompilationException;
-import org.apache.myfaces.extensions.scripting.api.CompilationResult;
-import org.apache.myfaces.extensions.scripting.api.CompilerConst;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.ClassLoaderUtils;
-import org.apache.myfaces.extensions.scripting.core.util.ClassUtils;
-import org.apache.myfaces.extensions.scripting.core.util.FileUtils;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-import java.io.File;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * <p>A compiler implementation that utilizes some internal classes that enable you to
- * compile Java source code using the javac compiler being provided by your JDK. However,
- * note that this only works if you're using a Sun JDK up to the version 1.5 (as of Java 6
- * you should use the JSR-199 API).</p>
- * <p/>
- * <p>This class loads some internal classes from $JAVA_HOME$/lib/tools.jar so be sure to
- * either include this JAR file in your classpath at startup or set the JAVA_HOME property
- * accordingly so that it points to a valid JDK home directory (it doesn't work if you're
- * just using a JRE!)</p>
- */
-public class JavacCompiler implements org.apache.myfaces.extensions.scripting.api.Compiler {
-
- /**
- * The logger instance for this class.
- */
- private static final Logger _logger = Logger.getLogger(JavacCompiler.class.getName());
-
- /**
- * The class name of the javac compiler. Note that this class
- * is only available if you're using a Sun JDK.
- */
- private static final String JAVAC_MAIN = "com.sun.tools.javac.Main";
-
- /**
- * The class reference to the internal Javac compiler.
- */
- private Class _compilerClass;
-
- // ------------------------------------------ Constructors
-
- /**
- * <p>Creates a new Javac compiler by searching for the required JAR file '$JAVA_HOME$/lib/tools.jar'
- * automatically. Note that the user has to specify the JAVA_HOME property in this case.</p>
- */
- public JavacCompiler() {
- this(null);
- }
-
- /**
- * <p>Creates a new Javac compiler by searching for internal classes in the given JAR file.</p>
- *
- * @param toolsJar the location of the JAR file '$JAVA_HOME$/lib/tools.jar' or <code>null</code>
- * if you want it to be searched for automatically
- */
- public JavacCompiler(URL toolsJar) {
- ClassLoader classLoader;
-
- try {
- classLoader = createJavacAwareClassLoader(toolsJar);
- } catch (MalformedURLException ex) {
- throw new IllegalStateException("An error occured while trying to load the Javac compiler class.", ex);
- }
-
- try {
- this._compilerClass = classLoader.loadClass(JAVAC_MAIN);
- } catch (ClassNotFoundException ex) {
- throw new IllegalStateException("The Javac compiler class '" + JAVAC_MAIN + "' couldn't be found even though" +
- "the required JAR file '$JAVA_HOME$/lib/tools.jar' has been put on the classpath. Are you sure that " +
- "you're using a valid Sun JDK?");
- }
- }
-
- // ------------------------------------------ Compiler methods
-
- /**
- * <p>Compiles the given file and creates an according class file in the given target path.</p>
- *
- * @param sourcePath the path to the source directory
- * @param targetPath the path to the target directory
- * @return the compilation result, i.e. as of now only the compiler output
- */
- public CompilationResult compile(File sourcePath, File targetPath, ClassLoader loader) throws CompilationException {
- FileUtils.assertPath(targetPath);
-
- try {
- StringWriter compilerOutput = new StringWriter();
- // Invoke the Javac compiler
- Method compile = _compilerClass.getMethod("compile", new Class[]{String[].class, PrintWriter.class});
- Object[] compilerArguments = new Object[]{buildCompilerArgumentsWhitelisted(sourcePath, targetPath, loader), new PrintWriter(compilerOutput)};
- logCommandLine(compilerArguments);
-
- Integer returnCode = (Integer) compile.invoke(null, compilerArguments);
-
- CompilationResult result = new CompilationResult(compilerOutput.toString());
- if (returnCode == null || returnCode.intValue() != 0) {
- result.registerError(new CompilationResult.CompilationMessage(-1,
- "Executing the javac compiler failed. The return code is '" + returnCode + "'." + compilerOutput.toString()));
- }
- WeavingContext.setCompilationResult(ScriptingConst.ENGINE_TYPE_JSF_JAVA, result);
- return result;
- } catch (NoSuchMethodException ex) {
- throw new CompilationException("The Javac compiler class '" + _compilerClass + "' doesn't provide the method " +
- "compile(String, PrintWriter). Are you sure that you're using a valid Sun JDK?", ex);
- } catch (InvocationTargetException ex) {
- throw new CompilationException("An error occured while invoking the compile(String, PrintWriter) method of the " +
- "Javac compiler class '" + _compilerClass + "'. Are you sure that you're using a valid Sun JDK?", ex);
- } catch (IllegalAccessException ex) {
- throw new CompilationException("An error occured while invoking the compile(String, PrintWriter) method of the " +
- "Javac compiler class '" + _compilerClass + "'. Are you sure that you're using a valid Sun JDK?", ex);
- }
-
- }
-
- /**
- * <p>Compiles the given file and creates an according class file in the given target path.</p>
- *
- * @param sourcePath the path to the source directory
- * @param targetPath the path to the target directory
- * @param file the relative file name of the class you want to compile
- * @return the compilation result, i.e. as of now only the compiler output
- */
- public CompilationResult compile(File sourcePath, File targetPath, File file, ClassLoader loader) throws CompilationException {
- // The destination directory must already exist as javac will not create the destination directory.
- FileUtils.assertPath(targetPath);
-
- try {
- StringWriter compilerOutput = new StringWriter();
-
- // Invoke the Javac compiler
- Method compile = _compilerClass.getMethod("compile", new Class[]{String[].class, PrintWriter.class});
- if (!targetPath.exists()) {
- if (!targetPath.mkdirs()) {
- throw new IllegalStateException("It wasn't possible to create the target " +
- "directory for the compiler ['" + targetPath.getAbsolutePath() + "'].");
- }
- }
-
- //TODO make a whitelist check here
- Object[] compilerArguments = new Object[]{buildCompilerArguments(sourcePath, targetPath, file.getAbsolutePath(), loader), new PrintWriter(compilerOutput)};
- logCommandLine(compilerArguments);
-
- Integer returnCode = (Integer) compile.invoke(null,
- compilerArguments);
-
- CompilationResult result = new CompilationResult(compilerOutput.toString());
- if (returnCode == null || returnCode != 0) {
- result.registerError(new CompilationResult.CompilationMessage(-1,
- "Executing the javac compiler failed. The return code is '" + returnCode + "'." + compilerOutput.toString()));
- }
- WeavingContext.setCompilationResult(ScriptingConst.ENGINE_TYPE_JSF_JAVA, result);
- return result;
- } catch (NoSuchMethodException ex) {
- throw new IllegalStateException("The Javac compiler class '" + _compilerClass + "' doesn't provide the method " +
- "compile(String, PrintWriter). Are you sure that you're using a valid Sun JDK?", ex);
- } catch (InvocationTargetException ex) {
- throw new IllegalStateException("An error occured while invoking the compile(String, PrintWriter) method of the " +
- "Javac compiler class '" + _compilerClass + "'. Are you sure that you're using a valid Sun JDK?", ex);
- } catch (IllegalAccessException ex) {
- throw new IllegalStateException("An error occured while invoking the compile(String, PrintWriter) method of the " +
- "Javac compiler class '" + _compilerClass + "'. Are you sure that you're using a valid Sun JDK?", ex);
- }
- }
-
- private void logCommandLine(Object[] compilerArguments) {
- if (_logger.isLoggable(Level.FINE)) {
- StringBuilder commandLine = new StringBuilder();
- commandLine.append("javac ");
- for (String compilerArgument : (String[]) compilerArguments[0]) {
- commandLine.append(compilerArgument);
- commandLine.append(" ");
- }
- _logger.log(Level.FINE, commandLine.toString());
- }
- if (_logger.isLoggable(Level.INFO)) {
- _logger.info("[EXT-SCRIPTING] compiling java");
- }
-
- }
-
- // ------------------------------------------ Utility methods
-
- /**
- * <p/>
- * Creates the arguments for the compiler, i.e. builds up an array of arguments
- * that one would pass to the javac compiler to compile a full path instead of a single file
- *
- * @param sourcePath the path to the source directory
- * @param targetPath the path to the target directory
- * @return an array of arguments that you have to pass to the Javac compiler
- */
- protected String[] buildCompilerArgumentsWhitelisted(File sourcePath, File targetPath, ClassLoader loader) {
- List<File> sourceFiles = FileUtils.fetchSourceFiles(WeavingContext.getConfiguration().getWhitelistedSourceDirs(ScriptingConst.ENGINE_TYPE_JSF_JAVA), "*.java");
-
- List arguments = getDefaultArguments(sourcePath, targetPath, loader);
-
- // Append the source file that is to be compiled. Note that the user specifies only a relative file location.
- for (File sourceFile : sourceFiles) {
- arguments.add(sourceFile.getAbsolutePath());
- }
- return (String[]) argumentsToArray(arguments);
- }
-
- private Object[] argumentsToArray(List arguments) {
- return arguments.toArray(new String[arguments.size()]);
- }
-
- /**
- * <p/>
- * Creates the arguments for the compiler, i.e. builds up an array of arguments
- * that one would pass to the javac compiler to compile a full path instead of a single file
- *
- * @param sourcePath the path to the source directory
- * @param targetPath the path to the target directory
- * @return an array of arguments that you have to pass to the Javac compiler
- */
- protected String[] buildCompilerArguments(File sourcePath, File targetPath, ClassLoader loader) {
- List<File> sourceFiles = FileUtils.fetchSourceFiles(sourcePath, "*.java");
-
- List arguments = getDefaultArguments(sourcePath, targetPath, loader);
-
- // Append the source file that is to be compiled. Note that the user specifies only a relative file location.
- for (File sourceFile : sourceFiles) {
- arguments.add(sourceFile.getAbsolutePath());
- }
- return (String[]) argumentsToArray(arguments);
- }
-
- /**
- * <p>Creates the arguments for the compiler, i.e. it builds an array of arguments that one would pass to
- * the Javac compiler on the command line.</p>
- *
- * @param sourcePath the path to the source directory
- * @param targetPath the path to the target directory
- * @param loader the classpath holder for the compiler
- * @param file the relative file name of the class you want to compile
- * @return an array of arguments that you have to pass to the Javac compiler
- */
- protected String[] buildCompilerArguments(File sourcePath, File targetPath, String file, ClassLoader loader) {
- List arguments = getDefaultArguments(sourcePath, targetPath, loader);
-
- // Append the source file that is to be compiled. Note that the user specifies only a relative file location.
- arguments.add(new File(sourcePath, file).getAbsolutePath());
-
- return (String[]) argumentsToArray(arguments);
- }
-
- /**
- * <p>
- * Determination of the default arguments
- * which have to be the same over all
- * different compilation strategies
- * </p>
- *
- * @param sourcePath the path to the source directory
- * @param targetPath the path to the target directory
- * @param loader the classloader holding the classpath
- * @return
- */
- private List getDefaultArguments(File sourcePath, File targetPath, ClassLoader loader) {
- List arguments = new ArrayList();
-
- // Set both the source code path to search for class or interface
- // definitions and the destination directory for class files.
- arguments.add(CompilerConst.JC_SOURCEPATH);
- arguments.add(sourcePath.getAbsolutePath());
- arguments.add(CompilerConst.JC_TARGET_PATH);
- arguments.add(targetPath.getAbsolutePath());
- arguments.add(CompilerConst.JC_CLASSPATH);
- arguments.add(ClassLoaderUtils.buildClasspath(loader));
-
- // Enable verbose output.
- arguments.add(CompilerConst.JC_VERBOSE);
-
- // Generate all debugging information, including local variables.
- arguments.add(CompilerConst.JC_DEBUG);
- return arguments;
- }
-
- /**
- * <p>Returns a possibly newly created classloader that you can use in order to load the
- * Javac compiler class. Usually the user would have to put the JAR file
- * '$JAVA_HOME$/lib/tools.jar' on the classpath but this method recognizes this on its own
- * and loads the JAR file if necessary. However, it's not guaranteed that the Javac compiler
- * class is available (e.g. if one is providing a wrong tools.jar file that doesn't contain
- * the required classes).</p>
- *
- * @param toolsJar the location of the JAR file '$JAVA_HOME$/lib/tools.jar' or <code>null</code>
- * if you want it to be searched for automatically
- * @return a classloader that you can use in order to load the Javac compiler class
- * @throws MalformedURLException if an error occurred while constructing the URL
- */
- private static ClassLoader createJavacAwareClassLoader(URL toolsJar) throws MalformedURLException {
- // If the user has already included the tools.jar in the classpath we don't have
- // to create a custom class loader as the class is already available.
- if (ClassUtils.isPresent(JAVAC_MAIN)) {
- if (_logger.isLoggable(Level.FINE)) {
- _logger.log(Level.FINE, "Seemingly the required JAR file '$JAVA_HOME$/lib/tools.jar' has already been "
- + "put on the classpath as the class '" + JAVAC_MAIN + "' is present. So there's no "
- + "need to create a custom classloader for the Javac compiler.");
- }
-
- return ClassUtils.getContextClassLoader();
- } else {
- // The compiler isn't available in the current classpath, but the user could have specified the tools.jar file.
- if (toolsJar == null) {
- String javaHome = System.getProperty("java.home");
- if (javaHome.toLowerCase(Locale.getDefault()).endsWith(File.separator + "jre")) {
- // Note that even if the user has installed a valid JDK the $JAVA_HOME$ property might reference
- // the JRE, e.g. '/usr/lib/jvm/java-6-sun-1.6.0.16/jre'. However, in this case we just have to
- // remove the last four characters (i.e. the '/jre').
- javaHome = javaHome.substring(0, javaHome.length() - 4);
- }
-
- // If the user hasn't specified the URL to the tools.jar file, we'll try to find it on our own.
- File toolsJarFile = new File(javaHome, "lib" + File.separatorChar + "tools.jar");
- if (toolsJarFile.exists()) {
- if (_logger.isLoggable(Level.FINE)) {
- _logger.log(Level.FINE,
- "The required JAR file '$JAVA_HOME$/lib/tools.jar' has been found ['" + toolsJarFile.getAbsolutePath()
- + "']. A custom URL classloader will be created for the Javac compiler.");
- }
-
- return new URLClassLoader(
- new URL[]{toolsJarFile.toURI().toURL()}, ClassUtils.getContextClassLoader());
- } else {
- throw new IllegalStateException("The Javac compiler class '" + JAVAC_MAIN + "' and the required JAR file " +
- "'$JAVA_HOME$/lib/tools.jar' couldn't be found. Are you sure that you're using a valid Sun JDK? " +
- "[$JAVA_HOME$: '" + System.getProperty("java.home") + "']");
- }
- } else {
- if (_logger.isLoggable(Level.FINE)) {
- _logger.log(Level.FINE, "The user has specified the required JAR file '$JAVA_HOME$/lib/tools.jar' ['"
- + toolsJar.toExternalForm() + "']. A custom URL classloader will be created for the Javac compiler.");
- }
-
- return new URLClassLoader(new URL[]{toolsJar}, ClassUtils.getContextClassLoader());
- }
- }
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/monitor/ClassResource.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/monitor/ClassResource.java
deleted file mode 100644
index 90ace82..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/monitor/ClassResource.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.monitor;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.logging.Logger;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ClassResource extends WatchedResource {
- /*
- * volatile due to the ram concurrency behavior
- * of the instance vars jdk 5+
- */
-
- //TODO we probably can drop the file definitions
- //the class has all meta data internally via findResource
- //on its corresponding classloader
- //caching the info however probably is faster
- volatile Class _aClass = null;
- volatile File _sourceFile;
- volatile long _lastLoaded = -1L;
- volatile int _scriptingEngine = ScriptingConst.ENGINE_TYPE_JSF_NO_ENGINE;
-
- //todo clean up the sourcepath and filename
-
- //--- todo move this into a separate resource handling facility
-
- @Override
- public String identifier() {
- return _aClass.getName();
- }
-
- @Override
- /**
- * returns the source file in this case
- */
- public File getFile() {
- try {
- return _sourceFile;
- } catch (NullPointerException ex) {
- return null;
- }
- }
-
- public void setFile(File sourceFile) {
- _sourceFile = sourceFile;
- }
-
- public Class getAClass() {
- return _aClass;
- }
-
- public void setAClass(Class aClass) {
- this._aClass = aClass;
- }
-
- public int getScriptingEngine() {
- return _scriptingEngine;
- }
-
- public void setScriptingEngine(int scriptingEngine) {
- this._scriptingEngine = scriptingEngine;
- }
-
-
- public void setRefreshAttribute(RefreshAttribute attr) {
- _refreshAttribute = attr;
- }
-
- @Override
- protected Object clone() throws CloneNotSupportedException {
- ClassResource retVal = (ClassResource) super.clone();
- retVal.setRefreshAttribute(_refreshAttribute.getClone());
- return retVal;
- }
-
-
- public String getSourceFile() {
- return _sourceFile.getAbsolutePath().substring(getSourceDir().length()+1);
- }
-
-
- public String getSourceDir() {
- Collection<String> sourceRoots = WeavingContext.getConfiguration().getSourceDirs(_scriptingEngine);
- String fileDir = _sourceFile.getAbsolutePath();
- fileDir = fileDir.replaceAll("\\\\","/");
- for(String sourceRoot: sourceRoots) {
- sourceRoot = sourceRoot.replaceAll("\\\\","/");
- if(fileDir.startsWith(sourceRoot)) {
- return sourceRoot;
- }
- }
- return null;
- }
-
- public void executeLastLoaded() {
- _lastLoaded = System.currentTimeMillis();
- }
-
- public long getLastLoaded() {
- return _lastLoaded;
- }
-
- /**
- *
- * @return true if the class file has been recompiled since the last request for recompilation
- */
- public boolean isRecompiled() {
- File classFile = WeavingContext.getConfiguration().resolveClassFile(_aClass.getName());
- if(!classFile.exists()) {
- return false;
- }
- Logger log = Logger.getLogger(this.getClass().getName());
- log.info(this.getAClass().getName() + (classFile.lastModified() - _lastLoaded));
-
-
- return classFile.lastModified() > _lastLoaded;
- }
-
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/monitor/RefreshAttribute.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/monitor/RefreshAttribute.java
deleted file mode 100644
index a92a28f..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/monitor/RefreshAttribute.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.monitor;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * data structure which holds the loaded data
- * for our taint thread
- *
- * @author Werner Punz
- */
-public class RefreshAttribute implements Cloneable {
-
- /**
- * <p>The timestamp in milliseconds of the last time that the bean
- * definition that this attribute belongs to has been requested to
- * refresh itself.</p>
- */
- private long refreshRequested;
-
- /**
- * <p>The timestamp in milliseconds of the last time that the bean
- * definition that this attribute belongs to has been actually
- * refreshed.</p>
- */
- private long refreshExecuted;
-
- /**
- * <p>By calling this method the user is able to request another refresh. Note that
- * this doesn't cause the bean factory to refresh the bean definition immediately,
- * but rather it just signals a request. The bean definition will be refreshed once
- * the bean factory has to deal with the next bean request (i.e. a call to
- * getBean()).</p>
- */
- public void requestRefresh() {
- refreshRequested = System.currentTimeMillis();
- }
-
- /**
- * <p>Returns the timestamp in milliseconds of the last time that a refresh operation
- * has been requested.</p>
- *
- * @return the timestamp in milliseconds of the last refresh request
- */
- public long getRequestedRefreshDate() {
- return refreshRequested;
- }
-
- /**
- * <p>By calling this method the user indicates that the according bean definition
- * has just been refreshed, which means that the method #{@link #requiresRefresh()}
- * will return <code>false</code> until the user requests the next refresh.</p>
- */
- public void executedRefresh() {
- refreshExecuted = System.currentTimeMillis();
- }
-
- /**
- * <p>Returns the timestamp in milliseconds of the last time that a refresh operation
- * has been executed.</p>
- *
- * @return the timestamp in milliseconds of the last executed refresh operation
- */
- public long getExecutedRefreshDate() {
- return refreshExecuted;
- }
-
- /**
- * <p>Determines whether a refresh is required, i.e. whether the user has requested
- * another refresh operation by calling {@link #requestRefresh()} recently. Note that
- * a call to this method only determines whether the bean definition on its own has
- * to be refreshed (i.e. it doesn't even consider a particular bean instance).</p>
- *
- * @return whether a refresh call is required
- */
- public boolean requiresRefresh() {
- return getExecutedRefreshDate() < getRequestedRefreshDate();
- }
-
-
-
- public RefreshAttribute getClone() {
- try {
- return (RefreshAttribute) clone();
- } catch (CloneNotSupportedException e) {
- Logger logger = Logger.getLogger(RefreshAttribute.class.getName());
- logger.log(Level.SEVERE, "", e);
- //cannot happen
- }
- return null;
- }
-}
\ No newline at end of file
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/monitor/RefreshContext.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/monitor/RefreshContext.java
deleted file mode 100644
index ae59f3d..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/monitor/RefreshContext.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.monitor;
-
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.api.DependencyRegistry;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.registry.MasterDependencyRegistry;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-import javax.faces.context.FacesContext;
-import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * <p/>
- * a context which holds information regarding the refresh cycle
- * which can be picked up by the request filter for refreshing strategies
- * <p/>
- * That way we can avoid a separate session filter and a push system
- * we use a pull system instead
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class RefreshContext {
- /**
- * this is a timed marker which is
- * a point in time the last bean refresh was issued
- * every request has to dump its personal scoped
- * (aka session, or custom) scoped beans
- * if the point in time is newer than the personal refresh time
- * application scoped beans are refreshed at the first refresh cycle
- * by the calling request issuing the compile
- */
- private volatile long _personalScopedBeanRefresh = -1L;
-
- /**
- * the bean synchronisation has to be dealt with
- * differently, we have two volatile points in the lifecycle
- * one being the compile the other one the bean refresh
- * the refresh can only happen outside of a compile cycle
- * and also a global refresh has to be atomic and no other
- * refreshes should happen
- */
- public final static Boolean BEAN_SYNC_MONITOR = new Boolean(true);
-
- /**
- * second synchronisation monitor
- * all other artifacts can only be refreshed outside of a
- * compile cycle otherwise the classloader would get
- * half finished compile states to load
- */
- public final static Boolean COMPILE_SYNC_MONITOR = new Boolean(true);
-
- private volatile AtomicInteger _currentlyRunningRequests = null;
-
- private MasterDependencyRegistry _dependencyRegistry = new MasterDependencyRegistry();
-
- /**
- * we keep a 10 minutes timeout period to keep the performance in place
- */
- private volatile long _taintLogTimeout = 10 * 60 * 1000;
-
- /**
- * This is a log which keeps track of the taints
- * over time, we need that mostly for bean refreshes
- * in multiuser surroundings, because only tainted beans need
- * to be refreshed.
- * Now if a user misses multiple updates he has to get a full
- * set of changed classes to be able to drop all personal scoped beans tainted
- * since the he refreshed last! Hence we have to move away from our
- * two dimensional <class, taint> to a three dimensional <class, taint, time>
- * view of things
- */
- private List<TaintingHistoryEntry> _taintLog = Collections.synchronizedList(new LinkedList<TaintingHistoryEntry>());
-
- /**
- * the daemon thread which marks the scripting classes
- * depending on the state, changed => tainted == true, not changed
- * tainted == false!
- */
- volatile ResourceMonitor _daemon = null;
-
- /**
- * internal class used by our own history log
- */
- static class TaintingHistoryEntry {
- long _timestamp;
- WatchedResource _data;
-
- public TaintingHistoryEntry(WatchedResource data) {
- _data = data.getClone();
- _timestamp = System.currentTimeMillis();
- }
-
- public long getTimestamp() {
- return _timestamp;
- }
-
- public WatchedResource getData() {
- return _data;
- }
- }
-
- /**
- * adds a new entry into our taint log
- * which allows us to access tainting data
- * from a given point in time
- *
- * @param data the tainting data to be added
- */
- public void addTaintLogEntry(WatchedResource data) {
- _taintLog.add(new TaintingHistoryEntry(data));
- }
-
- /**
- * garbage collects our tainting data
- * and removes all entries which are not
- * present anymore due to timeout
- * this gc code is called asynchronously
- * from our tainting thread to keep the
- * performance intact
- */
- public void gcTaintLog() {
- long timeoutTimestamp = System.currentTimeMillis() - _taintLogTimeout;
- Iterator<TaintingHistoryEntry> it = _taintLog.iterator();
-
- while (it.hasNext()) {
- TaintingHistoryEntry entry = it.next();
- if (entry.getTimestamp() < timeoutTimestamp) {
- it.remove();
- }
- }
- }
-
- /**
- * returns the last noOfEntries entries in the taint history
- *
- * @param noOfEntries the number of entries to be delivered
- * @return a collection of the last <noOfEntries> entries
- */
- public Collection<WatchedResource> getLastTainted(int noOfEntries) {
- Iterator<TaintingHistoryEntry> it = _taintLog.subList(Math.max(_taintLog.size() - noOfEntries, 0), _taintLog.size()).iterator();
- List<WatchedResource> retVal = new LinkedList<WatchedResource>();
- while (it.hasNext()) {
- TaintingHistoryEntry entry = it.next();
- retVal.add(entry.getData());
- }
- return retVal;
- }
-
- /**
- * Returns a set of tainting data from a given point in time up until now
- *
- * @param timestamp the point in time from which the tainting data has to be derived from
- * @return a set of entries which are a union of all points in time beginning from timestamp
- */
- public Collection<WatchedResource> getTaintHistory(long timestamp) {
- List<WatchedResource> retVal = new LinkedList<WatchedResource>();
- Iterator<TaintingHistoryEntry> it = _taintLog.iterator();
-
- while (it.hasNext()) {
- TaintingHistoryEntry entry = it.next();
- if (entry.getTimestamp() >= timestamp) {
- retVal.add(entry.getData());
- }
- }
- return retVal;
- }
-
- /**
- * Returns a set of tainted classes from a given point in time up until now
- *
- * @param timestamp the point in time from which the tainting data has to be derived from
- * @return a set of classnames which are a union of all points in time beginning from timestamp
- */
- public Set<String> getTaintHistoryClasses(long timestamp) {
- Set<String> retVal = new HashSet<String>();
- Iterator<TaintingHistoryEntry> it = _taintLog.iterator();
-
- while (it.hasNext()) {
- TaintingHistoryEntry entry = it.next();
- if (entry.getTimestamp() >= timestamp) {
- if(entry.getData() instanceof ClassResource) {
- retVal.add(((ClassResource)entry.getData()).getAClass().getName());
- } else {
- retVal.add(entry.getData().getFile().getAbsolutePath());
- }
- }
- }
- return retVal;
- }
-
- /**
- * returns the last global personal scoped bean refresh point in time
- *
- * @return a long value showing which personal bean refresh was the last in time
- */
- public long getPersonalScopedBeanRefresh() {
- return _personalScopedBeanRefresh;
- }
-
- /**
- * setter for the global personal scope bean refresh
- *
- * @param personalScopedBeanRefresh
- */
- public void setPersonalScopedBeanRefresh(long personalScopedBeanRefresh) {
- this._personalScopedBeanRefresh = personalScopedBeanRefresh;
- }
-
- /**
- * checks whether it would make sense at the current point
- * in time to enforce a recompile or not
- *
- * @param scriptingEngine
- * @return
- */
- public boolean isRecompileRecommended(int scriptingEngine) {
- Boolean recommended = _daemon.getSystemRecompileMap().get(scriptingEngine);
- return recommended == null || recommended.booleanValue();
- }
-
- public void setRecompileRecommended(int scriptingEngine, boolean recompileRecommended) {
- _daemon.getSystemRecompileMap().put(scriptingEngine, recompileRecommended);
- }
-
- public DependencyRegistry getDependencyRegistry(int scriptingEngine) {
- return _dependencyRegistry.getSubregistry(scriptingEngine);
- }
-
- public void setDependencyRegistry(int scriptingEngine, DependencyRegistry registry) {
- _dependencyRegistry.addSubregistry(scriptingEngine, registry);
- }
-
- public boolean isDependencyScanned(int scriptingEngine) {
- try {
- FacesContext ctx = FacesContext.getCurrentInstance();
- if (ctx == null) {
- return false;
- }
- Map<String, Object> requestMap = (Map<String, Object>) WeavingContext.getRequestMap();
- Boolean retVal = (Boolean) requestMap.get("isDependencyScanned_" + scriptingEngine);
- return (retVal == null) ? false : retVal;
- } catch (UnsupportedOperationException ex) {
- //still in startup
- return false;
- }
- }
-
- public void setDependencyScanned(int scriptingEngine, Boolean val) {
- try {
- FacesContext ctx = FacesContext.getCurrentInstance();
- if (ctx == null) {
- return;
- }
- Map<String, Object> requestMap = (Map<String, Object>) WeavingContext.getRequestMap();
- requestMap.put("isDependencyScanned_" + scriptingEngine, val);
- } catch (UnsupportedOperationException ex) {
- //still in startup
- }
- }
-
- public ResourceMonitor getDaemon() {
- return _daemon;
- }
-
- public void setDaemon(ResourceMonitor daemon) {
- this._daemon = daemon;
- }
-
- /**
- * @return true if a compile currently is in progress
- */
- public static boolean isCompileInProgress(int engineType) {
- //TODO implement this
- return false;
- }
-
- /**
- * returns whether a recompile now at the current point
- * in time for this engine is allowed or not
- * This state depends on the state of the application
- * if non locked compiles is enabled it always will return true
- * <p/>
- * if a synchronized locking compile is enabled
- * it will return true if the calling request is the only
- * one currently issued because no request is allowed to compile
- * until others have run out
- *
- * @param engineType
- * @return
- */
- public boolean isComileAllowed(int engineType) {
- return getCurrentlyRunningRequests().get() == 1;
- }
-
- /**
- * getter for our request counter
- * we need this variable to keep a lock
- * on the number of requests
- * we only can compile if the currently
- * running request is the only one currently
- * active, to keep the compilation results in sync
- *
- * @return the request counter holder which is an atomic integer
- * <p/>
- * probably deprecred
- */
- public AtomicInteger getCurrentlyRunningRequests() {
- return _currentlyRunningRequests;
- }
-
- /**
- * setter for our currently running requests
- *
- * @param currentlyRunning the number of currently running requests
- */
- public void setCurrentlyRunningRequests(AtomicInteger currentlyRunning) {
- _currentlyRunningRequests = currentlyRunning;
- }
-
- /**
- * checks outside of the request
- * scope for changes and taints
- * the corresponding engine
- */
- public static void scanAndMarkChange() {
- WeavingContext.getWeaver();
- }
-
- /**
- * Returns our dependency registry
- *
- * @return the Master Dependency registry holding all subregistries
- */
- public MasterDependencyRegistry getDependencyRegistry() {
- return _dependencyRegistry;
- }
-
- /**
- * Sets our master dependency registry
- *
- * @param dependencyRegistry the master dependency registry to be set
- */
- public void setDependencyRegistry(MasterDependencyRegistry dependencyRegistry) {
- _dependencyRegistry = dependencyRegistry;
- }
-
- /**
- * getter for the taintlog timeout
- *
- * @return the taintlog timeout
- */
- public long getTaintLogTimeout() {
- return _taintLogTimeout;
- }
-
- /**
- * setter for the taintlog timeout
- *
- * @param taintLogTimeout a new timeout for the taintlog
- */
- public void setTaintLogTimeout(long taintLogTimeout) {
- _taintLogTimeout = taintLogTimeout;
- }
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/monitor/ResourceMonitor.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/monitor/ResourceMonitor.java
deleted file mode 100644
index 8c90fb5..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/monitor/ResourceMonitor.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.monitor;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.core.ClassDependencies;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.api.extensionevents.ClassTaintedEvent;
-
-import javax.servlet.ServletContext;
-import java.io.File;
-import java.lang.ref.WeakReference;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Central daemon thread which watches the resources
- * for changes and marks them as changed.
- * This watchdog daemon is the central core
- * of the entire scripting engine it runs asynchronously
- * to your program and keeps an eye on the resources
- * and their dependencies, once a file has changed
- * all the referring dependencies are also marked
- * as being to reloaded.
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-public class ResourceMonitor extends Thread {
-
- private static final String CONTEXT_KEY = "extscriptDaemon";
-
- static ResourceMonitor _instance = null;
-
- Map<String, ClassResource> _classMap = new ConcurrentHashMap<String, ClassResource>(8, 0.75f, 1);
- ClassDependencies _dependencyMap = new ClassDependencies();
-
- /**
- * This map is a shortcut for the various scripting engines.
- * It keeps track whether the engines source paths
- * have dirty files or not and if true we enforce a recompile at the
- * next refresh!
- * <p/>
- * We keep track on engine level to avoid to search the classMap for every refresh
- * the classMap still is needed for various identification tasks which are reload
- * related
- */
- Map<Integer, Boolean> _systemRecompileMap = new ConcurrentHashMap<Integer, Boolean>(8, 0.75f, 1);
-
- boolean _running = false;
- boolean _contextInitialized = false;
- Logger _log = Logger.getLogger(ResourceMonitor.class.getName());
- ScriptingWeaver _weavers = null;
- static WeakReference<ServletContext> _externalContext;
-
- public static synchronized void startup(ServletContext externalContext) {
- if (_externalContext != null) return;
- _externalContext = new WeakReference<ServletContext>(externalContext);
-
- //we currently keep it as singleton but in the long run we will move it into the context
- //like everything else singleton-wise
- if (WeavingContext.isScriptingEnabled() && _instance == null) {
- _instance = new ResourceMonitor();
- externalContext.setAttribute(CONTEXT_KEY, _instance);
- /**
- * daemon thread to allow forced
- * shutdowns for web context restarts
- */
- _instance.setDaemon(true);
- _instance.setRunning(true);
- _instance.start();
-
- }
-
- }
-
- public static synchronized void clear() {
-
- }
-
- public static synchronized ResourceMonitor getInstance() {
- //we do it in this complicated manner because of find bugs
- //practically this cannot really happen except for shutdown were it is not important anymore
- ServletContext context = _externalContext.get();
- if (context != null) {
- return (ResourceMonitor) context.getAttribute(CONTEXT_KEY);
- }
- return null;
- }
-
- /**
- * Central run method
- * which performs the entire scanning process
- */
- public void run() {
- while (WeavingContext.isScriptingEnabled() && _running) {
- if (_externalContext != null && _externalContext.get() != null && !_contextInitialized) {
- WeavingContext.initThread((ServletContext) _externalContext.get());
- _contextInitialized = true;
- }
- try {
- try {
- Thread.sleep(ScriptingConst.TAINT_INTERVAL);
- } catch (InterruptedException e) {
- //if the server shuts down while we are in sleep we get an error
- //which we better should swallow
- }
-
- if (_classMap == null || _classMap.size() == 0)
- continue;
- if (_contextInitialized)
- checkForChanges();
- } catch (Throwable e) {
- _log.log(Level.SEVERE, "[EXT-SCRIPTING]", e);
-
- }
- }
- if (_log.isLoggable(Level.INFO)) {
- _log.info("[EXT-SCRIPTING] Dynamic reloading watch daemon is shutting down");
- }
- }
-
- /**
- * central tainted mark method which keeps
- * track if some file in one of the supported engines has changed
- * and if yes marks the file as tainted as well
- * as marks the engine as having to do a full recompile
- */
- private final void checkForChanges() {
- ScriptingWeaver weaver = WeavingContext.getWeaver();
- if (weaver == null) return;
- weaver.scanForAddedClasses();
-
- for (Map.Entry<String, ClassResource> it : this._classMap.entrySet()) {
-
- File proxyFile = it.getValue().getFile();
- if (isModified(it, proxyFile)) {
-
- _systemRecompileMap.put(it.getValue().getScriptingEngine(), Boolean.TRUE);
- ClassResource meta = it.getValue();
- meta.getRefreshAttribute().requestRefresh();
- printInfo(it, proxyFile);
-
- dependencyTainted(meta.getAClass().getName());
-
- //we add our log entry for further reference
- WeavingContext.getRefreshContext().addTaintLogEntry(meta);
- WeavingContext.getExtensionEventRegistry().sendEvent(new ClassTaintedEvent(meta));
- }
- //}
- }
- //we clean up the taint log
- WeavingContext.getRefreshContext().gcTaintLog();
- }
-
- /**
- * recursive walk over our meta data to taint also the classes
- * which refer to our refreshing class so that those
- * are reloaded as well, this helps to avoid classcast
- * exceptions caused by imports and casts on long running artifacts
- *
- * @param className the origin classname which needs to be walked recursively
- */
- private void dependencyTainted(String className) {
- Set<String> referrers = _dependencyMap.getReferringClasses(className);
- if (referrers == null) return;
- for (String referrer : referrers) {
- ClassResource metaData = _classMap.get(referrer);
- if (metaData == null) continue;
- if (metaData.getRefreshAttribute().requiresRefresh()) continue;
- printInfo(metaData);
-
- metaData.getRefreshAttribute().requestRefresh();
-
- dependencyTainted(metaData.getAClass().getName());
- WeavingContext.getRefreshContext().addTaintLogEntry(metaData);
- WeavingContext.getExtensionEventRegistry().sendEvent(new ClassTaintedEvent(metaData));
- }
- }
-
- private final boolean isModified(Map.Entry<String, ClassResource> it, File proxyFile) {
- return proxyFile.lastModified() > it.getValue().getRefreshAttribute().getRequestedRefreshDate() ;
- }
-
- private void printInfo(ClassResource it) {
- if (_log.isLoggable(Level.INFO)) {
- _log.log(Level.INFO, "[EXT-SCRIPTING] Tainting Dependency: {0}", it.getFile().getAbsolutePath());
- }
- }
-
- private void printInfo(Map.Entry<String, ClassResource> it, File proxyFile) {
- if (_log.isLoggable(Level.INFO)) {
- _log.log(Level.INFO, "[EXT-SCRIPTING] comparing {0} Dates: {1} {2} ", new String[]{it.getKey(), Long.toString(proxyFile.lastModified()), Long.toString(it.getValue().getRefreshAttribute().getExecutedRefreshDate())});
- _log.log(Level.INFO, "[EXT-SCRIPTING] Tainting: {0}", it.getValue().getFile().getAbsolutePath());
- }
- }
-
- public boolean isRunning() {
- return _running;
- }
-
- public void setRunning(boolean running) {
- this._running = running;
- }
-
- public Map<Integer, Boolean> getSystemRecompileMap() {
- return _systemRecompileMap;
- }
-
- public void setSystemRecompileMap(Map<Integer, Boolean> systemRecompileMap) {
- this._systemRecompileMap = systemRecompileMap;
- }
-
- public Map<String, ClassResource> getClassMap() {
- return _classMap;
- }
-
- public void setClassMap(Map<String, ClassResource> classMap) {
- this._classMap = classMap;
- }
-
- public ScriptingWeaver getWeavers() {
- return _weavers;
- }
-
- public void setWeavers(ScriptingWeaver weavers) {
- _weavers = weavers;
- }
-
- public ClassDependencies getDependencyMap() {
- return _dependencyMap;
- }
-}
-
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/monitor/WatchedResource.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/monitor/WatchedResource.java
deleted file mode 100644
index d93092f..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/monitor/WatchedResource.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.monitor;
-
-import java.io.File;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * An abstraction on our class watcher
- * we now deal with generic resources to simplify the access
- */
-
-public abstract class WatchedResource implements Cloneable {
-
- RefreshAttribute _refreshAttribute = new RefreshAttribute();
-
- /**
- * Unique identifier on the resource
- *
- * @return
- */
- public abstract String identifier();
-
- /**
- * @return a file handle on the current resource
- */
- public abstract File getFile();
-
- /**
- * @return additional refresh attribute metadata
- */
- public RefreshAttribute getRefreshAttribute() {
- return _refreshAttribute;
- }
-
- public WatchedResource getClone() {
- try {
- return (WatchedResource) super.clone();
- } catch (CloneNotSupportedException e) {
- return null;
- }
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/compiler/Compiler.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/compiler/Compiler.java
deleted file mode 100644
index eb1cfa9..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/compiler/Compiler.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.sandbox.compiler;
-
-import org.apache.myfaces.extensions.scripting.api.CompilationException;
-import org.apache.myfaces.extensions.scripting.api.CompilationResult;
-
-import java.io.File;
-
-/**
- * <p>An abstract compiler interface that enables you to compile one particular file at a time.</p>
- */
-public interface Compiler {
-
- /**
- * <p>Compiles the given file and creates an according class file in the given target path. Note that
- * it is possible for the given class to reference any other classes as long as the dependent classes
- * are available on the classpath. The given class loader determines the classes that are available
- * on the classpath.</p>
- *
- * @param sourcePath the path to the source directory
- * @param targetPath the path to the target directory
- * @param file the file of the class you want to compile
- * @param classLoader the class loader for dependent classes
- * @return the compilation result, i.e. the compiler output, a list of errors and a list of warnings
- * @throws CompilationException if a severe error occured while trying to compile a file
- */
- public CompilationResult compile(File sourcePath, File targetPath, File file, ClassLoader classLoader)
- throws CompilationException;
-
- /**
- * <p>Compiles the given file and creates an according class file in the given target path. Note that
- * it is possible for the given class to reference any other classes as long as the dependent classes
- * are available on the classpath. The given class loader determines the classes that are available
- * on the classpath.</p>
- *
- * @param sourcePath the path to the source directory
- * @param targetPath the path to the target directory
- * @param file the relative file name of the class you want to compile
- * @param classLoader the class loader for dependent classes
- * @return the compilation result, i.e. the compiler output, a list of errors and a list of warnings
- * @throws CompilationException if a severe error occurred while trying to compile a file
- */
- public CompilationResult compile(File sourcePath, File targetPath, String file, ClassLoader classLoader)
- throws CompilationException;
-
-}
\ No newline at end of file
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/compiler/CompilerFactory.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/compiler/CompilerFactory.java
deleted file mode 100644
index ca49980..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/compiler/CompilerFactory.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.sandbox.compiler;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * <p>This factory chooses and creates an instance of the according compiler
- * implementation based on the current JVM for you. If you're using a Java 6
- * VM, it will return a compiler using the JSR-199 API, otherwise it will
- * return a compiler that uses the JavaC tool.</p>
- */
-public class CompilerFactory {
-
- /**
- * The logger instance for this class.
- */
- private static final Logger logger = Logger.getLogger(CompilerFactory.class.getName());
-
- // ------------------------------------------ Public methods
-
- /**
- * <p>Factory method that creates a new Java compiler depending on the
- * Java runtime that this application is running on. That means, if the
- * Java runtime supports the JSR-199 API (i.e. it's at least a Java 6
- * runtime) this API will be used. Otherwise a compiler will be returned
- * that tries to use some internal JDK classes.</p>
- *
- * @return a new Java compiler depending on the Java runtime
- */
- public static Compiler createCompiler() {
- if (logger.isLoggable(Level.WARNING) &&
- !System.getProperty("java.vendor").contains("Sun Microsystems")) {
- logger.warning("This application is running on a Java runtime that neither supports the JSR-199 API " +
- "nor is it distributed by Sun Microsystems. However, the compiler implementation that will " +
- "be used depends on internal classes in the package 'com.sun.tools.javac' so compilation " +
- "is likely to fail! Be sure that the Java runtime that you're using provides these internal " +
- "classes!");
- }
-
- return new JavacCompiler();
- }
-}
\ No newline at end of file
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/compiler/GroovyCompiler.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/compiler/GroovyCompiler.java
deleted file mode 100644
index db8737e..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/compiler/GroovyCompiler.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.sandbox.compiler;
-
-import org.apache.myfaces.extensions.scripting.api.CompilationException;
-import org.apache.myfaces.extensions.scripting.api.CompilationResult;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.ClassLoaderUtils;
-import org.apache.myfaces.extensions.scripting.core.util.FileUtils;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.codehaus.groovy.control.CompilationFailedException;
-import org.codehaus.groovy.control.CompilationUnit;
-import org.codehaus.groovy.control.CompilerConfiguration;
-import org.codehaus.groovy.control.ErrorCollector;
-import org.codehaus.groovy.control.messages.Message;
-import org.codehaus.groovy.control.messages.SimpleMessage;
-import org.codehaus.groovy.control.messages.SyntaxErrorMessage;
-
-import java.io.File;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * <p>A compiler implementation that can be used to compile Groovy source files.</p>
- */
-public class GroovyCompiler implements Compiler {
-
- /**
- * The logger instance for this class.
- */
- private static final Logger logger = Logger.getLogger(GroovyCompiler.class.getName());
-
- // ------------------------------------------ Compiler methods
-
- /**
- * <p>Compiles the given file and creates an according class file in the given target path.</p>
- *
- * @param sourcePath the path to the source directory
- * @param targetPath the path to the target directory
- * @param file the file of the class you want to compile
- * @param classLoader the class loader to use to determine the classpath
- * @return the compilation result
- */
- public CompilationResult compile(File sourcePath, File targetPath, String file, ClassLoader classLoader)
- throws CompilationException {
- return compile(sourcePath, targetPath, new File(sourcePath, file), classLoader);
- }
-
- public CompilationResult compile(File sourcePath, File targetPath, ClassLoader classLoader) {
-
- List<File> sourceFiles = FileUtils.fetchSourceFiles(WeavingContext.getConfiguration().getWhitelistedSourceDirs(ScriptingConst.ENGINE_TYPE_JSF_GROOVY), "*.groovy");
-
- StringWriter compilerOutput = new StringWriter();
-
- CompilationUnit compilationUnit = new CompilationUnit(
- buildCompilerConfiguration(sourcePath, targetPath, classLoader));
- compilationUnit.getConfiguration().setOutput(new PrintWriter(compilerOutput));
-
- for (File sourceFile : sourceFiles) {
- compilationUnit.addSource(sourceFile);
- }
-
- CompilationResult result;
-
- try {
- compilationUnit.compile();
-
- result = new CompilationResult(compilerOutput.toString());
- WeavingContext.setCompilationResult(ScriptingConst.ENGINE_TYPE_JSF_GROOVY, result);
-
- } catch (CompilationFailedException ex) {
- // Register all collected error messages from the Groovy compiler
- result = new CompilationResult(compilerOutput.toString());
- ErrorCollector collector = compilationUnit.getErrorCollector();
- for (int i = 0; i < collector.getErrorCount(); ++i) {
- result.registerError(convertMessage(collector.getError(i)));
- }
- }
-
- // Register all collected warnings from the Groovy compiler
- ErrorCollector collector = compilationUnit.getErrorCollector();
- for (int i = 0; i < collector.getWarningCount(); ++i) {
- result.registerWarning(convertMessage(collector.getWarning(i)));
- }
-
- return result;
- }
-
- /**
- * <p>Compiles the given file and creates an according class file in the given target path.</p>
- *
- * @param sourcePath the path to the source directory
- * @param targetPath the path to the target directory
- * @param file the file of the class you want to compile
- * @param classLoader the class loader to use to determine the classpath
- * @return the compilation result
- */
- public CompilationResult compile(File sourcePath, File targetPath, File file, ClassLoader classLoader)
- {
- StringWriter compilerOutput = new StringWriter();
-
- CompilationUnit compilationUnit = new CompilationUnit(
- buildCompilerConfiguration(sourcePath, targetPath, classLoader));
- compilationUnit.getConfiguration().setOutput(new PrintWriter(compilerOutput));
- compilationUnit.addSource(file);
-
- CompilationResult result;
-
- try {
- compilationUnit.compile();
-
- result = new CompilationResult(compilerOutput.toString());
-
- WeavingContext.setCompilationResult(ScriptingConst.ENGINE_TYPE_JSF_GROOVY, result);
- } catch (CompilationFailedException ex) {
- // Register all collected error messages from the Groovy compiler
- result = new CompilationResult(compilerOutput.toString());
- ErrorCollector collector = compilationUnit.getErrorCollector();
- for (int i = 0; i < collector.getErrorCount(); ++i) {
- result.registerError(convertMessage(collector.getError(i)));
- }
- }
-
- // Register all collected warnings from the Groovy compiler
- ErrorCollector collector = compilationUnit.getErrorCollector();
- for (int i = 0; i < collector.getWarningCount(); ++i) {
- result.registerWarning(convertMessage(collector.getWarning(i)));
- }
-
- return result;
- }
-
- // ------------------------------------------ Utility methods
-
- /**
- * <p>Converts the given Groovy compiler message into a compilation message that
- * our compilation API consists of.</p>
- *
- * @param message the Groovy compiler message you want to convert
- * @return the final converted compilation message
- */
- protected CompilationResult.CompilationMessage convertMessage(Message message) {
- if (message instanceof SimpleMessage) {
- SimpleMessage simpleMessage = (SimpleMessage) message;
- return new CompilationResult.CompilationMessage(-1, simpleMessage.getMessage());
- } else if (message instanceof SyntaxErrorMessage) {
- SyntaxErrorMessage syntaxErrorMessage = (SyntaxErrorMessage) message;
- return new CompilationResult.CompilationMessage(
- syntaxErrorMessage.getCause().getLine(), syntaxErrorMessage.getCause().getMessage());
- } else {
- if (logger.isLoggable(Level.FINE)) {
- logger.log(Level.FINE,
- "This compiler came across an unknown message kind ['" + message + "']. It will be ignored.");
- }
-
- return null;
- }
- }
-
- /**
- * <p>Configures the compiler by building its configuration object.</p>
- *
- * @param sourcePath the path to the source directory
- * @param targetPath the path to the target directory
- * @param classLoader the class loader to use to determine the classpath
- * @return the compiler configuration
- */
- protected CompilerConfiguration buildCompilerConfiguration(File sourcePath, File targetPath, ClassLoader classLoader) {
- CompilerConfiguration configuration = new CompilerConfiguration();
-
- // Set the destination / target directory for the compiled .class files.
- configuration.setTargetDirectory(targetPath.getAbsoluteFile());
-
- // Specify the classpath of the given class loader. This enables the user to write new Java
- // "scripts" that depend on classes that have already been loaded previously. Otherwise he
- // wouldn't be able to use for example classes that are available in a library.
- configuration.setClasspath(ClassLoaderUtils.buildClasspath(classLoader));
-
- // Enable verbose output.
- configuration.setVerbose(true);
-
- // Generate debugging information.
- configuration.setDebug(true);
-
- return configuration;
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/compiler/JavacCompiler.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/compiler/JavacCompiler.java
deleted file mode 100644
index 4f7dbed..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/compiler/JavacCompiler.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.sandbox.compiler;
-
-import org.apache.myfaces.extensions.scripting.api.CompilationException;
-import org.apache.myfaces.extensions.scripting.api.CompilationResult;
-import org.apache.myfaces.extensions.scripting.core.util.ClassLoaderUtils;
-
-import java.io.File;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * <p>A compiler implementation that utilizes some internal classes that enable you to
- * compile Java source code using the javac compiler being provided by your JDK. However,
- * note that this only works if you're using a Sun JDK up to the version 1.5 (as of Java 6
- * you should use the JSR-199 API).</p>
- * <p/>
- * <p>This class loads some internal classes from $JAVA_HOME$/lib/tools.jar so be sure to
- * either include this JAR file in your classpath at startup or set the JAVA_HOME property
- * accordingly so that it points to a valid JDK home directory (it doesn't work if you're
- * just using a JRE!)</p>
- */
-public class JavacCompiler implements Compiler {
-
- /**
- * The logger instance for this class.
- */
- private static final Logger logger = Logger.getLogger(JavacCompiler.class.getName());
-
- /**
- * The class name of the javac compiler. Note that this class
- * is only available if you're using a Sun JDK.
- */
- private static final String JAVAC_MAIN = "com.sun.tools.javac.Main";
-
- /**
- * The class reference to the internal Javac compiler.
- */
- private Class compilerClass;
-
- // ------------------------------------------ Constructors
-
- /**
- * <p>Creates a new Javac compiler by searching for the required JAR file '$JAVA_HOME$/lib/tools.jar'
- * automatically. Note that the user has to specify the JAVA_HOME property in this case.</p>
- */
- public JavacCompiler() {
- this(null);
- }
-
- /**
- * <p>Creates a new Javac compiler by searching for internal classes in the given JAR file.</p>
- *
- * @param toolsJar the location of the JAR file '$JAVA_HOME$/lib/tools.jar' or <code>null</code>
- * if you want it to be searched for automatically
- */
- public JavacCompiler(URL toolsJar) {
- ClassLoader classLoader;
-
- try {
- classLoader = createJavacAwareClassLoader(toolsJar);
- }
- catch (MalformedURLException ex) {
- throw new IllegalStateException("An error occurred while trying to load the Javac compiler class.", ex);
- }
-
- try {
- this.compilerClass = classLoader.loadClass(JAVAC_MAIN);
- }
- catch (ClassNotFoundException ex) {
- throw new IllegalStateException("The Javac compiler class '" + JAVAC_MAIN + "' couldn't be found even though" +
- "the required JAR file '$JAVA_HOME$/lib/tools.jar' has been put on the classpath. Are you sure that " +
- "you're using a valid Sun JDK?");
- }
- }
-
- // ------------------------------------------ Compiler methods
-
- /**
- * <p>Compiles the given file and creates an according class file in the given target path.</p>
- *
- * @param sourcePath the path to the source directory
- * @param targetPath the path to the target directory
- * @param file the relative file name of the class you want to compile
- * @return the compilation result, i.e. as of now only the compiler output
- */
- public CompilationResult compile(File sourcePath, File targetPath, String file, ClassLoader classLoader)
- throws CompilationException {
- return compile(sourcePath, targetPath, new File(sourcePath, file), classLoader);
- }
-
- /**
- * <p>Compiles the given file and creates an according class file in the given target path.</p>
- *
- * @param sourcePath the path to the source directory
- * @param targetPath the path to the target directory
- * @param file the file of the class you want to compile
- * @return the compilation result, i.e. as of now only the compiler output
- */
- public CompilationResult compile(File sourcePath, File targetPath, File file, ClassLoader classLoader)
- throws CompilationException {
- // The destination directory must already exist as javac will not create the destination directory.
- if (!targetPath.exists()) {
- if (!targetPath.mkdirs()) {
- throw new IllegalStateException("It wasn't possible to create the target " +
- "directory for the compiler ['" + targetPath.getAbsolutePath() + "'].");
- }
-
- // If we've created the destination directory, we'll delete it as well once the application exits
- targetPath.deleteOnExit();
- }
-
- try {
- StringWriter compilerOutput = new StringWriter();
-
- // Invoke the Javac compiler
- Method compile = compilerClass.getMethod("compile", new Class[]{String[].class, PrintWriter.class});
- Integer returnCode = (Integer) compile.invoke(null,
- new Object[]{buildCompilerArguments(sourcePath, targetPath, file, classLoader),
- new PrintWriter(compilerOutput)});
-
- CompilationResult result = new CompilationResult(compilerOutput.toString());
- if (returnCode == null || returnCode.intValue() != 0) {
- result.registerError(new CompilationResult.CompilationMessage(-1,
- "Executing the javac compiler failed. The return code is '" + returnCode + "'."));
- }
-
- return result;
- }
- catch (NoSuchMethodException ex) {
- throw new IllegalStateException("The Javac compiler class '" + compilerClass + "' doesn't provide the method " +
- "compile(String, PrintWriter). Are you sure that you're using a valid Sun JDK?", ex);
- }
- catch (InvocationTargetException ex) {
- throw new IllegalStateException("An error occurred while invoking the compile(String, PrintWriter) method of the " +
- "Javac compiler class '" + compilerClass + "'. Are you sure that you're using a valid Sun JDK?", ex);
- }
- catch (IllegalAccessException ex) {
- throw new IllegalStateException("An error occurred while invoking the compile(String, PrintWriter) method of the " +
- "Javac compiler class '" + compilerClass + "'. Are you sure that you're using a valid Sun JDK?", ex);
- }
- }
-
- // ------------------------------------------ Utility methods
-
- /**
- * <p>Creates the arguments for the compiler, i.e. it builds an array of arguments that one would pass to
- * the Javac compiler on the command line.</p>
- *
- * @param sourcePath the path to the source directory
- * @param targetPath the path to the target directory
- * @param file the relative file name of the class you want to compile
- * @return an array of arguments that you have to pass to the Javac compiler
- */
- protected String[] buildCompilerArguments(File sourcePath, File targetPath, File file, ClassLoader classLoader) {
- List<String> arguments = new ArrayList<String>();
-
- // Note that we're knowingly not specifying the sourcepath as the compiler really should compile
- // only a single file (see 'file'). The dependent classes are available on the classpath anyway.
- // Otherwise the compiler would also compile dependent classes, which we want to avoid! This
- // would result in different versions of a Class file being in use (the system doesn't know that
- // it has to update itself due to a newer version of a Class file whilst the dynamic class loader
- // will already start using it!)
- // arguments.add("-sourcepath");
- // arguments.add(sourcePath.getAbsolutePath());
-
- // Set the destination / target directory for the compiled .class files.
- arguments.add("-d");
- arguments.add(targetPath.getAbsolutePath());
-
- // Specify the classpath of the given class loader. This enables the user to write new Java
- // "scripts" that depend on classes that have already been loaded previously. Otherwise he
- // wouldn't be able to use for example classes that are available in a library.
- arguments.add("-classpath");
- arguments.add(ClassLoaderUtils.buildClasspath(classLoader));
-
- // Enable verbose output.
- arguments.add("-verbose");
-
- // Generate all debugging information, including local variables.
- arguments.add("-g");
-
- // Append the source file that is to be compiled. Note that the user specifies only a relative file location.
- arguments.add(file.getAbsolutePath());
-
- return arguments.toArray(new String[arguments.size()]);
- }
-
- /**
- * <p>Returns a possibly newly created class loader that you can use in order to load the
- * Javac compiler class. Usually the user would have to put the JAR file
- * '$JAVA_HOME$/lib/tools.jar' on the classpath but this method recognizes this on its own
- * and loads the JAR file if necessary. However, it's not guaranteed that the Javac compiler
- * class is available (e.g. if one is providing a wrong tools.jar file that doesn't contain
- * the required classes).</p>
- *
- * @param toolsJar the location of the JAR file '$JAVA_HOME$/lib/tools.jar' or <code>null</code>
- * if you want it to be searched for automatically
- * @return a class loader that you can use in order to load the Javac compiler class
- * @throws MalformedURLException if an error occurred while constructing the URL
- */
- private static ClassLoader createJavacAwareClassLoader(URL toolsJar) throws MalformedURLException {
- // If the user has already included the tools.jar in the classpath we don't have
- // to create a custom class loader as the class is already available.
- if (ClassLoaderUtils.isClassAvailable(JAVAC_MAIN, ClassLoaderUtils.getDefaultClassLoader())) {
- if (logger.isLoggable(Level.FINE)) {
- logger.log(Level.FINE, "Seemingly the required JAR file '$JAVA_HOME$/lib/tools.jar' has already been "
- + "put on the classpath as the class '" + JAVAC_MAIN + "' is present. So there's no "
- + "need to create a custom class loader for the Javac compiler.");
- }
-
- return ClassLoaderUtils.getDefaultClassLoader();
- } else {
- // The compiler isn't available in the current classpath, but the user could have specified the tools.jar file.
- if (toolsJar == null) {
- String javaHome = System.getProperty("java.home");
- if (javaHome.toLowerCase(Locale.getDefault()).endsWith(File.separator + "jre")) {
- // Note that even if the user has installed a valid JDK the $JAVA_HOME$ property might reference
- // the JRE, e.g. '/usr/lib/jvm/java-6-sun-1.6.0.16/jre'. However, in this case we just have to
- // remove the last four characters (i.e. the '/jre').
- javaHome = javaHome.substring(0, javaHome.length() - 4);
- }
-
- // If the user hasn't specified the URL to the tools.jar file, we'll try to find it on our own.
- File toolsJarFile = new File(javaHome, "lib" + File.separatorChar + "tools.jar");
- if (toolsJarFile.exists()) {
- if (logger.isLoggable(Level.FINE)) {
- logger.log(Level.FINE,
- "The required JAR file '$JAVA_HOME$/lib/tools.jar' has been found ['" + toolsJarFile.getAbsolutePath()
- + "']. A custom URL class loader will be created for the Javac compiler.");
- }
-
- return new URLClassLoader(
- new URL[]{toolsJarFile.toURI().toURL()}, ClassLoaderUtils.getDefaultClassLoader());
- } else {
- throw new IllegalStateException("The Javac compiler class '" + JAVAC_MAIN + "' and the required JAR file " +
- "'$JAVA_HOME$/lib/tools.jar' couldn't be found. Are you sure that you're using a valid Sun JDK? " +
- "[$JAVA_HOME$: '" + System.getProperty("java.home") + "']");
- }
- } else {
- if (logger.isLoggable(Level.FINE)) {
- logger.log(Level.FINE, "The user has specified the required JAR file '$JAVA_HOME$/lib/tools.jar' ['"
- + toolsJar.toExternalForm() + "']. A custom URL class loader will be created for the Javac compiler.");
- }
-
- return new URLClassLoader(new URL[]{toolsJar}, ClassLoaderUtils.getDefaultClassLoader());
- }
- }
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/loader/ReloadingClassLoader.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/loader/ReloadingClassLoader.java
deleted file mode 100644
index 533c2cc..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/loader/ReloadingClassLoader.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.sandbox.loader;
-
-import org.apache.myfaces.extensions.scripting.core.util.FileUtils;
-import org.apache.myfaces.extensions.scripting.loaders.java.ThrowawayClassloader;
-import org.apache.myfaces.extensions.scripting.sandbox.loader.support.ClassFileLoader;
-import org.apache.myfaces.extensions.scripting.sandbox.loader.support.OverridingClassLoader;
-import org.apache.myfaces.extensions.scripting.sandbox.loader.support.ThrowAwayClassLoader;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * <p>A class loader implementation that enables you to reload certain classes. It automatically
- * reloads classes if there's a newer version of a .class file available in a specified compilation
- * target path. However, it's also possible to explicitly reload other classes.</p>
- * <p/>
- * <p>This enables you to do both modify and reload various classes that you've used for Spring
- * bean definitions, but it also enables you to reload for example classes depending on those
- * dynamically compiled classes, like factory bean classes. By explicitly reloading a factory
- * bean class the newly loaded factory bean will return updated bean instances as well!</p>
- * <p/>
- * <p>Note that even though this class extends the class URLClassLoader it doesn't use any
- * of its functionalities. This class loader just works similar and provides a similar interface
- * so it's useful to extend the class URLClassLoader as you can treat it like one (especially
- * when it comes to resolving the classpath of a class loader).</p>
- */
-public class ReloadingClassLoader extends URLClassLoader {
-
- /**
- * The system-dependent default name-separator character. Note that it's safe to
- * use this version of the file separator in regex methods, like replaceAll().
- */
- private static String FILE_SEPARATOR = FileUtils.getFileSeparatorForRegex();
-
- /**
- * The logger instance for this class.
- */
- private static final Logger _logger = Logger.getLogger(ReloadingClassLoader.class.getName());
-
- /**
- * A table of class names and the according class loaders. It's basically like
- * a list of classes that this class loader has already loaded. However, the
- * thing is that this class loader isn't actually going to load them as we
- * would loose the possibility to override them then, which is the reason why
- * each class has got its own class loader.
- */
- private Map<String, ThrowAwayClassLoader> _classLoaders =
- new HashMap<String, ThrowAwayClassLoader>();
-
- /**
- * The target directory for the compiler, i.e. the directory that contains the
- * dynamically compiled .class files.
- */
- private File _compilationDirectory;
-
- // ------------------------------------------ Constructors
-
- /**
- * <p>Constructs a new reloading classloader for the specified compilation
- * directory using the default delegation parent classloader. Note that this
- * classloader will only delegate to the parent classloader if there's no
- * dynamically compiled class available.</p>
- *
- * @param compilationDirectory the compilation directory
- */
- public ReloadingClassLoader(File compilationDirectory) {
- super(new URL[0]);
- this._compilationDirectory = compilationDirectory;
- }
-
- /**
- * <p>Constructs a new reloading classloader for the specified compilation
- * directory using the given delegation parent classloader. Note that this
- * classloader will only delegate to the parent classloader if there's no
- * dynamically compiled class available.</p>
- *
- * @param parentClassLoader the parent classloader
- * @param compilationDirectory the compilation directory
- */
- public ReloadingClassLoader(ClassLoader parentClassLoader, File compilationDirectory) {
- super(new URL[0], parentClassLoader);
- this._compilationDirectory = compilationDirectory;
- }
-
- // ------------------------------------------ URLClassLoader methods
-
- /**
- * <p>Loads the class with the specified binary name. This method searches for classes in the
- * compilation directory that you've specified previously. Note that this class loader recognizes
- * whether the class files have changed, that means, if you recompile and reload a class, you'll
- * get a Class object that represents the recompiled class.</p>
- *
- * @param className the binary name of the class you want to load
- * @param resolve <tt>true</tt>, if the class is to be resolved
- * @return The resulting <tt>Class</tt> object
- * @throws ClassNotFoundException if the class could not be found
- */
- protected Class<?> loadClass(String className, boolean resolve) throws ClassNotFoundException {
- // First of all, check if there's a class file available in the compilation target path.
- // It doesn't matter which class we're dealing with at the moment as there's always the
- // possibility that the user is either trying to override a statically compiled class
- // (i.e. a class that has been compiled before deploying the application) or he/she is
- // trying to modify a dynamically compiled class, in which case we should compare
- // timestamps, etc.
- File classFile = resolveClassFile(className);
- if (classFile != null && classFile.exists()) {
- if (_classLoaders.containsKey(className)) {
- // Check if the class loader is already outdated, i.e. there is a newer class file available
- // for the class we want to load than the class file we've already loaded. If that's the case
- // we're going to throw away this ClassLoader and create a new one for linkage reasons.
- ThrowAwayClassLoader classLoader = _classLoaders.get(className);
- if (classLoader.isOutdated(classFile.lastModified())) {
- // If the class loader is outdated, create a new one. Otherwise the same class loader
- // would have to load the same class twice or more often which would cause severe
- // linkage errors. Actually the JVM wouldn't permit that anyway and throw some
- // linkage errors / exceptions.
- reloadClass(className);
- }
- } else {
- if (_logger.isLoggable(Level.FINEST)) {
- _logger.log(Level.FINEST, "A new dynamic class '"
- + className + "' has been found by this class loader '" + this + "'.");
- }
-
- // We haven't loaded this class so far, but there is a .class file available,
- // so we have to reload the given class.
- reloadClass(className);
- }
-
- ThrowAwayClassLoader classLoader = _classLoaders.get(className);
- return classLoader.loadClass(className, resolve);
- } else {
- // Even though there is no class file available, there's still a chance that this
- // class loader has forcefully reloaded a statically compiled class.
- if (_classLoaders.containsKey(className)) {
- ThrowAwayClassLoader classLoader = _classLoaders.get(className);
- return classLoader.loadClass(className, resolve);
- } else {
- // However, if there's neither a .class file nor a reloadable class loader
- // available, just delegate to the parent class loader.
- return super.loadClass(className, resolve);
- }
- }
- }
-
- /**
- * <p>Returns the search path of URLs for loading classes, i.e. the
- * given compilation target directory, the directory that contains the
- * dynamically compiled .class files.</p>
- *
- * @return the search path of URLs for loading classes
- */
- public URL[] getURLs() {
- try {
- return new URL[]{_compilationDirectory.toURI().toURL()};
- } catch (IOException ex) {
- _logger.log(Level.SEVERE, "Couldn't resolve the URL to the compilation directory {0} {1} {2} ", new String[]{_compilationDirectory.getAbsolutePath(), ex.getMessage(), ex.toString()});
- return new URL[0];
- }
- }
-
- // ------------------------------------------ Public methods
-
- /**
- * <p>Determines whether the given class has been loaded by a class
- * loader that is already outdated.</p>
- *
- * @param classObj the class you want to check
- * @return <code>true</code, if there is a newer class file available for the given object
- */
- public boolean isOutdated(Class classObj) {
- // Is there even a dynamically compiled class file available for the given class?
- File classFile = resolveClassFile(classObj.getName());
- if (classFile.exists()) {
- // If so, check if we the Class reference has been loaded by a ThrowAwayClassLoader.
- // Otherwise it's definitely outdated and we don't have to compare timestamps.
- if (classObj.getClassLoader() instanceof ThrowAwayClassLoader) {
- // Compare the timestamps in order to determine whether the given Class
- // reference is already outdated.
- ThrowAwayClassLoader classLoader = (ThrowAwayClassLoader) classObj.getClassLoader();
- return classLoader.isOutdated(classFile.lastModified());
- } else {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * <p>Reloads the given class internally explicitly. Note that this classloader usually
- * reloads classes automatically, i.e. this classloader detects if there is a newer
- * version of a class file available in the compilation directory. However, by using
- * this method you tell this classloader to forcefully reload the given class. For
- * example, if you've got a newer version of a dynamically recompiled class and a
- * statically compiled class depending on this one, you can tell this classloader to
- * reload the statically compiled class as well so that it references the correct
- * version of the Class object.</p>
- *
- * @param className the class you want to reload
- */
- public void reloadClass(final String className) {
- ThrowAwayClassLoader classLoader;
-
- final File classFile = resolveClassFile(className);
- final ReloadingClassLoader _this = this;
- try {
- if (classFile != null && classFile.exists()) {
-
- classLoader = AccessController.doPrivileged(new PrivilegedExceptionAction<ClassFileLoader>() {
- public ClassFileLoader run() {
- return new ClassFileLoader(className, classFile, _this);
- }
- });
-
- } else {
- classLoader = AccessController.doPrivileged(new PrivilegedExceptionAction<OverridingClassLoader>() {
- public OverridingClassLoader run() {
- return new OverridingClassLoader(className, _this);
- }
- });
- }
- } catch (PrivilegedActionException e) {
- _logger.log(Level.SEVERE, "", e);
- return;
- }
-
- ThrowAwayClassLoader oldClassLoader = _classLoaders.put(className, classLoader);
- if (_logger.isLoggable(Level.INFO)) {
- if (oldClassLoader != null) {
- _logger.info("Replaced the class loader '" + oldClassLoader + "' with the class loader '"
- + classLoader + "' as this class loader is supposed to reload the class '" + className + "'.");
- } else {
- _logger.info("Installed a new class loader '" + classLoader + "' for the class '"
- + className + "' as this class loader is supposed to reload it.");
- }
- }
- }
-
- /**
- * <p>Returns a copy of the current reloading class loader with the only difference
- * being the parent class loader to use. Use this method if you just want to replace
- * the parent class loader (obviously you can't do that after a ClassLoader has been
- * created, hence a copy is created).</p>
- *
- * @param parentClassLoader the parent ClassLoader to use
- * @return a copy of the current reloading class loader
- */
- @SuppressWarnings("unused")
- public ReloadingClassLoader cloneWithParentClassLoader(final ClassLoader parentClassLoader) {
- ReloadingClassLoader classLoader = null;
- try {
- classLoader = AccessController.doPrivileged(new PrivilegedExceptionAction<ReloadingClassLoader>() {
- public ReloadingClassLoader run() {
- return new ReloadingClassLoader(parentClassLoader, _compilationDirectory);
- }
- });
- } catch (PrivilegedActionException e) {
- _logger.log(Level.SEVERE, "", e);
- return null;
- }
-
- // Note that we don't have to create "deep copies" as the class loaders in the map
- // are immutable anyway (they are only supposed to load a single class) and additionally
- // this map doesn't contain any classes that have been loaded using the current parent
- // class loader!
- classLoader._classLoaders = new HashMap<String, ThrowAwayClassLoader>(_classLoaders);
-
- return classLoader;
- }
-
- // ------------------------------------------ Utility methods
-
- /**
- * <p>Resolves and returns a File handle that represents the class file of
- * the given class on the file system. However, note that this method only
- * returns <code>null</code> if an error occured while resolving the class
- * file. A non-null valuee doesn't necessarily mean that the class file
- * actually exists. In oder to check the existence call the according
- * method on the returned object.</p>
- *
- * @param className the name of the class that you want to resolve
- * @return a File handle that represents the class file of the given class
- * on the file system
- * @see java.io.File#exists()
- */
- protected File resolveClassFile(String className) {
- // This method just has to look in the specified compilation directory. The
- // relative class file path can be computed from the class name.
- return new File(_compilationDirectory,
- className.replaceAll("\\.", FILE_SEPARATOR).concat(".class"));
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/loader/support/AbstractThrowAwayClassLoader.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/loader/support/AbstractThrowAwayClassLoader.java
deleted file mode 100644
index 3e15094..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/loader/support/AbstractThrowAwayClassLoader.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.sandbox.loader.support;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-/**
- *
- */
-public abstract class AbstractThrowAwayClassLoader extends URLClassLoader
- implements ThrowAwayClassLoader {
-
- /**
- * The size of the buffer we're going to use to copy the contents from a stream to a byte array.
- */
- private static final int BUFFER_SIZE = 4096;
-
- /**
- * Indicates when this ClassLoader has been created.
- */
- private final long _timestamp;
-
- /**
- * The name of the class that this class loader is going to load.
- */
- private final String _className;
-
- // ------------------------------------------ Constructors
-
- public AbstractThrowAwayClassLoader(String className, ClassLoader parentClassLoader) {
- super(new URL[0], parentClassLoader);
-
- if (className == null) {
- throw new IllegalArgumentException("The given class name must not be null.");
- }
-
- // Save a timestamp of the time this class loader has been created. In doing
- // so, we're able to tell if this class loader is already outdated or not.
- this._timestamp = System.currentTimeMillis();
- this._className = className;
- }
-
- // ------------------------------------------ ThrowAwayClassLoader methods
-
- /**
- * <p>Loads the class with the specified class name. However, note that implementing
- * classes are just supposed to load a single class, so if you want to load a different
- * class than that, this class loader will just delegate to the parent class loader.</p>
- *
- * @param className the name of the class you want to load
- * @param resolve if <tt>true</tt> then resolve the class
- * @return the resulting Class reference
- * @throws ClassNotFoundException if the class could not be found
- */
- public Class loadClass(String className, boolean resolve) throws ClassNotFoundException {
- Class c;
-
- // Note that this class loader is only supposed to load a specific Class reference,
- // hence the check against the class name. Otherwise this class loader would try to
- // resolve class files for dependent classes as well, which means that there would
- // be different versions of the same Class reference in the system.
- if (isEligibleForLoading(className)) {
- // First, check if the class has already been loaded
- c = findLoadedClass(className);
- if (c == null) {
- // Note that execution reaches this point only if we're either updating a
- // dynamically loaded class or loading it for the first time. Otherwise
- // this ClassLoader would have returned an already loaded class (see the
- // call to findLoadedClass()).
- c = findClass(className);
- if (resolve) {
- resolveClass(c);
- }
- }
- }
-
- // If this class loader isn't supposed to load the given class it doesn't
- // necessarily mean, that we're not dealing with a dynamic class here.
- // However, if that's the case, we really want to use the same class loader
- // (i.e. the same ClassFileLoader instance) as Spring does, hence the
- // delegation to the parent class loader (i.e. the ReloadingClassLoader
- // again).
- else {
- c = super.loadClass(className, resolve);
- }
-
- return c;
- }
-
- /**
- * <p>Returns <code>true</code> if the given "last modified"-timestamp is
- * more recent than the time stamp of this class loader, i.e. if this class loader
- * is to be destroyed as there is a newer class file available.
- *
- * @param lastModified the "last modified"-timestamp of the class file you want to load
- * @return <code>true</code> if the given "last modified"-timestamp is
- * more recent than the time stamp of this ClassLoader
- */
- public boolean isOutdated(long lastModified) {
- return _timestamp < lastModified;
- }
-
- // ------------------------------------------ Utility methods
-
- /**
- * <p>Determines whether this class loader is supposed to load the given class.</p>
- *
- * @param className the name of the class
- * @return <code>true</code>, if this class loader is supposed to load the
- * given class, <code>false</code> otherwise
- */
- protected boolean isEligibleForLoading(String className) {
- return getClassName().equals(className);
- }
-
- /**
- * <p>Finds and loads the class with the specified name from the compilation path.</p>
- *
- * @param className the name of the class
- * @return the resulting class
- * @throws ClassNotFoundException if the class could not be found
- */
- protected Class findClass(final String className) throws ClassNotFoundException {
- if (isEligibleForLoading(className)) {
- try {
- return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
- public Class<?> run() throws Exception {
- InputStream stream = null;
-
- try {
- // Load the raw bytes of the class file into the memory ..
- stream = openStreamForClass(className);
- if (stream != null) {
- byte[] buffer = loadClassFromStream(stream);
-
- // .. and create an according Class object.
- return defineClass(className, buffer, 0, buffer.length);
- } else {
- throw new ClassNotFoundException(
- "Cannot find the resource that defines the class '" + className + "'.");
- }
- }
- catch (IOException ex) {
- throw new ClassNotFoundException(
- "Cannot load the raw byte contents for the class '" + className + "'.", ex);
- }
- finally {
- if (stream != null) {
- stream.close();
- }
- }
- }
- });
- }
- catch (PrivilegedActionException e) {
- throw (ClassNotFoundException) e.getException();
- }
- } else {
- throw new ClassNotFoundException(
- "This class loader only knows how to load the class '" + getClassName() + "'.");
- }
- }
-
- /**
- * <p>Returns the name of the class that this class loader is going to load.</p>
- *
- * @return the name of the class that this class loader is going to load
- */
- protected String getClassName() {
- return _className;
- }
-
- /**
- * <p>Loads the byte array that you can use to define the given class
- * afterwards using a call to {@link #defineClass}.</p>
- *
- * @param stream a stream referencing e.g. a .class file
- * @return the byte array that you can use to define the given class
- * @throws IOException if an I/O error occurs
- */
- private byte[] loadClassFromStream(InputStream stream) throws IOException {
- ByteArrayOutputStream result = new ByteArrayOutputStream(BUFFER_SIZE * 5);
-
- byte[] buffer = new byte[BUFFER_SIZE];
-
- int readBytes;
- while ((readBytes = stream.read(buffer)) != -1) {
- result.write(buffer, 0, readBytes);
- }
-
- return result.toByteArray();
- }
-
- // ------------------------------------------ Abstract methods
-
- /**
- * <p>Opens a stream to the resource that defines the given class. If it
- * cannot be found, return <code>null</code>.</p>
- *
- * @param className the class to load
- * @return a stream to the resource that defines the given class
- * @throws IOException if an I/O error occurs
- */
- protected abstract InputStream openStreamForClass(String className) throws IOException;
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/loader/support/ClassFileLoader.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/loader/support/ClassFileLoader.java
deleted file mode 100644
index 5ced30a..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/loader/support/ClassFileLoader.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.sandbox.loader.support;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * <p>This class loader actually loads the newly compiled classes. Each newly compiled class
- * requires one to instantiate a new instance of this class loader, in doing so we don't cause
- * severe linkage errors (the JVM doesn't permit class loaders to load classes more than once).
- * That means on the other hand that each class loader is just going to load a single class.
- * </p>
- */
-public class ClassFileLoader extends AbstractThrowAwayClassLoader {
-
- /**
- * The logger instance for this class.
- */
- private static final Logger logger = Logger.getLogger(ClassFileLoader.class.getName());
-
- /**
- * The .class file that contains the byte code for the class that this class loader is going to load.
- */
- private final File classFile;
-
- // -------------------------------------- Constructors
-
- /**
- * <p>Constructs a new class loader that is just going to load the given class file. If one
- * requests to load a different class than that, this class loader will just delegate the
- * request to the given parent class loader.</p>
- *
- * @param className the name of the class that this class loader is going to load
- * @param classFile a reference to the .class file that contains the bytecode for the class
- * @param parentClassLoader the parent class loader
- */
- public ClassFileLoader(String className, File classFile, ClassLoader parentClassLoader) {
- super(className, parentClassLoader);
-
- if (classFile == null) {
- throw new IllegalArgumentException("The given class file must not be null.");
- }
-
- this.classFile = classFile;
- }
-
- // ------------------------------------------ URLClassLoader methods
-
- /**
- * <p>Returns the search path of URLs for loading classes, i.e. the
- * given compilation target directory, the directory that contains the
- * dynamically compiled .class files.</p>
- *
- * @return the search path of URLs for loading classes
- */
- public URL[] getURLs() {
- try {
- return new URL[]{classFile.toURI().toURL()};
- }
- catch (IOException ex) {
- logger.log(Level.SEVERE, "Couldn't resolve the URL to the class file {0} that this class loader {1} should load, {2} {3}", new String [] {classFile.getAbsolutePath() , this.getClassName(), ex.getMessage(), ex.toString()});
-
- return new URL[0];
- }
- }
-
- // -------------------------------------- ThrowAwayClassLoader methods
-
- /**
- * <p>Opens a stream to the resource that defines the given class. If it
- * cannot be found, return <code>null</code>.</p>
- *
- * @param className the class to load
- * @return a stream to the resource that defines the given class
- * @throws java.io.IOException if an I/O error occurs
- */
- protected InputStream openStreamForClass(String className) throws IOException {
- return new FileInputStream(classFile);
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/loader/support/OverridingClassLoader.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/loader/support/OverridingClassLoader.java
deleted file mode 100644
index 8bdd917..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/loader/support/OverridingClassLoader.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.sandbox.loader.support;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * <p>A reloadable class loader implementation that you can use to forcefully reload classes
- * even if you don't want to recompile them and hence haven't got the actual .class file. Use
- * this class loader if you want to reload a class that depends on a dynamically compiled
- * class, for example, in case of Spring if you've got a factory bean constructing bean
- * instances of a dynamically compiled class. Once the dynamically compiled class changes,
- * the class of the factory bean has to be reloaded as well even though it somehow didn't
- * really change.</p>
- */
-public class OverridingClassLoader extends AbstractThrowAwayClassLoader {
-
- // ------------------------------------------ Constructors
-
- /**
- * <p>Constructs a new overriding class loader using the name of the class that
- * it's going to override and the parent class loader. Note that this class loader
- * only loads the class definition for the given class name. Otherwise it will
- * delegate to the parent class loader.</p>
- *
- * @param className the name of the class that it's going to override
- * @param parent the parent class loader
- */
- public OverridingClassLoader(String className, ClassLoader parent) {
- super(className, parent);
- }
-
- // ------------------------------------------ AbstractThrowAwayClassLoader methods
-
- /**
- * <p>Opens a stream to the resource that defines the given class using the parent
- * class loader. If it cannot be found, return <code>null</code>.</p>
- *
- * @param className the class to load
- * @return a stream to the resource that defines the given class
- * @throws IOException if an I/O error occurs
- */
- protected InputStream openStreamForClass(String className) throws IOException {
- return getParent().getResourceAsStream(className.replace('.', '/') + ".class");
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/loader/support/ThrowAwayClassLoader.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/loader/support/ThrowAwayClassLoader.java
deleted file mode 100644
index f9e7156..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/loader/support/ThrowAwayClassLoader.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.sandbox.loader.support;
-
-/**
- * <p>A class loader that implements this interface is able to throw away class definitions.
- * Well, to be more precise, no class loader is really able to do that, but you can get this
- * behaviour by just throwing away this class loader. Note that a class loader implementing
- * this interface is supposed to load just a single class definition, i.e. there's a 1:1
- * relationship between the class loader and the class. In doing so, we're somehow able to
- * throw away class definitions and replace them with newer versions.</p>
- */
-public interface ThrowAwayClassLoader {
-
- /**
- * <p>Loads the class with the specified class name. However, note that implementing
- * classes are just supposed to load a single class, so if you want to load a different
- * class than that, this class loader will just delegate to the parent class loader.</p>
- *
- * @param className the name of the class you want to load
- * @param resolve if <tt>true</tt> then resolve the class
- * @return the resulting Class reference
- * @throws ClassNotFoundException if the class could not be found
- */
- public Class loadClass(String className, boolean resolve) throws ClassNotFoundException;
-
- /**
- * <p>Returns <code>true</code> if the given "last modified"-timestamp is
- * more recent than the timestamp of this ClassLoader, i.e. if this ClassLoader
- * is to be destroyed as there is a newer class file available.
- *
- * @param lastModified the "last modified"-timestamp of the class file you want to load
- * @return <code>true</code> if the given "last modified"-timestamp is
- * more recent than the timestamp of this class loader
- */
- public boolean isOutdated(long lastModified);
-
-}
\ No newline at end of file
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/readme.txt b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/readme.txt
deleted file mode 100644
index 1d93dd7..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/sandbox/readme.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-This files are sandbox they will be merged over time into the core
-nothing of this code is used outside of package, but code
-parts will be recycled and once done the class is removed
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/servlet/ScriptingServletFilter.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/servlet/ScriptingServletFilter.java
deleted file mode 100644
index df5c3e9..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/servlet/ScriptingServletFilter.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.servlet;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.jsf.RefreshPhaseListener;
-
-import javax.servlet.*;
-import java.io.IOException;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.logging.Logger;
-
-/**
- * Scripting servlet filter
- * <p/>
- * hits the filter while the
- * init system is not entirely finished yet
- *
- * @author Werner Punz
- */
-public class ScriptingServletFilter implements Filter {
-
- ServletContext _context = null;
- static volatile boolean _active = false;
- static volatile boolean _warned = false;
-
- public void init(FilterConfig filterConfig) throws ServletException {
- _context = filterConfig.getServletContext();
- /*we cannot use the context listener here
- * because we have the problem that we do not want to parse the web.xml*/
- WeavingContext.setFilterEnabled(true);
- }
-
- public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
- assertInitialized();
- if (!_active) {
- filterChain.doFilter(servletRequest, servletResponse);
- return;
- }
- markRequestStart();
- WeavingContext.initThread(_context);
-
- WeavingContext.setRequest(servletRequest);
-
- WeavingContext.getRefreshContext().setCurrentlyRunningRequests(getRequestCnt());
-
- ScriptingServletFilter._action.run();
-
- try {
- filterChain.doFilter(servletRequest, servletResponse);
- } finally {
- markRequestEnd();
- }
- }
-
- static Runnable _action = new Runnable() {
- public void run() {
- WeavingContext.doRequestRefreshes();
- }
- };
-
- /**
- * Checks for an initialized system and if not the filter will be deactivated
- * <p/>
- * the idea is to check the context in regular intervals
- * whether the startup process has been finished and then
- * allow the requests to pass through
- */
- private void assertInitialized() {
- if (_active) return;
-
- AtomicBoolean startup = (AtomicBoolean) _context.getAttribute(ScriptingConst.CTX_ATTR_STARTUP);
- if (startup == null) {
- if (!_warned) {
- Logger log = Logger.getLogger(ScriptingServletFilter.class.getName());
- log.warning("[EXT-SCRIPTING] the Startup plugin chainloader has not been set, ext scripting is not working" +
- "please refer to the documentation for the org.apache.myfaces.FACES_INIT_PLUGINS parameter, deactivating servlet filter");
- _active = false;
- }
- } else {
- _active = !startup.get();
- }
- }
-
- public void destroy() {
-
- WeavingContext.clean();
- }
-
- //we mark the request beginning and end for further synchronisation issues
-
- private final AtomicInteger getRequestCnt() {
- AtomicInteger retVal = (AtomicInteger) _context.getAttribute(ScriptingConst.CTX_ATTR_REQUEST_CNT);
-
- return retVal;
- }
-
- private int markRequestStart() {
- return getRequestCnt().incrementAndGet();
- }
-
- private int markRequestEnd() {
- return getRequestCnt().decrementAndGet();
- }
-
-}
\ No newline at end of file
diff --git a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/servlet/StartupServletContextPluginChainLoader.java b/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/servlet/StartupServletContextPluginChainLoader.java
deleted file mode 100644
index 72ab5b0..0000000
--- a/extscript-core-root/extscript-core/src/main_old/java/org/apache/myfaces/extensions/scripting/servlet/StartupServletContextPluginChainLoader.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.servlet;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.Cast;
-import org.apache.myfaces.extensions.scripting.core.util.ClassUtils;
-import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.monitor.RefreshContext;
-import org.apache.myfaces.extensions.scripting.api.extensionevents.SystemInitializedEvent;
-import org.apache.myfaces.webapp.StartupListener;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletContextEvent;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.logging.Logger;
-
-/**
- * Note, since MyFaces 1.2.8 we have a startup and shutdown event system
- * which allows us to to hook event listener on servlet level before JSF is initialized
- * and after it is destroyed (and of course in the phases in between)
- * <p/>
- * We use this to start our scripting engine and to hook in our class loading
- * facilities before MyFaces performs its startup routines.
- *
- * @author Werner Punz
- */
-public class StartupServletContextPluginChainLoader implements StartupListener {
- final Logger _log = Logger.getLogger(this.getClass().getName());
-
- public void preInit(ServletContextEvent servletContextEvent) {
-
- _log.info("[EXT-SCRIPTING] Instantiating StartupServletContextPluginChainLoader");
-
- ServletContext servletContext = servletContextEvent.getServletContext();
- if (servletContext == null) return;
-
- servletContext.setAttribute(ScriptingConst.CTX_ATTR_REQUEST_CNT, new AtomicInteger(0));
- servletContext.setAttribute(ScriptingConst.CTX_ATTR_STARTUP, new AtomicBoolean(Boolean.TRUE));
-
- initContext(servletContext);
- initChainLoader(servletContext);
- String initialCompileAndScan = (String) servletContext.getInitParameter(ScriptingConst.INIT_PARAM_INITIAL_COMPILE);
- if(WeavingContext.isScriptingEnabled() && WeavingContext.getConfiguration().isInitialCompile()) {
- initCompileAndScan();
- } else if(!WeavingContext.getConfiguration().isInitialCompile()) {
- WeavingContext.getWeaver().markAsFullyRecompiled();
- }
- }
-
- private void initCompileAndScan() {
- if (WeavingContext.isScriptingEnabled()) {
- _log.info("[EXT-SCRIPTING] Compiling all sources for the first time");
- //WeavingContext.getWeaver().postStartupActions();
- WeavingContext.getWeaver().fullRecompile();
- }
- }
-
- /**
- * initializes our custom chain loader which gets plugged into
- * the MyFaces loading part for classes!
- *
- * @param servletContext the servlet context to be passed down
- * @return the custom chain loader for loading our classes over our classloaders
- */
- private void initChainLoader(ServletContext servletContext) {
- Object loader = ReflectUtil.instantiate("org.apache.myfaces.extensions.scripting.servlet.CustomChainLoader",
- new Cast(ServletContext.class, servletContext));
- ClassUtils.addClassLoadingExtension(loader, true);
- }
-
- /**
- * initializes the central config storage!
- *
- * @param servletContext the applications servlet context
- */
- private void initContext(ServletContext servletContext) {
- WeavingContext.startup(servletContext);
- }
-
- public void postInit(ServletContextEvent evt) {
- //tell the system that the startup phase is done
- WeavingContext.getWeaver().fullClassScan();
- evt.getServletContext().setAttribute(ScriptingConst.CTX_ATTR_STARTUP, new AtomicBoolean(Boolean.FALSE));
-
- WeavingContext.getExtensionEventRegistry().sendEvent(new SystemInitializedEvent());
- }
-
- public void preDestroy(ServletContextEvent evt) {
-
- }
-
- public void postDestroy(ServletContextEvent evt) {
- //context is destroyed we have to shut down our daemon as well, by giving it
- //a hint to shutdown
-
- //TODO this is probably not needed because we run in a daemon thread anyway
- //so the servlet should not have a problem to shut it down externally
- RefreshContext rContext = (RefreshContext) evt.getServletContext().getAttribute("RefreshContext");
- rContext.getDaemon().setRunning(false);
- }
-
-}
\ No newline at end of file
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/api/CompilationExceptionTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/api/CompilationExceptionTest.java
deleted file mode 100644
index def3d27..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/api/CompilationExceptionTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.api;
-
-import org.apache.myfaces.extensions.scripting.api.CompilationException;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- * dummy test for the class to have class level coverage
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class CompilationExceptionTest {
- private static final String ERR_MSG = "BlaMessage";
-
- @Test
- public void testCompilationException() {
- CompilationException ex = new CompilationException(ERR_MSG);
-
- assertTrue(ex.getMessage().equals(ERR_MSG));
-
- ex = new CompilationException(ERR_MSG, new NullPointerException(ERR_MSG));
- assertTrue(ex.getMessage().equals(ERR_MSG));
- assertTrue(ex.getCause() instanceof NullPointerException);
-
- ex = new CompilationException(new NullPointerException(ERR_MSG));
- assertTrue(ex.getCause() instanceof NullPointerException);
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/api/CompilationResultTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/api/CompilationResultTest.java
deleted file mode 100644
index c56fe96..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/api/CompilationResultTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.api;
-
-import org.apache.myfaces.extensions.scripting.api.CompilationResult;
-import org.junit.Before;
-import org.junit.Test;
-
-import static junit.framework.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class CompilationResultTest {
- CompilationResult result = null;
- private static final String BOOGA = "booga";
-
- @Before
- public void init() {
- result = new CompilationResult(BOOGA);
- }
-
- @Test
- public void testGetCompilerOutput() throws Exception {
- assertTrue(result.getCompilerOutput().equals(BOOGA));
- }
-
- @Test
- public void testHasErrors() throws Exception {
- assertFalse(result.hasErrors());
- result.getErrors().add(new CompilationResult.CompilationMessage(1, BOOGA));
- assertTrue(result.hasErrors());
- }
-
- @Test
- public void testRegisterError() throws Exception {
- assertFalse(result.hasErrors());
- result.registerError(new CompilationResult.CompilationMessage(1, BOOGA));
- assertTrue(result.hasErrors());
- }
-
- @Test
- public void testGetErrors() throws Exception {
- assertTrue(result.getErrors().isEmpty());
- result.registerError(new CompilationResult.CompilationMessage(1, BOOGA));
- result.registerError(null);
- assertFalse(result.getErrors().isEmpty());
- assertTrue(result.getErrors().size() == 1);
- result.registerError(new CompilationResult.CompilationMessage(1, BOOGA));
- result.registerError(null);
- assertTrue(result.getErrors().size() == 2);
-
- }
-
- @Test
- public void testRegisterWarning() throws Exception {
- assertTrue(result.getWarnings().isEmpty());
- result.registerWarning(new CompilationResult.CompilationMessage(1, BOOGA));
- result.registerWarning(null);
- assertFalse(result.getWarnings().isEmpty());
- assertTrue(result.getWarnings().size() == 1);
- result.registerWarning(new CompilationResult.CompilationMessage(1, BOOGA));
-
- assertFalse(result.getWarnings().isEmpty());
- assertTrue(result.getWarnings().size() == 2);
- assertTrue(result.getErrors().isEmpty());
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/api/CompilerConstTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/api/CompilerConstTest.java
deleted file mode 100644
index ac11ee9..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/api/CompilerConstTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.api;
-
-import org.apache.myfaces.extensions.scripting.api.CompilerConst;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- * Dummy test to avoid a build exclude
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class CompilerConstTest {
- @Test
- public void testDummy() {
- CompilerConst compilerConst = new CompilerConst();
- assertTrue(compilerConst != null);
- }
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/api/ScriptingConstTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/api/ScriptingConstTest.java
deleted file mode 100644
index 7889f62..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/api/ScriptingConstTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.api;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- * Dummy test to cover the scripting const for the stats
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ScriptingConstTest {
-
- @Test
- public void testScriptingConst() {
- new ScriptingConst();
- assertTrue(true);
- }
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/components/CompilerComponentTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/components/CompilerComponentTest.java
deleted file mode 100644
index 1985e6c..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/components/CompilerComponentTest.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.components;
-
-import org.apache.myfaces.extensions.scripting.components.CompilerComponent;
-import org.apache.myfaces.extensions.scripting.components.RendererConst;
-import org.apache.myfaces.extensions.scripting.components.CompilerComponentRenderer;
-import org.apache.myfaces.renderkit.html.HtmlFormRenderer;
-import org.apache.myfaces.extensions.scripting.api.CompilationResult;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.support.ContextUtils;
-import org.apache.myfaces.extensions.scripting.core.support.MockServletContext;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContextInitializer;
-import org.apache.myfaces.test.base.AbstractJsfTestCase;
-import org.apache.myfaces.test.mock.MockRenderKitFactory;
-import org.apache.myfaces.test.mock.MockResponseWriter;
-
-import javax.faces.component.html.HtmlForm;
-import javax.servlet.ServletContext;
-import java.io.StringWriter;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class CompilerComponentTest extends AbstractJsfTestCase {
-
- ServletContext context;
- private CompilerComponent _compilerComponent;
- private MockResponseWriter _writer;
- private static final String ERROR_LABEL = "Error:";
- private static final String JAVA = "java";
- private static final String WARNINGS_LABEL = "Warnings:";
- private static final String GROOVY = "groovy";
- private static final String BLANK = "";
- private static final String ERROR_1 = "1_error";
- private static final String ERROR_2 = "2_error";
- private static final String WARNING_1 = "1_warning";
- private static final String WARNING_2 = "2_warning";
- private static final String ATTR_WARNINGS_LABEL = "warningsLabel";
- private static final String ATTR_ERRORS_LABEL = "errorsLabel";
- private static final String ATTR_SCRIPTING_LANGUAGE = "scriptingLanguage";
- private static final String NO_COMPILE_ERRORS_FOUND = "no compile errors found";
- private static final String COMPILE_ERRORS_FOUND = "Compile errors found";
- private static final String BOOGA = "booga";
- private static final String OUTPUT = "output";
-
- public CompilerComponentTest() {
- super(CompilerComponentTest.class.getName());
- }
-
- public void setUp() throws Exception {
- super.setUp();
- context = ContextUtils.startupSystem();
-
- _writer = new MockResponseWriter(new StringWriter(), null, null);
-
- facesContext.setResponseWriter(_writer);
- _compilerComponent = new CompilerComponent();
- HtmlForm form = new HtmlForm();
- _compilerComponent.setParent(form);
-
- facesContext.getViewRoot().setRenderKitId(MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
- facesContext.getRenderKit().addRenderer(
- _compilerComponent.getFamily(),
- _compilerComponent.getRendererType(),
- new CompilerComponentRenderer());
- facesContext.getRenderKit().addRenderer(
- form.getFamily(),
- form.getRendererType(),
- new HtmlFormRenderer());
-
- _compilerComponent.setErrorsLabel(ERROR_LABEL);
- _compilerComponent.setScriptingLanguage(JAVA);
- _compilerComponent.setWarningsLabel(WARNINGS_LABEL);
-
- }
-
- public void testIsTransient() throws Exception {
- assertTrue(_compilerComponent.isTransient());
- }
-
- public void testSaveRestoreState() throws Exception {
- Object state = _compilerComponent.saveState(facesContext);
- _compilerComponent.setErrorsLabel(BLANK);
- _compilerComponent.setScriptingLanguage(BLANK);
- _compilerComponent.setWarningsLabel(BLANK);
- _compilerComponent.restoreState(facesContext, state);
-
- assertDefaultTestingValues();
- }
-
- private void assertDefaultTestingValues() {
- assertTrue(_compilerComponent.getErrorsLabel().equals(ERROR_LABEL));
- assertTrue(_compilerComponent.getScriptingLanguage().equals(JAVA));
- assertTrue(_compilerComponent.getWarningsLabel().equals(WARNINGS_LABEL));
- assertTrue(_compilerComponent.getScriptingLanguageAsInt().equals(ScriptingConst.ENGINE_TYPE_JSF_JAVA));
- }
-
- public void testScriptingLanguageAsInt() {
- assertTrue(_compilerComponent.getScriptingLanguageAsInt().equals(ScriptingConst.ENGINE_TYPE_JSF_JAVA));
- _compilerComponent.setScriptingLanguage(GROOVY);
- assertTrue(_compilerComponent.getScriptingLanguageAsInt().equals(ScriptingConst.ENGINE_TYPE_JSF_GROOVY));
- _compilerComponent.setScriptingLanguage(BLANK);
- assertTrue(_compilerComponent.getScriptingLanguageAsInt().equals(ScriptingConst.ENGINE_TYPE_JSF_ALL));
- _compilerComponent.setScriptingLanguage(BOOGA);
- assertTrue(_compilerComponent.getScriptingLanguageAsInt().equals(ScriptingConst.ENGINE_TYPE_JSF_NO_ENGINE));
- }
-
- public void testElPart() {
- _compilerComponent.setWarningsLabel(null);
- _compilerComponent.setErrorsLabel(null);
- _compilerComponent.setScriptingLanguage(null);
-
- _compilerComponent.getAttributes().put(ATTR_WARNINGS_LABEL, WARNINGS_LABEL);
- _compilerComponent.getAttributes().put(ATTR_ERRORS_LABEL, ERROR_LABEL);
- _compilerComponent.getAttributes().put(ATTR_SCRIPTING_LANGUAGE, JAVA);
-
- assertDefaultTestingValues();
- }
-
- public void testRendererNoErrorsAndWarnings() throws Exception {
- _compilerComponent.encodeAll(facesContext);
- facesContext.renderResponse();
- assertTrue(NO_COMPILE_ERRORS_FOUND, _writer.getWriter().toString().contains(RendererConst.NO_COMPILE_ERRORS));
- }
-
- public void testRendererNoErrorsAndWarnings2() throws Exception {
- _compilerComponent.setScriptingLanguage(GROOVY);
- _compilerComponent.encodeAll(facesContext);
- facesContext.renderResponse();
- assertTrue(NO_COMPILE_ERRORS_FOUND, _writer.getWriter().toString().contains(RendererConst.NO_COMPILE_ERRORS));
- }
-
- public void testRendererNoErrorsAndWarnings3() throws Exception {
- _compilerComponent.setScriptingLanguage(BLANK);
- _compilerComponent.encodeAll(facesContext);
- facesContext.renderResponse();
- assertTrue(NO_COMPILE_ERRORS_FOUND, _writer.getWriter().toString().contains(RendererConst.NO_COMPILE_ERRORS));
- }
-
- public void testRendererNoErrorsAndWarnings4() throws Exception {
- _compilerComponent.setScriptingLanguage(BOOGA);
- _compilerComponent.encodeAll(facesContext);
- facesContext.renderResponse();
- assertTrue(NO_COMPILE_ERRORS_FOUND, _writer.getWriter().toString().contains(RendererConst.NO_COMPILE_ERRORS));
- }
-
- public void testCompilationResultJava() throws Exception {
- CompilationResult result = getCompilationResult(JAVA);
-
- WeavingContext.setCompilationResult(ScriptingConst.ENGINE_TYPE_JSF_JAVA, result);
-
- _compilerComponent.encodeAll(facesContext);
- facesContext.renderResponse();
- assertStandardResponse(JAVA);
-
- }
-
- public void testEmptyLabels() throws Exception {
- _compilerComponent.setWarningsLabel("");
- _compilerComponent.setErrorsLabel("");
- CompilationResult result = getCompilationResult(JAVA);
-
- WeavingContext.setCompilationResult(ScriptingConst.ENGINE_TYPE_JSF_JAVA, result);
-
- _compilerComponent.encodeAll(facesContext);
- facesContext.renderResponse();
- String response = _writer.getWriter().toString();
-
- assertFalse(response.contains(WARNINGS_LABEL));
- assertFalse(response.contains(ERROR_LABEL));
-
- }
-
- private void assertStandardResponse(String prefix) {
- assertFalse(COMPILE_ERRORS_FOUND, _writer.getWriter().toString().contains(RendererConst.NO_COMPILE_ERRORS));
- assertTrue(COMPILE_ERRORS_FOUND, _writer.getWriter().toString().contains(ERROR_LABEL));
-
- String response = _writer.getWriter().toString();
- assertTrue(response.contains(WARNINGS_LABEL));
- assertTrue(response.contains(prefix + ERROR_1));
- assertTrue(response.contains(prefix + ERROR_2));
- assertTrue(response.contains(prefix + WARNING_1));
- assertTrue(response.contains(prefix + WARNING_2));
- }
-
- public void testCompilationResultGroovy() throws Exception {
- CompilationResult result = getCompilationResult(GROOVY);
-
- WeavingContext.setCompilationResult(ScriptingConst.ENGINE_TYPE_JSF_JAVA, result);
-
- _compilerComponent.encodeAll(facesContext);
- _compilerComponent.setScriptingLanguage(GROOVY);
- facesContext.renderResponse();
- assertStandardResponse(GROOVY);
-
- }
-
- public void testCompilationResultAll() throws Exception {
- CompilationResult result = getCompilationResult(JAVA);
-
- WeavingContext.setCompilationResult(ScriptingConst.ENGINE_TYPE_JSF_JAVA, result);
- result = getCompilationResult(GROOVY);
- WeavingContext.setCompilationResult(ScriptingConst.ENGINE_TYPE_JSF_GROOVY, result);
-
- _compilerComponent.setScriptingLanguage("");
- _compilerComponent.encodeAll(facesContext);
- facesContext.renderResponse();
- assertStandardResponse(JAVA);
- assertStandardResponse(GROOVY);
-
- }
-
- private CompilationResult getCompilationResult(String prefix) {
- CompilationResult result = new CompilationResult(OUTPUT);
-
- result.getErrors().add(new CompilationResult.CompilationMessage(1, prefix + ERROR_1));
- result.getErrors().add(new CompilationResult.CompilationMessage(2, prefix + ERROR_2));
-
- result.getWarnings().add(new CompilationResult.CompilationMessage(1, prefix + WARNING_1));
- result.getWarnings().add(new CompilationResult.CompilationMessage(2, prefix + WARNING_2));
- return result;
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/components/RendererConstTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/components/RendererConstTest.java
deleted file mode 100644
index 9ebbe4a..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/components/RendererConstTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.components;
-
-import org.apache.myfaces.extensions.scripting.components.RendererConst;
-import org.junit.Test;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class RendererConstTest {
-
- @Test
- public void testDummy() {
- //dummy test case to remove the 0% Cobertura stat on the renderer const class
- new RendererConst();
- }
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/components/TaintHistoryTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/components/TaintHistoryTest.java
deleted file mode 100644
index c905b4b..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/components/TaintHistoryTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.components;
-
-import org.apache.myfaces.extensions.scripting.monitor.ClassResource;
-import org.apache.myfaces.extensions.scripting.monitor.RefreshAttribute;
-import org.apache.myfaces.renderkit.html.HtmlFormRenderer;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.support.ContextUtils;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.test.base.AbstractJsfTestCase;
-import org.apache.myfaces.test.mock.MockRenderKitFactory;
-import org.apache.myfaces.test.mock.MockResponseWriter;
-
-import javax.faces.component.html.HtmlForm;
-import javax.servlet.ServletContext;
-import java.io.File;
-import java.io.StringWriter;
-
-/**
- * Test cases for the taint history component and renderer
- * (note the filter attribute currently is not yet
- * tested for semantic usage because we don't have it implemented yet)
- *
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class TaintHistoryTest extends AbstractJsfTestCase {
-
- ServletContext context;
- private TaintHistory _taintHistory;
- private TaintHistoryRenderer _taintHistoryRenderer;
- private HtmlForm _form;
- private MockResponseWriter _writer;
- private static final String VAL_FILTER = "bla";
- private static final String NO_TAINT_HISTORY_FOUND = "no taint history found";
- private static final String BOOGA_JAVA = "booga.java";
- private static final String TAINT_HISTORY_FOUND = "taint history found";
- private static final String ATTR_NO_ENTRIES = "noEntries";
- private static final String ATTR_FILTER = "filter";
-
- public TaintHistoryTest() {
- super(TaintHistoryTest.class.getName());
- }
-
- public void setUp() throws Exception {
- super.setUp();
- context = ContextUtils.startupSystem();
-
- _writer = new MockResponseWriter(new StringWriter(), null, null);
-
- facesContext.setResponseWriter(_writer);
- _taintHistory = new TaintHistory();
- _form = new HtmlForm();
- _taintHistory.setParent(_form);
-
- facesContext.getViewRoot().setRenderKitId(MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
- facesContext.getRenderKit().addRenderer(
- _taintHistory.getFamily(),
- _taintHistory.getRendererType(),
- new TaintHistoryRenderer());
- facesContext.getRenderKit().addRenderer(
- _form.getFamily(),
- _form.getRendererType(),
- new HtmlFormRenderer());
-
- }
-
- public void testNoTaintHistory() throws Exception {
- _taintHistory.encodeAll(facesContext);
- facesContext.renderResponse();
- assertTrue(NO_TAINT_HISTORY_FOUND, _writer.getWriter().toString().contains(RendererConst.NO_TAINT_HISTORY_FOUND));
- }
-
- public void testTaintHistory() throws Exception {
- ClassResource historyEntry = new ClassResource();
- historyEntry.setAClass(this.getClass());
- historyEntry.getRefreshAttribute().requestRefresh();
- historyEntry.getRefreshAttribute().executedRefresh();
- historyEntry.setScriptingEngine(ScriptingConst.ENGINE_TYPE_JSF_JAVA);
- historyEntry.setFile(new File(BOOGA_JAVA));
- historyEntry.getRefreshAttribute().requestRefresh();
- //historyEntry.setTaintedOnce(true);
- WeavingContext.getRefreshContext().addTaintLogEntry(historyEntry);
-
- _taintHistory.encodeAll(facesContext);
- facesContext.renderResponse();
- assertFalse(TAINT_HISTORY_FOUND, _writer.getWriter().toString().contains(RendererConst.NO_TAINT_HISTORY_FOUND));
-
- assertTrue(_writer.getWriter().toString().contains(BOOGA_JAVA));
- }
-
- public void testSaveRestore() {
- _taintHistory.setFilter(VAL_FILTER);
- _taintHistory.setNoEntries(10);
- Object state = _taintHistory.saveState(facesContext);
- _taintHistory.setFilter("");
- _taintHistory.setNoEntries(0);
- _taintHistory.restoreState(facesContext, state);
-
- assertTrue(_taintHistory.getFilter().equals(VAL_FILTER));
-
- assertTrue(_taintHistory.getNoEntries().equals(10));
-
- }
-
- public void testNoEntries() throws Exception {
- int noEntries = 10;
- for (int cnt = 0; cnt < 100; cnt++) {
- ClassResource historyEntry = new ClassResource();
- historyEntry.setAClass(this.getClass());
- historyEntry.getRefreshAttribute().executedRefresh();
- historyEntry.setScriptingEngine(ScriptingConst.ENGINE_TYPE_JSF_JAVA);
- if(cnt < 10)
- historyEntry.setFile(new File("0"+cnt + "_"+BOOGA_JAVA));
- else
- historyEntry.setFile(new File(cnt + "_"+BOOGA_JAVA));
- historyEntry.getRefreshAttribute().requestRefresh();
- //historyEntry.setTaintedOnce(true);
- WeavingContext.getRefreshContext().addTaintLogEntry(historyEntry);
- }
-
- _taintHistory.setNoEntries(10);
- _taintHistory.encodeAll(facesContext);
- facesContext.renderResponse();
-
- assertTrue(_writer.getWriter().toString().contains("99_"+BOOGA_JAVA));
- assertFalse(_writer.getWriter().toString().contains("89_"+BOOGA_JAVA));
- assertFalse(_writer.getWriter().toString().contains("00_"+BOOGA_JAVA));
- }
-
- public void testElAttributes() {
- assertTrue(_taintHistory.getFilter() == null);
- assertTrue(_taintHistory.getNoEntries().equals(TaintHistory.DEFAULT_NO_ENTRIES));
- _taintHistory.setNoEntries(null);
-
- _taintHistory.getAttributes().put(ATTR_NO_ENTRIES, 20);
- _taintHistory.getAttributes().put(ATTR_FILTER, VAL_FILTER);
-
- assertTrue(_taintHistory.getNoEntries() == 20);
- assertTrue(_taintHistory.getFilter().equals(VAL_FILTER));
- }
-
-}
-
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/MethodLevelReloadingHandlerTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/MethodLevelReloadingHandlerTest.java
deleted file mode 100644
index 610fb7c..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/MethodLevelReloadingHandlerTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core;
-
-import org.apache.myfaces.extensions.scripting.core.MethodLevelReloadingHandler;
-import org.apache.myfaces.extensions.scripting.api.BaseWeaver;
-import org.apache.myfaces.extensions.scripting.api.DynamicCompiler;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.probes.MethodReloadingProbe;
-import org.apache.myfaces.extensions.scripting.core.probes.Probe;
-import org.apache.myfaces.extensions.scripting.core.support.ObjectReloadingWeaver;
-import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.junit.Before;
-import org.junit.Test;
-
-import static junit.framework.Assert.assertTrue;
-
-/**
- * TestCase for our method level reloading handler
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class MethodLevelReloadingHandlerTest {
-
- MethodReloadingProbe _probe;
- private static final String MSG_REPLACED = "objects must be replaced";
-
-
- /**
- * Before
- */
- @Before
- public void init() {
- WeavingContext.setWeaver(new ObjectReloadingWeaver(Probe.class));
- _probe = new Probe();
- }
-
- @Test
- public void testInvoke() throws Exception {
- MethodLevelReloadingHandler handler = new MethodLevelReloadingHandler(_probe, ScriptingConst.ARTIFACT_TYPE_PHASELISTENER);
-
- ReflectUtil.executeMethod(handler, "testMethod1");
- assertTrue(MSG_REPLACED, handler.getDelegate() != _probe && handler.getDelegate() != null);
- Object secondObject = handler.getDelegate();
- Boolean retVal = (Boolean) ReflectUtil.executeMethod(handler, "testMethod3", "true");
- assertTrue(retVal);
- assertTrue(MSG_REPLACED, handler.getDelegate() != secondObject && handler.getDelegate() != null);
-
- }
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/classIdentifier/DynamicClassloader.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/classIdentifier/DynamicClassloader.java
deleted file mode 100644
index 2304bea..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/classIdentifier/DynamicClassloader.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.classIdentifier;
-
-import org.apache.myfaces.extensions.scripting.core.support.Consts;
-import org.apache.myfaces.extensions.scripting.sandbox.loader.support.ThrowAwayClassLoader;
-import org.apache.myfaces.extensions.scripting.core.util.ClassUtils;
-import org.apache.myfaces.extensions.scripting.loaders.java.JavaThrowAwayClassloader;
-
-import java.io.File;
-import java.io.FileInputStream;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * A classloader implementing our throwaway classloader interface
- * the new detection algorithm depends on the classloader
- * instead of runtime alteration of the classes to attach
- * an interface
- */
-@JavaThrowAwayClassloader
-public class DynamicClassloader extends ClassLoader implements ThrowAwayClassLoader {
- String _rootPath = "";
-
- public DynamicClassloader(ClassLoader classLoader, String rootPath) {
- super(classLoader);
- _rootPath = rootPath;
- }
-
- public Class loadClass(String className, boolean resolve) throws ClassNotFoundException {
-
- if (className.contains(Consts.JAVA_LANG)) {
- return super.loadClass(className, resolve);
- }
-
- File classFile = ClassUtils.classNameToFile(_rootPath, className);
- assertClassfile(className, classFile);
-
- FileInputStream iStream = null;
- int fileLength = (int) classFile.length();
- byte[] fileContent = new byte[fileLength];
-
- try {
- iStream = new FileInputStream(classFile);
- iStream.read(fileContent);
-
- //we have to do it here because just in case
- //a dependend class is loaded as well we run into classcast exceptions
- return super.defineClass(className, fileContent, 0, fileLength);
-
- } catch (Exception e) {
- throw new ClassNotFoundException(e.toString());
- } finally {
- if (iStream != null) {
- try {
- iStream.close();
- } catch (Exception e) {
- }
- }
- }
- }
-
- private void assertClassfile(String className, File classFile) throws ClassNotFoundException {
- if (!classFile.exists()) {
- throw new ClassNotFoundException(className + " not found");
- }
- }
-
- public boolean isOutdated(long lastModified) {
- return false;
- }
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/classIdentifier/JavaDynamicClassIdentifierTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/classIdentifier/JavaDynamicClassIdentifierTest.java
deleted file mode 100644
index f52b2ec..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/classIdentifier/JavaDynamicClassIdentifierTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.classIdentifier;
-
-import org.apache.myfaces.extensions.scripting.core.CoreWeaver;
-import org.apache.myfaces.extensions.scripting.core.support.Consts;
-import org.apache.myfaces.extensions.scripting.core.support.TWeavingContext;
-import org.apache.myfaces.extensions.scripting.loaders.java.JavaScriptingWeaver;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.net.URL;
-
-import static org.junit.Assert.*;
-
-/**
- * @author werpu
- */
-public class JavaDynamicClassIdentifierTest {
-
- Object probe1 = null;
- Object probe2 = null;
- CoreWeaver weaver = null;
- private static final String CLASS_SHOULD_BE_STATIC = "Class should be static";
- private static final String CLASS_SHOULD_BE_DYNAMIC = "Class should be dynamic";
-
- @Before
- public void setUp() {
-
- probe1 = new Probe1();
- URL rootPath = this.getClass().getClassLoader().getResource(".");
-
- DynamicClassloader throwAwayClassloader = new DynamicClassloader(this.getClass().getClassLoader(), rootPath.getPath());
-
- try {
- probe2 = throwAwayClassloader.loadClass(Consts.PROBE2, false).newInstance();
- } catch (Throwable e) {
- fail(e.getMessage());
- }
-
- weaver = new CoreWeaver(new JavaScriptingWeaver());
- TWeavingContext.setScriptingEnabled(true);
- TWeavingContext.setWeaverForTesting(weaver);
- }
-
- @Test
- public void isStatic() {
- assertFalse(CLASS_SHOULD_BE_STATIC, TWeavingContext.isDynamic(probe1.getClass()));
- }
-
- @Test
- public void isDynamic() {
- assertTrue(CLASS_SHOULD_BE_DYNAMIC, TWeavingContext.isDynamic(probe2.getClass()));
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/classIdentifier/Probe1.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/classIdentifier/Probe1.java
deleted file mode 100644
index 311040b..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/classIdentifier/Probe1.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.classIdentifier;
-
-/**
- * @author werpu
- * probe for our unit test
- */
-public class Probe1 {
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/classIdentifier/Probe2.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/classIdentifier/Probe2.java
deleted file mode 100644
index df6addd..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/classIdentifier/Probe2.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.classIdentifier;
-
-/**
- * @author werpu
- */
-public class Probe2 {
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/compilerTest/GroovyCompilerTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/compilerTest/GroovyCompilerTest.java
deleted file mode 100644
index b300499..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/compilerTest/GroovyCompilerTest.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.compilerTest;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.myfaces.extensions.scripting.api.CompilationException;
-import org.apache.myfaces.extensions.scripting.api.CompilationResult;
-import org.apache.myfaces.extensions.scripting.api.Configuration;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-import org.apache.myfaces.extensions.scripting.core.util.FileUtils;
-import org.apache.myfaces.extensions.scripting.loaders.groovy.compiler.GroovyCompiler;
-import org.junit.Test;
-
-import java.io.File;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/**
- * Another testcase for the groovy compiler which
- * picks up the probes given in src/main/resources
- * <p/>
- * the advantage over our old groovy compiler testcase simply
- * is that the probes are separate files which already exist
- * the pattern already works on java files so it ought to work
- * on groovy files as well
- */
-
-public class GroovyCompilerTest {
-
- private static final String PROBE1 = "../../src/test/resources/compiler/TestProbe1Groovy.groovy";
- private static final String PROBE2 = "../../src/test/resources/compiler/TestProbe2Groovy.groovy";
- private static final String RESOURCES = "../../src/test/resources/";
-
- File probe1;
- File probe2;
- File root;
-
- GroovyCompiler compiler = new GroovyCompiler();
- private static final String RESULT_HAS_NO_ERRORS = "result has no errors";
- private static final String TARGET_DIR_EXISTS = "targetDir exists files are compiled into the targetDir";
- private static final String CLASSFILE1_IS_COMPILED = "Classfile1 is compiled into the targetDir";
- private static final String CLASSFILE1_IS_COMPILED1 = "Classfile1 is compiled into the target";
- private static final String CLASSFILE2_IS_COMPILED = "Classfile2 is compiled into the target";
-
- public GroovyCompilerTest() {
- //we use a location relative to our current root one to reach the sources
- //because the test also has to be performed outside of maven
- //and the ide cannot cope with resource paths for now
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
-
- String currentPath = loader.getResource("./").getPath();
- String sourcePath1 = currentPath + PROBE1;
- String sourcePath2 = currentPath + PROBE2;
- String rootPath = currentPath + RESOURCES;
-
- sourcePath1 = FilenameUtils.normalize(sourcePath1);
- sourcePath2 = FilenameUtils.normalize(sourcePath2);
- rootPath = FilenameUtils.normalize(rootPath);
-
- probe1 = new File(sourcePath1);
- probe2 = new File(sourcePath2);
- root = new File(rootPath);
-
- WeavingContext.setConfiguration(new Configuration());
- WeavingContext.getConfiguration().addSourceDir(ScriptingConst.ENGINE_TYPE_JSF_GROOVY, root.getAbsolutePath());
- }
-
- @Test
- public void testCompileSingleFile() {
-
- try {
- File targetDir = FileUtils.getTempDir();
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- targetDir.mkdirs();
- targetDir.deleteOnExit();
- File sourceFile = new File(root.getAbsolutePath() + File.separator + "compiler" + File.separator + "TestProbe1Groovy.groovy");
-
- CompilationResult result = null;
-
- result = compiler.compile(root, targetDir, sourceFile, loader);
-
- assertTrue(RESULT_HAS_NO_ERRORS, !result.hasErrors());
-
- assertTrue(TARGET_DIR_EXISTS, targetDir != null);
- File classFile1 = new File(targetDir.getAbsolutePath() + "/compiler/TestProbe1Groovy.class");
-
- assertTrue(CLASSFILE1_IS_COMPILED, classFile1.exists());
-
- } catch (CompilationException e) {
- fail(e.toString());
- }
- }
-
-
- @Test
- public void testFullCompileWhitelist() {
- File targetDir = null;
-
- File target = FileUtils.getTempDir();
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- target.mkdirs();
- target.deleteOnExit();
-
- WeavingContext.getConfiguration().addWhitelistPackage("compiler.myPackage");
-
- CompilationResult result = compiler.compile(root, target, loader);
-
- assertTrue(RESULT_HAS_NO_ERRORS, !result.hasErrors());
-
- assertTrue("target exists files are compiled into the target", target != null);
- File classFile1 = new File(target.getAbsolutePath() + "/compiler/TestProbe1Groovy.class");
- File classFile2 = new File(target.getAbsolutePath() + "/compiler/TestProbe2Groovy.class");
- File classFile3 = new File(target.getAbsolutePath() + "/compiler/myPackage/WhiteListedProbeGroovy.class");
-
- assertTrue(CLASSFILE1_IS_COMPILED1, !classFile1.exists());
- assertTrue(CLASSFILE2_IS_COMPILED, !classFile2.exists());
- assertTrue(CLASSFILE2_IS_COMPILED, classFile3.exists());
-
- }
-
- @Test
- public void testFullCompile() {
- File targetDir = null;
-
- File target = FileUtils.getTempDir();
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- target.mkdirs();
- target.deleteOnExit();
-
- CompilationResult result = compiler.compile(root, target, loader);
-
- assertTrue(RESULT_HAS_NO_ERRORS, !result.hasErrors());
-
- assertTrue(TARGET_DIR_EXISTS, target != null);
- File classFile1 = new File(target.getAbsolutePath() + "/compiler/TestProbe1Groovy.class");
- File classFile2 = new File(target.getAbsolutePath() + "/compiler/TestProbe2Groovy.class");
-
- assertTrue(CLASSFILE1_IS_COMPILED1, classFile1.exists());
- assertTrue(CLASSFILE2_IS_COMPILED, classFile2.exists());
-
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/compilerTest/TestCompilerAPI.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/compilerTest/TestCompilerAPI.java
deleted file mode 100644
index 8501bdb..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/compilerTest/TestCompilerAPI.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.compilerTest;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.FilenameUtils;
-import org.apache.myfaces.extensions.scripting.api.Configuration;
-import org.apache.myfaces.extensions.scripting.api.DynamicCompiler;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.support.ContextUtils;
-import org.apache.myfaces.extensions.scripting.core.support.PathUtils;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.loaders.java.compiler.CompilerFacade;
-import org.junit.Test;
-
-import java.io.File;
-import java.io.IOException;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class TestCompilerAPI {
-
- private static final String JAVA_FILE_ENDING = ".java";
-
- private static final PathUtils _pathUtils = new PathUtils();
- private static final String PROBE1 = _pathUtils.getResource("compiler/TestProbe1.java");
- private static final String PROBE2 = _pathUtils.getResource("compiler/TestProbe2.java");
- private static final String RESOURCES = _pathUtils.getResource(".");
-
- private static final String CLASSFILE1_IS_COMPILED = "Class file1 is compiled into the target";
- private static final String CLASSFILE2_IS_COMPILED = "Class file2 is compiled into the target";
- private static final String TARGET_EXISTS = "target exists files are compiled into the target";
- private static final String CLASSFILE_1_IS_NOT_COMPILED = "Class file_1 is not compiled into the target";
- private static final String CLASSFILE_2_IS_NOT_COMPILED = "Class file_2 is not compiled into the target";
- private static final String CLASSFILE_3_IS_COMPILED = "Class file_3 is compiled into the target";
-
- File _probe1;
- File _probe2;
- File _root;
-
- public TestCompilerAPI() {
- String sourcePath1 = PROBE1;
- String sourcePath2 = PROBE2;
- String rootPath = RESOURCES;
-
- sourcePath1 = FilenameUtils.normalize(sourcePath1);
- sourcePath2 = FilenameUtils.normalize(sourcePath2);
- rootPath = FilenameUtils.normalize(rootPath);
-
- _probe1 = new File(sourcePath1);
- _probe2 = new File(sourcePath2);
- _root = new File(rootPath);
-
- WeavingContext.setConfiguration(new Configuration());
- WeavingContext.getConfiguration().addSourceDir(ScriptingConst.ENGINE_TYPE_JSF_JAVA, _root.getAbsolutePath());
- }
-
- @Test
- public void testDummy() {
-
- }
-
- @Test
- public void testWhiteListedCompile() {
- //WeavingContext.getConfiguration().getWhitelistedSourceDirs(ScriptingConst.ENGINE_TYPE_JSF_JAVA).clear();
- WeavingContext.getConfiguration().addWhitelistPackage("compiler.myPackage");
-
- try {
-
- /*DynamicCompiler compiler = (DynamicCompiler) new CompilerFacade(false);//new ReflectCompilerFacade();
- try {
- FileUtils.deleteDirectory(WeavingContext.getConfiguration().getCompileTarget());
- } catch (IOException e) {
- fail(e.getMessage());
- }
- WeavingContext.getConfiguration().getCompileTarget().mkdirs();
-
- File target = compiler.compileAllFiles(_root.getAbsolutePath(), "");
- */
- File target = ContextUtils.doJavaRecompile(_root.getAbsolutePath());
-
- assertTrue(TARGET_EXISTS, target != null);
- File classFile1 = new File(target.getAbsolutePath() + "/compiler/TestProbe1.class");
- File classFile2 = new File(target.getAbsolutePath() + "/compiler/TestProbe2.class");
- File classFile3 = new File(target.getAbsolutePath() + "/compiler/myPackage/WhiteListedProbe.class");
-
- assertTrue(CLASSFILE_1_IS_NOT_COMPILED, !classFile1.exists());
- assertTrue(CLASSFILE_2_IS_NOT_COMPILED, !classFile2.exists());
- assertTrue(CLASSFILE_3_IS_COMPILED, classFile3.exists());
-
- } catch (ClassNotFoundException e) {
- fail(e.toString());
- }
-
- }
-
- @Test
- public void testFullCompile() {
- File targetDir = null;
- try {
-
- DynamicCompiler compiler = (DynamicCompiler) new CompilerFacade(false);//new ReflectCompilerFacade();
-
- File target = compiler.compileAllFiles(_root.getAbsolutePath(), "");
-
- assertTrue(TARGET_EXISTS, target != null);
- File classFile1 = new File(target.getAbsolutePath() + "/compiler/TestProbe1.class");
- File classFile2 = new File(target.getAbsolutePath() + "/compiler/TestProbe2.class");
-
- assertTrue(CLASSFILE1_IS_COMPILED, classFile1.exists());
- assertTrue(CLASSFILE2_IS_COMPILED, classFile2.exists());
- } catch (ClassNotFoundException e) {
- fail(e.toString());
- }
- }
-
-}
\ No newline at end of file
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/DependencyScannerTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/DependencyScannerTest.java
deleted file mode 100644
index db31dfc..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/DependencyScannerTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.StandardDependencyScanner;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.core.ClassDependencies;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.filter.WhitelistFilter;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.registry.DependencyRegistryImpl;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.registry.ExternalFilterDependencyRegistry;
-import org.junit.Test;
-
-import java.util.logging.Logger;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-public class DependencyScannerTest {
-
- Logger log = Logger.getLogger(DependencyScannerTest.class.getName());
-
- private static final String PROBE1 = "org.apache.myfaces.extensions.scripting.core.dependencyScan.probes.Probe";
- private static final String PROBE2 = "org.apache.myfaces.extensions.scripting.core.dependencyScan.probes.Probe2";
- private static final String PROBE3 = "org.apache.myfaces.extensions.scripting.core.dependencyScan.probes.Probe3";
- private static final String PROBE4 = "org.apache.myfaces.extensions.scripting.core.dependencyScan.probes.Probe4";
- private static final String GENERICS_PROBE = "org.apache.myfaces.extensions.scripting.core.dependencyScan.probes.GenericsProbe";
-
- private static final String PROBE_PAR = "org.apache.myfaces.extensions.scripting.core.dependencyScan.probes.ProbeParent";
- private static final String DUMMY = "org.apache.xxx";
- private static final String PROBE_NAMESPACE = "org.apache.myfaces.extensions.scripting.core.dependencyScan";
-
- /**
- * Basic dependency scanning test, which tests
- * for basic intra class relationships
- */
- @Test
- public void testClassDependencies2() {
- ClassDependencies dependencyMap = new ClassDependencies();
- ExternalFilterDependencyRegistry testRegistry = new DependencyRegistryImpl(ScriptingConst.ENGINE_TYPE_JSF_JAVA, dependencyMap);
- testRegistry.addFilter(new WhitelistFilter(DUMMY, PROBE_NAMESPACE));
- long before = System.currentTimeMillis();
- (new StandardDependencyScanner()).fetchDependencies(Thread.currentThread().getContextClassLoader(), ScriptingConst.ENGINE_TYPE_JSF_JAVA, PROBE1, testRegistry);
- long after = System.currentTimeMillis();
- log.info("Execution time registry based scan" + (after - before));
-
- assertTrue("Dependency Test1", dependencyMap.getReferringClasses(PROBE2).contains(PROBE1));
- assertTrue("Dependency Test2", dependencyMap.getReferringClasses(PROBE3).contains(PROBE1));
- assertTrue("Dependency Test3", dependencyMap.getReferringClasses(PROBE4).contains(PROBE1));
- assertTrue("Dependency Test4", dependencyMap.getReferringClasses(PROBE_PAR).contains(PROBE1));
-
- }
-
- /**
- * Test for
- * https://issues.apache.org/jira/browse/EXTSCRIPT-70
- */
- @Test
- public void testGenerics() {
- ClassDependencies dependencyMap = new ClassDependencies();
- ExternalFilterDependencyRegistry testRegistry = new DependencyRegistryImpl(ScriptingConst.ENGINE_TYPE_JSF_JAVA, dependencyMap);
- testRegistry.addFilter(new WhitelistFilter(DUMMY, PROBE_NAMESPACE));
- long before = System.currentTimeMillis();
- (new StandardDependencyScanner()).fetchDependencies(Thread.currentThread().getContextClassLoader(), ScriptingConst.ENGINE_TYPE_JSF_JAVA, GENERICS_PROBE, testRegistry);
- long after = System.currentTimeMillis();
- log.info("Execution time registry based scan" + (after - before));
-
- assertTrue("GenericsDependencyTest 1", dependencyMap.getReferringClasses(PROBE1).contains(GENERICS_PROBE));
- assertTrue("GenericsDependencyTest 2", dependencyMap.getReferringClasses(PROBE2).contains(GENERICS_PROBE));
- }
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/FilterTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/FilterTest.java
deleted file mode 100644
index 12fa2bc..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/FilterTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.apache.myfaces.extensions.scripting.core.dependencyScan;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.filter.StandardNamespaceFilter;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.filter.WhitelistFilter;
-import org.junit.Test;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class FilterTest {
-
- @Test
- public void testStandardNamespace() {
- StandardNamespaceFilter filter = new StandardNamespaceFilter();
-
- assertFalse("Standard namespace is not allowed", filter.isAllowed(ScriptingConst.ENGINE_TYPE_JSF_JAVA, "java.lang.String"));
- assertTrue("Non Standard namespace is not allowed", filter.isAllowed(ScriptingConst.ENGINE_TYPE_JSF_JAVA, "booga.looga"));
- }
-
- @Test
- public void testWhiteList() {
- List<String> whiteList = new LinkedList<String>();
- whiteList.add("com.booga.booga1");
- whiteList.add("booga2");
-
- WhitelistFilter filter = new WhitelistFilter(whiteList);
- assertTrue("Whitelist test 1", filter.isAllowed(ScriptingConst.ENGINE_TYPE_JSF_JAVA, "com.booga"));
- assertTrue("Whitelist test 2", filter.isAllowed(ScriptingConst.ENGINE_TYPE_JSF_JAVA, "com.booga.booga1"));
- assertTrue("Whitelist test 3", filter.isAllowed(ScriptingConst.ENGINE_TYPE_JSF_JAVA, "booga2"));
-
- assertFalse("Whitelist test 4", filter.isAllowed(ScriptingConst.ENGINE_TYPE_JSF_JAVA, "com.booga1"));
- assertFalse("Whitelist test 5", filter.isAllowed(ScriptingConst.ENGINE_TYPE_JSF_JAVA, "org.booga1"));
- assertFalse("Whitelist test 6", filter.isAllowed(ScriptingConst.ENGINE_TYPE_JSF_JAVA, "aaa"));
-
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ClassScanUtilsTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ClassScanUtilsTest.java
deleted file mode 100644
index 9c99729..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ClassScanUtilsTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.core;
-
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.core.ClassScanUtils;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ClassScanUtilsTest {
-
- @Test
- public void testIsStandardNamespace() throws Exception {
- new ClassScanUtils();//to reduce the dummy line coverage
- assertTrue(ClassScanUtils.isStandardNamespace("java.lang.String"));
- assertTrue(ClassScanUtils.isStandardNamespace("javax.faces"));
- assertTrue(ClassScanUtils.isStandardNamespace("com.sun"));
- assertTrue(ClassScanUtils.isStandardNamespace("org.jboss"));
- assertTrue(ClassScanUtils.isStandardNamespace("org.junit"));
- assertTrue(ClassScanUtils.isStandardNamespace("org.netbeans"));
- assertTrue(ClassScanUtils.isStandardNamespace("groovy.lang"));
- assertTrue(ClassScanUtils.isStandardNamespace("scala.lang"));
- assertTrue(ClassScanUtils.isStandardNamespace("org.springframework"));
- assertTrue(ClassScanUtils.isStandardNamespace("org.eclipse"));
- assertFalse(ClassScanUtils.isStandardNamespace("org.myproject"));
- assertFalse(ClassScanUtils.isStandardNamespace("groovy"));
- }
-
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes/GenericsProbe.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes/GenericsProbe.java
deleted file mode 100644
index b469aa9..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes/GenericsProbe.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.probes;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-@SuppressWarnings("unused")//used by dynamic instantiation
-public class GenericsProbe {
- Set<Probe> _testProbe = new HashSet<Probe>();
-
- public Set<Probe> getTestProbe() {
- return _testProbe;
- }
-
- public void setTestProbe(Set<Probe> testProbe) {
- Collection<Probe2> mySet = new HashSet<Probe2>();
- System.out.println(mySet.size());
- _testProbe = testProbe;
- }
-
-
- public void setTestProbe3() {
- System.out.println("boogaloo");
- }
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes/Probe.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes/Probe.java
deleted file mode 100644
index 1ffd717..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes/Probe.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.probes;
-
-import org.junit.Ignore;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * Probe for class scanning
- */
-@Ignore
-public class Probe extends ProbeParent {
- String prop1;
-
- public static int myTest(StringBuilder myBuilder, Object val2) {
- return (Integer) 1;
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes/Probe2.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes/Probe2.java
deleted file mode 100644
index 8f3de6c..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes/Probe2.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.probes;
-
-import org.junit.Ignore;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-@Ignore
-public interface Probe2 {
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes/Probe3.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes/Probe3.java
deleted file mode 100644
index 4cb35c3..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes/Probe3.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.probes;
-
-import org.junit.Ignore;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-@Ignore
-public interface Probe3 {
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes/Probe4.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes/Probe4.java
deleted file mode 100644
index 9c16748..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes/Probe4.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.probes;
-
-import org.junit.Ignore;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-@Ignore
-public class Probe4 {
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes/ProbeParent.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes/ProbeParent.java
deleted file mode 100644
index ae261f2..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes/ProbeParent.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.probes;
-
-import org.junit.Ignore;
-
-/**
- * Testing probe for inheritance dependency checks
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-@Ignore
-public class ProbeParent {
- public Object myTest2(Object parm) {
- try {
- Probe4[] probes = new Probe4[1];
- return (Probe2) parm;
- } catch (RuntimeException ex) {
- return (Probe3) parm;
- }
- }
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes2/Probe5.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes2/Probe5.java
deleted file mode 100644
index 526e74d..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/probes2/Probe5.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.probes2;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-public interface Probe5 {
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/registry/DependencyRegistryImplTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/registry/DependencyRegistryImplTest.java
deleted file mode 100644
index a8bb84c..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/registry/DependencyRegistryImplTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.dependencyScan.registry;
-
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.registry.DependencyRegistryImpl;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.api.DependencyRegistry;
-import org.apache.myfaces.extensions.scripting.core.dependencyScan.core.ClassDependencies;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class DependencyRegistryImplTest {
-
- ClassDependencies _classDeps;
- DependencyRegistry _dependencyRegistry;
-
- @Before
- public void init() {
- _classDeps = new ClassDependencies();
- _dependencyRegistry = new DependencyRegistryImpl(ScriptingConst.ENGINE_TYPE_JSF_JAVA, _classDeps);
- }
-
- @Test
- public void testClearFilters() throws Exception {
- ((DependencyRegistryImpl) _dependencyRegistry).clearFilters();
- assertFalse("standard namespace must be set after clear", ((DependencyRegistryImpl) _dependencyRegistry).isAllowed(ScriptingConst.ENGINE_TYPE_JSF_JAVA, "java.lang.String"));
- }
-
- @Test
-
- public void testAddDependency() throws Exception {
- _dependencyRegistry.addDependency(ScriptingConst.ENGINE_TYPE_JSF_JAVA, null, null, null);
- _dependencyRegistry.addDependency(ScriptingConst.ENGINE_TYPE_JSF_JAVA, null, "", "");
-
- //The rest is covered by other tests
-
- }
-
- @Test
- public void testFlush() throws Exception {
- ((DependencyRegistryImpl) _dependencyRegistry).flush(ScriptingConst.ENGINE_TYPE_JSF_JAVA);
- assertFalse("standard namespace must be set after clear", ((DependencyRegistryImpl) _dependencyRegistry).isAllowed(ScriptingConst.ENGINE_TYPE_JSF_JAVA, "java.lang.String"));
- }
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/lifecycle/FailedStartupTestcase.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/lifecycle/FailedStartupTestcase.java
deleted file mode 100644
index c5e5379..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/lifecycle/FailedStartupTestcase.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.lifecycle;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.support.ContextUtils;
-import org.apache.myfaces.extensions.scripting.core.support.LoggingHandler;
-import org.apache.myfaces.extensions.scripting.core.support.MockServletContext;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContextInitializer;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import javax.servlet.ServletContext;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import static org.junit.Assert.*;
-
-/**
- * A Test case simulating failed startup conditions
- * (first a missing servlet filter)
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-
-public class FailedStartupTestcase {
- ServletContext context;
- LoggingHandler handler;
- Logger logger;
- private static final String MSG_DISABLED = "Scripting must be disabled";
- private static final String VALID_PATH = "../../src/test/resources/brokenwebapp";
- private static final String INVALID_PATH = "../../src/test/resources/nonexisting";
-
- @Before
- public void init() {
- logger = Logger.getLogger(WeavingContextInitializer.class.getName());
- handler = new LoggingHandler();
- /*
- * we suppress the original handlers because we do not
- * want unwanted messages in our console
- */
- logger.setUseParentHandlers(false);
- logger.addHandler(handler);
- logger.setLevel(Level.INFO);
- }
-
- @Test
- public void testStartup() {
- context = ContextUtils.startupSystem(VALID_PATH);
- assertFalse(MSG_DISABLED, WeavingContext.isScriptingEnabled());
- assertTrue(handler.getOutput().toString().contains(ScriptingConst.ERR_SERVLET_FILTER));
- }
-
- @Test
- public void testWebxmlMissing() {
- context = ContextUtils.startupSystem(INVALID_PATH);
- assertFalse(MSG_DISABLED, WeavingContext.isScriptingEnabled());
- assertTrue(handler.getOutput().toString().contains(ScriptingConst.ERR_SERVLET_FILTER));
- }
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/lifecycle/StartupTestCase.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/lifecycle/StartupTestCase.java
deleted file mode 100644
index 58dd8ba..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/lifecycle/StartupTestCase.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.lifecycle;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.support.ContextUtils;
-import org.apache.myfaces.extensions.scripting.core.support.MockServletContext;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContextInitializer;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.servlet.ServletContext;
-
-import static org.junit.Assert.*;
-
-/**
- * Unit tests which should secure the startup cycle
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class StartupTestCase {
- ServletContext context;
-
- @Before
- public void init() {
- context = ContextUtils.startupSystem();
- }
-
- @Test
- public void testStartup() {
- assertTrue("Scripting must be enabled", WeavingContext.isScriptingEnabled());
- assertTrue("Configuration must be reachable", WeavingContext.getConfiguration() != null);
- assertTrue("RefreshContext must be set", WeavingContext.getRefreshContext() != null);
- assertTrue("Daemon must be running", WeavingContext.getRefreshContext().getDaemon().isRunning());
- assertTrue("Daemon must be running", WeavingContext.getFileChangedDaemon().isRunning());
- assertTrue("External context must be reachable", WeavingContext.getExternalContext() == context);
- assertTrue("Weaver must be set", WeavingContext.getWeaver() != null);
- }
-
- @Test
- public void testConfiguration() {
- assertTrue("Compile target dir must be set", WeavingContext.getConfiguration().getCompileTarget() != null);
- assertTrue("Initial compile flag must be set to allow the initial compile", WeavingContext.getConfiguration().isInitialCompile());
-
- assertTrue("Source dirs per registered scripting engine must be zero because they do not exist", WeavingContext.getConfiguration().getSourceDirs(ScriptingConst.ENGINE_TYPE_JSF_JAVA).size() == 1);
- assertTrue("Source dirs per registered scripting engine must be zero because they do not exist", WeavingContext.getConfiguration().getSourceDirs(ScriptingConst.ENGINE_TYPE_JSF_GROOVY).size() == 1);
- }
-
- @Test
- public void testNotFullyStarted() {
- assertTrue("Startup not done yet", context.getAttribute(ScriptingConst.CTX_ATTR_STARTUP) == null);
- }
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/probes/MethodReloadingProbe.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/probes/MethodReloadingProbe.java
deleted file mode 100644
index 3549fcf..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/probes/MethodReloadingProbe.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.apache.myfaces.extensions.scripting.core.probes;
-
-/**
- * Interface which will allow the proxying of our probe
- * in reloading handlers
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-public interface MethodReloadingProbe {
-
- /**
- * testmethod 1 goes through
- */
- public void testMethod1();
-
- /**
- * this one throws an exception
- */
- public void testMethod2();
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/probes/Probe.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/probes/Probe.java
deleted file mode 100644
index 50bd5df..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/probes/Probe.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.probes;
-
-import org.junit.Ignore;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * testprobe for our reflectutils
- */
-
-@Ignore
-public class Probe implements MethodReloadingProbe {
-
- public Probe() {
- }
-
- public Probe(String hello, String world) {
-
- }
-
- public void testMethod1() {
-
- }
-
- public void testMethod2() {
- throw new NullPointerException("for test");
- }
-
- public boolean testMethod3(String param1) {
- return true;
- }
-
- public static boolean testMethod4(String param1, String param2) {
- return true;
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/probes/Probe2.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/probes/Probe2.java
deleted file mode 100644
index e9d2d2b..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/probes/Probe2.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.probes;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class Probe2 {
-
- public Probe2(String[] test) {
-
- }
-
- public static Boolean myHello(String xxx) {
- return Boolean.TRUE;
- }
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/refreshContext/RefreshContextTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/refreshContext/RefreshContextTest.java
deleted file mode 100644
index 89add73..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/refreshContext/RefreshContextTest.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.refreshContext;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.myfaces.extensions.scripting.api.Configuration;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.monitor.ClassResource;
-import org.apache.myfaces.extensions.scripting.monitor.RefreshAttribute;
-import org.apache.myfaces.extensions.scripting.monitor.RefreshContext;
-import org.apache.myfaces.extensions.scripting.monitor.WatchedResource;
-import org.junit.Test;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.Set;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/**
- * Testcases for the refresh context
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class RefreshContextTest {
-
- private static String PROBE1 = "../../src/test/resources/compiler/TestProbe1.java";
- private static String PROBE2 = "../../src/test/resources/compiler/TestProbe2.java";
- private static String RESOURCES = "../../src/test/resources/";
-
- private static final String TAINT_HISTORY_SIZE = "Taint history size";
- private static final String TAINT_HISTORY_CONTAINS = "Taint history contains";
- private static final String THREE_NEW_ENTRIES_IN_THE_LOG = "three new entries in the log";
- private static final String ALL_ENTRIES_GCED = "All entries gced";
-
- File probe1;
- File probe2;
- File root;
-
- public RefreshContextTest() {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
-
- String currentPath = loader.getResource("./").getPath();
- String sourcePath1 = currentPath + PROBE1;
- String sourcePath2 = currentPath + PROBE2;
- String rootPath = currentPath + RESOURCES;
-
- sourcePath1 = FilenameUtils.normalize(sourcePath1);
- sourcePath2 = FilenameUtils.normalize(sourcePath2);
- rootPath = FilenameUtils.normalize(rootPath);
-
- probe1 = new File(sourcePath1);
- probe2 = new File(sourcePath2);
- root = new File(rootPath);
-
- WeavingContext.setConfiguration(new Configuration());
- WeavingContext.getConfiguration().addSourceDir(ScriptingConst.ENGINE_TYPE_JSF_JAVA, root.getAbsolutePath());
- WeavingContext.setRefreshContext(new RefreshContext());
- }
-
- @Test
- public void testTaingLog() {
- RefreshContext ctx = WeavingContext.getRefreshContext();
- ctx.setTaintLogTimeout(0);
-
- ClassResource data = new ClassResource();
- data.setAClass(this.getClass());
- data.getRefreshAttribute().requestRefresh();
- data.getRefreshAttribute().executedRefresh();
-
- ctx.addTaintLogEntry(data);
- ctx.addTaintLogEntry(data);
- ctx.addTaintLogEntry(data);
-
- assertTrue(THREE_NEW_ENTRIES_IN_THE_LOG, ctx.getTaintHistory(0l).size() == 3);
- try {
- Thread.sleep(20);
- } catch (InterruptedException e) {
- fail(e.toString());
- }
- ctx.gcTaintLog();
- assertTrue(ALL_ENTRIES_GCED, ctx.getTaintHistory(0l).size() == 0);
-
- ctx.setTaintLogTimeout(300000000l);
- ctx.addTaintLogEntry(data);
- ctx.addTaintLogEntry(data);
- ctx.addTaintLogEntry(data);
- ctx.gcTaintLog();
- assertTrue(THREE_NEW_ENTRIES_IN_THE_LOG, ctx.getTaintHistory(0l).size() == 3);
-
- }
-
- @Test
- public void testTaintHistory() {
- RefreshContext ctx = WeavingContext.getRefreshContext();
- ctx.setTaintLogTimeout(3);
-
- ClassResource data = new ClassResource();
- data.setAClass(this.getClass());
- data.getRefreshAttribute().requestRefresh();
- data.getRefreshAttribute().executedRefresh();
-
- ctx.addTaintLogEntry(data);
- ctx.addTaintLogEntry(data);
- ctx.addTaintLogEntry(data);
-
- Set<String> result = ctx.getTaintHistoryClasses(0l);
- assertTrue(TAINT_HISTORY_CONTAINS, result.contains(this.getClass().getName()));
- assertTrue(TAINT_HISTORY_SIZE, result.size() == 1);
-
- }
-
- @Test
- public void testTaintHistoryLastNoOfEntroies() {
- RefreshContext ctx = WeavingContext.getRefreshContext();
- ctx.setTaintLogTimeout(3);
-
- ClassResource data = new ClassResource();
- data.setAClass(this.getClass());
- data.getRefreshAttribute().requestRefresh();
- data.getRefreshAttribute().executedRefresh();
-
- ctx.addTaintLogEntry(data);
- ctx.addTaintLogEntry(data);
- ctx.addTaintLogEntry(data);
-
- Collection<WatchedResource> result = ctx.getLastTainted(100);
- assertTrue(TAINT_HISTORY_SIZE, result.size() == 3);
- result = ctx.getLastTainted(2);
- assertTrue(TAINT_HISTORY_SIZE, result.size() == 2);
- result = ctx.getLastTainted(0);
- assertTrue(TAINT_HISTORY_SIZE, result.size() == 0);
-
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/reloading/ManagedBeanReloadingStrategyTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/reloading/ManagedBeanReloadingStrategyTest.java
deleted file mode 100644
index e8e832a..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/reloading/ManagedBeanReloadingStrategyTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.reloading;
-
-import org.apache.myfaces.extensions.scripting.core.reloading.ManagedBeanReloadingStrategy;
-import org.apache.myfaces.extensions.scripting.api.BaseWeaver;
-import org.apache.myfaces.extensions.scripting.api.DynamicCompiler;
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.extensions.scripting.core.probes.Probe;
-import org.apache.myfaces.extensions.scripting.core.support.Consts;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- * A simple test to ensure that the managed bean reloading strategy
- * does not do anything
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ManagedBeanReloadingStrategyTest {
-
- static final class DummyWeaver extends BaseWeaver {
-
- @Override
- public boolean isDynamic(Class clazz) {
- return false;
- }
-
- public void scanForAddedClasses() {
-
- }
-
- @Override
- protected DynamicCompiler instantiateCompiler() {
- return null;
- }
-
- @Override
- protected String getLoadingInfo(String file) {
- return null;
- }
- }
-
- @Test
- public void testReload() throws Exception {
- Probe probe = new Probe();
- ManagedBeanReloadingStrategy strategy = new ManagedBeanReloadingStrategy();
- for (int artifactType : Consts.ARTIFACT_TYPES) {
- Object probe2 = strategy.reload(probe, artifactType);
- assertTrue(probe2 == probe);
- }
- }
-
- @Test
- public void testSetGetWeaver() throws Exception {
- ManagedBeanReloadingStrategy strategy = new ManagedBeanReloadingStrategy();
- ScriptingWeaver dummyWeaver = new DummyWeaver();
- strategy.setWeaver(dummyWeaver);
- assertTrue(strategy.getWeaver() == dummyWeaver);
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/reloading/SimpleReloadingStrategyTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/reloading/SimpleReloadingStrategyTest.java
deleted file mode 100644
index 647e9e1..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/reloading/SimpleReloadingStrategyTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.reloading;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.extensions.scripting.core.probes.Probe;
-import org.apache.myfaces.extensions.scripting.core.support.ContextUtils;
-import org.apache.myfaces.extensions.scripting.core.support.ObjectReloadingWeaver;
-import org.apache.myfaces.extensions.scripting.core.support.PathUtils;
-import org.apache.myfaces.extensions.scripting.core.support.TestingJavaScriptingWeaver;
-import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.loaders.java.RecompiledClassLoader;
-import org.apache.myfaces.extensions.scripting.monitor.ClassResource;
-import org.apache.myfaces.extensions.scripting.monitor.RefreshAttribute;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.servlet.ServletContext;
-import java.io.File;
-import java.util.logging.Logger;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Simple Reloading Strategy
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class SimpleReloadingStrategyTest {
-
- private static final PathUtils _pathUtils = new PathUtils();
- private static final String RESOURCES = _pathUtils.getResource(".");
- Logger logger = Logger.getLogger(SimpleReloadingStrategyTest.class.getName());
-
- ServletContext _context;
- RecompiledClassLoader _loader;
- File _root = new File(RESOURCES );
-
- SimpleReloadingStrategy _strategy;
-
- static class MyProbe {
- //weaver = new CoreWeaver(new JavaScriptingWeaver());
- //TWeavingContext.setScriptingEnabled(true);
- //TWeavingContext.setWeaverForTesting(weaver);
- }
-
- @Before
- public void init() throws Exception {
- _context = ContextUtils.startupSystem();
- WeavingContext.getConfiguration().getSourceDirs(ScriptingConst.ENGINE_TYPE_JSF_JAVA).clear();
- WeavingContext.getConfiguration().addSourceDir(ScriptingConst.ENGINE_TYPE_JSF_JAVA, _root.getAbsolutePath());
-
- _loader = new RecompiledClassLoader(Thread.currentThread().getContextClassLoader(), ScriptingConst.ENGINE_TYPE_JSF_JAVA, ".java", false);
- ContextUtils.doJavaRecompile(_root.getAbsolutePath());
-
- /**
- * we now work on our normal scripting weaver for java for this testcase
- */
- WeavingContext.setWeaver(new TestingJavaScriptingWeaver());
- _strategy = new SimpleReloadingStrategy(WeavingContext.getWeaver());
- }
-
- @Test
- public void testReload() throws Exception {
- synchronized (ContextUtils.COMPILE_LOAD_MONITOR) {
- Object probe = _loader.loadClass("compiler.TestProbe1").newInstance();
- ClassResource metaData = getResource(probe);
- WeavingContext.getRefreshContext().getDaemon().getClassMap().put("compiler.TestProbe1", metaData);
-
- ReflectUtil.executeMethod(probe, "setTestAttr", "hello");
- Object probe2 = _strategy.reload(probe, ScriptingConst.ENGINE_TYPE_JSF_JAVA);
- Object attr = ReflectUtil.executeMethod(probe, "getTestAttr");
- assertFalse(probe.hashCode() == probe2.hashCode());
- assertTrue(attr instanceof String);
- assertTrue(((String) attr).equals("hello"));
-
- Object probe3 = _strategy.reload(probe2, ScriptingConst.ENGINE_TYPE_JSF_JAVA);
- assertTrue(probe2 == probe3);
- }
- }
-
- private ClassResource getResource(Object probe) {
- ClassResource resource = new ClassResource();
- resource.setAClass(probe.getClass());
- resource.setFile(new File(RESOURCES+File.separator+"compiler/TestProbe1.java"));
- resource.setScriptingEngine(ScriptingConst.ENGINE_TYPE_JSF_JAVA);
- resource.getRefreshAttribute().requestRefresh();
-
- return resource;
- }
-
-
- @Test
- public void testGetSetWeaver() throws Exception {
- ScriptingWeaver weaver = new ObjectReloadingWeaver(Probe.class);
- _strategy.setWeaver(weaver);
- assertTrue(_strategy.getWeaver() == weaver);
- }
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/AbstractGeneratorTestCase.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/AbstractGeneratorTestCase.java
deleted file mode 100644
index 04bdb92..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/AbstractGeneratorTestCase.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.support;
-
-import junit.framework.TestCase;
-import org.apache.myfaces.extensions.scripting.api.CompilationException;
-import org.apache.myfaces.extensions.scripting.api.CompilationResult;
-import org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler;
-import org.apache.myfaces.extensions.scripting.sandbox.compiler.CompilerFactory;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-/**
- * <p>Base class for test cases that generate Java source files.</p>
- */
-public abstract class AbstractGeneratorTestCase extends TestCase {
-
- /**
- * The temporary test directory where test cases store generated Java source files, etc.
- */
- private File testDirectory;
-
- // ------------------------------------------ Test lifecycle methods
-
- /**
- * <p>Creates a temporary directory that can be used to store
- * generated source files and compiled class files within it.</p>
- */
- @Override
- public void setUp() throws Exception {
- // Create the test directory within the directory that the class file of this test case is located in
- testDirectory =
- new File(getClass().getResource(".").toURI().getPath(), "test");
- if (!testDirectory.mkdirs() && !testDirectory.exists()) {
- throw new IllegalStateException(
- "Couldn't setup the test case for the test case '" + getClass().getName()
- + "'. It wasn't possible to create a temporary test folder.");
- }
- }
-
- /**
- * <p>Deletes the temporary directory including all subdirectories
- * and files within it.</p>
- */
- @Override
- protected void tearDown() throws Exception {
- deleteDirectory(testDirectory);
-
- if (!testDirectory.delete()) {
- System.err.println("Couldn't delete the temporary test directory '" + testDirectory.getAbsolutePath() + "'.");
- }
- }
-
- // ------------------------------------------ Protected methods
-
- /**
- * <p>Writes the given file content to the specified file. Use this method in order to
- * persist dynamically generated Java code. Note that this method assumes that the given
- * file name is a relative path to the test directory.</p>
- *
- * @param fileName the Java source file that you want to save
- * @param fileContent the content that you want to save, i.e. the Java code
- * @throws java.io.IOException if an I/O-error occurs
- */
- protected void writeFile(String fileName, String[] fileContent) throws IOException {
- writeFile(new File(testDirectory, fileName), fileContent);
- }
-
- /**
- * <p>Writes the given file content to the specified file. Use this method in order to
- * persist dynamically generated Java code.</p>
- *
- * @param file the Java source file that you want to save
- * @param fileContent the content that you want to save, i.e. the Java code
- * @throws IOException if an I/O-error occurs
- */
- protected void writeFile(File file, String[] fileContent) throws IOException {
- if (!file.getParentFile().exists() && !file.getParentFile().mkdirs() && !!file.createNewFile()) {
- throw new IllegalStateException("Couldn't create the file '" + file.getAbsolutePath() + "'.");
- }
-
- PrintWriter writer = new PrintWriter(new FileOutputStream(file));
- for (String line : fileContent) {
- writer.println(line);
- }
-
- writer.flush();
- writer.close();
-
- // Wait a little bit so that the system updates the timestamps
- try {
- Thread.sleep(100);
- }
- catch (InterruptedException ex) {
- Thread.currentThread().interrupt();
- }
- }
-
- protected CompilationResult compileFile(String sourcePath, String targetPath, String fileName, String[] fileContent)
- throws IOException, CompilationException {
- return compileFile(CompilerFactory.createCompiler(),
- new File(buildAbsolutePath(sourcePath)), new File(buildAbsolutePath(targetPath)), fileName, fileContent);
- }
-
- protected CompilationResult compileFile(String sourcePath, String targetPath, String fileName, String[] fileContent, ClassLoader classLoader)
- throws IOException, CompilationException {
- return compileFile(CompilerFactory.createCompiler(),
- new File(buildAbsolutePath(sourcePath)), new File(buildAbsolutePath(targetPath)), fileName, fileContent, classLoader);
- }
-
- protected CompilationResult compileFile(Compiler compiler, String sourcePath, String targetPath, String fileName, String[] fileContent)
- throws IOException, CompilationException {
- return compileFile(compiler,
- new File(buildAbsolutePath(sourcePath)), new File(buildAbsolutePath(targetPath)), fileName, fileContent);
- }
-
- protected CompilationResult compileFile(Compiler compiler, File sourcePath, File targetPath, String fileName, String[] fileContent)
- throws IOException, CompilationException {
- return compileFile(compiler, sourcePath, targetPath, fileName, fileContent, getClass().getClassLoader());
- }
-
- protected CompilationResult compileFile(Compiler compiler, File sourcePath, File targetPath, String fileName, String[] fileContent, ClassLoader classLoader)
- throws IOException, CompilationException {
- writeFile(new File(sourcePath, fileName), fileContent);
-
- CompilationResult result = compiler.compile(sourcePath, targetPath, fileName, classLoader);
- assertFalse("Compilation errors: " + result.getErrors().toString(), result.hasErrors());
-
- return result;
- }
-
- /**
- * <p>Concatenates the given relative path and the path of the test directory. In doing so
- * an absolute path will be created that you can use to access the according file.</p>
- *
- * @param relativePath the relative path of the file that you want to access
- * @return the absolute path of the file that you want to access
- */
- protected String buildAbsolutePath(String relativePath) {
- return buildAbsoluteFile(relativePath).getAbsolutePath();
- }
-
- /**
- * <p>Concatenates the given relative path and the path of the test directory. In doing so
- * an absolute file will be created that you can use to access the according file.</p>
- *
- * @param relativePath the relative path of the file that you want to access
- * @return the absolute File object of the file that you want to access
- */
- protected File buildAbsoluteFile(String relativePath) {
- File file = new File(testDirectory, relativePath);
- if (!file.exists() && !file.mkdirs()) {
- throw new IllegalStateException("Couldn't create the directory '" + file.getAbsolutePath() + "'.");
- }
-
- return file;
- }
-
- // ------------------------------------------ Private utility methods
-
- /**
- * <p>Deletes all subdirectories and files within the given directory.</p>
- *
- * @param directory the directory you want to delete
- */
- public static void deleteDirectory(File directory) {
- for (File file : directory.listFiles()) {
- if (file.isDirectory()) {
- deleteDirectory(file);
- }
-
- if (!file.delete()) {
- System.err.println("Couldn't delete the file or directory '" + file.getAbsolutePath() + "'.");
- }
- }
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/Consts.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/Consts.java
deleted file mode 100644
index c47a1c0..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/Consts.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.support;
-
-import static org.apache.myfaces.extensions.scripting.core.api.ScriptingConst.*;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class Consts {
- public static final String PROBE2 = "org.apache.myfaces.extensions.scripting.core.classIdentifier.Probe2";
- public static String JAVA_FILE_ENDING = ".java";
- public static final int[] ARTIFACT_TYPES = {
- ARTIFACT_TYPE_UNKNOWN,
- ARTIFACT_TYPE_MANAGEDBEAN,
- ARTIFACT_TYPE_MANAGEDPROPERTY,
- ARTIFACT_TYPE_RENDERKIT,
- ARTIFACT_TYPE_VIEWHANDLER,
- ARTIFACT_TYPE_RENDERER,
- ARTIFACT_TYPE_COMPONENT,
- ARTIFACT_TYPE_VALIDATOR,
- ARTIFACT_TYPE_BEHAVIOR,
- ARTIFACT_TYPE_APPLICATION,
- ARTIFACT_TYPE_ELCONTEXTLISTENER,
- ARTIFACT_TYPE_ACTIONLISTENER,
- ARTIFACT_TYPE_VALUECHANGELISTENER,
- ARTIFACT_TYPE_CONVERTER,
- ARTIFACT_TYPE_LIFECYCLE,
- ARTIFACT_TYPE_PHASELISTENER,
- ARTIFACT_TYPE_FACESCONTEXT,
- ARTIFACT_TYPE_NAVIGATIONHANDLER,
- ARTIFACT_TYPE_RESPONSEWRITER,
- ARTIFACT_TYPE_RESPONSESTREAM,
- ARTIFACT_TYPE_RESOURCEHANDLER,
- ARTIFACT_TYPE_CLIENTBEHAVIORRENDERER,
- ARTIFACT_TYPE_SYSTEMEVENTLISTENER,
- };
- public static final String JAVA_LANG = "java.lang";
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/ContextUtils.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/ContextUtils.java
deleted file mode 100644
index 63f4369..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/ContextUtils.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.support;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.myfaces.extensions.scripting.api.DynamicCompiler;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContextInitializer;
-import org.apache.myfaces.extensions.scripting.loaders.java.compiler.CompilerFacade;
-
-import java.io.File;
-import java.io.IOException;
-
-import static org.junit.Assert.fail;
-
-/**
- * Context utils which store the reusable test code
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-public class ContextUtils {
-
- /**
- * locking monitor for the compile/load parts
- */
- public static volatile Boolean COMPILE_LOAD_MONITOR = new Boolean(true);
-
- /**
- * A startup routine shared by many tests
- * to do the basic weaving initialization
- *
- * @return the mockup servlet context
- */
- public static MockServletContext startupSystem() {
- MockServletContext context = new MockServletContext();
- WeavingContextInitializer.initWeavingContext(context);
- return context;
- }
-
- /**
- * same as the other one but with a web.xml path being possible
- *
- * @param webXmlPath the path to the web.xml
- * @return the servlet context
- */
- public static MockServletContext startupSystem(String webXmlPath) {
- MockServletContext context = new MockServletContext(webXmlPath);
- WeavingContextInitializer.initWeavingContext(context);
- return context;
- }
-
- public static File doJavaRecompile(String sourceRoot) throws ClassNotFoundException {
- synchronized (COMPILE_LOAD_MONITOR) {
-
- DynamicCompiler compiler = new CompilerFacade(false);
- try {
- FileUtils.deleteDirectory(WeavingContext.getConfiguration().getCompileTarget());
- } catch (IOException e) {
- fail(e.getMessage());
- }
- WeavingContext.getConfiguration().getCompileTarget().mkdirs();
- return compiler.compileAllFiles(sourceRoot, "");
- }
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/LoggingHandler.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/LoggingHandler.java
deleted file mode 100644
index 0f0a066..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/LoggingHandler.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.support;
-
-import java.util.logging.Handler;
-import java.util.logging.LogRecord;
-
-/**
- * A logging handler which can capture our internal logging output
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class LoggingHandler extends Handler {
- StringBuilder _output = new StringBuilder();
-
- @Override
- public void publish(LogRecord record) {
- _output.append(record.getMessage());
- }
-
- public StringBuilder getOutput() {
- return _output;
- }
-
- public void setOutput(StringBuilder output) {
- _output = output;
- }
-
- @Override
- public void flush() {
-
- }
-
- @Override
- public void close() throws SecurityException {
-
- }
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/MockServletContext.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/MockServletContext.java
deleted file mode 100644
index db33f46..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/MockServletContext.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.support;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.servlet.StartupServletContextPluginChainLoader;
-
-import javax.servlet.ServletContext;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Basic unit testing servlet context mock
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class MockServletContext extends org.apache.myfaces.test.mock.MockServletContext {
-
- Map<String, Object> _attributes = new HashMap<String, Object>();
- Map<String, String> _initParameters = new HashMap<String, String>();
- String _resourceRoot = "../../src/test/resources/webapp";
-
- public MockServletContext() {
- setResourceRoot(_resourceRoot);
- addInitParameter(ScriptingConst.INIT_PARAM_MYFACES_PLUGIN, StartupServletContextPluginChainLoader.class.getName());
- }
-
- public MockServletContext(String resourceRoot) {
- setResourceRoot(resourceRoot);
- addInitParameter(ScriptingConst.INIT_PARAM_MYFACES_PLUGIN, StartupServletContextPluginChainLoader.class.getName());
- }
-
- public void setResourceRoot(String newRoot) {
- _resourceRoot = newRoot;
- super.setDocumentRoot(new File(Thread.currentThread().getContextClassLoader().getResource("./").getPath() + _resourceRoot));
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/MockupScriptingWeaver.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/MockupScriptingWeaver.java
deleted file mode 100644
index 94e258f..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/MockupScriptingWeaver.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.support;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-
-import java.util.Collection;
-
-/**
- * A simple mockup which just
- * remembers its last operation
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class MockupScriptingWeaver implements ScriptingWeaver {
-
- String _lastOp = null;
- int _scriptingEngine;
-
- public MockupScriptingWeaver(int scriptingEngine) {
- _scriptingEngine = scriptingEngine;
- }
-
- public String getLastOp() {
- return _lastOp;
- }
-
- public void setLastOp(String lastOp) {
- this._lastOp = lastOp;
- }
-
- public void appendCustomScriptPath(String scriptPath) {
- _lastOp = "appendCustomScriptPath";
- }
-
- public Object reloadScriptingInstance(Object o, int artifactType) {
- _lastOp = "reloadScriptingInstance";
- return o;
- }
-
- public Class reloadScriptingClass(Class aclass) {
- _lastOp = "reloadScriptingInstance";
- return aclass;
- }
-
- public Class loadScriptingClassFromName(String className) {
- _lastOp = "loadScriptingClassFromName";
- return null;
- }
-
- public int getScriptingEngine() {
- _lastOp = "getScriptingEngine";
- return _scriptingEngine;
- }
-
- public boolean isDynamic(Class clazz) {
- _lastOp = "isDynamic";
- return true;
- }
-
- public ScriptingWeaver getWeaverInstance(Class weaverClass) {
- _lastOp = "getWeaverInstance";
- return this;
- }
-
- public void fullClassScan() {
- _lastOp = "fullClassScan";
- }
-
- public void fullRecompile() {
- _lastOp = "fullRecompile";
- }
-
- public void markAsFullyRecompiled() {
-
- }
-
- public void postStartupActions() {
- _lastOp = "postStartupActions";
- }
-
- public void requestRefresh() {
- _lastOp = "requestRefresh";
- }
-
- @Override
- public void jsfRequestRefresh() {
- _lastOp = "jsfRequestRefresh";
- }
-
- public Collection<String> loadPossibleDynamicClasses() {
- _lastOp = "loadPossibleDynamicClasses";
- return null;
- }
-
- public void scanForAddedClasses() {
- _lastOp = "scanForAddedClasses";
- }
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/ObjectReloadingWeaver.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/ObjectReloadingWeaver.java
deleted file mode 100644
index 7a05947..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/ObjectReloadingWeaver.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.support;
-
-import org.apache.myfaces.extensions.scripting.api.BaseWeaver;
-import org.apache.myfaces.extensions.scripting.api.DynamicCompiler;
-import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
-
-/**
- * This weaver does nothing except instantiating
- * the object anew at every reload instance request
- * <p/>
- * we need it to simulate the object level reloading
- * at every method call *
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ObjectReloadingWeaver extends BaseWeaver {
-
- Class _clazz;
-
- public ObjectReloadingWeaver(Class clazz) {
- super();
- _clazz = clazz;
- }
-
- @Override
- public boolean isDynamic(Class clazz) {
- return true;
- }
-
- public void scanForAddedClasses() {
- }
-
- @Override
- protected DynamicCompiler instantiateCompiler() {
- return null;
- }
-
- @Override
- protected String getLoadingInfo(String file) {
- return null;
- }
-
- @Override
- public Class reloadScriptingClass(Class aclass) {
- return aclass;
- }
-
- @Override
- public Object reloadScriptingInstance(Object scriptingInstance, int artifactType) {
- return ReflectUtil.instantiate(_clazz);
- }
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/PathUtils.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/PathUtils.java
deleted file mode 100644
index d2b2e1d..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/PathUtils.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.support;
-
-import java.io.File;
-
-/**
- * Supportive utils to access the source
- * probes directly
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class PathUtils {
-
- String _currentPath;
- String _resourceRoot;
-
- public PathUtils() {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- //we use a location relative to our current root one to reach the sources
- //because the test also has to be performed outside of maven
- //and the ide cannot cope with resource paths for now
- _currentPath = loader.getResource("./").getPath();
- _resourceRoot = _currentPath + "../../src/test/resources";
- }
-
- /**
- * Resource root dir getter
- *
- * @return the resource root dir (from our source package)
- */
- public String getResourceRoot() {
- return _resourceRoot;
- }
-
- public String getResource(String in) {
- if (in.startsWith("//") || in.startsWith("\\")) {
- in = in.substring(1);
- }
- return _resourceRoot + File.separator + in;
- }
-
- /**
- * Simulates the Unix touch statement on a relative pathed source file
- *
- * @param relativeSourceFile the relative path to the resource file
- */
- public void touch(String relativeSourceFile) {
- File resource = new File(getResource(relativeSourceFile));
- touch(resource);
- }
-
- /**
- * Unix touch on a file object
- *
- * @param resource the file object to be touched
- */
- public void touch(File resource) {
- if (resource.exists()) {
- resource.setLastModified(System.currentTimeMillis());
- }
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/TWeavingContext.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/TWeavingContext.java
deleted file mode 100644
index d7854cc..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/TWeavingContext.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.core.support;
-
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * A helper to bypass an app server startup which otherwise would be enforced
- */
-
-public class TWeavingContext extends WeavingContext {
- public static void setWeaverForTesting(Object weaver) {
- _weaverHolder.set(weaver);
- //if (ResourceMonitor.getInstance().getWeavers() == null) {
- // ResourceMonitor.getInstance().setWeavers((ScriptingWeaver) weaver);
- //}
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/TestingJavaScriptingWeaver.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/TestingJavaScriptingWeaver.java
deleted file mode 100644
index 49980c0..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/support/TestingJavaScriptingWeaver.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.support;
-
-import org.apache.myfaces.extensions.scripting.api.DynamicCompiler;
-import org.apache.myfaces.extensions.scripting.loaders.java.JavaScriptingWeaver;
-import org.apache.myfaces.extensions.scripting.loaders.java.compiler.CompilerFacade;
-import org.junit.Ignore;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-@Ignore
-public class TestingJavaScriptingWeaver extends JavaScriptingWeaver {
- @Override
- protected DynamicCompiler instantiateCompiler() {
- /*we enforce javac for testing purposes*/
- return new CompilerFacade(false);
- }
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/utilsTests/FileUtilsTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/utilsTests/FileUtilsTest.java
deleted file mode 100644
index 240f766..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/utilsTests/FileUtilsTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.utilsTests;
-
-import org.apache.myfaces.extensions.scripting.core.support.PathUtils;
-import org.apache.myfaces.extensions.scripting.core.util.FileUtils;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.File;
-import java.util.List;
-
-import static junit.framework.Assert.fail;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Test cases for our FileUtils
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class FileUtilsTest {
- PathUtils pathUtils = new PathUtils();
-
- @Before
- public void init() {
-
- }
-
- @Test
- public void testForRegexp() {
- String fileSep = FileUtils.getFileSeparatorForRegex();
- assertTrue("must be double backslash instead of single one", (File.separator.equals("\\")) ? fileSep.equals("\\\\") : fileSep.equals(File.separator));
- }
-
- @Test
- public void testGetFileSeparator() {
- String fileSeparator = FileUtils.getFileSeparator();
- assertTrue(fileSeparator.equals(File.separator));
- }
-
- @Test
- public void testGetTempDir() {
- File tempDir = FileUtils.getTempDir();
- assertTrue(tempDir != null);
- assertTrue(tempDir.exists());
- }
-
- @Test
- public void testFileStrategy() {
- List<File> sourceFiles = FileUtils.fetchSourceFiles(new File(pathUtils.getResource("compiler/")), ".java");
- assertTrue("wildcarding is needed", sourceFiles.size() == 0);
-
- sourceFiles = FileUtils.fetchSourceFiles(new File(pathUtils.getResource("compiler/")), "java");
- assertTrue("wildcarding is needed", sourceFiles.size() == 0);
-
-
- sourceFiles = FileUtils.fetchSourceFiles(new File(pathUtils.getResource("compiler/")), "*.java");
- assertTrue("source files must have been found", sourceFiles.size() > 2);
- //check also for subdirs
- for(File sourceFile: sourceFiles) {
- if(sourceFile.getAbsolutePath().contains("myPackage")) {
- return;
- }
- }
- fail("source file must also be in myPackage");
- }
-
- @Test
- public void testDirStrategy() {
- StringBuilder result = FileUtils.fetchSourcePaths(new File(pathUtils.getResource("compilerx/")), "");
- assertTrue("invalid dir should result in empty results", result.toString().trim().length() == 0);
-
- result = FileUtils.fetchSourcePaths(new File(pathUtils.getResource("compiler/")), "");
- assertTrue("myPackage should be found", result.toString().trim().contains("myPackage"));
-
-
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/utilsTests/ReflectUtilTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/utilsTests/ReflectUtilTest.java
deleted file mode 100644
index 33e00fd..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/core/utilsTests/ReflectUtilTest.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.core.utilsTests;
-
-import org.apache.myfaces.extensions.scripting.core.util.Cast;
-import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
-import org.apache.myfaces.extensions.scripting.core.util.Null;
-import org.apache.myfaces.extensions.scripting.core.probes.Probe;
-import org.apache.myfaces.extensions.scripting.core.util.*;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.lang.reflect.Method;
-import java.util.Collection;
-
-import static org.junit.Assert.*;
-
-/**
- * Testcase for our reflect utils
- * which we rely heavily upon
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ReflectUtilTest {
- private static final String HELLO_WORLD = "Hello World";
- private static final String JAVA_LANG_STRING = "java.lang.String";
- private static final String MSG_INSTANTIATED = "String must be instantiated";
- private static final String MSG_PROBE_INSTANTIATED = "Probe must be instantiated";
- private static final String MSG_INIT_FAIL = "init failed expected";
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testInstantiate() throws Exception {
- String retVal = (String) ReflectUtil.instantiate(JAVA_LANG_STRING);
- assertTrue(MSG_INSTANTIATED, retVal != null);
-
- retVal = (String) ReflectUtil.instantiate(JAVA_LANG_STRING, HELLO_WORLD);
- assertTrue(MSG_INSTANTIATED, retVal != null && retVal.equals(HELLO_WORLD));
-
- Object myHello = HELLO_WORLD;
- Object probe = ReflectUtil.instantiate(Probe.class, new Cast(String.class, myHello), HELLO_WORLD);
- assertTrue(MSG_PROBE_INSTANTIATED, probe != null);
-
- try {
- ReflectUtil.instantiate(Probe.class, new Cast(Integer.class, myHello), HELLO_WORLD);
- fail();
- } catch (RuntimeException ex) {
- assertTrue(MSG_INIT_FAIL, true);
- }
- probe = ReflectUtil.instantiate(Probe.class, new Null(String.class), new Null(String.class));
- assertTrue(MSG_PROBE_INSTANTIATED, probe != null);
-
- try {
- ReflectUtil.instantiate(Probe.class, new Null(Integer.class), new Null(String.class));
- fail();
- } catch (RuntimeException ex) {
- assertTrue(MSG_INIT_FAIL, true);
- }
-
- //TODO (1.1) test fails, but is not used so we can live with it
- //probe = ReflectUtil.instantiate(Probe2.class,new Array(String.class, HELLO_WORLD, HELLO_WORLD));
- //assertTrue("Probe must be instantiated", probe != null);
- }
-
- @Test
- public void testNewObject() throws Exception {
- String retVal = (String) ReflectUtil.newObject(String.class);
- assertTrue(MSG_INSTANTIATED, retVal != null);
- }
-
- @Test
- public void testExecuteStaticMethod() throws Exception {
- Boolean retVal = (Boolean) ReflectUtil.executeStaticMethod(Boolean.class, "valueOf", "true");
- assertTrue("retval must be true", retVal);
-
- try {
- ReflectUtil.executeStaticMethod(Boolean.class, "xx_valueOf", "true");
- fail();
- } catch (RuntimeException ex) {
- assertTrue("Exception must be thrown", true);
- }
-
- }
-
- @Test
- public void testFastExecuteStaticMethod() throws Exception {
- Boolean retVal = (Boolean) ReflectUtil.fastExecuteStaticMethod(Boolean.class, "valueOf", "true");
- assertTrue("retval must be true", retVal);
- }
-
- @Test
- public void testGetAllMethods() throws Exception {
- Collection<Method> retVal = ReflectUtil.getAllMethods(Boolean.class, "valueOf", 1);
- assertTrue(retVal.size() == 2);/*String and boolean*/
- retVal = ReflectUtil.getAllMethods(Object.class, "toString", 0);
- assertTrue(retVal.size() == 1);/*String and boolean*/
- }
-
- @Test
- public void testExecuteMethod() throws Exception {
-
- Boolean probe = true;
- Boolean retVal = (Boolean) ReflectUtil.executeMethod(probe, "valueOf", "true");
- assertTrue(retVal);
- String sRetVal = (String) ReflectUtil.executeMethod(probe, "toString");
- assertTrue(sRetVal.equals("true"));
-
- Object hashVal = ReflectUtil.executeMethod(new Probe(), "hashCode");
- assertTrue(hashVal != null);
-
- try {
- ReflectUtil.executeMethod(new Probe(), "xx_hashCode");
- fail();
- } catch (RuntimeException ex) {
- assertTrue("calling must faile with an RE", true);
- }
- }
-
- @Test
- public void testFastExecuteMethod() throws Exception {
-
- Boolean probe = true;
- Boolean retVal = (Boolean) ReflectUtil.fastExecuteMethod(probe, "valueOf", "true");
- assertTrue(retVal);
- String sRetVal = (String) ReflectUtil.fastExecuteMethod(probe, "toString");
- assertTrue(sRetVal.equals("true"));
-
- Object hashVal = ReflectUtil.fastExecuteMethod(new Probe(), "hashCode");
- assertTrue(hashVal != null);
-
- }
-
- @Test
- public void testCast() {
- assertTrue("Cast testing", ReflectUtil.cast(String.class, HELLO_WORLD) instanceof Cast);
- assertTrue("Cast testing", ReflectUtil.nullCast(String.class) instanceof Null);
- }
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/loaders/java/RecompiledClassLoaderTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/loaders/java/RecompiledClassLoaderTest.java
deleted file mode 100644
index 9a2c9b5..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/loaders/java/RecompiledClassLoaderTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.loaders.java;
-
-import org.apache.myfaces.extensions.scripting.loaders.java.RecompiledClassLoader;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.support.ContextUtils;
-import org.apache.myfaces.extensions.scripting.core.support.PathUtils;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import javax.servlet.ServletContext;
-import java.io.File;
-import java.security.AccessController;
-import java.util.logging.Logger;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class RecompiledClassLoaderTest {
-
- private static final PathUtils _pathUtils = new PathUtils();
- private static final String RESOURCES = _pathUtils.getResource(".");
- Logger logger = Logger.getLogger(RecompiledClassLoaderTest.class.getName());
-
- ServletContext _context;
- RecompiledClassLoader _loader;
- File _root = new File(RESOURCES + File.separator + "compiler/");
-
- @Before
- public void init() throws Exception {
- _context = ContextUtils.startupSystem();
- WeavingContext.getConfiguration().getSourceDirs(ScriptingConst.ENGINE_TYPE_JSF_JAVA).clear();
- WeavingContext.getConfiguration().addSourceDir(ScriptingConst.ENGINE_TYPE_JSF_JAVA, _root.getAbsolutePath());
-
- _loader = new RecompiledClassLoader(Thread.currentThread().getContextClassLoader(), ScriptingConst.ENGINE_TYPE_JSF_JAVA, ".java", false);
- ContextUtils.doJavaRecompile(_root.getAbsolutePath());
-
- }
-
- @Test
- public void testInit2() {
- new RecompiledClassLoader();
- }
-
- @Test
- public void testLoadClass() throws Exception {
- synchronized (ContextUtils.COMPILE_LOAD_MONITOR) {
- //the simple reloading case is handled by the reloading strategy testcase
- //so this test is mostly just to test the rest of the class
-
- Class clazz1 = _loader.loadClass("java.lang.String");
- Class clazz2 = _loader.loadClass("java.lang.String");
- assertTrue(clazz1.hashCode() == clazz2.hashCode());
-
- }
- }
-
- @Test
- public void testGetSetSourceRoot() throws Exception {
- _loader.setSourceRoot("booga");
- assertTrue(_loader.getSourceRoot().equals("booga"));
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/loaders/java/ScannerClassloaderTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/loaders/java/ScannerClassloaderTest.java
deleted file mode 100644
index 433c7dd..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/loaders/java/ScannerClassloaderTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.loaders.java;
-
-import org.apache.myfaces.extensions.scripting.loaders.java.ScannerClassloader;
-import org.apache.myfaces.extensions.scripting.loaders.java.RecompiledClassLoader;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.support.ContextUtils;
-import org.apache.myfaces.extensions.scripting.core.support.PathUtils;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.servlet.ServletContext;
-import java.io.File;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ScannerClassloaderTest {
- private static final PathUtils _pathUtils = new PathUtils();
- private static final String RESOURCES = _pathUtils.getResource(".");
-
- ServletContext _context;
- ScannerClassloader _loader;
- File _root = new File(RESOURCES + File.separator + "compiler/");
-
- @Before
- public void init() throws Exception {
- _context = ContextUtils.startupSystem();
- WeavingContext.getConfiguration().getSourceDirs(ScriptingConst.ENGINE_TYPE_JSF_JAVA).clear();
- WeavingContext.getConfiguration().addSourceDir(ScriptingConst.ENGINE_TYPE_JSF_JAVA, _root.getAbsolutePath());
-
- _loader = new ScannerClassloader(Thread.currentThread().getContextClassLoader(), ScriptingConst.ENGINE_TYPE_JSF_JAVA, ".java", WeavingContext.getConfiguration().getCompileTarget());
- ContextUtils.doJavaRecompile(_root.getAbsolutePath());
- }
-
- @Test
- public void testInit2() {
- new RecompiledClassLoader();
- }
-
- @Test
- public void testLoadClass() throws Exception {
- synchronized (ContextUtils.COMPILE_LOAD_MONITOR) {
- Class clazz1 = _loader.loadClass("compiler.TestProbe1");
- Class clazz2 = _loader.loadClass("compiler.TestProbe1");
- assertTrue(clazz1 == clazz2);
- }
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/AbstractJavaCompilerTestCase.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/AbstractJavaCompilerTestCase.java
deleted file mode 100644
index a82b063..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/AbstractJavaCompilerTestCase.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.sandbox;
-
-import java.io.File;
-
-import org.apache.myfaces.extensions.scripting.core.support.AbstractGeneratorTestCase;
-import org.apache.myfaces.extensions.scripting.api.CompilationResult;
-import org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler;
-import org.junit.Ignore;
-
-/**
- * <p>Test class for all Java implementations of
- * <code>org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler</code>.</p>
- */
-@Ignore
-public abstract class AbstractJavaCompilerTestCase extends AbstractGeneratorTestCase {
-
- // ------------------------------------------ Test methods
-
- public void testCompileGeneratedFile() throws Exception {
- writeFile("/src/main/java/org/apache/myfaces/extensions/scripting/HelloWorld.java", new String[]{
- "package org.apache.myfaces.extensions.scripting; ",
- " ",
- "public class HelloWorld { ",
- " ",
- " public static void main(String[] args) { ",
- " System.out.println(\"Hello World\"); ",
- " } ",
- "} "
- });
-
- org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler compiler = createCompiler();
- CompilationResult result = compiler.compile(
- new File(buildAbsolutePath("/src/main/java")),
- new File(buildAbsolutePath("/target/test-classes")),
- "org/apache/myfaces/extensions/scripting/HelloWorld.java", getCurrentClassLoader());
-
- assertFalse(result.hasErrors());
- assertTrue(new File(
- buildAbsolutePath("/target/test-classes/"), "org/apache/myfaces/extensions/scripting/HelloWorld.class").exists());
- }
-
- public void testCompileGeneratedFileWithError() throws Exception {
- writeFile("/src/main/java/org/apache/myfaces/extensions/scripting/HelloWorld.java", new String[]{
- "package org.apache.myfaces.extensions.scripting; ",
- " ",
- "public class HelloWorld { ",
- " ",
- " public static void main(String[] args) { ",
- " System.println(\"Hello World\"); ",
- " } ",
- "} "
- });
-
- Compiler compiler = createCompiler();
- CompilationResult result = compiler.compile(
- new File(buildAbsolutePath("/src/main/java")),
- new File(buildAbsolutePath("/target/test-classes")),
- "org/apache/myfaces/extensions/scripting/HelloWorld.java", getCurrentClassLoader());
-
- assertTrue(result.hasErrors());
- assertFalse(new File(
- buildAbsolutePath("/target/test-classes/"), "org/apache/myfaces/extensions/scripting/HelloWorld.class").exists());
- }
-
- public void testCompileFileWithDependencies() throws Exception {
- writeFile("/src/main/java/org/apache/myfaces/extensions/scripting/DummyCompiler.java", new String[]{
- "package org.apache.myfaces.extensions.scripting; ",
- " ",
- "import java.io.File; ",
- "import org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler; ",
- "import org.apache.myfaces.extensions.scripting.api.CompilationResult; ",
- " ",
- "public class DummyCompiler implements Compiler { ",
- " ",
- " public CompilationResult compile(File s, File t, String f, ClassLoader c) { ",
- " return null; ",
- " } ",
- " ",
- " public CompilationResult compile(File s, File t, File f, ClassLoader c) { ",
- " return null; ",
- " } ",
- "} "
-
- });
-
- Compiler compiler = createCompiler();
- CompilationResult result = compiler.compile(
- new File(buildAbsolutePath("/src/main/java")),
- new File(buildAbsolutePath("/target/test-classes")),
- "org/apache/myfaces/extensions/scripting/DummyCompiler.java", getCurrentClassLoader());
-
- assertFalse(result.hasErrors());
- assertTrue(new File(
- buildAbsolutePath("/target/test-classes/"), "org/apache/myfaces/extensions/scripting/DummyCompiler.class").exists());
- }
-
- public void testCompileFileWithDependenciesWithoutClassloader() throws Exception {
- writeFile("/src/main/java/org/apache/myfaces/extensions/scripting/DummyCompiler.java", new String[]{
- "package org.apache.myfaces.extensions.scripting; ",
- " ",
- "import java.io.File; ",
- "import org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler; ",
- "import org.apache.myfaces.extensions.scripting.api.CompilationResult; ",
- " ",
- "public class DummyCompiler implements Compiler { ",
- " ",
- " public CompilationResult compile(File s, File t, String f, ClassLoader c) { ",
- " return null; ",
- " } ",
- " ",
- " public CompilationResult compile(File s, File t, File f, ClassLoader c) { ",
- " return null; ",
- " } ",
- "} "
-
- });
-
- Compiler compiler = createCompiler();
- CompilationResult result = compiler.compile(
- new File(buildAbsolutePath("/src/main/java")),
- new File(buildAbsolutePath("/target/test-classes")),
- "aorg/apache/myfaces/extensions/scripting/DummyCompiler.java", null);
-
- assertTrue(result.hasErrors());
- assertFalse(new File(
- buildAbsolutePath("/target/test-classes/"), "org/apache/myfaces/extensions/scripting/DummyCompiler.class").exists());
- }
-
- // ------------------------------------------ Utility methods
-
- protected ClassLoader getCurrentClassLoader() {
- return getClass().getClassLoader();
- }
-
- // ------------------------------------------ Template methods
-
- /**
- * <p>Creates a new instance of the compiler implementation that this class should test.</p>
- *
- * @return a new instance of the compiler implementation that this class should test
- */
- protected abstract Compiler createCompiler();
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/DefaultGreeter.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/DefaultGreeter.java
deleted file mode 100644
index ae36048..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/DefaultGreeter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.sandbox;
-
-/**
- *
- *
- */
-public class DefaultGreeter implements Greeter {
-
- public String sayHello() {
- return "Hello";
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/DefaultPersonGreeter.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/DefaultPersonGreeter.java
deleted file mode 100644
index 12e9920..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/DefaultPersonGreeter.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.sandbox;
-
-/**
- *
- *
- */
-public class DefaultPersonGreeter implements PersonGreeter {
-
- private DefaultGreeter greeter = new DefaultGreeter();
-
- public String sayHello(String name) {
- return greeter.sayHello() + " " + name + "!";
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/Greeter.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/Greeter.java
deleted file mode 100644
index 6f87fe7..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/Greeter.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.sandbox;
-
-/**
- *
- *
- */
-public interface Greeter {
-
- public String sayHello();
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/GroovyCompilerTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/GroovyCompilerTest.java
deleted file mode 100644
index ef0eca5..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/GroovyCompilerTest.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.sandbox;
-
-import org.apache.myfaces.extensions.scripting.sandbox.compiler.GroovyCompiler;
-import org.apache.myfaces.extensions.scripting.core.support.AbstractGeneratorTestCase;
-import org.apache.myfaces.extensions.scripting.api.CompilationResult;
-import org.apache.myfaces.extensions.scripting.api.Configuration;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.sandbox.compiler.*;
-import org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler;
-
-import java.io.File;
-
-/**
- * <p>Test class for
- * <code>org.apache.myfaces.extensions.scripting.sandbox.compiler.GroovyCompiler</code></p>
- */
-
-public class GroovyCompilerTest extends AbstractGeneratorTestCase {
-
- // ------------------------------------------ Test methods
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- WeavingContext.setConfiguration(new Configuration());
- }
-
- /**
- * <p>Tests whether it is possible to compile a dynamically generated Groovy source file.</p>
- *
- * @throws Exception if an error occurs
- */
- public void testCompileGeneratedFile() throws Exception {
- writeFile("/src/main/groovy/org/apache/myfaces/extensions/scripting/HelloWorld.groovy", new String[]{
- "package org.apache.myfaces.extensions.scripting; ",
- " ",
- "def class HelloWorld { ",
- " ",
- " def static main(String[] args) { ",
- " println(\"Hello World\"); ",
- " } ",
- "} "
- });
-
- org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler compiler = new GroovyCompiler();
- CompilationResult result = compiler.compile(
- new File(buildAbsolutePath("/src/main/groovy")),
- new File(buildAbsolutePath("/target/test-classes")),
- "org/apache/myfaces/extensions/scripting/HelloWorld.groovy", getCurrentClassLoader());
-
- assertFalse(result.hasErrors());
- assertTrue(new File(
- buildAbsolutePath("/target/test-classes/"), "org/apache/myfaces/extensions/scripting/HelloWorld.class").exists());
- }
-
- /**
- * <p>Tests whether compilation fails in case of an invalid Groovy source file.</p>
- *
- * @throws Exception if an error occurs
- */
- public void testCompileGeneratedFileWithError() throws Exception {
- writeFile("/src/main/groovy/org/apache/myfaces/extensions/scripting/HelloWorld.groovy", new String[]{
- "package org.apache.myfaces.extensions.scripting; ",
- " ",
- "def class HelloWorld { ",
- " ",
- " def static main(String[] args) { ",
- " System2.out.println(\"Hello World\"); ",
- " } ",
- "} "
- });
-
- Compiler compiler = new GroovyCompiler();
- CompilationResult result = compiler.compile(
- new File(buildAbsolutePath("/src/main/groovy")),
- new File(buildAbsolutePath("/target/test-classes")),
- "org/apache/myfaces/extensions/scripting/HelloWorld.groovy", getCurrentClassLoader());
-
- assertTrue(result.hasErrors());
- assertFalse(new File(
- buildAbsolutePath("/target/test-classes/"), "org/apache/myfaces/extensions/scripting/HelloWorld.class").exists());
- }
-
- /**
- * <p>Tests whether it is possible to reference dependencies in the Groovy
- * source files that have to be resolved using the supplied class loader.</p>
- *
- * @throws Exception if an error occurs
- */
- public void testCompileFileWithDependencies() throws Exception {
- writeFile("/src/main/groovy/org/apache/myfaces/extensions/scripting/DummyCompiler.groovy", new String[]{
- "package org.apache.myfaces.extensions.scripting; ",
- " ",
- "import java.io.File; ",
- "import org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler; ",
- "import org.apache.myfaces.extensions.scripting.api.CompilationResult; ",
- " ",
- "def class DummyCompiler implements Compiler { ",
- " ",
- " def CompilationResult compile(File s, File t, String f, ClassLoader c) { ",
- " return null; ",
- " } ",
- " ",
- " def CompilationResult compile(File s, File t, File f, ClassLoader c) { ",
- " return null; ",
- " } ",
- "} "
- });
-
- Compiler compiler = new GroovyCompiler();
- CompilationResult result = compiler.compile(
- new File(buildAbsolutePath("/src/main/groovy")),
- new File(buildAbsolutePath("/target/test-classes")),
- "org/apache/myfaces/extensions/scripting/DummyCompiler.groovy", getCurrentClassLoader());
-
- assertFalse(result.hasErrors());
- assertTrue(new File(
- buildAbsolutePath("/target/test-classes/"), "org/apache/myfaces/extensions/scripting/DummyCompiler.class").exists());
- }
-
- // ------------------------------------------ Utility methods
-
- /**
- * <p>Returns the class loader that has loaded this class.</p>
- *
- * @return the class loader that has loaded this class
- */
- protected ClassLoader getCurrentClassLoader() {
- return getClass().getClassLoader();
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/JavacCompilerTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/JavacCompilerTest.java
deleted file mode 100644
index 7f45b7b..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/JavacCompilerTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.sandbox;
-
-import org.apache.myfaces.extensions.scripting.sandbox.compiler.JavacCompiler;
-import org.apache.myfaces.extensions.scripting.sandbox.compiler.*;
-import org.junit.Ignore;
-
-/**
- * <p>Test class for
- * <code>org.apache.myfaces.extensions.scripting.sandbox.compiler.JavacCompiler</code></p>
- */
-@Ignore
-public class JavacCompilerTest extends AbstractJavaCompilerTestCase {
-
- // ------------------------------------------ AbstractJavaCompilerTestCase methods
-
- protected org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler createCompiler() {
- return new JavacCompiler();
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/Jsr199CompilerTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/Jsr199CompilerTest.java
deleted file mode 100644
index 6c084c3..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/Jsr199CompilerTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.sandbox;
-
-import org.junit.Ignore;
-
-/**
- * <p>Test class for
- * <code>org.apache.myfaces.extensions.scripting.loaders.java.compiler.Jsr199Compiler</code></p>
- */
-@Ignore
-public class Jsr199CompilerTest extends AbstractJavaCompilerTestCase {
-
- // ------------------------------------------ AbstractJavaCompilerTestCase methods
-
- protected org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler createCompiler() {
- //return new Jsr199Compiler();
- return null;
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/OverridingClassLoaderTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/OverridingClassLoaderTest.java
deleted file mode 100644
index 51d8018..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/OverridingClassLoaderTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.sandbox;
-
-import junit.framework.TestCase;
-import org.apache.myfaces.extensions.scripting.sandbox.loader.support.OverridingClassLoader;
-
-/**
- * <p>Test class for the class
- * <code>org.apache.myfaces.extensions.scripting.sandbox.loader.support.OverridingClassLoader</code></p>
- */
-public class OverridingClassLoaderTest extends TestCase {
-
- // ------------------------------------------ Test methods
-
- /**
- * <p>Tests whether it is possible to override class definitions using the OverridingClassLoader,
- * i.e. it tests if you can produce multiple different Class objects using different class loaders
- * (which is not really a surprising thing at all).</p>
- *
- * @throws Exception if an unexpected error occurs
- */
- public void testOverrideClass() throws Exception {
- ClassLoader classLoader = new OverridingClassLoader(
- Dummy.class.getName(), OverridingClassLoaderTest.class.getClassLoader());
-
- Class dummyClass = classLoader.loadClass(Dummy.class.getName());
- assertNotSame("The OverridingClassLoader didn't return a different Class instance.",
- Dummy.class, dummyClass);
-
- // .. and another time
- classLoader = new OverridingClassLoader(Dummy.class.getName(), classLoader);
- Class secondDummyClass = classLoader.loadClass(Dummy.class.getName());
- assertNotSame("The OverridingClassLoader didn't return a different Class instance.",
- Dummy.class, secondDummyClass);
- assertNotSame("The OverridingClassLoader didn't return a different Class instance.",
- dummyClass, secondDummyClass);
- }
-
- /**
- * <p>Tests whether the OverridingClassLoader delegates the parent class loader correctly.</p>
- *
- * @throws Exception if an unexpected error occurs
- */
- public void testOverrideDifferentClass() throws Exception {
- ClassLoader classLoader = new OverridingClassLoader(
- Dummy.class.getName(), OverridingClassLoaderTest.class.getClassLoader());
- assertSame("The OverridingClassLoader replaced a Class instance that he wasn't supposed to replace.",
- Object.class, classLoader.loadClass("java.lang.Object"));
- }
-
- // ------------------------------------------ Dummy classes
-
- /**
- * <p>This class will be reloaded in some test cases.</p>
- */
- private static class Dummy {
-
- }
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/PersonGreeter.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/PersonGreeter.java
deleted file mode 100644
index 5de88cc..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/PersonGreeter.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.sandbox;
-
-/**
- *
- *
- */
-public interface PersonGreeter {
-
- public String sayHello(String name);
-
-}
diff --git a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/ReloadingClassLoaderTest.java b/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/ReloadingClassLoaderTest.java
deleted file mode 100644
index abe703b..0000000
--- a/extscript-core-root/extscript-core/src/old_test/java/org/apache/myfaces/extensions/scripting/sandbox/ReloadingClassLoaderTest.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.sandbox;
-
-import org.apache.myfaces.extensions.scripting.core.support.AbstractGeneratorTestCase;
-import org.apache.myfaces.extensions.scripting.sandbox.loader.ReloadingClassLoader;
-import org.junit.Ignore;
-
-import java.io.File;
-
-/**
- * <p>Test class for
- * <code>org.apache.myfaces.extensions.scripting.sandbox.loader.ReloadingClassLoader</code></p>
- */
-@Ignore
-public class ReloadingClassLoaderTest extends AbstractGeneratorTestCase {
-
- // ------------------------------------------ Test methods
-
- public void testCompileAndLoadFile() throws Exception {
- // Compile a dynamically generated class ..
- compileFile("/src/main/java", "/target/test-classes", "org/apache/myfaces/extensions/scripting/Greeter.java", new String[]{
- "package org.apache.myfaces.extensions.scripting; ",
- " ",
- "public class Greeter { ",
- " ",
- " public String sayHello() { ",
- " return \"Hello World\"; ",
- " } ",
- "} "
- });
-
- ClassLoader classLoader = buildClassLoader("/target/test-classes");
-
- // .. and try to load it afterwards.
- Class greeterClass = classLoader.loadClass("org.apache.myfaces.extensions.scripting.Greeter");
- assertNotNull(greeterClass);
- assertEquals("org.apache.myfaces.extensions.scripting.Greeter", greeterClass.getName());
-
- Object greeter = greeterClass.newInstance();
- String greeting = (String) greeter.getClass().getMethod("sayHello").invoke(greeter);
- assertEquals("Hello World", greeting);
- }
-
- public void testCompileAndLoadFileMultipleTimes() throws Exception {
- // Compile a dynamically generated class ..
- compileFile("/src/main/java", "/target/test-classes", "org/apache/myfaces/extensions/scripting/Greeter.java", new String[]{
- "package org.apache.myfaces.extensions.scripting; ",
- " ",
- "public class Greeter { ",
- " ",
- " public String sayHello() { ",
- " return \"Hello World\"; ",
- " } ",
- "} "
- });
-
- ClassLoader classLoader = buildClassLoader("/target/test-classes");
-
- // .. and try to load it afterwards ..
- Class firstGreeterClass = classLoader.loadClass("org.apache.myfaces.extensions.scripting.Greeter");
- assertNotNull(firstGreeterClass);
- assertEquals("org.apache.myfaces.extensions.scripting.Greeter", firstGreeterClass.getName());
-
- // .. more than once using the same classloader.
- Class secondGreeterClass = classLoader.loadClass("org.apache.myfaces.extensions.scripting.Greeter");
- assertNotNull(secondGreeterClass);
- assertEquals("org.apache.myfaces.extensions.scripting.Greeter", secondGreeterClass.getName());
-
- assertSame(firstGreeterClass, secondGreeterClass);
- }
-
- public void testRecompileAndLoadFile() throws Exception {
- // Compile a dynamically generated class.
- compileFile("/src/main/java", "/target/test-classes", "org/apache/myfaces/extensions/scripting/Greeter.java", new String[]{
- "package org.apache.myfaces.extensions.scripting; ",
- " ",
- "public class Greeter { ",
- " ",
- " public String sayHello() { ",
- " return \"Hello World\"; ",
- " } ",
- "} "
- });
-
- ClassLoader classLoader = buildClassLoader("/target/test-classes");
-
- Class firstGreeterClass = classLoader.loadClass("org.apache.myfaces.extensions.scripting.Greeter");
- assertNotNull(firstGreeterClass);
- assertEquals("org.apache.myfaces.extensions.scripting.Greeter", firstGreeterClass.getName());
-
- Object firstGreeter = firstGreeterClass.newInstance();
- String greeting = (String) firstGreeterClass.getMethod("sayHello").invoke(firstGreeter);
- assertEquals("Hello World", greeting);
-
- Thread.sleep(1000);
-
- // Modify the source code
- // Compile a dynamically generated class ..
- compileFile("/src/main/java", "/target/test-classes", "org/apache/myfaces/extensions/scripting/Greeter.java", new String[]{
- "package org.apache.myfaces.extensions.scripting; ",
- " ",
- "public class Greeter { ",
- " ",
- " public String sayHello() { ",
- " return \"Hello Universe\"; ",
- " } ",
- "} "
- });
-
- // Reload the class and verify it again
- Class secondGreeterClass = classLoader.loadClass("org.apache.myfaces.extensions.scripting.Greeter");
- assertNotNull(secondGreeterClass);
- assertEquals("org.apache.myfaces.extensions.scripting.Greeter", secondGreeterClass.getName());
-
- // However, it has to be a new Class object
- assertNotSame(firstGreeterClass, secondGreeterClass);
-
- Object secondGreeter = secondGreeterClass.newInstance();
- greeting = (String) secondGreeterClass.getMethod("sayHello").invoke(secondGreeter);
- assertEquals("Hello Universe", greeting);
- }
-
- public void testOverrideFile() throws Exception {
- ClassLoader classLoader = buildClassLoader("/target/test-classes");
- Greeter greeter = (Greeter) classLoader.loadClass(
- "org.apache.myfaces.extensions.scripting.sandbox.DefaultGreeter").newInstance();
- assertEquals("Hello", greeter.sayHello());
-
- // Compile a dynamically generated class.
- compileFile("/src/main/java", "/target/test-classes", "org/apache/myfaces/extensions/scripting/loader/DefaultGreeter.java", new String[]{
- "package org.apache.myfaces.extensions.scripting.sandbox.loader; ",
- " ",
- "public class DefaultGreeter implements Greeter { ",
- " ",
- " public String sayHello() { ",
- " return \"Hi\"; ",
- " } ",
- "} "
- });
-
- greeter = (Greeter) classLoader.loadClass(
- "org.apache.myfaces.extensions.scripting.sandbox.DefaultGreeter").newInstance();
- assertEquals("Hi", greeter.sayHello());
- }
-
- public void testOverrideFileAndCheckDependentClass() throws Exception {
- ReloadingClassLoader classLoader = buildClassLoader("/target/test-classes");
- PersonGreeter greeter = (PersonGreeter) classLoader.loadClass(
- "org.apache.myfaces.extensions.scripting.sandbox.DefaultPersonGreeter").newInstance();
- assertEquals("Hello John Doe!", greeter.sayHello("John Doe"));
-
- // Compile a dynamically generated class.
- compileFile("/src/main/java", "/target/test-classes", "org/apache/myfaces/extensions/scripting/loader/DefaultGreeter.java", new String[]{
- "package org.apache.myfaces.extensions.scripting.sandbox.loader; ",
- " ",
- "public class DefaultGreeter implements Greeter { ",
- " ",
- " public String sayHello() { ",
- " return \"Hi\"; ",
- " } ",
- "} "
- });
-
- // Note that the person greeter still uses the outdated version of the class file.
- greeter = (PersonGreeter) classLoader.loadClass(
- "org.apache.myfaces.extensions.scripting.sandbox.DefaultPersonGreeter").newInstance();
- assertEquals("Hello John Doe!", greeter.sayHello("John Doe"));
-
- // However, now we're forcefully reloading this class in order to reflect the changes.
- classLoader.reloadClass("org.apache.myfaces.extensions.scripting.sandbox.DefaultPersonGreeter");
-
- // Note that the person greeter still uses the outdated version of the class file.
- greeter = (PersonGreeter) classLoader.loadClass(
- "org.apache.myfaces.extensions.scripting.sandbox.DefaultPersonGreeter").newInstance();
- assertEquals("Hi John Doe!", greeter.sayHello("John Doe"));
- }
-
- public void testCompileAndLoadFileWithDependencies() throws Exception {
- compileFile("/src/main/java", "/target/test-classes", "org/apache/myfaces/extensions/scripting/DummyCompiler.java", new String[]{
- "package org.apache.myfaces.extensions.scripting; ",
- " ",
- "import java.io.File; ",
- "import org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler; ",
- "import org.apache.myfaces.extensions.scripting.api.CompilationResult; ",
- " ",
- "public class DummyCompiler implements Compiler { ",
- " ",
- " public CompilationResult compile(File s, File t, String f, ClassLoader c) { ",
- " return null; ",
- " } ",
- " ",
- " public CompilationResult compile(File s, File t, File f, ClassLoader c) { ",
- " return null; ",
- " } ",
- "} "
- });
-
- // Create a new class loader to load the dynamically compiled class
- ClassLoader classLoader = buildClassLoader("/target/test-classes");
-
- // Load the dynamically compiled class
- Class dummyCompilerClass = classLoader.loadClass("org.apache.myfaces.extensions.scripting.DummyCompiler");
- assertNotNull(dummyCompilerClass);
- assertEquals("org.apache.myfaces.extensions.scripting.DummyCompiler", dummyCompilerClass.getName());
- }
-
- public void testLoadParentClassFile() throws Exception {
- ClassLoader classLoader = buildClassLoader("/target/test-classes");
-
- Class compilerInterface = classLoader.loadClass("org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler");
- assertNotNull(compilerInterface);
- assertEquals("org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler", compilerInterface.getName());
- }
-
- public void testOutdatedCheck() throws Exception {
- // Compile a dynamically generated class ..
- compileFile("/src/main/java", "/target/test-classes", "org/apache/myfaces/extensions/scripting/Greeter.java", new String[]{
- "package org.apache.myfaces.extensions.scripting; ",
- " ",
- "public class Greeter { ",
- " ",
- " public String sayHello() { ",
- " return \"Hello World\"; ",
- " } ",
- "} "
- });
-
- ReloadingClassLoader classLoader = buildClassLoader("/target/test-classes");
-
- Class firstGreeterClass = classLoader.loadClass("org.apache.myfaces.extensions.scripting.Greeter");
- assertNotNull(firstGreeterClass);
- assertEquals("org.apache.myfaces.extensions.scripting.Greeter", firstGreeterClass.getName());
-
- assertFalse(classLoader.isOutdated(firstGreeterClass));
-
- Thread.sleep(1000);
-
- // Modify the source code ..
- compileFile("/src/main/java", "/target/test-classes", "org/apache/myfaces/extensions/scripting/Greeter.java", new String[]{
- "package org.apache.myfaces.extensions.scripting; ",
- " ",
- "public class Greeter { ",
- " ",
- " public String sayHello() { ",
- " return \"Hello Universe\"; ",
- " } ",
- "} "
- });
-
- // .. and test whether the classloader recognizes that we've got an outdated Class reference here.
- assertTrue(classLoader.isOutdated(firstGreeterClass));
- }
-
- // ------------------------------------------ Utility methods
-
- protected ReloadingClassLoader buildClassLoader(String compilationDirectory) {
- return new ReloadingClassLoader(getClass().getClassLoader(),
- new File(buildAbsolutePath(compilationDirectory)));
- }
-
-}
\ No newline at end of file
diff --git a/extscript-core-root/extscript-myfaces2-extensions/faces-config.NavData b/extscript-core-root/extscript-myfaces2-extensions/faces-config.NavData
deleted file mode 100644
index 298bfc5..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/faces-config.NavData
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Scene Scope="Project" version="2">
- <Scope Scope="Faces Configuration Only"/>
- <Scope Scope="Project"/>
- <Scope Scope="All Faces Configurations"/>
-</Scene>
diff --git a/extscript-core-root/extscript-myfaces2-extensions/pom.xml b/extscript-core-root/extscript-myfaces2-extensions/pom.xml
deleted file mode 100644
index c5d1440..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/pom.xml
+++ /dev/null
@@ -1,128 +0,0 @@
-<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>
- <artifactId>extscript-myfaces2-extensions</artifactId>
- <packaging>jar</packaging>
- <name>myfaces2-extensions</name>
-
- <description>
- extensions.scripting classes which enable myfaces 2.0 compatibility
- </description>
-
- <parent>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-core-root</artifactId>
- <version>1.0.3-SNAPSHOT</version>
- </parent>
-
- <scm>
- <connection>
- scm:svn:http://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions
- </connection>
- <developerConnection>
- scm:svn:https://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions
- </developerConnection>
- <url>
- http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions
- </url>
- </scm>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.myfaces.extensions.scripting</groupId>
- <artifactId>extscript-core</artifactId>
- <version>1.0.3-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.3</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.myfaces.core</groupId>
- <artifactId>myfaces-api</artifactId>
- <version>${myfaces2.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.myfaces.core</groupId>
- <artifactId>myfaces-impl</artifactId>
- <version>${myfaces2.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- <version>1.8.0</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.myfaces.extensions.validator.validation-modules</groupId>
- <artifactId>myfaces-extval-bean-validation</artifactId>
- <version>${extval.version}</version>
- <scope>provided</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <!--
- - Build and install into the repository some additional artifacts that we don't
- - want to build during normal development because they take too long.
- -->
- <id>generate-assembly</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <!-- Install in the repository a "-javadoc.jar" file -->
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.4</version>
- <executions>
- <execution>
- <id>attach-javadoc</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <!-- Install in the repository a "-sources.jar" file -->
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-source</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-
-</project>
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/BehaviorHandlerReloadingStrategy.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/BehaviorHandlerReloadingStrategy.java
deleted file mode 100644
index 728a2ae..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/BehaviorHandlerReloadingStrategy.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.facelet;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.extensions.scripting.core.reloading.SimpleReloadingStrategy;
-import org.apache.myfaces.extensions.scripting.core.util.Cast;
-import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
-
-import javax.faces.view.facelets.BehaviorConfig;
-import javax.faces.view.facelets.BehaviorHandler;
-import javax.faces.view.facelets.ComponentHandler;
-
-/**
- * The reloading strategy for our behavior tag handlers
- * note since we do not have an official api we must
- * enforce a getConverterConfig() method to allow
- * the reloading of converter tag handlers
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class BehaviorHandlerReloadingStrategy extends SimpleReloadingStrategy {
- public BehaviorHandlerReloadingStrategy(ScriptingWeaver weaver) {
- super(weaver);
- }
-
- @Override
- public Object reload(Object scriptingInstance, int artifactType) {
- if (!(scriptingInstance instanceof ComponentHandler)) return scriptingInstance;
- Class aclass = _weaver.reloadScriptingClass(scriptingInstance.getClass());
- if (aclass.hashCode() == scriptingInstance.getClass().hashCode()) {
- //class of this object has not changed although
- // reload is enabled we can skip the rest now
- return scriptingInstance;
- }
- BehaviorHandler oldHandler = (BehaviorHandler) scriptingInstance;
- /**
- *
- */
- BehaviorConfig config = (BehaviorConfig) ReflectUtil.executeMethod(oldHandler, "getBehaviorConfig");
- BehaviorHandler newHandler = (BehaviorHandler) ReflectUtil.instantiate(aclass, new Cast(BehaviorConfig.class, config));
-
- //save all pending non config related properties wherever possible
- super.mapProperties(newHandler, oldHandler);
-
- return newHandler;
- }
-
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ComponentHandlerReloadingStrategy.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ComponentHandlerReloadingStrategy.java
deleted file mode 100644
index 14936c7..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ComponentHandlerReloadingStrategy.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.facelet;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.extensions.scripting.core.reloading.SimpleReloadingStrategy;
-import org.apache.myfaces.extensions.scripting.core.util.Cast;
-import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
-
-import javax.faces.view.facelets.ComponentConfig;
-import javax.faces.view.facelets.ComponentHandler;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ComponentHandlerReloadingStrategy extends SimpleReloadingStrategy {
-
- public ComponentHandlerReloadingStrategy(ScriptingWeaver weaver) {
- super(weaver);
- }
-
- @Override
- public Object reload(Object scriptingInstance, int artifactType) {
- if (!(scriptingInstance instanceof ComponentHandler)) return scriptingInstance;
- Class aclass = _weaver.reloadScriptingClass(scriptingInstance.getClass());
- if (aclass.hashCode() == scriptingInstance.getClass().hashCode()) {
- //class of this object has not changed although
- // reload is enabled we can skip the rest now
- return scriptingInstance;
- }
- ComponentHandler oldHandler = (ComponentHandler) scriptingInstance;
- ComponentConfig config = oldHandler.getComponentConfig();
- ComponentHandler newHandler = (ComponentHandler) ReflectUtil.instantiate(aclass, new Cast(ComponentConfig.class, config));
-
- //save all pending non config related properties wherever possible
- super.mapProperties(newHandler, oldHandler);
-
- return newHandler;
- }
-
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ConverterHandlerReloadingStrategy.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ConverterHandlerReloadingStrategy.java
deleted file mode 100644
index e8479b4..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ConverterHandlerReloadingStrategy.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.facelet;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.extensions.scripting.core.reloading.SimpleReloadingStrategy;
-import org.apache.myfaces.extensions.scripting.core.util.Cast;
-import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
-
-import javax.faces.view.facelets.*;
-
-/**
- * The reloading strategy for our converter tag handlers
- * note since we do not have an official api we must
- * enforce a getConverterConfig() method to allow
- * the reloading of converter tag handlers
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-@SuppressWarnings("unused")//used dynamically
-public class ConverterHandlerReloadingStrategy extends SimpleReloadingStrategy {
-
- public ConverterHandlerReloadingStrategy(ScriptingWeaver weaver) {
- super(weaver);
- }
-
- @Override
- public Object reload(Object scriptingInstance, int artifactType) {
- if (!(scriptingInstance instanceof ComponentHandler)) return scriptingInstance;
- Class aclass = _weaver.reloadScriptingClass(scriptingInstance.getClass());
- if (aclass.hashCode() == scriptingInstance.getClass().hashCode()) {
- //class of this object has not changed although
- // reload is enabled we can skip the rest now
- return scriptingInstance;
- }
- ConverterHandler oldHandler = (ConverterHandler) scriptingInstance;
- /**
- *
- */
- ConverterConfig config = (ConverterConfig) ReflectUtil.executeMethod(oldHandler, "getConverterConfig");
- ConverterHandler newHandler = (ConverterHandler) ReflectUtil.instantiate(aclass, new Cast(ConverterConfig.class, config));
-
- //save all pending non config related properties wherever possible
- super.mapProperties(newHandler, oldHandler);
-
- return newHandler;
- }
-
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingBehaviorTagHandlerDelegate.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingBehaviorTagHandlerDelegate.java
deleted file mode 100644
index 89cb036..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingBehaviorTagHandlerDelegate.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.facelet;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.view.facelets.tag.jsf.BehaviorTagHandlerDelegate;
-
-import javax.faces.component.UIComponent;
-import javax.faces.view.facelets.*;
-import java.io.IOException;
-
-/**
- * Behavior Tag Handler which introduces reloading behavior
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ReloadingBehaviorTagHandlerDelegate extends TagHandlerDelegate {
-
- BehaviorHandler _owner;
- TagHandlerDelegate _delegate;
-
- public ReloadingBehaviorTagHandlerDelegate(BehaviorHandler owner) {
- applyOwner(owner);
- }
-
- private void applyOwner(BehaviorHandler owner) {
- _owner = owner;
- _delegate = new BehaviorTagHandlerDelegate(_owner);
- }
-
- @Override
- public void apply(FaceletContext ctx, UIComponent comp) throws IOException {
- if (WeavingContext.isDynamic(_owner.getClass())) {
- BehaviorHandler newOwner = (BehaviorHandler) WeavingContext.getWeaver().reloadScriptingInstance(_owner, ScriptingConst.ARTIFACT_TYPE_BEHAVIOR_HANDLER);
- if (!newOwner.getClass().equals(_owner.getClass())) {
- applyOwner(newOwner);
- }
- }
- _owner.apply(ctx, comp);
- }
-
- @Override
- public MetaRuleset createMetaRuleset(Class type) {
- return _delegate.createMetaRuleset(type);
- }
-
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingComponentTagHandlerDelegate.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingComponentTagHandlerDelegate.java
deleted file mode 100644
index 6234fa9..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingComponentTagHandlerDelegate.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.facelet;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.facelet.support.ComponentRule;
-import org.apache.myfaces.extensions.scripting.facelet.support.SwitchingMetarulesetImpl;
-import org.apache.myfaces.view.facelets.tag.jsf.*;
-
-import javax.faces.component.ActionSource;
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.component.ValueHolder;
-import javax.faces.view.facelets.*;
-import javax.faces.view.facelets.ComponentHandler;
-import java.io.IOException;
-
-/**
- * we provide our own component tag handler factory impl
- * so that we can deal with refreshing of components
- * on Facelets level without running into
- * nasty type exceptions
- */
-public class ReloadingComponentTagHandlerDelegate extends TagHandlerDelegate {
-
- ComponentHandler _owner;
- TagHandlerDelegate _delegate;
-
- public ReloadingComponentTagHandlerDelegate(ComponentHandler owner) {
- applyOwner(owner);
- }
-
- private void applyOwner(ComponentHandler owner) {
- _owner = owner;
- _delegate = new ComponentTagHandlerDelegate(_owner);
- }
-
- @Override
- public void apply(FaceletContext ctx, UIComponent comp) throws IOException {
- if (WeavingContext.isDynamic(_owner.getClass())) {
- ComponentHandler newOwner = (ComponentHandler) WeavingContext.getWeaver().reloadScriptingInstance(_owner, ScriptingConst.ARTIFACT_TYPE_COMPONENT_HANDLER);
- if (!newOwner.getClass().equals(_owner.getClass())) {
- applyOwner(newOwner);
- }
- }
- _delegate.apply(ctx, comp);
- }
-
- public MetaRuleset createMetaRuleset(Class type) {
- //We have to create a different meta rule set for dynamic classes
- //which have weaver instantiation criteria, the original meta rule set
- //first applies the attributes and then calls BeanPropertyTagRule
- //that one however caches the current method and does not take into consideration
- //that classes can be changed on the fly
-
- // if (WeavingContext.isDynamic(type)) {
- MetaRuleset m = new SwitchingMetarulesetImpl(_owner.getTag(), type);
- // ignore standard component attributes
- m.ignore("binding").ignore("id");
-
- // add auto wiring for attributes
- m.addRule(ComponentRule.Instance);
-
- // if it's an ActionSource
- if (ActionSource.class.isAssignableFrom(type)) {
- m.addRule(ActionSourceRule.INSTANCE);
- }
-
- // if it's a ValueHolder
- if (ValueHolder.class.isAssignableFrom(type)) {
- m.addRule(ValueHolderRule.INSTANCE);
-
- // if it's an EditableValueHolder
- if (EditableValueHolder.class.isAssignableFrom(type)) {
- m.ignore("submittedValue");
- m.ignore("valid");
- m.addRule(EditableValueHolderRule.INSTANCE);
- }
- }
-
- return m;
- //}
-
- //return _delegate.createMetaRuleset(type);
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingConverterTagHandlerDelegate.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingConverterTagHandlerDelegate.java
deleted file mode 100644
index 6f116b8..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingConverterTagHandlerDelegate.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.facelet;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.view.facelets.tag.jsf.ConverterTagHandlerDelegate;
-
-import javax.faces.component.UIComponent;
-import javax.faces.view.facelets.*;
-import java.io.IOException;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ReloadingConverterTagHandlerDelegate extends TagHandlerDelegate {
-
- ConverterHandler _owner;
- TagHandlerDelegate _delegate;
-
- public ReloadingConverterTagHandlerDelegate(ConverterHandler owner) {
- applyOwner(owner);
- }
-
- private void applyOwner(ConverterHandler owner) {
- _owner = owner;
- _delegate = new ConverterTagHandlerDelegate(_owner);
- }
-
- @Override
- public void apply(FaceletContext ctx, UIComponent comp) throws IOException {
- if (WeavingContext.isDynamic(_owner.getClass())) {
- ConverterHandler newOwner = (ConverterHandler) WeavingContext.getWeaver().reloadScriptingInstance(_owner, ScriptingConst.ARTIFACT_TYPE_CONVERTER_HANDLER);
- if(!newOwner.getClass().equals(_owner.getClass())) {
- applyOwner(newOwner);
- }
- }
- _delegate.apply(ctx, comp);
- }
-
- @Override
- public MetaRuleset createMetaRuleset(Class type) {
- return _delegate.createMetaRuleset(type);
- }
-
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingValidatorTagHandlerDelegate.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingValidatorTagHandlerDelegate.java
deleted file mode 100644
index 9dba0d8..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingValidatorTagHandlerDelegate.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.facelet;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.view.facelets.tag.jsf.ValidatorTagHandlerDelegate;
-
-import javax.faces.component.UIComponent;
-import javax.faces.view.facelets.FaceletContext;
-import javax.faces.view.facelets.MetaRuleset;
-import javax.faces.view.facelets.TagHandlerDelegate;
-import javax.faces.view.facelets.ValidatorHandler;
-import java.io.IOException;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ReloadingValidatorTagHandlerDelegate extends TagHandlerDelegate {
-
- ValidatorHandler _owner;
- TagHandlerDelegate _delegate;
-
- public ReloadingValidatorTagHandlerDelegate(ValidatorHandler owner) {
- applyOwner(owner);
- }
-
- private void applyOwner(ValidatorHandler owner) {
- _owner = owner;
- _delegate = new ValidatorTagHandlerDelegate(_owner);
- }
-
- @Override
- public void apply(FaceletContext ctx, UIComponent comp) throws IOException {
- if (WeavingContext.isDynamic(_owner.getClass())) {
- ValidatorHandler newOwner = (ValidatorHandler) WeavingContext.getWeaver().reloadScriptingInstance(_owner, ScriptingConst.ARTIFACT_TYPE_VALIDATOR_HANDLER);
- if (!newOwner.getClass().equals(_owner.getClass())) {
- applyOwner(newOwner);
- }
- }
- _owner.apply(ctx, comp);
- }
-
- @Override
- public MetaRuleset createMetaRuleset(Class type) {
- return _delegate.createMetaRuleset(type);
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReroutingResourceResolver.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReroutingResourceResolver.java
deleted file mode 100644
index 8e5bf4f..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReroutingResourceResolver.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.facelet;
-
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.view.facelets.impl.DefaultResourceResolver;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * decorated Facelet resource resolver to reroute
- * the resource requests to our source path if possible
- */
-public class ReroutingResourceResolver extends DefaultResourceResolver {
-
- DefaultResourceResolver _delegate = new DefaultResourceResolver();
- volatile boolean _initiated = false;
- List<String> _resourceDirs = null;
-
- Logger log = Logger.getLogger(this.getClass().getName());
-
- @Override
- public URL resolveUrl(String path) {
-
- if (!_initiated) {
- _resourceDirs = WeavingContext.getConfiguration().getResourceDirs();
- _initiated = true;
- }
-
- if (_resourceDirs != null && !_resourceDirs.isEmpty()) {
- for (String resourceDir : _resourceDirs) {
- File resource = new File(resourceDir + path);
- if (resource.exists()) try {
- return resource.toURI().toURL();
- } catch (MalformedURLException e) {
- log.log(Level.SEVERE, "",e);
- }
- }
- }
-
- return _delegate.resolveUrl(path);
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/TagHandlerDelegateFactoryImpl.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/TagHandlerDelegateFactoryImpl.java
deleted file mode 100644
index 1c64188..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/TagHandlerDelegateFactoryImpl.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.facelet;
-
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.view.facelets.tag.jsf.BehaviorTagHandlerDelegate;
-import org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegate;
-import org.apache.myfaces.view.facelets.tag.jsf.ConverterTagHandlerDelegate;
-import org.apache.myfaces.view.facelets.tag.jsf.ValidatorTagHandlerDelegate;
-
-import javax.faces.view.facelets.*;
-
-/**
- * Tag handler delegate factory which injects reloading
- * proxies for our facelet artifacts
- */
-public class TagHandlerDelegateFactoryImpl extends TagHandlerDelegateFactory {
-
- @Override
- public TagHandlerDelegate createBehaviorHandlerDelegate(
- BehaviorHandler owner) {
- if (WeavingContext.isDynamic(owner.getClass())) {
- return new ReloadingBehaviorTagHandlerDelegate(owner);
- } else {
- return new BehaviorTagHandlerDelegate(owner);
- }
- }
-
- @Override
- public TagHandlerDelegate createComponentHandlerDelegate(
- ComponentHandler owner) {
- return new ReloadingComponentTagHandlerDelegate(owner);
- }
-
- @Override
- public TagHandlerDelegate createConverterHandlerDelegate(
- ConverterHandler owner) {
- if (WeavingContext.isDynamic(owner.getClass())) {
- return new ReloadingConverterTagHandlerDelegate(owner);
- } else {
- return new ConverterTagHandlerDelegate(owner);
- }
- }
-
- @Override
- public TagHandlerDelegate createValidatorHandlerDelegate(
- ValidatorHandler owner) {
- if (WeavingContext.isDynamic(owner.getClass())) {
- return new ReloadingValidatorTagHandlerDelegate(owner);
- } else {
- return new ValidatorTagHandlerDelegate(owner);
- }
- }
-}
-
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ValidatorHandlerReloadingStrategy.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ValidatorHandlerReloadingStrategy.java
deleted file mode 100644
index 2d75f72..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ValidatorHandlerReloadingStrategy.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.facelet;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.extensions.scripting.core.reloading.SimpleReloadingStrategy;
-import org.apache.myfaces.extensions.scripting.core.util.Cast;
-import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
-
-import javax.faces.view.facelets.*;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ValidatorHandlerReloadingStrategy extends SimpleReloadingStrategy {
-
- public ValidatorHandlerReloadingStrategy(ScriptingWeaver weaver) {
- super(weaver);
- }
-
- @Override
- public Object reload(Object scriptingInstance, int artifactType) {
- if (!(scriptingInstance instanceof ComponentHandler)) return scriptingInstance;
- Class aclass = _weaver.reloadScriptingClass(scriptingInstance.getClass());
- if (aclass.hashCode() == scriptingInstance.getClass().hashCode()) {
- //class of this object has not changed although
- // reload is enabled we can skip the rest now
- return scriptingInstance;
- }
- ValidatorHandler oldHandler = (ValidatorHandler) scriptingInstance;
- ValidatorConfig config = oldHandler.getValidatorConfig();
- ValidatorHandler newHandler = (ValidatorHandler) ReflectUtil.instantiate(aclass, new Cast(ValidatorConfig.class, config));
-
- //save all pending non config related properties wherever possible
- super.mapProperties(newHandler, oldHandler);
-
- return newHandler;
- }
-
-}
-
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/support/ComponentRule.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/support/ComponentRule.java
deleted file mode 100644
index b7f2f58..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/support/ComponentRule.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.facelet.support;
-
-import javax.faces.component.UIComponent;
-import javax.faces.view.facelets.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * we have to re implement the component rule class here
- * because it is declared private in the original
- * implementation
- */
-public final class ComponentRule extends MetaRule {
-
- final class LiteralAttributeMetadata extends Metadata {
- private final String _name;
- private final String _value;
-
- public LiteralAttributeMetadata(String name, String value) {
- _name = name;
- _value = value;
- }
-
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((UIComponent) instance).getAttributes().put(_name, _value);
- }
- }
-
- final static class ValueExpressionMetadata extends Metadata {
- private final String _name;
-
- private final TagAttribute _attr;
-
- private final Class<?> _type;
-
- public ValueExpressionMetadata(String name, Class<?> type, TagAttribute attr) {
- _name = name;
- _attr = attr;
- _type = type;
- }
-
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((UIComponent) instance).setValueExpression(_name, _attr.getValueExpression(ctx, _type));
- }
- }
-
- //private final static Logger log = Logger.getLogger("facelets.tag.component");
- private final static Logger log = Logger.getLogger(ComponentRule.class.getName());
-
- public final static ComponentRule Instance = new ComponentRule();
-
- public ComponentRule() {
- super();
- }
-
- public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
- if (meta.isTargetInstanceOf(UIComponent.class)) {
- // if component and dynamic, then must set expression
- if (!attribute.isLiteral()) {
- Class<?> type = meta.getPropertyType(name);
- if (type == null) {
- type = Object.class;
- }
-
- return new ValueExpressionMetadata(name, type, attribute);
- } else if (meta.getWriteMethod(name) == null) {
-
- // this was an attribute literal, but not property
- warnAttr(attribute, meta.getTargetClass(), name);
-
- return new LiteralAttributeMetadata(name, attribute.getValue());
- }
- }
- return null;
- }
-
- private static void warnAttr(TagAttribute attr, Class<?> type, String n) {
- if (log.isLoggable(Level.FINER)) {
- log.finer(attr + " Property '" + n + "' is not on type: " + type.getName());
- }
- }
-
-}
-
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/support/InvokeDynamicBeanPropertyTagRule.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/support/InvokeDynamicBeanPropertyTagRule.java
deleted file mode 100644
index 698f388..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/support/InvokeDynamicBeanPropertyTagRule.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.facelet.support;
-
-import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
-
-import javax.faces.view.facelets.FaceletContext;
-import javax.faces.view.facelets.Metadata;
-import javax.faces.view.facelets.MetadataTarget;
-import javax.faces.view.facelets.TagAttribute;
-import java.lang.reflect.Method;
-
-/**
- * We have to introduce a BeanPropertyTagRule
- * which calls the setter of a given component
- * on a weaker base than the original facelets component
- * property tag rule does.
- * By not enforcing a strict per object/class policy on calling
- * the setter we are able to reload the classes on the fly
- * <p/>
- * the original approach was to cache the classes, and then
- * call the invoke method on the existing class
- * if we now exchange the classes we have a problem...
- * By making the invocation of the method independend from the underlying
- * class (sort of calling an invokedynamic) we can bypass this problem
- * on facelets level.
- */
-public class InvokeDynamicBeanPropertyTagRule {
- public final static InvokeDynamicBeanPropertyTagRule Instance = new InvokeDynamicBeanPropertyTagRule();
-
- public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
- Method m = meta.getWriteMethod(name);
-
- // if the property is writable
- if (m != null) {
- if (attribute.isLiteral()) {
- return new LiteralPropertyMetadata(m, attribute);
- } else {
- return new DynamicPropertyMetadata(m, attribute);
- }
- }
-
- return null;
- }
-
- final static class LiteralPropertyMetadata extends Metadata {
-
- private final Method method;
-
- private final TagAttribute attribute;
-
- private Object[] value;
-
- public LiteralPropertyMetadata(Method method, TagAttribute attribute) {
- this.method = method;
- this.attribute = attribute;
- }
-
- public void applyMetadata(FaceletContext ctx, Object instance) {
- if (value == null) {
- String str = this.attribute.getValue();
- value = new Object[]{ctx.getExpressionFactory().coerceToType(str, method.getParameterTypes()[0])};
- }
- //What we do here is simply to call an invoke dynamic on the method with the same name
- //but on the new instance of, that way we can bypass class problems
- //because the method reference has stored the old class in our case
- ReflectUtil.executeMethod(instance, method.getName(), this.value);
- }
-
- }
-
- final static class DynamicPropertyMetadata extends Metadata {
-
- private final Method method;
-
- private final TagAttribute attribute;
-
- private final Class<?> type;
-
- public DynamicPropertyMetadata(Method method, TagAttribute attribute) {
- this.method = method;
- this.type = method.getParameterTypes()[0];
- this.attribute = attribute;
- }
-
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ReflectUtil.executeMethod(instance, method.getName(), new Object[]{attribute.getObject(ctx, type)});
- }
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/support/SwitchingBeanPropertyTagRule.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/support/SwitchingBeanPropertyTagRule.java
deleted file mode 100644
index 2c07ce5..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/support/SwitchingBeanPropertyTagRule.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.facelet.support;
-
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.view.facelets.tag.BeanPropertyTagRule;
-
-import javax.faces.view.facelets.MetaRule;
-import javax.faces.view.facelets.Metadata;
-import javax.faces.view.facelets.MetadataTarget;
-import javax.faces.view.facelets.TagAttribute;
-
-/**
- * Bean property tag rule
- * which switches between the fast static
- * version and the slower invoke dynamic
- * version depending on the class type of
- * the incoming instance
- */
-public class SwitchingBeanPropertyTagRule extends MetaRule {
-
- InvokeDynamicBeanPropertyTagRule _invokeDynamic = InvokeDynamicBeanPropertyTagRule.Instance;
- BeanPropertyTagRule _invokeStatic = BeanPropertyTagRule.INSTANCE;
-
- public static volatile SwitchingBeanPropertyTagRule Instance = new SwitchingBeanPropertyTagRule();
-
- @Override
- public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
- if (WeavingContext.isDynamic(meta.getTargetClass())) {
- return _invokeDynamic.applyRule(name, attribute, meta);
- } else {
- return _invokeStatic.applyRule(name, attribute, meta);
- }
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/support/SwitchingMetarulesetImpl.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/support/SwitchingMetarulesetImpl.java
deleted file mode 100644
index ff4d731..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/support/SwitchingMetarulesetImpl.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.facelet.support;
-
-import org.apache.myfaces.view.facelets.tag.MetaRulesetImpl;
-import org.apache.myfaces.view.facelets.tag.MetadataImpl;
-import org.apache.myfaces.view.facelets.tag.MetadataTargetImpl;
-import org.apache.myfaces.view.facelets.util.ParameterCheck;
-
-import javax.faces.view.facelets.*;
-import java.beans.IntrospectionException;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * we have to to do a full reimplementation of the rule set
- * because otherwise we could not plant the switching bean reloading
- * rule due to private props in the original code
- */
-public class SwitchingMetarulesetImpl extends MetaRuleset {
- private final static Metadata NONE = new NullMetadata();
-
- //private final static Logger log = Logger.getLogger("facelets.tag.meta");
- private final static Logger log = Logger.getLogger(MetaRulesetImpl.class.getName());
-
- private final static WeakHashMap<String, MetadataTarget> _metadata = new WeakHashMap<String, MetadataTarget>();
-
- private final Map<String, TagAttribute> _attributes;
-
- private final List<Metadata> _mappers;
-
- private final List<MetaRule> _rules;
-
- private final Tag _tag;
-
- private final Class<?> _type;
-
- public SwitchingMetarulesetImpl(Tag tag, Class<?> type) {
- _tag = tag;
- _type = type;
- _attributes = new HashMap<String, TagAttribute>();
- _mappers = new ArrayList<Metadata>();
- _rules = new ArrayList<MetaRule>();
-
- // setup attributes
- for (TagAttribute attribute : _tag.getAttributes().getAll()) {
- _attributes.put(attribute.getLocalName(), attribute);
- }
-
- // add default rules
- _rules.add(SwitchingBeanPropertyTagRule.Instance);
- }
-
- public MetaRuleset add(Metadata mapper) {
- ParameterCheck.notNull("mapper", mapper);
-
- if (!_mappers.contains(mapper)) {
- _mappers.add(mapper);
- }
-
- return this;
- }
-
- public MetaRuleset addRule(MetaRule rule) {
- ParameterCheck.notNull("rule", rule);
-
- _rules.add(rule);
-
- return this;
- }
-
- public MetaRuleset alias(String attribute, String property) {
- ParameterCheck.notNull("attribute", attribute);
- ParameterCheck.notNull("property", property);
-
- TagAttribute attr = (TagAttribute) _attributes.remove(attribute);
- if (attr != null) {
- _attributes.put(property, attr);
- }
-
- return this;
- }
-
- public Metadata finish() {
- assert !_rules.isEmpty();
-
- if (!_attributes.isEmpty()) {
- MetadataTarget target = this._getMetadataTarget();
- int ruleEnd = _rules.size() - 1;
-
- // now iterate over attributes
- for (Map.Entry<String, TagAttribute> entry : _attributes.entrySet()) {
- Metadata data = null;
-
- int i = ruleEnd;
-
- // First loop is always safe
- do {
- MetaRule rule = _rules.get(i);
- data = rule.applyRule(entry.getKey(), entry.getValue(), target);
- i--;
- } while (data == null && i >= 0);
-
- if (data == null) {
- if (log.isLoggable(Level.SEVERE)) {
- log.severe(entry.getValue() + " Unhandled by MetaTagHandler for type " + _type.getName());
- }
- } else {
- _mappers.add(data);
- }
- }
- }
-
- if (_mappers.isEmpty()) {
- return NONE;
- } else {
- return new MetadataImpl(_mappers.toArray(new Metadata[_mappers.size()]));
- }
- }
-
- public MetaRuleset ignore(String attribute) {
- ParameterCheck.notNull("attribute", attribute);
-
- _attributes.remove(attribute);
-
- return this;
- }
-
- public MetaRuleset ignoreAll() {
- _attributes.clear();
-
- return this;
- }
-
- private final MetadataTarget _getMetadataTarget() {
- String key = _type.getName();
-
- MetadataTarget meta = _metadata.get(key);
- if (meta == null) {
- try {
- meta = new MetadataTargetImpl(_type);
- }
- catch (IntrospectionException e) {
- throw new TagException(_tag, "Error Creating TargetMetadata", e);
- }
-
- _metadata.put(key, meta);
- }
-
- return meta;
- }
-
- private static class NullMetadata extends Metadata {
- /**
- * {@inheritDoc}
- */
- @Override
- public void applyMetadata(FaceletContext ctx, Object instance) {
- // do nothing
- }
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingApplicationFactory.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingApplicationFactory.java
deleted file mode 100644
index 7d5eb95..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingApplicationFactory.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories;
-
-import org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implemetations.ApplicationProxy;
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-import javax.faces.application.ApplicationFactory;
-import javax.faces.application.Application;
-
-/**
- * Application factory which introduces
- * scripting proxies for their artefacts
- * <p/>
- * We use a mix of AOP and helper constructs
- * to reach the goal to be dynamic.
- * For most artefacts we just need to
- * check if the object is a Groovy object
- * and then reload at their connection interfaces
- * <p/>
- * Some artefacts have a longer lifespan and/or are stateless
- * for those we have to work with reloading AOP
- *
- * @author Werner Punz
- */
-public class ScriptingApplicationFactory extends ApplicationFactory implements Decorated {
-
- ApplicationFactory _delegate;
-
-
- public ScriptingApplicationFactory(ApplicationFactory delegate) {
- _delegate = delegate;
-
- }
-
- public Application getApplication() {
- Application retVal = _delegate.getApplication();
-
- if (WeavingContext.isScriptingEnabled() && !(retVal instanceof ApplicationProxy))
- retVal = new ApplicationProxy(retVal);
-
- return retVal;
- }
-
- public void setApplication(Application application) {
- if (WeavingContext.isScriptingEnabled() && !(application instanceof ApplicationProxy))
- application = new ApplicationProxy(application);
-
- _delegate.setApplication(application);
- }
-
- @Override
- public ApplicationFactory getWrapped() {
- return _delegate.getWrapped();
- }
-
- public Object getDelegate() {
- return _delegate;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingFacesContextFactory.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingFacesContextFactory.java
deleted file mode 100644
index 1352eef..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingFacesContextFactory.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories;
-
-import org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implemetations.FacesContextProxy;
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-import javax.faces.context.FacesContext;
-import javax.faces.context.FacesContextFactory;
-import javax.faces.lifecycle.Lifecycle;
-import javax.faces.FacesException;
-
-/**
- * Faces context weaver which builds
- * our reloading proxy around the current faces context
- *
- * @author Werner Punz
- */
-public class ScriptingFacesContextFactory extends javax.faces.context.FacesContextFactory implements Decorated {
-
- public FacesContextFactory _delegate;
-
- public ScriptingFacesContextFactory(FacesContextFactory delegate) {
- _delegate = delegate;
- }
-
- public void setDelegate(FacesContextFactory delegate) {
- _delegate = delegate;
- }
-
- public FacesContext getFacesContext(Object o, Object o1, Object o2, Lifecycle lifecycle) throws FacesException {
- FacesContext retVal = _delegate.getFacesContext(o, o1, o2, lifecycle);
-
- if (WeavingContext.isScriptingEnabled() && !(retVal instanceof FacesContextProxy))
- return new FacesContextProxy(retVal);
- return retVal;
- }
-
- @Override
- public FacesContextFactory getWrapped() {
- return _delegate.getWrapped();
- }
-
- public Object getDelegate() {
- return _delegate;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingLifecycleFactory.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingLifecycleFactory.java
deleted file mode 100644
index 16898cd..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingLifecycleFactory.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories;
-
-import org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implemetations.LifefcycleProxy;
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-import javax.faces.lifecycle.LifecycleFactory;
-import javax.faces.lifecycle.Lifecycle;
-import java.util.Iterator;
-
-/**
- * Lifecyclefactory which introduces scripting proxies
- * for their artefacts
- *
- * @author Werner Punz
- */
-public class ScriptingLifecycleFactory extends LifecycleFactory implements Decorated {
-
- LifecycleFactory _delegate;
-
-
- public ScriptingLifecycleFactory(LifecycleFactory delegate) {
- _delegate = delegate;
- }
-
- public void addLifecycle(String s, Lifecycle lifecycle) {
- if (WeavingContext.isScriptingEnabled() && !(lifecycle instanceof LifefcycleProxy))
- lifecycle = new LifefcycleProxy(lifecycle);
- _delegate.addLifecycle(s, lifecycle);
- }
-
- public Lifecycle getLifecycle(String s) {
- Lifecycle retVal = _delegate.getLifecycle(s);
- if (WeavingContext.isScriptingEnabled() && !(retVal instanceof LifefcycleProxy))
- retVal = new LifefcycleProxy(retVal);
-
- return retVal;
- }
-
- public Iterator getLifecycleIds() {
- return _delegate.getLifecycleIds();
- }
-
- public void setDelegate(LifecycleFactory delegate) {
- this._delegate = delegate;
- }
-
- @Override
- public LifecycleFactory getWrapped() {
- return _delegate.getWrapped();
- }
-
- public Object getDelegate() {
- return _delegate;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingRenderkitFactory.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingRenderkitFactory.java
deleted file mode 100644
index b5bc315..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingRenderkitFactory.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories;
-
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implemetations.RenderkitProxy;
-
-import javax.faces.render.RenderKitFactory;
-import javax.faces.render.RenderKit;
-import javax.faces.context.FacesContext;
-import java.util.Iterator;
-
-/**
- * Scripting enabled renderkit factory
- *
- * @author Werner Punz
- */
-public class ScriptingRenderkitFactory extends RenderKitFactory implements Decorated {
-
-
- public ScriptingRenderkitFactory(RenderKitFactory delegate) {
- _delegate = delegate;
- }
-
- public void addRenderKit(String s, RenderKit renderKit) {
- if (WeavingContext.isScriptingEnabled() && renderKit != null && !(renderKit instanceof RenderkitProxy))
- renderKit = new RenderkitProxy(renderKit);
-
- _delegate.addRenderKit(s, renderKit);
- }
-
- public RenderKit getRenderKit(FacesContext facesContext, String s) {
- RenderKit retVal = _delegate.getRenderKit(facesContext, s);
- if (WeavingContext.isScriptingEnabled() && retVal != null && !(retVal instanceof RenderkitProxy))
- retVal = new RenderkitProxy(retVal);
- return retVal;
- }
-
- public Iterator getRenderKitIds() {
- return _delegate.getRenderKitIds();
- }
-
- public void setDelegate(RenderKitFactory delegate) {
- _delegate = delegate;
- }
-
- @Override
- public RenderKitFactory getWrapped() {
- return _delegate.getWrapped();
- }
-
- RenderKitFactory _delegate = null;
-
- public Object getDelegate() {
- return _delegate;
- }
-}
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
deleted file mode 100644
index 6b7e7f1..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java
+++ /dev/null
@@ -1,841 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implemetations;
-
-import org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver;
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.jsf2.annotation.purged.*;
-
-import javax.el.*;
-import javax.faces.FacesException;
-import javax.faces.application.*;
-import javax.faces.component.UIComponent;
-import javax.faces.component.behavior.Behavior;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.el.*;
-import javax.faces.event.*;
-import javax.faces.validator.Validator;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * @author Werner Punz
- * <p/>
- * our decorating applicstion
- * which should resolve our bean issues within a central
- * bean processing interceptor
- */
-public class ApplicationProxy extends Application implements Decorated {
-
- Application _delegate = null;
-
- /*
- * separate map needed for the behavior ids, because
- * the original is immutable
- * we have to do a double bookkeeping
- * here
- */
- Map<String, String> _behaviors = new ConcurrentHashMap<String, String>();
-
- /**
- * special data structure to save our
- * object -> proxy references
- */
- class EventHandlerProxyEntry {
- Class event;
- Decorated proxy;
-
- EventHandlerProxyEntry(Class event, Decorated proxy) {
- this.event = event;
- this.proxy = proxy;
- }
-
- @SuppressWarnings("unused")
- public Class getEvent() {
- return event;
- }
-
- @SuppressWarnings("unused")
- public void setEvent(Class event) {
- this.event = event;
- }
-
- public Decorated getProxy() {
- return proxy;
- }
-
- @SuppressWarnings("unused")
- public void setProxy(Decorated proxy) {
- this.proxy = proxy;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- EventHandlerProxyEntry that = (EventHandlerProxyEntry) o;
-
- return !(event != null ? !event.equals(that.event) : that.event != null) && !(proxy != null ? !proxy.getDelegate().getClass().getName().equals(that.proxy.getDelegate().getClass().getName()) : that.proxy != null);
-
- }
-
- @Override
- public int hashCode() {
- int result = event.hashCode();
- result = 31 * result + proxy.getDelegate().getClass().getName().hashCode();
- return result;
- }
- }
-
- /**
- * now at the first look this looks like a weird construct
- * but the standard java set imposes this limit since
- * we have to iterate over the entire set to reach the correct element
- * the trick is to save the same object in as both key and value
- * and now if we generate a new key on an object
- * we can fetch our proxy which might already contain
- * the same object in a refreshed state from the value
- * part of the set, in our case
- * using hash maps should speed things up
- * <p/>
- * since we only have few write operations but access
- * the map multithreaded we use concurrentHashMap here
- */
- Map<EventHandlerProxyEntry, EventHandlerProxyEntry> _eventHandlerIdx = new ConcurrentHashMap<EventHandlerProxyEntry, EventHandlerProxyEntry>();
-
- volatile static boolean varResolverAdded = false;
-
- ELResolverProxy finalResolver = null;
-
- public ApplicationProxy(Application delegate) {
- _delegate = delegate;
- }
-
- public void addELResolver(ELResolver elResolver) {
- weaveDelegate();
- //we do not need a proxy here anymore because
- //we drop the beans directly
- _delegate.addELResolver(elResolver);
- }
-
- private void weaveDelegate() {
- if (_delegate != null) {
- _delegate = (Application) WeavingContext.getWeaver().reloadScriptingInstance(_delegate, ScriptingConst.ARTIFACT_TYPE_APPLICATION);
- }
- }
-
- public ELResolver getELResolver() {
- weaveDelegate();
-
- ELResolver retVal = _delegate.getELResolver();
- return retVal;
- }
-
- //TOD add a weaving for resource bundles
-
- public ResourceBundle getResourceBundle(FacesContext facesContext, String s) throws FacesException, NullPointerException {
- weaveDelegate();
- return _delegate.getResourceBundle(facesContext, s);
- }
-
- public UIComponent createComponent(ValueExpression valueExpression, FacesContext facesContext, String componentType) throws FacesException, NullPointerException {
- weaveDelegate();
- UIComponent component = _delegate.createComponent(valueExpression, facesContext, componentType);
- UIComponent oldComponent = component;
- //We can replace annotated components on the fly via
- //ApplicationImpl.addComponent(final String componentType, final String componentClassName)
-
- /*we are reweaving on the fly because we cannot be sure if
- * the class is not recycled all the time in the creation
- * code, in the renderer we do it on method base
- * due to the fact that our renderers are recycled via
- * a flyweight pattern
- *
- *
- * Also we cannot proxy here because there is no UIComponent interface
- * maybe in the long run we can make a decorator here instead
- * but for now lets try it this way
- */
- component = (UIComponent) reloadInstance(component, ScriptingConst.ARTIFACT_TYPE_COMPONENT);
-
- //we now have to check for an annotation change, but only in case a reload has happened
- if (component.getClass().hashCode() != oldComponent.getClass().hashCode()) {
- return handleAnnotationChange(component, valueExpression, facesContext, componentType);
- }
-
- return component;
-
- }
-
- public ExpressionFactory getExpressionFactory() {
- weaveDelegate();
- return _delegate.getExpressionFactory();
- }
-
- public void addELContextListener(ELContextListener elContextListener) {
- weaveDelegate();
- if (WeavingContext.isDynamic(elContextListener.getClass()))
- elContextListener = (ELContextListener) WeavingContext.createMethodReloadingProxyFromObject(elContextListener, ELContextListener.class, ScriptingConst.ARTIFACT_TYPE_ELCONTEXTLISTENER);
- _delegate.addELContextListener(elContextListener);
- }
-
- public void removeELContextListener(ELContextListener elContextListener) {
- weaveDelegate();
- _delegate.removeELContextListener(elContextListener);
- }
-
- public ELContextListener[] getELContextListeners() {
- weaveDelegate();
- return _delegate.getELContextListeners();
- }
-
- public ActionListener getActionListener() {
- weaveDelegate();
- ActionListener retVal = _delegate.getActionListener();
- if (WeavingContext.isDynamic(retVal.getClass()))
- retVal = (ActionListener) WeavingContext.createMethodReloadingProxyFromObject(retVal, ActionListener.class, ScriptingConst.ARTIFACT_TYPE_ACTIONLISTENER);
- return retVal;
- }
-
- public void setActionListener(ActionListener actionListener) {
- weaveDelegate();
- if (WeavingContext.isDynamic(actionListener.getClass()))
- actionListener = (ActionListener) WeavingContext.createMethodReloadingProxyFromObject(actionListener, ActionListener.class, ScriptingConst.ARTIFACT_TYPE_ACTIONLISTENER);
- _delegate.setActionListener(actionListener);
- }
-
- public Locale getDefaultLocale() {
- weaveDelegate();
- return _delegate.getDefaultLocale();
- }
-
- public void setDefaultLocale(Locale locale) {
- weaveDelegate();
- _delegate.setDefaultLocale(locale);
- }
-
- public String getDefaultRenderKitId() {
- weaveDelegate();
- return _delegate.getDefaultRenderKitId();
- }
-
- public void setDefaultRenderKitId(String s) {
- weaveDelegate();
- _delegate.setDefaultRenderKitId(s);
- }
-
- public String getMessageBundle() {
- weaveDelegate();
- return _delegate.getMessageBundle();
- }
-
- public void setMessageBundle(String s) {
- weaveDelegate();
- _delegate.setMessageBundle(s);
- }
-
- public NavigationHandler getNavigationHandler() {
- weaveDelegate();
- //defined in the setter to speed things up a little
- NavigationHandler retVal = _delegate.getNavigationHandler();
-
- //if (retVal != null && WeavingContext.isDynamic(retVal.getClass()))
- // retVal = new NavigationHandlerProxy(retVal);
- return retVal;
- }
-
- public void setNavigationHandler(NavigationHandler navigationHandler) {
- weaveDelegate();
-
- if (navigationHandler != null && WeavingContext.isDynamic(navigationHandler.getClass()))
- navigationHandler = new NavigationHandlerProxy(navigationHandler);
- _delegate.setNavigationHandler(navigationHandler);
- }
-
- @SuppressWarnings("deprecation")
- public PropertyResolver getPropertyResolver() {
- weaveDelegate();
- return _delegate.getPropertyResolver();
- }
-
- @SuppressWarnings("deprecation")
- public void setPropertyResolver(PropertyResolver propertyResolver) {
- weaveDelegate();
- _delegate.setPropertyResolver(propertyResolver);
- }
-
- @SuppressWarnings("deprecation")
- public VariableResolver getVariableResolver() {
- weaveDelegate();
- return _delegate.getVariableResolver();
- }
-
- @SuppressWarnings("deprecation")
- public void setVariableResolver(VariableResolver variableResolver) {
- weaveDelegate();
- if(!varResolverAdded) {
- variableResolver = new VariableResolverProxy(variableResolver);
- varResolverAdded = true;
- }
- _delegate.setVariableResolver(variableResolver);
- }
-
- public ViewHandler getViewHandler() {
- weaveDelegate();
- ViewHandler handler = _delegate.getViewHandler();
-
- /*
- We proxy here to enable dynamic reloading for
- methods in the long run, as soon as we hit
- java all our groovy reloading code is lost
- hence we have to work with proxies here
- */
- if (WeavingContext.isDynamic(handler.getClass()))
- handler = new ViewHandlerProxy(handler);
- return handler;
- }
-
- public void setViewHandler(ViewHandler viewHandler) {
- weaveDelegate();
- /*make sure you have the delegates as well in properties*/
- if (WeavingContext.isDynamic(viewHandler.getClass()))
- viewHandler = new ViewHandlerProxy(viewHandler);
-
- _delegate.setViewHandler(viewHandler);
- }
-
- public StateManager getStateManager() {
- weaveDelegate();
- return _delegate.getStateManager();
- }
-
- public void setStateManager(StateManager stateManager) {
- weaveDelegate();
- _delegate.setStateManager(stateManager);
- }
-
- public void addComponent(String componentType, String componentClass) {
- weaveDelegate();
- _delegate.addComponent(componentType, componentClass);
- }
-
- public UIComponent createComponent(String componentType) throws FacesException {
- weaveDelegate();
- //the components are generated anew very often
- //we cannot do an on object weaving here
- UIComponent oldComponent = _delegate.createComponent(componentType);
-
- /*we are reweaving on the fly because we cannot be sure if
- * the class is not recycled all the time in the creation
- * code, in the renderer we do it on method base
- * due to the fact that our renderers are recycled via
- * a flyweight pattern*/
- UIComponent component = (UIComponent) reloadInstance(oldComponent, ScriptingConst.ARTIFACT_TYPE_COMPONENT);
-
- //we now have to check for an annotation change, but only in case a reload has happened
- if (component.getClass().hashCode() != oldComponent.getClass().hashCode()) {
- return handleAnnotationChange(component, componentType);
- }
-
- return component;
-
- }
-
- @SuppressWarnings("deprecation")
- public UIComponent createComponent(ValueBinding valueBinding, FacesContext facesContext, String componentType) throws FacesException {
- weaveDelegate();
- UIComponent oldComponent = _delegate.createComponent(valueBinding, facesContext, componentType);
-
- /*we are reweaving on the fly because we cannot be sure if
- * the class is not recycled all the time in the creation
- * code, in the renderer we do it on method base
- * due to the fact that our renderers are recycled via
- * a flyweight pattern*/
- UIComponent component = (UIComponent) reloadInstance(oldComponent, ScriptingConst.ARTIFACT_TYPE_COMPONENT);
-
- //we now have to check for an annotation change, but only in case a reload has happened
- if (component.getClass().hashCode() != oldComponent.getClass().hashCode()) {
- return handleAnnotationChange(component, valueBinding, facesContext, componentType);
- }
-
- return component;
- }
-
- public Iterator<String> getComponentTypes() {
- weaveDelegate();
- return _delegate.getComponentTypes();
- }
-
- public void addConverter(String converterId, String converterClass) {
- weaveDelegate();
- /* if (converterClass.equals(PurgedConverter.class.getName())) {
- //purged case we do a full rescan
- WeavingContext.getWeaver().fullClassScan();
- Converter componentToChange = _delegate.createConverter(converterId);
- if (componentToChange instanceof PurgedConverter) {
- //Null not allowed here, but we set a purted converter to make
- //sure that we get errors on the proper level
- _delegate.addConverter(converterId, PurgedConverter.class.getName());
- }
- return;
- }*/
-
- _delegate.addConverter(converterId, converterClass);
- }
-
- public void addConverter(Class targetClass, String converterClass) {
- weaveDelegate();
- _delegate.addConverter(targetClass, converterClass);
- }
-
- public Converter createConverter(String converterId) {
- weaveDelegate();
- Converter retVal = _delegate.createConverter(converterId);
-
- /**
- * since createConverter is called only once
- * we have to work with method reloading proxies
- * we cannot use this technique extensively for speed reasons
- * most of the time it is fine just to work with
- *
- * reloading objects at their interception points
- */
- Converter newRetVal = (Converter) reloadInstance(retVal, ScriptingConst.ARTIFACT_TYPE_CONVERTER);
- if (newRetVal != retVal) {
- return _delegate.createConverter(converterId);
- }
-
- return retVal;
- }
-
- public Converter createConverter(Class aClass) {
- weaveDelegate();
- Converter retVal = _delegate.createConverter(aClass);
- Converter newRetVal = (Converter) reloadInstance(retVal, ScriptingConst.ARTIFACT_TYPE_CONVERTER);
- if (newRetVal != retVal) {
- return _delegate.createConverter(aClass);
- }
-
- return retVal;
- }
-
- public Iterator<String> getConverterIds() {
- weaveDelegate();
- return _delegate.getConverterIds();
- }
-
- public Iterator<Class<?>> getConverterTypes() {
- weaveDelegate();
- return _delegate.getConverterTypes();
- }
-
- @SuppressWarnings("deprecation")
- public MethodBinding createMethodBinding(String s, Class[] classes) throws ReferenceSyntaxException {
- weaveDelegate();
- return _delegate.createMethodBinding(s, classes);
- }
-
- public Iterator<Locale> getSupportedLocales() {
- weaveDelegate();
- return _delegate.getSupportedLocales();
- }
-
- public void setSupportedLocales(Collection<Locale> locales) {
- weaveDelegate();
- _delegate.setSupportedLocales(locales);
- }
-
- public void addValidator(String validatorId, String validatorClass) {
- weaveDelegate();
-/* if (validatorClass.equals(PurgedValidator.class.getName())) {
- //purged case we do a full rescane
- WeavingContext.getWeaver().fullClassScan();
- Validator componentToChange = _delegate.createValidator(validatorId);
- if (componentToChange instanceof PurgedValidator) {
- //Null not allowed here, but we set a purted validator to make
- //sure that we get errors on the proper level
- _delegate.addValidator(validatorId, PurgedValidator.class.getName());
-
- }
- return;
- } */
- _delegate.addValidator(validatorId, validatorClass);
- }
-
- public Validator createValidator(String validatorId) throws FacesException {
- weaveDelegate();
-
- Validator retVal = _delegate.createValidator(validatorId);
-
- //the validators are recreated every request we do not have to deal with them on method level
- Validator newRetVal = (Validator) reloadInstance(retVal, ScriptingConst.ARTIFACT_TYPE_VALIDATOR);
- if (newRetVal != retVal) {
- _delegate.createValidator(validatorId);
- }
- return retVal;
- }
-
- public Iterator<String> getValidatorIds() {
- weaveDelegate();
- return _delegate.getValidatorIds();
- }
-
- @SuppressWarnings("deprecation")
- public ValueBinding createValueBinding(String s) throws ReferenceSyntaxException {
- weaveDelegate();
- return _delegate.createValueBinding(s);
- }
-
- @Override
- public void addBehavior(String behaviorId, String behaviorClass) {
- weaveDelegate();
-
- if (behaviorClass.equals(PurgedValidator.class.getName())) {
- //purged case we do a full rescan
- WeavingContext.getWeaver().fullClassScan();
- Behavior behavior = _delegate.createBehavior(behaviorId);
- _behaviors.put(behaviorId, behaviorClass);
- if (behavior instanceof PurgedBehavior) {
- //Null not allowed here, but we set a purged validator to make
- //sure that we get errors on the proper level
- _delegate.addBehavior(behaviorId, PurgedBehavior.class.getName());
- _behaviors.remove(behaviorId);
-
- }
- return;
- }
-
- _delegate.addBehavior(behaviorId, behaviorClass);
- }
-
- @Override
- public void addDefaultValidatorId(String validatorId) {
- weaveDelegate();
- _delegate.addDefaultValidatorId(validatorId);
- }
-
- @Override
- public Behavior createBehavior(String behaviorId) throws FacesException {
- weaveDelegate();
- Behavior retVal = _delegate.createBehavior(behaviorId);
-
- //we might have casts here against one of the parents
- //of this object
- Behavior newBehavior = (Behavior) reloadInstance(retVal, ScriptingConst.ARTIFACT_TYPE_BEHAVIOR);
- if (newBehavior != retVal) {
- return _delegate.createBehavior(behaviorId);
- }
-
- return retVal;
- }
-
- @Override
- public UIComponent createComponent(FacesContext facesContext, Resource resource) {
- weaveDelegate();
-
- UIComponent oldComponent = _delegate.createComponent(facesContext, resource);
-
- /*we are reweaving on the fly because we cannot be sure if
- * the class is not recycled all the time in the creation
- * code, in the renderer we do it on method base
- * due to the fact that our renderers are recycled via
- * a flyweight pattern*/
- UIComponent component = (UIComponent) reloadInstance(oldComponent, ScriptingConst.ARTIFACT_TYPE_COMPONENT);
-
- //we now have to check for an annotation change, but only in case a reload has happened
- if (component.getClass().hashCode() != oldComponent.getClass().hashCode()) {
- return handleAnnotationChange(component, facesContext, resource);
- }
-
- return component;
-
- }
-
- @Override
- public UIComponent createComponent(FacesContext facesContext, String componentType, String rendererType) {
- weaveDelegate();
- UIComponent oldComponent = _delegate.createComponent(facesContext, componentType, rendererType);
-
- /*we are reweaving on the fly because we cannot be sure if
- * the class is not recycled all the time in the creation
- * code, in the renderer we do it on method base
- * due to the fact that our renderers are recycled via
- * a flyweight pattern*/
- UIComponent component = (UIComponent) reloadInstance(oldComponent, ScriptingConst.ARTIFACT_TYPE_COMPONENT);
-
- //we now have to check for an annotation change, but only in case a reload has happened
- if (component.getClass().hashCode() != oldComponent.getClass().hashCode()) {
- return handleAnnotationChange(component, facesContext, componentType, rendererType);
- }
-
- return component;
- }
-
- @Override
- public UIComponent createComponent(ValueExpression valueExpression, FacesContext facesContext, String s, String s1) {
- weaveDelegate();
- UIComponent oldComponent = _delegate.createComponent(valueExpression, facesContext, s, s1);
-
- /*we are reweaving on the fly because we cannot be sure if
- * the class is not recycled all the time in the creation
- * code, in the renderer we do it on method base
- * due to the fact that our renderers are recycled via
- * a flyweight pattern*/
- UIComponent component = (UIComponent) reloadInstance(oldComponent, ScriptingConst.ARTIFACT_TYPE_COMPONENT);
-
- //we now have to check for an annotation change, but only in case a reload has happened
- if (component.getClass().hashCode() != oldComponent.getClass().hashCode()) {
- return handleAnnotationChange(component, valueExpression, facesContext, s, s1);
- }
-
- return component;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T evaluateExpressionGet(FacesContext facesContext, String s, Class<? extends T> aClass) throws ELException {
- weaveDelegate();
- //good place for a dynamic reloading check as well
- T retVal = _delegate.evaluateExpressionGet(facesContext, s, aClass);
- if (WeavingContext.isDynamic(retVal.getClass()))
- retVal = (T) WeavingContext.getWeaver().reloadScriptingInstance(retVal, ScriptingConst.ARTIFACT_TYPE_MANAGEDBEAN);
- return retVal;
- }
-
- @Override
- public Iterator<String> getBehaviorIds() {
- weaveDelegate();
- return _behaviors.keySet().iterator();
- //return _delegate.getBehaviorIds();
- }
-
- @Override
- public Map<String, String> getDefaultValidatorInfo() {
- weaveDelegate();
- return _delegate.getDefaultValidatorInfo();
- }
-
- @Override
- public ProjectStage getProjectStage() {
- weaveDelegate();
- return _delegate.getProjectStage();
- }
-
- @Override
- public ResourceHandler getResourceHandler() {
- weaveDelegate();
- ResourceHandler retVal = _delegate.getResourceHandler();
-
- /*if (WeavingContext.isDynamic(retVal.getClass())) {
- ResourceHandler newHandler = (ResourceHandler) reloadInstance(retVal, ScriptingConst.ARTIFACT_TYPE_RESOURCEHANDLER);
- if (newHandler != retVal) {
- _delegate.setResourceHandler(newHandler);
- return newHandler;
- }
- } */
- return retVal;
- }
-
- @Override
- public void publishEvent(FacesContext facesContext, Class<? extends SystemEvent> eventClass, Class<?> sourceBaseTye, Object source) {
- weaveDelegate();
- _delegate.publishEvent(facesContext, eventClass, sourceBaseTye, source);
- }
-
- @Override
- public void publishEvent(FacesContext facesContext, Class<? extends SystemEvent> eventClass, Object source) {
- weaveDelegate();
- _delegate.publishEvent(facesContext, eventClass, source);
- }
-
- @Override
- public void setResourceHandler(ResourceHandler resourceHandler) {
- weaveDelegate();
- if (WeavingContext.isDynamic(resourceHandler.getClass())) {
- ResourceHandler proxy = new ResourceHandlerProxy(resourceHandler);
- resourceHandler = proxy;
- }
-
- _delegate.setResourceHandler(resourceHandler);
- //ResourceHandler handler = _delegate.getResourceHandler();
- //if (handler instanceof PurgedResourceHandler) {
- // WeavingContext.getWeaver().fullClassScan();
- //}
- }
-
- @Override
- public void subscribeToEvent(Class<? extends SystemEvent> eventClass, Class<?> aClass, SystemEventListener systemEventListener) {
- weaveDelegate();
- systemEventListener = makeEventProxy(eventClass, systemEventListener);
- _delegate.subscribeToEvent(eventClass, aClass, systemEventListener);
- }
-
- private SystemEventListener makeEventProxy(Class<? extends SystemEvent> eventClass, SystemEventListener systemEventListener) {
- if (WeavingContext.isDynamic(systemEventListener.getClass())) {
- systemEventListener = new SystemEventListenerProxy(systemEventListener);
- EventHandlerProxyEntry entry = new EventHandlerProxyEntry(eventClass, (Decorated) systemEventListener);
- _eventHandlerIdx.put(entry, entry);
- }
- return systemEventListener;
- }
-
- @Override
- public void subscribeToEvent(Class<? extends SystemEvent> eventClass, SystemEventListener systemEventListener) {
- weaveDelegate();
- systemEventListener = makeEventProxy(eventClass, systemEventListener);
- _delegate.subscribeToEvent(eventClass, systemEventListener);
- }
-
- @Override
- public void unsubscribeFromEvent(Class<? extends SystemEvent> eventClass, Class<?> aClass, SystemEventListener systemEventListener) {
- weaveDelegate();
- systemEventListener = resolveEventProxy(eventClass, systemEventListener);
- _delegate.unsubscribeFromEvent(eventClass, aClass, systemEventListener);
- }
-
- private SystemEventListener resolveEventProxy(Class<? extends SystemEvent> eventClass, SystemEventListener systemEventListener) {
- if (WeavingContext.isDynamic(systemEventListener.getClass())) {
- systemEventListener = new SystemEventListenerProxy(systemEventListener);
- EventHandlerProxyEntry entry = new EventHandlerProxyEntry(eventClass, (Decorated) systemEventListener);
- entry = _eventHandlerIdx.remove(entry);
- if (entry != null) {
- systemEventListener = (SystemEventListener) entry.getProxy().getDelegate();
- }
- }
- return systemEventListener;
- }
-
- @Override
- public void unsubscribeFromEvent(Class<? extends SystemEvent> eventClass, SystemEventListener systemEventListener) {
- weaveDelegate();
- systemEventListener = resolveEventProxy(eventClass, systemEventListener);
- _delegate.unsubscribeFromEvent(eventClass, systemEventListener);
- }
-
- public Object getDelegate() {
- return _delegate;
- }
-
- private Object reloadInstance(Object instance, int artifactType) {
- if (instance == null) {
- return null;
- }
- if (WeavingContext.isDynamic(instance.getClass()) && !alreadyWovenInRequest(instance.getClass().getName())) {
- instance = WeavingContext.getWeaver().reloadScriptingInstance(instance, artifactType);
- alreadyWovenInRequest(instance.getClass().getName());
- }
- return instance;
- }
-
- private boolean alreadyWovenInRequest(String clazz) {
- //portlets now can be enabled thanks to the jsf2 indirections regarding the external context
- Map<String, Object> req = WeavingContext.getRequestMap();
- if (req.get(ScriptingConst.SCRIPTING_REQUSINGLETON + clazz) == null) {
- req.put(ScriptingConst.SCRIPTING_REQUSINGLETON + clazz, "");
- return false;
- }
- return true;
- }
-
- private UIComponent handleAnnotationChange(UIComponent oldComponent, ValueExpression valueExpression, FacesContext facesContext, String componentType) {
- UIComponent componentToChange = _delegate.createComponent(valueExpression, facesContext, componentType);
- if (componentToChange instanceof PurgedComponent) {
- WeavingContext.getWeaver().fullClassScan();
- //via an additional create component we can check whether a purged component
- //was registered after the reload because the annotation has been removed
- componentToChange = _delegate.createComponent(valueExpression, facesContext, componentType);
-
- return componentToChange;
- }
- return oldComponent;
- }
-
- private UIComponent handleAnnotationChange(UIComponent oldComponent, String componentType) {
- UIComponent componentToChange = _delegate.createComponent(componentType);
- if (componentToChange instanceof PurgedComponent) {
- WeavingContext.getWeaver().fullClassScan();
- //via an additional create component we can check whether a purged component
- //was registered after the reload because the annotation has been removed
- componentToChange = _delegate.createComponent(componentType);
-
- return componentToChange;
- }
- return oldComponent;
- }
-
- @SuppressWarnings("deprecation")
- private UIComponent handleAnnotationChange(UIComponent oldComponent, ValueBinding valueBinding, FacesContext context, String componentType) {
- UIComponent componentToChange = _delegate.createComponent(valueBinding, context, componentType);
- if (componentToChange instanceof PurgedComponent) {
- WeavingContext.getWeaver().fullClassScan();
- //via an additional create component we can check whether a purged component
- //was registered after the reload because the annotation has been removed
- componentToChange = _delegate.createComponent(valueBinding, context, componentType);
-
- return componentToChange;
- }
- return oldComponent;
- }
-
- private UIComponent handleAnnotationChange(UIComponent oldComponent, FacesContext context, Resource resource) {
- UIComponent componentToChange = _delegate.createComponent(context, resource);
- if (componentToChange instanceof PurgedComponent) {
- WeavingContext.getWeaver().fullClassScan();
- //via an additional create component we can check whether a purged component
- //was registered after the reload because the annotation has been removed
- componentToChange = _delegate.createComponent(context, resource);
-
- return componentToChange;
- }
- return oldComponent;
- }
-
- private UIComponent handleAnnotationChange(UIComponent oldComponent, FacesContext context, String componentType, String rendererType) {
- UIComponent componentToChange = _delegate.createComponent(context, componentType, rendererType);
- if (componentToChange instanceof PurgedComponent) {
- WeavingContext.getWeaver().fullClassScan();
- //via an additional create component we can check whether a purged component
- //was registered after the reload because the annotation has been removed
- componentToChange = _delegate.createComponent(context, componentType, rendererType);
-
- return componentToChange;
- }
- return oldComponent;
- }
-
- private UIComponent handleAnnotationChange(UIComponent oldComponent, ValueExpression valueExpression, FacesContext facesContext, String s, String s1) {
- UIComponent componentToChange = _delegate.createComponent(valueExpression, facesContext, s, s1);
- if (componentToChange instanceof PurgedComponent) {
- WeavingContext.getWeaver().fullClassScan();
-
- //via an additional create component we can check whether a purged component
- //was registered after the reload because the annotation has been removed
-
- componentToChange = _delegate.createComponent(valueExpression, facesContext, s, s1);
-
- return componentToChange;
- }
- return oldComponent;
- }
-
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java
deleted file mode 100644
index 7ff311d..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implemetations;
-
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-import javax.el.ELContext;
-import javax.el.ELException;
-import javax.el.ELResolver;
-import javax.faces.context.FacesContext;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.util.Iterator;
-import java.util.logging.Logger;
-
-/**
- * EL Resolver which is scripting enabled
- *
- * @author Werner Punz
- *
- * TODO not needed anymore because we drop the beans at request start directly which are tainted...
- * they get reloaded because they are dropped entirely from the scope
- *
- * The compile and load happens on classloader level
- * @deprecated
- */
-public class ELResolverProxy extends ELResolver implements Decorated {
-
- Logger log = Logger.getLogger(ELResolverProxy.class.getName());
- ELResolver _delegate = null;
-
- // static ThreadLocal<Boolean> _getValue = new ThreadLocal<Boolean>();
-
- public Object getValue(ELContext elContext, final Object base, final Object property) throws NullPointerException, ELException {
-
- Object retVal = _delegate.getValue(elContext, base, property);
-
- /* Object newRetVal;
- if (retVal != null && WeavingContext.isDynamic(retVal.getClass())) {
-
- newRetVal = WeavingContext.getWeaver().reloadScriptingInstance(retVal, ScriptingConst.ARTIFACT_TYPE_MANAGEDBEAN);
-
- if (newRetVal != retVal) {
- setValue(elContext, base, property, newRetVal);
- }
-
- return newRetVal;
-
- }*/
-
- return retVal;
- }
-
-
-
-
- public Class<?> getType(ELContext elContext, Object o, Object o1) throws NullPointerException, ELException {
- Class<?> retVal = _delegate.getType(elContext, o, o1);
- if (retVal != null && WeavingContext.isDynamic(retVal)) {
- return WeavingContext.getWeaver().reloadScriptingClass(retVal);
- }
- return retVal;
- }
-
- public void setValue(ELContext elContext, Object base, Object property, Object value) throws NullPointerException, ELException {
- //now to more complex relations...
- if (base != null && WeavingContext.isDynamic(base.getClass()) && WeavingContext.isDynamic(value.getClass())) {
- WeavingContext.getRefreshContext().getDependencyRegistry().addDependency(ScriptingConst.ENGINE_TYPE_JSF_ALL, base.getClass().getName(), base.getClass().getName(), value.getClass().getName());
- }
- _delegate.setValue(elContext, base, property, value);
- }
-
- public boolean isReadOnly(ELContext elContext, Object o, Object o1) throws NullPointerException, ELException {
- return _delegate.isReadOnly(elContext, o, o1);
- }
-
- public Iterator getFeatureDescriptors(ELContext elContext, Object o) {
- return _delegate.getFeatureDescriptors(elContext, o);
- }
-
- public Class<?> getCommonPropertyType(ELContext elContext, Object o) {
- return _delegate.getCommonPropertyType(elContext, o);
- }
-
-
- public ELResolverProxy() {
- _delegate = FacesContext.getCurrentInstance().getELContext().getELResolver();
- }
-
- public ELResolverProxy(ELResolver delegate) {
- _delegate = delegate;
- }
-
- public Object getDelegate() {
- return _delegate;
- }
-
-
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
- {
- // our "pseudo-constructor"
- in.defaultReadObject();
- log = Logger.getLogger(ELResolverProxy.class.getName());
-
- }
-
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/FacesContextProxy.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/FacesContextProxy.java
deleted file mode 100644
index 4cd12e6..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/FacesContextProxy.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implemetations;
-
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-import javax.faces.context.*;
-import javax.faces.application.Application;
-import javax.faces.application.FacesMessage;
-import javax.faces.application.ProjectStage;
-import javax.faces.render.RenderKit;
-import javax.faces.component.UIViewRoot;
-import javax.faces.event.PhaseId;
-import javax.el.ELContext;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.List;
-
-/**
- * A reloading, weaving faces context
- * this is needed because groovy fails on
- * the introspection of the standard java myfaces
- * faces context due to pending references
- * of the _impl into the portlet context
- * not sure if this works in portlets
- * though
- *
- * @author Werner Punz
- */
-public class FacesContextProxy extends FacesContext implements Decorated {
-
- public FacesContext _delegate = null;
-
- private void weaveDelegate() {
- //in case of a context destroyed the weaver might be accessed a last time
- //but is already null due to having no weaver in the shutdown thread
- if (_delegate != null && WeavingContext.getWeaver() != null)
- _delegate = (FacesContext) WeavingContext.getWeaver().reloadScriptingInstance(_delegate, ScriptingConst.ARTIFACT_TYPE_FACESCONTEXT);
- }
-
- public ELContext getELContext() {
- return _delegate.getELContext();
- }
-
- public Application getApplication() {
- return _delegate.getApplication();
- }
-
- public Iterator<String> getClientIdsWithMessages() {
- return _delegate.getClientIdsWithMessages();
- }
-
- public ExternalContext getExternalContext() {
- return _delegate.getExternalContext();
- }
-
- public FacesMessage.Severity getMaximumSeverity() {
- return _delegate.getMaximumSeverity();
- }
-
- public Iterator<FacesMessage> getMessages() {
- return _delegate.getMessages();
- }
-
- public Iterator<FacesMessage> getMessages(String s) {
- return _delegate.getMessages(s);
- }
-
- public RenderKit getRenderKit() {
- return _delegate.getRenderKit();
- }
-
- public boolean getRenderResponse() {
- return _delegate.getRenderResponse();
- }
-
- public boolean getResponseComplete() {
- return _delegate.getResponseComplete();
- }
-
- public ResponseStream getResponseStream() {
- return _delegate.getResponseStream();
- }
-
- public void setResponseStream(ResponseStream responseStream) {
- _delegate.setResponseStream(responseStream);
- }
-
- public ResponseWriter getResponseWriter() {
- return _delegate.getResponseWriter();
- }
-
- public void setResponseWriter(ResponseWriter responseWriter) {
- _delegate.setResponseWriter(responseWriter);
- }
-
- public UIViewRoot getViewRoot() {
- return _delegate.getViewRoot();
- }
-
- public void setViewRoot(UIViewRoot uiViewRoot) {
- weaveDelegate();//perfect place no matter what the viewRoot is about once per request set
- _delegate.setViewRoot(uiViewRoot);
- }
-
- public void addMessage(String s, FacesMessage facesMessage) {
- _delegate.addMessage(s, facesMessage);
- }
-
- public void release() {
- _delegate.release();
- }
-
- public void renderResponse() {
- _delegate.renderResponse();
- }
-
- public void responseComplete() {
- _delegate.responseComplete();
- }
-
- public FacesContextProxy(FacesContext delegate) {
- _delegate = delegate;
- weaveDelegate();
- }
-
- @Override
- public Map<Object, Object> getAttributes() {
- return _delegate.getAttributes();
- }
-
- @Override
- public PhaseId getCurrentPhaseId() {
- return _delegate.getCurrentPhaseId();
- }
-
- @Override
- public ExceptionHandler getExceptionHandler() {
- return _delegate.getExceptionHandler();
- }
-
- @Override
- public List<FacesMessage> getMessageList() {
- return _delegate.getMessageList();
- }
-
- @Override
- public List<FacesMessage> getMessageList(String s) {
- return _delegate.getMessageList(s);
- }
-
- @Override
- public PartialViewContext getPartialViewContext() {
- return _delegate.getPartialViewContext();
- }
-
- @Override
- public boolean isValidationFailed() {
- return _delegate.isValidationFailed();
- }
-
- @Override
- public boolean isPostback() {
- return _delegate.isPostback();
- }
-
- @Override
- public boolean isProcessingEvents() {
- return _delegate.isProcessingEvents();
- }
-
- @Override
- public void setCurrentPhaseId(PhaseId phaseId) {
- _delegate.setCurrentPhaseId(phaseId);
- }
-
- @Override
- public void setExceptionHandler(ExceptionHandler exceptionHandler) {
- _delegate.setExceptionHandler(exceptionHandler);
- }
-
- @Override
- public void setProcessingEvents(boolean b) {
- _delegate.setProcessingEvents(b);
- }
-
- @Override
- public void validationFailed() {
- _delegate.validationFailed();
- }
-
- @Override
- public boolean isProjectStage(ProjectStage projectStage) {
- return _delegate.isProjectStage(projectStage);
- }
-
- public Object getDelegate() {
- return _delegate;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/LifefcycleProxy.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/LifefcycleProxy.java
deleted file mode 100644
index 6e046ff..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/LifefcycleProxy.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implemetations;
-
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-import javax.faces.lifecycle.Lifecycle;
-import javax.faces.event.PhaseListener;
-import javax.faces.context.FacesContext;
-import javax.faces.FacesException;
-
-/**
- * Scripting enabled lifecycle
- *
- * @author Werner Punz
- */
-public class LifefcycleProxy extends Lifecycle implements Decorated {
-
- Lifecycle _delegate = null;
-
- private void weaveDelegate() {
- if (_delegate != null)
- _delegate = (Lifecycle) WeavingContext.getWeaver().reloadScriptingInstance(_delegate, ScriptingConst.ARTIFACT_TYPE_LIFECYCLE);
- }
-
- public LifefcycleProxy(Lifecycle delegate) {
- _delegate = delegate;
- }
-
- public void addPhaseListener(PhaseListener phaseListener) {
- weaveDelegate();
- /*we can put our object weaving code into the add here*/
- if (WeavingContext.isDynamic(phaseListener.getClass()))
- phaseListener = (PhaseListener) WeavingContext.createMethodReloadingProxyFromObject(phaseListener, PhaseListener.class, ScriptingConst.ARTIFACT_TYPE_PHASELISTENER);
-
- _delegate.addPhaseListener(phaseListener);
- }
-
- public void execute(FacesContext facesContext) throws FacesException {
- weaveDelegate();
- _delegate.execute(facesContext);
- }
-
- public PhaseListener[] getPhaseListeners() {
- weaveDelegate();
- return _delegate.getPhaseListeners();
- }
-
- public void removePhaseListener(PhaseListener phaseListener) {
- weaveDelegate();
- _delegate.removePhaseListener(phaseListener);
- }
-
- public void render(FacesContext facesContext) throws FacesException {
- weaveDelegate();
- _delegate.render(facesContext);
- }
-
- public Object getDelegate() {
- return _delegate;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/NavigationHandlerProxy.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/NavigationHandlerProxy.java
deleted file mode 100644
index 8f149c7..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/NavigationHandlerProxy.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implemetations;
-
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-import javax.faces.application.NavigationHandler;
-import javax.faces.context.FacesContext;
-
-/**
- * A reloading navigation handler
- *
- * @author Werner Punz
- */
-public class NavigationHandlerProxy extends NavigationHandler implements Decorated {
-
- NavigationHandler _delegate;
-
- private void weaveDelegate() {
- _delegate = (NavigationHandler) WeavingContext.getWeaver().reloadScriptingInstance(_delegate, ScriptingConst.ARTIFACT_TYPE_NAVIGATIONHANDLER);
- }
-
- public NavigationHandlerProxy(NavigationHandler delegate) {
- super();
- _delegate = delegate;
- }
-
- public void handleNavigation(FacesContext facesContext, String s, String s1) {
- weaveDelegate();
- _delegate.handleNavigation(facesContext, s, s1);
- }
-
- public Object getDelegate() {
- return _delegate;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/RenderkitProxy.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/RenderkitProxy.java
deleted file mode 100644
index 674c661..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/RenderkitProxy.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implemetations;
-
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.jsf2.annotation.purged.PurgedRenderer;
-import org.apache.myfaces.extensions.scripting.jsf2.annotation.purged.PurgedClientBehaviorRenderer;
-
-import javax.faces.context.FacesContext;
-import javax.faces.render.RenderKit;
-import javax.faces.render.Renderer;
-import javax.faces.render.ResponseStateManager;
-import javax.faces.render.ClientBehaviorRenderer;
-import javax.faces.context.ResponseWriter;
-import javax.faces.context.ResponseStream;
-import javax.faces.FacesException;
-import java.io.Writer;
-import java.io.OutputStream;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * Weaving renderkit which
- * acts as a proxy factory for
- * our internal reloading referers
- *
- * @author Werner Punz
- */
-public class RenderkitProxy extends RenderKit implements Decorated {
-
- RenderKit _delegate = null;
-
- public RenderkitProxy(RenderKit delegate) {
- _delegate = delegate;
- }
-
- public void addRenderer(String componentFamily, String rendererType, Renderer renderer) {
- weaveDelegate();
- //wo do it brute force here because we have sometimes casts and hence cannot rely on proxies
- //renderers itself are flyweight patterns which means they are shared over objects
-
- renderer = (Renderer) reloadInstance(renderer, ScriptingConst.ARTIFACT_TYPE_RENDERER);
-
- _delegate.addRenderer(componentFamily, rendererType, renderer);
- }
-
- public Renderer getRenderer(String componentFamily, String rendererType) {
- weaveDelegate();
- Renderer rendr = _delegate.getRenderer(componentFamily, rendererType);
- Renderer rendr2 = (Renderer) reloadInstance(rendr, ScriptingConst.ARTIFACT_TYPE_RENDERER);
- if (rendr != rendr2) {
- Renderer tempRenderer = _delegate.getRenderer(componentFamily, rendererType);
- if (tempRenderer instanceof PurgedRenderer) {
- return handleAnnotationChange(componentFamily, rendererType);
- }
-
- _delegate.addRenderer(componentFamily, rendererType, rendr2);
- return rendr2;
- }
- return rendr;
- }
-
- private ClientBehaviorRenderer handleAnnotationChangeBehaviorRenderer(String s) {
- ClientBehaviorRenderer rendr2;
-
- rendr2 = _delegate.getClientBehaviorRenderer(s);
- if (rendr2 instanceof PurgedClientBehaviorRenderer) {
- throw new FacesException("Renderer not found");
- }
- rendr2 = _delegate.getClientBehaviorRenderer(s);
- return rendr2;
- }
-
- private Renderer handleAnnotationChange(String s, String s1) {
- Renderer rendr2;
-
- //WeavingContext.getWeaver().fullClassScan();
- rendr2 = _delegate.getRenderer(s, s1);
- if (rendr2 instanceof PurgedRenderer) {
- throw new FacesException("Renderer not found");
- }
- rendr2 = _delegate.getRenderer(s, s1);
- return rendr2;
- }
-
- public ResponseStateManager getResponseStateManager() {
- weaveDelegate();
- return _delegate.getResponseStateManager();
- }
-
- public ResponseWriter createResponseWriter(Writer writer, String s, String s1) {
- weaveDelegate();
- return (ResponseWriter) reloadInstance(_delegate.createResponseWriter(writer, s, s1), ScriptingConst.ARTIFACT_TYPE_RESPONSEWRITER);
- }
-
- public ResponseStream createResponseStream(OutputStream outputStream) {
- weaveDelegate();
- return (ResponseStream) reloadInstance(_delegate.createResponseStream(outputStream), ScriptingConst.ARTIFACT_TYPE_RESPONSESTREAM);
- }
-
- @Override
- public void addClientBehaviorRenderer(String s, ClientBehaviorRenderer renderer) {
-
- weaveDelegate();
- renderer = (ClientBehaviorRenderer) reloadInstance(renderer, ScriptingConst.ARTIFACT_TYPE_CLIENTBEHAVIORRENDERER);
- _delegate.addClientBehaviorRenderer(s, renderer);
- }
-
- @Override
- public ClientBehaviorRenderer getClientBehaviorRenderer(String s) {
- weaveDelegate();
- ClientBehaviorRenderer rendr = _delegate.getClientBehaviorRenderer(s);
- ClientBehaviorRenderer rendr2 = (ClientBehaviorRenderer) reloadInstance(rendr, ScriptingConst.ARTIFACT_TYPE_CLIENTBEHAVIORRENDERER);
- if (rendr != rendr2) {
-
- rendr2 = _delegate.getClientBehaviorRenderer(s);
- if (rendr2 instanceof PurgedClientBehaviorRenderer) {
- return handleAnnotationChangeBehaviorRenderer(s);
- }
- return rendr2;
- }
- return rendr;
- }
-
- @Override
- public Iterator<String> getClientBehaviorRendererTypes() {
- weaveDelegate();
- return _delegate.getClientBehaviorRendererTypes();
- }
-
- @Override
- public Iterator<String> getComponentFamilies() {
- weaveDelegate();
- return _delegate.getComponentFamilies();
- }
-
- @Override
- public Iterator<String> getRendererTypes(String s) {
- weaveDelegate();
- return _delegate.getRendererTypes(s);
- }
-
- public Object getDelegate() {
- return _delegate;
- }
-
- private void weaveDelegate() {
- _delegate = (RenderKit) WeavingContext.getWeaver().reloadScriptingInstance(_delegate, ScriptingConst.ARTIFACT_TYPE_RENDERKIT);
- }
-
- private Object reloadInstance(Object instance, int artefactType) {
- if (instance == null) {
- return null;
- }
- if (WeavingContext.isDynamic(instance.getClass()) && !alreadyWovenInRequest(instance.getClass().getName())) {
- alreadyWovenInRequest(instance.getClass().getName());
- instance = WeavingContext.getWeaver().reloadScriptingInstance(instance, artefactType);
-
- //now the add should be done properly if possible
- }
- return instance;
- }
-
- private boolean alreadyWovenInRequest(String clazz) {
- try {//portlets now can be enabled thanks to the jsf2 indirections regarding the external context
-
- //portlets now can be enabled thanks to the jsf2 indirections regarding the external context
- Map<String, Object> req = WeavingContext.getRequestMap();
- if (req.get(ScriptingConst.SCRIPTING_REQUSINGLETON + clazz) == null) {
- req.put(ScriptingConst.SCRIPTING_REQUSINGLETON + clazz, "");
- return false;
- }
- return true;
- } catch (UnsupportedOperationException ex) {
- //still in startup no additional weaving here
- return true;
- }
- }
-
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ResourceHandlerProxy.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ResourceHandlerProxy.java
deleted file mode 100644
index 1abd4e5..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ResourceHandlerProxy.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implemetations;
-
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-
-import javax.faces.application.Resource;
-import javax.faces.application.ResourceHandler;
-import javax.faces.context.FacesContext;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- *
- * Problem the resource request is issued on servlet level before
- * our compile triggers can trigger from the phase listener
- * this is evil
- *
- * We probably have to reissue the compile from the resource handler
- * directly upfront :-( or mark the resource handler as something like double tainted!
- *
- * This problem will resolve itself with async compile
- *
- */
-
-public class ResourceHandlerProxy extends ResourceHandler {
- private ResourceHandler _delegate;
-
- public ResourceHandlerProxy(ResourceHandler delegate) {
- _delegate = delegate;
- }
-
- public Resource createResource(String resourceName) {
- weaveDelegate();
- return _delegate.createResource(resourceName);
- }
-
- public Resource createResource(String resourceName, String libraryName) {
- weaveDelegate();
- return _delegate.createResource(resourceName, libraryName);
- }
-
- public Resource createResource(String resourceName, String libraryName, String contentType) {
- weaveDelegate();
- return _delegate.createResource(resourceName, libraryName, contentType);
- }
-
- public String getRendererTypeForResourceName(String resourceName) {
- weaveDelegate();
- return _delegate.getRendererTypeForResourceName(resourceName);
- }
-
- public void handleResourceRequest(FacesContext context) throws java.io.IOException {
- weaveDelegate();
- _delegate.handleResourceRequest(context);
- }
-
- public boolean isResourceRequest(FacesContext context) {
- weaveDelegate();
- return _delegate.isResourceRequest(context);
- }
-
- public boolean libraryExists(String libraryName) {
- weaveDelegate();
- return _delegate.libraryExists(libraryName);
- }
-
- private final void weaveDelegate() {
- _delegate = (ResourceHandler) WeavingContext.getWeaver().reloadScriptingInstance(_delegate, ScriptingConst.ARTIFACT_TYPE_RESOURCEHANDLER);
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/SystemEventListenerProxy.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/SystemEventListenerProxy.java
deleted file mode 100644
index 022b258..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/SystemEventListenerProxy.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implemetations;
-
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-import javax.faces.event.SystemEvent;
-import javax.faces.event.SystemEventListener;
-
-/**
- * a method level reloading proxy class
- * we do not use auto proxies here because
- * this class needs special treatment
- * over our decorated interface
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class SystemEventListenerProxy implements Decorated, SystemEventListener {
-
- SystemEventListener _delegate;
-
- public SystemEventListenerProxy(SystemEventListener delegate) {
- _delegate = delegate;
- }
-
- public boolean isListenerForSource(Object source) {
- weaveDelegate();
- return _delegate.isListenerForSource(source);
- }
-
- public void processEvent(SystemEvent event) {
- weaveDelegate();
- _delegate.processEvent(event);
- }
-
- @Override
- public Object getDelegate() {
- return _delegate;
- }
-
- private void weaveDelegate() {
- //TODO (1.1) add a speed optimization here by pushing something in the request map
- if (_delegate != null) {
- _delegate = (SystemEventListener) WeavingContext.getWeaver().reloadScriptingInstance(_delegate, ScriptingConst.ARTIFACT_TYPE_SYSTEMEVENTLISTENER);
- }
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/VariableResolverProxy.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/VariableResolverProxy.java
deleted file mode 100644
index b329560..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/VariableResolverProxy.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implemetations;
-
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-import javax.faces.context.FacesContext;
-import javax.faces.el.*;
-
-
-/**
- * objects loaded must
- * be checked if a reloading is needed
- *
- * @author Werner Punz
- */
-@SuppressWarnings("deprecation") //we must suppress it here
-public class VariableResolverProxy extends VariableResolver implements Decorated {
- VariableResolver _delegate;
-
- public VariableResolverProxy(VariableResolver delegate) {
- _delegate = delegate;
- }
-
- public Object resolveVariable(FacesContext facesContext, String s) throws EvaluationException {
- Object variable = _delegate.resolveVariable(facesContext, s);
- if (variable != null && WeavingContext.isDynamic(variable.getClass()))
- variable = WeavingContext.getWeaver().reloadScriptingInstance(variable, ScriptingConst.ARTIFACT_TYPE_MANAGEDBEAN);
- return variable;
- }
-
- public Object getDelegate() {
- return _delegate;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ViewHandlerProxy.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ViewHandlerProxy.java
deleted file mode 100644
index ea026cd..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ViewHandlerProxy.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implemetations;
-
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-import javax.faces.application.ViewHandler;
-import javax.faces.context.FacesContext;
-import javax.faces.component.UIViewRoot;
-import javax.faces.FacesException;
-import javax.faces.view.ViewDeclarationLanguage;
-import java.util.Locale;
-import java.util.Map;
-import java.util.List;
-import java.io.IOException;
-
-/**
- * Scripting enabled View Handler
- *
- * @author Werner Punz
- */
-public class ViewHandlerProxy extends ViewHandler implements Decorated {
-
- ViewHandler _delegate = null;
-
- private void weaveDelegate() {
- if (_delegate != null) {
- _delegate = (ViewHandler) WeavingContext.getWeaver().reloadScriptingInstance(_delegate, ScriptingConst.ARTIFACT_TYPE_VIEWHANDLER);
- }
- }
-
- public ViewHandlerProxy(ViewHandler delegate) {
- _delegate = delegate;
- }
-
- public String calculateCharacterEncoding(FacesContext facesContext) {
- weaveDelegate();
- return _delegate.calculateCharacterEncoding(facesContext);
- }
-
- public Locale calculateLocale(FacesContext facesContext) {
- weaveDelegate();
- return _delegate.calculateLocale(facesContext);
- }
-
- public String calculateRenderKitId(FacesContext facesContext) {
- weaveDelegate();
- return _delegate.calculateRenderKitId(facesContext);
- }
-
- public UIViewRoot createView(FacesContext facesContext, String s) {
- weaveDelegate();
- return _delegate.createView(facesContext, s);
- }
-
- public String getActionURL(FacesContext facesContext, String s) {
- weaveDelegate();
- return _delegate.getActionURL(facesContext, s);
- }
-
- public String getResourceURL(FacesContext facesContext, String s) {
- weaveDelegate();
- return _delegate.getResourceURL(facesContext, s);
- }
-
- public void initView(FacesContext facesContext) throws FacesException {
- weaveDelegate();
- _delegate.initView(facesContext);
- }
-
- public void renderView(FacesContext facesContext, UIViewRoot uiViewRoot) throws IOException, FacesException {
- weaveDelegate();
- _delegate.renderView(facesContext, uiViewRoot);
- }
-
- public UIViewRoot restoreView(FacesContext facesContext, String s) {
- weaveDelegate();
- return _delegate.restoreView(facesContext, s);
- }
-
- public void writeState(FacesContext facesContext) throws IOException {
- weaveDelegate();
- _delegate.writeState(facesContext);
- }
-
-
- @Override
- public String deriveViewId(FacesContext facesContext, String s) {
- weaveDelegate();
- return _delegate.deriveViewId(facesContext, s);
- }
-
- @Override
- public String getBookmarkableURL(FacesContext facesContext, String s, Map<String, List<String>> stringListMap, boolean b) {
- return super.getBookmarkableURL(facesContext, s, stringListMap, b);
- }
-
- @Override
- public ViewDeclarationLanguage getViewDeclarationLanguage(FacesContext facesContext, String s) {
- weaveDelegate();
- return _delegate.getViewDeclarationLanguage(facesContext, s);
- }
-
- @Override
- public String getRedirectURL(FacesContext facesContext, String s, Map<String, List<String>> stringListMap, boolean b) {
- weaveDelegate();
- return _delegate.getRedirectURL(facesContext, s, stringListMap, b);
- }
-
- public Object getDelegate() {
- return _delegate;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/BaseAnnotationScanListener.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/BaseAnnotationScanListener.java
deleted file mode 100644
index 55b66cb..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/BaseAnnotationScanListener.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation;
-
-import org.apache.myfaces.config.RuntimeConfig;
-
-import javax.faces.application.Application;
-import javax.faces.context.FacesContext;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Logger;
-
-/**
- * Base Class for the JSF2 annotation scanning
- * (note we do not rely on the impl
- * for annotation scanning because in the long
- * run we want to support Mojarra)
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class BaseAnnotationScanListener {
- Logger _log = Logger.getLogger(this.getClass().getName());
- static Map<String, Object> _alreadyRegistered = new ConcurrentHashMap<String, Object>(8, 0.75f, 1);
-
- protected RuntimeConfig getRuntimeConfig() {
- final FacesContext facesContext = FacesContext.getCurrentInstance();
- //runtime config not started
- if (facesContext == null) {
- return null;
- }
- return RuntimeConfig.getCurrentInstance(facesContext.getExternalContext());
- }
-
- protected Application getApplication() {
- return FacesContext.getCurrentInstance().getApplication();
- }
-
- /**
- * unregisters this class in the central registry
- * is triggered if the class itself has been registered previously
- *
- * @param className
- * @return
- */
- public void purge(String className) {
-
- }
-}
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
deleted file mode 100644
index 0311e2c..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/BeanImplementationListener.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation;
-
-import org.apache.myfaces.config.RuntimeConfig;
-import org.apache.myfaces.config.element.NavigationRule;
-import org.apache.myfaces.config.impl.digester.elements.ManagedBean;
-import org.apache.myfaces.extensions.scripting.api.AnnotationScanListener;
-import org.apache.myfaces.extensions.scripting.core.util.Cast;
-import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
-import org.apache.myfaces.extensions.scripting.core.util.StringUtils;
-
-import javax.faces.bean.*;
-import java.lang.reflect.Field;
-import java.util.*;
-import java.util.logging.Level;
-
-/**
- * bean implementation listener which registers new java sources
- * into the runtime config, note this class is not thread safe
- * it is only allowed to be called from a single thread
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class BeanImplementationListener extends BaseAnnotationScanListener implements AnnotationScanListener {
-
- public boolean supportsAnnotation(String annotation) {
- return annotation.equals(javax.faces.bean.ManagedBean.class.getName());
- }
-
- public boolean supportsAnnotation(Class annotation) {
- return annotation.equals(javax.faces.bean.ManagedBean.class);
- }
-
- public void register(Class clazz, java.lang.annotation.Annotation ann) {
-
- RuntimeConfig config = getRuntimeConfig();
-
- javax.faces.bean.ManagedBean annCasted = (javax.faces.bean.ManagedBean) ann;
-
- String beanName = annCasted.name();
- if (StringUtils.isBlank(beanName)) {
- beanName = normalizeName(clazz.getName());
- }
-
- beanName = beanName.replaceAll("\"", "");
- //we need to reregister for every bean due to possible managed prop
- //and scope changes
- ManagedBean mbean;
- if (!hasToReregister(beanName, clazz)) {
- mbean = (ManagedBean) _alreadyRegistered.get(beanName);
- //return;
- } else {
- mbean = new ManagedBean();
- }
-
- mbean.setBeanClass(clazz.getName());
- mbean.setName(beanName);
- handleManagedpropertiesCompiled(mbean, fields(clazz));
- resolveScope(clazz, mbean);
-
- _alreadyRegistered.put(beanName, mbean);
- config.addManagedBean(beanName, mbean);
-
- }
-
- private void resolveScope(Class clazz, ManagedBean mbean) {
- //now lets resolve the scope
- String scope = "none";
- if (clazz.isAnnotationPresent(RequestScoped.class)) {
- scope = "request";
- } else if (clazz.isAnnotationPresent(SessionScoped.class)) {
- 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)) {
- CustomScoped customScoped = (CustomScoped) clazz.getAnnotation(CustomScoped.class);
- scope = (customScoped != null) ? customScoped.value() : "custom";
- }
- mbean.setScope(scope);
- }
-
- private void handleManagedpropertiesCompiled(ManagedBean mbean, Field[] fields) {
- /*since we reprocess the managed properties we can handle them here by clearing them first*/
- mbean.getManagedProperties().clear();
- for (Field field : fields) {
- if (_log.isLoggable(Level.FINEST)) {
- _log.log(Level.FINEST, " Scanning field '" + field.getName() + "'");
- }
- javax.faces.bean.ManagedProperty property = field
- .getAnnotation(ManagedProperty.class);
- if (property != null) {
- if (_log.isLoggable(Level.FINE)) {
- _log.log(Level.FINE, " Field '" + field.getName()
- + "' has a @ManagedProperty annotation");
- }
-
- org.apache.myfaces.config.impl.digester.elements.ManagedProperty mpc =
- new org.apache.myfaces.config.impl.digester.elements.ManagedProperty();
- String name = property.name();
- if ((name == null) || "".equals(name)) {
- name = field.getName();
- }
- mpc.setPropertyName(name);
- mpc.setPropertyClass(field.getType().getName()); // FIXME - primitives, arrays, etc.
- mpc.setValue(property.value());
-
- ReflectUtil.executeMethod(mbean,"addProperty", mpc);
- }
- }
- }
-
- /**
- * <p>Return an array of all <code>Field</code>s reflecting declared
- * fields in this class, or in any superclass other than
- * <code>java.lang.Object</code>.</p>
- *
- * @param clazz Class to be analyzed
- * @return the array of fields
- */
- private Field[] fields(Class clazz) {
-
- Map<String, Field> fields = new HashMap<String, Field>();
- do {
- for (Field field : clazz.getDeclaredFields()) {
- if (!fields.containsKey(field.getName())) {
- fields.put(field.getName(), field);
- }
- }
- } while ((clazz = clazz.getSuperclass()) != Object.class);
- return fields.values().toArray(new Field[fields.size()]);
- }
-
- protected boolean hasToReregister(String name, Class clazz) {
- ManagedBean mbean = (ManagedBean) _alreadyRegistered.get(name);
- return mbean == null || !mbean.getManagedBeanClassName().equals(clazz.getName());
- }
-
- /**
- * name normalizer for automated name mapping
- * (aka if no name attribute is given in the annotation)
- *
- * @param className the classname to be mapped (can be with package=
- * @return the normalized jsf bean name
- */
- private String normalizeName(String className) {
- String name = className.substring(className.lastIndexOf(".") + 1);
-
- return name.substring(0, 1).toLowerCase() + name.substring(1);
- }
-
- @SuppressWarnings("unchecked")
- public void purge(String className) {
- RuntimeConfig config = getRuntimeConfig();
- //We have to purge and readd our managed beans, unfortunatly the myfaces impl enforces
- //us to do the same for the nav rules after purge
- //we cannot purge the managed beans and nav rules separately
- Collection<NavigationRule> navigationRules = new ArrayList<NavigationRule>();
- Map managedBeans = new HashMap<String, org.apache.myfaces.config.element.ManagedBean>();
-
- navigationRules.addAll(config.getNavigationRules());
- managedBeans.putAll(config.getManagedBeans());
-
- config.purge();
-
- for (NavigationRule navRule : navigationRules) {
- config.addNavigationRule(navRule);
- }
-
- //We refresh the managed beans, dead references still can cause
- //runtime errors but in this case we cannot do anything
- org.apache.myfaces.config.element.ManagedBean mbeanFound = null;
- List<String> mbeanKey = new LinkedList<String>();
-
- for (Object entry : managedBeans.entrySet()) {
- Map.Entry mbean = (Map.Entry) entry;
-
- Object bean = mbean.getValue();
-
-
- if (!((Class)ReflectUtil.executeMethod( bean, "getManagedBeanClass")).getName().equals(className)) {
- config.addManagedBean((String) mbean.getKey(), (org.apache.myfaces.config.element.ManagedBean) mbean.getValue());
- } else {
- Object mbeanf = mbean.getValue();
- mbeanKey.add((String)ReflectUtil.executeMethod(mbeanf, "getManagedBeanName"));
- }
- }
- if (mbeanFound != null) {
- for (String toRemove : mbeanKey) {
- _alreadyRegistered.remove(toRemove);
- }
- }
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/BehaviorImplementationListener.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/BehaviorImplementationListener.java
deleted file mode 100644
index 0e9ad86..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/BehaviorImplementationListener.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation;
-
-import org.apache.myfaces.extensions.scripting.api.AnnotationScanListener;
-import org.apache.myfaces.extensions.scripting.jsf2.annotation.purged.PurgedBehavior;
-
-import javax.faces.component.behavior.FacesBehavior;
-import java.util.logging.Level;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class BehaviorImplementationListener extends SingleEntityAnnotationListener implements AnnotationScanListener {
-
- public BehaviorImplementationListener() {
- super();
- _entityParamValue = "value";
- }
-
- public boolean supportsAnnotation(String annotation) {
- return annotation.equals(FacesBehavior.class.getName());
- }
-
- public boolean supportsAnnotation(Class annotation) {
- return annotation.equals(FacesBehavior.class);
- }
-
-
- protected void addEntity(Class clazz, String val) {
- if (_log.isLoggable(Level.FINEST)) {
- _log.log(Level.FINEST, "addBehavior(" + val + ","
- + clazz.getName() + ")");
- }
- getApplication().addBehavior(val, clazz.getName());
- }
-
- @Override
- public void purge(String className) {
- super.purge(className);
- if (!_alreadyRegistered.containsKey(className)) {
- return;
- }
-
- String val = (String) _alreadyRegistered.remove(className);
- if (val != null) {
- getApplication().addBehavior(val, PurgedBehavior.class.getName());
- }
- }
-
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/BehaviorRendererImplementationListener.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/BehaviorRendererImplementationListener.java
deleted file mode 100644
index f012b05..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/BehaviorRendererImplementationListener.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation;
-
-import org.apache.myfaces.extensions.scripting.jsf2.annotation.purged.PurgedClientBehaviorRenderer;
-
-import javax.faces.FactoryFinder;
-import javax.faces.context.FacesContext;
-import javax.faces.render.FacesBehaviorRenderer;
-import javax.faces.render.RenderKit;
-import javax.faces.render.RenderKitFactory;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Level;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * Implementation listener for the FacesBehaviorRenderer annotation
- */
-
-public class BehaviorRendererImplementationListener extends MapEntityAnnotationScanner {
-
- private static final String PAR_RENDERERTYPE = "rendererType";
- private static final String PAR_RENDERKITID = "renderKitId";
-
- Map<AnnotationEntry, String> _inverseIndex = new HashMap<AnnotationEntry, String>();
-
- class AnnotationEntry {
- String rendererType;
- String renderKitId;
-
- AnnotationEntry(String rendererType, String renderKitId) {
- this.rendererType = rendererType;
- this.renderKitId = renderKitId;
- }
-
- public boolean equals(Object incoming) {
- if (!(incoming instanceof AnnotationEntry)) {
- return false;
- }
- AnnotationEntry toCompare = (AnnotationEntry) incoming;
-
- if (incoming == null) {
- return false;
- }
-
- boolean firstEquals = compareValuePair(rendererType, toCompare.getRendererType());
- boolean secondEquals = compareValuePair(renderKitId, toCompare.getRenderKitId());
-
- return firstEquals && secondEquals;
- }
-
- @Override
- public int hashCode() {
- return (checkForNull(rendererType) + "_" + checkForNull(renderKitId)).hashCode(); //To change body of overridden methods use File | Settings | File Templates.
- }
-
- private String checkForNull(String in) {
- return (in == null) ? "" : in;
- }
-
- protected boolean compareValuePair(Object val1, Object val2) {
- boolean retVal = false;
- if (val1 == null) {
- if (val2 != null) retVal = false;
- if (val2 == null) {
- retVal = true;
- }
- } else {
- retVal = val1.equals(val2);
- }
- return retVal;
- }
-
- public String getRendererType() {
- return rendererType;
- }
-
- public String getRenderKitId() {
- return renderKitId;
- }
- }
-
- public BehaviorRendererImplementationListener() {
- super();
- }
-
- @Override
- protected void addEntity(Class clazz, Map<String, Object> params) {
- String value = (String) params.get(PAR_RENDERERTYPE);
- String renderKitId = (String) params.get(PAR_RENDERKITID);
-
- AnnotationEntry entry = new AnnotationEntry(value, renderKitId);
- _alreadyRegistered.put(clazz.getName(), entry);
- _inverseIndex.put(entry, clazz.getName());
-
- getApplication().addConverter(entry.getRendererType(), clazz.getName());
- }
-
- @Override
- protected boolean hasToReregister(Map params, Class clazz) {
- String value = (String) params.get(PAR_RENDERERTYPE);
- String renderKitId = (String) params.get(PAR_RENDERKITID);
-
- AnnotationEntry entry = new AnnotationEntry(value, renderKitId);
-
- AnnotationEntry alreadyRegistered = (AnnotationEntry) _alreadyRegistered.get(clazz.getName());
- if (alreadyRegistered == null) {
- return true;
- }
-
- return alreadyRegistered.equals(entry);
- }
-
- public boolean supportsAnnotation(String annotation) {
- return annotation.equals(FacesBehaviorRenderer.class.getName());
- }
-
- public boolean supportsAnnotation(Class annotation) {
- return annotation.equals(FacesBehaviorRenderer.class);
- }
-
-
- private RenderKitFactory getRenderKitFactory() {
- return (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
- }
-
- private RenderKit getRenderkit(String renderKitId) {
- RenderKitFactory factory = getRenderKitFactory();
- RenderKit renderKit = factory.getRenderKit(FacesContext.getCurrentInstance(), renderKitId);
- return renderKit;
- }
-
- @Override
- public void purge(String className) {
- super.purge(className);
- AnnotationEntry entry = (AnnotationEntry) _alreadyRegistered.remove(className);
- if (entry == null) {
- return;
- }
-
- RenderKit renderKit = getRenderkit(entry.getRenderKitId());
- try {
- String rendererClass = _inverseIndex.get(entry);
- if (rendererClass != null && rendererClass.equals(className)) {
- _inverseIndex.put(entry, PurgedClientBehaviorRenderer.class.getName());
- renderKit.addClientBehaviorRenderer(entry.getRendererType(), PurgedClientBehaviorRenderer.class.newInstance());
- }
- } catch (InstantiationException e) {
- _log.log(Level.SEVERE, "", e);
- } catch (IllegalAccessException e) {
- _log.log(Level.SEVERE, "", e);
- }
- }
-
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/ComponentImplementationListener.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/ComponentImplementationListener.java
deleted file mode 100644
index 81e63f9..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/ComponentImplementationListener.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation;
-
-import org.apache.myfaces.extensions.scripting.api.AnnotationScanListener;
-import org.apache.myfaces.extensions.scripting.jsf2.annotation.purged.PurgedComponent;
-
-import javax.faces.component.FacesComponent;
-import java.util.logging.Level;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ComponentImplementationListener extends SingleEntityAnnotationListener implements AnnotationScanListener {
-
- public ComponentImplementationListener() {
- super();
- _entityParamValue = "value";
- }
-
- public boolean supportsAnnotation(String annotation) {
- return annotation.equals(FacesComponent.class.getName());
- }
-
- public boolean supportsAnnotation(Class annotation) {
- return annotation.equals(FacesComponent.class);
- }
-
-
- protected void addEntity(Class clazz, String val) {
- if (_log.isLoggable(Level.FINEST)) {
- _log.log(Level.FINEST, "addComponent(" + val + "," + clazz.getName() + ")");
- }
- getApplication().addComponent(val, clazz.getName());
- //register the renderer if not registered
-
- _alreadyRegistered.put(clazz.getName(), val);
- }
-
- @Override
- public void purge(String className) {
- super.purge(className);
- //no purge needed we already have a different class
- //registered
- if (!_alreadyRegistered.containsKey(className)) {
- return;
- }
- String val = (String) _alreadyRegistered.remove(className);
- if (val != null) {
- getApplication().addComponent(val, PurgedComponent.class.getName());
- }
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/ConverterImplementationListener.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/ConverterImplementationListener.java
deleted file mode 100644
index 65a2ab8..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/ConverterImplementationListener.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation;
-
-import org.apache.myfaces.extensions.scripting.api.AnnotationScanListener;
-import org.apache.myfaces.extensions.scripting.jsf2.annotation.purged.PurgedConverter;
-
-import javax.faces.application.Application;
-import javax.faces.convert.FacesConverter;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ConverterImplementationListener extends MapEntityAnnotationScanner implements AnnotationScanListener {
-
- private static final String PAR_VALUE = "value";
- private static final String PAR_DEFAULT = "forClass";
-
- Map<AnnotationEntry, String> _inverseIndex = new HashMap<AnnotationEntry, String>();
-
- class AnnotationEntry {
- String value;
- Class forClass;
-
- AnnotationEntry(String value, Class forClass) {
-
- this.value = value;
- this.forClass = forClass;
- }
-
- public boolean equals(Object incoming) {
- if (incoming == null) {
- return false;
- }
-
- if (!(incoming instanceof AnnotationEntry)) {
- return false;
- }
- AnnotationEntry toCompare = (AnnotationEntry) incoming;
-
- boolean firstEquals = compareValuePair(value, toCompare.getValue());
- boolean secondEquals = compareValuePair(forClass, toCompare.getForClass());
-
- return firstEquals && secondEquals;
- }
-
- @Override
- public int hashCode() {
- String retVal = checkForNull(value) + "_";
- retVal += ((forClass != null) ? forClass.getName() : "");
- return retVal.hashCode();
- }
-
- private String checkForNull(String in) {
- return (in == null) ? "" : in;
- }
-
- protected boolean compareValuePair(Object val1, Object val2) {
- boolean retVal = false;
- if (val1 == null) {
- if (val2 != null) retVal = false;
- if (val2 == null) {
- retVal = true;
- }
- } else {
- retVal = val1.equals(val2);
- }
- return retVal;
- }
-
- public String getValue() {
- return value;
- }
-
- public Class getForClass() {
- return forClass;
- }
- }
-
- public ConverterImplementationListener() {
- super(PAR_VALUE, PAR_DEFAULT);
- }
-
- @Override
- protected void addEntity(Class clazz, Map<String, Object> params) {
- String value = (String) params.get(PAR_VALUE);
- Class forClass = (Class) params.get(PAR_DEFAULT);
-
- AnnotationEntry entry = new AnnotationEntry(value, forClass);
- _alreadyRegistered.put(clazz.getName(), entry);
- _inverseIndex.put(entry, clazz.getName());
-
- getApplication().addConverter(entry.getValue(), clazz.getName());
- }
-
- @Override
- protected boolean hasToReregister(Map params, Class clazz) {
- String value = (String) params.get(PAR_VALUE);
- Class forClass = (Class) params.get(PAR_DEFAULT);
-
- AnnotationEntry entry = new AnnotationEntry(value, forClass);
-
- AnnotationEntry alreadyRegistered = (AnnotationEntry) _alreadyRegistered.get(clazz.getName());
-
- return (alreadyRegistered == null) || alreadyRegistered.equals(entry);
- }
-
- public boolean supportsAnnotation(String annotation) {
- return annotation.equals(FacesConverter.class.getName());
- }
-
- public boolean supportsAnnotation(Class annotation) {
- return annotation.equals(FacesConverter.class);
- }
-
-
- @Override
- public void purge(String className) {
- super.purge(className);
- AnnotationEntry entry = (AnnotationEntry) _alreadyRegistered.remove(className);
- if (entry == null) {
- return;
- }
- String _oldConverterClass = _inverseIndex.get(entry);
- if (_oldConverterClass.equals(className)) {
- Application application = getApplication();
- application.addConverter(entry.getValue(), PurgedConverter.class.getName());
- _inverseIndex.put(entry, className);
- }
- }
-
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/GenericAnnotationScanner.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/GenericAnnotationScanner.java
deleted file mode 100644
index 766a726..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/GenericAnnotationScanner.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation;
-
-import org.apache.myfaces.extensions.scripting.api.*;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.loaders.java.ScannerClassloader;
-import org.apache.myfaces.extensions.scripting.monitor.ClassResource;
-import org.apache.myfaces.extensions.scripting.monitor.RefreshAttribute;
-
-import javax.faces.context.FacesContext;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * Source path annotation scanner for java it scans all sources in the specified source paths
- * recursively for additional information
- * and then adds the id/name -> class binding information to the correct factory locations,
- * wherever possible
- */
-@SuppressWarnings("unused")
-public class GenericAnnotationScanner extends BaseAnnotationScanListener implements ClassScanner {
-
- List<ClassScanListener> _listeners = new LinkedList<ClassScanListener>();
-
- Map<String, String> _registeredAnnotations = new HashMap<String, String>();
- LinkedList<String> _sourcePaths = new LinkedList<String>();
-
- ScriptingWeaver _weaver = null;
-
- public GenericAnnotationScanner() {
- initDefaultListeners();
- }
-
- public GenericAnnotationScanner(ScriptingWeaver weaver) {
- _weaver = weaver;
- initDefaultListeners();
- }
-
- public void addScanPath(String sourcePath) {
- _sourcePaths.addFirst(sourcePath);
- }
-
- Collection<java.lang.annotation.Annotation> filterAnnotations(java.lang.annotation.Annotation[] annotations) {
- List<java.lang.annotation.Annotation> retVal = new ArrayList<java.lang.annotation.Annotation>(annotations.length);
-
- for (java.lang.annotation.Annotation annotation : annotations) {
- if (annotation.annotationType().getName().startsWith(ScriptingConst.JAVAX_FACES)) {
- retVal.add(annotation);
- }
-
- }
- return retVal;
- }
-
- public void scanClass(Class clazz) {
- java.lang.annotation.Annotation[] annotations = clazz.getAnnotations();
-
- Collection<java.lang.annotation.Annotation> annCol = filterAnnotations(annotations);
- if (!annCol.isEmpty()) {
- addOrMoveAnnotations(clazz);
- } else {
- removeAnnotations(clazz);
- }
- }
-
- private void initDefaultListeners() {
- _listeners.add(new BeanImplementationListener());
- _listeners.add(new BehaviorImplementationListener());
- _listeners.add(new ComponentImplementationListener());
- _listeners.add(new ConverterImplementationListener());
- _listeners.add(new RendererImplementationListener());
- _listeners.add(new ValidatorImplementationListener());
- }
-
- /**
- * builds up the parsing chain and then notifies its observers
- * on the found data
- */
- public void scanPaths() {
- //https://issues.apache.org/jira/browse/EXTSCRIPT-33
-
- //check if the faces config is already available otherwise we cannot scan yet
- final FacesContext facesContext = FacesContext.getCurrentInstance();
- //runtime config not started
- //for now we only can reach the runtime config in the referenced BaseAnnotatonScanListener
- //if we have a facesContext reachable.
- if (facesContext == null) {
- //TODO (1.1) decouple the scan in the BaseAnnotationScanListener from the facesConfig
- //to get the runtime config
- return;
- }
-
- for (String className : _weaver.loadPossibleDynamicClasses()) {
- try {
- ScannerClassloader loader = new ScannerClassloader(Thread.currentThread().getContextClassLoader(), -1, null, WeavingContext.getConfiguration().getCompileTarget());
-
- Class clazz;
- //in case the class does not exist we have to load it from our weavingcontext
- //otherwise we do just a scan on the class to avoid side behavior
- if (WeavingContext.getFileChangedDaemon().getClassMap().get(className) == null) {
- clazz = _weaver.loadScriptingClassFromName(className);
- } else {
- clazz = loader.loadClass(className);
- }
-
- if (clazz != null) {
- java.lang.annotation.Annotation[] anns = clazz.getAnnotations();
- if (anns != null && anns.length > 0) {
- addOrMoveAnnotations(clazz);
- } else {
- removeAnnotations(clazz);
- }
- }
- } catch (ClassNotFoundException e) {
- Logger _logger = Logger.getLogger(this.getClass().getName());
- _logger.log(Level.WARNING, "", e);
- }
- }
-
- }
-
- /**
- * add or moves a class level annotation
- * to a new place
- *
- * @param clazz the class to have the annotation moved or added
- */
- private void addOrMoveAnnotations(Class clazz) {
- java.lang.annotation.Annotation[] anns = clazz.getAnnotations();
- for (java.lang.annotation.Annotation ann : anns) {
- for (ClassScanListener cListener : _listeners) {
- AnnotationScanListener listener = (AnnotationScanListener) cListener;
- if (listener.supportsAnnotation(ann.annotationType())) {
- listener.register(clazz, ann);
-
- _registeredAnnotations.put(clazz.getName(), ann.annotationType().getName());
- //TODO check if we still need this
- ClassResource metaData = WeavingContext.getFileChangedDaemon().getClassMap().get(clazz.getName());
-
- }
- }
- }
- }
-
- /**
- * use case annotation removed
- * we have to entirely remove the annotation
- * from our internal registry and the myfaces registry
- *
- * @param clazz the class to have the annotation removed
- */
- private void removeAnnotations(Class clazz) {
- String registeredAnnotation = _registeredAnnotations.get(clazz.getName());
- if (registeredAnnotation != null) {
- for (ClassScanListener cListener : _listeners) {
- AnnotationScanListener listener = (AnnotationScanListener) cListener;
- if (listener.supportsAnnotation(registeredAnnotation)) {
- listener.purge(clazz.getName());
- _registeredAnnotations.remove(clazz.getName());
- WeavingContext.getFileChangedDaemon().getClassMap().remove(clazz.getName());
- }
- }
- }
- }
-
- public void clearListeners() {
- _listeners.clear();
- }
-
- public void addListener(ClassScanListener listener) {
- _listeners.add(listener);
- }
-
- @Override
- public void scanAndMarkChange() {
- //do nothing here
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/ListenerForAnnotationHandler.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/ListenerForAnnotationHandler.java
deleted file mode 100644
index 7c5abe2..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/ListenerForAnnotationHandler.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.jsf2.annotation;
-
-/**
- * A generic system event listener which makes the system event
- * annotations dynamic
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ListenerForAnnotationHandler {
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/MapEntityAnnotationScanner.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/MapEntityAnnotationScanner.java
deleted file mode 100644
index c39d5a0..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/MapEntityAnnotationScanner.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation;
-
-import org.apache.myfaces.extensions.scripting.api.AnnotationScanListener;
-import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
-
-import javax.faces.component.behavior.FacesBehavior;
-import java.util.Map;
-import java.util.HashMap;
-import java.lang.annotation.Annotation;
-
-/**
- * Annotation scanner which scans generically
- * an annotation with more than one entry values.
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public abstract class MapEntityAnnotationScanner extends BaseAnnotationScanListener implements AnnotationScanListener {
-
- String[] _annotationParms = null;
-
- public MapEntityAnnotationScanner(String... annotationParms) {
- _annotationParms = annotationParms;
- }
-
- public void register(Class clazz, Annotation annotation) {
-
- Map<String, Object> parms = new HashMap<String, Object>(_annotationParms.length);
-
- for (String accessor : _annotationParms) {
- parms.put(accessor, ReflectUtil.fastExecuteMethod(annotation, accessor, new Object[0]));
- }
-
- if (hasToReregister(parms, clazz)) {
- addEntity(clazz, parms);
- }
- }
-
- protected abstract void addEntity(Class clazz, Map<String, Object> params);
-
- protected abstract boolean hasToReregister(Map params, Class clazz);
-
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/RendererImplementationListener.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/RendererImplementationListener.java
deleted file mode 100644
index 7bd4679..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/RendererImplementationListener.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation;
-
-import org.apache.myfaces.extensions.scripting.api.AnnotationScanListener;
-import org.apache.myfaces.extensions.scripting.jsf2.annotation.purged.PurgedRenderer;
-
-import javax.faces.FactoryFinder;
-import javax.faces.context.FacesContext;
-import javax.faces.render.FacesRenderer;
-import javax.faces.render.RenderKit;
-import javax.faces.render.RenderKitFactory;
-import javax.faces.render.Renderer;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Level;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class RendererImplementationListener extends MapEntityAnnotationScanner implements AnnotationScanListener {
- private static final String PAR_FAMILY = "componentFamily";
- private static final String PAR_RENDERERTYPE = "rendererType";
- private static final String PAR_RENDERKITID = "renderKitId";
-
- Map<AnnotationEntry, String> _inverseIndex = new HashMap<AnnotationEntry, String>();
-
- public RendererImplementationListener() {
- super(PAR_FAMILY, PAR_RENDERERTYPE, PAR_RENDERKITID);
- }
-
- class AnnotationEntry {
- String componentFamily;
- String rendererType;
- String renderKitId;
-
- AnnotationEntry(String componentFamily, String rendererType, String renderKitId) {
- this.componentFamily = componentFamily;
- this.rendererType = rendererType;
- this.renderKitId = renderKitId;
- }
-
- public boolean equals(Object incoming) {
- if (!(incoming instanceof AnnotationEntry)) {
- return false;
- }
- AnnotationEntry toCompare = (AnnotationEntry) incoming;
- //handle null cases
- if ((componentFamily == null && toCompare.getComponentFamily() != null) ||
- (componentFamily != null && toCompare.getComponentFamily() == null) ||
- (rendererType == null && toCompare.getRendererType() != null) ||
- (rendererType != null && toCompare.getRendererType() == null) ||
- (renderKitId == null && toCompare.getRenderKitId() != null) ||
- (renderKitId != null && toCompare.getRenderKitId() == null)) {
-
- return false;
- } else if (componentFamily == null && toCompare.getComponentFamily() == null &&
- rendererType == null && toCompare.getRendererType() == null &&
- renderKitId == null && toCompare.getRenderKitId() == null) {
- return true;
- }
-
- return componentFamily.equals(toCompare.getComponentFamily()) &&
- rendererType.equals(toCompare.getRendererType()) &&
- renderKitId.equals(toCompare.getRenderKitId());
- }
-
- @Override
- public int hashCode() {
- /*we calculate the hashcoide to avoid double entries*/
- return (((componentFamily != null) ? componentFamily : "")
- + "_" +
- ((rendererType != null) ? rendererType : "")
- + "_" +
- ((renderKitId != null) ? renderKitId : "")
-
- ).hashCode();
- }
-
- public String getComponentFamily() {
- return componentFamily;
- }
-
- public String getRendererType() {
- return rendererType;
- }
-
- public String getRenderKitId() {
- return renderKitId;
- }
- }
-
- public boolean supportsAnnotation(String annotation) {
- return annotation.equals(FacesRenderer.class.getName());
- }
-
- public boolean supportsAnnotation(Class annotation) {
- return annotation.equals(FacesRenderer.class);
- }
-
- @Override
- protected void addEntity(Class clazz, Map<String, Object> params) {
- String value = (String) params.get(PAR_FAMILY);
- String theDefault = (String) params.get(PAR_RENDERERTYPE);
-
- String renderKitId = getRenderKitId(params);
- RenderKit renderKit = getRenderkit(renderKitId);
-
- AnnotationEntry entry = new AnnotationEntry(value, theDefault, renderKitId);
- _inverseIndex.put(entry, clazz.getName());
- _alreadyRegistered.put(clazz.getName(), entry);
-
- if (_log.isLoggable(Level.FINEST)) {
- _log.log(Level.FINEST, "addRenderer(" + renderKitId + ", "
- + entry.getComponentFamily() + ", " + entry.getRendererType()
- + ", " + clazz.getName() + ")");
- }
-
- try {
- renderKit.addRenderer(entry.getComponentFamily(), entry.getRendererType(), (Renderer) clazz.newInstance());
- } catch (InstantiationException e) {
- _log.log(Level.SEVERE, "", e);
- } catch (IllegalAccessException e) {
- _log.log(Level.SEVERE, "", e);
- }
- }
-
- private RenderKitFactory getRenderKitFactory() {
- return (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
- }
-
- @Override
- protected boolean hasToReregister(Map params, Class clazz) {
- String value = (String) params.get(PAR_FAMILY);
- String theDefault = (String) params.get(PAR_RENDERERTYPE);
- String renderKitId = (String) params.get(PAR_RENDERKITID);
-
- AnnotationEntry entry = new AnnotationEntry(value, theDefault, renderKitId);
-
- AnnotationEntry alreadyRegistered = (AnnotationEntry) _alreadyRegistered.get(clazz.getName());
- if (alreadyRegistered == null) {
- return true;
- }
- //here the check if the new class is the same as the old one
- return alreadyRegistered.equals(entry);
- }
-
- private String getRenderKitId(Map<String, Object> params) {
- String renderKitId = (String) params.get(PAR_RENDERKITID);
- renderKitId = (renderKitId == null) ? getApplication().getDefaultRenderKitId() : renderKitId;
- return renderKitId;
- }
-
- private RenderKit getRenderkit(String renderKitId) {
- RenderKitFactory factory = getRenderKitFactory();
- RenderKit renderKit = factory.getRenderKit(FacesContext.getCurrentInstance(), renderKitId);
- return renderKit;
- }
-
- @Override
- public void purge(String className) {
- super.purge(className);
- AnnotationEntry entry = (AnnotationEntry) _alreadyRegistered.remove(className);
- if (entry == null) {
- return;
- }
-
- RenderKit renderKit = getRenderkit(entry.getRenderKitId());
- try {
- //by fetching the changed renderer we save a full rescan
- String rendererClass = _inverseIndex.get(entry);
- if (rendererClass != null && rendererClass.equals(className)) {
- _inverseIndex.put(entry, PurgedRenderer.class.getName());
- renderKit.addRenderer(entry.getComponentFamily(), entry.getRendererType(), PurgedRenderer.class.newInstance());
- }
- } catch (InstantiationException e) {
- _log.log(Level.SEVERE, "", e);
- } catch (IllegalAccessException e) {
- _log.log(Level.SEVERE, "", e);
- }
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/SingleEntityAnnotationListener.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/SingleEntityAnnotationListener.java
deleted file mode 100644
index 42c36c5..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/SingleEntityAnnotationListener.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation;
-
-import org.apache.myfaces.extensions.scripting.api.AnnotationScanListener;
-import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
-
-import java.util.Map;
-import java.lang.annotation.Annotation;
-
-/**
- * annotation scanner which generalized
- * scans annotations with one value entry
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public abstract class SingleEntityAnnotationListener extends BaseAnnotationScanListener implements AnnotationScanListener {
- String _entityParamValue = null;
-
- public void register(Class clazz, Annotation annotation) {
-
- String val = (String) ReflectUtil.executeMethod(annotation, _entityParamValue);
- if (hasToReregister(val, clazz)) {
- addEntity(clazz, val);
- }
- }
-
- protected abstract void addEntity(Class clazz, String val);
-
- protected boolean hasToReregister(String name, Class clazz) {
- String componentClass = (String) _alreadyRegistered.get(name);
- return componentClass == null || !componentClass.equals(clazz.getName());
- }
-
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/ValidatorImplementationListener.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/ValidatorImplementationListener.java
deleted file mode 100644
index 6a33a10..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/ValidatorImplementationListener.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation;
-
-import org.apache.myfaces.extensions.scripting.api.AnnotationScanListener;
-import org.apache.myfaces.extensions.scripting.jsf2.annotation.purged.PurgedValidator;
-
-import javax.faces.validator.FacesValidator;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class ValidatorImplementationListener extends MapEntityAnnotationScanner implements AnnotationScanListener {
-
- private static final String PAR_VALUE = "value";
- private static final String PAR_DEFAULT = "isDefault";
-
- Map<AnnotationEntry, String> _inverseIndex = new HashMap<AnnotationEntry, String>();
-
- public ValidatorImplementationListener() {
- /*supported annotation parameters rendererType and default*/
- super(PAR_VALUE, PAR_DEFAULT);
- }
-
- class AnnotationEntry {
- String value;
- Boolean theDefault;
-
- AnnotationEntry(String value, Boolean theDefault) {
- this.value = value;
- this.theDefault = theDefault;
- }
-
- public boolean equals(Object incoming) {
- if (!(incoming instanceof AnnotationEntry)) {
- return false;
- }
- AnnotationEntry toCompare = (AnnotationEntry) incoming;
-
- if (incoming == null) {
- return false;
- }
-
- boolean firstEquals = compareValuePair(value, toCompare.getValue());
- boolean secondEquals = compareValuePair(theDefault, toCompare.getTheDefault());
-
- return firstEquals && secondEquals;
- }
-
- @Override
- public int hashCode() {
- String retVal = checkForNull(value) + "_" + checkForNull(theDefault);
- return retVal.hashCode();
- }
-
- private String checkForNull(String in) {
- return (in == null) ? "" : in;
- }
-
- private String checkForNull(Boolean in) {
- return (in == null) ? "" : String.valueOf(in.booleanValue());
- }
-
- protected boolean compareValuePair(Object val1, Object val2) {
- boolean retVal = false;
- if (val1 == null) {
- if (val2 != null) retVal = false;
- if (val2 == null) {
- retVal = true;
- }
- } else {
- retVal = val1.equals(val2);
- }
- return retVal;
- }
-
- public String getValue() {
- return value;
- }
-
- public Boolean getTheDefault() {
- return theDefault;
- }
- }
-
- public boolean supportsAnnotation(String annotation) {
- return annotation.equals(FacesValidator.class.getName());
- }
-
- public boolean supportsAnnotation(Class annotation) {
- return annotation.equals(FacesValidator.class);
- }
-
-
- @Override
- protected void addEntity(Class clazz, Map<String, Object> params) {
- String value = (String) params.get(PAR_VALUE);
- Boolean theDefault = (Boolean) params.get(PAR_DEFAULT);
-
- AnnotationEntry entry = new AnnotationEntry(value, theDefault);
- _alreadyRegistered.put(clazz.getName(), entry);
- _inverseIndex.put(entry, clazz.getName());
-
- getApplication().addValidator(entry.getValue(), clazz.getName());
- }
-
- @Override
- protected boolean hasToReregister(Map params, Class clazz) {
- String value = (String) params.get(PAR_VALUE);
- Boolean theDefault = (Boolean) params.get(PAR_DEFAULT);
-
- AnnotationEntry entry = new AnnotationEntry(value, theDefault);
-
- AnnotationEntry alreadyRegistered = (AnnotationEntry) _alreadyRegistered.get(clazz.getName());
- if (alreadyRegistered == null) {
- return true;
- }
-
- return alreadyRegistered.equals(entry);
- }
-
- @Override
- public void purge(String className) {
- super.purge(className);
- AnnotationEntry entry = (AnnotationEntry) _alreadyRegistered.get(className);
- if (entry == null) {
- return;
- }
-
- String oldValidator = _inverseIndex.get(entry);
- if (oldValidator.equals(className)) {
- _alreadyRegistered.remove(className);
- getApplication().addValidator(entry.getValue(), PurgedValidator.class.getName());
- _inverseIndex.put(entry, PurgedValidator.class.getName());
- }
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedBehavior.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedBehavior.java
deleted file mode 100644
index d45fd13..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedBehavior.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation.purged;
-
-import javax.faces.component.behavior.Behavior;
-import javax.faces.event.BehaviorEvent;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class PurgedBehavior implements Behavior {
- public void broadcast(BehaviorEvent event) {
- throw new RuntimeException("Behavior does not exist");
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedClientBehaviorRenderer.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedClientBehaviorRenderer.java
deleted file mode 100644
index f358ef3..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedClientBehaviorRenderer.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation.purged;
-
-import javax.faces.render.ClientBehaviorRenderer;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class PurgedClientBehaviorRenderer extends ClientBehaviorRenderer {
-
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedComponent.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedComponent.java
deleted file mode 100644
index be08cd7..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedComponent.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation.purged;
-
-import javax.faces.component.UIOutput;
-
-/**
- * We override the component from a real family so that
- * so that myfaces can handle it in a decent way
- * directly from UIComponent it would fail
- * unless we implement everything family etc... all by our own
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class PurgedComponent extends UIOutput {
- public PurgedComponent() {
- super();
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedConverter.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedConverter.java
deleted file mode 100644
index 8853dce..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedConverter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation.purged;
-
-import javax.faces.convert.Converter;
-import javax.faces.convert.ConverterException;
-import javax.faces.context.FacesContext;
-import javax.faces.component.UIComponent;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class PurgedConverter implements Converter {
- private static final String DOES_NOT_EXIST = "Converter does not exist";
-
- public Object getAsObject(FacesContext context, UIComponent component, String value) throws ConverterException {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- public String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedELResolver.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedELResolver.java
deleted file mode 100644
index 08776b5..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedELResolver.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation.purged;
-
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-
-import javax.el.ELResolver;
-import javax.el.ELContext;
-import java.util.Iterator;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class PurgedELResolver extends ELResolver implements Decorated {
-
- private final String DOES_NOT_EXIST = "EL Resolver does not exist";
-
- ELResolver _delegate;
-
- public PurgedELResolver(ELResolver delegate) {
- _delegate = delegate;
- }
-
- @Override
- public Object getValue(ELContext elContext, Object o, Object o1) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public Class getType(ELContext elContext, Object o, Object o1) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public void setValue(ELContext elContext, Object o, Object o1, Object o2) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public boolean isReadOnly(ELContext elContext, Object o, Object o1) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public Iterator getFeatureDescriptors(ELContext elContext, Object o) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public Class getCommonPropertyType(ELContext elContext, Object o) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- public ELResolver getDelegate() {
- return _delegate;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedLifecycle.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedLifecycle.java
deleted file mode 100644
index 2f6656c..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedLifecycle.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation.purged;
-
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-
-import javax.faces.lifecycle.Lifecycle;
-import javax.faces.event.PhaseListener;
-import javax.faces.context.FacesContext;
-import javax.faces.FacesException;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class PurgedLifecycle extends Lifecycle implements Decorated {
-
- private static final String DOES_NOT_EXIST = "Lifecycle does not exist";
-
- Lifecycle _delegate;
-
- public PurgedLifecycle(Lifecycle delegate) {
- _delegate = delegate;
- }
-
- @Override
- public void addPhaseListener(PhaseListener listener) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public void execute(FacesContext context) throws FacesException {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public PhaseListener[] getPhaseListeners() {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public void removePhaseListener(PhaseListener listener) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public void render(FacesContext context) throws FacesException {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- public Object getDelegate() {
- return _delegate;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedNavigationHandler.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedNavigationHandler.java
deleted file mode 100644
index 0b2ac5d..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedNavigationHandler.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation.purged;
-
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-
-import javax.faces.application.NavigationHandler;
-import javax.faces.context.FacesContext;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class PurgedNavigationHandler extends NavigationHandler implements Decorated {
-
- NavigationHandler _delegate;
-
- public PurgedNavigationHandler(NavigationHandler delegate) {
- _delegate = delegate;
- }
-
- @Override
- public void handleNavigation(FacesContext context, String fromAction, String outcome) {
- throw new RuntimeException("Navigation handler does not exist");
- }
-
- public NavigationHandler getDelegate() {
- return _delegate;
- }
-
- public void setDelegate(NavigationHandler delegate) {
- _delegate = delegate;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedRenderer.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedRenderer.java
deleted file mode 100644
index 0ff1433..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedRenderer.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation.purged;
-
-import javax.faces.render.Renderer;
-import javax.faces.context.FacesContext;
-import javax.faces.component.UIComponent;
-import javax.faces.convert.ConverterException;
-import java.io.IOException;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class PurgedRenderer extends Renderer {
- private static final String DOES_NOT_EXIST = "Renderer does not exist";
-
- public PurgedRenderer() {
- super();
- }
-
- @Override
- public void decode(FacesContext context, UIComponent component) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public String convertClientId(FacesContext context, String clientId) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public boolean getRendersChildren() {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws ConverterException {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedRenderkit.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedRenderkit.java
deleted file mode 100644
index 7345663..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedRenderkit.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation.purged;
-
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-
-import javax.faces.render.RenderKit;
-import javax.faces.render.Renderer;
-import javax.faces.render.ResponseStateManager;
-import javax.faces.context.ResponseStream;
-import javax.faces.context.ResponseWriter;
-import java.io.OutputStream;
-import java.io.Writer;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class PurgedRenderkit extends RenderKit implements Decorated {
-
- private static final String DOES_NOT_EXIST = "Renderkit does not exist";
-
- RenderKit _delegate;
-
- public PurgedRenderkit(RenderKit delegate) {
- _delegate = delegate;
- }
-
- @Override
- public void addRenderer(String family, String rendererType, Renderer renderer) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public ResponseStream createResponseStream(OutputStream out) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public ResponseWriter createResponseWriter(Writer writer, String contentTypeList, String characterEncoding) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public Renderer getRenderer(String family, String rendererType) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public ResponseStateManager getResponseStateManager() {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- public RenderKit getDelegate() {
- return _delegate;
- }
-
- public void setDelegate(RenderKit delegate) {
- _delegate = delegate;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedResourceHandler.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedResourceHandler.java
deleted file mode 100644
index d19fc11..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedResourceHandler.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation.purged;
-
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-
-import javax.faces.application.ResourceHandler;
-import javax.faces.application.Resource;
-import javax.faces.context.FacesContext;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-
-public class PurgedResourceHandler extends ResourceHandler implements Decorated {
-
- private static final String DOES_NOT_EXIST = "Resource Handler does not exist";
-
- ResourceHandler _delegate;
-
- public PurgedResourceHandler(ResourceHandler delegate) {
- _delegate = delegate;
- }
-
- @Override
- public Resource createResource(String resourceName) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public Resource createResource(String resourceName, String libraryName) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public Resource createResource(String resourceName, String libraryName, String contentType) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public String getRendererTypeForResourceName(String resourceName) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public void handleResourceRequest(FacesContext context) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public boolean isResourceRequest(FacesContext context) {
- throw new RuntimeException(DOES_NOT_EXIST);
- }
-
- @Override
- public boolean libraryExists(String libraryName) {
- return false;
- }
-
- public ResourceHandler getDelegate() {
- return _delegate;
- }
-
- public void setDelegate(ResourceHandler delegate) {
- _delegate = delegate;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedValidator.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedValidator.java
deleted file mode 100644
index abe168c..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/annotation/purged/PurgedValidator.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.annotation.purged;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.validator.Validator;
-import javax.faces.validator.ValidatorException;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * Purged validator class to enable validator
- * purging despite the fact
- * that the original code does not allow it
- */
-
-public class PurgedValidator implements Validator {
-
- public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
- throw new RuntimeException("Validator does not exist");
- }
-
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/AliasResourceMetaImpl.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/AliasResourceMetaImpl.java
deleted file mode 100644
index 034cc39..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/AliasResourceMetaImpl.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.resources;
-
-/**
- * Contains the metadata information to reference a resource
- *
- * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
- * @version $Revision: 700544 $ $Date: 2008-09-30 13:44:02 -0500 (Mar, 30 Sep 2008) $
- */
-public class AliasResourceMetaImpl extends ResourceMetaImpl
-{
- private String _realResourceName;
-
- private boolean _couldContainValueExpressions;
-
- public AliasResourceMetaImpl(String prefix, String libraryName, String libraryVersion,
- String resourceName, String resourceVersion, String realResourceName, boolean couldContainValueExpressions)
- {
- super(prefix, libraryName, libraryVersion,
- resourceName, resourceVersion);
- _realResourceName = realResourceName;
- _couldContainValueExpressions = couldContainValueExpressions;
- }
-
- public String getRealResourceName()
- {
- return _realResourceName;
- }
-
- public void setRealResourceName(String realResourceName)
- {
- _realResourceName = realResourceName;
- }
-
- @Override
- public String getResourceIdentifier()
- {
- StringBuilder builder = new StringBuilder();
- boolean firstSlashAdded = false;
- if (getLocalePrefix() != null && getLocalePrefix().length() > 0)
- {
- builder.append(getLocalePrefix());
- firstSlashAdded = true;
- }
- if (getLibraryName() != null)
- {
- if (firstSlashAdded) builder.append('/');
- builder.append(getLibraryName());
- firstSlashAdded = true;
- }
- if (getLibraryVersion() != null)
- {
- if (firstSlashAdded) builder.append('/');
- builder.append(getLibraryVersion());
- firstSlashAdded = true;
- }
- if (getRealResourceName() != null)
- {
- if (firstSlashAdded) builder.append('/');
- builder.append(getRealResourceName());
- firstSlashAdded = true;
- }
- if (getResourceVersion() != null)
- {
- if (firstSlashAdded) builder.append('/');
- builder.append(getResourceVersion());
- builder.append(
- getRealResourceName().substring(getRealResourceName().lastIndexOf('.')));
- firstSlashAdded = true;
- }
- return builder.toString();
- }
-
- @Override
- public boolean couldResourceContainValueExpressions()
- {
- return _couldContainValueExpressions;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/BaseResourceHandlerSupport.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/BaseResourceHandlerSupport.java
deleted file mode 100644
index a810a0b..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/BaseResourceHandlerSupport.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.resources;
-
-import java.util.Map;
-
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-
-
-/**
- * A ResourceHandlerSupport implementation for use with standard Java Servlet engines,
- * ie an engine that supports javax.servlet, and uses a standard web.xml file.
- *
- * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
- * @version $Revision: 946779 $ $Date: 2010-05-20 15:31:42 -0500 (Jue, 20 May 2010) $
- */
-public class BaseResourceHandlerSupport extends ResourceHandlerSupport
-{
-
- /**
- * Set the max time in miliseconds set on the "Expires" header for a resource.
- * (default to one week in miliseconds or 604800000)
- */
- public static final String RESOURCE_MAX_TIME_EXPIRES = "org.apache.myfaces.RESOURCE_MAX_TIME_EXPIRES";
-
- /**
- * Identifies the FacesServlet mapping in the current request map.
- */
- private static final String CACHED_SERVLET_MAPPING =
- BaseResourceHandlerSupport.class.getName() + ".CACHED_SERVLET_MAPPING";
-
- private Long _startupTime;
-
- private Long _maxTimeExpires;
-
- public BaseResourceHandlerSupport()
- {
- _startupTime = System.currentTimeMillis();
- }
-
- public ResourceLoader[] getResourceLoaders()
- {
- return null;
- }
-
- public String calculateResourceBasePath(FacesContext facesContext)
- {
- FacesServletMapping mapping = getFacesServletMapping(facesContext);
- ExternalContext externalContext = facesContext.getExternalContext();
-
- if (mapping != null)
- {
- String resourceBasePath = null;
- if (mapping.isExtensionMapping())
- {
- // Mapping using a suffix. In this case we have to strip
- // the suffix. If we have a url like:
- // http://localhost:8080/testjsf20/javax.faces.resource/imagen.jpg.jsf?ln=dojo
- //
- // The servlet path is /javax.faces.resource/imagen.jpg.jsf
- //
- // For obtain the resource name we have to remove the .jsf suffix and
- // the prefix ResourceHandler.RESOURCE_IDENTIFIER
- resourceBasePath = externalContext.getRequestServletPath();
- int stripPoint = resourceBasePath.lastIndexOf('.');
- if (stripPoint > 0)
- {
- resourceBasePath = resourceBasePath.substring(0, stripPoint);
- }
- }
- else
- {
- // Mapping using prefix. In this case we have to strip
- // the prefix used for mapping. If we have a url like:
- // http://localhost:8080/testjsf20/faces/javax.faces.resource/imagen.jpg?ln=dojo
- //
- // The servlet path is /faces
- // and the path info is /javax.faces.resource/imagen.jpg
- //
- // For obtain the resource name we have to remove the /faces prefix and
- // then the prefix ResourceHandler.RESOURCE_IDENTIFIER
- resourceBasePath = externalContext.getRequestPathInfo();
- }
- return resourceBasePath;
- }
- else
- {
- //If no mapping is detected, just return the
- //information follows the servlet path but before
- //the query string
- return externalContext.getRequestPathInfo();
- }
- }
-
- public boolean isExtensionMapping()
- {
- FacesServletMapping mapping = getFacesServletMapping(
- FacesContext.getCurrentInstance());
- if (mapping != null)
- {
- if (mapping.isExtensionMapping())
- {
- return true;
- }
- }
- return false;
- }
-
- public String getMapping()
- {
- FacesServletMapping mapping = getFacesServletMapping(
- FacesContext.getCurrentInstance());
- if (mapping != null)
- {
- if (mapping.isExtensionMapping())
- {
- return mapping.getExtension();
- }
- else
- {
- return mapping.getPrefix();
- }
- }
- return "";
- }
-
- /**
- * Read the web.xml file that is in the classpath and parse its internals to
- * figure out how the FacesServlet is mapped for the current webapp.
- */
- protected FacesServletMapping getFacesServletMapping(FacesContext context)
- {
- Map<Object, Object> attributes = context.getAttributes();
-
- // Has the mapping already been determined during this request?
- FacesServletMapping mapping = (FacesServletMapping) attributes.get(CACHED_SERVLET_MAPPING);
- if (mapping == null)
- {
- ExternalContext externalContext = context.getExternalContext();
- mapping = calculateFacesServletMapping(externalContext.getRequestServletPath(),
- externalContext.getRequestPathInfo());
-
- attributes.put(CACHED_SERVLET_MAPPING, mapping);
- }
- return mapping;
- }
-
- /**
- * Determines the mapping of the FacesServlet in the web.xml configuration
- * file. However, there is no need to actually parse this configuration file
- * as runtime information is sufficient.
- *
- * @param servletPath The servletPath of the current request
- * @param pathInfo The pathInfo of the current request
- * @return the mapping of the FacesServlet in the web.xml configuration file
- */
- protected static FacesServletMapping calculateFacesServletMapping(
- String servletPath, String pathInfo)
- {
- if (pathInfo != null)
- {
- // If there is a "extra path", it's definitely no extension mapping.
- // Now we just have to determine the path which has been specified
- // in the url-pattern, but that's easy as it's the same as the
- // current servletPath. It doesn't even matter if "/*" has been used
- // as in this case the servletPath is just an empty string according
- // to the Servlet Specification (SRV 4.4).
- return FacesServletMapping.createPrefixMapping(servletPath);
- }
- else
- {
- // In the case of extension mapping, no "extra path" is available.
- // Still it's possible that prefix-based mapping has been used.
- // Actually, if there was an exact match no "extra path"
- // is available (e.g. if the url-pattern is "/faces/*"
- // and the request-uri is "/context/faces").
- int slashPos = servletPath.lastIndexOf('/');
- int extensionPos = servletPath.lastIndexOf('.');
- if (extensionPos > -1 && extensionPos > slashPos)
- {
- String extension = servletPath.substring(extensionPos);
- return FacesServletMapping.createExtensionMapping(extension);
- }
- else
- {
- // There is no extension in the given servletPath and therefore
- // we assume that it's an exact match using prefix-based mapping.
- return FacesServletMapping.createPrefixMapping(servletPath);
- }
- }
- }
-
- public long getStartupTime()
- {
- return _startupTime;
- }
-
- public long getMaxTimeExpires()
- {
- if (_maxTimeExpires == null)
- {
- String time = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(RESOURCE_MAX_TIME_EXPIRES);
- if (time != null && time.length() > 0)
- {
- try
- {
- _maxTimeExpires = Long.parseLong(time);
- }
- catch (NumberFormatException e)
- {
- _maxTimeExpires = 604800000L;
- }
- }
- else
- {
- _maxTimeExpires = 604800000L;
- }
- }
- return _maxTimeExpires;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ClassLoaderResourceLoader.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ClassLoaderResourceLoader.java
deleted file mode 100644
index 3ed02f3..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ClassLoaderResourceLoader.java
+++ /dev/null
@@ -1,480 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.resources;
-
-import java.io.InputStream;
-import java.net.URL;
-
-import javax.faces.application.ProjectStage;
-import javax.faces.context.FacesContext;
-
-import org.apache.myfaces.extensions.scripting.core.util.ClassLoaderUtils;
-
-/**
- * A resource loader implementation which loads resources from the thread ClassLoader.
- *
- */
-public class ClassLoaderResourceLoader extends ResourceLoader
-{
- /**
- * It checks version like this: 1, 1_0, 1_0_0, 100_100
- *
- * Used on getLibraryVersion to filter resource directories
- **/
- //protected static Pattern VERSION_CHECKER = Pattern.compile("\\p{Digit}+(_\\p{Digit}*)*");
-
- /**
- * It checks version like this: /1.js, /1_0.js, /1_0_0.js, /100_100.js
- *
- * Used on getResourceVersion to filter resources
- **/
- //protected static Pattern RESOURCE_VERSION_CHECKER = Pattern.compile("/\\p{Digit}+(_\\p{Digit}*)*\\..*");
-
- /*
- private FileFilter _libraryFileFilter = new FileFilter()
- {
- public boolean accept(File pathname)
- {
- if (pathname.isDirectory() && VERSION_CHECKER.matcher(pathname.getName()).matches())
- {
- return true;
- }
- return false;
- }
- };*/
-
- /*
- private FileFilter _resourceFileFilter = new FileFilter()
- {
- public boolean accept(File pathname)
- {
- if (pathname.isDirectory() && RESOURCE_VERSION_CHECKER.matcher(pathname.getName()).matches())
- {
- return true;
- }
- return false;
- }
- };*/
-
- private final boolean _developmentStage;
-
- public ClassLoaderResourceLoader(String prefix)
- {
- super(prefix);
- _developmentStage = FacesContext.getCurrentInstance().isProjectStage(ProjectStage.Development);
- }
-
- @Override
- public String getLibraryVersion(String path)
- {
- return null;
- /*
- String libraryVersion = null;
- if (getPrefix() != null)
- path = getPrefix() + '/' + path;
-
- URL url = getClassLoader().getResource(path);
-
- if (url == null)
- {
- // This library does not exists for this
- // ResourceLoader
- return null;
- }
-
- // The problem here is how to scan the directory. When a ClassLoader
- // is used two cases could occur
- // 1. The files are unpacked so we can use Url.toURI and crawl
- // the directory using the api for files.
- // 2. The files are packed in a jar. This case is more tricky,
- // because we only have a URL. Checking the jar api we can use
- // JarURLConnection (Sounds strange, but the api of
- // URL.openConnection says that for a jar connection a
- // JarURLConnection is returned). From this point we can access
- // to the jar api and solve the algoritm.
- if (url.getProtocol().equals("file"))
- {
- try
- {
- File directory = new File(url.toURI());
- if (directory.isDirectory())
- {
- File[] versions = directory.listFiles(_libraryFileFilter);
- for (int i = 0; i < versions.length; i++)
- {
- String version = versions[i].getName();
- if (VERSION_CHECKER.matcher(version).matches())
- {
- if (libraryVersion == null)
- {
- libraryVersion = version;
- }
- else if (getVersionComparator().compare(libraryVersion, version) < 0)
- {
- libraryVersion = version;
- }
- }
- }
- }
- }
- catch (URISyntaxException e)
- {
- // Just return null, because library version cannot be
- // resolved.
- Logger log = Logger.getLogger(ClassLoaderResourceLoader.class.getName());
- if (log.isLoggable(Level.WARNING))
- {
- log.log(Level.WARNING, "url "+url.toString()+" cannot be translated to uri: "+e.getMessage(), e);
- }
- }
- }
- else if (isJarResourceProtocol(url.getProtocol()))
- {
- try
- {
- url = getClassLoader().getResource(path + '/');
-
- if (url != null)
- {
- JarURLConnection conn = (JarURLConnection)url.openConnection();
- // See DIGESTER-29 for related problem
- conn.setUseCaches(false);
-
- try
- {
- if (conn.getJarEntry().isDirectory())
- {
- // Unfortunately, we have to scan all entry files
- // because there is no proper api to scan it as a
- // directory tree.
- JarFile file = conn.getJarFile();
- for (Enumeration<JarEntry> en = file.entries(); en.hasMoreElements();)
- {
- JarEntry entry = en.nextElement();
- String entryName = entry.getName();
-
- if (entryName.startsWith(path + '/'))
- {
- if (entryName.length() == path.length() + 1)
- {
- // the same string, just skip it
- continue;
- }
-
- if (entryName.charAt(entryName.length() - 1) != '/')
- {
- // Skip files
- continue;
- }
-
- entryName = entryName.substring(path.length() + 1, entryName.length() - 1);
-
- if (entryName.indexOf('/') >= 0)
- {
- // Inner Directory
- continue;
- }
-
- String version = entryName;
- if (VERSION_CHECKER.matcher(version).matches())
- {
- if (libraryVersion == null)
- {
- libraryVersion = version;
- }
- else if (getVersionComparator().compare(libraryVersion, version) < 0)
- {
- libraryVersion = version;
- }
- }
- }
- }
- }
- }
- finally
- {
- //See TRINIDAD-73
- //just close the input stream again if
- //by inspecting the entries the stream
- //was let open.
- try
- {
- conn.getInputStream().close();
- }
- catch (Exception exception)
- {
- // Ignored
- }
- }
- }
- }
- catch (IOException e)
- {
- // Just return null, because library version cannot be
- // resolved.
- Logger log = Logger.getLogger(ClassLoaderResourceLoader.class.getName());
- if (log.isLoggable(Level.WARNING))
- {
- log.log(Level.WARNING, "IOException when scanning for resource in jar file:", e);
- }
- }
- }
- return libraryVersion;
- */
- }
-
- @Override
- public InputStream getResourceInputStream(ResourceMeta resourceMeta)
- {
- if (getPrefix() != null && !"".equals(getPrefix()))
- {
- return getClassLoader().getResourceAsStream(getPrefix() + '/' + resourceMeta.getResourceIdentifier());
- }
- else
- {
- return getClassLoader().getResourceAsStream(resourceMeta.getResourceIdentifier());
- }
- }
-
- @Override
- public URL getResourceURL(ResourceMeta resourceMeta)
- {
- if (getPrefix() != null && !"".equals(getPrefix()))
- {
- return getClassLoader().getResource(getPrefix() + '/' + resourceMeta.getResourceIdentifier());
- }
- else
- {
- return getClassLoader().getResource(resourceMeta.getResourceIdentifier());
- }
- }
-
- @Override
- public String getResourceVersion(String path)
- {
- return null;
- /*
- String resourceVersion = null;
-
- if (getPrefix() != null)
- path = getPrefix() + '/' + path;
-
- URL url = getClassLoader().getResource(path);
-
- if (url == null)
- {
- // This library does not exists for this
- // ResourceLoader
- return null;
- }
-
- if (url.getProtocol().equals("file"))
- {
- try
- {
- File directory = new File(url.toURI());
- if (directory.isDirectory())
- {
- File[] versions = directory.listFiles(_resourceFileFilter);
- for (int i = 0; i < versions.length; i++)
- {
- String version = versions[i].getName();
- if (resourceVersion == null)
- {
- resourceVersion = version;
- }
- else if (getVersionComparator().compare(resourceVersion, version) < 0)
- {
- resourceVersion = version;
- }
- }
- //Since it is a directory and no version found set resourceVersion as invalid
- if (resourceVersion == null)
- {
- resourceVersion = VERSION_INVALID;
- }
- }
- }
- catch (URISyntaxException e)
- {
- Logger log = Logger.getLogger(ClassLoaderResourceLoader.class.getName());
- if (log.isLoggable(Level.WARNING))
- {
- log.log(Level.WARNING, "url "+url.toString()+" cannot be translated to uri: "+e.getMessage(), e);
- }
- }
- }
- else if (isJarResourceProtocol(url.getProtocol()))
- {
- try
- {
- url = getClassLoader().getResource(path + '/');
-
- if (url != null)
- {
- JarURLConnection conn = (JarURLConnection)url.openConnection();
- // See DIGESTER-29 for related problem
- conn.setUseCaches(false);
-
- try
- {
- if (conn.getJarEntry().isDirectory())
- {
- // Unfortunately, we have to scan all entry files
- JarFile file = conn.getJarFile();
- for (Enumeration<JarEntry> en = file.entries(); en.hasMoreElements();)
- {
- JarEntry entry = en.nextElement();
- String entryName = entry.getName();
-
- if (entryName.startsWith(path + '/'))
- {
- if (entryName.length() == path.length() + 1)
- {
- // the same string, just skip it
- continue;
- }
-
- entryName = entryName.substring(path.length());
- if (RESOURCE_VERSION_CHECKER.matcher(entryName).matches())
- {
- String version = entryName.substring(1, entryName.lastIndexOf('.'));
- if (resourceVersion == null)
- {
- resourceVersion = version;
- }
- else if (getVersionComparator().compare(resourceVersion, version) < 0)
- {
- resourceVersion = version;
- }
- }
- }
- }
- if (resourceVersion == null)
- {
- resourceVersion = VERSION_INVALID;
- }
- }
- }
- finally
- {
- //See TRINIDAD-73
- //just close the input stream again if
- //by inspecting the entries the stream
- //was let open.
- try
- {
- conn.getInputStream().close();
- }
- catch (Exception exception)
- {
- // Ignored
- }
- }
-
- }
- }
- catch (IOException e)
- {
- // Just return null, because library version cannot be
- // resolved.
- Logger log = Logger.getLogger(ClassLoaderResourceLoader.class.getName());
- if (log.isLoggable(Level.WARNING))
- {
- log.log(Level.WARNING, "IOException when scanning for resource in jar file:", e);
- }
- }
- }
- return resourceVersion;
- */
- }
-
- @Override
- public ResourceMeta createResourceMeta(String prefix, String libraryName, String libraryVersion,
- String resourceName, String resourceVersion)
- {
- if (_developmentStage && libraryName != null &&
- ResourceLoaderUtils.JAVAX_FACES_LIBRARY_NAME.equals(libraryName) &&
- ResourceLoaderUtils.JSF_JS_RESOURCE_NAME.equals(resourceName))
- {
- // InternalClassLoaderResourceLoader will serve it, so return null in this case.
- return null;
- } else if (_developmentStage && libraryName != null &&
- ResourceLoaderUtils.MYFACES_LIBRARY_NAME.equals(libraryName) &&
- ResourceLoaderUtils.MYFACES_JS_RESOURCE_NAME.equals(resourceName)) {
- // InternalClassLoaderResourceLoader will serve it, so return null in this case.
- return null;
- } else
- {
- return new ResourceMetaImpl(prefix, libraryName, libraryVersion, resourceName, resourceVersion);
- }
- }
-
- /**
- * Returns the ClassLoader to use when looking up resources under the top level package. By default, this is the
- * context class loader.
- *
- * @return the ClassLoader used to lookup resources
- */
- protected ClassLoader getClassLoader()
- {
- return ClassLoaderUtils.getDefaultClassLoader();
- }
-
- @Override
- public boolean libraryExists(String libraryName)
- {
- if (getPrefix() != null && !"".equals(getPrefix()))
- {
- URL url = getClassLoader().getResource(getPrefix() + '/' + libraryName);
- if (url != null)
- {
- return true;
- }
- }
- else
- {
- URL url = getClassLoader().getResource(libraryName);
- if (url != null)
- {
- return true;
- }
- }
- return false;
- }
-
- /**
- * <p>Determines whether the given URL resource protocol refers to a JAR file. Note that
- * BEA WebLogic and IBM WebSphere don't use the "jar://" protocol for some reason even
- * though you can treat these resources just like normal JAR files, i.e. you can ignore
- * the difference between these protocols after this method has returned.</p>
- *
- * @param protocol the URL resource protocol you want to check
- *
- * @return <code>true</code> if the given URL resource protocol refers to a JAR file,
- * <code>false</code> otherwise
- */
- /*
- private static boolean isJarResourceProtocol(String protocol)
- {
- // Websphere uses the protocol "wsjar://" and Weblogic uses the protocol "zip://".
- return "jar".equals(protocol) || "wsjar".equals(protocol) || "zip".equals(protocol);
- }*/
-
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ExternalContextResourceLoader.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ExternalContextResourceLoader.java
deleted file mode 100644
index 19b8870..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ExternalContextResourceLoader.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.resources;
-
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-import javax.faces.context.FacesContext;
-
-/**
- * A resource loader implementation which loads resources from the webapp root. It uses the methods on ExternalContext
- * for handle resources.
- *
- */
-public class ExternalContextResourceLoader extends ResourceLoader
-{
- /**
- * It checks version like this: /1/, /1_0/, /1_0_0/, /100_100/
- *
- * Used on getLibraryVersion to filter resource directories
- **/
- protected static Pattern VERSION_CHECKER = Pattern.compile("/\\p{Digit}+(_\\p{Digit}*)*/");
-
- /**
- * It checks version like this: /1.js, /1_0.js, /1_0_0.js, /100_100.js
- *
- * Used on getResourceVersion to filter resources
- **/
- protected static Pattern RESOURCE_VERSION_CHECKER = Pattern.compile("/\\p{Digit}+(_\\p{Digit}*)*\\..*");
-
- public ExternalContextResourceLoader(String prefix)
- {
- super(prefix);
- }
-
- protected Set<String> getResourcePaths(String path)
- {
- return FacesContext.getCurrentInstance().getExternalContext().getResourcePaths(getPrefix() + '/' + path);
- }
-
- @Override
- public String getResourceVersion(String path)
- {
- String resourceVersion = null;
- Set<String> resourcePaths = this.getResourcePaths(path);
- if (getPrefix() != null)
- path = getPrefix() + '/' + path;
-
- if (null != resourcePaths && !resourcePaths.isEmpty())
- {
- // resourceVersion = // execute the comment
- // Look in the resourcePaths for versioned resources.
- // If one or more versioned resources are found, take
- // the one with the "highest" version number as the value
- // of resourceVersion. If no versioned libraries
- // are found, let resourceVersion remain null.
- for (String resourcePath : resourcePaths)
- {
- String version = resourcePath.substring(path.length());
-
- if (RESOURCE_VERSION_CHECKER.matcher(version).matches())
- {
- version = version.substring(1, version.lastIndexOf('.'));
- if (resourceVersion == null)
- {
- resourceVersion = version;
- }
- else if (getVersionComparator().compare(resourceVersion, version) < 0)
- {
- resourceVersion = version;
- }
- }
- }
- //Since it is a directory and no version was found, set as invalid
- if (resourceVersion == null)
- {
- resourceVersion = VERSION_INVALID;
- }
- }
- return resourceVersion;
- }
-
- @Override
- public String getLibraryVersion(String path)
- {
- String libraryVersion = null;
- Set<String> libraryPaths = this.getResourcePaths(path);
- path = getPrefix() + '/' + path;
- if (null != libraryPaths && !libraryPaths.isEmpty())
- {
- // Look in the libraryPaths for versioned libraries.
- // If one or more versioned libraries are found, take
- // the one with the "highest" version number as the value
- // of libraryVersion. If no versioned libraries
- // are found, let libraryVersion remain null.
-
- for (Iterator<String> it = libraryPaths.iterator(); it.hasNext();)
- {
- String libraryPath = it.next();
- String version = libraryPath.substring(path.length());
-
- if (VERSION_CHECKER.matcher(version).matches())
- {
- version = version.substring(1, version.length() - 1);
- if (libraryVersion == null)
- {
- libraryVersion = version;
- }
- else if (getVersionComparator().compare(libraryVersion, version) < 0)
- {
- libraryVersion = version;
- }
- }
- }
- }
- return libraryVersion;
- }
-
- @Override
- public URL getResourceURL(ResourceMeta resourceMeta)
- {
- try
- {
- return FacesContext.getCurrentInstance().getExternalContext().getResource(
- getPrefix() + '/' + resourceMeta.getResourceIdentifier());
- }
- catch (MalformedURLException e)
- {
- return null;
- }
- }
-
- @Override
- public InputStream getResourceInputStream(ResourceMeta resourceMeta)
- {
- return FacesContext.getCurrentInstance().getExternalContext().getResourceAsStream(
- getPrefix() + '/' + resourceMeta.getResourceIdentifier());
- }
-
- @Override
- public ResourceMeta createResourceMeta(String prefix, String libraryName, String libraryVersion,
- String resourceName, String resourceVersion)
- {
- return new ResourceMetaImpl(prefix, libraryName, libraryVersion, resourceName, resourceVersion);
- }
-
- @Override
- public boolean libraryExists(String libraryName)
- {
- if (getPrefix() != null && !"".equals(getPrefix()))
- {
- try
- {
- URL url =
- FacesContext.getCurrentInstance().getExternalContext().getResource(
- getPrefix() + '/' + libraryName);
- if (url != null)
- {
- return true;
- }
- }
- catch (MalformedURLException e)
- {
- return false;
- }
- }
- else
- {
- try
- {
-
- URL url = FacesContext.getCurrentInstance().getExternalContext().getResource(libraryName);
-
- if (url != null)
- {
- return true;
- }
- }
- catch (MalformedURLException e)
- {
- return false;
- }
- }
- return false;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/FacesServletMapping.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/FacesServletMapping.java
deleted file mode 100644
index 7514771..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/FacesServletMapping.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.jsf2.resources;
-
-/**
- * Represents a mapping entry of the FacesServlet in the web.xml
- * configuration file.
- */
-public class FacesServletMapping
-{
-
- /**
- * The path ("/faces", for example) which has been specified in the
- * url-pattern of the FacesServlet mapping.
- */
- private String prefix;
-
- /**
- * The extension (".jsf", for example) which has been specified in the
- * url-pattern of the FacesServlet mapping.
- */
- private String extension;
-
- /**
- * Creates a new FacesServletMapping object using prefix mapping.
- *
- * @param path The path ("/faces", for example) which has been specified
- * in the url-pattern of the FacesServlet mapping.
- * @return a newly created FacesServletMapping
- */
- public static FacesServletMapping createPrefixMapping(String path)
- {
- FacesServletMapping mapping = new FacesServletMapping();
- mapping.setPrefix(path);
- return mapping;
- }
-
- /**
- * Creates a new FacesServletMapping object using extension mapping.
- *
- * @param path The extension (".jsf", for example) which has been
- * specified in the url-pattern of the FacesServlet mapping.
- * @return a newly created FacesServletMapping
- */
- public static FacesServletMapping createExtensionMapping(
- String extension)
- {
- FacesServletMapping mapping = new FacesServletMapping();
- mapping.setExtension(extension);
- return mapping;
- }
-
- /**
- * Returns the path ("/faces", for example) which has been specified in
- * the url-pattern of the FacesServlet mapping. If this mapping is based
- * on an extension, <code>null</code> will be returned. Note that this
- * path is not the same as the specified url-pattern as the trailing
- * "/*" is omitted.
- *
- * @return the path which has been specified in the url-pattern
- */
- public String getPrefix()
- {
- return prefix;
- }
-
- /**
- * Sets the path ("/faces/", for example) which has been specified in
- * the url-pattern.
- *
- * @param path The path which has been specified in the url-pattern
- */
- public void setPrefix(String path)
- {
- this.prefix = path;
- }
-
- /**
- * Returns the extension (".jsf", for example) which has been specified
- * in the url-pattern of the FacesServlet mapping. If this mapping is
- * not based on an extension, <code>null</code> will be returned.
- *
- * @return the extension which has been specified in the url-pattern
- */
- public String getExtension()
- {
- return extension;
- }
-
- /**
- * Sets the extension (".jsf", for example) which has been specified in
- * the url-pattern of the FacesServlet mapping.
- *
- * @param extension The extension which has been specified in the url-pattern
- */
- public void setExtension(String extension)
- {
- this.extension = extension;
- }
-
- /**
- * Indicates whether this mapping is based on an extension (e.g.
- * ".jsp").
- *
- * @return <code>true</code>, if this mapping is based is on an
- * extension, <code>false</code> otherwise
- */
- public boolean isExtensionMapping()
- {
- return extension != null;
- }
-
- /**
- * Indicates whether this mapping is based on a prefix (e.g.
- * /faces/*").
- *
- * @return <code>true</code>, if this mapping is based is on a
- * prefix, <code>false</code> otherwise
- */
- public boolean isPrefixMapping()
- {
- return prefix != null;
- }
-
- /**
- * Returns the url-pattern entry for this servlet mapping.
- *
- * @return the url-pattern entry for this servlet mapping
- */
- public String getUrlPattern()
- {
- if (isExtensionMapping())
- {
- return "*" + extension;
- }
- else
- {
- return prefix + "/*";
- }
- }
-
-}
\ No newline at end of file
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceHandlerCache.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceHandlerCache.java
deleted file mode 100644
index 7f2f728..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceHandlerCache.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.resources;
-
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.faces.application.ProjectStage;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-
-public class ResourceHandlerCache
-{
- private static final Logger log = Logger
- .getLogger(ResourceHandlerCache.class.getName());
-
- private Boolean _resourceCacheEnabled = null;
- private Map<ResourceKey, ResourceValue> _resourceCacheMap = null;
-
- private static final String RESOURCE_HANDLER_CACHE_SIZE_ATTRIBUTE = "org.apache.myfaces.RESOURCE_HANDLER_CACHE_SIZE";
- private static final int RESOURCE_HANDLER_CACHE_DEFAULT_SIZE = 500;
-
- private static final String RESOURCE_HANDLER_CACHE_ENABLED_ATTRIBUTE = "org.apache.myfaces.RESOURCE_HANDLER_CACHE_ENABLED";
- private static final boolean RESOURCE_HANDLER_CACHE_ENABLED_DEFAULT = true;
-
- public ResourceValue getResource(String resourceName, String libraryName,
- String contentType)
- {
- if (!isResourceCachingEnabled() || _resourceCacheMap == null)
- return null;
-
- if (log.isLoggable(Level.FINE))
- log.log(Level.FINE, "Attemping to get resource from cache for "
- + resourceName);
-
- ResourceKey key = new ResourceKey(resourceName, libraryName,
- contentType);
-
- return _resourceCacheMap.get(key);
- }
-
- public boolean containsResource(String resourceName, String libraryName,
- String contentType)
- {
- if (!isResourceCachingEnabled() || _resourceCacheMap == null)
- return false;
- ResourceKey key = new ResourceKey(resourceName, libraryName,
- contentType);
- return _resourceCacheMap.containsKey(key);
- }
-
- public void putResource(String resourceName, String libraryName,
- String contentType, ResourceMeta resource, ResourceLoader loader)
- {
- if (!isResourceCachingEnabled())
- return;
-
- if (log.isLoggable(Level.FINE))
- log.log(Level.FINE, "Attemping to put resource to cache for "
- + resourceName);
-
- if (_resourceCacheMap == null)
- {
- if (log.isLoggable(Level.FINE))
- log.log(Level.FINE, "Initializing resource cache map");
- _resourceCacheMap = Collections
- .synchronizedMap(new _ResourceMap<ResourceKey, ResourceValue>(
- getMaxSize()));
- }
-
- _resourceCacheMap.put(new ResourceKey(resourceName, libraryName,
- contentType), new ResourceValue(resource, loader));
- }
-
- private boolean isResourceCachingEnabled()
- {
- if (_resourceCacheEnabled == null)
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
-
- //first, check to make sure that ProjectStage is production, if not, skip caching
- if (!facesContext.isProjectStage(ProjectStage.Production))
- {
- return _resourceCacheEnabled = Boolean.FALSE;
- }
-
- ExternalContext externalContext = facesContext.getExternalContext();
- if (externalContext == null)
- return false; //don't cache right now, but don't disable it yet either
-
- //if in production, make sure that the cache is not explicitly disabled via context param
- String configParam = externalContext
- .getInitParameter(ResourceHandlerCache.RESOURCE_HANDLER_CACHE_ENABLED_ATTRIBUTE);
- _resourceCacheEnabled = configParam == null ? ResourceHandlerCache.RESOURCE_HANDLER_CACHE_ENABLED_DEFAULT
- : Boolean.parseBoolean(configParam);
-
- if (log.isLoggable(Level.FINE))
- {
- log.log(Level.FINE, "MyFaces Resource Caching Enabled="
- + _resourceCacheEnabled);
- }
- }
- return _resourceCacheEnabled;
- }
-
- private int getMaxSize()
- {
- ExternalContext externalContext = FacesContext.getCurrentInstance()
- .getExternalContext();
-
- String configParam = externalContext == null ? null : externalContext
- .getInitParameter(RESOURCE_HANDLER_CACHE_SIZE_ATTRIBUTE);
- return configParam == null ? RESOURCE_HANDLER_CACHE_DEFAULT_SIZE
- : Integer.parseInt(configParam);
- }
-
- public static class ResourceKey
- {
- private String resourceName;
- private String libraryName;
- private String contentType;
-
- public ResourceKey(String resourceName, String libraryName,
- String contentType)
- {
- this.resourceName = resourceName;
- this.libraryName = libraryName;
- this.contentType = contentType;
- }
-
- @Override
- public int hashCode()
- {
- final int prime = 31;
- int result = 1;
- result = prime * result
- + ((contentType == null) ? 0 : contentType.hashCode());
- result = prime * result
- + ((libraryName == null) ? 0 : libraryName.hashCode());
- result = prime * result
- + ((resourceName == null) ? 0 : resourceName.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ResourceKey other = (ResourceKey) obj;
- if (contentType == null)
- {
- if (other.contentType != null)
- return false;
- }
- else if (!contentType.equals(other.contentType))
- return false;
- if (libraryName == null)
- {
- if (other.libraryName != null)
- return false;
- }
- else if (!libraryName.equals(other.libraryName))
- return false;
- if (resourceName == null)
- {
- if (other.resourceName != null)
- return false;
- }
- else if (!resourceName.equals(other.resourceName))
- return false;
- return true;
- }
- }
-
- public static class ResourceValue
- {
- private ResourceMeta resourceMeta;
-
- private ResourceLoader resourceLoader;
-
- public ResourceValue(ResourceMeta resourceMeta,
- ResourceLoader resourceLoader)
- {
- super();
- this.resourceMeta = resourceMeta;
- this.resourceLoader = resourceLoader;
- }
-
- public ResourceMeta getResourceMeta()
- {
- return resourceMeta;
- }
-
- public ResourceLoader getResourceLoader()
- {
- return resourceLoader;
- }
- }
-
- private static class _ResourceMap<K, V> extends LinkedHashMap<K, V>
- {
- private static final long serialVersionUID = 1L;
- private int maxCapacity;
-
- public _ResourceMap(int cacheSize)
- {
- // create map at max capacity and 1.1 load factor to avoid rehashing
- super(cacheSize + 1, 1.1f, true);
- maxCapacity = cacheSize;
- }
-
- @Override
- protected boolean removeEldestEntry(Map.Entry<K, V> eldest)
- {
- return size() > maxCapacity;
- }
- }
-}
\ No newline at end of file
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceHandlerImpl.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceHandlerImpl.java
deleted file mode 100644
index a6ca82f..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceHandlerImpl.java
+++ /dev/null
@@ -1,567 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.resources;
-
-import org.apache.myfaces.extensions.scripting.core.util.ClassLoaderUtils;
-import org.apache.myfaces.renderkit.ErrorPageWriter;
-
-import javax.faces.application.Resource;
-import javax.faces.application.ResourceHandler;
-import javax.faces.context.FacesContext;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * DOCUMENT ME!
- *
- * @author Simon Lessard (latest modification by $Author: slessard $)
- *
- * @version $Revision: 696515 $ $Date: 2008-09-17 19:37:53 -0500 (mer., 17 sept. 2008) $
- */
-public abstract class ResourceHandlerImpl extends ResourceHandler
-{
-
- private static final String IS_RESOURCE_REQUEST = "org.apache.myfaces.IS_RESOURCE_REQUEST";
-
- private ResourceHandlerSupport _resourceHandlerSupport;
-
- private ResourceHandlerCache _resourceHandlerCache;
-
- //private static final Log log = LogFactory.getLog(ResourceHandlerImpl.class);
- private static final Logger log = Logger.getLogger(ResourceHandlerImpl.class.getName());
-
- private static final int _BUFFER_SIZE = 2048;
-
- @Override
- public Resource createResource(String resourceName)
- {
- return createResource(resourceName, null);
- }
-
- @Override
- public Resource createResource(String resourceName, String libraryName)
- {
- return createResource(resourceName, libraryName, null);
- }
-
- @Override
- public Resource createResource(String resourceName, String libraryName,
- String contentType)
- {
- Resource resource = null;
-
- if (contentType == null)
- {
- //Resolve contentType using ExternalContext.getMimeType
- contentType = FacesContext.getCurrentInstance().getExternalContext().getMimeType(resourceName);
- }
-
- if(getResourceLoaderCache().containsResource(resourceName, libraryName, contentType))
- {
- ResourceHandlerCache.ResourceValue resourceValue = getResourceLoaderCache().getResource(resourceName, libraryName, contentType);
- resource = new ResourceImpl(resourceValue.getResourceMeta(), resourceValue.getResourceLoader(),
- getResourceHandlerSupport(), contentType);
- }
- else
- {
- for (ResourceLoader loader : getResourceHandlerSupport()
- .getResourceLoaders())
- {
- ResourceMeta resourceMeta = deriveResourceMeta(loader,
- resourceName, libraryName);
-
- if (resourceMeta != null)
- {
- resource = new ResourceImpl(resourceMeta, loader,
- getResourceHandlerSupport(), contentType);
-
- getResourceLoaderCache().putResource(resourceName, libraryName, contentType, resourceMeta, loader);
- break;
- }
- }
- }
-
- return resource;
- }
-
- /**
- * This method try to create a ResourceMeta for a specific resource
- * loader. If no library, or resource is found, just return null,
- * so the algorithm in createResource can continue checking with the
- * next registered ResourceLoader.
- */
- protected ResourceMeta deriveResourceMeta(ResourceLoader resourceLoader,
- String resourceName, String libraryName)
- {
- String localePrefix = getLocalePrefixForLocateResource();
- String resourceVersion = null;
- String libraryVersion = null;
- ResourceMeta resourceId = null;
-
- //1. Try to locate resource in a localized path
- if (localePrefix != null)
- {
- if (null != libraryName)
- {
- String pathToLib = localePrefix + '/' + libraryName;
- libraryVersion = resourceLoader.getLibraryVersion(pathToLib);
-
- if (null != libraryVersion)
- {
- String pathToResource = localePrefix + '/'
- + libraryName + '/' + libraryVersion + '/'
- + resourceName;
- resourceVersion = resourceLoader
- .getResourceVersion(pathToResource);
- }
- else
- {
- String pathToResource = localePrefix + '/'
- + libraryName + '/' + resourceName;
- resourceVersion = resourceLoader
- .getResourceVersion(pathToResource);
- }
-
- if (!(resourceVersion != null && ResourceLoader.VERSION_INVALID.equals(resourceVersion)))
- {
- resourceId = resourceLoader.createResourceMeta(localePrefix, libraryName,
- libraryVersion, resourceName, resourceVersion);
- }
- }
- else
- {
- resourceVersion = resourceLoader
- .getResourceVersion(localePrefix + '/'+ resourceName);
- if (!(resourceVersion != null && ResourceLoader.VERSION_INVALID.equals(resourceVersion)))
- {
- resourceId = resourceLoader.createResourceMeta(localePrefix, null, null,
- resourceName, resourceVersion);
- }
- }
-
- if (resourceId != null)
- {
- URL url = resourceLoader.getResourceURL(resourceId);
- if (url == null)
- {
- resourceId = null;
- }
- }
- }
-
- //2. Try to localize resource in a non localized path
- if (resourceId == null)
- {
- if (null != libraryName)
- {
- libraryVersion = resourceLoader.getLibraryVersion(libraryName);
-
- if (null != libraryVersion)
- {
- String pathToResource = (libraryName + '/' + libraryVersion
- + '/' + resourceName);
- resourceVersion = resourceLoader
- .getResourceVersion(pathToResource);
- }
- else
- {
- String pathToResource = (libraryName + '/'
- + resourceName);
- resourceVersion = resourceLoader
- .getResourceVersion(pathToResource);
- }
-
- if (!(resourceVersion != null && ResourceLoader.VERSION_INVALID.equals(resourceVersion)))
- {
- resourceId = resourceLoader.createResourceMeta(null, libraryName,
- libraryVersion, resourceName, resourceVersion);
- }
- }
- else
- {
- resourceVersion = resourceLoader
- .getResourceVersion(resourceName);
-
- if (!(resourceVersion != null && ResourceLoader.VERSION_INVALID.equals(resourceVersion)))
- {
- resourceId = resourceLoader.createResourceMeta(null, null, null,
- resourceName, resourceVersion);
- }
- }
-
- if (resourceId != null)
- {
- URL url = resourceLoader.getResourceURL(resourceId);
- if (url == null)
- {
- resourceId = null;
- }
- }
- }
-
- return resourceId;
- }
-
- @Override
- public String getRendererTypeForResourceName(String resourceName)
- {
- if (resourceName.endsWith(".js"))
- return "javax.faces.resource.Script";
- else if (resourceName.endsWith(".css"))
- return "javax.faces.resource.Stylesheet";
- return null;
- }
-
- /**
- * Handle the resource request, writing in the output.
- *
- * This method implements an algorithm semantically identical to
- * the one described on the javadoc of ResourceHandler.handleResourceRequest
- */
- @Override
- public void handleResourceRequest(FacesContext facesContext) throws IOException
- {
- try
- {
- String resourceBasePath = getResourceHandlerSupport()
- .calculateResourceBasePath(facesContext);
-
- if (resourceBasePath == null)
- {
- // No base name could be calculated, so no further
- //advance could be done here. HttpServletResponse.SC_NOT_FOUND
- //cannot be returned since we cannot extract the
- //resource base name
- return;
- }
-
- // We neet to get an instance of HttpServletResponse, but sometimes
- // the response object is wrapped by several instances of
- // ServletResponseWrapper (like ResponseSwitch).
- // Since we are handling a resource, we can expect to get an
- // HttpServletResponse.
- Object response = facesContext.getExternalContext().getResponse();
-
- //TODO merge the servlet response determination in
- HttpServletResponse httpServletResponse = (HttpServletResponse) response;
- if (httpServletResponse == null)
- {
- throw new IllegalStateException("Could not obtain an instance of HttpServletResponse.");
- }
-
- if (isResourceIdentifierExcluded(facesContext, resourceBasePath))
- {
- httpServletResponse.setStatus(HttpServletResponse.SC_NOT_FOUND);
- return;
- }
-
- String resourceName = null;
- if (resourceBasePath.startsWith(ResourceHandler.RESOURCE_IDENTIFIER))
- {
- resourceName = resourceBasePath
- .substring(ResourceHandler.RESOURCE_IDENTIFIER.length() + 1);
- }
- else
- {
- //Does not have the conditions for be a resource call
- httpServletResponse.setStatus(HttpServletResponse.SC_NOT_FOUND);
- return;
- }
-
- String libraryName = facesContext.getExternalContext()
- .getRequestParameterMap().get("ln");
-
- Resource resource = null;
- if (libraryName != null)
- {
- //log.info("libraryName=" + libraryName);
- resource = facesContext.getApplication().getResourceHandler().createResource(resourceName, libraryName);
- }
- else
- {
- resource = facesContext.getApplication().getResourceHandler().createResource(resourceName);
- }
-
- if (resource == null)
- {
- httpServletResponse.setStatus(HttpServletResponse.SC_NOT_FOUND);
- return;
- }
-
- if (!resource.userAgentNeedsUpdate(facesContext))
- {
- httpServletResponse.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
- return;
- }
-
- httpServletResponse.setContentType(resource.getContentType());
-
- Map<String, String> headers = resource.getResponseHeaders();
-
- for (Map.Entry<String, String> entry : headers.entrySet())
- {
- httpServletResponse.setHeader(entry.getKey(), entry.getValue());
- }
-
- //serve up the bytes (taken from trinidad ResourceServlet)
- try
- {
- InputStream in = resource.getInputStream();
- OutputStream out = httpServletResponse.getOutputStream();
- byte[] buffer = new byte[_BUFFER_SIZE];
-
- try
- {
- int count = pipeBytes(in, out, buffer);
- //set the content lenght
- httpServletResponse.setContentLength(count);
- }
- finally
- {
- try
- {
- in.close();
- }
- finally
- {
- out.close();
- }
- }
- }
- catch (IOException e)
- {
- //TODO: Log using a localized message (which one?)
- if (log.isLoggable(Level.SEVERE))
- log.severe("Error trying to load resource " + resourceName
- + " with library " + libraryName + " :"
- + e.getMessage());
- httpServletResponse.setStatus(HttpServletResponse.SC_NOT_FOUND);
- }
- }
- catch (Throwable ex)
- {
- // handle the Throwable accordingly. Maybe generate an error page.
- // FIXME we are creating a html error page for a non html request here
- // shouln't we do something better? -=Jakob Korherr=-
- ErrorPageWriter.handleThrowable(facesContext, ex);
- }
- }
-
- /**
- * Reads the specified input stream into the provided byte array storage and
- * writes it to the output stream.
- */
- private static int pipeBytes(InputStream in, OutputStream out, byte[] buffer)
- throws IOException
- {
- int count = 0;
- int length;
-
- while ((length = (in.read(buffer))) >= 0)
- {
- out.write(buffer, 0, length);
- count += length;
- }
- return count;
- }
-
- @Override
- public boolean isResourceRequest(FacesContext facesContext)
- {
- // Since this method could be called many times we save it
- //on request map so the first time is calculated it remains
- //alive until the end of the request
- Boolean value = (Boolean) facesContext.getAttributes().get(IS_RESOURCE_REQUEST);
-
- if (value != null && value)
- {
- //return the saved value
- return value;
- }
- else
- {
- String resourceBasePath = getResourceHandlerSupport()
- .calculateResourceBasePath(facesContext);
-
- if (resourceBasePath != null
- && resourceBasePath.startsWith(ResourceHandler.RESOURCE_IDENTIFIER))
- {
- facesContext.getAttributes().put(IS_RESOURCE_REQUEST, Boolean.TRUE);
- return true;
- }
- else
- {
- facesContext.getAttributes().put(IS_RESOURCE_REQUEST, Boolean.FALSE);
- return false;
- }
- }
- }
-
- protected String getLocalePrefixForLocateResource()
- {
- String localePrefix = null;
- FacesContext context = FacesContext.getCurrentInstance();
-
- String bundleName = context.getApplication().getMessageBundle();
-
- if (null != bundleName)
- {
- Locale locale = context.getApplication().getViewHandler()
- .calculateLocale(context);
-
- ResourceBundle bundle = ResourceBundle
- .getBundle(bundleName, locale, ClassLoaderUtils.getDefaultClassLoader());
-
- if (bundle != null)
- {
- try
- {
- localePrefix = bundle.getString(ResourceHandler.LOCALE_PREFIX);
- }
- catch (MissingResourceException e)
- {
- // Ignore it and return null
- }
- }
- }
- return localePrefix;
- }
-
- private static ResourceBundle getBundle(FacesContext facesContext, Locale locale, String bundleName)
- {
- try
- {
- // First we try the JSF implementation class loader
- return ResourceBundle.getBundle(bundleName, locale, facesContext.getClass().getClassLoader());
- }
- catch (MissingResourceException ignore1)
- {
- try
- {
- // Next we try the JSF API class loader
- return ResourceBundle.getBundle(bundleName, locale, ResourceHandlerImpl.class.getClassLoader());
- }
- catch (MissingResourceException ignore2)
- {
- try
- {
- // Last resort is the context class loader
- return ResourceBundle.getBundle(bundleName, locale, ClassLoaderUtils.getDefaultClassLoader());
- }
- catch (MissingResourceException damned)
- {
- return null;
- }
- }
- }
- }
-
- protected boolean isResourceIdentifierExcluded(FacesContext context,
- String resourceIdentifier)
- {
- String value = context.getExternalContext().getInitParameter(
- RESOURCE_EXCLUDES_PARAM_NAME);
- if (value == null)
- {
- value = RESOURCE_EXCLUDES_DEFAULT_VALUE;
- }
- //TODO: optimize this code
- String[] extensions = value.split("\\s+");
- for (int i = 0; i < extensions.length; i++)
- {
- if (resourceIdentifier.endsWith(extensions[i]))
- {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Check if a library exists or not. This is done delegating
- * to each ResourceLoader used, because each one has a different
- * prefix and way to load resources.
- *
- */
- @Override
- public boolean libraryExists(String libraryName)
- {
- String localePrefix = getLocalePrefixForLocateResource();
-
- String pathToLib = null;
-
- if (localePrefix != null)
- {
- //Check with locale
- pathToLib = localePrefix + '/' + libraryName;
-
- for (ResourceLoader loader : getResourceHandlerSupport()
- .getResourceLoaders())
- {
- if (loader.libraryExists(pathToLib))
- {
- return true;
- }
- }
- }
-
- //Check without locale
- for (ResourceLoader loader : getResourceHandlerSupport()
- .getResourceLoaders())
- {
- if (loader.libraryExists(libraryName))
- {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * @param resourceHandlerSupport
- * the resourceHandlerSupport to set
- */
- public void setResourceHandlerSupport(
- ResourceHandlerSupport resourceHandlerSupport)
- {
- _resourceHandlerSupport = resourceHandlerSupport;
- }
-
- /**
- * @return the resourceHandlerSupport
- */
- protected abstract ResourceHandlerSupport getResourceHandlerSupport();
-
- private ResourceHandlerCache getResourceLoaderCache()
- {
- if (_resourceHandlerCache == null)
- _resourceHandlerCache = new ResourceHandlerCache();
- return _resourceHandlerCache;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceHandlerSupport.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceHandlerSupport.java
deleted file mode 100644
index 67c77cf..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceHandlerSupport.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.resources;
-
-import javax.faces.context.FacesContext;
-
-/**
- * A utility class to isolate a ResourceHandler implementation from its
- * underlying implementation
- *
- * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
- * @version $Revision: 891494 $ $Date: 2009-12-16 19:42:18 -0500 (Mié, 16 Dic 2009) $
- */
-public abstract class ResourceHandlerSupport
-{
-
- /**
- * Calculate the resource base path.
- *
- * It should extract a string like:
- *
- * ResourceHandler.RESOURCE_IDENTIFIER + '/' + getResourceName()
- *
- * For example:
- *
- * /javax.faces.resource/image.jpg
- *
- * This is used on ResourceHandler.handleResourceRequest()
- *
- */
- public abstract String calculateResourceBasePath(FacesContext facesContext);
-
- /**
- * Return an array of resource loaders used to find resources
- * using the standard. The order of ResourceLoaders define
- * its precedence.
- *
- * @return
- */
- public abstract ResourceLoader[] getResourceLoaders();
-
- /**
- * Check if the mapping used is done using extensions (.xhtml, .jsf)
- * or if it is not (/faces/*)
- * @return
- */
- public abstract boolean isExtensionMapping();
-
- /**
- * Get the mapping used as prefix(/faces) or sufix(.jsf)
- *
- * @return
- */
- public abstract String getMapping();
-
- /**
- * Return the time when the app started. This is useful to set the
- * "Last-Modified" header in some specific cases.
- *
- * @return
- */
- public abstract long getStartupTime();
-
- /**
- * Return the time that should be set on "Expires" header in a resource.
- *
- * @return
- */
- public abstract long getMaxTimeExpires();
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceImpl.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceImpl.java
deleted file mode 100644
index 6e0b8fc..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceImpl.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.resources;
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PushbackInputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.el.ELContext;
-import javax.el.ELException;
-import javax.el.ValueExpression;
-import javax.faces.application.ProjectStage;
-import javax.faces.application.Resource;
-import javax.faces.application.ResourceHandler;
-import javax.faces.context.FacesContext;
-import javax.faces.event.ExceptionQueuedEvent;
-import javax.faces.event.ExceptionQueuedEventContext;
-
-/**
- * Default implementation for resources
- *
- * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
- * @version $Revision: 957739 $ $Date: 2010-06-24 17:27:40 -0500 (Jue, 24 Jun 2010) $
- */
-public class ResourceImpl extends Resource {
-
-
- private ResourceMeta _resourceMeta;
- private ResourceLoader _resourceLoader;
- private ResourceHandlerSupport _resourceHandlerSupport;
-
- public ResourceImpl(ResourceMeta resourceMeta,
- ResourceLoader resourceLoader, ResourceHandlerSupport support, String contentType) {
- _resourceMeta = resourceMeta;
- _resourceLoader = resourceLoader;
- _resourceHandlerSupport = support;
- setLibraryName(resourceMeta.getLibraryName());
- setResourceName(resourceMeta.getResourceName());
- setContentType(contentType);
- }
-
- public ResourceLoader getResourceLoader() {
- return _resourceLoader;
- }
-
- @Override
- public InputStream getInputStream() throws IOException {
- if (couldResourceContainValueExpressions()) {
- return new ValueExpressionFilterInputStream(
- getResourceLoader().getResourceInputStream(_resourceMeta));
- } else {
- return getResourceLoader().getResourceInputStream(_resourceMeta);
- }
- }
-
- private boolean couldResourceContainValueExpressions() {
- if (_resourceMeta.couldResourceContainValueExpressions()) {
- return true;
- } else {
- //By default only css resource contain value expressions
- String contentType = getContentType();
-
- return ("text/css".equals(contentType));
- }
- }
-
- private class ValueExpressionFilterInputStream extends InputStream {
- private PushbackInputStream delegate;
-
- public ValueExpressionFilterInputStream(InputStream in) {
- super();
- delegate = new PushbackInputStream(in, 255);
- }
-
- @Override
- public int read() throws IOException {
- int c1 = delegate.read();
-
- if (c1 == -1) return -1;
-
- if (((char) c1) == '#') {
- int c2 = delegate.read();
- if (c2 == -1) return -1;
- if (((char) c2) == '{') {
- //It is a value expression. We need
- //to look for a occurrence of } to
- //extract the expression and evaluate it,
- //the result should be unread.
- List<Integer> expressionList = new ArrayList<Integer>();
- int c3 = delegate.read();
- while (c3 != -1 && ((char) c3) != '}') {
- expressionList.add(c3);
- c3 = delegate.read();
- }
-
- if (c3 == -1) {
- //get back the data, because we can't
- //extract any value expression
- for (int i = 0; i < expressionList.size(); i++) {
- delegate.unread(expressionList.get(i));
- }
- delegate.unread(c2);
- return c1;
- } else {
- //EL expression found. Evaluate it and pushback
- //the result into the stream
- FacesContext context = FacesContext.getCurrentInstance();
- ELContext elContext = context.getELContext();
- try {
- ValueExpression ve = context.getApplication().
- getExpressionFactory().createValueExpression(
- elContext,
- "#{" + convertToExpression(expressionList) + "}",
- String.class);
- String value = (String) ve.getValue(elContext);
-
- for (int i = value.length() - 1; i >= 0; i--) {
- delegate.unread((int) value.charAt(i));
- }
- } catch (ELException e) {
- ExceptionQueuedEventContext equecontext = new ExceptionQueuedEventContext(context, e, null);
- context.getApplication().publishEvent(context, ExceptionQueuedEvent.class, equecontext);
-
- Logger log = Logger.getLogger(ResourceImpl.class.getName());
- if (log.isLoggable(Level.SEVERE))
- log.severe("Cannot evaluate EL expression " + convertToExpression(expressionList) + " in resource " + getLibraryName() + ":" + getResourceName());
-
- delegate.unread(c3);
- for (int i = expressionList.size() - 1; i >= 0; i--) {
- delegate.unread(expressionList.get(i));
- }
- delegate.unread(c2);
- return c1;
- }
-
- //read again
- return delegate.read();
- }
- } else {
- delegate.unread(c2);
- return c1;
- }
- } else {
- //just continue
- return c1;
- }
- }
-
- private String convertToExpression(List<Integer> expressionList) {
- char[] exprArray = new char[expressionList.size()];
-
- for (int i = 0; i < expressionList.size(); i++) {
- exprArray[i] = (char) expressionList.get(i).intValue();
- }
- return String.valueOf(exprArray);
- }
- }
-
- @Override
- public String getRequestPath() {
- String path;
- if (_resourceHandlerSupport.isExtensionMapping()) {
- path = ResourceHandler.RESOURCE_IDENTIFIER + '/' +
- getResourceName() + _resourceHandlerSupport.getMapping();
- } else {
- String mapping = _resourceHandlerSupport.getMapping();
- path = ResourceHandler.RESOURCE_IDENTIFIER + '/' + getResourceName();
- path = (mapping == null) ? path : mapping + path;
- }
-
- FacesContext facesContext = FacesContext.getCurrentInstance();
- String metadata = null;
- boolean useAmp = false;
- if (getLibraryName() != null) {
- metadata = "?ln=" + getLibraryName();
- path = path + metadata;
- useAmp = true;
-
- if (!facesContext.isProjectStage(ProjectStage.Production)
- && ResourceLoaderUtils.JSF_JS_RESOURCE_NAME.equals(getResourceName())
- && ResourceLoaderUtils.JAVAX_FACES_LIBRARY_NAME.equals(getLibraryName())) {
- // append &stage=?? for all ProjectStages except Production
- path = path + "&stage=" + facesContext.getApplication().getProjectStage().toString();
- }
- }
-
- return facesContext.getApplication().getViewHandler().getResourceURL(facesContext, path);
- }
-
- @Override
- public Map<String, String> getResponseHeaders() {
- FacesContext facesContext = FacesContext.getCurrentInstance();
-
- if (facesContext.getApplication().getResourceHandler().isResourceRequest(facesContext)) {
- Map<String, String> headers = new HashMap<String, String>();
-
- long lastModified;
- try {
- lastModified = ResourceLoaderUtils.getResourceLastModified(this.getURL());
- } catch (IOException e) {
- lastModified = -1;
- }
-
- // Here we have two cases: If the file could contain EL Expressions
- // the last modified time is the greatest value between application startup and
- // the value from file.
- if (this.couldResourceContainValueExpressions() &&
- lastModified < _resourceHandlerSupport.getStartupTime()) {
- lastModified = _resourceHandlerSupport.getStartupTime();
- } else if (_resourceMeta instanceof AliasResourceMetaImpl &&
- lastModified < _resourceHandlerSupport.getStartupTime()) {
- // If the resource meta is aliased, the last modified time is the greatest
- // value between application startup and the value from file.
- lastModified = _resourceHandlerSupport.getStartupTime();
- }
-
- if (lastModified >= 0) {
- headers.put("Last-Modified", ResourceLoaderUtils.formatDateHeader(lastModified));
-
- long expires;
- if (facesContext.isProjectStage(ProjectStage.Development)) {
- // Force to expire now to prevent caching on development time.
- expires = System.currentTimeMillis();
- } else {
- expires = System.currentTimeMillis() + _resourceHandlerSupport.getMaxTimeExpires();
- }
- headers.put("Expires", ResourceLoaderUtils.formatDateHeader(expires));
- }
-
- return headers;
- } else {
- //No need to return headers
- return Collections.emptyMap();
- }
- }
-
- @Override
- public URL getURL() {
- return getResourceLoader().getResourceURL(_resourceMeta);
- }
-
- @Override
- public boolean userAgentNeedsUpdate(FacesContext context) {
- // RFC2616 says related to If-Modified-Since header the following:
- //
- // "... The If-Modified-Since request-header field is used with a method to
- // make it conditional: if the requested variant has not been modified since
- // the time specified in this field, an entity will not be returned from
- // the server; instead, a 304 (not modified) response will be returned
- // without any message-body..."
- //
- // This method is called from ResourceHandlerImpl.handleResourceRequest and if
- // returns false send a 304 Not Modified response.
-
- String ifModifiedSinceString = context.getExternalContext().getRequestHeaderMap().get("If-Modified-Since");
-
- if (ifModifiedSinceString == null) {
- return true;
- }
-
- Long ifModifiedSince = ResourceLoaderUtils.parseDateHeader(ifModifiedSinceString);
-
- if (ifModifiedSince == null) {
- return true;
- }
-
- Long lastModified;
- try {
- lastModified = ResourceLoaderUtils.getResourceLastModified(this.getURL());
- } catch (IOException exception) {
- lastModified = -1L;
- }
-
- if (lastModified >= 0) {
- if (this.couldResourceContainValueExpressions() &&
- lastModified < _resourceHandlerSupport.getStartupTime()) {
- lastModified = _resourceHandlerSupport.getStartupTime();
- }
-
- // If the lastModified date is lower or equal than ifModifiedSince,
- // the agent does not need to update.
- // Note the lastModified time is set at milisecond precision, but when
- // the date is parsed and sent on ifModifiedSince, the exceding miliseconds
- // are trimmed. So, we have to compare trimming this from the calculated
- // lastModified time.
- if ((lastModified - (lastModified % 1000)) <= ifModifiedSince) {
- return false;
- }
- }
-
- return true;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceLoader.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceLoader.java
deleted file mode 100644
index 8a3341a..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceLoader.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.resources;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Comparator;
-
-/**
- * Base class for resource loaders. Resource loaders can lookup resources
- * as URLs from arbitrary locations, including JAR files.
- *
- * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
- * @version $Revision: 882702 $ $Date: 2009-11-20 15:16:07 -0500 (Vie, 20 Nov 2009) $
- */
-public abstract class ResourceLoader
-{
-
- public static final String VERSION_INVALID = "INVALID";
-
- private String _prefix;
-
- public ResourceLoader(String prefix)
- {
- _prefix = prefix;
- }
-
- public abstract String getResourceVersion(String path);
-
- /**
- * Return the max available version found (if exists) or
- * return null if no version available.
- */
- public abstract String getLibraryVersion(String path);
-
- /**
- * Return the max available version found (if exists) or
- * return null if no version available.
- */
- public abstract URL getResourceURL(ResourceMeta resourceMeta);
-
- public abstract InputStream getResourceInputStream(ResourceMeta resourceMeta);
-
- public abstract ResourceMeta createResourceMeta(String prefix, String libraryName, String libraryVersion,
- String resourceName, String resourceVersion);
-
- public abstract boolean libraryExists(String libraryName);
-
- private Comparator<String> _versionComparator = null;
-
- protected Comparator<String> getVersionComparator()
- {
- if (_versionComparator == null)
- {
- _versionComparator = new VersionComparator();
- }
- return _versionComparator;
- }
-
- protected void setVersionComparator(Comparator<String> versionComparator)
- {
- _versionComparator = versionComparator;
- }
-
- public class VersionComparator implements Comparator<String>
- {
-
- public int compare(String s1, String s2)
- {
- int n1 = 0;
- int n2 = 0;
- String o1 = s1;
- String o2 = s2;
-
- boolean p1 = true;
- boolean p2 = true;
-
- while (n1 == n2 && (p1 || p2))
- {
- int i1 = o1.indexOf('_');
- int i2 = o2.indexOf('_');
- if (i1 < 0)
- {
- if (o1.length() > 0)
- {
- p1 = false;
- n1 = Integer.valueOf(o1);
- o1 = "";
- }
- else
- {
- p1 = false;
- n1 = 0;
- }
- }
- else
- {
- n1 = Integer.valueOf(o1.substring(0, i1));
- o1 = o1.substring(i1 + 1);
- }
- if (i2 < 0)
- {
- if (o2.length() > 0)
- {
- p2 = false;
- n2 = Integer.valueOf(o2);
- o2 = "";
- }
- else
- {
- p2 = false;
- n2 = 0;
- }
- }
- else
- {
- n2 = Integer.valueOf(o2.substring(0, i2));
- o2 = o2.substring(i2 + 1);
- }
- }
-
- if (n1 == n2)
- {
- return s1.length() - s2.length();
- }
- return n1 - n2;
- }
- }
-
- public String getPrefix()
- {
- return _prefix;
- }
-
- public void setPrefix(String prefix)
- {
- _prefix = prefix;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceLoaderUtils.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceLoaderUtils.java
deleted file mode 100644
index 166eb02..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceLoaderUtils.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.resources;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.JarURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-import java.util.TimeZone;
-
-public class ResourceLoaderUtils {
-
- public final static String JAVAX_FACES_LIBRARY_NAME = "javax.faces";
- public final static String JSF_JS_RESOURCE_NAME = "jsf.js";
-
- public final static String MYFACES_JS_RESOURCE_NAME = "oamSubmit.js";
- public final static String MYFACES_JS_RESOURCE_NAME_UNCOMPRESSED = "oamSubmit-uncompressed.js";
-
- public final static String MYFACES_LIBRARY_NAME = "org.apache.myfaces";
- private final static String RENDERED_MYFACES_JS = "org.apache.myfaces.RENDERED_MYFACES_JS";
-
- // TODO: In tomcat and jetty it is implemented a Flyweight pattern when converting
- // date headers. For now it is better keep this stuff simple.
- private static final String HTTP_RESPONSE_DATE_HEADER =
- "EEE, dd MMM yyyy HH:mm:ss zzz";
-
- private static final String[] HTTP_REQUEST_DATE_HEADER = {
- "EEE, dd MMM yyyy HH:mm:ss zzz", "EEEEEE, dd-MMM-yy HH:mm:ss zzz",
- "EEE MMMM d HH:mm:ss yyyy"};
-
- private static TimeZone __GMT = TimeZone.getTimeZone("GMT");
-
- public static String formatDateHeader(long value) {
- SimpleDateFormat format = new SimpleDateFormat(
- HTTP_RESPONSE_DATE_HEADER,
- Locale.US);
- format.setTimeZone(__GMT);
- return format.format(new Date(value));
- }
-
- public static Long parseDateHeader(String value) {
- Date date = null;
- for (int i = 0; (date == null) && (i < HTTP_REQUEST_DATE_HEADER.length); i++) {
- try {
- SimpleDateFormat format = new SimpleDateFormat(
- HTTP_REQUEST_DATE_HEADER[i], Locale.US);
- format.setTimeZone(__GMT);
- date = format.parse(value);
- } catch (ParseException e) {
- ;
- }
- }
- if (date == null) {
- return null;
- }
- return new Long(date.getTime());
- }
-
- //Taken from trinidad URLUtils
- public static long getResourceLastModified(URL url) throws IOException {
- if ("file".equals(url.getProtocol())) {
- String externalForm = url.toExternalForm();
- // Remove the "file:"
- File file = new File(externalForm.substring(5));
-
- return file.lastModified();
- } else {
- return getResourceLastModified(url.openConnection());
- }
- }
-
- //Taken from trinidad URLUtils
- public static long getResourceLastModified(URLConnection connection) throws IOException {
- long modified;
- if (connection instanceof JarURLConnection) {
- // The following hack is required to work-around a JDK bug.
- // getLastModified() on a JAR entry URL delegates to the actual JAR file
- // rather than the JAR entry.
- // This opens internally, and does not close, an input stream to the JAR
- // file.
- // In turn, you cannot close it by yourself, because it's internal.
- // The work-around is to get the modification date of the JAR file
- // manually,
- // and then close that connection again.
-
- URL jarFileUrl = ((JarURLConnection) connection).getJarFileURL();
- URLConnection jarFileConnection = jarFileUrl.openConnection();
-
- try {
- modified = jarFileConnection.getLastModified();
- } finally {
- try {
- jarFileConnection.getInputStream().close();
- } catch (Exception exception) {
- // Ignored
- }
- }
- } else {
- modified = connection.getLastModified();
- }
-
- return modified;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceMeta.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceMeta.java
deleted file mode 100644
index 796db45..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceMeta.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.resources;
-
-/**
- * Contains the metadata information to reference a resource
- *
- * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
- * @version $Revision: 946779 $ $Date: 2010-05-20 15:31:42 -0500 (Jue, 20 May 2010) $
- */
-public abstract class ResourceMeta
-{
-
- public abstract String getLibraryName();
-
- public abstract String getResourceName();
-
- public abstract String getLocalePrefix();
-
- public abstract String getLibraryVersion();
-
- public abstract String getResourceVersion();
-
- public abstract String getResourceIdentifier();
-
- public abstract boolean couldResourceContainValueExpressions();
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceMetaImpl.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceMetaImpl.java
deleted file mode 100644
index bc6c552..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceMetaImpl.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.resources;
-
-/**
- * Contains the metadata information to reference a resource
- *
- * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
- * @version $Revision: 700544 $ $Date: 2008-09-30 13:44:02 -0500 (Mar, 30 Sep 2008) $
- */
-public class ResourceMetaImpl extends ResourceMeta
-{
-
- private final String _prefix;
- private final String _libraryName;
- private final String _libraryVersion;
- private final String _resourceName;
- private final String _resourceVersion;
-
- public ResourceMetaImpl(String prefix, String libraryName, String libraryVersion,
- String resourceName, String resourceVersion)
- {
- _prefix = prefix;
- _libraryName = libraryName;
- _libraryVersion = libraryVersion;
- _resourceName = resourceName;
- _resourceVersion = resourceVersion;
- }
-
- public String getLibraryName()
- {
- return _libraryName;
- }
-
- public String getResourceName()
- {
- return _resourceName;
- }
-
- public String getLocalePrefix()
- {
- return _prefix;
- }
-
- public String getLibraryVersion()
- {
- return _libraryVersion;
- }
-
- public String getResourceVersion()
- {
- return _resourceVersion;
- }
-
- @Override
- public String getResourceIdentifier()
- {
- StringBuilder builder = new StringBuilder();
- boolean firstSlashAdded = false;
- if (_prefix != null && _prefix.length() > 0)
- {
- builder.append(_prefix);
- firstSlashAdded = true;
- }
- if (_libraryName != null)
- {
- if (firstSlashAdded) builder.append('/');
- builder.append(_libraryName);
- firstSlashAdded = true;
- }
- if (_libraryVersion != null)
- {
- if (firstSlashAdded) builder.append('/');
- builder.append(_libraryVersion);
- firstSlashAdded = true;
- }
- if (_resourceName != null)
- {
- if (firstSlashAdded) builder.append('/');
- builder.append(_resourceName);
- firstSlashAdded = true;
- }
- if (_resourceVersion != null)
- {
- if (firstSlashAdded) builder.append('/');
- builder.append(_resourceVersion);
- builder.append(
- _resourceName.substring(_resourceName.lastIndexOf('.')));
- firstSlashAdded = true;
- }
-
- return builder.toString();
- }
-
- @Override
- public boolean couldResourceContainValueExpressions()
- {
- return false;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceHandler.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceHandler.java
deleted file mode 100644
index e9bf112..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceHandler.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.resources;
-
-import org.apache.myfaces.extensions.scripting.api.Decorated;
-
-import javax.faces.application.Resource;
-import javax.faces.application.ResourceHandler;
-import javax.faces.context.FacesContext;
-import java.io.IOException;
-import java.net.URL;
-
-/**
- * A simple delegating resource handler
- * which is supposed to pick up resources from a
- * given location if the Weaving configuration
- * has the parameter present
- */
-public class SourceResourceHandler extends ResourceHandlerImpl implements Decorated {
-
- ResourceHandler _delegate = null;
- ResourceHandlerSupport _sourceHandlerSupport = null;
-
- public SourceResourceHandler(ResourceHandler delegate) {
- _delegate = delegate;
- }
-
- public Resource createResource(String resourceName) {
- Resource retVal = super.createResource(resourceName);
- if (retVal != null)
- return retVal;
-
- return _delegate.createResource(resourceName);
- }
-
- public Resource createResource(String resourceName, String libraryName) {
- Resource retVal = super.createResource(resourceName, libraryName);
- if (retVal != null)
- return retVal;
-
- return _delegate.createResource(resourceName, libraryName);
- }
-
- public Resource createResource(String resourceName, String libraryName, String contentType) {
- Resource retVal = super.createResource(resourceName, libraryName, contentType);
-
- if (retVal != null)
- return retVal;
-
- return _delegate.createResource(resourceName, libraryName, contentType);
- }
-
- public String getRendererTypeForResourceName(String resourceName) {
-
- String retVal = super.getRendererTypeForResourceName(resourceName);
- if (retVal != null)
- return retVal;
-
- return _delegate.getRendererTypeForResourceName(resourceName);
- }
-
- public void handleResourceRequest(FacesContext context) throws IOException {
- super.handleResourceRequest(context);
- }
-
- public boolean isResourceRequest(FacesContext context) {
- return _delegate.isResourceRequest(context);
- }
-
- public boolean libraryExists(String libraryName) {
- return _delegate.libraryExists(libraryName);
- }
-
- public ResourceHandler getDelegate() {
- return _delegate;
- }
-
- @Override
- /**
- * central override of this class it provides a new handler
- * support class which allows source pickups after the
- * JSF2 specified restful algorithms
- *
- * @return A support instance which allows also source pickups from resources additionally to the
- * default deployment and jar pickups
- */
- protected ResourceHandlerSupport getResourceHandlerSupport() {
- if (_sourceHandlerSupport == null) {
- _sourceHandlerSupport = new SourceResourceHandlerSupport();
- }
- return _sourceHandlerSupport;
- }
-
- protected ResourceMeta deriveResourceMeta(ResourceLoader resourceLoader,
- String resourceName, String libraryName) {
- String localePrefix = getLocalePrefixForLocateResource();
- String resourceVersion = null;
- String libraryVersion = null;
- ResourceMeta resourceId = null;
-
- //1. Try to locate resource in a localized path
- if (localePrefix != null) {
- if (null != libraryName) {
- String pathToLib = localePrefix + '/' + libraryName;
- libraryVersion = resourceLoader.getLibraryVersion(pathToLib);
-
- if (null != libraryVersion) {
- String pathToResource = localePrefix + '/'
- + libraryName + '/' + libraryVersion + '/'
- + resourceName;
- resourceVersion = resourceLoader
- .getResourceVersion(pathToResource);
- } else {
- String pathToResource = localePrefix + '/'
- + libraryName + '/' + resourceName;
- resourceVersion = resourceLoader
- .getResourceVersion(pathToResource);
- }
-
- if (!(resourceVersion != null && ResourceLoader.VERSION_INVALID.equals(resourceVersion))) {
- resourceId = resourceLoader.createResourceMeta(localePrefix, libraryName,
- libraryVersion, resourceName, resourceVersion);
- }
- } else {
- resourceVersion = resourceLoader
- .getResourceVersion(localePrefix + '/' + resourceName);
- if (!(resourceVersion != null && ResourceLoader.VERSION_INVALID.equals(resourceVersion))) {
- resourceId = resourceLoader.createResourceMeta(localePrefix, null, null,
- resourceName, resourceVersion);
- } else if (resourceVersion == ResourceLoader.VERSION_INVALID) {
- resourceId = resourceLoader.createResourceMeta(null, libraryName,
- null, resourceName, null);
- }
- }
-
- if (resourceId != null) {
- URL url = resourceLoader.getResourceURL(resourceId);
- if (url == null) {
- resourceId = null;
- }
- }
- }
-
- //2. Try to localize resource in a non localized path
- if (resourceId == null) {
- if (null != libraryName) {
- libraryVersion = resourceLoader.getLibraryVersion(libraryName);
-
- if (null != libraryVersion) {
- String pathToResource = (libraryName + '/' + libraryVersion
- + '/' + resourceName);
- resourceVersion = resourceLoader
- .getResourceVersion(pathToResource);
- } else {
- String pathToResource = (libraryName + '/'
- + resourceName);
- resourceVersion = resourceLoader
- .getResourceVersion(pathToResource);
- }
-
- if (!(resourceVersion != null && ResourceLoader.VERSION_INVALID.equals(resourceVersion))) {
- resourceId = resourceLoader.createResourceMeta(null, libraryName,
- libraryVersion, resourceName, resourceVersion);
- } else if (resourceVersion == ResourceLoader.VERSION_INVALID) {
- resourceId = resourceLoader.createResourceMeta(null, libraryName,
- libraryVersion, resourceName, null);
- }
- } else {
- resourceVersion = resourceLoader
- .getResourceVersion(resourceName);
-
- if (!(resourceVersion != null && ResourceLoader.VERSION_INVALID.equals(resourceVersion))) {
- resourceId = resourceLoader.createResourceMeta(null, null, null,
- resourceName, resourceVersion);
- } else if (resourceVersion == ResourceLoader.VERSION_INVALID) {
- resourceId = resourceLoader.createResourceMeta(null, null,
- null, resourceName, null);
- }
- }
-
- if (resourceId != null) {
- URL url = resourceLoader.getResourceURL(resourceId);
- if (url == null) {
- resourceId = null;
- }
- }
- }
-
- return resourceId;
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceHandlerSupport.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceHandlerSupport.java
deleted file mode 100644
index 5443d28..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceHandlerSupport.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.resources;
-
-import javax.faces.context.FacesContext;
-
-/**
- * impl specific handler support which attaches
- * the source resource loader upfront before
- * checking the other ones
- * <p/>
- * a delegate is used to limit the binding between
- * the "parent" class and the child class
- * in this case it simply makes sense to avoid any internal sideeffects
- * between getResourceLoaders and the other methods
- */
-public class SourceResourceHandlerSupport extends ResourceHandlerSupport {
-
- private ResourceLoader[] _supportResourceLoaders;
- private BaseResourceHandlerSupport _defaultSupport = new BaseResourceHandlerSupport();
-
- @Override
- /**
- * Delivers a list of resource loaders in a binding order
- * of the resource lookup algorithms
- *
- * @return a list of resource loaders with following order,
- * <ul>
- * <li>source lookup paths if present</li>
- * <li>/resources directory</li>
- * <li>META-INF/resources directory</li>
- * </ul>
- */
- public ResourceLoader[] getResourceLoaders() {
- if (_supportResourceLoaders == null) {
- //The ExternalContextResourceLoader has precedence over
- //ClassLoaderResourceLoader, so it goes first.
- _supportResourceLoaders = new ResourceLoader[]{
- new SourceResourceLoader("/resources"),
- new ExternalContextResourceLoader("/resources"),
- new ClassLoaderResourceLoader("META-INF/resources")
- };
- }
- return _supportResourceLoaders;
- }
-
- public String calculateResourceBasePath(FacesContext facesContext) {
- return _defaultSupport.calculateResourceBasePath(facesContext);
- }
-
- public boolean isExtensionMapping() {
- return _defaultSupport.isExtensionMapping();
- }
-
- public String getMapping() {
- return _defaultSupport.getMapping();
- }
-
- public long getStartupTime() {
- return _defaultSupport.getStartupTime();
- }
-
- public long getMaxTimeExpires() {
- return _defaultSupport.getMaxTimeExpires();
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceLoader.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceLoader.java
deleted file mode 100644
index 31b15e2..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceLoader.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.jsf2.resources;
-
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * internal resource loader to be used with our custom resource handler
- * the resource loader is added to the list of available loaders
- * so that the resource gets loaded properly from our source path
- * instead of the web context if present, the source paths as usual
- * are picked up by our context params.
- */
-public class SourceResourceLoader extends ExternalContextResourceLoader {
-
- public SourceResourceLoader(String prefix) {
- super(prefix);
- }
-
- @Override
- protected Set<String> getResourcePaths(String path) {
- List<String> resourceRoots = WeavingContext.getConfiguration().getResourceDirs();
- if (resourceRoots == null || resourceRoots.isEmpty()) {
- return Collections.EMPTY_SET;
- }
- Set<String> retVals = new HashSet<String>(resourceRoots.size());
- //for (String resourceRoot : resourceRoots) {
- retVals.add(getPrefix() + "/" + path);
- //}
- return retVals;
- }
-
- @Override
- public URL getResourceURL(ResourceMeta resourceMeta) {
- try {
- List<String> resourceRoots = WeavingContext.getConfiguration().getResourceDirs();
- if (resourceRoots == null || resourceRoots.isEmpty()) {
- return super.getResourceURL(resourceMeta);
- }
-
- for (String resourceRoot : resourceRoots) {
- File resourceFile = new File(resourceRoot + getPrefix() + "/" + resourceMeta.getLibraryName() + "/"+ resourceMeta.getResourceName());
- if (resourceFile.exists()) {
- return resourceFile.toURI().toURL();
- }
- }
-
- return super.getResourceURL(resourceMeta);
- }
- catch (MalformedURLException e) {
- return null;
- }
- }
-
- @Override
- public InputStream getResourceInputStream(ResourceMeta resourceMeta) {
- try {
- List<String> resourceRoots = WeavingContext.getConfiguration().getResourceDirs();
- if (resourceRoots == null || resourceRoots.isEmpty()) {
- return super.getResourceInputStream(resourceMeta);
- }
-
- for (String resourceRoot : resourceRoots) {
- File resourceFile = new File(resourceRoot + getPrefix() + "/" +resourceMeta.getLibraryName() + "/"+ resourceMeta.getResourceName());
- if (resourceFile.exists()) {
- return new FileInputStream(resourceFile);
- }
- }
-
- return super.getResourceInputStream(resourceMeta);
- }
- catch (IOException e) {
- return null;
- }
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/servlet/CustomChainLoader.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/servlet/CustomChainLoader.java
deleted file mode 100644
index e10a68b..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/servlet/CustomChainLoader.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.servlet;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.shared.util.ClassLoaderExtension;
-
-import javax.servlet.ServletContext;
-
-/**
- * a custom chainloader which adds a groovy loading
- * facility to our myfaces loading plugin system
- *
- * @author Werner Punz
- */
-@SuppressWarnings("unused")
-public class CustomChainLoader extends ClassLoaderExtension
-{
-
- /*
- * servlet context init var for additional chain loader paths which have
- * higher priority than the default ones
- */
-
- ScriptingWeaver _scriptingWeaver = null;
-
- public CustomChainLoader(ServletContext servletContext)
- {
- _scriptingWeaver = WeavingContext.getWeaver();
- }
-
- public Class forName(String name)
- {
- if (_scriptingWeaver == null || name == null)
- {
- return null;
- }
-
- if (name.endsWith(";"))
- {
- name = name.substring(1, name.length() - 1);
- }
-
- if (name.startsWith("java.")) /*the entire java namespace is reserved so no use to do a specific classloading check here*/
- return null;
- if (name.startsWith("javax.")) /*the entire java namespace is reserved so no use to do a specific classloading check here*/
- return null;
- else if (name.startsWith("com.sun")) /*internal java specific namespace*/
- return null;
- else if (name.startsWith("sun.")) /*internal java specific namespace*/
- return null;
- else if (name.startsWith("org.apache") && !name.startsWith("org.apache.myfaces"))
- {
- return null;
- } else if (name.startsWith("org.apache") && name.startsWith("org.apache.myfaces.config"))
- {
- return null;
- }
- return _scriptingWeaver.loadScriptingClassFromName(name);
- }
-
-
-
-}
\ No newline at end of file
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/startup/IntialScanAnnotationListener.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/startup/IntialScanAnnotationListener.java
deleted file mode 100644
index 4013aa4..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/startup/IntialScanAnnotationListener.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.extensions.scripting.startup;
-
-import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
-import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
-import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
-
-import javax.faces.event.SystemEventListener;
-import javax.faces.event.SystemEvent;
-import javax.faces.event.PostConstructApplicationEvent;
-import javax.faces.application.Application;
-import javax.servlet.ServletContext;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- * <p/>
- * we do the initial source scan after the entire application has started up
- * we now can reuse our jsf2 system event faclities by placing
- * a listener to the application startup
- */
-
-public class IntialScanAnnotationListener implements SystemEventListener {
- public boolean isListenerForSource(Object source) {
- return source instanceof Application;
- }
-
- public void processEvent(SystemEvent event) {
- if (!event.getClass().equals(PostConstructApplicationEvent.class)) {
- return;
- }
- //we can rely on being in the same thread as the original
- //startup context listener, so the initial weaver still is activated
- ScriptingWeaver weaver = WeavingContext.getWeaver();
-
- if (WeavingContext.isScriptingEnabled() && WeavingContext.getConfiguration().isInitialCompile()) {
- weaver.fullRecompile();
- //we now do a full source or precompiled annotation scan
- //the entire scripting subsystem should be initialized by now
- weaver.fullClassScan();
- }
- }
-}
diff --git a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/startup/SuppressExtValWarningStartupListener.java b/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/startup/SuppressExtValWarningStartupListener.java
deleted file mode 100644
index 3907ca0..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/startup/SuppressExtValWarningStartupListener.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.extensions.scripting.startup;
-
-import javax.faces.application.Application;
-import javax.faces.event.PostConstructApplicationEvent;
-import javax.faces.event.SystemEvent;
-import javax.faces.event.SystemEventListener;
-
-/**
- * A startup listener which suppresses
- * the ext-val warning (which actually is a bug in ext-val)
- * for version 2.0.3, is already reported and will be fixed in the
- * long run
- *
- * @author Werner Punz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-public class SuppressExtValWarningStartupListener implements SystemEventListener {
- public boolean isListenerForSource(Object source) {
- return source instanceof Application;
- }
-
- public void processEvent(SystemEvent event) {
- if (!event.getClass().equals(PostConstructApplicationEvent.class)) {
- return;
- }
-
- //TODO disable the EXT-VAL warning
- }
-
-}
-
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
deleted file mode 100644
index 8563472..0000000
--- a/extscript-core-root/extscript-myfaces2-extensions/src/main/resources/META-INF/faces-config.xml
+++ /dev/null
@@ -1,121 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
- version="2.0">
-
-
-
-
- <!--
- * 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.
- -->
- <!--
- <lifecycle>
- <phase-listener>org.apache.myfaces.extensions.scripting.jsf.RefreshPhaseListener</phase-listener>
-
- </lifecycle>
-
- <component>
- <component-type>org.apache.myfaces.extensions.scripting.components.CompilerComponent</component-type>
- <component-class>org.apache.myfaces.extensions.scripting.components.CompilerComponent</component-class>
- </component>
-
- <component>
- <component-type>org.apache.myfaces.extensions.scripting.components.TaintHistory</component-type>
- <component-class>org.apache.myfaces.extensions.scripting.components.TaintHistory</component-class>
- </component>
-
-
- <render-kit>
- <renderer>
- <component-family>javax.faces.Output</component-family>
- <renderer-type>org.apache.myfaces.extensions.scripting.components.CompilerComponentRenderer</renderer-type>
- <renderer-class>org.apache.myfaces.extensions.scripting.components.CompilerComponentRenderer</renderer-class>
- </renderer>
- <renderer>
- <component-family>javax.faces.Output</component-family>
- <renderer-type>org.apache.myfaces.extensions.scripting.components.TaintHistoryRenderer</renderer-type>
- <renderer-class>org.apache.myfaces.extensions.scripting.components.TaintHistoryRenderer</renderer-class>
- </renderer>
- </render-kit>
- -->
-
- <factory>
-
- <!--
- all these factories are replacements for the normal ones
- issue is we have to make a codeweaving for every bean created
- -->
-
- <application-factory>
- org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories.ScriptingApplicationFactory
- </application-factory>
-
- <faces-context-factory>
- org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories.ScriptingFacesContextFactory
- </faces-context-factory>
-
-
- <lifecycle-factory>
- org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories.ScriptingLifecycleFactory
- </lifecycle-factory>
-
- <render-kit-factory>
- org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories.ScriptingRenderkitFactory
- </render-kit-factory>
-
- <!--
- <tag-handler-delegate-factory>
- org.apache.myfaces.extensions.scripting.facelet.TagHandlerDelegateFactoryImpl
- </tag-handler-delegate-factory>
- -->
- </factory>
- <lifecycle>
- <phase-listener>org.apache.myfaces.extensions.scripting.jsf.startup.AnnotationScanPhaseListener</phase-listener>
- </lifecycle>
-
- <!--
- <application>
- <resource-handler>org.apache.myfaces.extensions.scripting.jsf.resources.SourceResourceHandler</resource-handler>
- </application>
- -->
-
- <!--
- <application>
- <system-event-listener>
- <system-event-listener-class>org.apache.myfaces.extensions.scripting.startup.IntialScanAnnotationListener
- </system-event-listener-class>
- <system-event-class>javax.faces.event.PostConstructApplicationEvent</system-event-class>
- </system-event-listener>
-
- </application>
- -->
-
- <component>
- <component-type>org.apache.myfaces.extensions.scripting.components.CompilerComponent</component-type>
- <component-class>org.apache.myfaces.extensions.scripting.components.CompilerComponent</component-class>
- </component>
-
- <component>
- <component-type>org.apache.myfaces.extensions.scripting.components.TaintHistory</component-type>
- <component-class>org.apache.myfaces.extensions.scripting.components.TaintHistory</component-class>
- </component>
-
-
-</faces-config>
\ No newline at end of file