SmartFrog 3.10.000

org.smartfrog.sfcore.common
Class ConfigurationDescriptor

java.lang.Object
  extended by org.smartfrog.sfcore.common.ConfigurationDescriptor
All Implemented Interfaces:
MessageKeys

public class ConfigurationDescriptor
extends java.lang.Object
implements MessageKeys

Creating a Configuration Descriptor with options


Nested Class Summary
static class ConfigurationDescriptor.Action
          an enumeration of our options
static class ConfigurationDescriptor.Result
          class acting as an enumeration for results
static class ConfigurationDescriptor.SF1Options
          Special Options for SF1 Language
 
Field Summary
 java.lang.Throwable resultException
          Result exception for action
 java.lang.Object resultObject
          Result Object return by EXEC action
 
Fields inherited from interface org.smartfrog.sfcore.common.MessageKeys
CANNOT_LINK_TO_PREDICATE, COMPONENT_TERMINATED, COPY_FAILED, COPY_SERIALIZE_FAILED, ERROR_NO_SECURITY_BUT_REQUIRED, ILLEGAL_BOOLEAN_PARAMETER, ILLEGAL_NUMERIC_PARAMETER, ILLEGAL_STRING_PARAMETER, ILLEGAL_VECTOR_PARAMETER, LIVENESS_SEND_FAILURE, LIVENESS_SEND_FAILURE_IN, MISSING_PARAMETER, MSG_CLASS_NOT_FOUND, MSG_CONNECT_ERR, MSG_CONT_OTHER_DEPLOY, MSG_DEPLOY_COMP_TERMINATED, MSG_DEPLOY_SUCCESS, MSG_DEPLOYWITH_PHASE_FAILED, MSG_DETACH_SUCCESS, MSG_DETACH_TERMINATE_SUCCESS, MSG_ERR_DEPLOY_FROM_URL, MSG_ERR_PARSE, MSG_ERR_RESOLVE_PHASE, MSG_ERR_SF_RUNNING, MSG_ERR_TERM, MSG_FAILED_INET_ADDRESS_LOOKUP, MSG_FAILED_TO_CONTACT_PARENT, MSG_FILE_NOT_FOUND, MSG_HOOK_ACTION_FAILED, MSG_ILLEGAL_ACCESS, MSG_ILLEGAL_CLASS_TYPE, MSG_ILLEGAL_CLASS_TYPE_EXPECTING_GOT, MSG_ILLEGAL_REFERENCE, MSG_INPUTSTREAM_NULL, MSG_INSTANTIATION_ERROR, MSG_INVALID_OBJECT_TYPE, MSG_INVOCATION_TARGET, MSG_LANG_NOT_FOUND, MSG_LIVENESS_START_FAILED, MSG_LOADING_URL, MSG_METHOD_NOT_FOUND, MSG_NON_REP_ATTRIB, MSG_NOT_COMPONENT_REFERENCE, MSG_NOT_FOUND_ATTRIBUTE, MSG_NOT_FOUND_REFERENCE, MSG_NOT_VALUE_REFERENCE, MSG_NULL_DEF_METHOD, MSG_NULL_URL, MSG_OBJECT_REGISTRATION_FAILED, MSG_PARENT_LOCATION_FAILED, MSG_PING_SUCCESS, MSG_RANDM_ERR, MSG_REMOTE_CONNECT_ERR, MSG_REPEATED_ATTRIBUTE, MSG_SF_DEAD, MSG_SF_READY, MSG_SF_TERMINATED, MSG_STACKTRACE_FOLLOWS, MSG_START_COMP_TERMINATED, MSG_TERMINATE_SUCCESS, MSG_UNHANDLED_EXCEPTION, MSG_UNKNOWN_HOST, MSG_UNRESOLVED_REFERENCE, MSG_UNRESOLVED_REFERENCE_IN, MSG_UPDATE_SUCCESS, MSG_URL_NOT_FOUND, MSG_URL_TO_PARSE_NOT_FOUND, MSG_WARNING_LIVENESS_ENABLED, MSG_WARNING_STACKTRACE_DISABLED, MSG_WARNING_STACKTRACE_ENABLED, ROOT_MUST_BE_COMPONENT, WARN_NO_SECURITY
 
