org.rhq.modules.plugins.jbossas7
Class AbstractBaseDiscovery

java.lang.Object
  extended by org.rhq.modules.plugins.jbossas7.AbstractBaseDiscovery
Direct Known Subclasses:
BaseProcessDiscovery, ManagedASDiscovery

public class AbstractBaseDiscovery
extends Object

Abstract base class for some discovery related functionality - especially in the area of processes and host.xml

Author:
Heiko W. Rupp

Nested Class Summary
protected static class AbstractBaseDiscovery.HostPort
          Helper class that holds information about the host,port tuple
 
Field Summary
protected  Document hostXml
           
protected  org.apache.commons.logging.Log log
           
 
Constructor Summary
protected AbstractBaseDiscovery()
           
 
Method Summary
protected  String determineServerVersionFromHomeDir(String homeDir)
           
protected  String findHostName()
          Try to determine the host name - that is the name of a standalone server or a host in domain mode by looking at the standalone.xml/host.xml files
protected  AbstractBaseDiscovery.HostPort getDomainControllerFromHostXml()
          Try to obtain the domain controller's location from looking at host.xml
protected  String getHostXmlFileLocation(ProcessInfo processInfo, boolean isDomain)
          Get the location of the host definition file (host.xml in domain mode, standalone.xml in standalone mode.
protected  AbstractBaseDiscovery.HostPort getManagementPortFromHostXml(String[] commandLine)
          Try to obtain the management IP and port from the already parsed host.xml or standalone.xml
protected  String obtainXmlPropertyViaXPath(String xpathExpression)
          Run the passed xpathExpression on the prepopulated hostXml document and return the target element or attribute as a String.
protected  void readStandaloneOrHostXml(ProcessInfo processInfo, boolean isDomainMode)
          Read the host.xml or standalone.xml file depending on isDomainMode.
protected  void readStandaloneOrHostXmlFromFile(String hostXmlFile)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hostXml

protected Document hostXml

log

protected final org.apache.commons.logging.Log log
Constructor Detail

AbstractBaseDiscovery

protected AbstractBaseDiscovery()
Method Detail

readStandaloneOrHostXml

protected void readStandaloneOrHostXml(ProcessInfo processInfo,
                                       boolean isDomainMode)
Read the host.xml or standalone.xml file depending on isDomainMode. If isDomainMode is true, host.xml is read, otherwise standalone.xml. The xml file content is stored in the variable hostXml for future use.

Parameters:
processInfo - Process info to determine the base file location
isDomainMode - Indiates if host.xml should be read (true) or standalone.xml (false)

readStandaloneOrHostXmlFromFile

protected void readStandaloneOrHostXmlFromFile(String hostXmlFile)

getManagementPortFromHostXml

protected AbstractBaseDiscovery.HostPort getManagementPortFromHostXml(String[] commandLine)
Try to obtain the management IP and port from the already parsed host.xml or standalone.xml

Parameters:
commandLine - Command line arguments of the process to
Returns:
an Object containing host and port
See Also:
on how to obtain the parsed xml

findHostName

protected String findHostName()
Try to determine the host name - that is the name of a standalone server or a host in domain mode by looking at the standalone.xml/host.xml files

Returns:
server name

getDomainControllerFromHostXml

protected AbstractBaseDiscovery.HostPort getDomainControllerFromHostXml()
Try to obtain the domain controller's location from looking at host.xml

Returns:
host and port of the domain controller

getHostXmlFileLocation

protected String getHostXmlFileLocation(ProcessInfo processInfo,
                                        boolean isDomain)
Get the location of the host definition file (host.xml in domain mode, standalone.xml in standalone mode.

Parameters:
processInfo - ProcessInfo structure containing the ENV variables
isDomain - Are we looking for host.xml (=isDomain) or not
Returns:
The path to the definition file.

determineServerVersionFromHomeDir

protected String determineServerVersionFromHomeDir(String homeDir)

obtainXmlPropertyViaXPath

protected String obtainXmlPropertyViaXPath(String xpathExpression)
Run the passed xpathExpression on the prepopulated hostXml document and return the target element or attribute as a String.

Parameters:
xpathExpression - XPath Expression to evaluate
Returns:
String value of the Element or Attribute the XPath was pointing to. Null in case the xpathExpression could not be evaluated.
Throws:
IllegalArgumentException - if hostXml is null


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