http://weblogs.java.net/blog/kohsuke/archive/2007/02/howitworks_runn.html
should
be an idea...

2007/11/18, nicolas de loof <[EMAIL PROTECTED]>:
>
> Hello,
>
> For the javascript maven plugin I have a classloader issue to address :
>
> The plugin itself requires Rhino javascript engine as a dependency.
> To support javascript compression, I'd like to provides support for
> various compressors : JSMin, Dojo Shrinksafe, Yahoo compressor...
>
> The 2 later use some customized Rhino engine. I can't set them as
> dependency as this creates a classpath conflict.
>
> I'd like to setup some custom "parent-last" classloader to load and run
> the compressor :
>
> plugin classloader [mozilla unmodified Rhino engine]
>   |_ shrinksafe compresor classloader [dojo custom rhino]
>   |_ yui compressor classloader [custom rhino]
>
> The plugin could then invoke the compressor by reflection on the Class
> object obtained form the compressor-dedicated classloader.
>
> <pseudo-code>
>   // Create a parent-last classloader
>   ParentLastClassLoader cl = new ParentLastClassloader( 
> this.getClass().getClassLoader()
> );
>
>   // Add the required dependencies artifacts
>   Artifact customRhino = pluginArtifactMap.get( "
> org.dojotoolkit:custom_rhino" );
>   cl.addPath( customRhino.getFile().toUrl() );
>
>   // Add the plugin itself
>    Artifact plugin = project.getPlugin( "
> org.codeahus.mojo:maven-javascript-plugin" );
>   cl.addPath( plugin.getFile().toUrl() );
>
>   // Load the taret compressor class from isolated classloader
>   Class compressor = cl.getClass( ShrinkSafeCompressor.class.getName() );
>
>   // Invoke by reflection compress( File source, File dest );
>   Method compress = compressor.getMethod( "compress", ... );
>   compress.invoke( compressor.newInstance(), source, dest );
> </pseudo-code>
>
> Is there allready some code that use same strategy ? I've looked at
> classworld but hardly understand how to configure it for such use case.
>
> Any suggestion would be welcome !
>
> Nico.
>
>
>

Reply via email to