Ponder2 Bootstrap

The Ponder2 SMC comprises a completely empty root domain when it starts up. The bootstrap code below is executed to give the initial structure to avoid the user having to write it for each application. The PonderTalk code is followed by the bootstrap that was used by the previous version of Ponder2 when XML was used as the configuration/command language. Both sets of code are fully commented; it can be seen that the new code is considerably more readable than the old.

The option -boot - can be given to Ponder2 when it is started to prevent the loading of this bootstrap code.

   1 // Bootstrap code for Ponder2
   2 
   3 // Import the Domain code and create the default domains
   4 root add: "domaintemplate" obj: ( root import: "Domain" );
   5      add: "template" obj: root/domaintemplate create;
   6      add: "policy" obj: root/domaintemplate create;
   7      add: "event" obj: root/domaintemplate create.
   8 
   9 // Move the domain template into the template directory
  10 root/template add: "domain" obj: root/domaintemplate.
  11 root remove: "domaintemplate".
  12 
  13 // Import event and policy templates
  14 root/template add: "event" obj: ( root import: "EventTemplate" );
  15               add: "policy" obj: ( root import: "Policy" ).

<?xml version="1.0" encoding="UTF-8"?>
<!-- First import a Domain type, create a Template domain and move the Domain type to the new domain -->
<xml>
        <!-- Import the template for creating domains -->
        <use name="/">
                <!-- /.add("domaintemplate",import(Domain) -->
                <add name="domaintemplate">
                        <use name="/">
                                <import name="Domain" />
                        </use>
                </add>
                <!-- /.add("template",/domaintemplate.create()) -->
                <add name="template">
                        <use name="/domaintemplate">
                                <create />
                        </use>
                </add>
        </use>
        <!-- Link the Domain template into the new domain -->
        <use name="/template">
                <!-- /template.link("domain", "/domaintemplate") -->
                <link name="domain" object="/domaintemplate" />
        </use>
        <!-- Unlink the original temporary template -->
        <use name="/">
                <!-- /.remove(domaintemplate) -->
                <remove name="domaintemplate" />
        </use>
        <!-- Create the framework domains -->
        <use name="/">
                <!-- /.add("policy", /template/domain.create()) -->
                <add name="policy">
                        <use name="/template/domain">
                                <create />
                        </use>
                </add>
                <!-- /.add("event", /template/domain.create()) -->
                <add name="event">
                        <use name="/template/domain">
                                <create />
                        </use>
                </add>
        </use>
        <!--  We need to create events -->
        <use name="/template">
                <!-- /template.add("event", import(policy.EventTemplate)) -->
                <add name="event">
                        <use name="/">
                                <import name="EventTemplate" />
                        </use>
                </add>
        </use>
        <!-- We need to create policies -->
        <use name="/template">
                <!-- /template.add("event", import(policy.Policy)) -->
                <add name="policy">
                        <use name="/">
                                <import name="Policy" />
                        </use>
                </add>
        </use>
</xml>

Ponder2Bootstrap (last edited 2008-02-12 10:00:17 by KevinTwidle)