JADE相關問題1

  • 啓動問題1

    啓動遠程平臺需要先啓動jre下的rmiregistry.exe。注意oracle中也有個rmiregistry,若path中先後未設置正確,可能使用該rmiregistry,將無法註冊

  • 啓動問題2

    rmi需要使用sub,因此需要將帶樁的jar文件(jade.jar)配到系統classpath中。否則rmiregistry.exe將無法找到該樁文件。

  • 脫機啓動問題3

  v3.5 jade.Boot -detect-main false

  • 啓動問題  --- unknowhost

    客戶端主機名 必須對應一個正確的客戶端IP
例如linux下配置主機/etc/sysconfig/networking/profiles/default/hosts文件中
xxx.xxx.x.x 主機名

  • 在web中嵌入agent

public class MonitorServlet extends HttpServlet {
 public void init() throws ServletException {
  Properties prop = new Properties();
  String path = this.getServletContext().getRealPath("/")+"/WEB-INF/webagent.properties";
  try {
   prop.load(path);
   JadeGateway.init("com.lingtong.monitor.agent.WebAgent",prop); //非本機時需配置
  } catch (IOException e) {
   e.printStackTrace();
  }
 }
 
 protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
  DetectCommand cmd = null;
  ...
  cmd = new DetectCommand(agentId);
  JadeGateway.execute(cmd,200000); //同步調用,可配超時
  result =cmd.getResult();
  ...
 }
}

 

class WebAgent extends GatewayAgent {
 public void setup() {
  ....
  super.setup();  //不可少
 }
 protected void processCommand(java.lang.Object obj) {
  if (obj instanceof DetectCommand) {
   ....
  }
 }

 

----- webagent.properties(參見jade.core.Profile) --------
host=192.168.10.88
#port=1099
container-name=monitor

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章