Java Code Examples for org.osgi.framework.BundleEvent#STARTING
The following examples show how to use
org.osgi.framework.BundleEvent#STARTING .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BundleStartTimeCalculator.java From sling-whiteboard with Apache License 2.0 | 5 votes |
@Override public void bundleChanged(BundleEvent event) { Bundle bundle = event.getBundle(); // this bundle is already starting by the time this is invoked. We also can't get proper timing // from the framework bundle if ( bundle.getBundleId() == Constants.SYSTEM_BUNDLE_ID || bundle.getBundleId() == ourBundleId ) { return; } synchronized (bundleToStartTime) { switch (event.getType()) { case BundleEvent.STARTING: bundleToStartTime.put(bundle.getBundleId(), new StartTime(bundle.getSymbolicName(), clock.millis())); break; case BundleEvent.STARTED: StartTime startTime = bundleToStartTime.get(bundle.getBundleId()); if ( startTime == null ) { Log.debug(getClass(), "No previous data for started bundle {}/{}", new Object[] { bundle.getBundleId(), bundle.getSymbolicName() }); return; } startTime.started(clock.millis()); break; default: // nothing to do here break; } } }
Example 2
Source File: Util.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static String bundleEventName(int type) { switch (type) { case BundleEvent.INSTALLED: return "installed"; case BundleEvent.STARTED: return "started"; case BundleEvent.STOPPED: return "stopped"; case BundleEvent.UNINSTALLED: return "uninstalled"; case BundleEvent.UPDATED: return "updated"; case BundleEvent.RESOLVED: return "resolved"; case BundleEvent.UNRESOLVED: return "unresolved"; case BundleEvent.STARTING: return "starting"; case BundleEvent.STOPPING: return "stopping"; case BundleEvent.LAZY_ACTIVATION: return "lazyActivation"; default: return "<" + type + ">"; } }
Example 3
Source File: Netigso.java From netbeans with Apache License 2.0 | 4 votes |
final void notifyBundleChange(final String symbolicName, final Version version, final int action) { final Exception stack = Netigso.LOG.isLoggable(Level.FINER) ? new Exception("StackTrace") : null; final Runnable doLog = new Runnable() { @Override public void run() { if (isEnabled(symbolicName)) { return; } final Mutex mutex = Main.getModuleSystem().getManager().mutex(); if (!mutex.isReadAccess()) { mutex.postReadRequest(this); return; } String type = "" + action; Level notify = Level.INFO; switch (action) { case BundleEvent.INSTALLED: return; // no message for installed case BundleEvent.RESOLVED: type = "resolved"; break; case BundleEvent.STARTED: type = "started"; break; case BundleEvent.STOPPED: type = "stopped"; break; case BundleEvent.UNINSTALLED: return; // nothing for uninstalled case BundleEvent.LAZY_ACTIVATION: type = "lazy"; notify = Level.FINEST; break; case BundleEvent.STARTING: type = "starting"; notify = Level.FINEST; break; } Netigso.LOG.log(notify, "bundle {0}@{2} {1}", new Object[]{ symbolicName, type, version }); if (stack != null) { Netigso.LOG.log(Level.FINER, null, stack); } } }; RP.post(doLog); }
Example 4
Source File: Concierge.java From concierge with Eclipse Public License 1.0 | 4 votes |
/** * notify all bundle listeners. * * @param state * the new state. * @param bundle * the bundle. */ void notifyBundleListeners(final int state, final Bundle bundle, final Bundle origin) { if (syncBundleListeners.isEmpty() && bundleListeners.isEmpty()) { return; } final BundleEvent event = new BundleEvent(state, bundle, origin); final SynchronousBundleListener[] syncs; final BundleListener[] asyncs; // call the hooks, if any if (!bundleEventHooks.isEmpty()) { final ArrayList<SynchronousBundleListener> syncListeners = new ArrayList<SynchronousBundleListener>( syncBundleListeners); final ArrayList<BundleListener> asyncListeners = new ArrayList<BundleListener>( bundleListeners); final ConciergeCollections.DeltaTrackingRemoveOnlyList<BundleContext> contexts = new ConciergeCollections.DeltaTrackingRemoveOnlyList<BundleContext>( bundleListenerMap.keySet()); for (final ServiceReferenceImpl<org.osgi.framework.hooks.bundle.EventHook> sref : bundleEventHooks) { final org.osgi.framework.hooks.bundle.EventHook eventHook = sref .getService(Concierge.this); if (eventHook != null) { try { eventHook.event(event, contexts); } catch (final Throwable t) { // TODO: to log? } } sref.ungetService(Concierge.this); } for (final BundleContext removed : contexts.getRemoved()) { if(removed != this.context){ // system bundle contexts listeners always gets events for (final BundleListener listener : bundleListenerMap .get(removed)) { syncListeners.remove(listener); asyncListeners.remove(listener); } } } syncs = syncListeners.toArray( new SynchronousBundleListener[syncListeners.size()]); asyncs = asyncListeners .toArray(new BundleListener[asyncListeners.size()]); } else { syncs = syncBundleListeners.toArray( new SynchronousBundleListener[syncBundleListeners.size()]); asyncs = bundleListeners .toArray(new BundleListener[bundleListeners.size()]); } for (int i = 0; i < syncs.length; i++) { syncs[i].bundleChanged(event); } // asynchronous listeners do not get these events final int type = event.getType(); if (bundleListeners.isEmpty() || (type & (BundleEvent.STARTING | BundleEvent.STOPPING | BundleEvent.LAZY_ACTIVATION)) > 0) { return; } for (int i = 0; i < asyncs.length; i++) { asyncs[i].bundleChanged(event); } }