Constructor Summary
ConfigurationDescriptor()
          empty constructor for people who know what they are doing
ConfigurationDescriptor(java.lang.String deploymentURL)
          Creates a Configuration Descriptor using a deployment URL
ConfigurationDescriptor(java.lang.String name, java.lang.String url)
           
ConfigurationDescriptor(java.lang.String name, java.lang.String url, int actionType, java.lang.String host, java.lang.String subProcess)
           
ConfigurationDescriptor(java.lang.String name, java.lang.String url, int actionType, java.lang.String deployReference, java.lang.String host, java.lang.String subProcess)
          Creates Configuration Descriptor
 
Method Summary
 java.lang.Object execute(ProcessCompound targetProcess)
          Performs the nominated action
 int getActionType()
          Gets action type
 Context getContext()
          Get Context
 java.lang.Object getContextAttribute(java.lang.Object name)
          Get Context Attribute
 Reference getDeployReference()
          Gets defined use for final resolve of a configuration
 java.lang.String getHost()
          host for action.
 java.lang.String getName()
          get the name of this component
 java.lang.Object getOption(java.lang.Object name)
          Gets the value from option hashtable
 java.util.Hashtable getOptions()
          get option hashtable.
 java.lang.String getResultMessage()
          Parses resultMessage and resultException and generates one message.
 java.lang.String getResultObjectName()
          get the name of resultObject only if it is a Prim.
 int getResultType()
          Gets result type
 java.lang.String getSubProcess()
          subProcess where to apply action.
 java.lang.String getUrl()
          Get resource to use during action.
static java.lang.String parseExceptionStackTrace(java.lang.Throwable thr, java.lang.String lineSeparator)
          Generates a String for the StackTrace using lineSeparator
 void setActionType(int type)
          set the action type.
 void setActionType(java.lang.String type)
          Sets action type.
 void setContext(Context context)
          Set Context
 Context setContextAttribute(java.lang.Object name, java.lang.Object value)
          Set Context attributes
 void setDeployReference(java.lang.String reference)
          Sets reference use for final resolve of a configuration By default is will use 'sfConfig'.
 void setHost(java.lang.String host)
          host where to apply action.
 void setName(java.lang.String name)
          set the name of this component
 void setOption(java.lang.Object name, java.lang.Object value)
          Adds the name to option hashtable
 void setOptions(java.util.Hashtable options)
          option table
 void setResult(int type, java.lang.String message, java.lang.Throwable thr)
          To set all attributes for any result
 void setSubProcess(java.lang.String subProcess)
          set subProcess where to apply action.
 void setSuccessfulResult()
          Sets result as SUCCESSFULL
 void setUrl(java.lang.String url)
          Set resource to use during action.
 java.lang.String statusString()
          Gets status message using ', ' as separator
 java.lang.String statusString(java.lang.String separator)
          Gets status message
 java.lang.String toString()
          To String
 java.lang.String toString(java.lang.String separator)
          To String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

resultObject

public java.lang.Object resultObject
Result Object return by EXEC action


resultException

public java.lang.Throwable resultException
Result exception for action

Constructor Detail

ConfigurationDescriptor

public ConfigurationDescriptor(java.lang.String deploymentURL)
                        throws SmartFrogInitException
Creates a Configuration Descriptor using a deployment URL

