Java 类org.osgi.framework.FrameworkEvent 实例源码

项目:incubator-netbeans    文件:NetbinoxHooks.java   
@Override
public void log(FrameworkEvent fe) {
    Level l = Level.FINE;
    if ((fe.getType() & FrameworkEvent.ERROR) != 0) {
        l = Level.SEVERE;
    } else if ((fe.getType() & FrameworkEvent.WARNING) != 0) {
        l = Level.WARNING;
    } else if ((fe.getType() & FrameworkEvent.INFO) != 0) {
        l = Level.INFO;
    }
    LogRecord lr = new LogRecord(l, "framework event {0} type {1}");
    lr.setParameters(new Object[]{fe.getBundle().getSymbolicName(), fe.getType()});
    lr.setThrown(fe.getThrowable());
    lr.setLoggerName(NetbinoxFactory.LOG.getName());
    NetbinoxFactory.LOG.log(lr);
}
项目:atlas    文件:BundleImpl.java   
/**
 * uninstall the bundle.
 * 
 * @throws BundleException if bundle is already uninstalled
 * @see org.osgi.framework.Bundle#uninstall()
 * @category Bundle
 */
public synchronized void uninstall() throws BundleException {

    if (state == UNINSTALLED) {
        throw new IllegalStateException("Bundle " + toString() + " is already uninstalled.");
    }
    if (state == ACTIVE) {
        try {
            stop();
        } catch (Throwable t) {
            Framework.notifyFrameworkListeners(FrameworkEvent.ERROR, this, t);
        }
    }

    state = UNINSTALLED;

    classloader.cleanup(true);
    classloader = null;

    Framework.bundles.remove(getLocation());
    Framework.notifyBundleListeners(BundleEvent.UNINSTALLED, this);
}
项目:atlas    文件:Framework.java   
/**
 * notify all framework listeners.
 *
 * @param state the new state.
 * @param bundle the bundle.
 * @param throwable a throwable.
 */
static void notifyFrameworkListeners(final int state, final Bundle bundle, final Throwable throwable) {

    if (frameworkListeners.isEmpty()) {
        return;
    }

    final FrameworkEvent event = new FrameworkEvent(state);

    final FrameworkListener[] listeners = frameworkListeners.toArray(new FrameworkListener[frameworkListeners.size()]);

    for (int i = 0; i < listeners.length; i++) {
        final FrameworkListener listener = listeners[i];

        listener.frameworkEvent(event);
    }
}
项目:gemini.blueprint    文件:OsgiStringUtilsTest.java   
public void testNullSafeToStringFrameworkEvent() throws Exception {
    Bundle bundle = new MockBundle();
    Throwable th = new Exception();
    assertEquals("STARTED",
        OsgiStringUtils.nullSafeToString(new FrameworkEvent(FrameworkEvent.STARTED, bundle, th)));
    assertEquals("ERROR", OsgiStringUtils.nullSafeToString(new FrameworkEvent(FrameworkEvent.ERROR, bundle, th)));

    assertEquals("WARNING",
        OsgiStringUtils.nullSafeToString(new FrameworkEvent(FrameworkEvent.WARNING, bundle, th)));

    assertEquals("INFO", OsgiStringUtils.nullSafeToString(new FrameworkEvent(FrameworkEvent.INFO, bundle, th)));

    assertEquals("PACKAGES_REFRESHED", OsgiStringUtils.nullSafeToString(new FrameworkEvent(
        FrameworkEvent.PACKAGES_REFRESHED, bundle, th)));

    assertEquals("STARTLEVEL_CHANGED", OsgiStringUtils.nullSafeToString(new FrameworkEvent(
        FrameworkEvent.STARTLEVEL_CHANGED, bundle, th)));
}
项目:adeptj-runtime    文件:FrameworkRestartHandler.java   
/**
 * Handles OSGi Framework restart, does following on System Bundle STARTED event.
 * <p>
 * 1. Removes the BundleContext from ServletContext attributes. <br>
 * 2. Gets the new BundleContext from System Bundle and sets that to ServletContext. <br>
 * 3. Closes the DispatcherServletTracker and open again with new BundleContext. <br>
 * 4. As the BundleContext is removed and added from ServletContext the corresponding BridgeServletContextAttributeListener
 * is fired with events which in turn closes the EventDispatcherTracker and open again with new BundleContext.
 */
