Examples of FrameworkLog


Examples of org.eclipse.osgi.framework.log.FrameworkLog

            }
        }
    }

    public void log(SVNLogType logType, Throwable th, Level logLevel) {
        FrameworkLog log = myActivator.getFrameworkLog();
        if (log == null) {
            return;
        }
        if (th != null) {
            int level = getSeverity(logLevel);
            if (level >= 0) {
                String message = getMessage(logType, th.getMessage());
                FrameworkLogEntry entry = myActivator.createFrameworkLogEntry(FrameworkEvent.ERROR, message, th);
                if (entry != null) {
                    log.log(entry);
                }
            }
        }
    }
View Full Code Here

Examples of org.eclipse.osgi.framework.log.FrameworkLog

    public FrameworkLog getFrameworkLog() {
        if (myFLogTracker == null) {
            return null;
        }
        FrameworkLog log = (FrameworkLog) myFLogTracker.getService();
        if (log != null) {
            return log;
        }
        return null;
    }
View Full Code Here

Examples of org.eclipse.osgi.framework.log.FrameworkLog

    for (int i = 0; i < adaptorHooks.length; i++) {
      log = adaptorHooks[i].createFrameworkLog();
      if (log != null)
        return log;
    }
    log = new FrameworkLog() {
      public void log(FrameworkEvent frameworkEvent) {
        log(new FrameworkLogEntry(frameworkEvent.getBundle().getSymbolicName() == null ? frameworkEvent.getBundle().getLocation() : frameworkEvent.getBundle().getSymbolicName(), FrameworkLogEntry.ERROR, 0, "FrameworkEvent.ERROR", 0, frameworkEvent.getThrowable(), null)); //$NON-NLS-1$
      }

      public void log(FrameworkLogEntry logEntry) {
View Full Code Here

Examples of org.eclipse.osgi.framework.log.FrameworkLog

    }
  }

  private static void logUnresolvedBundles(Bundle[] bundles) {
    State state = adaptor.getState();
    FrameworkLog logService = adaptor.getFrameworkLog();
    StateHelper stateHelper = adaptor.getPlatformAdmin().getStateHelper();

    // first lets look for missing leaf constraints (bug 114120)
    VersionConstraint[] leafConstraints = stateHelper.getUnsatisfiedLeaves(state.getBundles());
    // hash the missing leaf constraints by the declaring bundles
    Map<BundleDescription, List<VersionConstraint>> missing = new HashMap<BundleDescription, List<VersionConstraint>>();
    for (int i = 0; i < leafConstraints.length; i++) {
      // only include non-optional and non-dynamic constraint leafs
      if (leafConstraints[i] instanceof BundleSpecification && ((BundleSpecification) leafConstraints[i]).isOptional())
        continue;
      if (leafConstraints[i] instanceof ImportPackageSpecification) {
        if (ImportPackageSpecification.RESOLUTION_OPTIONAL.equals(((ImportPackageSpecification) leafConstraints[i]).getDirective(Constants.RESOLUTION_DIRECTIVE)))
          continue;
        if (ImportPackageSpecification.RESOLUTION_DYNAMIC.equals(((ImportPackageSpecification) leafConstraints[i]).getDirective(Constants.RESOLUTION_DIRECTIVE)))
          continue;
      }
      BundleDescription bundle = leafConstraints[i].getBundle();
      List<VersionConstraint> constraints = missing.get(bundle);
      if (constraints == null) {
        constraints = new ArrayList<VersionConstraint>();
        missing.put(bundle, constraints);
      }
      constraints.add(leafConstraints[i]);
    }

    // found some bundles with missing leaf constraints; log them first
    if (missing.size() > 0) {
      FrameworkLogEntry[] rootChildren = new FrameworkLogEntry[missing.size()];
      int rootIndex = 0;
      for (Iterator<BundleDescription> iter = missing.keySet().iterator(); iter.hasNext(); rootIndex++) {
        BundleDescription description = iter.next();
        String symbolicName = description.getSymbolicName() == null ? FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME : description.getSymbolicName();
        String generalMessage = NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_RESOLVED, description.getLocation());
        List<VersionConstraint> constraints = missing.get(description);
        FrameworkLogEntry[] logChildren = new FrameworkLogEntry[constraints.size()];
        for (int i = 0; i < logChildren.length; i++)
          logChildren[i] = new FrameworkLogEntry(symbolicName, FrameworkLogEntry.WARNING, 0, MessageHelper.getResolutionFailureMessage(constraints.get(i)), 0, null, null);
        rootChildren[rootIndex] = new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.WARNING, 0, generalMessage, 0, null, logChildren);
      }
      logService.log(new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.WARNING, 0, EclipseAdaptorMsg.ECLIPSE_STARTUP_ROOTS_NOT_RESOLVED, 0, null, rootChildren));
    }

    // There may be some bundles unresolved for other reasons, causing the system to be unresolved
    // log all unresolved constraints now
    List<FrameworkLogEntry> allChildren = new ArrayList<FrameworkLogEntry>();
    for (int i = 0; i < bundles.length; i++)
      if (bundles[i].getState() == Bundle.INSTALLED) {
        String symbolicName = bundles[i].getSymbolicName() == null ? FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME : bundles[i].getSymbolicName();
        String generalMessage = NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_RESOLVED, bundles[i]);
        BundleDescription description = state.getBundle(bundles[i].getBundleId());
        // for some reason, the state does not know about that bundle
        if (description == null)
          continue;
        FrameworkLogEntry[] logChildren = null;
        VersionConstraint[] unsatisfied = stateHelper.getUnsatisfiedConstraints(description);
        if (unsatisfied.length > 0) {
          // the bundle wasn't resolved due to some of its constraints were unsatisfiable
          logChildren = new FrameworkLogEntry[unsatisfied.length];
          for (int j = 0; j < unsatisfied.length; j++)
            logChildren[j] = new FrameworkLogEntry(symbolicName, FrameworkLogEntry.WARNING, 0, MessageHelper.getResolutionFailureMessage(unsatisfied[j]), 0, null, null);
        } else {
          ResolverError[] resolverErrors = state.getResolverErrors(description);
          if (resolverErrors.length > 0) {
            logChildren = new FrameworkLogEntry[resolverErrors.length];
            for (int j = 0; j < resolverErrors.length; j++)
              logChildren[j] = new FrameworkLogEntry(symbolicName, FrameworkLogEntry.WARNING, 0, resolverErrors[j].toString(), 0, null, null);
          }
        }

        allChildren.add(new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.WARNING, 0, generalMessage, 0, null, logChildren));
      }
    if (allChildren.size() > 0)
      logService.log(new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.WARNING, 0, EclipseAdaptorMsg.ECLIPSE_STARTUP_ALL_NOT_RESOLVED, 0, null, allChildren.toArray(new FrameworkLogEntry[allChildren.size()])));
  }
