org.safs.staf.service
Class SAFSVariableService

java.lang.Object
  extended by org.safs.staf.service.SAFSVariableService
All Implemented Interfaces:
com.ibm.staf.service.STAFServiceInterfaceLevel1, SimpleVarsInterface

public class SAFSVariableService
extends java.lang.Object
implements com.ibm.staf.service.STAFServiceInterfaceLevel1, SimpleVarsInterface

Copyright 2003 SAS Institute GNU General Public License (GPL) http://www.opensource.org/licenses/gpl-license.php

This SAFSVariablesService class is an external STAF service run by the JSTAF Service Proxy.
This acts as a SAFS-aware wrapper for the STAF Variables service.

In a true SAFS environment, Variables (DDVariables) are nearly always tightly integrated with the centralized AppMap service. This is because we allow the retrieval of Variable values to "look thru" to AppMap "constants". And we allow the AppMap to provide dynamic values via Variables for items that are otherwise normally static.

Thus, in a single request for a variable or AppMap value, the search can ping back and forth between Variable and AppMap services until the request is satisfied or we have exhausted the search chain.

Another important issue is that SAFS variables use a different syntax for identifying variables:

Lastly(?), the RESOLVE command will have to process the EXPRESSIONS supported by SAFS.

Oh, additionally, SAFS variable names are not case-sensitive.

The SAFSVariablesService service provides the following commands:

SAFSMAPS Get/Set the associated AppMap service name
HANDLEID Return the handle used by this service
SET Set a variable value
GET Get a variable value
LIST Retrieves the list of all variables/values
RESET Reset and clear all storage--delete everything.
RESOLVE Resolve variables and expressions in a string.
DELETE Delete a variable
COUNT Return the count of variables currently stored
HELP Get HELP on command syntax.

1.0 Service Registration

Each instance of the service must be registered via the STAF Service service.

Example showing comandline registration:

 STAF LOCAL SERVICE ADD SERVICE <servicename> LIBRARY JSTAF /
            EXECUTE org/safs/staf/service/SAFSVariablesService [PARMS <Parameters>]

 SERVICE ADD SERVICE safsvars LIBRARY JSTAF EXECUTE org/safs/staf/service/SAFSVariablesService /
                              PARMS SAFSMAPS "altMapService"
 

By default, the service expects a default "SAFSMAPS" SAFSAppMapService to handle AppMap calls.

1.1 Valid Parameters when registering the service:

1.1.1 SAFSMAPS <servicename>
The SAFSMAPS parameter specifies the name of the service that will provide SAFS AppMap services to this Variables service. If not provided, the Variables service expects a "SAFSMAPS" service to handle requests.

EX: <PARMS> SAFSMAPS "altMapService"

2.0 Commands

2.1 SAFSMAPS

Get or Set the name of the SAFSMAPS service handling AppMap requests for variable resolution.

Syntax:

SAFSMAPS <no parameter> - returns the current SAFSMAPS setting.
SAFSMAPS <servicename> - sets an alternate AppMap service.

2.1.1 <servicename> is the name of an alternate SAFSAppMapService to associate for variables resolution. By default, thes "SAFSMAPS" service is used.

2.2 HANDLEID

Returns the HANDLE associated with the SAFSVariableService.

Syntax:

HANDLEID

2.3 SET

Sets the value of a SAFS variable.

Syntax:

SET <name> VALUE <value>

2.3.1 <name> the name of the variable to "set"

2.3.2 <value> the value to assign the variable

2.4 GET

Returns the value of a SAFS variable.

Syntax:

GET <name>

2.4.1 <<name> the name of the variable to resolve

2.5 DELETE

Delete a variable from storage.

Syntax:

DELETE <name>

2.5.1 <name> the name of the variable to delete

2.6 LIST

The LIST command returns info on each open AppMap for the service.

Syntax:

LIST

2.7 COUNT

The COUNT command returns the count of variables currently stored.

Syntax:

COUNT

2.8 RESET

When implemented, this will reset (DELETE) all stored variables

Syntax:

RESET

2.9 RESOLVE

This will resolve variable values and SAFS expressions in a multi-field, delimited string (a test record). Returns the input strings in a RC:STRING format. The RC is a numeric STAF return code -- hopefully 0 (Ok). Followed by a colon(:), then the actual processed test record.

Syntax:

RESOLVE <string> [SEPARATOR <char>] [NOEXPRESSIONS]

2.9.1 <string> the string (input record) to process for variables and expressions. Note, if the CARET (^) identifying a DDVariable cannot be sent intact the service will accept the string "_DDV_" in place of each intended CARET character and convert it internally before processing.

2.9.2 SEPARATOR <char> an optional single character to use as the field delimiter when processing the input string or record as separate fields, left to right.

2.9.3 NOEXPRESSIONS an optional value to indicate how the input record will have the variables and expressions processed. By default, Expressions are assumed ON. With NOEXPRESSIONS, the input record is handled in the older Substitute/Extract method: only the setting and getting of individual variable values occurs.

2.10 HELP

The HELP command returns this syntax information for service requests.

Syntax:

HELP

Software Automation Framework Support (SAFS) http://safsdev.sourceforge.net
Software Testing Automation Framework (STAF) http://staf.sourceforge.net

See Also:
SAFSAppMapService

Field Summary
protected static com.ibm.staf.STAFHandle client
           
protected static int clients
           
