Plugin Development Doubt :
arun2arunraj Jun 21, 2013 7:19 AMHi Developers,
Is it possible to discover two resources by manual Add Facet at a single time ? ? ?
In other words, When I have import a single resourceType , I have to get two resouces in it. Is that possible . If yes, please change my below coding.
package org.rhq.plugins.Demos; import java.util.ArrayList; import java.util.HashSet; import java.util.Set; import java.util.Collections; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; import org.rhq.core.pluginapi.inventory.ManualAddFacet; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; public class WebServiceDiscovery implements ResourceDiscoveryComponent<ParentComponent>, ManualAddFacet { /** * This attribute mLogger is for logging the Class Name into RHQ Agent. */ private final Log mLogger = LogFactory.getLog(this.getClass()); /** * This attribute mCustomers is for storing the resources details. */ private Set<DiscoveredResourceDetails> mWebService = new HashSet<DiscoveredResourceDetails>(); /** * discoverResources() method is used to discover web services based on the resourceKey. */ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) throws InvalidPluginConfigurationException, Exception { return Collections.emptySet(); } public Set<DiscoveredResourceDetails> discoverResource(Configuration pluginConfig, ResourceDiscoveryContext context) throws InvalidPluginConfigurationException { /** * This attribute mDiscoveredResourceDetails is used to store single resource detail. */ DiscoveredResourceDetails mDiscoveredResourceDetails = null; ArrayList <String> resourceName = new ArrayList<String>(); ArrayList <String> resourceKey = new ArrayList<String>(); ArrayList <String> resourceDescription = new ArrayList<String>(); int index; String parentKey = null; parentKey = context.getParentResourceContext().getResourceKey(); if(parentKey!=null) { customerName.add("Billing"); customerName.add("Submission"); customerDescription.add("Billing service "); customerDescription.add("Submission service "); customerKey.add(parentKey + "Billing Webservice"); customerKey.add(parentKey + "Submission Webservice"); for(index=0;index<customerName.size();index++) { mDiscoveredResourceDetails = new DiscoveredResourceDetails(context.getResourceType(), resourceKey.get(index), resourceName.get(index),null,resourceDescription.get(index),null, null); mWebService.add(mDiscoveredResourceDetails); } } mLogger.debug("Exiting from WebServiceDiscovery: discoverResources() method.->->-><-<-<-"+customerKey); return mWebService; } }
Please guide me to understand the concept.
Regards,
ArunRaj