public JAMServiceUILauncher(ServiceDiscoveryManager clm, Entry[] entry, String clName)
     throws ClassNotFoundException, RemoteException {
   super();
   Class[] cls = {Class.forName(clName)};
   lookupCache = clm.createLookupCache(new ServiceTemplate(null, cls, entry), null, this);
   // this.key = ((JobUserKey)entry[0]).key;
   // System.out.println("JAM SERVICE UIKey: " + key);
 }
 private void removeLookupCache() {
   lookupCache.removeListener(this);
   lookupCache.terminate();
   if (clm != null) clm.terminate();
   // System.out.println("JAM LAUNCHER terminated " + key);
 }
Esempio n. 3
0
  /**
   * Causes the classloader to run the static initiliasre block above Negates need for
   * Class.forName();
   */
  public static void initialise(Configuration config) {
    try {
      System.out.println("Initialising SystemManager");
      SystemManager.SYSTEMCHANGELISTENER = new SystemConfigChangeListener();
      String[] GROUPS =
          (String[]) config.getEntry("org.jini.projects.athena", "groups", String[].class);
      ldm = new LookupDiscoveryManager(GROUPS, null, null, config);
      sdm = new ServiceDiscoveryManager(ldm, null, config);
      ServiceTemplate temp = new ServiceTemplate(null, new Class[] {ErosService.class}, null);

      ServiceItem svc = sdm.lookup(temp, new ErosFilter(), 3000);
      if (svc != null) {
        if (svc.service != null && svc.service instanceof ErosService) {

          try {
            ProxyPreparer preparer =
                (ProxyPreparer)
                    config.getEntry(
                        "org.jini.projects.athena",
                        "proxyPreparer",
                        ProxyPreparer.class,
                        new BasicProxyPreparer());
            eros = (ErosService) preparer.prepareProxy(svc.service);
            eLogger = eros.getLogger();
            eLogger.initialise("Athena");
            logHandler = (Handler) eLogger.getLoggingHandler();

            int Kb = 1024;
            FileHandler fhandler = new FileHandler("logs/athena", 500 * Kb, 40);
            fhandler.setFormatter(new LogFormatter());

            String consoleLogLevel =
                (String)
                    config.getEntry("org.jini.projects.athena", "consoleLogLevel", String.class);
            String fileLogLevel =
                (String) config.getEntry("org.jini.projects.athena", "fileLogLevel", String.class);
            stdLogger = java.util.logging.Logger.getLogger("org.jini.projects.athena");
            stdLogger.setLevel(Level.parse(fileLogLevel));

            stdLogger.setUseParentHandlers(false);
            fhandler.setLevel(Level.parse(fileLogLevel));
            logHandler.setLevel(Level.parse(consoleLogLevel));
            stdLogger.addHandler(fhandler);
            stdLogger.addHandler(logHandler);
            stdLogger.info("Eros Logging enabled");

          } catch (RemoteException e) {
            System.err.println("Exception occured whilst interacting with Eros");
            e.printStackTrace();
          } catch (SecurityException e) {
            System.err.println("Security Exception occured whilst interacting with Eros");
            e.printStackTrace();
          } catch (Exception e) {
            System.err.println("Exception occured whilst interacting with Eros");
            e.printStackTrace();
          }
        }
      } else {
        System.out.println("Eros could not be found....default logging will be provided");
        int Kb = 1024;
        File logDir = new File("logs");
        if (!logDir.exists()) logDir.mkdir();
        FileHandler fhandler = new FileHandler("logs/athena", 500 * Kb, 40);
        fhandler.setFormatter(new LogFormatter());

        String consoleLogLevel =
            (String) config.getEntry("org.jini.projects.athena", "consoleLogLevel", String.class);
        String fileLogLevel =
            (String) config.getEntry("org.jini.projects.athena", "fileLogLevel", String.class);
        stdLogger = java.util.logging.Logger.getLogger("org.jini.projects.athena");
        stdLogger.setLevel(Level.parse(fileLogLevel));

        ConsoleHandler logHandler = new ConsoleHandler();
        logHandler.setFormatter(new LogFormatter());
        stdLogger.setUseParentHandlers(false);
        fhandler.setLevel(Level.parse(fileLogLevel));
        logHandler.setLevel(Level.parse(consoleLogLevel));
        stdLogger.addHandler(fhandler);
        stdLogger.addHandler(logHandler);
      }
    } catch (IOException e) {
      System.out.println("System cannot perform lookup for Eros");
      e.printStackTrace();
    } catch (Exception e) {
      System.out.println("System cannot perform lookup for Eros");
      e.printStackTrace();
    }
    stdLogger.info("Initialised SystemManager");
  }