@Override
public void frameworkEvent(FrameworkEvent event) {
    Logger logger = LoggerFactory.getLogger(FrameworkRestartHandler.class);
    switch (event.getType()) {
        case FrameworkEvent.STARTED:
            logger.info("Handling OSGi Framework Restart!!");
            // Add the new BundleContext as a ServletContext attribute, remove the stale BundleContext.
            BundleContext bundleContext = event.getBundle().getBundleContext();
            this.handleBundleContext(bundleContext);
            this.handleDispatcherServletTracker(logger);
            break;
        case FrameworkEvent.STOPPED_UPDATE:
            logger.info("Closing DispatcherServletTracker!!");
            ServiceTrackers.INSTANCE.closeDispatcherServletTracker();
            logger.info("Closing EventDispatcherTracker!!");
            ServiceTrackers.INSTANCE.closeEventDispatcherTracker();
            break;
        default:
            // log it and ignore.
            if (logger.isDebugEnabled()) {
                logger.debug("Ignoring the OSGi FrameworkEvent: [{}]", FrameworkEvents.asString(event.getType()));
            }
            break;
    }
}
项目:ch.vorburger.minecraft.osgi    文件:LoggingFrameworkListener.java   
private String getFrameworkEventTypeText(int type) {
    switch (type) {
        case FrameworkEvent.STARTED:
            return "Started";
        case FrameworkEvent.ERROR:
            return "Error";
        case FrameworkEvent.WARNING:
            return "Warning";
        case FrameworkEvent.INFO:
            return "Info";
        case FrameworkEvent.PACKAGES_REFRESHED:
            return "Packages Refreshed";
        case FrameworkEvent.STARTLEVEL_CHANGED:
            return "Start Level Changed";
        case FrameworkEvent.STOPPED:
            return "Stopped";
        case FrameworkEvent.STOPPED_BOOTCLASSPATH_MODIFIED:
            return "Stopped Bootclasspath Modified";
        case FrameworkEvent.STOPPED_UPDATE:
            return "Stopped Update";
        case FrameworkEvent.WAIT_TIMEDOUT:
            return "Wait Timeout";
        default:
            return type + " ???";
    }
}
项目:vespa    文件:FelixFramework.java   
@Override
public void refreshPackages() {
    FrameworkWiring wiring = felix.adapt(FrameworkWiring.class);
    final CountDownLatch latch = new CountDownLatch(1);
    wiring.refreshBundles(null,
                          event -> {
                              switch (event.getType()) {
                              case FrameworkEvent.PACKAGES_REFRESHED:
                                  latch.countDown();
                                  break;
                              case FrameworkEvent.ERROR:
                                  log.log(Level.SEVERE, "ERROR FrameworkEvent received.", event.getThrowable());
                                  break;
                              }
                          });
    try {
        long TIMEOUT_SECONDS = 60L;
        if (!latch.await(TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
            log.warning("No PACKAGES_REFRESHED FrameworkEvent received within " + TIMEOUT_SECONDS +
                                " seconds of calling FrameworkWiring.refreshBundles()");
        }
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    }
}
项目:carbon-kernel    文件:CarbonServer.java   
/**
 * Wait until this Framework has completely stopped.
 *
 * @param framework OSGi framework
 * @throws java.lang.Exception
 */
private void waitForServerStop(Framework framework) throws Exception {
    if (!isFrameworkActive()) {
        return;
    }

    while (true) {
        FrameworkEvent event = framework.waitForStop(0);

        // We should not stop the framework if the user has updated the system bundle via the OSGi console or
        //  programmatically. In this case, framework will shutdown and start itself.
        if (event.getType() != FrameworkEvent.STOPPED_UPDATE) {
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, "OSGi framework is stopped for update.");
            }
            break;
        }
    }
}
项目:spring-osgi    文件:OsgiStringUtilsTest.java   
public void testNullSafeToStringFrameworkEvent() throws Exception {
    Bundle bundle = new MockBundle();
    Throwable th = new Exception();
    assertEquals("STARTED",
        OsgiStringUtils.nullSafeToString(new FrameworkEvent(FrameworkEvent.STARTED, bundle, th)));
    assertEquals("ERROR", OsgiStringUtils.nullSafeToString(new FrameworkEvent(FrameworkEvent.ERROR, bundle, th)));

    assertEquals("WARNING",
        OsgiStringUtils.nullSafeToString(new FrameworkEvent(FrameworkEvent.WARNING, bundle, th)));

    assertEquals("INFO", OsgiStringUtils.nullSafeToString(new FrameworkEvent(FrameworkEvent.INFO, bundle, th)));

    assertEquals("PACKAGES_REFRESHED", OsgiStringUtils.nullSafeToString(new FrameworkEvent(
        FrameworkEvent.PACKAGES_REFRESHED, bundle, th)));

    assertEquals("STARTLEVEL_CHANGED", OsgiStringUtils.nullSafeToString(new FrameworkEvent(
        FrameworkEvent.STARTLEVEL_CHANGED, bundle, th)));
}
项目:osgi-testrunner    文件:FrameworkStartingShutdownBlockerImpl.java   
/**
 * Starting the blocker instance.
 */