protected  SafsExpression exp
           
protected  com.ibm.staf.service.STAFCommandParser parser
           
protected  boolean service_maps_available
           
protected  java.lang.String servicemaps
           
protected  java.lang.String servicename
           
protected  java.lang.String serviceparms
           
static java.lang.String SVS_CARET
           
static java.lang.String SVS_FALSE_CARET
           
 int SVS_SERVICE_INIT_ARGS_MAX
           
static java.lang.String SVS_SERVICE_PROCESS_NAME
           
 int SVS_SERVICE_REQUEST_ARGS_MAX
           
static java.lang.String SVS_SERVICE_REQUEST_COUNT
           
static java.lang.String SVS_SERVICE_REQUEST_DELETE
           
static java.lang.String SVS_SERVICE_REQUEST_GET
           
static java.lang.String SVS_SERVICE_REQUEST_HANDLEID
           
static java.lang.String SVS_SERVICE_REQUEST_HELP
           
static java.lang.String SVS_SERVICE_REQUEST_LIST
           
static java.lang.String SVS_SERVICE_REQUEST_NOEXPRESSIONS
           
static java.lang.String SVS_SERVICE_REQUEST_RESET
           
static java.lang.String SVS_SERVICE_REQUEST_RESOLVE
           
static java.lang.String SVS_SERVICE_REQUEST_SAFSMAPS
           
static java.lang.String SVS_SERVICE_REQUEST_SEPARATOR
           
static java.lang.String SVS_SERVICE_REQUEST_SET
           
static java.lang.String SVS_SERVICE_REQUEST_VALUE
           
 
Constructor Summary
SAFSVariableService()
          Initialize the class, primarily, the parser used to parse service requests.
 
Method Summary
 com.ibm.staf.STAFResult acceptRequest(java.lang.String machine, java.lang.String process, int handle, java.lang.String request)
          Handle service request from STAF
protected  java.lang.String getHELPInfo()
          our HELP text
 java.lang.String getValue(java.lang.String varname)
          Get the value of a named variable.
 int init(java.lang.String name, java.lang.String params)
          Handle initializing this instance of the service for STAF
 java.lang.String setValue(java.lang.String varname, java.lang.String varvalue)
          Set the value of a named variable.
 int term()
          Handle the request to shutdown the service from STAF
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SVS_SERVICE_REQUEST_ARGS_MAX

public int SVS_SERVICE_REQUEST_ARGS_MAX

SVS_SERVICE_INIT_ARGS_MAX

public int SVS_SERVICE_INIT_ARGS_MAX

SVS_SERVICE_PROCESS_NAME

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

SVS_SERVICE_REQUEST_SAFSMAPS

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

SVS_SERVICE_REQUEST_HANDLEID

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

SVS_SERVICE_REQUEST_COUNT

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

SVS_SERVICE_REQUEST_GET

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

SVS_SERVICE_REQUEST_SET

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

SVS_SERVICE_REQUEST_VALUE

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

SVS_SERVICE_REQUEST_LIST

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

SVS_SERVICE_REQUEST_RESET

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

SVS_SERVICE_REQUEST_RESOLVE

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

SVS_SERVICE_REQUEST_SEPARATOR

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

SVS_SERVICE_REQUEST_NOEXPRESSIONS

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

SVS_SERVICE_REQUEST_DELETE

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

SVS_SERVICE_REQUEST_HELP

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

SVS_CARET

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

SVS_FALSE_CARET

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

parser

protected com.ibm.staf.service.STAFCommandParser parser

servicemaps

protected java.lang.String servicemaps

servicename

protected java.lang.String servicename

serviceparms

protected java.lang.String serviceparms

service_maps_available

protected boolean service_maps_available

clients

protected static int clients

client

protected static com.ibm.staf.STAFHandle client

exp

protected SafsExpression exp
Constructor Detail

SAFSVariableService

public SAFSVariableService()
Initialize the class, primarily, the parser used to parse service requests.

Method Detail

getHELPInfo

protected java.lang.String getHELPInfo()
our HELP text


init

public final int init(java.lang.String name,
                      java.lang.String params)
Handle initializing this instance of the service for STAF

Specified by:
init in interface com.ibm.staf.service.STAFServiceInterfaceLevel1

getValue

public final java.lang.String getValue(java.lang.String varname)
Description copied from interface: SimpleVarsInterface
Get the value of a named variable.

Specified by:
getValue in interface SimpleVarsInterface
Returns:
the current value of the variable, or an empty string.
See Also:
SimpleVarsInterface.getValue(String)

setValue

public final java.lang.String setValue(java.lang.String varname,
                                       java.lang.String varvalue)
Description copied from interface: SimpleVarsInterface
Set the value of a named variable.

Specified by:
setValue in interface SimpleVarsInterface
Returns:
the value as retrieved from the variable after it was set.
See Also:
SimpleVarsInterface.setValue(String, String)

acceptRequest

public final com.ibm.staf.STAFResult acceptRequest(java.lang.String machine,
                                                   java.lang.String process,
                                                   int handle,
                                                   java.lang.String request)
Handle service request from STAF

Specified by:
acceptRequest in interface com.ibm.staf.service.STAFServiceInterfaceLevel1

term

public final int term()
Handle the request to shutdown the service from STAF

Specified by:
term in interface com.ibm.staf.service.STAFServiceInterfaceLevel1