One thing that I have neglected so far in the plugin development articles for Jopr that I wrote is the possibility to just manually add a resource instead of having it auto discovered.
Why would you want to manually add a resource?
Some resources are virtual like e.g. Twitter feeds in the twitter plugin. If you have 100 agents, it makes no sense to either take the twitter feeds into inventory on all 100 of them or to have to ignore them all in the auto discovery portlet.
When to use auto discovery then?
Auto discovery is best used for more concrete resources like e.g. processes that can exist on a system (a JBossAS for example) or file systems etc. Those are items you usually want to monitor on each system.
Ok, show me the code
Well, actually the code is not that different from what you already know. Within
ResourceDiscoveryComponent.discoverResources()the change is to check for passed resource configurations and use those to create the concrete discovered resource:
for (Configuration config :
DiscoveredResourceDetails detail =
discoveryContext.getResourceType(), // ResourceType
url + "_"+ user, // ResourceKey
url + " feed for " +user,
"One " + url + " user",
As the plugin container will only pass us one configuration at a time (even if the call to
getPluginConfigurations()is returning a List), we can safely return the constructed detail. And this is already all :-)
One thing you need to change though is in the plugin descriptor:
description="Twitter monitoring subsystem"
This supportsManualAdd is what lets the resource type show up in its parent (usually platform for a standalone server) "Manually Add" dialog:
For more resources related to plugin development have a look at this post.