net.ponder2
Class SelfManagedCell

java.lang.Object
  extended by net.ponder2.Domain
      extended by net.ponder2.SelfManagedCell
All Implemented Interfaces:
ManagedObject

public class SelfManagedCell
extends Domain
implements ManagedObject

The top level root domain of the whole system. Contains main() to start the whole thing off

Version:
$Id: SelfManagedCell.java,v 1.20 2006/03/15 13:36:42 kpt Exp $
Author:
Kevin Twidle

Field Summary
static java.lang.String EventDomain
           
static java.lang.String PolicyDomain
           
static int port
           
static P2Object RootDomain
           
static java.util.Map<java.lang.String,P2Object> startupArgs
           
static java.lang.String[] startupArgsArray
           
static java.lang.String SVNDate
           
static java.lang.String SVNRevision
           
static boolean SystemTrace
           
 
Constructor Summary
SelfManagedCell(P2Object myP2Object)
          creates a new SelfManagedCell domain.
 
Method Summary
protected  void address(java.lang.String anAddress)
          Loads a communications protocol and sets the SMC's local address to anAddress.
protected  P2Object argsAsArray()
          answers with an array containing all the user supplied arguments to the SMC.
protected  P2Object argsAsHash()
          answers with a hash containing the user supplied arguments to the SMC.
protected  P2Object execute(P2Object source, P2Block aBlock)
          Executes aBlock with no arguments.
protected  P2Object executeArgs(P2Object source, P2Block aBlock, P2Array anArray)
          Executes aBlock with anArray of arguments.
protected  P2Object executeHash(P2Object source, P2Block aBlock, P2Hash aHash)
          Executes aBlock with the values of its arguments being taken by name from aHash.
protected  void exit()
          Terminates the Ponder2 SMC with a zero status
protected  void exit(int exitStatus)
          Terminates the Ponder2 SMC with exitStatus
static boolean getDefaulAuthPolicy()
           
 java.lang.String getFile(java.lang.String aFileName)
          Reads a text file called aFileName into a string and returns it.
static void main(java.lang.String[] args)
          starts the whole system running
protected  long memory()
          answers with the amount of free memory in the Java VM
protected  P2Object operation_import_from(java.lang.String aName, java.lang.String aLocation)
          Answers the remote managed object which has aName belonging to an SMC at aLocation.
protected  P2Object operation_load(java.lang.String anObject)
          Loads the code necessary for creating an instance of anObject.
static boolean ping(java.lang.String location)
          Pings remote SMC to see if it is alive.
protected  java.lang.String print(java.lang.String aString)
          Answers aString.
 void read(P2Object source, java.lang.String aUrl)
          Reads and executes PonderTalk from aUrl.
 void read(P2Object source, java.lang.String aUrl, P2Hash varHash)
          Reads and executes PonderTalk from aUrl.
 P2Object readString(P2Object source, java.lang.String aPonderTalkString)
          Reads and executes PonderTalk from aPonderTalkString.
 P2Object readString(P2Object source, java.lang.String aPonderTalkString, P2Hash varHash)
          Reads and executes PonderTalk from aPonderTalkString.
protected  void sleep(int secs)
          Sleeps for secs seconds
static void start(java.lang.String[] args)
          starts the whole system running and returns the root OID.
protected  boolean trace(boolean aBoolean)
          Answers aBoolean.
 
Methods inherited from class net.ponder2.Domain
add, contains, contains, get, names, operation_asHash, operation_at_add, operation_at, operation_at, operation_collect, operation_do, operation_listNames, operation_listObjects, operation_remove, operation_resolve, remove, removeAll, removeObject, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SVNDate

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

SVNRevision

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

SystemTrace

public static boolean SystemTrace

EventDomain

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

PolicyDomain

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

RootDomain

public static P2Object RootDomain

port

public static int port

startupArgs

public static java.util.Map<java.lang.String,P2Object> startupArgs

startupArgsArray

public static java.lang.String[] startupArgsArray
Constructor Detail

SelfManagedCell

public SelfManagedCell(P2Object myP2Object)
creates a new SelfManagedCell domain. This is normally the root domain of an SMC. It contains code for loading other objects, printing etc.

Method Detail

argsAsHash

protected P2Object argsAsHash()
answers with a hash containing the user supplied arguments to the SMC. User supplied arguments are those after an argument of '-' by itself.

The arguments are interpreted as key=>value pairs where the key is an argument starting with a '-'. A value cannot start with a '-', it is taken to be the next key instead. The hash is indexed with the names of the keys without the '-'. If a value follows a key then it is included as the value in the hash. If a value is found without a preceding key, it is ignored. In the following example "copper" will be lost.

-a -b gold -c silver copper -d

becomes

 a => ""
 b => gold
 c => silver
 d => ""
 