public void start() {
  frameworkListener = new FrameworkListener() {

    @Override
    public void frameworkEvent(final FrameworkEvent event) {
      if (event.getType() == FrameworkEvent.STARTED) {
        blocking = false;
        unblock();
      }

    }
  };
  bundleContext.addFrameworkListener(frameworkListener);

  Bundle frameworkBundle = bundleContext.getBundle(0);
  if (frameworkBundle.getState() != Bundle.ACTIVE) {
    blocking = true;
    block();
  } else {
    blocking = false;
  }

}
项目:incubator-netbeans    文件:NetigsoStartLevelTest.java   
@Override
public synchronized void frameworkEvent(FrameworkEvent fe) {
    if (fe.getType() == FrameworkEvent.STARTLEVEL_CHANGED) {
        levelChanged = true;
        notifyAll();
    }
}
项目:incubator-netbeans    文件:Activator.java   
public @Override void start(final BundleContext context) throws Exception {
        if (System.getProperty("netbeans.home") != null) {
            throw new IllegalStateException("Should not be run from inside regular NetBeans module system");
        }
        String storage = context.getProperty(Constants.FRAMEWORK_STORAGE);
        if (storage != null) {
            System.setProperty("netbeans.user", storage);
        }
        System.setProperty("TopSecurityManager.disable", "true");
        NbBundle.setBranding(System.getProperty("branding.token"));
        OSGiMainLookup.initialize(context);
        queue = new DependencyQueue<String,Bundle>();
        this.context = context;
        framework = ((Framework) context.getBundle(0));
        if (framework.getState() == Bundle.STARTING) {
            LOG.fine("framework still starting");
            final AtomicReference<FrameworkListener> frameworkListener = new AtomicReference<FrameworkListener>();
            frameworkListener.set(new FrameworkListener() {
                public @Override void frameworkEvent(FrameworkEvent event) {
                    if (event.getType() == FrameworkEvent.STARTED) {
//                        System.err.println("framework started");
                        context.removeFrameworkListener(frameworkListener.get());
                        context.addBundleListener(Activator.this);
                        processLoadedBundles();
                    }
                }
            });
            context.addFrameworkListener(frameworkListener.get());
        } else {
            LOG.fine("framework already started");
            context.addBundleListener(this);
            processLoadedBundles();
        }
    }
项目:incubator-netbeans    文件:NetbinoxLoader.java   
private static BundleFile createBundleFile(Object content, BaseData sourcedata) {
    try {
        return sourcedata.getAdaptor().createBundleFile(content, sourcedata);
    } catch (IOException e) {
        sourcedata.getAdaptor().getEventPublisher().publishFrameworkEvent(FrameworkEvent.ERROR, sourcedata.getBundle(), e);
    }
    return null;
}
项目:atlas    文件:FrameworkLifecycleHandler.java   
@Override
public void frameworkEvent(FrameworkEvent event) {
    switch (event.getType()) {
        case 0:/* STARTING */
            starting();
            break;
        case FrameworkEvent.STARTED:
            started();
            break;
        case FrameworkEvent.STARTLEVEL_CHANGED:
        case FrameworkEvent.PACKAGES_REFRESHED:
        case FrameworkEvent.ERROR:
    }

}
项目:atlas    文件:Framework.java   
/**
 * launch the framework.
 *
 * @throws Throwable
 */
