How to make the changes of inventory connection effective in discovery component?

Lin Gao lgao at redhat.com
Tue Dec 28 06:04:51 UTC 2010


Hi:

   If the value of one inventory connection is part of the resource 
component name, how to make the resource component name reflecting the 
changes of the inventory connection value.

  below is an example:

  rhq-plugin.xml:

<server name="HttpServer-Host" description="Http server host and port"
             discovery="HttpHostDiscoveryComponent" 
class="HttpHostResourceComponent"
             supportsManualAdd="true">

<plugin-configuration>
<c:simple-property name="host" description="host of target http server" />
<c:simple-property name="port"  description="port of target http server" />
</plugin-configuration>
</server>

HttpHostDiscoveryComponent.java:

public Set<DiscoveredResourceDetails> discoverResources(
             ResourceDiscoveryContext<HttpHostResourceComponent> context)
             throws InvalidPluginConfigurationException, Exception {
         Set<DiscoveredResourceDetails> result = new 
HashSet<DiscoveredResourceDetails>();
         for(Configuration config: context.getPluginConfigurations()){
             String host = config.getSimpleValue(PLUGIN_CONFIG_HOST_KEY, 
null);
             Integer port = 
Integer.valueOf(config.getSimpleValue(PLUGIN_CONFIG_PORT_KEY, "80"));

             String resourceKey = "HTTP_CHECK_" + host + ":" + port;
             String resourceName = "Http Checker on: " + host + ":" + port;
             String resourceVersion = "1.0.0";
             String resourceDescription = "Http Checker on server: " + 
host + ":" + port + ".";
             DiscoveredResourceDetails resource = new 
DiscoveredResourceDetails(context.getResourceType(), resourceKey, 
resourceName, resourceVersion, resourceDescription, config, null);
             result.add(resource);
         }
         return result;
     }


If the host is defined to: 127.0.0.1 and port to: 80 when the server is 
added manually, the name of this resource component in the navigate tree 
is: "Http Checker on: 127.0.0.1:80", after that, if the host is 
changed(inventory->connection->edit...), the name of the resource 
component in the navigate tree is not changed, even re load the tree, so 
how to make it changed also?

-- 
Best Regards
Lin Gao
JBoss Software Engineer
Red Hat China R&D Branch
IRC:lgao @ #jbosscn,#prod,#jbossas,#Eng-china
Phone:  +86-10-6260-8252
Mobile Phone: +86-13811109928
E-Mail: lgao at redhat.com



More information about the rhq-devel mailing list