MSC Trial 3

Ken Webb 2010-04-13T11:07:45Z

In this Malleable Software Challenge (MSC) trial, I will run an existing Xholon application, and will then replace a node with a new node that does something slightly different. Specifically, I will replace the World node in the Hello World Tutorial. The new version of World will print Earth instead of World.

At runtime, paste the following XML as a last child of the World node.

<ReplaceNode implName="">
  <Earth implName=""/>

The node to be replaced (the old node, World in this case) is the parent of the ReplaceNode instance. The node that replaces it (the new node, Earth in this case) is the child of the ReplaceNode instance.

The new node will be an instance of the Earth class.


import org.primordion.xholon.base.IMessage;
import org.primordion.xholon.base.Xholon;

public class Earth extends Xholon {
  public static final int SIGNAL_ONE = 100;
  public void processReceivedMessage(IMessage msg)
    switch(msg.getSignal()) {
    case SIGNAL_ONE:
      System.out.println("Earth !");
      msg.getSender().sendMessage(SIGNAL_ONE, null, this);

Here's the initial version of the ReplaceNodes script.


import java.util.List;

import org.primordion.xholon.base.IXholon;
import org.primordion.xholon.base.PortInformation;
import org.primordion.xholon.base.Xholon;

public class ReplaceNode extends Xholon {

  IXholon oldNode = null; // ex: World
  IXholon newNode = null; // ex: Earth

  public void postConfigure() {
    oldNode = getParentNode();
    newNode = getFirstChild();

  public boolean visit(IXholon visitee) {
    List portList = visitee.getAllPorts();
    for (int i = 0; i < portList.size(); i++) {
      PortInformation portInfo = (PortInformation) portList.get(i);
      if (portInfo.getReffedNode() == oldNode) {
        if ("port".equals(portInfo.getFieldName())) {
          visitee.setPort(portInfo.getFieldNameIndex(), newNode);
        // TODO handle non-port ports
    return true;


return to main page