Package jade.core

Examples of jade.core.GenericCommand


        content = content + " (ACLMessage) ) (MTS-error " + receiver + " \"" +
            ie.getMessage() + "\") )";
        failure.setContent(content);

        try {
            GenericCommand command = new GenericCommand(MessagingSlice.SEND_MESSAGE,
                    MessagingSlice.NAME, null);
            command.addParam(theAMS);
            command.addParam(new GenericMessage(failure));
            command.addParam((AID) (failure.getAllReceiver().next()));

            // FIXME: We should set the AMS principal and credentials
            submit(command);
        } catch (ServiceException se) {
            // It should never happen
View Full Code Here


*/
public class TopicManagementProxy extends SliceProxy implements TopicManagementSlice {
 
  public void register(AID aid, AID topic) throws IMTPException {
    try {
      GenericCommand cmd = new GenericCommand(H_REGISTER, TopicManagementService.NAME, null);
      cmd.addParam(aid);
      cmd.addParam(topic);
     
      Node n = getNode();
      Object result = n.accept(cmd);
      if((result != null) && (result instanceof Throwable)) {
        if(result instanceof IMTPException) {
View Full Code Here

    }
  }
 
  public void deregister(AID aid, AID topic) throws IMTPException
    try {
      GenericCommand cmd = new GenericCommand(H_DEREGISTER, TopicManagementService.NAME, null);
      cmd.addParam(aid);
      cmd.addParam(topic);
     
      Node n = getNode();
      Object result = n.accept(cmd);
      if((result != null) && (result instanceof Throwable)) {
        if(result instanceof IMTPException) {
View Full Code Here

          String agentName = (String)params[1];
         
          cmd.setReturnValue(fetchClassFile(className, agentName));
        }
        else if(cmdName.equals(AgentMobilitySlice.H_MOVEAGENT)) {
          GenericCommand gCmd = new GenericCommand(AgentMobilityHelper.REQUEST_MOVE, AgentMobilitySlice.NAME, null);
          AID agentID = (AID)params[0];
          Location where = (Location)params[1];
          gCmd.addParam(agentID);
          gCmd.addParam(where);
         
          result = gCmd;
        }
        else if(cmdName.equals(AgentMobilitySlice.H_COPYAGENT)) {
          GenericCommand gCmd = new GenericCommand(AgentMobilityHelper.REQUEST_CLONE, AgentMobilitySlice.NAME, null);
          AID agentID = (AID)params[0];
          Location where = (Location)params[1];
          String newName = (String)params[2];
          gCmd.addParam(agentID);
          gCmd.addParam(where);
          gCmd.addParam(newName);
         
          result = gCmd;
        }
        else if(cmdName.equals(AgentMobilitySlice.H_PREPARE)) {
         
          cmd.setReturnValue(new Boolean(prepare()));
        }
        else if(cmdName.equals(AgentMobilitySlice.H_TRANSFERIDENTITY)) {
          AID agentID = (AID)params[0];
          Location src = (Location)params[1];
          Location dest = (Location)params[2];
         
          cmd.setReturnValue(new Boolean(transferIdentity(agentID, src, dest)));
        }
        else if(cmdName.equals(AgentMobilitySlice.H_HANDLETRANSFERRESULT)) {
          AID agentID = (AID)params[0];
          boolean transferResult = ((Boolean)params[1]).booleanValue();
          List messages = (List)params[2];
         
          handleTransferResult(agentID, transferResult, messages);
        }
        else if(cmdName.equals(AgentMobilitySlice.H_CLONEDAGENT)) {
          GenericCommand gCmd = new GenericCommand(AgentMobilityHelper.INFORM_CLONED, AgentMobilitySlice.NAME, null);
          AID agentID = (AID)params[0];
          ContainerID cid = (ContainerID)params[1];
          Credentials creds = (Credentials)params[2];
          gCmd.addParam(agentID);
          gCmd.addParam(cid);
          gCmd.addParam(creds);
         
          result = gCmd;
        }
        //#J2ME_EXCLUDE_BEGIN
        else if(cmdName.equals(AgentMobilitySlice.H_CLONECODELOCATORENTRY)) {
View Full Code Here

*/
public class ResourceManagementProxy extends SliceProxy implements ResourceManagementSlice {

  public byte[] getResource(String name, int fetchMode) throws Exception {
    try {
      GenericCommand cmd = new GenericCommand(H_GETRESOURCE, ResourceManagementService.NAME, null);
      cmd.addParam(name);
      cmd.addParam(fetchMode);
     
      Node n = getNode();
      Object result = n.accept(cmd);
      if((result != null) && (result instanceof Throwable)) {
        if(result instanceof Exception) {
View Full Code Here

      try {
        String cmdName = cmd.getName();
        Object[] params = cmd.getParams();
       
        if(cmdName.equals(MessagingSlice.H_DISPATCHLOCALLY)) {
          GenericCommand gCmd = new GenericCommand(MessagingSlice.SEND_MESSAGE, MessagingSlice.NAME, null);
          AID senderAID = (AID)params[0];
          GenericMessage msg = (GenericMessage)params[1];
          AID receiverID = (AID)params[2];
          if (params.length == 4) {
            msg.setTimeStamp(((Long) params[3]).longValue());
          }
          if (msg.getTraceID() != null) {
            myLogger.log(Logger.INFO, "MessagingService slice received message "+MessageManager.stringify(msg)+" for receiver "+receiverID.getLocalName()+". Trace ID = "+msg.getTraceID());
          }
          gCmd.addParam(senderAID);
          gCmd.addParam(msg);
          gCmd.addParam(receiverID);
          result = gCmd;
        }
        else if(cmdName.equals(MessagingSlice.H_GETAGENTLOCATION)) {
          AID agentID = (AID)params[0];
         
          cmd.setReturnValue(getAgentLocation(agentID));
        }
        else if(cmdName.equals(MessagingSlice.H_ROUTEOUT)) {
          Envelope env = (Envelope)params[0];
          byte[] payload = (byte[])params[1];
          AID receiverID = (AID)params[2];
          String address = (String)params[3];
         
          routeOut(env, payload, receiverID, address);
        }
        else if(cmdName.equals(MessagingSlice.H_INSTALLMTP)) {
          GenericCommand gCmd = new GenericCommand(MessagingSlice.INSTALL_MTP, MessagingSlice.NAME, null);
          String address = (String)params[0];
          String className = (String)params[1];
          gCmd.addParam(address);
          gCmd.addParam(className);
         
          result = gCmd;
        }
        else if(cmdName.equals(MessagingSlice.H_UNINSTALLMTP)) {
          GenericCommand gCmd = new GenericCommand(MessagingSlice.UNINSTALL_MTP, MessagingSlice.NAME, null);
          String address = (String)params[0];
          gCmd.addParam(address);
         
          result = gCmd;
        }
        else if(cmdName.equals(MessagingSlice.H_NEWMTP)) {
          MTPDescriptor mtp = (MTPDescriptor)params[0];
          ContainerID cid = (ContainerID)params[1];
         
          GenericCommand gCmd = new GenericCommand(MessagingSlice.NEW_MTP, MessagingSlice.NAME, null);
          gCmd.addParam(mtp);
          gCmd.addParam(cid);
         
          result = gCmd;
        }
        else if(cmdName.equals(MessagingSlice.H_DEADMTP)) {
          MTPDescriptor mtp = (MTPDescriptor)params[0];
          ContainerID cid = (ContainerID)params[1];
         
          GenericCommand gCmd = new GenericCommand(MessagingSlice.DEAD_MTP, MessagingSlice.NAME, null);
          gCmd.addParam(mtp);
          gCmd.addParam(cid);
         
          result = gCmd;
        }
        else if(cmdName.equals(MessagingSlice.H_ADDROUTE)) {
          MTPDescriptor mtp = (MTPDescriptor)params[0];
View Full Code Here

    Iterator routeIterator = routes.getAddresses();
    while ( routeIterator.hasNext() ) {
      platformAddresses.add( routeIterator.next() );
    }
    // make an uninstall-mtp command to re-use for each MTP installed
    GenericCommand cmd = new GenericCommand( MessagingSlice.UNINSTALL_MTP, getName(), null );
    // for each platform address, uninstall the MTP it represents
    routeIterator = platformAddresses.iterator();
    while ( routeIterator.hasNext() ) {
      String route = (String)routeIterator.next();
      try {
        cmd.addParam( route );
        receiverSink.consume( cmd );
        cmd.removeParam( route );
        if ( myLogger.isLoggable( Logger.FINER ) ) {
          myLogger.log( Logger.FINER,"uninstalled MTP "+route );
        }
      }
      catch ( Exception e ) {
View Full Code Here

    if ("true".equals(acl.getUserDefinedParameter(ACLMessage.IGNORE_FAILURE))) {
      // Ignore the failure
      return;
    }
   
    GenericCommand cmd = new GenericCommand(MessagingSlice.NOTIFY_FAILURE, MessagingSlice.NAME, null);
    cmd.addParam(msg);
    cmd.addParam(receiver);
    cmd.addParam(ie);
   
    try {
      submit(cmd);
    }
    catch(ServiceException se) {
View Full Code Here

     * the Message Transport Service.
     * Package scoped as it can be called by the MessageManager
     */
    public void notifyFailureToSender(GenericMessage msg, AID receiver,
        InternalError ie) {
        GenericCommand cmd = new GenericCommand(MessagingSlice.NOTIFY_FAILURE,
                MessagingSlice.NAME, null);
        cmd.addParam(receiver);
        cmd.addParam(msg);
        cmd.addParam(ie);

        try {
            submit(cmd);
        } catch (ServiceException se) {
            // It should never happen
View Full Code Here

   
  private void killNode(String name, byte[] nn) {
    Node node = null;
    try {
      node = nodeSerializer.deserialize(nn);
      HorizontalCommand cmd = new GenericCommand(H_KILLNODE, NAME, null);
      node.accept(cmd);
      myLogger.log(Logger.INFO, "Node "+name+" successfully killed.");
    }
    catch (IMTPException imtpe) {
      myLogger.log(Logger.INFO, "Node "+name+" unreachable (it has likely been killed in the meanwhile) or does not support fault recovery.");
View Full Code Here

TOP

Related Classes of jade.core.GenericCommand

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.