示例#1
0
  public static void main(String args[]) {
    UAN uan = null;
    UAL ual = null;
    if (System.getProperty("uan") != null) {
      uan = new UAN(System.getProperty("uan"));
      ServiceFactory.getTheater();
      RunTime.receivedUniversalActor();
    }
    if (System.getProperty("ual") != null) {
      ual = new UAL(System.getProperty("ual"));

      if (uan == null) {
        System.err.println("Actor Creation Error:");
        System.err.println("	uan: " + uan);
        System.err.println("	ual: " + ual);
        System.err.println("	Identifier: " + System.getProperty("identifier"));
        System.err.println("	Cannot specify an actor to have a ual at runtime without a uan.");
        System.err.println(
            "	To give an actor a specific ual at runtime, use the identifier system property.");
        System.exit(0);
      }
      RunTime.receivedUniversalActor();
    }
    if (System.getProperty("identifier") != null) {
      if (ual != null) {
        System.err.println("Actor Creation Error:");
        System.err.println("	uan: " + uan);
        System.err.println("	ual: " + ual);
        System.err.println("	Identifier: " + System.getProperty("identifier"));
        System.err.println(
            "	Cannot specify an identifier and a ual with system properties when creating an actor.");
        System.exit(0);
      }
      ual = new UAL(ServiceFactory.getTheater().getLocation() + System.getProperty("identifier"));
    }
    RunTime.receivedMessage();
    CrazyMigration instance = (CrazyMigration) new CrazyMigration(uan, ual, null).construct();
    gc.WeakReference instanceRef = new gc.WeakReference(uan, ual);
    {
      Object[] _arguments = {args};

      // preAct() for local actor creation
      // act() for remote actor creation
      if (ual != null && !ual.getLocation().equals(ServiceFactory.getTheater().getLocation())) {
        instance.send(new Message(instanceRef, instanceRef, "act", _arguments, false));
      } else {
        instance.send(new Message(instanceRef, instanceRef, "preAct", _arguments, false));
      }
    }
    RunTime.finishedProcessingMessage();
  }
    public boolean timeoutMsg() {
      for (int i = 0; i < targetActors.size(); i++) {
        ActorReference target = (ActorReference) targetActors.get(i);
        String messageId = (String) targetMessages.get(i);
        Integer position = (Integer) targetPositions.get(i);

        /**
         * If the value is a large object, it isn't required to be sent if this token is being used
         * for synchronization. We can send null instead.
         */
        Object[] arguments = new Object[3];
        arguments[0] = messageId;
        arguments[1] = position;
        Object[] ret = new Object[index];
        System.arraycopy(values, 0, ret, 0, index);
        if (position.intValue() == -3) arguments[2] = null;
        else arguments[2] = ret;
        Message data =
            new Message(
                ((JoinDirector) self), target, "resolveToken", arguments, null, null, false);
        target.send(data);
      }
      this.ServiceDie();
      return true;
    }
  public static void main(String args[]) {
    UAN uan = null;
    UAL ual = null;
    if (System.getProperty("uan") != null) {
      uan = new UAN(System.getProperty("uan"));
      ServiceFactory.getTheater();
      RunTime.receivedUniversalActor();
    }
    if (System.getProperty("ual") != null) {
      ual = new UAL(System.getProperty("ual"));

      if (uan == null) {
        System.err.println("Actor Creation Error:");
        System.err.println("	uan: " + uan);
        System.err.println("	ual: " + ual);
        System.err.println("	Identifier: " + System.getProperty("identifier"));
        System.err.println("	Cannot specify an actor to have a ual at runtime without a uan.");
        System.err.println(
            "	To give an actor a specific ual at runtime, use the identifier system property.");
        System.exit(0);
      }
      RunTime.receivedUniversalActor();
    }
    if (System.getProperty("identifier") != null) {
      if (ual != null) {
        System.err.println("Actor Creation Error:");
        System.err.println("	uan: " + uan);
        System.err.println("	ual: " + ual);
        System.err.println("	Identifier: " + System.getProperty("identifier"));
        System.err.println(
            "	Cannot specify an identifier and a ual with system properties when creating an actor.");
        System.exit(0);
      }
      ual = new UAL(ServiceFactory.getTheater().getLocation() + System.getProperty("identifier"));
    }
    JoinDirector instance = (JoinDirector) new JoinDirector(uan, ual).construct();
    {
      Object[] _arguments = {args};
      instance.send(new Message(instance, instance, "act", _arguments, null, null));
    }
  }