Hi,
while I tried to implement the org.xwiki.classloader.ExtendedURLStreamHandler 
in the described way I recognized some problems:


-      First, the class 
org.xwiki.rendering.internal.macro.script.ScriptClassLoaderHandlerListener uses 
the org.xwiki.rendering.internal.macro.script.AttachmentClassLoaderFactory 
which only constructs AttachmentClassLoaders which uses 
org.xwiki.classloader.internal.protocol.attachmentjar.AttachmentURLStreamHandler.
 Last one cannot be exchanged.

In the current implementation this is no problem because the ScriptMacro only 
supports the protocol “attach” and the URL Format itself. The 
AttachmentURLStreamHandler can handle this.



I think the Used ClassLoaderFactory should automatically get the right Class 
Loader depending on the used protocol.



-      Second, I also have to resolve the dependencies of the given maven 
artifact in the URL. So I have to put more than one jar-URL in the URL 
Connection. Otherwise I have to declare all the dependencies in the URL String.

Do you know a solution for my problems?

Thanks

Roman



Von: Vincent Massol [mailto:vmas...@gmail.com] Im Auftrag von vinc...@massol.net
Gesendet: Freitag, 4. Juli 2014 14:30
An: Summer, Roman; XWiki Users
Betreff: Re: [xwiki-users] exchanging the ScriptMacro ClassLoader

Hi Roman,

On 4 Jul 2014 at 13:11:23, Summer, Roman 
(roman.sum...@de-gmbh.com(mailto:roman.sum...@de-gmbh.com))<mailto:roman.sum...@de-gmbh.com(mailto:roman.sum...@de-gmbh.com))>
 wrote:

> Hello
>
> I want to write a java script macro

I had to read this 3 times to understand it ;) (I kept thinking about 
"javascript macro”).

> which is able to load jars from an external currently not supported source 
> (e.g. from a maven repository). Therefore I want to exchange the used class 
> loader. Overriding the ScriptMacroParameters#getJars() method is not possible 
> for me, because I only want to load the classes in view and not in edit mode.
>
> My question: How is it possible to exchange the currently injected 
> implementation of the interface 
> org.xwiki.rendering.internal.macro.script.AttachmentClassLoaderFactory
> for my macro to exchange the used class loader or is there another 
> recommended official way to ream my aim.

See 
http://extensions.xwiki.org/xwiki/bin/view/Extension/ClassLoader+API#HAddinganewURLStreamHandler

Thanks
-Vincent

PS1: You should checkout OPS4J Pax URL: 
https://ops4j1.jira.com/wiki/display/paxurl/Mvn+Protocol

PS2: I think we would be interested by such a contribution. Actually a great 
contribution would be to bridge our code to use PAX URL (not even sure anything 
is needed for that!). We probably just need a tutorial explaining how to use 
PAX URL in XWiki.
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to