[seam-commits] Seam SVN: r8467 - in trunk: src/wicket/org/jboss/seam/wicket/ioc and 1 other directory.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon Jul 14 18:12:21 EDT 2008
Author: pete.muir at jboss.org
Date: 2008-07-14 18:12:21 -0400 (Mon, 14 Jul 2008)
New Revision: 8467
Modified:
trunk/examples/wicket/build.xml
trunk/src/wicket/org/jboss/seam/wicket/ioc/JavassistInstrumentor.java
trunk/src/wicket/org/jboss/seam/wicket/ioc/WicketClassLoader.java
Log:
Fix classloader to load resources, fix wicket example deploy path
Modified: trunk/examples/wicket/build.xml
===================================================================
--- trunk/examples/wicket/build.xml 2008-07-14 21:33:48 UTC (rev 8466)
+++ trunk/examples/wicket/build.xml 2008-07-14 22:12:21 UTC (rev 8467)
@@ -21,13 +21,13 @@
<import file="../build.xml"/>
<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" >
+ <mkdir dir="${war.dir}/WEB-INF/wicket" />
+ <javac destdir="${war.dir}/WEB-INF/wicket" debug="${javac.debug}" deprecation="${javac.deprecation}" nowarn="on" >
<src path="${src.web.dir}" />
<classpath refid="build.classpath"/>
<classpath location="${jar.dir}"/>
</javac>
- <copy todir="${war.dir}/WEB-INF/classes">
+ <copy todir="${war.dir}/WEB-INF/wicket">
<fileset dir="${src.web.dir}">
<include name="**/*.component.xml" />
<include name="**/*.html" />
Modified: trunk/src/wicket/org/jboss/seam/wicket/ioc/JavassistInstrumentor.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/JavassistInstrumentor.java 2008-07-14 21:33:48 UTC (rev 8466)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/JavassistInstrumentor.java 2008-07-14 22:12:21 UTC (rev 8467)
@@ -42,9 +42,15 @@
public void instrument() throws NotFoundException, CannotCompileException, ClassNotFoundException
{
+ if (wicketComponentDirectory == null)
+ {
+ log.warn("No wicket components found to give Seam super powers to");
+ classLoader = Thread.currentThread().getContextClassLoader();
+ return;
+ }
ClassLoader parent = Thread.currentThread().getContextClassLoader();
classPool = new ClassPool();
- classLoader = new WicketClassLoader(parent, classPool, classes);
+ classLoader = new WicketClassLoader(parent, classPool, classes, wicketComponentDirectory);
classPool.insertClassPath(wicketComponentDirectory.getAbsolutePath());
classPool.insertClassPath(new LoaderClassPath(parent));
Modified: trunk/src/wicket/org/jboss/seam/wicket/ioc/WicketClassLoader.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/WicketClassLoader.java 2008-07-14 21:33:48 UTC (rev 8466)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/WicketClassLoader.java 2008-07-14 22:12:21 UTC (rev 8467)
@@ -1,5 +1,8 @@
package org.jboss.seam.wicket.ioc;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.List;
import javassist.ClassPool;
@@ -9,23 +12,27 @@
{
private List<String> classes;
+ private File wicketComponentDirectory;
- public WicketClassLoader(List<String> classes)
+ public WicketClassLoader(List<String> classes, File wicketComponentDirectory)
{
super();
this.classes = classes;
+ this.wicketComponentDirectory = wicketComponentDirectory;
}
- public WicketClassLoader(ClassLoader parent, ClassPool cp, List<String> classes)
+ public WicketClassLoader(ClassLoader parent, ClassPool cp, List<String> classes, File wicketComponentDirectory)
{
super(parent, cp);
this.classes = classes;
+ this.wicketComponentDirectory = wicketComponentDirectory;
}
- public WicketClassLoader(ClassPool cp, List<String> classes)
+ public WicketClassLoader(ClassPool cp, List<String> classes, File wicketComponentDirectory)
{
super(cp);
this.classes = classes;
+ this.wicketComponentDirectory = wicketComponentDirectory;
}
@Override
@@ -42,4 +49,32 @@
return clazz;
}
+ @Override
+ public URL getResource(String name)
+ {
+ File file = new File(wicketComponentDirectory, name);
+ if (file.exists())
+ {
+ try
+ {
+ return file.toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ else
+ {
+ if (getParent() != null)
+ {
+ return getParent().getResource(name);
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
}
More information about the seam-commits
mailing list