/** * 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); } }
/** * 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; } }
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(); } }
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); } } }
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); } }
public void removeFrameworkListener(FrameworkListener frameworkListener) { checkValid(); Framework.frameworkListeners.remove(frameworkListener); this.bundle.registeredFrameworkListeners.remove(frameworkListener); if (this.bundle.registeredFrameworkListeners.isEmpty()) { this.bundle.registeredFrameworkListeners = null; } }
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); } } }
@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(); }
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; }
public void addFrameworkListener(FrameworkListener fl) { throw new UnsupportedOperationException("Not supported yet."); }
public void removeFrameworkListener(FrameworkListener fl) { throw new UnsupportedOperationException("Not supported yet."); }
public void removeFrameworkListener(FrameworkListener fl) { delegate.removeFrameworkListener(fl); }
public void addFrameworkListener(FrameworkListener fl) { delegate.addFrameworkListener(fl); }
public static void addFrameworkListener(FrameworkListener listener) { frameworkListeners.add(listener); }
public static void removeFrameworkListener(FrameworkListener listener) { frameworkListeners.remove(listener); }
public void addFrameworkListener(FrameworkListener listener) { }
public void removeFrameworkListener(FrameworkListener listener) { }
static void addFrameworkListener(FrameworkListener frameworkListener) { frameworkListeners.add(frameworkListener); }
static void removeFrameworkListener(FrameworkListener frameworkListener) { frameworkListeners.remove(frameworkListener); }
public void addFrameworkListener(FrameworkListener frameworkListener) { Framework.addFrameworkListener(frameworkListener); }
public void removeFrameworkListener(FrameworkListener frameworkListener) { Framework.removeFrameworkListener(frameworkListener); }
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(); }
public void addFrameworkListener( FrameworkListener arg0 ) { }
public void removeFrameworkListener( FrameworkListener arg0 ) { }
@Override public void addFrameworkListener(FrameworkListener arg0) { }
@Override public void removeFrameworkListener(FrameworkListener arg0) { }
@Override public void addFrameworkListener(FrameworkListener listener) { throw new UnsupportedOperationException("Mock implementation"); }
@Override public void removeFrameworkListener(FrameworkListener listener) { throw new UnsupportedOperationException("Mock implementation"); }
@Override public void addFrameworkListener(FrameworkListener listener) { /* empty */ }
@Override public void removeFrameworkListener(FrameworkListener listener) { /* empty */ }