|
SmartFrog 3.10.000 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.smartfrog.sfcore.reference.RemoteReferenceResolverHelperImpl
org.smartfrog.sfcore.prim.PrimImpl
public class PrimImpl
Defines the base class for all deployed components. A deployed component knows how to react to termination, deployment requests and heart beats. This implementation allows subclasses to define how a deployed component is communicated with. The sfExport attribute is examined. If set to "true" the sfExportRef method is called, which by default uses RMI to export the component. Subclasses may choose to export a component another way.
A liveness thread is started for a primitive if it has no parent, but is expected to have children (like Compound), or if the parent is remote. Liveness attribute sfLivenessDelay dictates how often (in seconds) sfPing is supposed to be called. sfLivenessFactor is the multiplier for sfLivenessDelay to wait until the primitive declares that there is a liveness failure. Both attributes are looked up using ATTRIB in order to find out whether a parent has set liveness on.
| Field Summary | |
|---|---|
protected static Reference |
refLivenessDelay
Reference used to look up sfLivenessDelay attributes. |
protected static Reference |
refLivenessFactor
Reference used to look up sfLivenessFactor attributes. |
protected Reference |
sfCompleteName
Reference that caches cannonical name. |
protected Context |
sfContext
Attribute context. |
static PrimHookSet |
sfDeployHooks
Static attribute that hold the lifecycle hooks for sfDeploy. |
static PrimHookSet |
sfDeployWithHooks
Static attribute that hold the lifecycle hooks for sfDeployWith. |
protected java.lang.Object |
sfExportRef
Reference to export form of self if sfExport is true. |
protected boolean |
sfIsDeployed
Flag indicating that this component has been deployed. |
protected boolean |
sfIsStarted
Flag indicating that this component has been started. |
protected boolean |
sfIsTerminated
Flag indicating that this component has been terminated. |
protected boolean |
sfIsTerminating
Flag indicating that this component termination is initiated. |
protected int |
sfLivenessCount
Current count for liveness, updated through sfPing. |
protected long |
sfLivenessDelay
How often to send liveness in seconds. |
protected int |
sfLivenessFactor
Livneess factor. |
protected LivenessSender |
sfLivenessSender
Timer for initiating heartbeats. |
protected Prim |
sfParent
Parent. |
static PrimHookSet |
sfStartHooks
Static attribute that hold the lifecycle hooks for sfStart. |
static PrimHookSet |
sfTerminateWithHooks
Static attribute that hold the lifecycle hooks for sfTerminateWith. |
protected java.lang.Object |
termLock
|
| Constructor Summary | |
|---|---|
PrimImpl()
Used in conjunction with sfDeployWith to set parent and context after creation. |
|
| Method Summary | |
|---|---|
boolean |
equals(java.lang.Object o)
Implemented to provide for remote equality checking. |
int |
hashCode()
Returns the hashcode for the exported object if it was exported, the object itself if not. |
protected void |
registerWithProcessCompound()
Registers component with local ProcessCompound only if it is root component, its parent is remote or the attribute sfProcessComponentName is defined. |
java.lang.Object |
sfAddAttribute(java.lang.Object name,
java.lang.Object value)
Adds an attribute to this component under given name. |
java.lang.Object |
sfAttributeKeyFor(java.lang.Object value)
Returns the attribute key given a value. |
java.util.Iterator |
sfAttributes()
Returns an ordered iterator over the attribute names in this component. |
Reference |
sfCompleteName()
Returns the complete name for this component from the root of the application. |
Reference |
sfCompleteNameSafe()
Returns the complete name for this component from the root of the application and does not throw any exception. |
boolean |
sfContainsAttribute(java.lang.Object attribute)
Returns true if the context contains attribute. |
boolean |
sfContainsValue(java.lang.Object value)
Returns true if the context contains value. |
Context |
sfContext()
Returns the context of this component. |
void |
sfDeploy()
Called after instantiation for deployment purposes. |
java.net.InetAddress |
sfDeployedHost()
Request the host on which this component is deployed. |
java.lang.String |
sfDeployedProcessName()
Request the process in which this component is deployed, the name being that defined in the sfProcessName attribute or the string ROOT if in the root process compound. |
void |
sfDeployWith(Prim parent,
Context cxt)
Private method to set up newly created component. |
void |
sfDetach()
Get this object to detach from its parent. |
void |
sfDetachAndTerminate(TerminationRecord status)
Get this object to terminate, after detaching itself from its parent. |
ComponentDescription |
sfDiagnosticsReport()
Creates diagnostics report |
void |
sfDumpState(Dump target)
Default dump state behavior is to send the context to the target. |
protected java.lang.Object |
sfExport(java.lang.Object portObj)
Exports this component using portObj. |
java.lang.Object |
sfExportRef()
Export this primitive to accept remote method calls using an anonymous port. |
java.lang.Object |
sfExportRef(int port)
Export this primitive to accept remote method calls using port. |
LogSF |
sfGetApplicationLog()
To get application logger using ROOT name. |
LogSF |
sfGetCoreLog()
To get the sfCore logger |
LogSF |
sfGetLog(java.lang.String name)
To get a logger with a particular name. |
boolean |
sfIsDeployed()
Returns value of flag indicating if this component has been deployed. |
protected boolean |
sfIsRemote(java.lang.Object o)
Checks whether given object is a non-local object. |
boolean |
sfIsStarted()
Returns value of flag indicating if this component has been started. |
boolean |
sfIsTerminated()
Returns value of flag indicating if this component has been terminated. |
boolean |
sfIsTerminating()
Returns value of flag indicating if this component is terminating. |
protected void |
sfLivenessFailure(java.lang.Object source,
java.lang.Object target,
java.lang.Throwable failure)
Handle ping failures. |
LogSF |
sfLog()
To log into sfCore logger. |
Prim |
sfParent()
Returns the parent of this component. |
void |
sfParentageChanged()
Parentage changed in component hierachy. |
void |
sfPing(java.lang.Object source)
Liveness call in to check if this component is still alive. |
java.lang.Object |
sfRemoveAttribute(java.lang.Object name)
Removes an attribute from this component. |
java.lang.Object |
sfReplaceAttribute(java.lang.Object name,
java.lang.Object value)
Replace named attribute in component context. |
java.lang.Object |
sfResolve(Reference r)
Resolves a given reference. |
java.lang.Object |
sfResolve(Reference r,
int index)
Resolves given reference starting at given index. |
java.lang.Object |
sfResolveHere(java.lang.Object name)
Find an attribute in this component context. |
java.lang.Object |
sfResolveHere(java.lang.Object name,
boolean mandatory)
Find an attribute in this context. |
java.lang.Object |
sfResolveParent()
Returns the parent for this component. |
LogSF |
sfSetLog(LogSF newlog)
Method to replace logger used by components. |
void |
sfStart()
Can be called to start components. |
protected void |
sfStartLivenessSender()
initializes and starts the liveness sender for this primitive. |
protected void |
sfStopLivenessSender()
Stops the liveness sender if this component has one. |
void |
sfTerminate(TerminationRecord status)
Request this component to terminate. |
void |
sfTerminatedWith(TerminationRecord status,
Prim comp)
Called from sub-component (normally) to indicate termination. |
void |
sfTerminateQuietlyWith(TerminationRecord status)
Called from up the containment tree to terminate. |
protected void |
sfTerminateWith(TerminationRecord status)
Provides hook for subclasses to implement useful termination behavior. |
java.util.Iterator |
sfValues()
Returns an ordered iterator over the attibute values in this component. |
protected void |
terminateComponent(Prim targetComponent,
java.lang.Throwable excp,
Reference componentId)
Terminates the component in a seperate thread. |
protected void |
terminateNotifying(TerminationRecord status,
Prim comp)
Notifies a component that this component has terminated through sfTerminatedWith and calls the local hook (sfTerminateWith). |
java.lang.String |
toString()
Returns the string of the remote reference if this primitive was exported, the superclass toString if not. |
| Methods inherited from class org.smartfrog.sfcore.reference.RemoteReferenceResolverHelperImpl |
|---|
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 |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.smartfrog.sfcore.reference.RemoteReferenceResolverHelper |
|---|
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 |
| Field Detail |
|---|
public static final PrimHookSet sfDeployHooks
public static final PrimHookSet sfStartHooks
public static final PrimHookSet sfDeployWithHooks
public static final PrimHookSet sfTerminateWithHooks
protected static final Reference refLivenessDelay
protected static final Reference refLivenessFactor
protected boolean sfIsTerminated
protected boolean sfIsTerminating
protected boolean sfIsDeployed
protected boolean sfIsStarted
protected Prim sfParent
protected Context sfContext
protected LivenessSender sfLivenessSender
protected int sfLivenessCount
protected int sfLivenessFactor
protected long sfLivenessDelay
protected java.lang.Object sfExportRef
protected Reference sfCompleteName
protected final java.lang.Object termLock
| Constructor Detail |
|---|
public PrimImpl()
throws java.rmi.RemoteException
java.rmi.RemoteException - In case of network/rmi error| Method Detail |
|---|
public java.lang.Object sfResolveHere(java.lang.Object name)
throws SmartFrogResolutionException
sfResolveHere in interface RemoteReferenceResolvername - attribute key to resolve
SmartFrogResolutionException - failed to find attribute
public java.lang.Object sfResolveHere(java.lang.Object name,
boolean mandatory)
throws SmartFrogResolutionException
sfResolveHere in interface RemoteReferenceResolvername - attribute key to resolvemandatory - boolean that indicates if this attribute must be
present in the description. If it is mandatory and not found it
throws a SmartFrogResolutionException
SmartFrogResolutionException - failed to find attributepublic java.lang.Object sfResolveParent()
sfResolveParent in interface RemoteReferenceResolver
public java.lang.Object sfResolve(Reference r)
throws SmartFrogResolutionException,
java.rmi.RemoteException
sfResolve in interface RemoteReferenceResolversfResolve in class RemoteReferenceResolverHelperImplr - reference to resolve
SmartFrogResolutionException - occurred while resolving
java.rmi.RemoteException - In case of network/rmi error
public java.lang.Object sfResolve(Reference r,
int index)
throws SmartFrogResolutionException,
java.rmi.RemoteException
sfResolve in interface RemoteReferenceResolversfResolve in class RemoteReferenceResolverHelperImplr - reference to resolveindex - index in reference to start resolving
SmartFrogResolutionException - error occurred while resolving
java.rmi.RemoteException - In case of network/rmi error
public java.net.InetAddress sfDeployedHost()
throws java.rmi.RemoteException
sfDeployedHost in interface Primjava.rmi.RemoteException - In case of network/rmi error
public java.lang.String sfDeployedProcessName()
throws java.rmi.RemoteException
sfDeployedProcessName in interface Primjava.rmi.RemoteException - In case of Remote/network error
public java.lang.Object sfAddAttribute(java.lang.Object name,
java.lang.Object value)
throws SmartFrogRuntimeException,
java.rmi.RemoteException
sfAddAttribute in interface Primname - name of attributevalue - value of attribute
SmartFrogRuntimeException - when name or value are null
java.rmi.RemoteException - In case of Remote/nework error
public java.lang.Object sfRemoveAttribute(java.lang.Object name)
throws SmartFrogRuntimeException,
java.rmi.RemoteException
sfRemoveAttribute in interface Primname - of attribute to be removed
SmartFrogRuntimeException - when name is null
java.rmi.RemoteException - In case of Remote/nework error
public java.lang.Object sfReplaceAttribute(java.lang.Object name,
java.lang.Object value)
throws SmartFrogRuntimeException,
java.rmi.RemoteException
sfReplaceAttribute in interface Primname - of attribute to replacevalue - value to add or replace
SmartFrogRuntimeException - when name or value are null
java.rmi.RemoteException - In case of Remote/nework errorpublic java.lang.Object sfAttributeKeyFor(java.lang.Object value)
sfAttributeKeyFor in interface Primvalue - value to look up key for
public boolean sfContainsValue(java.lang.Object value)
throws java.rmi.RemoteException
sfContainsValue in interface Primvalue - object to check
java.rmi.RemoteException - In case of Remote/nework error
public boolean sfContainsAttribute(java.lang.Object attribute)
throws java.rmi.RemoteException
sfContainsAttribute in interface Primattribute - to check
java.rmi.RemoteException - In case of Remote/nework error
public java.util.Iterator sfAttributes()
throws java.rmi.RemoteException
sfAttributes in interface Primjava.rmi.RemoteException - In case of Remote/nework error
public java.util.Iterator sfValues()
throws java.rmi.RemoteException
sfValues in interface Primjava.rmi.RemoteException - In case of Remote/nework errorpublic Context sfContext()
sfContext in interface Prim
public Reference sfCompleteName()
throws java.rmi.RemoteException
sfCompleteName in interface Primjava.rmi.RemoteException - In case of network/rmi errorpublic Reference sfCompleteNameSafe()
sfCompleteNameSafe in class RemoteReferenceResolverHelperImpl
public Prim sfParent()
throws java.rmi.RemoteException
sfParent in interface Primjava.rmi.RemoteException - In case of Remote/nework error
public void sfDeployWith(Prim parent,
Context cxt)
throws SmartFrogDeploymentException,
java.rmi.RemoteException
sfDeployWith in interface Primparent - parent of componentcxt - context for component
SmartFrogDeploymentException - In case of any error while
deploying the component
java.rmi.RemoteException - In case of network/rmi error
protected java.lang.Object sfExport(java.lang.Object portObj)
throws java.rmi.RemoteException,
java.rmi.RemoteException,
SmartFrogException
portObj - Object
java.rmi.RemoteException - In case of Remote/nework error
SmartFrogException - if failed to export
protected void registerWithProcessCompound()
throws java.rmi.RemoteException,
SmartFrogException
java.rmi.RemoteException - In case of Remote/nework error
SmartFrogException - if failed to register
public java.lang.Object sfExportRef(int port)
throws SmartFrogException
port - where to export. If 0, it will use any port available.
SmartFrogException - failed to export primitive
public java.lang.Object sfExportRef()
throws SmartFrogException
SmartFrogException - failed to export primitive
protected void sfStartLivenessSender()
throws SmartFrogLivenessException
SmartFrogLivenessException - failed to initialize or start senderprotected void sfStopLivenessSender()
protected boolean sfIsRemote(java.lang.Object o)
o - object to check remoteness on
public void sfDeploy()
throws SmartFrogException,
java.rmi.RemoteException
sfDeploy in interface PrimSmartFrogException - error while deploying
java.rmi.RemoteException - In case of network/rmi error
public void sfStart()
throws SmartFrogException,
java.rmi.RemoteException
sfStart in interface PrimSmartFrogException - failure while starting
java.rmi.RemoteException - In case of network/rmi errorpublic void sfDumpState(Dump target)
sfDumpState in interface Primtarget - dump interface to dump topublic void sfTerminate(TerminationRecord status)
sfTerminate in interface Primstatus - termination status recordprotected void sfTerminateWith(TerminationRecord status)
status - termination status
protected void terminateNotifying(TerminationRecord status,
Prim comp)
status - termination statuscomp - component to notify of termination
public void sfDetach()
throws SmartFrogException,
java.rmi.RemoteException
sfDetach in interface PrimSmartFrogException - detachment failed
java.rmi.RemoteException - In case of network/rmi errorpublic void sfDetachAndTerminate(TerminationRecord status)
sfDetachAndTerminate in interface Primstatus - termination status
public void sfTerminatedWith(TerminationRecord status,
Prim comp)
sfTerminatedWith in interface Primstatus - termination statuscomp - component that has terminatedpublic void sfTerminateQuietlyWith(TerminationRecord status)
sfTerminateQuietlyWith in interface Primstatus - termination status
public void sfPing(java.lang.Object source)
throws SmartFrogLivenessException,
java.rmi.RemoteException
sfPing in interface Livenesssource - source of call
SmartFrogLivenessException - component is terminated
java.rmi.RemoteException - for consistency with the Liveness interface
protected void sfLivenessFailure(java.lang.Object source,
java.lang.Object target,
java.lang.Throwable failure)
source - source of updatetarget - target that update was trying to reachfailure - error that occurredpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - object to compare with
public int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object
protected void terminateComponent(Prim targetComponent,
java.lang.Throwable excp,
Reference componentId)
targetComponent - The component that encountered the errorexcp - The error that caused the terminationcomponentId - Component Identifierpublic LogSF sfLog()
public LogSF sfSetLog(LogSF newlog)
newlog - replacement for Prim core log
public LogSF sfGetLog(java.lang.String name)
name - logger name
public LogSF sfGetCoreLog()
public LogSF sfGetApplicationLog()
throws SmartFrogException,
java.rmi.RemoteException
SmartFrogCoreKeys.SF_APP_LOG_NAME
If this attribute has been pre-set then it is used to get the application logger,
otherwise ROOT cannonical name is used.
SmartFrogException - if failed
java.rmi.RemoteException - In case of Remote/nework error
public void sfParentageChanged()
throws java.rmi.RemoteException
sfParentageChanged in interface Primjava.rmi.RemoteException - In case of Remote/nework errorpublic boolean sfIsTerminated()
sfIsTerminated in interface Primpublic boolean sfIsTerminating()
sfIsTerminating in interface Primpublic boolean sfIsDeployed()
sfIsDeployed in interface Primpublic boolean sfIsStarted()
sfIsStarted in interface Primpublic ComponentDescription sfDiagnosticsReport()
sfDiagnosticsReport in interface Diagnostics
|
SmartFrog CORE 3.10.000 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||