當前位置: 首頁>>代碼示例>>Java>>正文


Java BundleListener類代碼示例

本文整理匯總了Java中org.osgi.framework.BundleListener的典型用法代碼示例。如果您正苦於以下問題:Java BundleListener類的具體用法?Java BundleListener怎麽用?Java BundleListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BundleListener類屬於org.osgi.framework包,在下文中一共展示了BundleListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: notifyBundleListeners

import org.osgi.framework.BundleListener; //導入依賴的package包/類
/**
 * notify all bundle listeners.
 *
 * @param state the new state.
 * @param bundle the bundle.
 */
static void notifyBundleListeners(final int state, final Bundle bundle) {
    if (syncBundleListeners.isEmpty() && bundleListeners.isEmpty()) {
        return;
    }

    final BundleEvent event = new BundleEvent(state, bundle);

    // inform the synchrounous bundle listeners first ...
    final BundleListener[] syncs = (BundleListener[]) syncBundleListeners.toArray(new BundleListener[syncBundleListeners.size()]);

    for (int i = 0; i < syncs.length; i++) {
        syncs[i].bundleChanged(event);
    }

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

    final BundleListener[] asyncs = (BundleListener[]) bundleListeners.toArray(new BundleListener[bundleListeners.size()]);
    for (int i = 0; i < asyncs.length; i++) {
        asyncs[i].bundleChanged(event);
    }
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:30,代碼來源:Framework.java

示例2: notifyBundleListeners

import org.osgi.framework.BundleListener; //導入依賴的package包/類
static void notifyBundleListeners(int event, Bundle bundle) {

        if (!syncBundleListeners.isEmpty() || !bundleListeners.isEmpty()) {
            BundleEvent bundleEvent = new BundleEvent(event, bundle);
            BundleListener[] bundleListenerArr = syncBundleListeners.toArray(new BundleListener[syncBundleListeners.size()]);
            for (BundleListener bundleChanged : bundleListenerArr) {
                bundleChanged.bundleChanged(bundleEvent);
            }
            if (!bundleListeners.isEmpty()) {
                bundleListenerArr = bundleListeners.toArray(new BundleListener[bundleListeners.size()]);
                for (BundleListener bundleListener : bundleListenerArr) {
                    bundleListener.bundleChanged(bundleEvent);
                }

            }
        }
    }
 
開發者ID:bunnyblue,項目名稱:ACDD,代碼行數:18,代碼來源:Framework.java

示例3: notifyBundleListeners

import org.osgi.framework.BundleListener; //導入依賴的package包/類
static void notifyBundleListeners(int i, Bundle bundle) {
    int i2 = 0;
    if (!syncBundleListeners.isEmpty() || !bundleListeners.isEmpty()) {
        BundleEvent bundleEvent = new BundleEvent(i, bundle);
        BundleListener[] bundleListenerArr = (BundleListener[]) syncBundleListeners.toArray(new BundleListener[syncBundleListeners.size()]);
        for (BundleListener bundleChanged : bundleListenerArr) {
            bundleChanged.bundleChanged(bundleEvent);
        }
        if (!bundleListeners.isEmpty()) {
            bundleListenerArr = (BundleListener[]) bundleListeners.toArray(new BundleListener[bundleListeners.size()]);
            while (i2 < bundleListenerArr.length) {
                bundleListenerArr[i2].bundleChanged(bundleEvent);
                i2++;
            }
        }
    }
}
 
開發者ID:achellies,項目名稱:AtlasForAndroid,代碼行數:18,代碼來源:Framework.java

示例4: stop

import org.osgi.framework.BundleListener; //導入依賴的package包/類
@Test
public void stop() throws Exception {
  ArgumentCaptor<BundleListener> bundleListenerCaptor = ArgumentCaptor.forClass( BundleListener.class );

  BundleContext mockBundleContext = mock( BundleContext.class );
  final ServiceRegistration mockServiceRegistration = mock( ServiceRegistration.class );
  when( mockBundleContext
      .registerService( eq( PentahoWebPackageService.class ), any( PentahoWebPackageService.class ), any() ) )
      .thenReturn( mockServiceRegistration );

  this.activator.start( mockBundleContext );

  verify( mockBundleContext, times( 1 ) ).addBundleListener( bundleListenerCaptor.capture() );

  this.activator.stop( mockBundleContext );

  verify( mockServiceRegistration, times( 1 ) ).unregister();
  verify( mockBundleContext, times( 1 ) ).removeBundleListener( same( bundleListenerCaptor.getValue() ) );
}
 
開發者ID:pentaho,項目名稱:pentaho-osgi-bundles,代碼行數:20,代碼來源:ActivatorTest.java

示例5: FileAssociationChecker

import org.osgi.framework.BundleListener; //導入依賴的package包/類
public FileAssociationChecker()
{
    mEditorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
    mJobName = EclipseNSISStartup.getResourceString("job.name"); //$NON-NLS-1$
    mDialogTitleFormat = new MessageFormat(EclipseNSISStartup.getResourceString("dialog.title.format")); //$NON-NLS-1$
    mDialogMessageFormat = new MessageFormat(EclipseNSISStartup.getResourceString("dialog.message.format")); //$NON-NLS-1$
    mDialogToggleMessageFormat = new MessageFormat(EclipseNSISStartup.getResourceString("dialog.toggle.message.format")); //$NON-NLS-1$
    final IExtensionTracker tracker = PlatformUI.getWorkbench().getExtensionTracker();
    loadExtensions(tracker);
    tracker.registerHandler(this, ExtensionTracker.createExtensionPointFilter(getExtensionPointFilter()));
    final BundleContext bundleContext = EclipseNSISStartup.getDefault().getBundleContext();
    bundleContext.addBundleListener(new BundleListener() {
        public void bundleChanged(BundleEvent event)
        {
            if(event.getType() == BundleEvent.STOPPED ) {
                bundleContext.removeBundleListener(this);
            }
            tracker.unregisterHandler(FileAssociationChecker.this);
            Job.getJobManager().cancel(JOB_FAMILY);
        }
    });
}
 
開發者ID:henrikor2,項目名稱:eclipsensis,代碼行數:23,代碼來源:FileAssociationChecker.java

示例6: addBundlerListener

import org.osgi.framework.BundleListener; //導入依賴的package包/類
private void addBundlerListener(BundleContext context) {
	// Listen for our STARTED event
	// Alternatively, we can get the bundle from org.osgi.framework.FrameworkUtil
	context.addBundleListener(new BundleListener() {
		public void bundleChanged(BundleEvent event) {
			String name = event.getBundle().getSymbolicName();
			if (name != null && name.equals(PLUGIN_ID)) {
				switch (event.getType()) {
					case BundleEvent.STARTED:
						bundleStarted();
						break;
					case BundleEvent.UNINSTALLED:
						emacsIds = null;
						break;
					default:
						break;
				}
			}
		}
	});
}
 
開發者ID:MulgaSoft,項目名稱:e4macs,代碼行數:22,代碼來源:EmacsPlusActivator.java

示例7: MockBundleContext

import org.osgi.framework.BundleListener; //導入依賴的package包/類
/**
 * Constructs a new <code>MockBundleContext</code> instance allowing both
 * the bundle and the context properties to be specified.
 * 
 * @param bundle associated bundle
 * @param props context properties
 */
public MockBundleContext(Bundle bundle, Properties props) {
	this.bundle = (bundle == null ? new MockBundle(this) : bundle);
	properties = new Properties(DEFAULT_PROPERTIES);
	if (props != null)
		properties.putAll(props);

       // make sure the order is preserved
       this.serviceListeners = new LinkedHashSet<ServiceListener>(2);
       this.bundleListeners = new LinkedHashSet<BundleListener>(2);
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:18,代碼來源:MockBundleContext.java

示例8: EclipseClassProvider

import org.osgi.framework.BundleListener; //導入依賴的package包/類
/**
 * Constructor.
 * 
 * @param context
 *            the {@link BundleContext}
 * @param classLoader
 *            the fall back {@link ClassLoader}
 */
public EclipseClassProvider(BundleContext context, ClassLoader classLoader) {
    super(classLoader);
    this.context = context;
    for (Bundle bundle : context.getBundles()) {
        bundles.put(bundle.getSymbolicName(), bundle);
    }
    listener = new BundleListener() {

        @Override
        public void bundleChanged(BundleEvent event) {
            switch (event.getType()) {
                case BundleEvent.INSTALLED:
                    bundles.put(event.getBundle().getSymbolicName(), event.getBundle());
                    break;

                case BundleEvent.UNINSTALLED:
                    bundles.remove(event.getBundle().getSymbolicName());
                    break;

                default:
                    // nothing to do here
                    break;
            }
        }
    };
    context.addBundleListener(listener);
}
 
開發者ID:ObeoNetwork,項目名稱:M2Doc,代碼行數:36,代碼來源:EclipseClassProvider.java

示例9: start

import org.osgi.framework.BundleListener; //導入依賴的package包/類
/**
 * Starts the OSGi bundle by registering the engine with the bundle of the
 * Restlet API.
 * 
 * @param context
 *            The bundle context.
 */
public void start(BundleContext context) throws Exception {
    org.restlet.engine.Engine.register(false);

    // Discover helpers in installed bundles and start
    // the bundle if necessary
    for (final Bundle bundle : context.getBundles()) {
        registerHelpers(bundle);
    }

    // Listen to installed bundles
    context.addBundleListener(new BundleListener() {
        public void bundleChanged(BundleEvent event) {
            switch (event.getType()) {
            case BundleEvent.INSTALLED:
                registerHelpers(event.getBundle());
                break;

            case BundleEvent.UNINSTALLED:
                break;
            }
        }
    });

    Engine.getInstance().registerDefaultConnectors();
    Engine.getInstance().registerDefaultAuthentications();
    Engine.getInstance().registerDefaultConverters();
}
 
開發者ID:restlet,項目名稱:restlet-framework,代碼行數:35,代碼來源:Activator.java

示例10: afterPropertiesSet

import org.osgi.framework.BundleListener; //導入依賴的package包/類
@Override
public void afterPropertiesSet() throws Exception {
	Assert.notNull(context);
	Assert.notNull(serviceStateManager);
	Assert.notNull(serviceFactoryImpl);
	dataServiceTracker = new ServiceTracker(context, BaseDataService.class.getName(),
			new DataServiceTrackerCustomizer());
	serviceInterceptorTracker = new ServiceTracker(context, ServiceInterceptor.class.getName(),
			new ServiceInterceptorTrackerCustomizer());

	dataServiceTracker.open(true);
	serviceInterceptorTracker.open(true);

	context.addBundleListener(new BundleListener() {

		@Override
		public void bundleChanged(BundleEvent event) {
			if (event.getType() == BundleEvent.UNINSTALLED) {
				String name = event.getBundle().getSymbolicName();
				try {
					logger.info("uninstall bundle " + name);
					zookeeper.deleteNodeByBundle(name);
					ServiceWatcher.this.nodeUpdate();
				} catch (Exception e) {
					logger.error(
							"zookeeper delete service by bundle, bundle name : "
									+ name, e);
				}
			}
		}
	});

	logger.info("服務監聽啟動");
}
 
開發者ID:javen-hao,項目名稱:osmp,代碼行數:35,代碼來源:ServiceWatcher.java

示例11: start

import org.osgi.framework.BundleListener; //導入依賴的package包/類
/**
 * Starts the framework. There is usually no reason to call this method manually because it will
 * be invoked automatically by the {@link #initializationComplete()} callback.
 *
 * @throws BundleException
 *             Exception.
 */
public synchronized void start() throws BundleException {
    if (this.framework == null) {
        this.prepareFramework();
    }
    for (BundleListener listener : listeners) {
        framework.getBundleContext().addBundleListener(listener);
    }
    framework.start();
    fileInstall.updated("initial", propertiesDictionary);
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:18,代碼來源:OSGiManagement.java

示例12: registerListener

import org.osgi.framework.BundleListener; //導入依賴的package包/類
void registerListener(Framework f) {
	f.getBundleContext().addBundleListener(new BundleListener() {

		@Override
		public void bundleChanged(BundleEvent e) {
			Log.d(TAG, "bundleChanged. event:" + e);

		}
	});
}
 
開發者ID:luoqii,項目名稱:ApkLauncher,代碼行數:11,代碼來源:FrameworkHelper.java

示例13: addBundleListener

import org.osgi.framework.BundleListener; //導入依賴的package包/類
public void addBundleListener(BundleListener bundleListener) {
    checkValid();
    List list = bundleListener instanceof SynchronousBundleListener ? Framework.syncBundleListeners : Framework.bundleListeners;
    if (this.bundle.registeredBundleListeners == null) {
        this.bundle.registeredBundleListeners = new ArrayList();
    }
    if (!this.bundle.registeredBundleListeners.contains(bundleListener)) {
        list.add(bundleListener);
        this.bundle.registeredBundleListeners.add(bundleListener);
    }
}
 
開發者ID:achellies,項目名稱:AtlasForAndroid,代碼行數:12,代碼來源:BundleContextImpl.java

示例14: removeBundleListener

import org.osgi.framework.BundleListener; //導入依賴的package包/類
public void removeBundleListener(BundleListener bundleListener) {
    checkValid();
    (bundleListener instanceof SynchronousBundleListener ? Framework.syncBundleListeners : Framework.bundleListeners).remove(bundleListener);
    this.bundle.registeredBundleListeners.remove(bundleListener);
    if (this.bundle.registeredBundleListeners.isEmpty()) {
        this.bundle.registeredBundleListeners = null;
    }
}
 
開發者ID:achellies,項目名稱:AtlasForAndroid,代碼行數:9,代碼來源:BundleContextImpl.java

示例15: earlyStartup

import org.osgi.framework.BundleListener; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void earlyStartup() {

  // check if plug-in org.eclipse.jdt.ui is final already active
  final Bundle bundle = Platform.getBundle(JAVA_PLUGIN_ID);
  if (bundle != null && bundle.getState() == Bundle.ACTIVE) {
    registerResolvers();
  } else {
    // register listener to final get informed, when plug-in final becomes
    // active
    final BundleContext bundleContext = Activator.getDefault().getBundle().getBundleContext();
    bundleContext.addBundleListener(new BundleListener() {

      @Override
      public void bundleChanged(final BundleEvent pEvent) {

        final Bundle eventBundle = pEvent.getBundle();
        if (!eventBundle.getSymbolicName().equals(JAVA_PLUGIN_ID)) {
          // ignore other plugins
          return;
        }
        if (eventBundle.getState() == Bundle.ACTIVE) {
          registerResolvers();
          bundleContext.removeBundleListener(this);
        }
      }
    });
  }
}
 
開發者ID:m-m-m,項目名稱:eclipse-templatevariables,代碼行數:33,代碼來源:TemplateVariablesStartup.java


注:本文中的org.osgi.framework.BundleListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。