Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Renamed CDIContainerXXX event to BundleContainerXXX event

Added some @Observes methods to check

Note that the shutdown syso line do not appear :'(
  • Loading branch information...
commit 01a59255ddd0a3b85abf918b09cbf1d6bbf044df 1 parent d96ad30
@sauthieg authored
View
10 sample/bundle-gui/src/main/java/com/sample/osgi/cdi/startable/internal/AppStarter.java
@@ -12,6 +12,8 @@
import org.jboss.weld.environment.osgi.api.extension.Publish;
import org.jboss.weld.environment.osgi.api.extension.Startable;
import org.jboss.weld.environment.osgi.api.extension.events.AbstractServiceEvent;
+import org.jboss.weld.environment.osgi.api.extension.events.BundleContainerInitialized;
+import org.jboss.weld.environment.osgi.api.extension.events.BundleContainerShutdown;
@Startable
@Publish
@@ -36,4 +38,12 @@ public void bindService(@Observes @Specification(Instance.class) AbstractService
if (event.eventType() == AbstractServiceEvent.EventType.SERVICE_ARRIVAL)
event.type(Instance.class).getService();
}
+
+ public void onStartup(@Observes BundleContainerInitialized event) {
+ System.out.println("CDI COntainer for bundle " + event.getBundleContext().getBundle() + " started");
+ }
+
+ public void onShutdown(@Observes BundleContainerShutdown event) {
+ System.out.println("CDI COntainer for bundle " + event.getBundleContext().getBundle() + " stopped");
+ }
}
View
20 ...i-api/src/main/java/org/jboss/weld/environment/osgi/api/extension/events/BundleContainerInitialized.java
@@ -0,0 +1,20 @@
+package org.jboss.weld.environment.osgi.api.extension.events;
+
+import org.osgi.framework.BundleContext;
+
+/**
+ *
+ * @author Mathieu ANCELIN - SERLI (mathieu.ancelin@serli.com)
+ */
+public class BundleContainerInitialized {
+
+ private BundleContext bundleContext;
+
+ public BundleContainerInitialized(final BundleContext context) {
+ this.bundleContext = context;
+ }
+
+ public BundleContext getBundleContext() {
+ return bundleContext;
+ }
+}
View
20 ...osgi-api/src/main/java/org/jboss/weld/environment/osgi/api/extension/events/BundleContainerShutdown.java
@@ -0,0 +1,20 @@
+package org.jboss.weld.environment.osgi.api.extension.events;
+
+import org.osgi.framework.BundleContext;
+
+/**
+ *
+ * @author Mathieu ANCELIN - SERLI (mathieu.ancelin@serli.com)
+ */
+public class BundleContainerShutdown {
+
+ private BundleContext bundleContext;
+
+ public BundleContainerShutdown(final BundleContext context) {
+ this.bundleContext = context;
+ }
+
+ public BundleContext getBundleContext() {
+ return bundleContext;
+ }
+}
View
8 ...osgi-api/src/main/java/org/jboss/weld/environment/osgi/api/extension/events/CDIContainerInitialized.java
@@ -1,8 +0,0 @@
-package org.jboss.weld.environment.osgi.api.extension.events;
-
-/**
- *
- * @author Mathieu ANCELIN - SERLI (mathieu.ancelin@serli.com)
- */
-public class CDIContainerInitialized {
-}
View
8 weld-osgi-api/src/main/java/org/jboss/weld/environment/osgi/api/extension/events/CDIContainerShutdown.java
@@ -1,8 +0,0 @@
-package org.jboss.weld.environment.osgi.api.extension.events;
-
-/**
- *
- * @author Mathieu ANCELIN - SERLI (mathieu.ancelin@serli.com)
- */
-public class CDIContainerShutdown {
-}
View
8 weld-osgi-impl/src/main/java/org/jboss/weld/environment/osgi/integration/Weld.java
@@ -16,8 +16,8 @@
import org.jboss.weld.bootstrap.api.Bootstrap;
import org.jboss.weld.bootstrap.api.Environments;
-import org.jboss.weld.environment.osgi.api.extension.events.CDIContainerInitialized;
-import org.jboss.weld.environment.osgi.api.extension.events.CDIContainerShutdown;
+import org.jboss.weld.environment.osgi.api.extension.events.BundleContainerInitialized;
+import org.jboss.weld.environment.osgi.api.extension.events.BundleContainerShutdown;
import org.jboss.weld.environment.osgi.api.extension.Publish;
import org.jboss.weld.environment.osgi.api.extension.Startable;
import org.jboss.weld.environment.osgi.integration.discovery.bundle.BundleBeanDeploymentArchiveFactory;
@@ -69,7 +69,7 @@ public boolean initialize() {
// Get this Bundle BeanManager
manager = bootstrap.getManager(deployment.getBeanDeploymentArchive());
- manager.fireEvent(new CDIContainerInitialized());
+ manager.fireEvent(new BundleContainerInitialized(bundle.getBundleContext()));
// TODO Move this in extension ...
System.out.println(String.format("\nRegistering/Starting OSGi Service for bundle %s\n", bundle.getSymbolicName()));
@@ -161,7 +161,7 @@ public void shutdown() {
System.out.println("Stopping Weld container for bundle " + bundle.getSymbolicName());
hasShutdownBeenCalled = true;
try {
- manager.fireEvent(new CDIContainerShutdown());
+ manager.fireEvent(new BundleContainerShutdown(bundle.getBundleContext()));
} catch (Throwable t) {
// Ignore
}
Please sign in to comment.
Something went wrong with that request. Please try again.