SmartFrog 3.10.000

org.smartfrog.sfcore.languages.sf.sfcomponentdescription
Class SFComponentDescriptionImpl

java.lang.Object
  extended by org.smartfrog.sfcore.reference.ReferenceResolverHelperImpl
      extended by org.smartfrog.sfcore.componentdescription.ComponentDescriptionImpl
          extended by org.smartfrog.sfcore.languages.sf.sfcomponentdescription.SFComponentDescriptionImpl
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Copying, MessageKeys, PrettyPrinting, ComponentDescription, ComponentResolver, SFComponentDescription, Phases, ReferenceResolver, ReferenceResolverHelper
Direct Known Subclasses:
CSFComponentDescriptionImpl

public class SFComponentDescriptionImpl
extends ComponentDescriptionImpl
implements java.io.Serializable, java.lang.Cloneable, SFComponentDescription, MessageKeys

Defines the context class used by Components. Context implementations need to respect the ordering and copying requirements imposed by Components.

See Also:
Serialized Form

Field Summary
protected  java.util.Vector phases
          cache the resoltion phases for this component - obtained by calls to sfGetPhases().
protected  Reference sfConfigRef
          Reference to sfConfig attribute
 Reference type
          type of description.
 
Fields inherited from class org.smartfrog.sfcore.componentdescription.ComponentDescriptionImpl
eager, parent, primParent, sfContext
 
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
SFComponentDescriptionImpl(Reference type, SFComponentDescription parent, Context cxt, boolean eager)
          Constuctor.
 
Method Summary
 java.lang.Object clone()
          Returns the clone.
 java.lang.Object copy()
          Creates a deep copy of the compiled component.
protected  java.lang.Object copyValue(java.lang.Object v)
           
protected  java.lang.Object copyVector(java.util.Vector v)
           
 void doLinkResolve(ResolutionState resState)
          Internal method to do recursion on link resolution.
 void doPlaceResolve(ResolutionState resState)
          Internal method to do recursion of place resolve.
 void doTypeResolve(ResolutionState resState)
          Internal method to do recursion of type resolve.
 Reference getType()
          Get prototype for this description.
 void linkResolve()
          'Link' resolve a description.
protected  boolean place(Reference key, java.lang.Object value, ResolutionState resState)
          Places an attribute key which is a reference.
 void placeResolve()
          Place resolves the component.
protected  boolean resolveType(ResolutionState resState)
          Does the actual type resolution.
 Reference setType(Reference t)
          Set new type for this component.
 ComponentDescription sfAsComponentDescription()
          Return a component description as required by the deployer.
 java.util.Vector sfGetPhases()
          Public method to get the set of phases defined in the component.
 java.lang.Object sfResolve(Reference r, int index)
          Resolves a refererence starting at given index.
 Phases sfResolvePhase(java.lang.String phase)
          Public method to carry out specific phase.
 Phases sfResolvePhases()
          Public method to carry out specific resolution actions as defined by the phaseList attribute.
 Phases sfResolvePhases(java.util.Vector phases)
          Public method to carry out specific resolution actions as defined by the phases provided.
protected  void subtype(SFComponentDescription superType)
          Subtypes a supertype ino this component.
 java.lang.String toString()
          Returns a string representation of the component.
 void typeResolve()
          Type resolves the component.
 void writeOn(java.io.Writer ps, int indent)
          Writes this component description on a writer.
 
Methods inherited from class org.smartfrog.sfcore.componentdescription.ComponentDescriptionImpl
addSystemProperties, addSystemProperties, getClassComponentDescription, getClassComponentDescription, getEager, initLog, setContext, setEager, setParent, setPrimParent, sfAddAttribute, sfAttributeKeyFor, sfAttributes, sfCompleteName, sfCompleteNameSafe, sfComponentDescription, sfComponentDescription, sfComponentDescription, sfComponentDescription, sfComponentDescriptionFromStr, sfComponentDescriptionFromStr, sfComponentDescriptionFromStr, sfComponentDescriptionFromStr, sfContainsAttribute, sfContainsValue, sfContext, sfDiagnosticsReport, sfLog, sfParent, sfParentageChanged, sfPrimParent, sfRemoveAttribute, sfReplaceAttribute, sfResolve, sfResolveHere, sfResolveHere, sfResolveParent, sfValues, tabPad, visit, visit, visit, visit, writeOn
 
