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

项目: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);
    }
}
项目: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    文件: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();
        }
    }
项目: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);
        }
    }
}
项目:AtlasForAndroid    文件:BundleContextImpl.java   
public void addFrameworkListener(FrameworkListener frameworkListener) {
    checkValid();
    if (this.bundle.registeredFrameworkListeners == null) {
        this.bundle.registeredFrameworkListeners = new ArrayList();
    }
    if (!this.bundle.registeredFrameworkListeners.contains(frameworkListener)) {
        Framework.frameworkListeners.add(frameworkListener);
        this.bundle.registeredFrameworkListeners.add(frameworkListener);
    }
}
项目:AtlasForAndroid    文件:BundleContextImpl.java   
public void removeFrameworkListener(FrameworkListener frameworkListener) {
    checkValid();
    Framework.frameworkListeners.remove(frameworkListener);
    this.bundle.registeredFrameworkListeners.remove(frameworkListener);
    if (this.bundle.registeredFrameworkListeners.isEmpty()) {
        this.bundle.registeredFrameworkListeners = null;
    }
}
项目: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);
        }
    }
}
项目: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();
}
项目: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;
}
项目:incubator-netbeans    文件:NetigsoSelfQueryTest.java   
public void addFrameworkListener(FrameworkListener fl) {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:incubator-netbeans    文件:NetigsoSelfQueryTest.java   
public void removeFrameworkListener(FrameworkListener fl) {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:incubator-netbeans    文件:Netbinox.java   
public void removeFrameworkListener(FrameworkListener fl) {
    delegate.removeFrameworkListener(fl);
}
项目:incubator-netbeans    文件:Netbinox.java   
public void addFrameworkListener(FrameworkListener fl) {
    delegate.addFrameworkListener(fl);
}
项目:atlas    文件:Framework.java   
public static void addFrameworkListener(FrameworkListener listener) {
    frameworkListeners.add(listener);
}
项目:atlas    文件:Framework.java   
public static void removeFrameworkListener(FrameworkListener listener) {
    frameworkListeners.remove(listener);
}
项目:gemini.blueprint    文件:MockBundleContext.java   
public void addFrameworkListener(FrameworkListener listener) {
}
项目:gemini.blueprint    文件:MockBundleContext.java   
public void removeFrameworkListener(FrameworkListener listener) {
}
项目:ACDD    文件:Framework.java   
static void addFrameworkListener(FrameworkListener frameworkListener) {
    frameworkListeners.add(frameworkListener);
}
项目:ACDD    文件:Framework.java   
static void removeFrameworkListener(FrameworkListener frameworkListener) {
    frameworkListeners.remove(frameworkListener);
}
项目:ACDD    文件:ACDD.java   
public void addFrameworkListener(FrameworkListener frameworkListener) {
    Framework.addFrameworkListener(frameworkListener);
}
项目:ACDD    文件:ACDD.java   
public void removeFrameworkListener(FrameworkListener frameworkListener) {
    Framework.removeFrameworkListener(frameworkListener);
}
项目: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-in-action    文件:MockBundleContext.java   
public void addFrameworkListener( FrameworkListener arg0 )
{
}
项目:osgi-in-action    文件:MockBundleContext.java   
public void removeFrameworkListener( FrameworkListener arg0 )
{
}
项目:AtlasForAndroid    文件:Atlas.java   
public void addFrameworkListener(FrameworkListener frameworkListener) {
    Framework.addFrameworkListener(frameworkListener);
}
项目:AtlasForAndroid    文件:Atlas.java   
public void removeFrameworkListener(FrameworkListener frameworkListener) {
    Framework.removeFrameworkListener(frameworkListener);
}
项目:AtlasForAndroid    文件:Framework.java   
static void addFrameworkListener(FrameworkListener frameworkListener) {
    frameworkListeners.add(frameworkListener);
}
项目:AtlasForAndroid    文件:Framework.java   
static void removeFrameworkListener(FrameworkListener frameworkListener) {
    frameworkListeners.remove(frameworkListener);
}
项目:EASyProducer    文件:FakeBundleContext.java   
@Override
public void addFrameworkListener(FrameworkListener arg0) {
}
项目:EASyProducer    文件:FakeBundleContext.java   
@Override
public void removeFrameworkListener(FrameworkListener arg0) {
}
项目:p3-stanbol-engine-fam    文件:MockComponentContext.java   
@Override
public void addFrameworkListener(FrameworkListener listener) {
    throw new UnsupportedOperationException("Mock implementation");
}
项目:p3-stanbol-engine-fam    文件:MockComponentContext.java   
@Override
public void removeFrameworkListener(FrameworkListener listener) {
    throw new UnsupportedOperationException("Mock implementation");
}
项目:spring-osgi    文件:MockBundleContext.java   
public void addFrameworkListener(FrameworkListener listener) {
}
项目:spring-osgi    文件:MockBundleContext.java   
public void removeFrameworkListener(FrameworkListener listener) {
}
项目:osgi_in_action-    文件:MockBundleContext.java   
public void addFrameworkListener( FrameworkListener arg0 )
{
}
项目:osgi_in_action-    文件:MockBundleContext.java   
public void removeFrameworkListener( FrameworkListener arg0 )
{
}
项目:musicTreePrograms    文件:MyBundleContext.java   
@Override
public void addFrameworkListener(FrameworkListener listener) {
  /* empty */
}
项目:musicTreePrograms    文件:MyBundleContext.java   
@Override
public void removeFrameworkListener(FrameworkListener listener) {
  /* empty */
}
项目:musicTreePrograms    文件:MyBundleContext.java   
@Override
public void addFrameworkListener(FrameworkListener listener) {
  /* empty */
}
项目:musicTreePrograms    文件:MyBundleContext.java   
@Override
public void removeFrameworkListener(FrameworkListener listener) {
  /* empty */
}