Package org.osgi.service.log

Examples of org.osgi.service.log.LogService


  public Algorithm createAlgorithm(
      Data[] data, Dictionary<String, Object> parameters, CIShellContext ciShellContext) {
    DataConversionService conversionManager =
      (DataConversionService) ciShellContext.getService(
        DataConversionService.class.getName());
    LogService logger = (LogService) ciShellContext.getService(LogService.class.getName());

        return new FileView(data, ciShellContext, conversionManager, logger);
    }
View Full Code Here


        this.context = context;
    }

    public Data[] execute() {
        if (parameters != null) {
            LogService log = (LogService) context.getService(LogService.class.getName());
            log.log(LogService.LOG_INFO, "Parameters Entered:");
            for (Enumeration i = parameters.keys(); i.hasMoreElements(); ) {
                String key = (String) i.nextElement();
                Object value = parameters.get(key);
               
                log.log(LogService.LOG_INFO, key + " -> " + value + " (" + value.getClass().getName() + ")");
            }
           
            GUIBuilderService guiBuilder = (GUIBuilderService)
                context.getService(GUIBuilderService.class.getName());
           
            boolean confirm = guiBuilder.showConfirm("showConfirm()", "showConfirm Test", "showConfirm Details");
            log.log(LogService.LOG_INFO, "Confirmed? " + confirm);
            guiBuilder.showError("showError()", "showError Test", "showError Details");
           
            try {
                Integer.parseInt("Not an integer...");
            } catch (NumberFormatException e) {
                guiBuilder.showError("showError()", "showError w/ Throwable Test", e);
            }
           
            guiBuilder.showInformation("showInformation()", "showInformation Test", "showInformation Details");
            confirm = guiBuilder.showQuestion("showQuestion()", "showQuestion Test", "showQuestion Details");
            log.log(LogService.LOG_INFO, "Yes? " + (confirm ? "Yes" : "No"));
            guiBuilder.showWarning("showWarning()", "showWarning Test", "showWarning Details");
        }
       
        return null;
    }
View Full Code Here

    }
   
    private void printAlgorithmInformation(
        ServiceReference serviceReference, CIShellContext ciContext) {
        // Adjust to log the whole acknowledgement in one block.
        LogService logger = (LogService) ciContext.getService(LogService.class.getName());
        StringBuffer acknowledgement = new StringBuffer();
        String label = (String) serviceReference.getProperty(LABEL);

        if (label != null) {
          acknowledgement.append("..........\n" + label + " was selected.\n");
        }

        String authors = (String) serviceReference.getProperty(AUTHORS);

        if (authors != null) {
          acknowledgement.append("Author(s): " + authors + "\n");
        }

        String implementers = (String) serviceReference.getProperty(IMPLEMENTERS);

        if (implementers != null) {
          acknowledgement.append("Implementer(s): " + implementers + "\n");
        }

        String integrators = (String) serviceReference.getProperty(INTEGRATORS);

        if (integrators != null) {
            acknowledgement.append("Integrator(s): " + integrators + "\n");
        }

        String reference = (String) serviceReference.getProperty(REFERENCE);
        String reference_url = (String) serviceReference.getProperty(REFERENCE_URL);           

        if ((reference != null) && (reference_url != null)) {
            acknowledgement.append(
              "Reference: " + reference + " ([url]" + reference_url + "[/url])\n");
        } else if ((reference != null) && (reference_url == null)) {
          acknowledgement.append("Reference: " + reference + "\n");
        }

        String documentationURL = (String) serviceReference.getProperty(DOCUMENTATION_URL);

        if (documentationURL != null) {
          acknowledgement.append("Documentation: [url]" + documentationURL + "[/url]\n");
        }

        if (acknowledgement.length() > 1) {
          logger.log(serviceReference, LogService.LOG_INFO, acknowledgement.toString());
        }
    }
View Full Code Here

    return prefsToPublish
        .contains(UserPrefsProperty.PUBLISH_PARAM_DEFAULT_PREFS_VALUE);
  }

  protected void log(int logLevel, String message) {
    LogService logger = (LogService) this.ciShellContext
        .getService(LogService.class.getName());
    if (logger != null) {
      logger.log(this.serviceReference, logLevel, message);
    } else {
      System.out.println(message);
    }
  }
View Full Code Here

      System.out.println(message);
    }
  }

  protected void log(int logLevel, String message, Throwable exception) {
    LogService logger = (LogService) this.ciShellContext
        .getService(LogService.class.getName());

    if (logger != null) {
      logger.log(this.serviceReference, logLevel, message, exception);
    } else {
      System.out.println(message);
      exception.printStackTrace();
    }
  }
View Full Code Here

    }
  }

  protected void printParameters(String metatype_pid,
      MetaTypeProvider provider, Dictionary parameters) {
    LogService logger = getLogService();
    Map idToLabelMap = setupIdToLabelMap(metatype_pid, provider);

    if (logger != null && !parameters.isEmpty()) {
      // adjust to log all input parameters in one block
      StringBuffer inputParams = new StringBuffer("\n"
          + "Input Parameters:");

      for (Enumeration e = parameters.keys(); e.hasMoreElements();) {
        String key = (String) e.nextElement();
        Object value = parameters.get(key);

        key = (String) idToLabelMap.get(key);
        inputParams.append("\n" + key + ": " + value);

      }
      logger.log(this.serviceReference, LogService.LOG_INFO,
          inputParams.toString());
    }
  }
View Full Code Here

  }

  private LogService getLogService() {
    ServiceReference serviceReference = bundleContext
        .getServiceReference(DataManagerService.class.getName());
    LogService log = null;

    if (serviceReference != null) {
      log = (LogService) bundleContext.getService(bundleContext
          .getServiceReference(LogService.class.getName()));
    }
View Full Code Here

        log = (LogReaderService) osgi.getServiceObject(LogReaderService.class.getName(), null);
        if (log == null) {
            throw new RuntimeException("No Log Service !");
        }

        LogService logs = (LogService) osgi.getServiceObject(LogService.class.getName(), null);
        logs.log(LogService.LOG_WARNING, "Ready");
    }
View Full Code Here

        log = (LogReaderService) osgi.getServiceObject(LogReaderService.class.getName(), null);
        if (log == null) {
            throw new RuntimeException("No Log Service !");
        }

        LogService logs = (LogService) osgi.getServiceObject(LogService.class.getName(), null);
        logs.log(LogService.LOG_WARNING, "Ready");
    }
View Full Code Here

        log = (LogReaderService) osgi.getServiceObject(LogReaderService.class.getName(), null);
        if (log == null) {
            throw new RuntimeException("No Log Service !");
        }

        LogService logs = (LogService) osgi.getServiceObject(LogService.class.getName(), null);
        logs.log(LogService.LOG_WARNING, "Ready");
    }
View Full Code Here

TOP

Related Classes of org.osgi.service.log.LogService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.