Methods inherited from class org.smartfrog.sfcore.reference.ReferenceResolverHelperImpl
sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolveWithParser
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

phases

protected java.util.Vector phases
cache the resoltion phases for this component - obtained by calls to sfGetPhases().


sfConfigRef

protected Reference sfConfigRef
Reference to sfConfig attribute


type

public Reference type
type of description. The type field is used as a prototype for this description. This means that the attributes of the (super)type are inherited by this component in a structural copy

Constructor Detail

SFComponentDescriptionImpl

public SFComponentDescriptionImpl(Reference type,
                                  SFComponentDescription parent,
                                  Context cxt,
                                  boolean eager)
Constuctor.

Parameters:
type - supertype for component
parent - parent component
cxt - context for description
eager - eager flag
Method Detail

getType

public Reference getType()
Get prototype for this description. This is the component from which attributes get copied into this description.

Specified by:
getType in interface SFComponentDescription
Returns:
type for this description
See Also:
setType(org.smartfrog.sfcore.reference.Reference)

setType

public Reference setType(Reference t)
Set new type for this component.

Specified by:
setType in interface SFComponentDescription
Parameters:
t - new prototype for description
Returns:
old type
See Also:
getType()

copy

public java.lang.Object copy()
Creates a deep copy of the compiled component. Parent, type and eager flag are the same in the copy. Resolvers are blanked in the copy to avoid resolution confusion. Resolution data object reference is copied if it implements the Copying interface, otherwise the pointer is shared with the copy.

Specified by:
copy in interface Copying
Overrides:
copy in class ComponentDescriptionImpl
Returns:
copy of component

clone

public java.lang.Object clone()
Returns the clone.

Specified by:
clone in interface Copying
Overrides:
clone in class ComponentDescriptionImpl
Returns:
an Object clone

sfResolve

public java.lang.Object sfResolve(Reference r,
                                  int index)
                           throws SmartFrogResolutionException
Resolves a refererence starting at given index. If the reference is lazy, it is returned since component descriptions are not supposed to chain on lazy references.

Specified by:
sfResolve in interface ReferenceResolver
Overrides:
sfResolve in class ComponentDescriptionImpl
Parameters:
r - reference to resolve
index - index in reference to start to resolve
Returns:
Object refernce
Throws:
SmartFrogResolutionException - failure while resolving reference

placeResolve

public void placeResolve()
                  throws SmartFrogCompileResolutionException
Place resolves the component. This means iterating a number of times over the description tree, and doing place resolution. Places attributes which have a reference as a key in the right place.

Specified by:
placeResolve in interface ComponentResolver
Throws:
SmartFrogCompileResolutionException - failed to place resolve

doPlaceResolve

public void doPlaceResolve(ResolutionState resState)
                    throws SmartFrogCompileResolutionException
Internal method to do recursion of place resolve.

Specified by:
doPlaceResolve in interface ComponentResolver
Parameters:
resState - resolution state
Throws:
SmartFrogCompileResolutionException - failed to place resolve

place

protected boolean place(Reference key,
                        java.lang.Object value,
                        ResolutionState resState)
Places an attribute key which is a reference. Finds the destination component indicated by the reference and moves the value to the destination (using last reference part in reference). If value is description, it is re-parented, and remembered in the state as needing resolution. Failure to locate the destination description is remembered in the state as well.

Parameters:
key - attribute key
value - attribute value
resState - resolution state

typeResolve

public void typeResolve()
                 throws SmartFrogCompileResolutionException
Type resolves the component. This means iterating a number of times over the description tree, and doing type resolution. Type resolution finds the supertype and subtypes it into this component.

Specified by:
typeResolve in interface ComponentResolver
Throws:
SmartFrogCompileResolutionException - failed to type resolve

doTypeResolve

public void doTypeResolve(ResolutionState resState)
                   throws SmartFrogCompileResolutionException
Internal method to do recursion of type resolve.

Specified by:
doTypeResolve in interface ComponentResolver
Parameters:
resState - resolution state
Throws:
SmartFrogCompileResolutionException - failed to type resolve

resolveType

protected boolean resolveType(ResolutionState resState)
Does the actual type resolution. Looks for super type relative to this description if the first element of the type reference is a HereReferencePart (ie. not a PARENT or ROOT). Subtypes supertype into this description if found.