Parameters:
deploymentURL - Format: 'name:ACTION:url:sfConfig:HOST:PROCESS'
      - name: name where to apply ACTION
            ex. foo
            ex. "HOST localhost:foo"
            ex. 'HOST localhost:foo'
      - ACTION: possible actions: DEPLOY, TERMINATE, DETACH, DETaTERM, PING, PARSE, DIAGNOSTICS, UPDATE
      - url: description used by ACTION
            ex. /home/sf/foo.sf
            ex. "c:\sf\foo.sf"
            ex. "c:\My documents\foo.sf"
            ex. 'c:\My documents\foo.sf'
      - target: component description name to use with action. It can be empty
            ex: foo
            ex: "first:foo"
            ex: 'first:foo'
            note: sfConfig cannot be use with DEPLOY!
      - HOST: host name or IP where to apply ACTION. When empty it assumes localhost.
            ex: localhost
            ex: 127.0.0.1
      - PROCESS: process namewhere to apply ACTION. When empty it assumes rootProcess
     ex1: Deploy a description in local daemon
        counterEx:DEPLOY:org/smartfrog/examples/counter/example.sf::localhost:
     ex2. Terminate local sfDaemon
        rootProcess:TERMINATE:::localhost:
     ex3: Deploy "counterToSucceed" from counter/example2.sf
        counterEx3:DEPLOY:org/smartfrog/examples/counter/example2.sf:"testLevel1:counterToSucceed":localhost:
Throws:
SmartFrogInitException - failure in some part of the process
See Also:
ConfigurationDescriptor.Action

ConfigurationDescriptor

public ConfigurationDescriptor(java.lang.String name,
                               java.lang.String url)
Parameters:
name - application/component name
url - resource to use during action. Usually a sf description

ConfigurationDescriptor

public ConfigurationDescriptor(java.lang.String name,
                               java.lang.String url,
                               int actionType,
                               java.lang.String host,
                               java.lang.String subProcess)
                        throws SmartFrogInitException
Parameters:
name - application/component name
url - resource to use during action. Usually a sf description
actionType - @see Action inner class for valid types
host - host were to apply action. Can be null and then no rootProcess is used.
subProcess - subProcess were to apply action. Can be null.
Throws:
SmartFrogInitException

ConfigurationDescriptor

public ConfigurationDescriptor()
empty constructor for people who know what they are doing


ConfigurationDescriptor

public ConfigurationDescriptor(java.lang.String name,
                               java.lang.String url,
                               int actionType,
                               java.lang.String deployReference,
                               java.lang.String host,
                               java.lang.String subProcess)
                        throws SmartFrogInitException,
                               SmartFrogResolutionException
Creates Configuration Descriptor

Parameters:
name - application/component name
url - resource to use during action. Usually a sf description
actionType - @see Action inner class for valid types
deployReference - reference used for final resolve of a configuration
host - host were to apply action. Can be null and then no rootProcess is used.
subProcess - subProcess were to apply action. Can be null.
Throws:
SmartFrogInitException - when a parameter is wrongly defined
SmartFrogResolutionException
Method Detail

toString

public java.lang.String toString()
To String

Overrides:
toString in class java.lang.Object
Returns:
String

toString

public java.lang.String toString(java.lang.String separator)
To String

Parameters:
separator - the separator to be used
Returns:
String

statusString

public java.lang.String statusString()
Gets status message using ', ' as separator

Returns:
status message

statusString

public java.lang.String statusString(java.lang.String separator)
Gets status message

Parameters:
separator - the separator to be used
Returns:
String status message

parseExceptionStackTrace

public static java.lang.String parseExceptionStackTrace(java.lang.Throwable thr,
                                                        java.lang.String lineSeparator)
Generates a String for the StackTrace using lineSeparator

Parameters:
thr - Exception
lineSeparator - the line separartor to be used in the message
Returns:
String Exception message

getDeployReference

public Reference getDeployReference()
Gets defined use for final resolve of a configuration

Returns:
Reference deployReference
See Also:
Reference

setDeployReference

public void setDeployReference(java.lang.String reference)
                        throws SmartFrogResolutionException