static void startup(boolean updated) throws BundleException {
    AtlasBundleInfoManager.instance().getBundleInfo();
    AtlasHotPatchManager.getInstance();
    notifyFrameworkListeners(0 /* STARTING */, null, null);
    notifyFrameworkListeners(FrameworkEvent.STARTED, null, null);
}
项目:gemini.blueprint    文件:OsgiStringUtils.java   
/**
 * Returns a String representation for the given <code>FrameworkEvent</code> .
 * 
 * @param event OSGi <code>FrameworkEvent</code> (can be <code>null</code>)
 * @return String representation of the given event
 */
public static String nullSafeToString(FrameworkEvent event) {
    if (event == null)
        return NULL_STRING;
    try {
        return FRAMEWORK_EVENTS.toCode(Integer.valueOf(event.getType()), EMPTY_STRING);
    } catch (ConstantException cex) {
        return UNKNOWN_EVENT_TYPE;
    }
}
项目:ACDD    文件:Framework.java   
static void notifyFrameworkListeners(int event, Bundle bundle, Throwable th) {
    if (!frameworkListeners.isEmpty()) {
        FrameworkEvent frameworkEvent = new FrameworkEvent(event, bundle, th);
        FrameworkListener[] frameworkListenerArr = frameworkListeners.toArray(new FrameworkListener[frameworkListeners.size()]);
        for (FrameworkListener frameworkListener : frameworkListenerArr) {
            frameworkListener.frameworkEvent(frameworkEvent);
        }
    }
}
项目:ch.vorburger.minecraft.osgi    文件:LoggingFrameworkListener.java   
public void log(FrameworkEvent event) {
    // if (event.getType() == FrameworkEvent.ERROR)
    if (event.getThrowable() == null) {
        LOG.info("FrameworkEvent {} : {}", getFrameworkEventTypeText(event.getType()),
                event.getBundle().getSymbolicName());
    } else {
        LOG.error("FrameworkEvent {} : {}", getFrameworkEventTypeText(event.getType()),
                event.getBundle().getSymbolicName(), event.getThrowable());
    }
}
项目:bartleby    文件:FrameworkErrorListener.java   
private void dump(FrameworkEvent fe) {
    Throwable t = fe.getThrowable();
    String tString = null;
    if (t != null) {
        tString = t.toString();
    }
    System.out.println("Framework ERROR:" + ", source " + fe.getSource() + ", bundle=" + fe.getBundle() + ", ex=" + tString);
    if (t != null) {
        t.printStackTrace();
    }
}
项目:bartleby    文件:FrameworkErrorListener.java   
private void dump(FrameworkEvent fe) {
  Throwable t = fe.getThrowable();
  String tString = null;
  if (t != null) {
    tString = t.toString();
  }
  System.out.println("Framework ERROR:" + ", source " + fe.getSource()
      + ", bundle=" + fe.getBundle() + ", ex=" + tString);
  if(t != null) {
    t.printStackTrace();
  }
}
项目:AtlasForAndroid    文件:Framework.java   
static void notifyFrameworkListeners(int i, Bundle bundle, Throwable th) {
    if (!frameworkListeners.isEmpty()) {
        FrameworkEvent frameworkEvent = new FrameworkEvent(i, bundle, th);
        FrameworkListener[] frameworkListenerArr = (FrameworkListener[]) frameworkListeners.toArray(new FrameworkListener[frameworkListeners.size()]);
        for (FrameworkListener frameworkEvent2 : frameworkListenerArr) {
            frameworkEvent2.frameworkEvent(frameworkEvent);
        }
    }
}
项目:spring-osgi    文件:OsgiStringUtils.java   
/**
 * Returns a String representation for the given <code>FrameworkEvent</code>.
 * 
 * @param event OSGi <code>FrameworkEvent</code> (can be <code>null</code>)
 * @return String representation of the given event
 */
