コード例 #1
0
 public void testEchoContainer() throws Exception {
   delayTestFinish(TEST_DELAY);
   Context ctx = factory.ctx();
   DomainProxy proxy = ctx.create(DomainProxy.class);
   proxy.setA("42");
   ContainerProxy container = ctx.create(ContainerProxy.class);
   container.setDomain(proxy);
   ctx.echoContainer(container)
       .fire(
           new Receiver<ContainerProxy>() {
             @Override
             public void onSuccess(ContainerProxy response) {
               assertEquals("42", response.getDomain().getA());
               finishTest();
             }
           });
 }
コード例 #2
0
  /**
   * Removes a message transport protocol, previously running within this container.
   *
   * @param address The transport address exported by the new MTP, in string format.
   * @exception MTPException If something goes wrong during transport protocol activation.
   * @exception NotFoundException If no protocol with the given address is currently installed on
   *     this container.
   */
  public void uninstallMTP(String address)
      throws MTPException, NotFoundException, StaleProxyException {
    if (myImpl == null || myProxy == null) {
      throw new StaleProxyException();
    }

    try {
      myProxy.uninstallMTP(address);
    } catch (Throwable t) {
      throw new StaleProxyException(t);
    }
  }
コード例 #3
0
  /**
   * Installs a new message transport protocol, that will run within this container.
   *
   * @param address The transport address exported by the new MTP, in string format.
   * @param className The fully qualified name of the Java class that implements the transport
   *     protocol.
   * @exception MTPException If something goes wrong during transport protocol activation.
   */
  public void installMTP(String address, String className)
      throws MTPException, StaleProxyException {
    if (myImpl == null || myProxy == null) {
      throw new StaleProxyException();
    }

    try {
      myProxy.installMTP(address, className);
    } catch (Throwable t) {
      throw new StaleProxyException(t);
    }
  }
コード例 #4
0
  /** Shuts down this container, terminating all the agents running within it. */
  public void kill() throws StaleProxyException {
    if (myImpl == null || myProxy == null) {
      throw new StaleProxyException();
    }

    try {
      myProxy.killContainer();
      // release resources of this object
      myProxy = null;
      myImpl = null;
      myPlatformName = null;
    } catch (Throwable t) {
      throw new StaleProxyException(t);
    }
  }
コード例 #5
0
  /**
   * Creates a new JADE agent, running within this container,
   *
   * @param nickname A platform-unique nickname for the newly created agent. The agent will be given
   *     a FIPA compliant agent identifier using the nickname and the ID of the platform it is
   *     running on.
   * @param className The fully qualified name of the class that implements the agent.
   * @param args An object array, containing initialization parameters to pass to the new agent.
   * @return A proxy object, allowing to call state-transition forcing methods on the real agent
   *     instance.
   */
  public AgentController createNewAgent(String nickname, String className, Object[] args)
      throws StaleProxyException {
    if (myImpl == null || myProxy == null) {
      throw new StaleProxyException();
    }

    AID agentID = new AID(AID.createGUID(nickname, myImpl.getPlatformID()), AID.ISGUID);

    try {
      myProxy.createAgent(agentID, className, args);
      return new AgentControllerImpl(agentID, myProxy, myImpl);
    } catch (Throwable t) {
      t.printStackTrace();
      throw new StaleProxyException(t);
    }
  }