Sets reference use for final resolve of a configuration By default is will use 'sfConfig'.

Parameters:
reference -
Throws:
SmartFrogResolutionException - failure in resolving
See Also:
Reference

getActionType

public int getActionType()
Gets action type

Returns:
int action type

setResult

public void setResult(int type,
                      java.lang.String message,
                      java.lang.Throwable thr)
To set all attributes for any result

Parameters:
type - Type of result
message - result message
thr - result exception if it existed
See Also:
inner class

setSuccessfulResult

public void setSuccessfulResult()
Sets result as SUCCESSFULL


setActionType

public void setActionType(int type)
                   throws SmartFrogInitException
set the action type. this also sets the action attribute to an instance of the action which is needed to do the actual execution.

Parameters:
type - action type
Throws:
SmartFrogInitException - if the type is not valid

setActionType

public void setActionType(java.lang.String type)
                   throws SmartFrogInitException
Sets action type.

Parameters:
type - action type
Throws:
SmartFrogInitException - if the type is not valid
See Also:
inner class for valid types

getResultType

public int getResultType()
Gets result type

Returns:
int result type

getResultMessage

public java.lang.String getResultMessage()
Parses resultMessage and resultException and generates one message.

Returns:
String result message

execute

public java.lang.Object execute(ProcessCompound targetProcess)
                         throws SmartFrogException,
                                java.rmi.RemoteException
Performs the nominated action

Parameters:
targetProcess - optional target process; set to null to hand off process lookup to the ConfigurationAction subclass. It keeps a reference to the result object in resultObject.
Returns:
the object created from the operation
Throws:
SmartFrogException - if smartfrog is unhappy
java.rmi.RemoteException - if the network is unhappy

getName

public java.lang.String getName()
get the name of this component

Returns:
String component name

getResultObjectName

public java.lang.String getResultObjectName()
get the name of resultObject only if it is a Prim. Otherways returns null

Returns:
String name of resultObject

setName

public void setName(java.lang.String name)
set the name of this component

Parameters:
name - component name

getUrl

public java.lang.String getUrl()
Get resource to use during action.

Returns:
a url

setUrl

public void setUrl(java.lang.String url)
Set resource to use during action.

Parameters:
url - resource url

getHost

public java.lang.String getHost()
host for action. May be null

Returns:
String hostname

setHost

public void setHost(java.lang.String host)
host where to apply action. Can be null and then no rootProcess is used.

Parameters:
host - hostname

getSubProcess

public java.lang.String getSubProcess()
subProcess where to apply action. Can be null.

Returns:
string or null

setSubProcess

public void setSubProcess(java.lang.String subProcess)
set subProcess where to apply action. Can be null.

Parameters:
subProcess - subProcess name

getOptions

public java.util.Hashtable getOptions()
get option hashtable. This is not a copy; it is a direct accessor to the table.

Returns:
Hashtable option hashtable

setOptions

public void setOptions(java.util.Hashtable options)
option table

Parameters:
options - option hashtable

setOption

public void setOption(java.lang.Object name,
                      java.lang.Object value)
Adds the name to option hashtable

Parameters:
name - Object name
value - value

getOption

public java.lang.Object getOption(java.lang.Object name)
Gets the value from option hashtable

Parameters:
name - Objct name
Returns:
Object value

getContext

public Context getContext()
Get Context

Returns:
Context

setContext

public void setContext(Context context)
Set Context

Parameters:
context - Context

setContextAttribute

public Context setContextAttribute(java.lang.Object name,
                                   java.lang.Object value)
Set Context attributes

Parameters:
name - attribute name
value - attribute value
Returns:
Context

getContextAttribute

public java.lang.Object getContextAttribute(java.lang.Object name)
Get Context Attribute

Parameters:
name - attribute name
Returns:
Object attribute value

SmartFrog CORE 3.10.000

(C) Copyright 1998-2006 Hewlett-Packard Development Company, LP