Returns:
a hash containing the user, run-time arguments

argsAsArray

protected P2Object argsAsArray()
answers with an array containing all the user supplied arguments to the SMC. User supplied arguments are those after an argument of '-' by itself. All arguments are added to the array as-is, any '-' characters are left intact.

Returns:
an array containing all the user, run-time arguments

sleep

protected void sleep(int secs)
Sleeps for secs seconds

Parameters:
secs -

exit

protected void exit()
Terminates the Ponder2 SMC with a zero status


exit

protected void exit(int exitStatus)
Terminates the Ponder2 SMC with exitStatus

Parameters:
exitStatus -

address

protected void address(java.lang.String anAddress)
                throws Ponder2RemoteException
Loads a communications protocol and sets the SMC's local address to anAddress. This is functionally the same as using the -address argument when running Ponder2, however, it means that communications can be delayed until the domain structure is setup correctly

Parameters:
anAddress - the new address as a string in the correct format for the protocol chosen
Throws:
Ponder2RemoteException - if the protocol cannot be loaded properly

operation_load

protected P2Object operation_load(java.lang.String anObject)
                           throws Ponder2Exception
Loads the code necessary for creating an instance of anObject. Answers the factory for creating instances of anObject.

Throws:
Ponder2Exception

ping

public static boolean ping(java.lang.String location)
                    throws Ponder2Exception
Pings remote SMC to see if it is alive. Answers true if it is.

Parameters:
location - address of remote site
Returns:
true if the remote is alive
Throws:
Ponder2Exception

operation_import_from

protected P2Object operation_import_from(java.lang.String aName,
                                         java.lang.String aLocation)
                                  throws Ponder2Exception
Answers the remote managed object which has aName belonging to an SMC at aLocation.

Throws:
Ponder2Exception

memory

protected long memory()
answers with the amount of free memory in the Java VM

Returns:
the amount of free memory

read

public void read(P2Object source,
                 java.lang.String aUrl)
          throws Ponder2Exception
Reads and executes PonderTalk from aUrl.

Parameters:
source -
aUrl -
Throws:
Ponder2Exception

read

public void read(P2Object source,
                 java.lang.String aUrl,
                 P2Hash varHash)
          throws Ponder2Exception
Reads and executes PonderTalk from aUrl. The parser is initialized with the variables in the P2Hash varHash

Parameters:
source -
aUrl -
Throws:
Ponder2Exception

readString

public P2Object readString(P2Object source,
                           java.lang.String aPonderTalkString)
                    throws Ponder2Exception
Reads and executes PonderTalk from aPonderTalkString.

Throws:
Ponder2Exception

readString

public P2Object readString(P2Object source,
                           java.lang.String aPonderTalkString,
                           P2Hash varHash)
                    throws Ponder2Exception
Reads and executes PonderTalk from aPonderTalkString. The parser is initialised with the variables in the P2Hash varHash

Throws:
Ponder2Exception

getFile

public java.lang.String getFile(java.lang.String aFileName)
                         throws Ponder2OperationException
Reads a text file called aFileName into a string and returns it.

Parameters:
aFileName -
Returns:
the contents of the file
Throws:
Ponder2OperationException

trace

protected boolean trace(boolean aBoolean)
Answers aBoolean. Set system tracing on or off.


print

protected java.lang.String print(java.lang.String aString)
Answers aString. Displays aString on the console.


execute

protected P2Object execute(P2Object source,
                           P2Block aBlock)
                    throws Ponder2Exception
Executes aBlock with no arguments. Answers with the answer from aBlock. Used to force execution of a block within a particular SMC.

Throws:
Ponder2Exception

executeHash

protected P2Object executeHash(P2Object source,
                               P2Block aBlock,
                               P2Hash aHash)
                        throws Ponder2Exception
Executes aBlock with the values of its arguments being taken by name from aHash. Answers the value of the last statement executed by the block. Throws an error if aHash does not satisfy the block's arguments. Used to force execution of a block within a particular SMC.

Throws:
Ponder2Exception

executeArgs

protected P2Object executeArgs(P2Object source,
                               P2Block aBlock,
                               P2Array anArray)
                        throws Ponder2Exception
Executes aBlock with anArray of arguments. Answers with the result of the last statement executed by the block. Used to force execution of a block within a particular SMC.

Throws:
Ponder2Exception

getDefaulAuthPolicy

public static boolean getDefaulAuthPolicy()

start

public static void start(java.lang.String[] args)
starts the whole system running and returns the root OID. The root OID can be useful for starting the SMC from within a Java VM.

Parameters:
args - see doc for argument values and meanings

main

public static void main(java.lang.String[] args)
starts the whole system running

Parameters:
args - see doc for argument values and meanings


Copyright © 2008 Imperial College. All Rights Reserved.