org.glassfish.common.util.admin
Class AsadminInput

java.lang.Object
  extended by org.glassfish.common.util.admin.AsadminInput

public class AsadminInput
extends java.lang.Object

Implements in one place the details of providing data to asadmin's System.in and consuming it.

Primarily (but not exclusively) for security reasons, it is useful to be able to have asadmin read data from its System.in. This class provides the logic to do so consistently. It also provides a little help for writing data to a stream such that it will be acceptable as input.

The input stream must have the following format:

 version=some-version-value
 (lines as expected by the specified version)
 

Currently there is only one version supported. The lines following the version spec must be in the format of a properties file, with the convention that each property name is (category).(property-within-category)=value The AsadminInput.InputReader returned will return a Map from its AsadminInput.InputReader.settings() method. The map will contain one entry for each category in the input, and the associated Properties object will map each property-within-category to its value.

Author:
Tim Quinn

Nested Class Summary
static interface AsadminInput.InputReader
           
 
Field Summary
static java.lang.String CLI_INPUT_OPTION
           
static java.lang.String CLI_INPUT_OPTION_NAME
           
static java.lang.String SYSTEM_IN_INDICATOR
           
 
Constructor Summary
AsadminInput()
           
 
Method Summary
static AsadminInput.InputReader reader(java.io.InputStream is)
          Returns a reader that can consume the specified version of asadmin input
static AsadminInput.InputReader reader(java.lang.String inputPath)
          Returns an asadmin reader for reading from the specified URI.
static java.lang.String versionSpecifier()
          Returns a string containing a specifier for the current version, suitable for use as the first line to write to the asadmin System.in stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLI_INPUT_OPTION_NAME

public static final java.lang.String CLI_INPUT_OPTION_NAME
See Also:
Constant Field Values

CLI_INPUT_OPTION

public static final java.lang.String CLI_INPUT_OPTION
See Also:
Constant Field Values

SYSTEM_IN_INDICATOR

public static final java.lang.String SYSTEM_IN_INDICATOR
See Also:
Constant Field Values
Constructor Detail

AsadminInput

public AsadminInput()
Method Detail

versionSpecifier

public static java.lang.String versionSpecifier()
Returns a string containing a specifier for the current version, suitable for use as the first line to write to the asadmin System.in stream.

Returns:

reader

public static AsadminInput.InputReader reader(java.lang.String inputPath)
                                       throws java.net.URISyntaxException,
                                              java.io.IOException
Returns an asadmin reader for reading from the specified URI.

Parameters:
inputPath - a valid file path or the dash indicating to read from system.in
Returns:
Throws:
java.io.IOException
java.net.URISyntaxException

reader

public static AsadminInput.InputReader reader(java.io.InputStream is)
                                       throws java.io.IOException
Returns a reader that can consume the specified version of asadmin input

Returns:
Throws:
java.io.IOException


Copyright © 2012 GlassFish Community. All Rights Reserved.