I have a plugin A that locates and loads resource bundles when the resource does discovery. Based on the properties in the default plugin configuration it will load those resources.
I have another plugin B which uses classes and resources from A but a different default plugin configuration. Resources in B is attempting to load resources from within plugin B's classpath. So basically we have:
441884 06-12-12 22:21 lib/snmp.jar 9003 06-12-12 22:36 .../snmp/MibComponent.class 4562 06-12-12 22:36 .../snmp/MibDiscovery.class 5690 06-13-12 00:24 META-INF/rhq-plugin.xml
0 06-12-12 17:23 mibs/ 151517 06-13-12 00:47 META-INF/rhq-plugin.xml // uses Plugin A's classes 18944 06-12-12 22:23 mibs/IPV6-ICMP-MIB.mib
Plugin B configuration:
<plugin xmlns="urn:xmlns:rhq-plugin" xmlns:c="urn:xmlns:rhq-configuration" name="B" displayName="B Plugin"> <depends plugin="A" useClasses="true"/> <service name="B" discovery="MibDiscovery" class="MibComponent" singleton="true"> <runs-inside> <parent-resource-type name="SNMP Component" plugin="snmp" /> </runs-inside> <plugin-configuration> <c:simple-property name="mibs" default="IPV6-ICMP-MIB.mib" /> </plugin-configuration>
This doesn't seem to work on RHQ 4.1. I also tested on 4.4 and it fails.
I think the work around must be to create a (dummy) class that simply extends MibDiscovery.
What should happen is a separate class loader get created for 'B Plugin' which will load resources and classes from 'A Plugin' if not found in 'B Plugin'. Let me know if I should file a bug or not. Thanks.
What should happen is a separate class loader get created for 'B Plugin' which will
load resources and classes from 'A Plugin' if not found in 'B Plugin'.
That is how is should usually work. Read this for a more detailed description of how things are working. Maybe something in here can shed light on the issue?
This also has more classloading docs that may be helpful:
You mentioned something about discovery in your post - there is specific information on "discovery classloaders" in here that you should look at.
Thanks for your help. I scratched my head a bit, but basically what seemed to work is set classloader='instance' for my resource.
I think the documents are helpful but might be easier to grok with a couple of simple diagrams and more examples.
The expectation I had is that resources defined in a plugin can load classes and resources from that plugin, even though that plugin is using classes from another 'parent plugin.'