sasapplication.java
上传用户:aonuowh
上传日期:2021-05-23
资源大小:35390k
文件大小:2k
源码类别:

SNMP编程

开发平台:

C/C++

  1. /* $Id: sasapplication.java,v 1.4 2002/09/09 05:39:09 parasuraman Exp $ */
  2. /*
  3.  * @(#)sasapplication.java
  4.  * Copyright (c) 1996-2002 AdventNet, Inc. All Rights Reserved.
  5.  * Please read the associated COPYRIGHTS file for more details.
  6.  */
  7.  /**
  8.   * This example shows how applications can use the sasappclient file by
  9. * plugging in their own Applet stub.
  10. *
  11. * It basically instantiates the sasappclient object, sets the user-defined
  12. * AppletStub stub into it.
  13. */
  14. import com.adventnet.management.transport.*;
  15. import com.adventnet.snmp.snmp2.*;
  16. import javax.swing.*;
  17. import java.awt.event.*;
  18. import java.net.*;
  19. public class sasapplication extends JFrame {
  20. sasapplication() {
  21. super("SAS Application");
  22. }
  23. public static void main (String[] args) {
  24. sasapplication testObj = new sasapplication();
  25. final sasappclient obj = new sasappclient();
  26. // Create the Applet stub & plug it into the Applet
  27. SASAppletStub sasStub = new SASAppletStub();
  28. sasStub.setParameter("TRANSPORT_PROVIDER","com.adventnet.management.transport.TcpClientTransportImpl");
  29. // localhost can be replaced by any host name 
  30. sasStub.setParameter("HOST","localhost");
  31. // set the port parameter to the port in which SAServer is listening.
  32. sasStub.setParameter("PORT","8282");
  33. sasStub.setParameter("CODEBASE", "http://localhost:8282/");
  34. sasStub.setParameter("DOCUMENTBASE", "http://localhost:8282/");
  35. try {
  36. URL codebase = new URL("http://localhost:8282/");
  37. sasStub.setCodeBase(codebase);
  38. sasStub.setDocumentBase(codebase);
  39. } catch (Exception e) {};
  40. obj.setStub(sasStub);
  41. // Start the Applet
  42. obj.init();
  43. obj.start();
  44. // Set UI properties of the frame
  45. testObj.getContentPane().add (obj);
  46. testObj.pack();
  47. testObj.setVisible(true);
  48. // Set the window listener behaviour
  49. WindowAdapter win = new WindowAdapter() {
  50. public void windowClosing(WindowEvent e) {
  51. obj.stop();
  52. System.exit(0);
  53. }
  54. };
  55.   testObj.addWindowListener(win);
  56. }
  57. }