Ejemplo n.º 1
0
  /** initializes NetPeerGroup and the CMS */
  private void startJxta() {
    try {
      // create, and Start the default jxta NetPeerGroup
      netPeerGroup = PeerGroupFactory.newNetPeerGroup();

      // uncomment the following line if you want to start the app defined
      // the NetPeerGroup Advertisement (by default it's the shell)
      // in this case we want use jxta directly.

      // netPeerGroup.startApp(null);

      // instanciate and initialize a content management service for
      // the NetPeerGroup
      cms = new CMS();
      cms.init(netPeerGroup, null, null);

      // set up a ShareDemo directory inside the JXTA_HOME directory
      String homedir = System.getProperty("JXTA_HOME");
      homedir = (homedir != null) ? homedir + "ShareDemo" : "ShareDemo";

      // start CMS, creating a directory named ShareDemo to store the
      // ContentAdvertisement cache in.
      if (cms.startApp(new File(homedir)) == -1) {
        System.out.println("CMS initialization failed");
        System.exit(-1);
      }

    } catch (PeerGroupException e) {
      // could not instanciate the group, print the stack and exit
      System.out.println("fatal error : group creation failure");
      e.printStackTrace();
      System.exit(1);
    }
  }
Ejemplo n.º 2
0
  public ShareDemo() {
    startJxta();

    // adds a search listener that monitors incoming list requests
    cms.addSearchListener(new MySearchListener());

    ShareWindow window = new ShareWindow();
    window.setVisible(true);
  }