Parameters:
resState - resolution state to maintain unresolved types
Returns:
true if resolved, false if not

subtype

protected void subtype(SFComponentDescription superType)
Subtypes a supertype ino this component. Copies the type of the superType into this description. Also copies any attributes which are not in this description into it.

Parameters:
superType - super type to copy from

linkResolve

public void linkResolve()
                 throws SmartFrogCompileResolutionException
'Link' resolve a description. This involves iterating over the description tree a number of times and looking at the attribute values. If the value is an eager reference, it is resolved. The resulting value replaces the reference as the attribute value

Specified by:
linkResolve in interface ComponentResolver
Throws:
SmartFrogCompileResolutionException - failed to deploy resolve

doLinkResolve

public void doLinkResolve(ResolutionState resState)
                   throws SmartFrogCompileResolutionException
Internal method to do recursion on link resolution.

Specified by:
doLinkResolve in interface ComponentResolver
Parameters:
resState - resolution state
Throws:
SmartFrogCompileResolutionException - failed to deploy resolve

toString

public java.lang.String toString()
Returns a string representation of the component. This will give a description of the component which is parseable, and deployable again... Unless someone removed attributes which are essential to startup that is. Large description trees should be written out using writeOn since memory for large strings runs out quick!

Specified by:
toString in interface ComponentDescription
Overrides:
toString in class ComponentDescriptionImpl
Returns:
string representation of component

writeOn

public void writeOn(java.io.Writer ps,
                    int indent)
             throws java.io.IOException
Writes this component description on a writer. Used by toString. Should be used instead of toString to write large descriptions to file, since memory can become a problem given the LONG strings created

Specified by:
writeOn in interface PrettyPrinting
Overrides:
writeOn in class ComponentDescriptionImpl
Parameters:
ps - writer to write on
indent - the indent to use for printing offset
Throws:
java.io.IOException - failure while writing

sfAsComponentDescription

public ComponentDescription sfAsComponentDescription()
                                              throws SmartFrogCompilationException
Return a component description as required by the deployer. Works by side-effect on the SFComponentDescription for efficiency. This becomes uniseable after the conversion.

Specified by:
sfAsComponentDescription in interface Phases
Returns:
the equivalent component descriptino
Throws:
SmartFrogCompilationException - error converting phases to a componentdescription

copyValue

protected java.lang.Object copyValue(java.lang.Object v)
                              throws SmartFrogCompilationException
Throws:
SmartFrogCompilationException

copyVector

protected java.lang.Object copyVector(java.util.Vector v)
                               throws SmartFrogCompilationException
Throws:
SmartFrogCompilationException

sfResolvePhases

public Phases sfResolvePhases()
                       throws SmartFrogException
Public method to carry out specific resolution actions as defined by the phaseList attribute. This attribute is removed as part of the resolution. The phases are defined by the sfGetPhases method.

Specified by:
sfResolvePhases in interface Phases
Returns:
the resultant Phases object, ready for the next phase action or convertion into the core ComponentDescription
Throws:
SmartFrogException - In case of SmartFrog system error

sfResolvePhase

public Phases sfResolvePhase(java.lang.String phase)
                      throws SmartFrogException
Public method to carry out specific phase.

Specified by:
sfResolvePhase in interface Phases
Parameters:
phase - The phase to carry out
Returns:
the resultant Phases object, ready for the next phase action or convertion into the core ComponentDescription
Throws:
SmartFrogException - In case of SmartFrog system error

sfResolvePhases

public Phases sfResolvePhases(java.util.Vector phases)
                       throws SmartFrogException
Public method to carry out specific resolution actions as defined by the phases provided.

Specified by:
sfResolvePhases in interface Phases
Parameters:
phases - a vector of strings defining the names of the phases
Returns:
the resultant Phases object, ready for the next phase action or convertion into the core ComponentDescription
Throws:
SmartFrogException - In case of SmartFrog system error

sfGetPhases

public java.util.Vector sfGetPhases()
Public method to get the set of phases defined in the component. This will either be the phaseList attribute, or the standard set defined as though the phaseList attribute had been defined phaseList ["type", "place", "sfConfig", "link", "function"]; The attribute is removed to tidy the definition, but the result is cached for later use

Specified by:
sfGetPhases in interface Phases
Returns:
Vector of Phases

SmartFrog CORE 3.10.000

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