[seam-commits] Seam SVN: r7358 - in trunk: build and 9 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon Feb 4 12:27:54 EST 2008
Author: pete.muir at jboss.org
Date: 2008-02-04 12:27:54 -0500 (Mon, 04 Feb 2008)
New Revision: 7358
Added:
trunk/build/wicket.pom.xml
trunk/src/wicket/
trunk/src/wicket/org/
trunk/src/wicket/org/jboss/
trunk/src/wicket/org/jboss/seam/
trunk/src/wicket/org/jboss/seam/wicket/
trunk/src/wicket/org/jboss/seam/wicket/BijectedAttribute.java
trunk/src/wicket/org/jboss/seam/wicket/BijectedField.java
trunk/src/wicket/org/jboss/seam/wicket/BijectedMethod.java
trunk/src/wicket/org/jboss/seam/wicket/BijectedProperty.java
trunk/src/wicket/org/jboss/seam/wicket/InjectionInterceptor.java
trunk/src/wicket/org/jboss/seam/wicket/InjectionSupport.java
trunk/src/wicket/org/jboss/seam/wicket/LoggerSupport.java
trunk/src/wicket/org/jboss/seam/wicket/MetaModel.java
trunk/src/wicket/org/jboss/seam/wicket/MetaModelUtils.java
trunk/src/wicket/org/jboss/seam/wicket/ModelValidator.java
trunk/src/wicket/org/jboss/seam/wicket/OutjectionSupport.java
trunk/src/wicket/org/jboss/seam/wicket/SeamAuthorizationStrategy.java
trunk/src/wicket/org/jboss/seam/wicket/SeamLink.java
trunk/src/wicket/org/jboss/seam/wicket/SeamSupport.java
trunk/src/wicket/org/jboss/seam/wicket/SimpleDataProvider.java
trunk/src/wicket/org/jboss/seam/wicket/WicketComponent.java
trunk/src/wicket/org/jboss/seam/wicket/WicketExceptionFilter.java
trunk/src/wicket/org/jboss/seam/wicket/WicketManager.java
trunk/src/wicket/org/jboss/seam/wicket/WicketRedirectFilter.java
trunk/src/wicket/org/jboss/seam/wicket/WicketSeamFilter.java
trunk/src/wicket/seam.properties
Removed:
trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedAttribute.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedField.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedMethod.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedProperty.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/InjectionInterceptor.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/InjectionSupport.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/LoggerSupport.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/MetaModel.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/MetaModelUtils.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/ModelValidator.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/OutjectionSupport.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamAuthorizationStrategy.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamLink.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamSupport.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/SimpleDataProvider.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketComponent.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketManager.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketRedirectFilter.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketSeamFilter.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/components/
Modified:
trunk/build.xml
trunk/build/ci.build.xml
trunk/build/classpath.tmpl
trunk/build/common.build.xml
trunk/build/root.pom.xml
trunk/examples/build.xml
trunk/examples/wicket/build.xml
Log:
Move wicket support to a module
Modified: trunk/build/ci.build.xml
===================================================================
--- trunk/build/ci.build.xml 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/build/ci.build.xml 2008-02-04 17:27:54 UTC (rev 7358)
@@ -21,6 +21,7 @@
<deploySnapshot pom="${core.pom}" jar="${lib.dir}/jboss-seam.jar" srcjar="${lib.dir}/src/jboss-seam-sources.jar" />
<deploySnapshot pom="${debug.pom}" jar="${lib.dir}/jboss-seam-debug.jar" srcjar="${lib.dir}/src/jboss-seam-debug-sources.jar"/>
<deploySnapshot pom="${jbas5.pom}" jar="${lib.dir}/interop/jboss-seam-jbas5.jar" srcjar="${lib.dir}/interop/src/jboss-seam-jbas5-sources.jar"/>
+ <deploySnapshot pom="${wicket.pom}" jar="${lib.dir}/jboss-seam-wicket.jar" srcjar="${lib.dir}/src/jboss-seam-wicket-sources.jar"/>
<deploySnapshot pom="${gen.pom}" jar="${lib.dir}/jboss-seam-gen.jar" srcjar="${lib.dir}/src/jboss-seam-gen-sources.jar"/>
<deploySnapshot pom="${ioc.pom}" jar="${lib.dir}/jboss-seam-ioc.jar" srcjar="${lib.dir}/src/jboss-seam-ioc-sources.jar"/>
<deploySnapshot pom="${mail.pom}" jar="${lib.dir}/jboss-seam-mail.jar" srcjar="${lib.dir}/src/jboss-seam-mail-sources.jar"/>
Modified: trunk/build/classpath.tmpl
===================================================================
(Binary files differ)
Modified: trunk/build/common.build.xml
===================================================================
--- trunk/build/common.build.xml 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/build/common.build.xml 2008-02-04 17:27:54 UTC (rev 7358)
@@ -94,6 +94,7 @@
<install pom="${parent.pom}" />
<pomfile name="core.pom" value="${build.dir}/core.pom.xml" />
<pomfile name="debug.pom" value="${build.dir}/debug.pom.xml" />
+ <pomfile name="wicket.pom" value="${build.dir}/wicket.pom.xml" />
<pomfile name="jbas5.pom" value="${build.dir}/jbas5.pom.xml" />
<pomfile name="gen.pom" value="${build.dir}/gen.pom.xml" />
<pomfile name="ioc.pom" value="${build.dir}/ioc.pom.xml" />
@@ -108,6 +109,7 @@
<target name="copyseamdependencies" if="mavenized.property" unless="copyseamdependenciesdone" depends="initcopy, initpoms">
<copyDependencies id="core" pom="${core.pom}" todir="${lib.dir}" scope="runtime" />
<copyDependencies id="debug" pom="${debug.pom}" todir="${lib.dir}" scope="runtime" />
+ <copyDependencies id="wicket" pom="${wicket.pom}" todir="${lib.dir}" scope="runtime" />
<copyDependencies id="jbas5" pom="${jbas5.pom}" todir="${lib.dir}" scope="runtime" />
<copyDependencies id="ioc" pom="${ioc.pom}" todir="${lib.dir}" scope="runtime" />
<copyDependencies id="mail" pom="${mail.pom}" todir="${lib.dir}" scope="runtime" />
@@ -116,6 +118,7 @@
<copyDependencies id="ui" pom="${ui.pom}" todir="${lib.dir}" scope="runtime" />
<copyDependencies id="core" pom="${core.pom}" todir="${lib.dir}" scope="compile" />
<copyDependencies id="debug" pom="${debug.pom}" todir="${lib.dir}" scope="compile" />
+ <copyDependencies id="wicket" pom="${wicket.pom}" todir="${lib.dir}" scope="compile" />
<copyDependencies id="jbas5" pom="${jbas5.pom}" todir="${lib.dir}" scope="compile" />
<copyDependencies id="ioc" pom="${ioc.pom}" todir="${lib.dir}" scope="compile" />
<copyDependencies id="mail" pom="${mail.pom}" todir="${lib.dir}" scope="compile" />
@@ -129,6 +132,7 @@
<artifact:dependencies filesetId="seam.fileset" versionsId="seam.versions">
<dependency groupId="org.jboss.seam" artifactId="jboss-seam" version="${complete.version}" />
<dependency groupId="org.jboss.seam" artifactId="jboss-seam-debug" version="${complete.version}" />
+ <dependency groupId="org.jboss.seam" artifactId="jboss-seam-wicket" version="${complete.version}" />
<dependency groupId="org.jboss.seam" artifactId="jboss-seam-ioc" version="${complete.version}" />
<dependency groupId="org.jboss.seam" artifactId="jboss-seam-mail" version="${complete.version}" />
<dependency groupId="org.jboss.seam" artifactId="jboss-seam-pdf" version="${complete.version}" />
@@ -199,6 +203,7 @@
<propertyref name="mail.pom" />
<propertyref name="debug.pom" />
<propertyref name="jbas5.pom" />
+ <propertyref name="wicket.pom" />
<propertyref name="testng.jvmargs"/>
</propertyset>
</ant>
@@ -231,6 +236,7 @@
<propertyref name="ioc.pom" />
<propertyref name="mail.pom" />
<propertyref name="debug.pom" />
+ <propertyref name="wicket.pom" />
<propertyref name="jbas5.pom" />
<propertyref name="testng.jvmargs"/>
</propertyset>
@@ -265,6 +271,7 @@
<propertyref name="mail.pom" />
<propertyref name="debug.pom" />
<propertyref name="jbas5.pom" />
+ <propertyref name="wicket.pom" />
<propertyref name="testng.jvmargs"/>
</propertyset>
</ant>
@@ -324,6 +331,8 @@
<outputDependencyReport module="mail" />
<outputDependencyReport module="pdf" />
<outputDependencyReport module="ioc" />
+ <outputDependencyReport module="wicket" />
+ <outputDependencyReport module="jbas5" />
<echo>Dependency Report written to ${seam.dir}/dependency-report.txt</echo>
</target>
Modified: trunk/build/root.pom.xml
===================================================================
--- trunk/build/root.pom.xml 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/build/root.pom.xml 2008-02-04 17:27:54 UTC (rev 7358)
@@ -34,11 +34,17 @@
<name>JBoss Snapshot Repository</name>
<url>http://snapshots.jboss.org/maven2</url>
</repository>
+ <repository>
+ <id>wicketstuff.org</id>
+ <name>Wicket</name>
+ <url>http://wicketstuff.org/maven/repository</url>
+ </repository>
</repositories>
<!-- Externalize some version numbers here -->
<properties>
<version.richfaces>3.1.4.GA</version.richfaces>
+ <version.wicket>1.3.0-SNAPSHOT</version.wicket>
</properties>
<dependencyManagement>
@@ -845,7 +851,75 @@
</exclusion>
</exclusions>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket</artifactId>
+ <version>${version.wicket}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>cglib</groupId>
+ <artifactId>cglib-nodep</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>asm</groupId>
+ <artifactId>asm</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-ioc</artifactId>
+ <version>${version.wicket}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>cglib</groupId>
+ <artifactId>cglib-nodep</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>asm</groupId>
+ <artifactId>asm</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-extensions</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <groupId>cglib</groupId>
+ <artifactId>cglib-nodep</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>asm</groupId>
+ <artifactId>asm</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-datetime</artifactId>
+ <version>${version.wicket}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+
</dependencies>
</dependencyManagement>
Added: trunk/build/wicket.pom.xml
===================================================================
--- trunk/build/wicket.pom.xml (rev 0)
+++ trunk/build/wicket.pom.xml 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.jboss.seam</groupId>
+ <artifactId>jboss-seam-wicket</artifactId>
+ <parent>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>parent</artifactId>
+ <version>@seam.version@</version>
+ </parent>
+
+ <!-- See parent pom for notes on how to declare dependencies -->
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>jboss-seam</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-ioc</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-datetime</artifactId>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-extensions</artifactId>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.ejb</groupId>
+ <artifactId>ejb-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
Property changes on: trunk/build/wicket.pom.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/build.xml 2008-02-04 17:27:54 UTC (rev 7358)
@@ -18,6 +18,7 @@
<property name="classes.ioc.dir" value="${classes.dir}/iocclasses" />
<property name="classes.mail.dir" value="${classes.dir}/mailclasses" />
<property name="classes.debug.dir" value="${classes.dir}/debugclasses" />
+ <property name="classes.wicket.dir" value="${classes.dir}/wicketclasses" />
<property name="classes.jbas5.dir" value="${classes.dir}/jbas5classes" />
<property name="classes.remoting.dir" value="${classes.dir}/remotingclasses" />
<property name="classes.gen.dir" value="${classes.dir}/genclasses" />
@@ -33,6 +34,7 @@
<property name="src.ioc.dir" value="src/ioc" />
<property name="src.mail.dir" value="src/mail" />
<property name="src.debug.dir" value="src/debug" />
+ <property name="src.wicket.dir" value="src/wicket" />
<property name="src.jbas5.dir" value="src/jbas5" />
<property name="src.gen.dir" value="src/gen" />
<property name="src.remoting.dir" value="src/remoting" />
@@ -64,6 +66,7 @@
<property name="dist.src.ioc.dir" value="${dist.dir}/src/ioc" />
<property name="dist.src.mail.dir" value="${dist.dir}/src/mail" />
<property name="dist.src.debug.dir" value="${dist.dir}/src/debug" />
+ <property name="dist.src.wicket.dir" value="${dist.dir}/src/wicket" />
<property name="dist.src.jbas5.dir" value="${dist.dir}/src/jbas5" />
<property name="dist.src.gen.dir" value="${dist.dir}/src/gen" />
<property name="dist.src.remoting.dir" value="${dist.dir}/src/remoting" />
@@ -153,7 +156,7 @@
<delete dir="${lib.dir}" quiet="${quietclean}" />
</target>
- <target name="build" depends="jarcore,jarpdf,jarioc,jarmail,jarremoting,jardebug,jargen,jarui,jarjbas5" description="Build all distribution .jar files" />
+ <target name="build" depends="jarcore,jarpdf,jarioc,jarmail,jarremoting,jardebug,jargen,jarui,jarjbas5,jarwicket" description="Build all distribution .jar files" />
<target name="select-compiler">
<available classname="org.eclipse.jdt.core.JDTCompilerAdapter" property="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter" />
@@ -248,6 +251,20 @@
<archive classesdir="${classes.debug.dir}" module="jboss-seam-debug" pom="${debug.pom}" srcdir="${src.debug.dir}"/>
</target>
+ <!-- ########################### DEBUG TARGETS ###########################-->
+
+ <target name="initwicket" depends="init, jarcore">
+ <init classesdir="${classes.wicket.dir}" srcdir="${src.wicket.dir}" modulename="wicket" pom="${wicket.pom}" />
+ </target>
+
+ <target name="compilewicket" depends="initwicket, select-compiler">
+ <compile classesdir="${classes.wicket.dir}" srcdir="${src.wicket.dir}" classpath="compile.wicket.path" />
+ </target>
+
+ <target name="jarwicket" depends="compilewicket" description="Build the distribution .jar file for the Wicket Integration package">
+ <archive classesdir="${classes.wicket.dir}" module="jboss-seam-wicket" pom="${wicket.pom}" srcdir="${src.wicket.dir}"/>
+ </target>
+
<!-- ########################### JBAS5 TARGETS ###########################-->
<target name="initjbas5" depends="init, jarcore">
@@ -339,6 +356,7 @@
<cleanexample name="icefaces" />
<cleanexample name="seambay" />
<cleanexample name="nestedbooking" />
+ <cleanexample name="wicket" />
</target>
<target name="undeployall" description="Undeploy all examples">
@@ -369,6 +387,7 @@
<undeployexample name="icefaces" />
<undeployexample name="seambay" />
<undeployexample name="nestedbooking" />
+ <undeployexample name="wicket" />
</target>
<target name="deploypresentation" depends="build" description="Deploy the examples used in Seam presentations">
@@ -430,6 +449,7 @@
<copysource destdir="${dist.src.remoting.dir}" srcdir="${src.remoting.dir}" />
<copysource destdir="${dist.src.mail.dir}" srcdir="${src.mail.dir}" />
<copysource destdir="${dist.src.debug.dir}" srcdir="${src.debug.dir}" />
+ <copysource destdir="${dist.src.wicket.dir}" srcdir="${src.wicket.dir}" />
<copysource destdir="${dist.src.jbas5.dir}" srcdir="${src.jbas5.dir}" />
<copysource destdir="${dist.src.gen.dir}" srcdir="${src.gen.dir}" />
<copysource destdir="${dist.src.test.dir}" srcdir="${src.test.dir}" />
@@ -506,6 +526,7 @@
<!--<include name="portal/**/*" />-->
<include name="drools/**/*" />
<include name="nestedbooking/**/*" />
+ <include name="wicket/**/*" />
<include name="remoting/chatroom/**/*" />
<include name="remoting/helloworld/**/*" />
<include name="remoting/progressbar/**/*" />
@@ -893,6 +914,7 @@
<propertyref name="ioc.pom" />
<propertyref name="mail.pom" />
<propertyref name="debug.pom" />
+ <propertyref name="wicket.pom" />
<propertyref name="jbas5.pom" />
<propertyref name="testng.jvmargs"/>
</propertyset>
@@ -903,6 +925,7 @@
<target name="downloadDependenciesSources" description="Download source jars for all dependencies" depends="init">
<dependenciesWithSources id="core" scope="compile" pom="${core.pom}" />
<dependenciesWithSources id="debug" scope="compile" pom="${debug.pom}" />
+ <dependenciesWithSources id="wicket" scope="compile" pom="${wicket.pom}" />
<dependenciesWithSources id="jbas5" scope="compile" pom="${jbas5.pom}" />
<dependenciesWithSources id="gen" scope="compile" pom="${gen.pom}" />
<dependenciesWithSources id="ioc" scope="compile" pom="${ioc.pom}" />
@@ -931,6 +954,7 @@
classpathref="seam-gen.path"/>
<dependencies id="core" scope="compile" pom="${core.pom}" />
<dependencies id="debug" scope="compile" pom="${debug.pom}" />
+ <dependencies id="wicket" scope="compile" pom="${wicket.pom}" />
<dependencies id="jbas5" scope="compile" pom="${jbas5.pom}" />
<dependencies id="gen" scope="compile" pom="${gen.pom}" />
<dependencies id="ioc" scope="compile" pom="${ioc.pom}" />
@@ -948,6 +972,7 @@
<path refid="compile.remoting.path" />
<path refid="compile.ui.path" />
<path refid="compile.jbas5.path" />
+ <path refid="compile.wicket.path" />
</eclipseClasspath>
</target>
Modified: trunk/examples/build.xml
===================================================================
--- trunk/examples/build.xml 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/build.xml 2008-02-04 17:27:54 UTC (rev 7358)
@@ -173,6 +173,15 @@
<fileset id="seam.remoting.jar" dir="${lib.dir}">
<include name="jboss-seam-remoting.jar" if="seam.remoting.lib" />
</fileset>
+
+ <!-- Seam Wicket integration, with required dependencies -->
+ <fileset id="seam.wicket.jar" dir="${lib.dir}">
+ <include name="jboss-seam-wicket.jar" if="seam.wicket.lib" />
+ <include name="wicket.jar" if="seam.wicket.lib" />
+ <include name="wicket-ioc.jar" if="seam.wicket.lib" />
+ <include name="slf4j-api.jar" if="seam.wicket.lib" />
+ <include name="slf4j-log4j12.jar" if="seam.wicket.lib" />
+ </fileset>
<!-- jboss-el -->
<fileset id="jboss-el.jar" dir="${lib.dir}">
@@ -291,6 +300,11 @@
<fileset id="jboss-embedded-api.jar" dir="${lib.dir}">
<include name="jboss-embedded-api.jar" if="jboss-embedded-api.lib" />
</fileset>
+
+ <fileset id="wicket-extensions.jar" dir="${lib.dir}">
+ <include name="wicket-extensions.jar" if="wicket-extensions.lib" />
+ <include name="wicket-datetime.jar" if="wicket-extensions.lib" />
+ </fileset>
<!-- ############################ MELDWARE ############################ -->
@@ -416,7 +430,12 @@
<path id="build.classpath">
<fileset dir="${lib.dir}">
<include name="*.jar" />
- <exclude name="jboss-seam-*.jar" />
+ <include name="jboss-seam-wicket.jar" />
+ <exclude name="jboss-seam-debug.jar" />
+ <exclude name="jboss-seam-ui.jar" />
+ <exclude name="jboss-seam-remoting.jar" />
+ <exclude name="jboss-seam-mail.jar" />
+ <exclude name="jboss-seam-pdf.jar" />
</fileset>
<path refid="build.classpath.extras" />
</path>
@@ -564,6 +583,8 @@
<fileset refid="spring.jar" />
<fileset refid="jcaptcha.jar" />
<fileset refid="antlr.jar" />
+ <fileset refid="wicket-extensions.jar" />
+ <fileset refid="seam.wicket.jar" />
<mapper type="flatten" />
</copy>
</target>
@@ -752,6 +773,8 @@
<fileset refid="search.jar" />
<fileset refid="richfaces-api.jar" />
<fileset refid="groovy.jar" />
+ <fileset refid="wicket-extensions.jar" />
+ <fileset refid="seam.wicket.jar" />
<mapper type="flatten" />
</copy>
<copy todir="${war.dir}">
Modified: trunk/examples/wicket/build.xml
===================================================================
--- trunk/examples/wicket/build.xml 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/build.xml 2008-02-04 17:27:54 UTC (rev 7358)
@@ -10,26 +10,15 @@
<property name="src.web.dir" value="src/web" />
<!-- Libraries to include -->
+
+ <property name="seam.wicket.lib" value="yes" />
+ <property name="wicket-extensions.lib" value="yes" />
<!-- Datasource -->
<property name="example.ds" value="jboss-seam-wicket-ds.xml"/>
-
- <property name="example.tmp.lib.dir" value="${basedir}/lib" />
-
- <property name="clean.extra" value="${example.tmp.lib.dir}"/>
-
-
-
+
<import file="../build.xml"/>
-
- <path id="build.classpath.extras">
- <fileset dir="${example.tmp.lib.dir}" />
- </path>
- <fileset id="ear.lib.extras" dir="${example.tmp.lib.dir}">
- <include name="*.jar" />
- </fileset>
-
<target name="compile.web" depends="compile">
<mkdir dir="${war.dir}/WEB-INF/classes" />
<javac destdir="${war.dir}/WEB-INF/classes" debug="${javac.debug}" deprecation="${javac.deprecation}" nowarn="on" >
@@ -48,33 +37,5 @@
<!-- Examples build hook point for running targets before creating the war -->
<target name="init.war" depends="compile.web" />
-
- <target name="copyextradependencies">
- <artifact:remoteRepository id="wicketstuff.org" url="http://wicketstuff.org/maven/repository"/>
-
- <artifact:dependencies filesetId="wicket.fileset" versionsId="wicket.versions" sourcesfilesetid="wicket.sources">
- <dependency groupId="org.apache.wicket" artifactId="wicket" version="1.3.0-SNAPSHOT">
- <exclusion groupId="cglib" artifactid="cglib-nodep" />
- <exclusion groupId="asm" artifactId="asm" />
- </dependency>
- <dependency groupId="org.apache.wicket" artifactId="wicket-ioc" version="1.3.0-SNAPSHOT">
- <exclusion groupId="cglib" artifactid="cglib-nodep" />
- <exclusion groupId="asm" artifactId="asm" />
- </dependency>
- <dependency groupId="org.slf4j" artifactId="slf4j-log4j12" version="1.0.1" />
- <dependency groupId="org.apache.wicket" artifactId="wicket-extensions" version="1.3.0-SNAPSHOT">
- <exclusion groupId="cglib" artifactid="cglib-nodep" />
- <exclusion groupId="asm" artifactId="asm" />
- <exclusion groupId="commons-collections" artifactId="commons-collections" />
- </dependency>
- <dependency groupId="org.apache.wicket" artifactId="wicket-datetime" version="1.3.0-SNAPSHOT">
- </dependency>
- <remoterepository refid="wicketstuff.org"/>
- </artifact:dependencies>
- <copy todir="${example.tmp.lib.dir}">
- <fileset refid="wicket.fileset" />
- <mapper classpathref="maven-ant-tasks.classpath" classname="org.apache.maven.artifact.ant.VersionMapper" from="${wicket.versions}" to="flatten" />
- </copy>
- </target>
</project>
Deleted: trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedAttribute.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedAttribute.java 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedAttribute.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -1,14 +0,0 @@
-package org.jboss.seam.wicket;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-
-public interface BijectedAttribute<T extends Annotation>
-{
- public String getName();
- public T getAnnotation();
- public Class getType();
- public void set(Object bean, Object value);
- public Object get(Object bean);
- public MetaModel getMetaModel();
-}
Deleted: trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedField.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedField.java 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedField.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -1,54 +0,0 @@
-package org.jboss.seam.wicket;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-
-public class BijectedField<T extends Annotation> implements BijectedAttribute<T>
- {
- private String name;
- private Field field;
- private T annotation;
- private MetaModel metaModel;
-
- public BijectedField(String name, Field field, T annotation, MetaModel metaModel)
- {
- this.name = name;
- this.field = field;
- this.annotation = annotation;
- this.metaModel = metaModel;
- }
- public String getName()
- {
- return name;
- }
- public Field getField()
- {
- return field;
- }
- public T getAnnotation()
- {
- return annotation;
- }
- public Class getType()
- {
- return field.getType();
- }
- public void set(Object bean, Object value)
- {
- metaModel.setFieldValue(bean, field, name, value);
- }
- public Object get(Object bean)
- {
- return metaModel.getFieldValue(bean, field, name);
- }
- @Override
- public String toString()
- {
- return "BijectedField(" + name + ')';
- }
-
- public MetaModel getMetaModel()
- {
- return metaModel;
- }
- }
\ No newline at end of file
Deleted: trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedMethod.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedMethod.java 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedMethod.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -1,53 +0,0 @@
-package org.jboss.seam.wicket;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-
-public class BijectedMethod<T extends Annotation> implements BijectedAttribute<T>
- {
- private String name;
- private Method method;
- private T annotation;
- private MetaModel metaModel;
-
- public BijectedMethod(String name, Method method, T annotation, MetaModel metaModel)
- {
- this.name = name;
- this.method = method;
- this.annotation = annotation;
- }
- public String getName()
- {
- return name;
- }
- public Method getMethod()
- {
- return method;
- }
- public T getAnnotation()
- {
- return annotation;
- }
- public void set(Object bean, Object value)
- {
- metaModel.setPropertyValue(bean, method, name, value);
- }
- public Object get(Object bean)
- {
- return metaModel.getPropertyValue(bean, method, name);
- }
- public Class getType()
- {
- return method.getParameterTypes()[0];
- }
- @Override
- public String toString()
- {
- return "BijectedMethod(" + name + ')';
- }
-
- public MetaModel getMetaModel()
- {
- return metaModel;
- }
- }
\ No newline at end of file
Deleted: trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedProperty.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedProperty.java 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedProperty.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -1,66 +0,0 @@
-package org.jboss.seam.wicket;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-
-import org.jboss.seam.util.Reflections;
-
-public class BijectedProperty<T extends Annotation> implements BijectedAttribute<T>
- {
-
- private BijectedMethod<T> getter;
- private BijectedMethod<T> setter;
- private MetaModel metaModel;
-
- public BijectedProperty(String name, Method getter, Method setter, T annotation, MetaModel metaModel)
- {
- this.getter = new BijectedMethod(name, getter, annotation, metaModel);
- this.setter = new BijectedMethod(name, setter, annotation, metaModel);
- }
-
- public BijectedProperty(String name, Method getter, T annotation, MetaModel metaModel)
- {
- this.getter = new BijectedMethod(name, getter, annotation, metaModel);
- try
- {
- Method setterMethod = Reflections.getSetterMethod(getter.getDeclaringClass(), name);
- this.setter = new BijectedMethod(name, setterMethod, annotation, metaModel);
- }
- catch (IllegalArgumentException e) {}
- }
-
- public Object get(Object bean)
- {
- return getter.get(bean);
- }
-
- public T getAnnotation()
- {
- return getter.getAnnotation();
- }
-
- public String getName()
- {
- return getter.getName();
- }
-
- public Class getType()
- {
- return getter.getType();
- }
-
- public void set(Object bean, Object value)
- {
- if (setter == null)
- {
- throw new IllegalArgumentException("Component must have a setter for " + metaModel.getName());
- }
- setter.set(bean, value);
- }
-
- public MetaModel getMetaModel()
- {
- return metaModel;
- }
-
- }
\ No newline at end of file
Deleted: trunk/examples/wicket/src/web/org/jboss/seam/wicket/InjectionInterceptor.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/InjectionInterceptor.java 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/InjectionInterceptor.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -1,112 +0,0 @@
-package org.jboss.seam.wicket;
-
-import static org.jboss.seam.ScopeType.STATELESS;
-import static org.jboss.seam.ScopeType.UNSPECIFIED;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.Namespace;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.core.Expressions;
-import org.jboss.seam.core.Init;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
-import org.jboss.seam.util.Reflections;
-
-import javassist.util.proxy.MethodHandler;
-
-public class InjectionInterceptor implements MethodHandler, Serializable
-{
-
- private String name;
- private In annotation;
- private String metaModelName;
- private transient MetaModel metaModel;
-
- public InjectionInterceptor(BijectedAttribute<In> in)
- {
- this.name = in.getName();
- this.annotation = in.getAnnotation();
- this.metaModelName = in.getMetaModel().getMetaModelName();
- }
-
- private static LogProvider log = Logging.getLogProvider(InjectionInterceptor.class);
-
- public Object invoke(final Object proxy, final Method method, final Method proceed, final Object[] params) throws Throwable
- {
- return Reflections.invoke(method, getValueToInject(proxy), params);
- }
-
- private Object getValueToInject(Object bean)
- {
- if ( name.startsWith("#") )
- {
- if ( log.isDebugEnabled() )
- {
- log.trace("trying to inject with EL expression: " + name);
- }
- return Expressions.instance().createValueExpression(name).getValue();
- }
- else if ( annotation.scope()==UNSPECIFIED )
- {
- if ( log.isDebugEnabled() )
- {
- log.trace("trying to inject with hierarchical context search: " + name);
- }
- return getInstanceInAllNamespaces(name, annotation.create());
- }
- else
- {
- if ( annotation.create() )
- {
- throw new IllegalArgumentException(
- "cannot combine create=true with explicit scope on @In: " +
- getMetaModel().getAttributeMessage(name)
- );
- }
- if ( annotation.scope()==STATELESS )
- {
- throw new IllegalArgumentException(
- "cannot specify explicit scope=STATELESS on @In: " +
- getMetaModel().getAttributeMessage(name)
- );
- }
-
-
- log.trace("trying to inject from specified context: " + name);
-
- if ( annotation.scope().isContextActive() )
- {
- return annotation.scope().getContext().get(name);
- }
- }
- return null;
- }
-
- private Object getInstanceInAllNamespaces(String name, boolean create)
- {
- Object result;
- result = Component.getInstance(name, create);
- if (result==null)
- {
- for ( Namespace namespace: Init.instance().getGlobalImports() )
- {
- result = namespace.getComponentInstance(name, create);
- if (result!=null) break;
- }
- }
- return result;
- }
-
- private MetaModel getMetaModel()
- {
- if (metaModel == null)
- {
- metaModel = MetaModel.forName(metaModelName);
- }
- return metaModel;
- }
-
-}
Deleted: trunk/examples/wicket/src/web/org/jboss/seam/wicket/InjectionSupport.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/InjectionSupport.java 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/InjectionSupport.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -1,91 +0,0 @@
-package org.jboss.seam.wicket;
-
-import static org.jboss.seam.wicket.MetaModelUtils.createProxyFactory;
-import static org.jboss.seam.wicket.MetaModelUtils.toName;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javassist.util.proxy.ProxyObject;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.Namespace;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.core.Init;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
-
-
-public class InjectionSupport
-{
-
- // TODO Ouch
- private static final Map<Class, Class<ProxyObject>> proxyFactories = new HashMap<Class, Class<ProxyObject>>();
-
- private LogProvider log = Logging.getLogProvider(InjectionSupport.class);
-
- private List<BijectedAttribute<In>> inAttributes = new ArrayList<BijectedAttribute<In>>();
-
- private MetaModel metaModel;
-
- public InjectionSupport(MetaModel metaModel)
- {
- this.metaModel = metaModel;
- }
-
- public void add(Method method)
- {
- if ( method.isAnnotationPresent(In.class) )
- {
- In in = method.getAnnotation(In.class);
- String name = toName( in.value(), method );
- inAttributes.add( new BijectedMethod(name, method, in, metaModel) );
- }
- }
-
- public void add(Field field)
- {
- if ( field.isAnnotationPresent(In.class) )
- {
- In in = field.getAnnotation(In.class);
- String name = toName( in.value(), field );
- inAttributes.add( new BijectedField(name, field, in, metaModel) );
- }
- }
-
- public void inject(Object instance) throws Exception
- {
- for ( BijectedAttribute<In> in : inAttributes )
- {
- // Currently need a proxy here as Wicket has no native support for interceptors
- // TODO Replace this with a Seam ClientSide interceptor. Needs JBSEAM-699
- in.set( instance, wrap( instance, in ) );
- }
- }
-
- private static Object wrap(Object bean, BijectedAttribute<In> in) throws Exception
- {
- ProxyObject proxy = getProxyFactory(in.getType()).newInstance();
- proxy.setHandler(new InjectionInterceptor(in));
- return proxy;
- }
-
- private static Class<ProxyObject> getProxyFactory(Class type)
- {
- if (proxyFactories.containsKey(type))
- {
- return proxyFactories.get(type);
- }
- else
- {
- Class<ProxyObject> factory = createProxyFactory( type );
- proxyFactories.put(type, factory);
- return factory;
- }
- }
-
-}
Deleted: trunk/examples/wicket/src/web/org/jboss/seam/wicket/LoggerSupport.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/LoggerSupport.java 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/LoggerSupport.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -1,58 +0,0 @@
-package org.jboss.seam.wicket;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.seam.util.Reflections;
-
-// TODO Reimplement as Seam ClientSide Interceptor
-public class LoggerSupport
-{
-
- private List<Field> logFields = new ArrayList<Field>();
- private List<org.jboss.seam.log.Log> logInstances = new ArrayList<org.jboss.seam.log.Log>();
-
- private MetaModel metaModel;
-
- public LoggerSupport(MetaModel metaModel)
- {
- this.metaModel = metaModel;
- }
-
- public void add(Field field)
- {
- if ( field.isAnnotationPresent(org.jboss.seam.annotations.Logger.class) )
- {
- String category = field.getAnnotation(org.jboss.seam.annotations.Logger.class).value();
- org.jboss.seam.log.Log logInstance;
- if ( "".equals( category ) )
- {
- logInstance = org.jboss.seam.log.Logging.getLog(metaModel.getBeanClass());
- }
- else
- {
- logInstance = org.jboss.seam.log.Logging.getLog(category);
- }
- if ( Modifier.isStatic( field.getModifiers() ) )
- {
- Reflections.setAndWrap(field, null, logInstance);
- }
- else
- {
- logFields.add(field);
- logInstances.add(logInstance);
- }
- }
- }
-
- public void inject(Object instance) throws Exception
- {
- for (int i=0; i<logFields.size(); i++)
- {
- metaModel.setFieldValue( instance, logFields.get(i), "log", logInstances.get(i) );
- }
- }
-
-}
Deleted: trunk/examples/wicket/src/web/org/jboss/seam/wicket/MetaModel.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/MetaModel.java 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/MetaModel.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -1,144 +0,0 @@
-package org.jboss.seam.wicket;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import org.jboss.seam.Model;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.util.Reflections;
-
-public abstract class MetaModel extends Model
-{
-
- private InjectionSupport injectionSupport;
- private OutjectionSupport outjectionSupport;
- private LoggerSupport loggerSupport;
-
- public MetaModel(Class<?> beanClass)
- {
- super(beanClass);
- injectionSupport = new InjectionSupport(this);
- outjectionSupport = new OutjectionSupport(this);
- loggerSupport = new LoggerSupport(this);
- scan();
- }
-
- public void initialize()
- {
- scan();
- }
-
- public void inject(Object instance) throws Exception
- {
- injectionSupport.inject(instance);
- loggerSupport.inject(instance);
- }
-
- public void outject(Object instance)
- {
- outjectionSupport.outject(instance);
- }
-
- private void scan()
- {
- Class clazz = getBeanClass();
- for ( ; clazz!=Object.class; clazz = clazz.getSuperclass() )
- {
- for ( Method method: clazz.getDeclaredMethods() )
- {
- scanMethod(method);
- }
-
- for ( Field field: clazz.getDeclaredFields() )
- {
- scanField(field);
- }
- }
- }
-
- private void scanField(Field field)
- {
- if ( !field.isAccessible() )
- {
- field.setAccessible(true);
- }
- injectionSupport.add(field);
- loggerSupport.add(field);
- }
-
- private void scanMethod(Method method)
- {
- injectionSupport.add(method);
- }
-
- protected void setFieldValue(Object bean, Field field, String name, Object value)
- {
- try
- {
- Reflections.set(field, bean, value);
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException("could not set field value: " + getAttributeMessage(name), e);
- }
- }
-
- protected Object getFieldValue(Object bean, Field field, String name)
- {
- try {
- return Reflections.get(field, bean);
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException("could not get field value: " + getAttributeMessage(name), e);
- }
- }
-
- protected String getAttributeMessage(String attributeName)
- {
- return getName() + '.' + attributeName;
- }
-
- protected String getName()
- {
- return getBeanClass().getName();
- }
-
- protected abstract String getMetaModelName();
-
- protected void setPropertyValue(Object bean, Method method, String name, Object value)
- {
- try
- {
- Reflections.invoke(method, bean, value );
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException("could not set property value: " + getAttributeMessage(name), e);
- }
- }
-
- public Object getPropertyValue(Object bean, Method method, String name)
- {
- try {
- return Reflections.invoke(method, bean);
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException("could not get property value: " + getAttributeMessage(name), e);
- }
- }
-
- public static MetaModel forName(String name)
- {
- if (Contexts.isApplicationContextActive())
- {
- return (MetaModel) Contexts.getApplicationContext().get(name);
- }
- else
- {
- throw new IllegalStateException("Application context is not active");
- }
- }
-
-}
Deleted: trunk/examples/wicket/src/web/org/jboss/seam/wicket/MetaModelUtils.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/MetaModelUtils.java 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/MetaModelUtils.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -1,48 +0,0 @@
-package org.jboss.seam.wicket;
-
-import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import javassist.util.proxy.ProxyObject;
-
-import org.jboss.seam.util.ProxyFactory;
-
-public class MetaModelUtils
-{
-
- public static String toName(String name, Method method)
- {
- //TODO: does not handle "isFoo"
- if (name==null || name.length() == 0)
- {
- name = method.getName().substring(3, 4).toLowerCase()
- + method.getName().substring(4);
- }
- return name;
- }
-
- public static String toName(String name, Field field)
- {
- if (name==null || name.length() == 0)
- {
- name = field.getName();
- }
- return name;
- }
-
- public static Class<ProxyObject> createProxyFactory(final Class beanClass)
- {
- ProxyFactory factory = new ProxyFactory();
- if (beanClass.isInterface())
- {
- factory.setInterfaces(new Class[] {beanClass, Serializable.class});
- }
- else
- {
- factory.setSuperclass( beanClass );
- }
- return factory.createClass();
- }
-
-}
Deleted: trunk/examples/wicket/src/web/org/jboss/seam/wicket/ModelValidator.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/ModelValidator.java 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/ModelValidator.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -1,51 +0,0 @@
-package org.jboss.seam.wicket;
-
-import org.apache.wicket.model.PropertyModel;
-import org.apache.wicket.validation.IValidatable;
-import org.apache.wicket.validation.IValidationError;
-import org.apache.wicket.validation.IValidator;
-import org.apache.wicket.validation.ValidationError;
-import org.hibernate.validator.ClassValidator;
-import org.hibernate.validator.InvalidValue;
-import org.jboss.seam.core.Validators;
-
-
-/**
- *
- * An implementation of Hibernate Model Validation for Wicket
- *
- * @author Pete Muir
- *
- */
-public class ModelValidator implements IValidator
-{
-
- private Class clazz;
- private String property;
-
- public ModelValidator(Class clazz, String property)
- {
- this.clazz = clazz;
- this.property = property;
- }
-
- public ModelValidator(PropertyModel propertyModel)
- {
- this.clazz = propertyModel.getTarget().getClass();
- this.property = propertyModel.getPropertyExpression();
- }
-
- public void validate(IValidatable validatable)
- {
- System.out.println("model validator " + property + " / " + clazz);
- ClassValidator classValidator = Validators.instance().getValidator(clazz);
- InvalidValue[] invalidValues = classValidator.getPotentialInvalidValues(property, validatable.getValue());
- if (invalidValues.length > 0)
- {
- String message = invalidValues[0].getMessage();
- IValidationError validationError = new ValidationError().setMessage(message);
- validatable.error(validationError);
- }
- }
-
-}
Deleted: trunk/examples/wicket/src/web/org/jboss/seam/wicket/OutjectionSupport.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/OutjectionSupport.java 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/OutjectionSupport.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -1,94 +0,0 @@
-package org.jboss.seam.wicket;
-
-import static org.jboss.seam.ScopeType.STATELESS;
-import static org.jboss.seam.ScopeType.UNSPECIFIED;
-import static org.jboss.seam.wicket.MetaModelUtils.toName;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.seam.RequiredException;
-import org.jboss.seam.annotations.Out;
-
-
-public class OutjectionSupport
-{
-
- private List<BijectedAttribute<Out>> outAttributes = new ArrayList<BijectedAttribute<Out>>();
-
- private MetaModel metaModel;
-
- public OutjectionSupport(MetaModel metaModel)
- {
- this.metaModel = metaModel;
- }
-
- public void add(Method method)
- {
- Out out = method.getAnnotation(Out.class);
- String name = toName( out.value(), method );
- outAttributes.add( new BijectedMethod(name, method, out, metaModel) );
- }
-
- public void add(Field field)
- {
- if ( field.isAnnotationPresent(Out.class) )
- {
- Out out = field.getAnnotation(Out.class);
- String name = toName( out.value(), field );
- outAttributes.add(new BijectedField(name, field, out, metaModel) );
- }
- }
-
- public void outject(Object instance)
- {
- for ( BijectedAttribute<Out> att: outAttributes )
- {
- outjectAttribute( att.getAnnotation(), att.getName(), instance, att.get(instance) );
- }
- }
-
- private void outjectAttribute(Out out, String name, Object bean, Object value)
- {
-
- if (value==null && out.required())
- {
- throw new RequiredException(
- "@Out attribute requires non-null value: " +
- metaModel.getAttributeMessage(name)
- );
- }
- else
- {
- if ( out.scope()==UNSPECIFIED )
- {
- throw new IllegalArgumentException(
- "Must specify a scope to outject to: " +
- metaModel.getAttributeMessage(name)
- );
- }
- else if ( out.scope()==STATELESS )
- {
- throw new IllegalArgumentException(
- "cannot specify explicit scope=STATELESS on @Out: " +
- metaModel.getAttributeMessage(name)
- );
- }
-
- if ( out.scope().isContextActive() )
- {
- if (value==null)
- {
- out.scope().getContext().remove(name);
- }
- else
- {
- out.scope().getContext().set(name, value);
- }
- }
- }
- }
-
-}
Deleted: trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamAuthorizationStrategy.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamAuthorizationStrategy.java 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamAuthorizationStrategy.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -1,72 +0,0 @@
-package org.jboss.seam.wicket;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.Page;
-import org.apache.wicket.RestartResponseAtInterceptPageException;
-import org.apache.wicket.authorization.Action;
-import org.apache.wicket.authorization.IAuthorizationStrategy;
-import org.jboss.seam.annotations.security.Restrict;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
-import org.jboss.seam.security.Identity;
-import org.jboss.seam.security.NotLoggedInException;
-import org.jboss.seam.util.Strings;
-
-public class SeamAuthorizationStrategy implements IAuthorizationStrategy
-{
-
- private LogProvider log = Logging.getLogProvider(SeamAuthorizationStrategy.class);
- private Class loginPage;
-
- public SeamAuthorizationStrategy()
- {
- this(null);
- }
-
- public SeamAuthorizationStrategy(final Class loginPage)
- {
- this.loginPage = loginPage;
- }
-
- // TODO Use permission schemes for this?
- public boolean isActionAuthorized(Component component, Action action)
- {
- return isInstantiationAuthorized(component.getClass());
- }
-
- public boolean isInstantiationAuthorized(Class componentClass)
- {
- Restrict restrict = (Restrict) componentClass.getAnnotation(Restrict.class);
- if ( restrict != null && Identity.isSecurityEnabled() )
- {
- String expr = !Strings.isEmpty( restrict.value() ) ? restrict.value() : "#{identity.loggedIn}";
- try
- {
- Identity.instance().checkRestriction(expr);
- }
- catch (NotLoggedInException e)
- {
- log.error("Unauthorized access to " + componentClass.getName() + ", user not logged in", e);
- return handleException(componentClass);
- }
- catch (org.jboss.seam.security.AuthorizationException e)
- {
- log.error("Unauthorized access to " + componentClass.getName(), e);
- return handleException(componentClass);
- }
- }
- return true;
- }
-
- private boolean handleException(Class componentClass)
- {
- if (Page.class.isAssignableFrom(componentClass))
- {
- // Redirect to page to let the user sign in
- throw new RestartResponseAtInterceptPageException(loginPage);
- }
- return false;
- }
-
-
-}
Deleted: trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamLink.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamLink.java 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamLink.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -1,39 +0,0 @@
-package org.jboss.seam.wicket;
-
-import org.apache.wicket.markup.html.link.ILinkListener;
-import org.apache.wicket.markup.html.link.Link;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.util.value.ValueMap;
-import org.jboss.seam.core.Conversation;
-import org.jboss.seam.core.Manager;
-
-public abstract class SeamLink extends Link
-{
-
- public SeamLink(String id)
- {
- super(id);
- }
-
- public SeamLink(String id, IModel model)
- {
- super(id, model);
- }
-
- @Override
- protected CharSequence getURL()
- {
- return getRequestCycle().urlFor(this, ILinkListener.INTERFACE, getParameterMap());
- }
-
- private ValueMap getParameterMap()
- {
- ValueMap valueMap = new ValueMap();
- if (Conversation.instance().isLongRunning())
- {
- valueMap.add(Manager.instance().getConversationIdParameter(), Conversation.instance().getId());
- }
- return valueMap;
- }
-
-}
Deleted: trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamSupport.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamSupport.java 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamSupport.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -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.jboss.seam.wicket;
-
-import org.apache.wicket.Application;
-import org.apache.wicket.Component;
-import org.apache.wicket.application.IComponentInstantiationListener;
-
-/**
- * Main support class for letting Wicket work with Seam annotations. Active
- * support by calling {@link #activate(Application) the activate method}
- * preferably from your {@link Application#init() application's init method}.
- *
- * @author eelcohillenius
- * @author Pete Muir
- */
-// TODO handle outjection etc. Might need onAfterRender and may
-// onBeforeRender for that, in which case this class can implement the
-// appropriate interfaces and register itself as a listener for them.
-// TODO handle method level sometime. For starters, see if there is any example/
-// test case/ whatever in Seam first that shows off that kind of usage
-public class SeamSupport implements IComponentInstantiationListener {
-
- /**
- * Activate support for Seam annotations on components for the provided
- * application.
- *
- * @param application
- * The application to active support for
- */
- public static void activate(Application application) {
- SeamSupport listener = new SeamSupport();
- application.addComponentInstantiationListener(listener);
- }
-
- /**
- * @see org.apache.wicket.application.IComponentInstantiationListener#onInstantiation(org.apache.wicket.Component)
- */
- public void onInstantiation(Component component)
- {
- WicketComponent wicketComponent = WicketComponent.forClass(component.getClass());
- try
- {
- wicketComponent.inject(component);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-}
Deleted: trunk/examples/wicket/src/web/org/jboss/seam/wicket/SimpleDataProvider.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/SimpleDataProvider.java 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/SimpleDataProvider.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -1,22 +0,0 @@
-package org.jboss.seam.wicket;
-
-import java.io.Serializable;
-
-import org.apache.wicket.markup.repeater.data.IDataProvider;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-
-public abstract class SimpleDataProvider implements IDataProvider
-{
-
- public IModel model(Object object)
- {
- return new Model((Serializable) object);
- }
-
- public void detach()
- {
- // No - op
- }
-
-}
Deleted: trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketComponent.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketComponent.java 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketComponent.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -1,47 +0,0 @@
-package org.jboss.seam.wicket;
-
-import org.jboss.seam.contexts.Contexts;
-
-public class WicketComponent extends MetaModel
-{
-
- public WicketComponent(Class<?> beanClass)
- {
- super(beanClass);
- }
-
- @Override
- protected String getMetaModelName()
- {
- return getComponentName(getBeanClass());
- }
-
- protected static String getComponentName(Class clazz)
- {
- return clazz.getName() + ".wicketComponent";
- }
-
- public static WicketComponent forClass(Class clazz)
- {
- if (Contexts.isApplicationContextActive())
- {
- String metaModelName = getComponentName(clazz);
- instantiate(metaModelName, clazz);
- return (WicketComponent) forName(metaModelName);
- }
- else
- {
- throw new IllegalStateException("Application context is not active");
- }
- }
-
- private static void instantiate(String componentName, Class clazz)
- {
- if (!Contexts.getApplicationContext().isSet(componentName))
- {
- WicketComponent component = new WicketComponent(clazz);
- Contexts.getApplicationContext().set(componentName, component);
- }
- }
-
-}
Deleted: trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketManager.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketManager.java 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketManager.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -1,48 +0,0 @@
-package org.jboss.seam.wicket;
-
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.core.Manager;
-
- at Scope(ScopeType.EVENT)
- at Name("org.jboss.seam.core.manager")
- at Install(precedence=100, classDependencies="org.apache.wicket.Application")
- at BypassInterceptors
-public class WicketManager extends Manager
-{
-
- private boolean controllingRedirect;
-
- public String appendConversationIdFromRedirectFilter(String url, String viewId)
- {
- boolean appendConversationId = !controllingRedirect;
- if (appendConversationId)
- {
- beforeRedirect(viewId);
- url = encodeConversationId(url, viewId);
- }
- return url;
- }
-
- /**
- * Temporarily promote a temporary conversation to
- * a long running conversation for the duration of
- * a browser redirect. After the redirect, the
- * conversation will be demoted back to a temporary
- * conversation. Handle any changes to the conversation
- * id, due to propagation via natural id.
- */
- public void beforeRedirect(String viewId)
- {
- // TODO - do something here!
- }
-
- public static WicketManager instance()
- {
- return (WicketManager) Manager.instance();
- }
-}
Deleted: trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketRedirectFilter.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketRedirectFilter.java 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketRedirectFilter.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -1,43 +0,0 @@
-package org.jboss.seam.wicket;
-
-import static org.jboss.seam.ScopeType.APPLICATION;
-
-import java.io.IOException;
-
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.annotations.web.Filter;
-import org.jboss.seam.web.AbstractFilter;
-
-/**
- *
- * @author Kill the redirect filter
- */
- at Scope(APPLICATION)
- at Name("org.jboss.seam.web.redirectFilter")
- at Install(precedence = 100, classDependencies="org.apache.wicket.Application")
- at BypassInterceptors
- at Filter(within="org.jboss.seam.web.ajax4jsfFilter")
-public class WicketRedirectFilter extends AbstractFilter
-{
-
-
- @Override
- public boolean isDisabled()
- {
- return true;
- }
-
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
- {
-
-
- }
-}
Deleted: trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketSeamFilter.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketSeamFilter.java 2008-02-04 15:06:38 UTC (rev 7357)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketSeamFilter.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -1,163 +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.jboss.seam.wicket;
-
-import static org.jboss.seam.ScopeType.APPLICATION;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
-import java.io.IOException;
-import java.util.Set;
-
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.wicket.Application;
-import org.apache.wicket.protocol.http.WebApplication;
-import org.apache.wicket.protocol.http.WicketFilter;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.annotations.web.Filter;
-import org.jboss.seam.contexts.Context;
-import org.jboss.seam.contexts.ServletLifecycle;
-import org.jboss.seam.core.ConversationPropagation;
-import org.jboss.seam.core.Manager;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
-import org.jboss.seam.servlet.ContextualHttpServletRequest;
-import org.jboss.seam.servlet.ServletRequestSessionMap;
-import org.jboss.seam.web.AbstractFilter;
-import org.jboss.seam.web.ServletContexts;
-
-/**
- * Seam component that delegates requests to the {@link WicketFilter} and sets
- * up and pulls down Seam {@link Context}s for the request.
- * <p>
- * Users do not have to install this filter, but instead just install
- * {@link WicketFilter} like they would normally do. This Seam component
- * automatically attaches to it.
- * </p>
- * <p>
- * The filter automatically picks up the {@link WebApplication} when there is
- * only one active for the web application this filter is configured for. If
- * there are multiple Wicket applications active in the web application, you'll
- * have to explicitly configure which one to use by providing filter init
- * parameter 'applicationName', which corresponds to the filter name of the
- * Wicket filter for the application you want to use this filter with.
- * </p>
- *
- * @author eelcohillenius
- */
- at Scope(APPLICATION)
- at Name("org.apache.wicket.seam.WicketSeamFilter")
- at Install(classDependencies = { "org.apache.wicket.protocol.http.WebApplication" }, precedence = BUILT_IN)
- at BypassInterceptors
- at Filter()
-public class WicketSeamFilter extends AbstractFilter {
-
- private static final class WicketSeamFilterConfigurationException extends
- IllegalStateException {
- public WicketSeamFilterConfigurationException(String msg) {
- super(msg);
- }
- }
-
- private static final String APPLICATION_NONE = "<none>";
-
- private static LogProvider log = Logging.getLogProvider(WicketSeamFilter.class);
-
- private String applicationName = null;
-
- private WicketFilter delegate = null;
-
- /**
- * Construct.
- */
- public WicketSeamFilter() {
- }
-
- @SuppressWarnings("unchecked")
- public void doFilter(final ServletRequest servletRequest,
- final ServletResponse servletResponse, final FilterChain filterChain)
- throws IOException, ServletException {
-
- // Check for the Wicket filter (which might be initialized after this
- // filter, hence the lazy loading). Synchronization is not important.
- if (delegate == null && !APPLICATION_NONE.equals(applicationName)) {
-
- if (applicationName == null) {
- Set<String> applicationKeys = Application.getApplicationKeys();
- if (applicationKeys.size() > 1) {
- throw new WicketSeamFilterConfigurationException(
- "If you run this filter in the context of multiple Wicket "
- + "application instances (/ filters) you have to provide filer "
- + "init parameter 'applicationName' which should correspond to "
- + "the filter name you want to use this filter with.");
- } else if (applicationKeys.size() == 0) {
- // no Wicket apps configured... set to special name
- applicationName = APPLICATION_NONE;
- } else {
- applicationName = applicationKeys.iterator().next();
- }
- }
- Application application = (!APPLICATION_NONE
- .equals(applicationName)) ? Application
- .get(applicationName) : null;
- if (application != null && !(application instanceof WebApplication)) {
- log
- .warn("This filter can only be used with Wicket WebApplications. Currently, "
- + "it is configured to work with an application of type "
- + application.getClass().getName());
- applicationName = APPLICATION_NONE;
- filterChain.doFilter(servletRequest, servletResponse);
- return;
- }
-
- WebApplication webApplication = (WebApplication) application;
- if (webApplication == null) {
- log
- .warn("ignoring request: no Wicket web application instance found");
- applicationName = APPLICATION_NONE;
- filterChain.doFilter(servletRequest, servletResponse);
- return;
- }
-
- delegate = webApplication.getWicketFilter();
- }
-
- new ContextualHttpServletRequest((HttpServletRequest) servletRequest)
- {
- @Override
- public void process() throws Exception
- {
- delegate.doFilter(servletRequest, servletResponse, filterChain);
- }
-
- }.run();
- }
-
- @Override
- public void init(FilterConfig filterConfig) throws ServletException {
- super.init(filterConfig);
- this.applicationName = filterConfig.getInitParameter("applicationName");
- }
-}
Copied: trunk/src/wicket/org/jboss/seam/wicket/BijectedAttribute.java (from rev 7355, trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedAttribute.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/BijectedAttribute.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/BijectedAttribute.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,14 @@
+package org.jboss.seam.wicket;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+
+public interface BijectedAttribute<T extends Annotation>
+{
+ public String getName();
+ public T getAnnotation();
+ public Class getType();
+ public void set(Object bean, Object value);
+ public Object get(Object bean);
+ public MetaModel getMetaModel();
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/BijectedField.java (from rev 7355, trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedField.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/BijectedField.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/BijectedField.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,54 @@
+package org.jboss.seam.wicket;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+
+public class BijectedField<T extends Annotation> implements BijectedAttribute<T>
+ {
+ private String name;
+ private Field field;
+ private T annotation;
+ private MetaModel metaModel;
+
+ public BijectedField(String name, Field field, T annotation, MetaModel metaModel)
+ {
+ this.name = name;
+ this.field = field;
+ this.annotation = annotation;
+ this.metaModel = metaModel;
+ }
+ public String getName()
+ {
+ return name;
+ }
+ public Field getField()
+ {
+ return field;
+ }
+ public T getAnnotation()
+ {
+ return annotation;
+ }
+ public Class getType()
+ {
+ return field.getType();
+ }
+ public void set(Object bean, Object value)
+ {
+ metaModel.setFieldValue(bean, field, name, value);
+ }
+ public Object get(Object bean)
+ {
+ return metaModel.getFieldValue(bean, field, name);
+ }
+ @Override
+ public String toString()
+ {
+ return "BijectedField(" + name + ')';
+ }
+
+ public MetaModel getMetaModel()
+ {
+ return metaModel;
+ }
+ }
\ No newline at end of file
Copied: trunk/src/wicket/org/jboss/seam/wicket/BijectedMethod.java (from rev 7355, trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedMethod.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/BijectedMethod.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/BijectedMethod.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,53 @@
+package org.jboss.seam.wicket;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+public class BijectedMethod<T extends Annotation> implements BijectedAttribute<T>
+ {
+ private String name;
+ private Method method;
+ private T annotation;
+ private MetaModel metaModel;
+
+ public BijectedMethod(String name, Method method, T annotation, MetaModel metaModel)
+ {
+ this.name = name;
+ this.method = method;
+ this.annotation = annotation;
+ }
+ public String getName()
+ {
+ return name;
+ }
+ public Method getMethod()
+ {
+ return method;
+ }
+ public T getAnnotation()
+ {
+ return annotation;
+ }
+ public void set(Object bean, Object value)
+ {
+ metaModel.setPropertyValue(bean, method, name, value);
+ }
+ public Object get(Object bean)
+ {
+ return metaModel.getPropertyValue(bean, method, name);
+ }
+ public Class getType()
+ {
+ return method.getParameterTypes()[0];
+ }
+ @Override
+ public String toString()
+ {
+ return "BijectedMethod(" + name + ')';
+ }
+
+ public MetaModel getMetaModel()
+ {
+ return metaModel;
+ }
+ }
\ No newline at end of file
Copied: trunk/src/wicket/org/jboss/seam/wicket/BijectedProperty.java (from rev 7355, trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedProperty.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/BijectedProperty.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/BijectedProperty.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,66 @@
+package org.jboss.seam.wicket;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+import org.jboss.seam.util.Reflections;
+
+public class BijectedProperty<T extends Annotation> implements BijectedAttribute<T>
+ {
+
+ private BijectedMethod<T> getter;
+ private BijectedMethod<T> setter;
+ private MetaModel metaModel;
+
+ public BijectedProperty(String name, Method getter, Method setter, T annotation, MetaModel metaModel)
+ {
+ this.getter = new BijectedMethod(name, getter, annotation, metaModel);
+ this.setter = new BijectedMethod(name, setter, annotation, metaModel);
+ }
+
+ public BijectedProperty(String name, Method getter, T annotation, MetaModel metaModel)
+ {
+ this.getter = new BijectedMethod(name, getter, annotation, metaModel);
+ try
+ {
+ Method setterMethod = Reflections.getSetterMethod(getter.getDeclaringClass(), name);
+ this.setter = new BijectedMethod(name, setterMethod, annotation, metaModel);
+ }
+ catch (IllegalArgumentException e) {}
+ }
+
+ public Object get(Object bean)
+ {
+ return getter.get(bean);
+ }
+
+ public T getAnnotation()
+ {
+ return getter.getAnnotation();
+ }
+
+ public String getName()
+ {
+ return getter.getName();
+ }
+
+ public Class getType()
+ {
+ return getter.getType();
+ }
+
+ public void set(Object bean, Object value)
+ {
+ if (setter == null)
+ {
+ throw new IllegalArgumentException("Component must have a setter for " + metaModel.getName());
+ }
+ setter.set(bean, value);
+ }
+
+ public MetaModel getMetaModel()
+ {
+ return metaModel;
+ }
+
+ }
\ No newline at end of file
Copied: trunk/src/wicket/org/jboss/seam/wicket/InjectionInterceptor.java (from rev 7355, trunk/examples/wicket/src/web/org/jboss/seam/wicket/InjectionInterceptor.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/InjectionInterceptor.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/InjectionInterceptor.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,112 @@
+package org.jboss.seam.wicket;
+
+import static org.jboss.seam.ScopeType.STATELESS;
+import static org.jboss.seam.ScopeType.UNSPECIFIED;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+
+import org.jboss.seam.Component;
+import org.jboss.seam.Namespace;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.core.Expressions;
+import org.jboss.seam.core.Init;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+import org.jboss.seam.util.Reflections;
+
+import javassist.util.proxy.MethodHandler;
+
+public class InjectionInterceptor implements MethodHandler, Serializable
+{
+
+ private String name;
+ private In annotation;
+ private String metaModelName;
+ private transient MetaModel metaModel;
+
+ public InjectionInterceptor(BijectedAttribute<In> in)
+ {
+ this.name = in.getName();
+ this.annotation = in.getAnnotation();
+ this.metaModelName = in.getMetaModel().getMetaModelName();
+ }
+
+ private static LogProvider log = Logging.getLogProvider(InjectionInterceptor.class);
+
+ public Object invoke(final Object proxy, final Method method, final Method proceed, final Object[] params) throws Throwable
+ {
+ return Reflections.invoke(method, getValueToInject(proxy), params);
+ }
+
+ private Object getValueToInject(Object bean)
+ {
+ if ( name.startsWith("#") )
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.trace("trying to inject with EL expression: " + name);
+ }
+ return Expressions.instance().createValueExpression(name).getValue();
+ }
+ else if ( annotation.scope()==UNSPECIFIED )
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.trace("trying to inject with hierarchical context search: " + name);
+ }
+ return getInstanceInAllNamespaces(name, annotation.create());
+ }
+ else
+ {
+ if ( annotation.create() )
+ {
+ throw new IllegalArgumentException(
+ "cannot combine create=true with explicit scope on @In: " +
+ getMetaModel().getAttributeMessage(name)
+ );
+ }
+ if ( annotation.scope()==STATELESS )
+ {
+ throw new IllegalArgumentException(
+ "cannot specify explicit scope=STATELESS on @In: " +
+ getMetaModel().getAttributeMessage(name)
+ );
+ }
+
+
+ log.trace("trying to inject from specified context: " + name);
+
+ if ( annotation.scope().isContextActive() )
+ {
+ return annotation.scope().getContext().get(name);
+ }
+ }
+ return null;
+ }
+
+ private Object getInstanceInAllNamespaces(String name, boolean create)
+ {
+ Object result;
+ result = Component.getInstance(name, create);
+ if (result==null)
+ {
+ for ( Namespace namespace: Init.instance().getGlobalImports() )
+ {
+ result = namespace.getComponentInstance(name, create);
+ if (result!=null) break;
+ }
+ }
+ return result;
+ }
+
+ private MetaModel getMetaModel()
+ {
+ if (metaModel == null)
+ {
+ metaModel = MetaModel.forName(metaModelName);
+ }
+ return metaModel;
+ }
+
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/InjectionSupport.java (from rev 7355, trunk/examples/wicket/src/web/org/jboss/seam/wicket/InjectionSupport.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/InjectionSupport.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/InjectionSupport.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,91 @@
+package org.jboss.seam.wicket;
+
+import static org.jboss.seam.wicket.MetaModelUtils.createProxyFactory;
+import static org.jboss.seam.wicket.MetaModelUtils.toName;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javassist.util.proxy.ProxyObject;
+
+import org.jboss.seam.Component;
+import org.jboss.seam.Namespace;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.core.Init;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+
+
+public class InjectionSupport
+{
+
+ // TODO Ouch
+ private static final Map<Class, Class<ProxyObject>> proxyFactories = new HashMap<Class, Class<ProxyObject>>();
+
+ private LogProvider log = Logging.getLogProvider(InjectionSupport.class);
+
+ private List<BijectedAttribute<In>> inAttributes = new ArrayList<BijectedAttribute<In>>();
+
+ private MetaModel metaModel;
+
+ public InjectionSupport(MetaModel metaModel)
+ {
+ this.metaModel = metaModel;
+ }
+
+ public void add(Method method)
+ {
+ if ( method.isAnnotationPresent(In.class) )
+ {
+ In in = method.getAnnotation(In.class);
+ String name = toName( in.value(), method );
+ inAttributes.add( new BijectedMethod(name, method, in, metaModel) );
+ }
+ }
+
+ public void add(Field field)
+ {
+ if ( field.isAnnotationPresent(In.class) )
+ {
+ In in = field.getAnnotation(In.class);
+ String name = toName( in.value(), field );
+ inAttributes.add( new BijectedField(name, field, in, metaModel) );
+ }
+ }
+
+ public void inject(Object instance) throws Exception
+ {
+ for ( BijectedAttribute<In> in : inAttributes )
+ {
+ // Currently need a proxy here as Wicket has no native support for interceptors
+ // TODO Replace this with a Seam ClientSide interceptor. Needs JBSEAM-699
+ in.set( instance, wrap( instance, in ) );
+ }
+ }
+
+ private static Object wrap(Object bean, BijectedAttribute<In> in) throws Exception
+ {
+ ProxyObject proxy = getProxyFactory(in.getType()).newInstance();
+ proxy.setHandler(new InjectionInterceptor(in));
+ return proxy;
+ }
+
+ private static Class<ProxyObject> getProxyFactory(Class type)
+ {
+ if (proxyFactories.containsKey(type))
+ {
+ return proxyFactories.get(type);
+ }
+ else
+ {
+ Class<ProxyObject> factory = createProxyFactory( type );
+ proxyFactories.put(type, factory);
+ return factory;
+ }
+ }
+
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/LoggerSupport.java (from rev 7355, trunk/examples/wicket/src/web/org/jboss/seam/wicket/LoggerSupport.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/LoggerSupport.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/LoggerSupport.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,58 @@
+package org.jboss.seam.wicket;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.seam.util.Reflections;
+
+// TODO Reimplement as Seam ClientSide Interceptor
+public class LoggerSupport
+{
+
+ private List<Field> logFields = new ArrayList<Field>();
+ private List<org.jboss.seam.log.Log> logInstances = new ArrayList<org.jboss.seam.log.Log>();
+
+ private MetaModel metaModel;
+
+ public LoggerSupport(MetaModel metaModel)
+ {
+ this.metaModel = metaModel;
+ }
+
+ public void add(Field field)
+ {
+ if ( field.isAnnotationPresent(org.jboss.seam.annotations.Logger.class) )
+ {
+ String category = field.getAnnotation(org.jboss.seam.annotations.Logger.class).value();
+ org.jboss.seam.log.Log logInstance;
+ if ( "".equals( category ) )
+ {
+ logInstance = org.jboss.seam.log.Logging.getLog(metaModel.getBeanClass());
+ }
+ else
+ {
+ logInstance = org.jboss.seam.log.Logging.getLog(category);
+ }
+ if ( Modifier.isStatic( field.getModifiers() ) )
+ {
+ Reflections.setAndWrap(field, null, logInstance);
+ }
+ else
+ {
+ logFields.add(field);
+ logInstances.add(logInstance);
+ }
+ }
+ }
+
+ public void inject(Object instance) throws Exception
+ {
+ for (int i=0; i<logFields.size(); i++)
+ {
+ metaModel.setFieldValue( instance, logFields.get(i), "log", logInstances.get(i) );
+ }
+ }
+
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/MetaModel.java (from rev 7355, trunk/examples/wicket/src/web/org/jboss/seam/wicket/MetaModel.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/MetaModel.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/MetaModel.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,144 @@
+package org.jboss.seam.wicket;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.jboss.seam.Model;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.util.Reflections;
+
+public abstract class MetaModel extends Model
+{
+
+ private InjectionSupport injectionSupport;
+ private OutjectionSupport outjectionSupport;
+ private LoggerSupport loggerSupport;
+
+ public MetaModel(Class<?> beanClass)
+ {
+ super(beanClass);
+ injectionSupport = new InjectionSupport(this);
+ outjectionSupport = new OutjectionSupport(this);
+ loggerSupport = new LoggerSupport(this);
+ scan();
+ }
+
+ public void initialize()
+ {
+ scan();
+ }
+
+ public void inject(Object instance) throws Exception
+ {
+ injectionSupport.inject(instance);
+ loggerSupport.inject(instance);
+ }
+
+ public void outject(Object instance)
+ {
+ outjectionSupport.outject(instance);
+ }
+
+ private void scan()
+ {
+ Class clazz = getBeanClass();
+ for ( ; clazz!=Object.class; clazz = clazz.getSuperclass() )
+ {
+ for ( Method method: clazz.getDeclaredMethods() )
+ {
+ scanMethod(method);
+ }
+
+ for ( Field field: clazz.getDeclaredFields() )
+ {
+ scanField(field);
+ }
+ }
+ }
+
+ private void scanField(Field field)
+ {
+ if ( !field.isAccessible() )
+ {
+ field.setAccessible(true);
+ }
+ injectionSupport.add(field);
+ loggerSupport.add(field);
+ }
+
+ private void scanMethod(Method method)
+ {
+ injectionSupport.add(method);
+ }
+
+ protected void setFieldValue(Object bean, Field field, String name, Object value)
+ {
+ try
+ {
+ Reflections.set(field, bean, value);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("could not set field value: " + getAttributeMessage(name), e);
+ }
+ }
+
+ protected Object getFieldValue(Object bean, Field field, String name)
+ {
+ try {
+ return Reflections.get(field, bean);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("could not get field value: " + getAttributeMessage(name), e);
+ }
+ }
+
+ protected String getAttributeMessage(String attributeName)
+ {
+ return getName() + '.' + attributeName;
+ }
+
+ protected String getName()
+ {
+ return getBeanClass().getName();
+ }
+
+ protected abstract String getMetaModelName();
+
+ protected void setPropertyValue(Object bean, Method method, String name, Object value)
+ {
+ try
+ {
+ Reflections.invoke(method, bean, value );
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("could not set property value: " + getAttributeMessage(name), e);
+ }
+ }
+
+ public Object getPropertyValue(Object bean, Method method, String name)
+ {
+ try {
+ return Reflections.invoke(method, bean);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("could not get property value: " + getAttributeMessage(name), e);
+ }
+ }
+
+ public static MetaModel forName(String name)
+ {
+ if (Contexts.isApplicationContextActive())
+ {
+ return (MetaModel) Contexts.getApplicationContext().get(name);
+ }
+ else
+ {
+ throw new IllegalStateException("Application context is not active");
+ }
+ }
+
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/MetaModelUtils.java (from rev 7355, trunk/examples/wicket/src/web/org/jboss/seam/wicket/MetaModelUtils.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/MetaModelUtils.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/MetaModelUtils.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,48 @@
+package org.jboss.seam.wicket;
+
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javassist.util.proxy.ProxyObject;
+
+import org.jboss.seam.util.ProxyFactory;
+
+public class MetaModelUtils
+{
+
+ public static String toName(String name, Method method)
+ {
+ //TODO: does not handle "isFoo"
+ if (name==null || name.length() == 0)
+ {
+ name = method.getName().substring(3, 4).toLowerCase()
+ + method.getName().substring(4);
+ }
+ return name;
+ }
+
+ public static String toName(String name, Field field)
+ {
+ if (name==null || name.length() == 0)
+ {
+ name = field.getName();
+ }
+ return name;
+ }
+
+ public static Class<ProxyObject> createProxyFactory(final Class beanClass)
+ {
+ ProxyFactory factory = new ProxyFactory();
+ if (beanClass.isInterface())
+ {
+ factory.setInterfaces(new Class[] {beanClass, Serializable.class});
+ }
+ else
+ {
+ factory.setSuperclass( beanClass );
+ }
+ return factory.createClass();
+ }
+
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/ModelValidator.java (from rev 7355, trunk/examples/wicket/src/web/org/jboss/seam/wicket/ModelValidator.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ModelValidator.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/ModelValidator.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,51 @@
+package org.jboss.seam.wicket;
+
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.validation.IValidatable;
+import org.apache.wicket.validation.IValidationError;
+import org.apache.wicket.validation.IValidator;
+import org.apache.wicket.validation.ValidationError;
+import org.hibernate.validator.ClassValidator;
+import org.hibernate.validator.InvalidValue;
+import org.jboss.seam.core.Validators;
+
+
+/**
+ *
+ * An implementation of Hibernate Model Validation for Wicket
+ *
+ * @author Pete Muir
+ *
+ */
+public class ModelValidator implements IValidator
+{
+
+ private Class clazz;
+ private String property;
+
+ public ModelValidator(Class clazz, String property)
+ {
+ this.clazz = clazz;
+ this.property = property;
+ }
+
+ public ModelValidator(PropertyModel propertyModel)
+ {
+ this.clazz = propertyModel.getTarget().getClass();
+ this.property = propertyModel.getPropertyExpression();
+ }
+
+ public void validate(IValidatable validatable)
+ {
+ System.out.println("model validator " + property + " / " + clazz);
+ ClassValidator classValidator = Validators.instance().getValidator(clazz);
+ InvalidValue[] invalidValues = classValidator.getPotentialInvalidValues(property, validatable.getValue());
+ if (invalidValues.length > 0)
+ {
+ String message = invalidValues[0].getMessage();
+ IValidationError validationError = new ValidationError().setMessage(message);
+ validatable.error(validationError);
+ }
+ }
+
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/OutjectionSupport.java (from rev 7355, trunk/examples/wicket/src/web/org/jboss/seam/wicket/OutjectionSupport.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/OutjectionSupport.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/OutjectionSupport.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,94 @@
+package org.jboss.seam.wicket;
+
+import static org.jboss.seam.ScopeType.STATELESS;
+import static org.jboss.seam.ScopeType.UNSPECIFIED;
+import static org.jboss.seam.wicket.MetaModelUtils.toName;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.seam.RequiredException;
+import org.jboss.seam.annotations.Out;
+
+
+public class OutjectionSupport
+{
+
+ private List<BijectedAttribute<Out>> outAttributes = new ArrayList<BijectedAttribute<Out>>();
+
+ private MetaModel metaModel;
+
+ public OutjectionSupport(MetaModel metaModel)
+ {
+ this.metaModel = metaModel;
+ }
+
+ public void add(Method method)
+ {
+ Out out = method.getAnnotation(Out.class);
+ String name = toName( out.value(), method );
+ outAttributes.add( new BijectedMethod(name, method, out, metaModel) );
+ }
+
+ public void add(Field field)
+ {
+ if ( field.isAnnotationPresent(Out.class) )
+ {
+ Out out = field.getAnnotation(Out.class);
+ String name = toName( out.value(), field );
+ outAttributes.add(new BijectedField(name, field, out, metaModel) );
+ }
+ }
+
+ public void outject(Object instance)
+ {
+ for ( BijectedAttribute<Out> att: outAttributes )
+ {
+ outjectAttribute( att.getAnnotation(), att.getName(), instance, att.get(instance) );
+ }
+ }
+
+ private void outjectAttribute(Out out, String name, Object bean, Object value)
+ {
+
+ if (value==null && out.required())
+ {
+ throw new RequiredException(
+ "@Out attribute requires non-null value: " +
+ metaModel.getAttributeMessage(name)
+ );
+ }
+ else
+ {
+ if ( out.scope()==UNSPECIFIED )
+ {
+ throw new IllegalArgumentException(
+ "Must specify a scope to outject to: " +
+ metaModel.getAttributeMessage(name)
+ );
+ }
+ else if ( out.scope()==STATELESS )
+ {
+ throw new IllegalArgumentException(
+ "cannot specify explicit scope=STATELESS on @Out: " +
+ metaModel.getAttributeMessage(name)
+ );
+ }
+
+ if ( out.scope().isContextActive() )
+ {
+ if (value==null)
+ {
+ out.scope().getContext().remove(name);
+ }
+ else
+ {
+ out.scope().getContext().set(name, value);
+ }
+ }
+ }
+ }
+
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/SeamAuthorizationStrategy.java (from rev 7355, trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamAuthorizationStrategy.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/SeamAuthorizationStrategy.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/SeamAuthorizationStrategy.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,72 @@
+package org.jboss.seam.wicket;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.Page;
+import org.apache.wicket.RestartResponseAtInterceptPageException;
+import org.apache.wicket.authorization.Action;
+import org.apache.wicket.authorization.IAuthorizationStrategy;
+import org.jboss.seam.annotations.security.Restrict;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+import org.jboss.seam.security.Identity;
+import org.jboss.seam.security.NotLoggedInException;
+import org.jboss.seam.util.Strings;
+
+public class SeamAuthorizationStrategy implements IAuthorizationStrategy
+{
+
+ private LogProvider log = Logging.getLogProvider(SeamAuthorizationStrategy.class);
+ private Class loginPage;
+
+ public SeamAuthorizationStrategy()
+ {
+ this(null);
+ }
+
+ public SeamAuthorizationStrategy(final Class loginPage)
+ {
+ this.loginPage = loginPage;
+ }
+
+ // TODO Use permission schemes for this?
+ public boolean isActionAuthorized(Component component, Action action)
+ {
+ return isInstantiationAuthorized(component.getClass());
+ }
+
+ public boolean isInstantiationAuthorized(Class componentClass)
+ {
+ Restrict restrict = (Restrict) componentClass.getAnnotation(Restrict.class);
+ if ( restrict != null && Identity.isSecurityEnabled() )
+ {
+ String expr = !Strings.isEmpty( restrict.value() ) ? restrict.value() : "#{identity.loggedIn}";
+ try
+ {
+ Identity.instance().checkRestriction(expr);
+ }
+ catch (NotLoggedInException e)
+ {
+ log.error("Unauthorized access to " + componentClass.getName() + ", user not logged in", e);
+ return handleException(componentClass);
+ }
+ catch (org.jboss.seam.security.AuthorizationException e)
+ {
+ log.error("Unauthorized access to " + componentClass.getName(), e);
+ return handleException(componentClass);
+ }
+ }
+ return true;
+ }
+
+ private boolean handleException(Class componentClass)
+ {
+ if (Page.class.isAssignableFrom(componentClass))
+ {
+ // Redirect to page to let the user sign in
+ throw new RestartResponseAtInterceptPageException(loginPage);
+ }
+ return false;
+ }
+
+
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/SeamLink.java (from rev 7355, trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamLink.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/SeamLink.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/SeamLink.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,39 @@
+package org.jboss.seam.wicket;
+
+import org.apache.wicket.markup.html.link.ILinkListener;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.util.value.ValueMap;
+import org.jboss.seam.core.Conversation;
+import org.jboss.seam.core.Manager;
+
+public abstract class SeamLink extends Link
+{
+
+ public SeamLink(String id)
+ {
+ super(id);
+ }
+
+ public SeamLink(String id, IModel model)
+ {
+ super(id, model);
+ }
+
+ @Override
+ protected CharSequence getURL()
+ {
+ return getRequestCycle().urlFor(this, ILinkListener.INTERFACE, getParameterMap());
+ }
+
+ private ValueMap getParameterMap()
+ {
+ ValueMap valueMap = new ValueMap();
+ if (Conversation.instance().isLongRunning())
+ {
+ valueMap.add(Manager.instance().getConversationIdParameter(), Conversation.instance().getId());
+ }
+ return valueMap;
+ }
+
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/SeamSupport.java (from rev 7355, trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamSupport.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/SeamSupport.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/SeamSupport.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,65 @@
+/*
+ * 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.jboss.seam.wicket;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.Component;
+import org.apache.wicket.application.IComponentInstantiationListener;
+
+/**
+ * Main support class for letting Wicket work with Seam annotations. Active
+ * support by calling {@link #activate(Application) the activate method}
+ * preferably from your {@link Application#init() application's init method}.
+ *
+ * @author eelcohillenius
+ * @author Pete Muir
+ */
+// TODO handle outjection etc. Might need onAfterRender and may
+// onBeforeRender for that, in which case this class can implement the
+// appropriate interfaces and register itself as a listener for them.
+// TODO handle method level sometime. For starters, see if there is any example/
+// test case/ whatever in Seam first that shows off that kind of usage
+public class SeamSupport implements IComponentInstantiationListener {
+
+ /**
+ * Activate support for Seam annotations on components for the provided
+ * application.
+ *
+ * @param application
+ * The application to active support for
+ */
+ public static void activate(Application application) {
+ SeamSupport listener = new SeamSupport();
+ application.addComponentInstantiationListener(listener);
+ }
+
+ /**
+ * @see org.apache.wicket.application.IComponentInstantiationListener#onInstantiation(org.apache.wicket.Component)
+ */
+ public void onInstantiation(Component component)
+ {
+ WicketComponent wicketComponent = WicketComponent.forClass(component.getClass());
+ try
+ {
+ wicketComponent.inject(component);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/SimpleDataProvider.java (from rev 7355, trunk/examples/wicket/src/web/org/jboss/seam/wicket/SimpleDataProvider.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/SimpleDataProvider.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/SimpleDataProvider.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,22 @@
+package org.jboss.seam.wicket;
+
+import java.io.Serializable;
+
+import org.apache.wicket.markup.repeater.data.IDataProvider;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+
+public abstract class SimpleDataProvider implements IDataProvider
+{
+
+ public IModel model(Object object)
+ {
+ return new Model((Serializable) object);
+ }
+
+ public void detach()
+ {
+ // No - op
+ }
+
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/WicketComponent.java (from rev 7355, trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketComponent.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/WicketComponent.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/WicketComponent.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,47 @@
+package org.jboss.seam.wicket;
+
+import org.jboss.seam.contexts.Contexts;
+
+public class WicketComponent extends MetaModel
+{
+
+ public WicketComponent(Class<?> beanClass)
+ {
+ super(beanClass);
+ }
+
+ @Override
+ protected String getMetaModelName()
+ {
+ return getComponentName(getBeanClass());
+ }
+
+ protected static String getComponentName(Class clazz)
+ {
+ return clazz.getName() + ".wicketComponent";
+ }
+
+ public static WicketComponent forClass(Class clazz)
+ {
+ if (Contexts.isApplicationContextActive())
+ {
+ String metaModelName = getComponentName(clazz);
+ instantiate(metaModelName, clazz);
+ return (WicketComponent) forName(metaModelName);
+ }
+ else
+ {
+ throw new IllegalStateException("Application context is not active");
+ }
+ }
+
+ private static void instantiate(String componentName, Class clazz)
+ {
+ if (!Contexts.getApplicationContext().isSet(componentName))
+ {
+ WicketComponent component = new WicketComponent(clazz);
+ Contexts.getApplicationContext().set(componentName, component);
+ }
+ }
+
+}
Added: trunk/src/wicket/org/jboss/seam/wicket/WicketExceptionFilter.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/WicketExceptionFilter.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/WicketExceptionFilter.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,44 @@
+package org.jboss.seam.wicket;
+
+import static org.jboss.seam.annotations.Install.FRAMEWORK;
+import static org.jboss.seam.ScopeType.APPLICATION;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.annotations.web.Filter;
+import org.jboss.seam.web.AbstractFilter;
+
+/**
+ * Kill the redirect filter
+ * @author
+ */
+ at Scope(APPLICATION)
+ at Name("org.jboss.seam.web.exceptionFilter")
+ at Install(precedence = FRAMEWORK, classDependencies="org.apache.wicket.Application")
+ at BypassInterceptors
+ at Filter()
+public class WicketExceptionFilter extends AbstractFilter
+{
+
+
+ @Override
+ public boolean isDisabled()
+ {
+ return true;
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
+ {
+
+
+ }
+}
Property changes on: trunk/src/wicket/org/jboss/seam/wicket/WicketExceptionFilter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/src/wicket/org/jboss/seam/wicket/WicketManager.java (from rev 7355, trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketManager.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/WicketManager.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/WicketManager.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,48 @@
+package org.jboss.seam.wicket;
+
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.core.Manager;
+
+ at Scope(ScopeType.EVENT)
+ at Name("org.jboss.seam.core.manager")
+ at Install(precedence=100, classDependencies="org.apache.wicket.Application")
+ at BypassInterceptors
+public class WicketManager extends Manager
+{
+
+ private boolean controllingRedirect;
+
+ public String appendConversationIdFromRedirectFilter(String url, String viewId)
+ {
+ boolean appendConversationId = !controllingRedirect;
+ if (appendConversationId)
+ {
+ beforeRedirect(viewId);
+ url = encodeConversationId(url, viewId);
+ }
+ return url;
+ }
+
+ /**
+ * Temporarily promote a temporary conversation to
+ * a long running conversation for the duration of
+ * a browser redirect. After the redirect, the
+ * conversation will be demoted back to a temporary
+ * conversation. Handle any changes to the conversation
+ * id, due to propagation via natural id.
+ */
+ public void beforeRedirect(String viewId)
+ {
+ // TODO - do something here!
+ }
+
+ public static WicketManager instance()
+ {
+ return (WicketManager) Manager.instance();
+ }
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/WicketRedirectFilter.java (from rev 7355, trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketRedirectFilter.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/WicketRedirectFilter.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/WicketRedirectFilter.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,43 @@
+package org.jboss.seam.wicket;
+
+import static org.jboss.seam.ScopeType.APPLICATION;
+import static org.jboss.seam.annotations.Install.FRAMEWORK;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.web.AbstractFilter;
+
+/**
+ * Kill the redirect filter
+ *
+ * @author
+ */
+ at Scope(APPLICATION)
+ at Name("org.jboss.seam.web.redirectFilter")
+ at Install(precedence = FRAMEWORK, classDependencies="org.apache.wicket.Application")
+ at BypassInterceptors
+public class WicketRedirectFilter extends AbstractFilter
+{
+
+
+ @Override
+ public boolean isDisabled()
+ {
+ return true;
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
+ {
+
+
+ }
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/WicketSeamFilter.java (from rev 7355, trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketSeamFilter.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/WicketSeamFilter.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/WicketSeamFilter.java 2008-02-04 17:27:54 UTC (rev 7358)
@@ -0,0 +1,163 @@
+/*
+ * 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.jboss.seam.wicket;
+
+import static org.jboss.seam.ScopeType.APPLICATION;
+import static org.jboss.seam.annotations.Install.BUILT_IN;
+
+import java.io.IOException;
+import java.util.Set;
+
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.protocol.http.WicketFilter;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.annotations.web.Filter;
+import org.jboss.seam.contexts.Context;
+import org.jboss.seam.contexts.ServletLifecycle;
+import org.jboss.seam.core.ConversationPropagation;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+import org.jboss.seam.servlet.ContextualHttpServletRequest;
+import org.jboss.seam.servlet.ServletRequestSessionMap;
+import org.jboss.seam.web.AbstractFilter;
+import org.jboss.seam.web.ServletContexts;
+
+/**
+ * Seam component that delegates requests to the {@link WicketFilter} and sets
+ * up and pulls down Seam {@link Context}s for the request.
+ * <p>
+ * Users do not have to install this filter, but instead just install
+ * {@link WicketFilter} like they would normally do. This Seam component
+ * automatically attaches to it.
+ * </p>
+ * <p>
+ * The filter automatically picks up the {@link WebApplication} when there is
+ * only one active for the web application this filter is configured for. If
+ * there are multiple Wicket applications active in the web application, you'll
+ * have to explicitly configure which one to use by providing filter init
+ * parameter 'applicationName', which corresponds to the filter name of the
+ * Wicket filter for the application you want to use this filter with.
+ * </p>
+ *
+ * @author eelcohillenius
+ */
+ at Scope(APPLICATION)
+ at Name("org.apache.wicket.seam.WicketSeamFilter")
+ at Install(classDependencies = { "org.apache.wicket.protocol.http.WebApplication" }, precedence = BUILT_IN)
+ at BypassInterceptors
+ at Filter()
+public class WicketSeamFilter extends AbstractFilter {
+
+ private static final class WicketSeamFilterConfigurationException extends
+ IllegalStateException {
+ public WicketSeamFilterConfigurationException(String msg) {
+ super(msg);
+ }
+ }
+
+ private static final String APPLICATION_NONE = "<none>";
+
+ private static LogProvider log = Logging.getLogProvider(WicketSeamFilter.class);
+
+ private String applicationName = null;
+
+ private WicketFilter delegate = null;
+
+ /**
+ * Construct.
+ */
+ public WicketSeamFilter() {
+ }
+
+ @SuppressWarnings("unchecked")
+ public void doFilter(final ServletRequest servletRequest,
+ final ServletResponse servletResponse, final FilterChain filterChain)
+ throws IOException, ServletException {
+
+ // Check for the Wicket filter (which might be initialized after this
+ // filter, hence the lazy loading). Synchronization is not important.
+ if (delegate == null && !APPLICATION_NONE.equals(applicationName)) {
+
+ if (applicationName == null) {
+ Set<String> applicationKeys = Application.getApplicationKeys();
+ if (applicationKeys.size() > 1) {
+ throw new WicketSeamFilterConfigurationException(
+ "If you run this filter in the context of multiple Wicket "
+ + "application instances (/ filters) you have to provide filer "
+ + "init parameter 'applicationName' which should correspond to "
+ + "the filter name you want to use this filter with.");
+ } else if (applicationKeys.size() == 0) {
+ // no Wicket apps configured... set to special name
+ applicationName = APPLICATION_NONE;
+ } else {
+ applicationName = applicationKeys.iterator().next();
+ }
+ }
+ Application application = (!APPLICATION_NONE
+ .equals(applicationName)) ? Application
+ .get(applicationName) : null;
+ if (application != null && !(application instanceof WebApplication)) {
+ log
+ .warn("This filter can only be used with Wicket WebApplications. Currently, "
+ + "it is configured to work with an application of type "
+ + application.getClass().getName());
+ applicationName = APPLICATION_NONE;
+ filterChain.doFilter(servletRequest, servletResponse);
+ return;
+ }
+
+ WebApplication webApplication = (WebApplication) application;
+ if (webApplication == null) {
+ log
+ .warn("ignoring request: no Wicket web application instance found");
+ applicationName = APPLICATION_NONE;
+ filterChain.doFilter(servletRequest, servletResponse);
+ return;
+ }
+
+ delegate = webApplication.getWicketFilter();
+ }
+
+ new ContextualHttpServletRequest((HttpServletRequest) servletRequest)
+ {
+ @Override
+ public void process() throws Exception
+ {
+ delegate.doFilter(servletRequest, servletResponse, filterChain);
+ }
+
+ }.run();
+ }
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException {
+ super.init(filterConfig);
+ this.applicationName = filterConfig.getInitParameter("applicationName");
+ }
+}
Added: trunk/src/wicket/seam.properties
===================================================================
More information about the seam-commits
mailing list