本文整理匯總了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);
}
}
示例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);
}
}
}
}
示例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++;
}
}
}
}
示例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() ) );
}
示例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);
}
});
}
示例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;
}
}
}
});
}
示例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);
}
示例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);
}
示例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();
}
示例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("服務監聽啟動");
}
示例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);
}
示例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);
}
});
}
示例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);
}
}
示例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;
}
}
示例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);
}
}
});
}
}