On Tue, Jul 8, 2014 at 1:35 PM, Summer, Roman <[email protected]> wrote:
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?
What is the goal exactly ? From what I understood (and how I see http://jira.xwiki.org/browse/XWIKI-6211) the feature is to support an url that just contains the extension id (and optionally maybe the version, need to define a syntax for that) which is then requested with extension manager in the registered repositories. Extension Manager API gives you the dependencies of the extension. The simplest here is probably to generate an install plan and load all the extension listed in the plan.
Thanks
Roman
Von: Vincent Massol [mailto:[email protected]] Im Auftrag von [email protected] 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 ([email protected](mailto:[email protected]))<mailto:[email protected](mailto:[email protected]))> 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#HAdding...
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 [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne