May I ask, why you need two instances of javaloader?
The purpose of the java loader is that you can point to a set of java jar’s or classes your application will use. Usually, at startup you point the java loader to what java classes to load. Then you can just use it throughout your application.
I. I have two plugins. PluginA is a delimited file plugin
(reads,writes delimited files). PluginB is a string case plugin
(converts strings to Titlecase, Sentencecase). Independently, they
work and each plugin has a jar file that it uses functionality from.
The problem arises when PluginA makes a call to PluginB. Both plugins
"setup" their jar files with javaloader in the plugin's init. Because
only one javaloader exists, it will only have a reference to one of
the jars for both plugins. So when I try to create objects from those
jars, it will fail for one of the plugins as the classes won't be
found.
II. However, I have found a workaround. My current workaround is to
create the objects I need from those jars on init right after java
loader is "setup". So now in the plugin's init function, I:
init() {
- Get javaloader plugin
- "Setup" javaloader with this plugin's jar
- Create objects from that jar that are used in the public functions
}
III. I thought about loading everything at startup but I really liked
the idea of the plugins taking care of loading what they needed
themselves and only when they were actually in use.
Appending works if javaloader is already loaded in the server scope.
Fails otherwise.
One option is to have the append function check if javaloader has been
loaded, and, if it hasn't, load it using the first location as the
loadpath.
That way, you can use the "setup" function if you're loading
everything at once. If you're loading "a la cart", like in mulitple
plugins that may or may not be needed, you can just use "appendPaths"
knowing that it will "setup" if needed.