View Full Code Here

Examples of org.eclipse.osgi.framework.log.FrameworkLog

  }

  FrameworkLog createFrameworkLog(Bundle bundle, EclipseLogWriter eclipseWriter) {
    final EclipseLogWriter logWriter = eclipseWriter == null ? defaultWriter : eclipseWriter;
    final Logger logger = bundle == null ? logManager.getSystemBundleLog().getLogger(eclipseWriter.getLoggerName()) : logManager.getSystemBundleLog().getLogger(bundle, logWriter.getLoggerName());
    return new FrameworkLog() {

      public void setWriter(Writer newWriter, boolean append) {
        logWriter.setWriter(newWriter, append);
      }
View Full Code Here

Examples of org.eclipse.osgi.framework.log.FrameworkLog

  public static boolean isRunning() {
    return running;
  }

  protected static FrameworkLog createFrameworkLog() {
    FrameworkLog frameworkLog;
    String logFileProp = FrameworkProperties.getProperty(EclipseStarter.PROP_LOGFILE);
    if (logFileProp != null) {
      frameworkLog = new EclipseLog(new File(logFileProp));
    } else {
      Location location = LocationManager.getConfigurationLocation();
      File configAreaDirectory = null;
      if (location != null)
        // TODO assumes the URL is a file: url
        configAreaDirectory = new File(location.getURL().getFile());

      if (configAreaDirectory != null) {
        String logFileName = Long.toString(System.currentTimeMillis()) + ".log"; //$NON-NLS-1$
        File logFile = new File(configAreaDirectory, logFileName);
        FrameworkProperties.setProperty(EclipseStarter.PROP_LOGFILE, logFile.getAbsolutePath());
        frameworkLog = new EclipseLog(logFile);
      } else
        frameworkLog = new EclipseLog();
    }
    if ("true".equals(FrameworkProperties.getProperty(EclipseStarter.PROP_CONSOLE_LOG))) //$NON-NLS-1$
      frameworkLog.setConsoleLog(true);
    return frameworkLog;
  }
View Full Code Here

Examples of org.eclipse.osgi.framework.log.FrameworkLog

    }
  }

  private static void logUnresolvedBundles(Bundle[] bundles) {
    State state = adaptor.getState();
    FrameworkLog logService = adaptor.getFrameworkLog();
    StateHelper stateHelper = adaptor.getPlatformAdmin().getStateHelper();

    // first lets look for missing leaf constraints (bug 114120)
    VersionConstraint[] leafConstraints = stateHelper.getUnsatisfiedLeaves(state.getBundles());
    // hash the missing leaf constraints by the declaring bundles
    Map missing = new HashMap();
    for (int i = 0; i < leafConstraints.length; i++) {
      // only include non-optional and non-dynamic constraint leafs
      if (leafConstraints[i] instanceof BundleSpecification && ((BundleSpecification) leafConstraints[i]).isOptional())
        continue;
      if (leafConstraints[i] instanceof ImportPackageSpecification) {
        if (ImportPackageSpecification.RESOLUTION_OPTIONAL.equals(((ImportPackageSpecification) leafConstraints[i]).getDirective(Constants.RESOLUTION_DIRECTIVE)))
          continue;
        if (ImportPackageSpecification.RESOLUTION_DYNAMIC.equals(((ImportPackageSpecification) leafConstraints[i]).getDirective(Constants.RESOLUTION_DIRECTIVE)))
          continue;
      }
      BundleDescription bundle = leafConstraints[i].getBundle();
      ArrayList constraints = (ArrayList) missing.get(bundle);
      if (constraints == null) {
        constraints = new ArrayList();
        missing.put(bundle, constraints);
      }
      constraints.add(leafConstraints[i]);
    }

    // found some bundles with missing leaf constraints; log them first
    if (missing.size() > 0) {
      FrameworkLogEntry[] rootChildren = new FrameworkLogEntry[missing.size()];
      int rootIndex = 0;
      for (Iterator iter = missing.keySet().iterator(); iter.hasNext(); rootIndex++) {
        BundleDescription description = (BundleDescription) iter.next();
        String symbolicName = description.getSymbolicName() == null ? FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME : description.getSymbolicName();
        String generalMessage = NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_RESOLVED, description.getLocation());
        ArrayList constraints = (ArrayList) missing.get(description);
        FrameworkLogEntry[] logChildren = new FrameworkLogEntry[constraints.size()];
        for (int i = 0; i < logChildren.length; i++)
          logChildren[i] = new FrameworkLogEntry(symbolicName, FrameworkLogEntry.WARNING, 0, MessageHelper.getResolutionFailureMessage((VersionConstraint) constraints.get(i)), 0, null, null);
        rootChildren[rootIndex] = new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.WARNING, 0, generalMessage, 0, null, logChildren);
      }
      logService.log(new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.WARNING, 0, EclipseAdaptorMsg.ECLIPSE_STARTUP_ROOTS_NOT_RESOLVED, 0, null, rootChildren));
    }

    // There may be some bundles unresolved for other reasons, causing the system to be unresolved
    // log all unresolved constraints now
    ArrayList allChildren = new ArrayList();
    for (int i = 0; i < bundles.length; i++)
      if (bundles[i].getState() == Bundle.INSTALLED) {
        String symbolicName = bundles[i].getSymbolicName() == null ? FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME : bundles[i].getSymbolicName();
        String generalMessage = NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_RESOLVED, bundles[i]);
        BundleDescription description = state.getBundle(bundles[i].getBundleId());
        // for some reason, the state does not know about that bundle
        if (description == null)
          continue;
        FrameworkLogEntry[] logChildren = null;
        VersionConstraint[] unsatisfied = stateHelper.getUnsatisfiedConstraints(description);
        if (unsatisfied.length > 0) {
          // the bundle wasn't resolved due to some of its constraints were unsatisfiable
          logChildren = new FrameworkLogEntry[unsatisfied.length];
          for (int j = 0; j < unsatisfied.length; j++)
            logChildren[j] = new FrameworkLogEntry(symbolicName, FrameworkLogEntry.WARNING, 0, MessageHelper.getResolutionFailureMessage(unsatisfied[j]), 0, null, null);
        } else {
          ResolverError[] resolverErrors = state.getResolverErrors(description);
          if (resolverErrors.length > 0) {
            logChildren = new FrameworkLogEntry[resolverErrors.length];
            for (int j = 0; j < resolverErrors.length; j++)
              logChildren[j] = new FrameworkLogEntry(symbolicName, FrameworkLogEntry.WARNING, 0, resolverErrors[j].toString(), 0, null, null);
          }
        }

        allChildren.add(new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.WARNING, 0, generalMessage, 0, null, logChildren));
      }
    if (allChildren.size() > 0)
      logService.log(new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.WARNING, 0, EclipseAdaptorMsg.ECLIPSE_STARTUP_ALL_NOT_RESOLVED, 0, null, (FrameworkLogEntry[]) allChildren.toArray(new FrameworkLogEntry[allChildren.size()])));
  }
