tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Tapestry Wiki] Update of "HowToRunTapestry5OnJboss5" by ShingHingMan
Date Mon, 11 May 2009 20:08:48 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Tapestry Wiki" for change notification.

The following page has been changed by ShingHingMan:
http://wiki.apache.org/tapestry/HowToRunTapestry5OnJboss5

------------------------------------------------------------------------------
- Tapestry 5 can not find the core pages and components from the URLs provided from classloaders
in Jboss 5.x. Please see   https://issues.apache.org/jira/browse/TAP5-576 for details.
+ Tapestry 5.x can not find the core pages and components from the URLs provided from classloaders
in Jboss 5.x. Please see   https://issues.apache.org/jira/browse/TAP5-576 for details. In
JIRA 576, Benjamin Bentmann provided an implementation of ClasspathURLConverter to overcome
the problem. 
  
+ {{{
+ public class ClasspathURLConverterJBoss5 implements ClasspathURLConverter
+ {
+ 	private static Logger log = Logger.getLogger(ClasspathURLConverterJBoss5.class);
+ 
+    public URL convert(URL url)
+    {
+         if (url != null && url.getProtocol().startsWith("vfs"))
+         {
+             // supports virtual filesystem used by JBoss 5.x
+             try
+             {
+                 URLConnection connection = url.openConnection();
+                 Object virtualFile = invokerGetter(connection, "getContent");
+                 Object zipEntryHandler = invokerGetter(virtualFile, "getHandler");
+                 Object realUrl = invokerGetter(zipEntryHandler, "getRealURL");
+                 return (URL) realUrl;
+             }
+             catch (Exception e)
+             {
+                 log.info(e.getCause());
+             }
+         }
+        return url;
+    }
+ 
+     private Object invokerGetter(Object target, String getter) throws NoSuchMethodException,
InvocationTargetException, IllegalAccessException
+     {
+         Class<?> type = target.getClass();
+         Method method;
+         try
+         {
+             method = type.getMethod(getter);
+         }
+         catch (NoSuchMethodException e)
+         {
+             method = type.getDeclaredMethod(getter);
+             method.setAccessible(true);
+         }
+         return method.invoke(target);
+     }
+ 
+ }
+ }}}
+ 
+ To override the default implementation of ClasspathURLConverter, just add the above  ClasspathURLConverterJBoss5.java
to your project and add the following piece of code to your AppModule.java.
+ 
+ {{{
+ public static void contributeServiceOverride(MappedConfiguration<Class,Object> configuration)
+     {
+       configuration.add(ClasspathURLConverter.class,  new ClasspathURLConverterJBoss5());
+     }
+     
+ }}}
+ 
+ The above just override the default ClaspathURLConverter service. For more information on
overriding  a general service, please see http://tapestry.apache.org/tapestry5.1/tapestry-ioc/cookbook/override.html
+ 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


Mime
View raw message