本文整理汇总了Java中org.osgi.service.blueprint.container.BlueprintListener类的典型用法代码示例。如果您正苦于以下问题:Java BlueprintListener类的具体用法?Java BlueprintListener怎么用?Java BlueprintListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlueprintListener类属于org.osgi.service.blueprint.container包,在下文中一共展示了BlueprintListener类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.osgi.service.blueprint.container.BlueprintListener; //导入依赖的package包/类
@Override
public void start( BundleContext bundleContext ) throws Exception {
BlueprintStateServiceImpl blueprintServiceImpl = new BlueprintStateServiceImpl( bundleContext );
bundleContext
.registerService( new String[] { BlueprintListener.class.getName(), BlueprintStateService.class.getName() },
blueprintServiceImpl, null );
KarafBlueprintWatcherImpl karafBlueprintWatcher = new KarafBlueprintWatcherImpl( bundleContext );
bundleContext.registerService( IKarafBlueprintWatcher.class.getName(), karafBlueprintWatcher, null );
bundleContext.registerService( ProxyUnwrapper.class.getName(), new ProxyUnwrapperImpl( bundleContext ), null );
bundleContext.registerService( BeanFactoryLocator.class.getName(), new BeanFactoryLocatorImpl(), null );
ServiceReference ref = bundleContext.getServiceReference( ConfigurationAdmin.class.getName() );
ConfigurationAdmin admin = (ConfigurationAdmin) bundleContext.getService( ref );
KarafFeatureWatcherImpl karafFeatureWatcher = new KarafFeatureWatcherImpl( bundleContext );
bundleContext.registerService( IKarafFeatureWatcher.class.getName(), karafFeatureWatcher, null );
}
示例2: dispatchReplayEvents
import org.osgi.service.blueprint.container.BlueprintListener; //导入依赖的package包/类
void dispatchReplayEvents(BlueprintListener listener) {
synchronized (events) {
for (BlueprintEvent event : events.values()) {
listener.blueprintEvent(event);
}
}
}
示例3: BlueprintListenerManager
import org.osgi.service.blueprint.container.BlueprintListener; //导入依赖的package包/类
public BlueprintListenerManager(BundleContext context) {
this.replayManager = new ReplayEventManager(context);
OsgiServiceCollectionProxyFactoryBean fb = new OsgiServiceCollectionProxyFactoryBean();
fb.setBundleContext(context);
fb.setAvailability(Availability.OPTIONAL);
fb.setCollectionType(CollectionType.LIST);
fb.setInterfaces(new Class[] { BlueprintListener.class });
fb.setBeanClassLoader(BundleDelegatingClassLoader.createBundleClassLoaderFor(context.getBundle()));
fb.setListeners(new OsgiServiceLifecycleListener[] { new RegistrationReplayDelivery() });
fb.afterPropertiesSet();
cleanupHook = fb;
listeners = (List) fb.getObject();
}
示例4: blueprintEvent
import org.osgi.service.blueprint.container.BlueprintListener; //导入依赖的package包/类
public void blueprintEvent(BlueprintEvent event) {
replayManager.addEvent(event);
for (BlueprintListener listener : listeners) {
try {
listener.blueprintEvent(event);
} catch (Exception ex) {
log.warn("exception encountered when calling listener " + System.identityHashCode(listener), ex);
}
}
}
示例5: waitForBlueprintContainer
import org.osgi.service.blueprint.container.BlueprintListener; //导入依赖的package包/类
/**
* Synchronization method to wait for particular state of BlueprintContainer under test.
*/
public static void waitForBlueprintContainer(final Set<Long> eventHistory, BundleContext context,
final String symbolicName, final int bpEvent, final Runnable runAndWait)
throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final Throwable[] pThrowable = new Throwable[] {null};
ServiceRegistration<BlueprintListener> registration = context.registerService(BlueprintListener.class, new BlueprintListener() {
@Override
public void blueprintEvent(BlueprintEvent event) {
if (event.getBundle().getSymbolicName().equals(symbolicName)) {
if (event.getType() == bpEvent) {
// we skip events that we've already seen
// it works with BP container reloads if next CREATE state is at least 1ms after previous one
if (eventHistory == null || eventHistory.add(event.getTimestamp())) {
latch.countDown();
}
} else if (event.getType() == BlueprintEvent.FAILURE) {
// we didn't wait for FAILURE, but we got it - fail fast then
pThrowable[0] = event.getCause();
latch.countDown();
}
}
}
}, null);
if (runAndWait != null) {
runAndWait.run();
}
latch.await(BlueprintHelper.DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
registration.unregister();
if (pThrowable[0] != null) {
throw new RuntimeException(pThrowable[0].getMessage(), pThrowable[0]);
}
}
示例6: init
import org.osgi.service.blueprint.container.BlueprintListener; //导入依赖的package包/类
public void init() throws Exception {
LOG.trace("init {}", this);
// add service listener so we can be notified when blueprint container is done
// and we would be ready to start CamelContext
bundleContext.addServiceListener(this);
// add blueprint listener as service, as we need this for the blueprint container
// to support change events when it changes states
registration = bundleContext.registerService(BlueprintListener.class, this, null);
}
示例7: waitForBlueprintContainer
import org.osgi.service.blueprint.container.BlueprintListener; //导入依赖的package包/类
/**
* Synchronization method to wait for particular state of BlueprintContainer under test.
*/
public static void waitForBlueprintContainer(final Set<Long> eventHistory, BundleContext context,
final String symbolicName, final int bpEvent, final Runnable runAndWait)
throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final Throwable[] pThrowable = new Throwable[] {null};
ServiceRegistration<BlueprintListener> registration = context.registerService(BlueprintListener.class, new BlueprintListener() {
@Override
public void blueprintEvent(BlueprintEvent event) {
if (event.getBundle().getSymbolicName().equals(symbolicName)) {
if (event.getType() == bpEvent) {
// we skip events that we've already seen
// it works with BP container reloads if next CREATE state is at least 1ms after previous one
if (eventHistory == null || eventHistory.add(event.getTimestamp())) {
latch.countDown();
}
} else if (event.getType() == BlueprintEvent.FAILURE) {
// we didn't wait for FAILURE, but we got it - fail fast then
pThrowable[0] = event.getCause();
latch.countDown();
}
}
}
}, null);
if (runAndWait != null) {
runAndWait.run();
}
latch.await(CamelBlueprintHelper.DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
registration.unregister();
if (pThrowable[0] != null) {
throw new RuntimeException(pThrowable[0].getMessage(), pThrowable[0]);
}
}
示例8: start
import org.osgi.service.blueprint.container.BlueprintListener; //导入依赖的package包/类
@Override
public void start(final BundleContext context) throws Exception {
BlueprintListenerImpl blueprintListener = new BlueprintListenerImpl();
blueprintListenerSR = context.registerService(BlueprintListener.class, blueprintListener,
new Hashtable<String, Object>());
Hashtable<String, String> servletProps = new Hashtable<String, String>();
servletProps.put("felix.webconsole.label", "everit_blueprint_events");
servletProps.put("felix.webconsole.category", "Everit");
servletProps.put("felix.webconsole.title", "Blueprint Events");
Servlet blueprintServlet = new BlueprintServlet(blueprintListener);
blueprintServletSR = context.registerService(Servlet.class, blueprintServlet, servletProps);
}
示例9: bind
import org.osgi.service.blueprint.container.BlueprintListener; //导入依赖的package包/类
public void bind(Object service, Map properties) throws Exception {
BlueprintListener listener = (BlueprintListener) service;
replayManager.dispatchReplayEvents(listener);
}