Plugin Namespace
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 23
- Joined: Sun Jan 15, 2017 3:15 pm
- Location: Salem, Oregon
Plugin Namespace
I would like to be able to call code among Plugins or have a Global space where my plugin can call.
For instance, if I have a plugin "A" that has a function foo(myParam), I'd like to be able to call foo("test") from plugin "B". From what I can tell the namespaces for each plugin are isolated... or way down a tree branch not meant to be followed.
Here's another example, I have the following code:
which if included in each and every plugin works, but it would be nice to be able to have print() defined just once in a location where any plugin may call it. Is there a way to accomplish this or a way of contributing to the global namespace?
For instance, if I have a plugin "A" that has a function foo(myParam), I'd like to be able to call foo("test") from plugin "B". From what I can tell the namespaces for each plugin are isolated... or way down a tree branch not meant to be followed.
Here's another example, I have the following code:
Code: Select all
function print (msg) {
if (typeof(msg) == "undefined"){
// getting an undefined causes error as interpreter does not
// know if string or object
Packages.java.lang.System.out.println("undefined");
return;
}
// next line for debugging
//Packages.java.lang.System.out.println("[print 59] typeof msg = " + typeof(msg));
if (typeof(msg) == "object"){
Packages.java.lang.System.out.println(msg.toString);
} else {
Packages.java.lang.System.out.println(msg);
}
}
which if included in each and every plugin works, but it would be nice to be able to have print() defined just once in a location where any plugin may call it. Is there a way to accomplish this or a way of contributing to the global namespace?
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Plugin Namespace
Hi,
By default each plugin is loaded in its own class loader, meaning that indeed they cannot access methods from another plugin's code. We do this to avoid conflicts between plugins created by separate vendors/developers.
When you refer to libraries in the plugin.xml you can add a @scope attribute to the reference:
https://www.oxygenxml.com/doc/versions/ ... lugin.html
Maybe specifying a "global" scope when referencing libraries containing common code would work in your case.
Regards,
Radu
By default each plugin is loaded in its own class loader, meaning that indeed they cannot access methods from another plugin's code. We do this to avoid conflicts between plugins created by separate vendors/developers.
When you refer to libraries in the plugin.xml you can add a @scope attribute to the reference:
https://www.oxygenxml.com/doc/versions/ ... lugin.html
Maybe specifying a "global" scope when referencing libraries containing common code would work in your case.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 23
- Joined: Sun Jan 15, 2017 3:15 pm
- Location: Salem, Oregon
Re: Plugin Namespace
What I'd like to be able to do is reference the JavaScript functions. It appears that specifying global relates to java jars which I believe can only contain Java classes. Is there a way to have JavaScript objects made global? I'm used to developing in Arbortext using JavaScript using encapsulation of our JavaScript classes within a single global namespace. In Arbortext, we created JavaScript, not Java, objects within hierarchies, e.g. com.oracle.xxx.yyy.zzz.MyClassMaybe specifying a "global" scope when referencing libraries containing common code would work in your case.
Is there some way to have the JavaScript share namespaces? If not, then it looks like I will have to place everything into one JavaScript file.
2nd question: Can the loader load more than one JavaScript file so in a plugin, called "red", I might have several JavaScript files such as red.js, red2.js and red3.js?
I tried using the "this.classname" within my JavaScript to see where in the global namespace it might be, even if in temporary named areas, and I got "undefined."
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Plugin Namespace
Hi,
So:
So you will probably need to create a small build process which takes the modular Javscript files and creates a large Javascript file used in the plugin.
Regards,
Radu
So:
Right now there is no way for a Javascript in one plugin to call methods from a Javascript in another. We'll try to remove this limitation in the future.Is there some way to have the JavaScript share namespaces? If not, then it looks like I will have to place everything into one JavaScript file.
Also unfortunately we do not have this. We have an internal issue registered for this and I will update this forum thread when an Oxygen version containing this improvement is available.2nd question: Can the loader load more than one JavaScript file so in a plugin, called "red", I might have several JavaScript files such as red.js, red2.js and red3.js?
So you will probably need to create a small build process which takes the modular Javscript files and creates a large Javascript file used in the plugin.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Plugin Namespace
Hi,
We released Oxygen 21.1 and it should allow specifying multiple Javascript module files in the plugin.xml like:
Regards,
Radu
We released Oxygen 21.1 and it should allow specifying multiple Javascript module files in the plugin.xml like:
Code: Select all
<extension type="WorkspaceAccessJS" href="wsAccess.js"/>
<extension type="WorkspaceAccessJSModule" href="wsAccessModule1.js"/>
<extension type="WorkspaceAccessJSModule" href="wsAccessModule2.js"/>
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “SDK-API, Frameworks - Document Types”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service