当前位置: 首页>>代码示例>>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;未经允许,请勿转载。