org.rhq.plugins.platform
Class PlatformDiscoveryComponent

java.lang.Object
  extended by org.rhq.plugins.platform.PlatformDiscoveryComponent
All Implemented Interfaces:
ResourceDiscoveryComponent
Direct Known Subclasses:
AixPlatformDiscoveryComponent, BsdPlatformDiscoveryComponent, HpuxPlatformDiscoveryComponent, JavaPlatformDiscoveryComponent, LinuxPlatformDiscoveryComponent, MacOSXPlatformDiscoveryComponent, SolarisPlatformDiscoveryComponent, WindowsPlatformDiscoveryComponent

public abstract class PlatformDiscoveryComponent
extends Object
implements ResourceDiscoveryComponent

Discovers the platform resource. This will discover one and only one resource. This is an abstract superclass to all the natively supported platform discovery components and the fallback Java-only discovery component.

Author:
John Mazzitelli

Constructor Summary
PlatformDiscoveryComponent()
           
 
Method Summary
protected  String determineResourceKey(ResourceDiscoveryContext context)
          This will determine what the new platform's resource key should be.
protected  String determineResourceName(ResourceDiscoveryContext context)
          This will determine what the new platform's resource name should be.
protected  void discoverConfiguration(org.rhq.core.domain.configuration.Configuration configuration)
          Override this method to add additional configurations to discovered platforms
 Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context)
          This will build the platform's resource details, where its name and key are by default the plugin container's name.
protected  String getHostname(SystemInfo systemInformation)
          Tries to determine this platform's hostname, using the (possibly native) system info API.
protected abstract  boolean isPlatformSupported(ResourceDiscoveryContext context)
          Subclasses will implement this method to tell this class whether or not it can discover the platform of the resource type found in the given context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlatformDiscoveryComponent

public PlatformDiscoveryComponent()
Method Detail

discoverResources

public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context)
This will build the platform's resource details, where its name and key are by default the plugin container's name. Subclasses of this platform discovery component are free to override this behavior if they wish to make the platform name different, but under normal circumstances, subclasses will not want to alter the key value.

Specified by:
discoverResources in interface ResourceDiscoveryComponent
See Also:
ResourceDiscoveryComponent.discoverResources(ResourceDiscoveryContext)

discoverConfiguration

protected void discoverConfiguration(org.rhq.core.domain.configuration.Configuration configuration)
Override this method to add additional configurations to discovered platforms

Parameters:
configuration -

determineResourceKey

protected String determineResourceKey(ResourceDiscoveryContext context)
This will determine what the new platform's resource key should be. This default implementation first tries to use the plugin container's name which is guaranteed to be unique across all agents/plugin containers. If, for some odd reason, it is null, the platform's hostname is used. This is less than optimal but the plugin container's name will never be null under virtually all use-cases (except perhaps in test scenarios).

Parameters:
context - the discovery context used to get the plugin container name or host name if its needed
Returns:
the new platform's resource key

determineResourceName

protected String determineResourceName(ResourceDiscoveryContext context)
This will determine what the new platform's resource name should be. This default implementation first tries to use the plugin container's name which is guaranteed to be unique across all agents/plugin containers. If, for some odd reason, it is null, the platform's hostname is used.

Parameters:
context - the discovery context used to get the plugin container name or host name if its needed
Returns:
the new platform's resource key

getHostname

protected String getHostname(SystemInfo systemInformation)
Tries to determine this platform's hostname, using the (possibly native) system info API. If, for whatever reason, this method cannot determine the hostname, a generic "Unnamed Platform" String will be returned (this will rarely, if ever, happen under normal situations).

Parameters:
systemInformation -
Returns:
the platform's hostname (will never be null)

isPlatformSupported

protected abstract boolean isPlatformSupported(ResourceDiscoveryContext context)
Subclasses will implement this method to tell this class whether or not it can discover the platform of the resource type found in the given context. If this returns false, this subclass discovery component instance does not recognize the platform.

It is very important that all subclasses must return false except one for any given platform. That is to say, if running on "RHEL 5", only the subclass that supports RHEL 5 must return true, all others must return false. If running on "Windows XP", only the suclass that supports Windows XP must return true. The only exception to this rule is the fallback Java platform discovery component, which will always return true because the fallback Java platform is always supported.

Parameters:
context -
Returns:
true if this instance can support the platform this plugin is running on; false otherwise


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.