ubiqossystemagentpacket.java

来自「一个agent 工具包,可以开发移动设备应用,考虑了安全措施」· Java 代码 · 共 53 行

JAVA
53
字号
package SOMA.agent.mobility;

import SOMA.agent.Agent;
import SOMA.Environment;
import SOMA.naming.AgentID;
import java.io.*;

/**
 * Title:        	ubiQoS
 * Copyright:    	Copyright (c) 2002
 * Date:		12/04/2002
 * Description:		Multimedia middleware based in part on precedent versions implemented by Antonio D'Errico and Francesco Baschieri
 * @author 		Luca Foschini
 * @version 		1.0
 *
 */

/**
 * A packetizer for the UbiQoS system agents. This class implements a packetizer for the
 * system agents used in the ubiQoS package. In particular this packetizer moves only the
 * fields of the class and assumes that all the needed code, both for the agent and for 
 * the fields is present in the target location. There is no code mobility in this case,
 * but only mobility of the state of the agent.
 *
 */
public class UbiQoSSystemAgentPacket implements AgentPacket
{
  private final byte[] packet;
  private final AgentID agentID;
  private final String className;

  public UbiQoSSystemAgentPacket( Agent agent )
  {
    agentID = agent.getID();
    className = agent.getClass().getName();

    byte[] thePacket = null;
    try
    {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream( baos );
      oos.writeObject( agent );
      //AgentOutputStream aos = new AgentOutputStream( baos, agent );
      //aos.writeObject( agent );
      thePacket = baos.toByteArray();
    }
    catch( Exception e )
    {
      e.printStackTrace();
    }

    packet = thePacket;
       // packet 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?