public static String nullSafeToString(FrameworkEvent event) {
    if (event == null)
        return NULL_STRING;
    try {
        return FRAMEWORK_EVENTS.toCode(new Integer(event.getType()), EMPTY_STRING);
    }
    catch (ConstantException cex) {
        return UNKNOWN_EVENT_TYPE;
    }
}
项目:bundles    文件:Guard.java   
@Override
public void start(BundleContext context) throws Exception {
    this.context = context;

    packages = load(context.getBundle(), "guardinfo/packages.properties", packages);
    services = load(context.getBundle(), "guardinfo/services.properties", services);

    Hashtable<String,Object> properties = new Hashtable<>();
    properties.put("command.scope", "guard");
    properties.put("command.function", new String[] {
            "restart", "clear"
    });
    context.registerService(Object.class, new Object(), properties);

    final AtomicBoolean started = new AtomicBoolean(false);

    //
    // Wait before polling
    context.addFrameworkListener(new FrameworkListener() {

        @Override
        public void frameworkEvent(FrameworkEvent event) {
            if (event.getType() == FrameworkEvent.STARTED && started.getAndSet(true)) {
                start();
            }
        }
    });
    Thread.sleep(5000);
    if (started.getAndSet(true))
        start();
}
项目:proactive-component-monitoring    文件:OSGiFramework.java   
public void frameworkEvent(FrameworkEvent event) {
    if (event.getType() == FrameworkEvent.ERROR) {
    } else if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED) {
    } else if (event.getType() == FrameworkEvent.STARTED) {
    } else if (event.getType() == FrameworkEvent.STARTLEVEL_CHANGED) {
    }
}
项目:osgi-richconsole    文件:FrameworkRefreshListener.java   
@Override
public void frameworkEvent(final FrameworkEvent event) {
    int eventType = event.getType();
    if ((eventType == FrameworkEvent.ERROR) || (eventType == FrameworkEvent.PACKAGES_REFRESHED)) {
        refreshFinishLock.lock();
        try {
            refreshFinished.set(true);
            Logger.info("Framework refresh finished with code "
                    + BundleUtil.convertFrameworkEventTypeCode(eventType));
            refreshFinishCondition.signal();
        } finally {
            refreshFinishLock.unlock();
        }
    } else {
        StringBuilder sb = new StringBuilder("Event caught during refreshing packages with data:");
        if (event.getBundle() != null) {
            sb.append("\n\tBundle: ").append(event.getBundle().toString());
        }
        if (event.getSource() != null) {
            sb.append("\n\tSource object: ").append(event.getSource().toString());
        }
        sb.append("\n\tEvent type: ").append(BundleUtil.convertFrameworkEventTypeCode(event.getType()));
        if (event.getThrowable() != null) {
            Logger.error(sb.toString(), event.getThrowable());
        } else {
            Logger.info(sb.toString());
        }
    }
}
项目:osgi-richconsole    文件:UpgradeProcess.java   
public void setFrameworkStartLevel(final int startLevel) {
    Logger.info("Setting framework startlevel to " + startLevel);
    final AtomicBoolean startLevelReached = new AtomicBoolean(false);
    final Lock lock = new ReentrantLock();
    final Condition startLevelReachedCondition = lock.newCondition();

    frameworkStartLevel.setStartLevel(startLevel, new FrameworkListener() {

        @Override
        public void frameworkEvent(final FrameworkEvent event) {
            lock.lock();
            int eventType = event.getType();
            if ((eventType == FrameworkEvent.STARTLEVEL_CHANGED) || (eventType == FrameworkEvent.ERROR)) {
                if (eventType == FrameworkEvent.ERROR) {
                    Logger.error("Setting framework startlevel to " + startLevel + " finished with error: ",
                            event.getThrowable());
                } else {
                    Logger.info("Setting framework startlevel to " + startLevel + " finished with success");
                }
                startLevelReached.set(true);
                startLevelReachedCondition.signal();
            }
            lock.unlock();
        }
    });
    lock.lock();
    try {
        while (!startLevelReached.get()) {
            startLevelReachedCondition.await();
        }
    } catch (InterruptedException e) {
        Logger.error("Startlevel reaching wait interrupted", e);
    } finally {
        lock.unlock();
    }
    currentFrameworkStartLevelValue = startLevel;
}
项目:osgi-richconsole    文件:BundleUtil.java   
public static String convertFrameworkEventTypeCode(final int code) {
    switch (code) {
    case FrameworkEvent.ERROR:
        return "ERROR";
    case FrameworkEvent.INFO:
        return "INFO";
    case FrameworkEvent.PACKAGES_REFRESHED:
        return "PACKAGES_REFRESHED";
    case FrameworkEvent.STARTED:
        return "STARTED";
    case FrameworkEvent.STARTLEVEL_CHANGED:
        return "STARTLEVEL_CHANGED";
    case FrameworkEvent.STOPPED:
        return "STOPPED";
    case FrameworkEvent.STOPPED_BOOTCLASSPATH_MODIFIED:
        return "STOPPED_BOOTCLASSPATH_MODIFIED";
    case FrameworkEvent.STOPPED_UPDATE:
        return "STOPPED_UPDATE";
    case FrameworkEvent.WAIT_TIMEDOUT:
        return "WAIT_TIMEDOUT";
    case FrameworkEvent.WARNING:
        return "WARNING";
    default:
        break;
    }
    return String.valueOf(code);
}
项目:incubator-netbeans    文件:NetigsoSelfQueryTest.java   
public FrameworkEvent waitForStop(long l) throws InterruptedException {
    return null;
}
项目:incubator-netbeans    文件:NetbinoxHooks.java   
@Override
  public void frameworkEvent(FrameworkEvent ev) {
if (ev.getType() == FrameworkEvent.ERROR) {
          log(ev);
}
  }
