本文整理汇总了Java中org.osgi.framework.FrameworkListener类的典型用法代码示例。如果您正苦于以下问题:Java FrameworkListener类的具体用法?Java FrameworkListener怎么用?Java FrameworkListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FrameworkListener类属于org.osgi.framework包,在下文中一共展示了FrameworkListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: notifyFrameworkListeners
import org.osgi.framework.FrameworkListener; //导入依赖的package包/类
/**
* 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);
}
}
示例2: start
import org.osgi.framework.FrameworkListener; //导入依赖的package包/类
/**
* 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;
}
}
示例3: start
import org.osgi.framework.FrameworkListener; //导入依赖的package包/类
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();
}
}
示例4: notifyFrameworkListeners
import org.osgi.framework.FrameworkListener; //导入依赖的package包/类
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);
}
}
}
示例5: addFrameworkListener
import org.osgi.framework.FrameworkListener; //导入依赖的package包/类
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);
}
}
示例6: removeFrameworkListener
import org.osgi.framework.FrameworkListener; //导入依赖的package包/类
public void removeFrameworkListener(FrameworkListener frameworkListener) {
checkValid();
Framework.frameworkListeners.remove(frameworkListener);
this.bundle.registeredFrameworkListeners.remove(frameworkListener);
if (this.bundle.registeredFrameworkListeners.isEmpty()) {
this.bundle.registeredFrameworkListeners = null;
}
}
示例7: notifyFrameworkListeners
import org.osgi.framework.FrameworkListener; //导入依赖的package包/类
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);
}
}
}
示例8: start
import org.osgi.framework.FrameworkListener; //导入依赖的package包/类
@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();
}
示例9: setFrameworkStartLevel
import org.osgi.framework.FrameworkListener; //导入依赖的package包/类
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;
}
示例10: addFrameworkListener
import org.osgi.framework.FrameworkListener; //导入依赖的package包/类
public void addFrameworkListener(FrameworkListener fl) {
throw new UnsupportedOperationException("Not supported yet.");
}
示例11: removeFrameworkListener
import org.osgi.framework.FrameworkListener; //导入依赖的package包/类
public void removeFrameworkListener(FrameworkListener fl) {
throw new UnsupportedOperationException("Not supported yet.");
}
示例12: removeFrameworkListener
import org.osgi.framework.FrameworkListener; //导入依赖的package包/类
public void removeFrameworkListener(FrameworkListener fl) {
delegate.removeFrameworkListener(fl);
}
示例13: addFrameworkListener
import org.osgi.framework.FrameworkListener; //导入依赖的package包/类
public void addFrameworkListener(FrameworkListener fl) {
delegate.addFrameworkListener(fl);
}
示例14: addFrameworkListener
import org.osgi.framework.FrameworkListener; //导入依赖的package包/类
public static void addFrameworkListener(FrameworkListener listener) {
frameworkListeners.add(listener);
}
示例15: removeFrameworkListener
import org.osgi.framework.FrameworkListener; //导入依赖的package包/类
public static void removeFrameworkListener(FrameworkListener listener) {
frameworkListeners.remove(listener);
}