org.rhq.plugins.apache.util
Enum HttpdAddressUtility

java.lang.Object
  extended by java.lang.Enum<HttpdAddressUtility>
      extended by org.rhq.plugins.apache.util.HttpdAddressUtility
All Implemented Interfaces:
Serializable, Comparable<HttpdAddressUtility>

public enum HttpdAddressUtility
extends Enum<HttpdAddressUtility>

Utility class to extract various HTTP addresses from Augeas loaded Apache configuration.

Author:
Lukas Krejci

Nested Class Summary
static class HttpdAddressUtility.Address
           
 
Enum Constant Summary
APACHE_1_3
           
APACHE_2_x
           
 
Field Summary
static String BOGUS_HOST_WITHOUT_FORWARD_DNS
           
static String BOGUS_HOST_WITHOUT_REVERSE_DNS
           
 
Method Summary
static HttpdAddressUtility get(String version)
           
abstract  List<HttpdAddressUtility.Address> getAllMainServerAddresses(ApacheDirectiveTree ag, boolean substituteWildcards)
          This returns all the addresses the server listens on.
 HttpdAddressUtility.Address getHttpdInternalMainServerAddressRepresentation(ApacheDirectiveTree runtimeConfig)
           
 HttpdAddressUtility.Address getHttpdInternalVirtualHostAddressRepresentation(ApacheDirectiveTree runtimeConfig, String virtualHost, String serverName)
           
 HttpdAddressUtility.Address getMainServerSampleAddress(ApacheDirectiveTree ag, String limitToHost, int limitToPort)
          This just constructs a first available address under which the server or one of its virtual hosts can be reached.
 HttpdAddressUtility.Address getVirtualHostSampleAddress(ApacheDirectiveTree ag, String virtualHost, String serverName, boolean legacyWildcardHostHandling)
          This constructs an address on which given virtual host can be accessed.
static boolean isAddressConforming(HttpdAddressUtility.Address listen, String limitingHost, int limitingPort, boolean snmpModuleCompatibleMode)
          Checks that given address represents a possibly wildcarded limitingHost and limitingPort values.
static HttpdAddressUtility.Address parseListen(String listenValue)
           
static HttpdAddressUtility valueOf(String name)
          Returns the enum constant of this type with the specified name.
static HttpdAddressUtility[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

APACHE_1_3

public static final HttpdAddressUtility APACHE_1_3

APACHE_2_x

public static final HttpdAddressUtility APACHE_2_x
Field Detail

BOGUS_HOST_WITHOUT_FORWARD_DNS

public static final String BOGUS_HOST_WITHOUT_FORWARD_DNS
See Also:
Constant Field Values

BOGUS_HOST_WITHOUT_REVERSE_DNS

public static final String BOGUS_HOST_WITHOUT_REVERSE_DNS
See Also:
Constant Field Values
Method Detail

values

public static HttpdAddressUtility[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (HttpdAddressUtility c : HttpdAddressUtility.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static HttpdAddressUtility valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

get

public static HttpdAddressUtility get(String version)

getAllMainServerAddresses

public abstract List<HttpdAddressUtility.Address> getAllMainServerAddresses(ApacheDirectiveTree ag,
                                                                            boolean substituteWildcards)
This returns all the addresses the server listens on.

Parameters:
ag - the tree of the httpd configuration
substituteWildcards - true if wildcard substitution should be made on host and port specs
Returns:
the addresses or null on failure

getMainServerSampleAddress

public HttpdAddressUtility.Address getMainServerSampleAddress(ApacheDirectiveTree ag,
                                                              String limitToHost,
                                                              int limitToPort)
This just constructs a first available address under which the server or one of its virtual hosts can be reached.

Parameters:
ag - the tree of the httpd configuration
limitToHost - if non-null and different from HttpdAddressUtility.Address.DEFAULT_HOST and HttpdAddressUtility.Address.WILDCARD, the sample address is looked for only for the given host
limitToPort - if > 0, the sample address is looked for only for the given port
Returns:
the address or null on failure

getVirtualHostSampleAddress

public HttpdAddressUtility.Address getVirtualHostSampleAddress(ApacheDirectiveTree ag,
                                                               String virtualHost,
                                                               String serverName,
                                                               boolean legacyWildcardHostHandling)
This constructs an address on which given virtual host can be accessed.

Parameters:
ag - the augeas tree of the httpd configuration
virtualHost - the port or address:port of the virtual host
serverName - the server name for the namebased virtual hosts (or null if the virtual host is ip based)
legacyWildcardHostHandling - use the legacy handling of wildcard hosts. This should always be false unless you are calling this method from the code generating the legacy resource keys during vhost upgrade
Returns:
the address on which the virtual host can be accessed or null on error

getHttpdInternalMainServerAddressRepresentation

public HttpdAddressUtility.Address getHttpdInternalMainServerAddressRepresentation(ApacheDirectiveTree runtimeConfig)

getHttpdInternalVirtualHostAddressRepresentation

public HttpdAddressUtility.Address getHttpdInternalVirtualHostAddressRepresentation(ApacheDirectiveTree runtimeConfig,
                                                                                    String virtualHost,
                                                                                    String serverName)

parseListen

public static HttpdAddressUtility.Address parseListen(String listenValue)

isAddressConforming

public static boolean isAddressConforming(HttpdAddressUtility.Address listen,
                                          String limitingHost,
                                          int limitingPort,
                                          boolean snmpModuleCompatibleMode)
Checks that given address represents a possibly wildcarded limitingHost and limitingPort values.

Parameters:
listen - the address to check
limitingHost - the host to limit to. The null value or the HttpdAddressUtility.Address.DEFAULT_HOST or the HttpdAddressUtility.Address.WILDCARD are not considered limiting
limitingPort - the port to limit the address to. Values <= 0 are not considered limiting
snmpModuleCompatibleMode - the snmp module represents both port 80 and port wildcard (*) as '0'. If this flag is set to true, this method takes that into account.
Returns:


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