Author: rmannibucau
Date: Thu Jan 5 14:58:04 2012
New Revision: 1227617
URL: http://svn.apache.org/viewvc?rev=1227617&view=rev
Log:
trying to get the bundle context from a cache version is not found (restart
event)
Modified:
openejb/trunk/openejb/osgi/openejb-core-osgi/src/main/java/org/apache/openejb/core/osgi/impl/Deployer.java
Modified:
openejb/trunk/openejb/osgi/openejb-core-osgi/src/main/java/org/apache/openejb/core/osgi/impl/Deployer.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/osgi/openejb-core-osgi/src/main/java/org/apache/openejb/core/osgi/impl/Deployer.java?rev=1227617&r1=1227616&r2=1227617&view=diff
==============================================================================
---
openejb/trunk/openejb/osgi/openejb-core-osgi/src/main/java/org/apache/openejb/core/osgi/impl/Deployer.java
(original)
+++
openejb/trunk/openejb/osgi/openejb-core-osgi/src/main/java/org/apache/openejb/core/osgi/impl/Deployer.java
Thu Jan 5 14:58:04 2012
@@ -63,6 +63,7 @@ public class Deployer implements BundleL
private final Map<Bundle, List<ServiceRegistration>> registrations = new
ConcurrentHashMap<Bundle, List<ServiceRegistration>>();
private final Map<Bundle, String> paths = new ConcurrentHashMap<Bundle,
String>();
+ private final Map<Bundle, BundleContext> contexts = new
ConcurrentHashMap<Bundle, BundleContext>();
private final Activator openejbActivator;
@@ -79,12 +80,17 @@ public class Deployer implements BundleL
openejbActivator.checkServiceManager(OpenEJBBundleContextHolder.get());
switch (event.getType()) {
case BundleEvent.STARTED:
- deploy(event.getBundle());
+ final BundleContext context =
event.getBundle().getBundleContext();
+ if (context != null) {
+ contexts.put(event.getBundle(), context);
+ deploy(event.getBundle());
+ }
break;
case BundleEvent.STOPPED:
- undeploy(event.getBundle());
- break;
case BundleEvent.UNINSTALLED:
+ if (contexts.containsKey(event.getBundle())) {
+ contexts.remove(event.getBundle());
+ }
undeploy(event.getBundle());
break;
case BundleEvent.UPDATED:
@@ -108,6 +114,14 @@ public class Deployer implements BundleL
try {
try {
try {
+ BundleContext context = bundle.getBundleContext();
+ if (context == null && contexts.containsKey(bundle)) {
+ context = contexts.get(bundle);
+ } else if (context == null) {
+ LOGGER.warn("can't get bundle context of bundle {}",
bundle.getBundleId());
+ return;
+ }
+
// equinox? found in aries
File bundleDump =
bundle.getBundleContext().getDataFile(bundle.getSymbolicName() + "/" +
bundle.getVersion() + "/");
// TODO: what should happen if there is multiple versions?