本文整理汇总了Java中org.osgi.framework.Bundle.STOPPING属性的典型用法代码示例。如果您正苦于以下问题:Java Bundle.STOPPING属性的具体用法?Java Bundle.STOPPING怎么用?Java Bundle.STOPPING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.osgi.framework.Bundle
的用法示例。
在下文中一共展示了Bundle.STOPPING属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bundleChanged
public @Override void bundleChanged(BundleEvent event) {
Bundle bundle = event.getBundle();
switch (event.getType()) {
case BundleEvent.STARTED:
// System.err.println("started " + bundle.getSymbolicName());
Dictionary<?,?> headers = bundle.getHeaders();
load(queue.offer(bundle, provides(headers), requires(headers), needs(headers)));
break;
case BundleEvent.STOPPED:
// System.err.println("stopped " + bundle.getSymbolicName());
if (framework.getState() == Bundle.STOPPING) {
// System.err.println("fwork stopping during " + bundle.getSymbolicName());
// ActiveQueue.stop();
} else {
unload(queue.retract(bundle));
}
break;
}
}
示例2: activate
@Activate
void activate(BundleContext ctx) {
this.base = new File("").toURI();
// Find the resolved vaadin bundle
this.vaadinResourceBundles = new BundleTracker<Bundle>(ctx, Bundle.RESOLVED |
Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING,
new BundleTrackerCustomizer<Bundle>() {
@Override
public Bundle addingBundle(Bundle bundle, BundleEvent event) {
return VAADIN_SERVER_BUNDLE.equals(bundle.getSymbolicName()) ?
bundle : null;
}
@Override
public void modifiedBundle(Bundle bundle, BundleEvent event, Bundle object) {
}
@Override
public void removedBundle(Bundle bundle, BundleEvent event, Bundle object) {
}
});
this.vaadinResourceBundles.open();
}
示例3: addEvent
void addEvent(BlueprintEvent event) {
// copy event
BlueprintEvent replay = new BlueprintEvent(event, true);
Bundle bnd = replay.getBundle();
if (bnd.getState() == Bundle.ACTIVE || bnd.getState() == Bundle.STARTING || bnd.getState() == Bundle.STOPPING) {
events.put(bnd, replay);
if (log.isTraceEnabled())
log.trace("Adding replay event " + replay.getType() + " for bundle " + replay.getBundle());
} else {
if (log.isTraceEnabled()) {
log.trace("Replay event " + replay.getType() + " ignored; " + "owning bundle has been uninstalled "
+ bnd);
events.remove(bnd);
}
}
}
示例4: testIsBundleResolved
public void testIsBundleResolved() throws Exception {
OsgiBundleUtilsTest.state = Bundle.UNINSTALLED;
assertFalse(OsgiBundleUtils.isBundleResolved(bundle));
OsgiBundleUtilsTest.state = Bundle.INSTALLED;
assertFalse(OsgiBundleUtils.isBundleResolved(bundle));
OsgiBundleUtilsTest.state = Bundle.ACTIVE;
assertTrue(OsgiBundleUtils.isBundleResolved(bundle));
OsgiBundleUtilsTest.state = Bundle.RESOLVED;
assertTrue(OsgiBundleUtils.isBundleResolved(bundle));
OsgiBundleUtilsTest.state = Bundle.STOPPING;
assertTrue(OsgiBundleUtils.isBundleResolved(bundle));
OsgiBundleUtilsTest.state = Bundle.STARTING;
assertTrue(OsgiBundleUtils.isBundleResolved(bundle));
}
示例5: isEnabled
public @Override boolean isEnabled() {
switch (b.getState()) {
case Bundle.RESOLVED:
case Bundle.ACTIVE:
case Bundle.STARTING:
case Bundle.STOPPING:
return true;
default:
return false;
}
}
示例6: start
@Override
public void start(BundleContext ctx) {
LOG.debug("Starting EclipseLink adapter");
context = ctx;
ctx.addBundleListener(this);
for (Bundle b : ctx.getBundles()) {
if ((b.getState() & (Bundle.ACTIVE | Bundle.STARTING | Bundle.RESOLVED | Bundle.STOPPING)) != 0)
handlePotentialEclipseLink(b);
}
}
示例7: testServiceListener
public void testServiceListener() throws Exception {
assertEquals("Expected initial binding of service", 1, MyListener.BOUND_COUNT);
assertEquals("Unexpected initial unbinding of service", 0, MyListener.UNBOUND_COUNT);
Bundle simpleServiceBundle = OsgiBundleUtils.findBundleBySymbolicName(bundleContext,
"org.eclipse.gemini.blueprint.iandt.simpleservice");
assertNotNull("Cannot find the simple service bundle", simpleServiceBundle);
simpleServiceBundle.stop();
while (simpleServiceBundle.getState() == Bundle.STOPPING) {
Thread.sleep(100);
}
assertEquals("Expected one binding of service", 1, MyListener.BOUND_COUNT);
assertTrue("Expected only one unbinding of service", MyListener.UNBOUND_COUNT < 2);
assertEquals("Expected unbinding of service not seen", 1, MyListener.UNBOUND_COUNT);
logger.debug("about to restart simple service");
simpleServiceBundle.start();
waitOnContextCreation("org.eclipse.gemini.blueprint.iandt.simpleservice");
// wait some more to let the listener binding propagate
Thread.sleep(1000);
logger.debug("simple service succesfully restarted");
assertTrue("Expected only two bindings of service", MyListener.BOUND_COUNT < 3);
assertEquals("Expected binding of service not seen", 2, MyListener.BOUND_COUNT);
assertEquals("Unexpected unbinding of service", 1, MyListener.UNBOUND_COUNT);
}
示例8: testReferenceProxyLifecycle
public void testReferenceProxyLifecycle() throws Exception {
MyService reference = ServiceReferer.serviceReference;
assertNotNull("reference not initialized", reference);
assertNotNull("no value specified in the reference", reference.stringValue());
Bundle simpleServiceBundle = OsgiBundleUtils.findBundleBySymbolicName(bundleContext,
"org.eclipse.gemini.blueprint.iandt.simpleservice");
assertNotNull("Cannot find the simple service bundle", simpleServiceBundle);
System.out.println("stopping bundle");
simpleServiceBundle.stop();
while (simpleServiceBundle.getState() == Bundle.STOPPING) {
System.out.println("waiting for bundle to stop");
Thread.sleep(10);
}
System.out.println("bundle stopped");
// Service should be unavailable
try {
reference.stringValue();
fail("ServiceUnavailableException should have been thrown!");
}
catch (ServiceUnavailableException e) {
// Expected
}
System.out.println("starting bundle");
simpleServiceBundle.start();
waitOnContextCreation("org.eclipse.gemini.blueprint.iandt.simpleservice");
System.out.println("bundle started");
// Service should be running
assertNotNull(reference.stringValue());
}
示例9: testGetBundleStateAsName
public void testGetBundleStateAsName() throws Exception {
OsgiStringUtilsTest.state = Bundle.ACTIVE;
assertEquals("ACTIVE", OsgiStringUtils.bundleStateAsString(bundle));
OsgiStringUtilsTest.state = Bundle.STARTING;
assertEquals("STARTING", OsgiStringUtils.bundleStateAsString(bundle));
OsgiStringUtilsTest.state = Bundle.STOPPING;
assertEquals("STOPPING", OsgiStringUtils.bundleStateAsString(bundle));
OsgiStringUtilsTest.state = -123;
assertEquals("UNKNOWN STATE", OsgiStringUtils.bundleStateAsString(bundle));
}
示例10: createEntityManagerFactory
@Override
public EntityManagerFactory createEntityManagerFactory(Map<String, Object> props) {
synchronized (this) {
if (closed) {
throw new IllegalStateException("The EntityManagerFactoryBuilder for " +
getPUName() + " is no longer valid");
}
}
if (bundle.getState() == Bundle.UNINSTALLED || bundle.getState() == Bundle.INSTALLED
|| bundle.getState() == Bundle.STOPPING) {
// Not sure why but during the TCK tests updated sometimes was
// called for uninstalled bundles
throw new IllegalStateException("The EntityManagerFactoryBuilder for " +
getPUName() + " is no longer valid");
}
Map<String, Object> processedProperties = processProperties(props);
synchronized (this) {
if(processedProperties.equals(activeProps) && emf != null) {
return emf;
}
}
closeEMF();
final EntityManagerFactory toUse = createAndPublishEMF(processedProperties);
return (EntityManagerFactory) Proxy.newProxyInstance(getClass().getClassLoader(),
new Class<?>[] {EntityManagerFactory.class}, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if("close".equals(method.getName())) {
// Close the registration as per the spec
closeEMF();
// Do not delegate as the closeEMF call already closes
return null;
}
return method.invoke(toUse, args);
}
});
}
示例11: assertAllBundlesResolved
private void assertAllBundlesResolved() {
int mask = Bundle.RESOLVED | Bundle.STARTING | Bundle.STOPPING | Bundle.ACTIVE;
for (Bundle bundle : this.bundleContext.getBundles()) {
assertTrue("Unresolved bundle " + bundle.getSymbolicName(), (bundle.getState() & mask) > 0);
}
}
示例12: testLifecycle
public void testLifecycle() throws Exception {
assertNotSame("Guinea pig has already been shutdown", "true",
System.getProperty("org.eclipse.gemini.blueprint.iandt.lifecycle.GuineaPig.close"));
assertEquals("Guinea pig didn't startup", "true",
System.getProperty("org.eclipse.gemini.blueprint.iandt.lifecycle.GuineaPig.startUp"));
Bundle[] bundles = bundleContext.getBundles();
Bundle testBundle = null;
for (int i = 0; i < bundles.length; i++) {
if ("org.eclipse.gemini.blueprint.iandt.lifecycle".equals(bundles[i].getSymbolicName())) {
testBundle = bundles[i];
break;
}
}
assertNotNull("Could not find the test bundle", testBundle);
StringBuilder filter = new StringBuilder();
filter.append("(&");
filter.append("(").append(Constants.OBJECTCLASS).append("=").append(ApplicationContext.class.getName()).append(")");
filter.append("(").append(ConfigurableOsgiBundleApplicationContext.APPLICATION_CONTEXT_SERVICE_PROPERTY_NAME);
filter.append("=").append(testBundle.getSymbolicName()).append(")");
filter.append(")");
logger.info("Creating filter = " + filter);
/*
[org.springframework.beans.factory.DisposableBean,
org.eclipse.gemini.blueprint.context.DelegatedExecutionOsgiBundleApplicationContext,
org.eclipse.gemini.blueprint.context.ConfigurableOsgiBundleApplicationContext,
org.springframework.context.ConfigurableApplicationContext,
org.springframework.context.ApplicationContext,
org.springframework.context.Lifecycle,
org.springframework.beans.factory.ListableBeanFactory,
org.springframework.beans.factory.HierarchicalBeanFactory,
org.springframework.context.MessageSource,
org.springframework.context.ApplicationEventPublisher,
org.springframework.core.io.support.ResourcePatternResolver,
org.springframework.beans.factory.BeanFactory,
org.springframework.core.io.ResourceLoader]
*/
// ServiceTracker tracker = new ServiceTracker(bundleContext, bundleContext.createFilter(filter.toString()), null);
// ServiceTracker tracker = new ServiceTracker(testBundle.getBundleContext(), testBundle.getBundleContext().createFilter(filter.toString()), null);
// tracker.open();
try {
// logger.info("All Services");
// ServiceReference[] refs = bundleContext.getAllServiceReferences(ApplicationContext.class.getName(), null);
// printServiceRefs(refs);
// logger.info("Visible Services from local context");
// refs = bundleContext.getServiceReferences(null, filter.toString());
// printServiceRefs(refs);
// logger.info("Visible Services from test client context");
// refs = testBundle.getBundleContext().getServiceReferences(null, filter.toString());
// printServiceRefs(refs);
//
// logger.info("tracking count = " + tracker.getTrackingCount());
// AbstractRefreshableApplicationContext appContext = (AbstractRefreshableApplicationContext) tracker.waitForService(50000);
// logger.info("tracking count = " + tracker.getTrackingCount());
// AbstractRefreshableApplicationContext appContext = (AbstractRefreshableApplicationContext) tracker.getService();
ServiceReference[] refs = bundleContext.getServiceReferences((String)null, filter.toString());
assertEquals("Should have a single service matched", 1, refs.length);
AbstractRefreshableApplicationContext appContext = (AbstractRefreshableApplicationContext)bundleContext.getService(refs[0]);
assertNotNull("test application context", appContext);
assertTrue("application context is active", appContext.isActive());
testBundle.stop();
while (testBundle.getState() == Bundle.STOPPING) {
Thread.sleep(10);
}
assertEquals("Guinea pig didn't shutdown", "true",
System.getProperty("org.eclipse.gemini.blueprint.iandt.lifecycle.GuineaPig.close"));
assertFalse("application context is inactive", appContext.isActive());
} finally {
// tracker.close();
}
}