View Full Code Here

Examples of org.eclipse.osgi.framework.log.FrameworkLog

    for (int i = 0; i < adaptorHooks.length; i++) {
      log = adaptorHooks[i].createFrameworkLog();
      if (log != null)
        return log;
    }
    log = new FrameworkLog() {
      public void log(FrameworkEvent frameworkEvent) {
        log(new FrameworkLogEntry(frameworkEvent.getBundle().getSymbolicName() == null ? frameworkEvent.getBundle().getLocation() : frameworkEvent.getBundle().getSymbolicName(), FrameworkLogEntry.ERROR, 0, "FrameworkEvent.ERROR", 0, frameworkEvent.getThrowable(), null)); //$NON-NLS-1$
      }

      public void log(FrameworkLogEntry logEntry) {
View Full Code Here

Examples of org.eclipse.osgi.framework.log.FrameworkLog

    // do nothing
    return false;
  }

  public FrameworkLog createFrameworkLog() {
    FrameworkLog frameworkLog;
    String logFileProp = FrameworkProperties.getProperty(EclipseStarter.PROP_LOGFILE);
    if (logFileProp != null) {
      frameworkLog = new EclipseLog(new File(logFileProp));
    } else {
      Location location = LocationManager.getConfigurationLocation();
      File configAreaDirectory = null;
      if (location != null)
        // TODO assumes the URL is a file: url
        configAreaDirectory = new File(location.getURL().getFile());

      if (configAreaDirectory != null) {
        String logFileName = Long.toString(System.currentTimeMillis()) + EclipseLogHook.LOG_EXT;
        File logFile = new File(configAreaDirectory, logFileName);
        FrameworkProperties.setProperty(EclipseStarter.PROP_LOGFILE, logFile.getAbsolutePath());
        frameworkLog = new EclipseLog(logFile);
      } else
        frameworkLog = new EclipseLog();
    }
    if ("true".equals(FrameworkProperties.getProperty(EclipseStarter.PROP_CONSOLE_LOG))) //$NON-NLS-1$
      frameworkLog.setConsoleLog(true);
    return frameworkLog;
  }
View Full Code Here

Examples of org.eclipse.osgi.framework.log.FrameworkLog

  }

  public void publishFrameworkEventPrivileged(FrameworkEvent event) {
    /* if the event is an error then it should be logged */
    if (event.getType() == FrameworkEvent.ERROR) {
      FrameworkLog frameworkLog = adaptor.getFrameworkLog();
      if (frameworkLog != null)
        frameworkLog.log(event);
    }
    /* queue to hold set of listeners */
    ListenerQueue listeners = new ListenerQueue(eventManager);
    /* queue to hold set of BundleContexts w/ listeners */
    ListenerQueue contexts = new ListenerQueue(eventManager);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.