项目:osc-core    文件:DeploymentInstaller.java   
@Override
public void frameworkEvent(FrameworkEvent event) {
    if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED) {
        invalidateAllUnits("Packaged Refreshed");
    }
}
项目:gemini.blueprint    文件:OsgiStringUtilsTest.java   
public void testNullSafeToStringFrameworkEventNull() throws Exception {
    assertNotNull(OsgiStringUtils.nullSafeToString((FrameworkEvent) null));
}
项目:gemini.blueprint    文件:OsgiStringUtilsTest.java   
public void testNullSafeToStringFrameworkEventInvalidType() throws Exception {
    assertEquals("UNKNOWN EVENT TYPE", OsgiStringUtils.nullSafeToString(new FrameworkEvent(-123, bundle,
        new Exception())));
}
项目:puzzle    文件:PluginActivator.java   
@Override
public void frameworkEvent(FrameworkEvent event) {
    if(event.getType() ==FrameworkEvent.STARTLEVEL_CHANGED){
        PluginFrameworkListener.Processor.execute(true);
    }
}
项目:LoliXL    文件:OSGiListener.java   
@Override
public void frameworkEvent(FrameworkEvent event) {
    Level level;
    String type;
    switch (event.getType()) {
        case FrameworkEvent.STARTED:
            level = Level.INFO;
            type = "STARTED";
            break;
        case FrameworkEvent.ERROR:
            level = Level.SEVERE;
            type = "ERROR";
            break;
        case FrameworkEvent.WARNING:
            level = Level.WARNING;
            type = "WARNING";
            break;
        case FrameworkEvent.INFO:
            level = Level.INFO;
            type = "INFO";
            break;
        case FrameworkEvent.PACKAGES_REFRESHED:
            level = Level.FINE;
            type = "PACKAGES_REFRESHED";
            break;
        case FrameworkEvent.STARTLEVEL_CHANGED:
            level = Level.FINE;
            type = "STARTLEVEL_CHANGED";
            break;
        case FrameworkEvent.STOPPED:
            level = Level.INFO;
            type = "STOPPED";
            break;
        case FrameworkEvent.STOPPED_BOOTCLASSPATH_MODIFIED:
            level = Level.INFO;
            type = "STOPPED_BOOTCLASSPATH_MODIFIED";
            break;
        case FrameworkEvent.STOPPED_UPDATE:
            level = Level.INFO;
            type = "STOPPED_UPDATE";
            break;
        case FrameworkEvent.WAIT_TIMEDOUT:
            level = Level.FINE;
            type = "WAIT_TIMEDOUT";
            break;
        default:
            level = Level.OFF;
            type = "<Unknown type: " + event.getType() + ">";
            break;
    }
    StringBuilder sb = new StringBuilder();
    sb.append(type);
    if (event.getBundle() != null) {
        sb.append(" bundle=[")
                .append(event.getBundle())
                .append("]");
    }
    LOGGER_FRAMEWORK.log(level, sb.toString(), event.getThrowable());
}
项目:LoliXL    文件:Main.java   
public static void main(String[] args) {
    try {
        Metadata.initMetadata();
        setupSystemProperties();
        setupWorkingDir();
        configureJUL();

        initFx();

        felixConfiguration = loadConfiguration();
        processConfiguration(felixConfiguration);
        AccessEndpoint.internalBundleRepository = new InternalBundleRepository();

        clearFelixCache();
        felix = new Felix(felixConfiguration);
        felix.start();
        OSGiListener osgiListener = new OSGiListener();
        felix.getBundleContext().addBundleListener(osgiListener);
        felix.getBundleContext().addFrameworkListener(osgiListener);
        setupFelix(felix);

        FrameworkEvent event;
        do {
            event = felix.waitForStop(Long.MAX_VALUE);
            if ((event.getType() & FrameworkEvent.ERROR) == FrameworkEvent.ERROR) {
                throw new IllegalStateException("Felix stopped because of an error: " + event, event.getThrowable());
            }
        } while (event.getType() == FrameworkEvent.WAIT_TIMEDOUT ||
                event.getType() == FrameworkEvent.STOPPED_UPDATE);
        clearFelixCache();
        exitFx();
    } catch (Throwable e) {
        if (felix != null) {
            try {
                felix.stop();
            } catch (Throwable e1) {
                e.addSuppressed(e1);
            }
        }
        clearFelixCache();
        FatalErrorReporter.process(e);
        exitFx();
        System.exit(1);
    }
}
项目:ch.vorburger.minecraft.osgi    文件:LoggingFrameworkListener.java   
@Override
public void frameworkEvent(FrameworkEvent event) {
    log(event);
}
项目:ch.vorburger.minecraft.osgi    文件:OSGiFrameworkWrapper.java   
public void stop() throws InterruptedException, BundleException {
    framework.stop();
    FrameworkEvent event = framework.waitForStop(7000); // 7s
    loggingFrameworkListener.log(event);
}
项目:gvnix1    文件:DefaultProcessManager.java   
protected void activate(final ComponentContext context) {
    this.context = context.getBundleContext();
    workingDir = OSGiUtils.getRooWorkingDirectory(context);
    this.context.addFrameworkListener(
            new FrameworkListener() {
                public void frameworkEvent(final FrameworkEvent event) {

                    if(startLevel == null){
                        startLevel = getStartLevel();
                    }

                    Validate.notNull(startLevel, "StartLevel is required");

                    if (startLevel.getStartLevel() >= 99) {
                        // We check we haven't already started, as this
                        // event listener will be called several times at SL
                        // >= 99
                        if (getProcessManagerStatus() == ProcessManagerStatus.STARTING) {
                            // A proper synchronized process manager status
                            // check will take place in the
                            // completeStartup() method
                            completeStartup();
                        }
                    }
                }
            });

    // Now start a thread that will undertake a background poll every second
    final Thread t = new Thread(new Runnable() {
        public void run() {
            // Unsynchronized lookup of terminated status to avoid anything
            // blocking the termination of the thread
            while (getProcessManagerStatus() != ProcessManagerStatus.TERMINATED) {
                // We only bother doing a poll if we seem to be available (a
                // proper synchronized check happens later)
                if (getProcessManagerStatus() == ProcessManagerStatus.AVAILABLE) {
                    timerBasedPoll();
                }
                try {
                    Thread.sleep(1000);
                }
                catch (final InterruptedException ignoreAndContinue) {
                }
            }
        }
    }, "Spring Roo Process Manager Background Polling Thread");
    t.start();
}
项目:osgi-jpms-layer    文件:LayerFactoryImpl.java   
@Override
public void frameworkEvent(FrameworkEvent event) {
    if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED) {
        createNewWiringLayers();
    }
}
项目:bartleby    文件:FrameworkErrorListener.java   
public void frameworkEvent(FrameworkEvent fe) {
    if (fe.getType() == FrameworkEvent.ERROR) {
        errorList.add(fe);

    }
}