LocalRegistryTest.mesa
Copyright Ó 1990, 1991, 1992 by Xerox Corporation. All rights reserved.
Spreitze, January 14, 1991 1:33 pm PST
DIRECTORY Atom, Commander, CommanderOps, Convert, LocalRegistryAgent, LocalRegistryAgentBackdoor, Rope;
LocalRegistryTest:
CEDAR
PROGRAM
IMPORTS Atom, Commander, CommanderOps, Convert, LocalRegistryAgent, LocalRegistryAgentBackdoor, Rope
= BEGIN
ROPE: TYPE ~ Rope.ROPE;
usage: ROPE ¬ "Usage: MaintainService name regTimeout regPeriod key1 val1 key2 val2 ...";
services: LIST OF LocalRegistryAgent.ServiceRegistration ¬ NIL;
MaintainServiceCmd:
PROC [cmd: Commander.Handle]
RETURNS [result:
REF
ANY ¬
NIL, msg:
ROPE ¬
NIL] ~ {
argv: CommanderOps.ArgumentVector ~ CommanderOps.Parse[cmd];
regTimeout, regPeriod: INT;
propList: LocalRegistryAgent.PropList ¬ NIL;
IF argv.argc<6 OR (argv.argc MOD 2) # 0 THEN RETURN [$Failure, usage];
regTimeout ¬ Convert.IntFromRope[argv[2] !Convert.Error => CommanderOps.Failed[Rope.Cat["Convert.Error when parsing ", argv[2], "as an INT"]] ];
regPeriod ¬ Convert.IntFromRope[argv[3] !Convert.Error => CommanderOps.Failed[Rope.Cat["Convert.Error when parsing ", argv[2], "as an INT"]] ];
FOR i:
NAT
DECREASING
IN [2..argv.argc/2)
DO
propList ¬ Atom.PutPropOnList[propList: propList, prop: Atom.MakeAtom[argv[i*2]], val: argv[i*2+1] ];
ENDLOOP;
services ¬ CONS[LocalRegistryAgent.MaintainService[argv[1], propList, regTimeout, regPeriod], services];
RETURN};
VerboseCommand: Commander.CommandProc ~ {
LocalRegistryAgentBackdoor.SetVerbosity[cmd.procData.clientData = $Verbose]};
Commander.Register["MaintainService", MaintainServiceCmd, "name regTimeout regPeriod key1 val1 key2 val2 ... --- register service with the LocalRegistry"];
Commander.Register["LocalRegistryAgentVerbose", VerboseCommand, "Make LocalRegistryAgentImpl report errors", $Verbose];
Commander.Register["LocalRegistryAgentSilent", VerboseCommand, "Make LocalRegistryAgentImpl suppress errors", $Silent];
END.