[jboss-cvs] JBossAS SVN: r97474 - projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Dec 4 14:09:55 EST 2009
Author: alesj
Date: 2009-12-04 14:09:55 -0500 (Fri, 04 Dec 2009)
New Revision: 97474
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java
Log:
TODO - on servicefactory unget.
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2009-12-04 18:26:13 UTC (rev 97473)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2009-12-04 19:09:55 UTC (rev 97474)
@@ -67,6 +67,7 @@
* @author <a href="ales.justin at jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
+ at SuppressWarnings({"ThrowableInstanceNeverThrown"})
public class OSGiServiceState extends AbstractControllerContext implements ServiceReference, ServiceRegistration, InvokeDispatchContext
{
/** The alias constant */
@@ -426,14 +427,14 @@
if (serviceCache == null)
return null;
- ServiceFactory serviceFactory = (ServiceFactory)serviceOrFactory;
service = serviceCache.get(bundleState);
+
ContextTracker ct = getContextTracker();
int count = ct.getUsedByCount(this, bundleState);
- if (count == 1) // remove
- serviceCache.remove(bundleState);
- if (count > 0) // unget
+ if (count == 1 || (count == 2 && ct == bundleState)) // remove & unget, double count if tracker == bundle
{
+ serviceCache.remove(bundleState);
+ ServiceFactory serviceFactory = (ServiceFactory)serviceOrFactory;
try
{
serviceFactory.ungetService(bundleState, getRegistration(), service);
@@ -674,15 +675,10 @@
if (users.isEmpty() == false)
{
OSGiBundleManager manager = bundleState.getBundleManager();
- Set<AbstractBundleState> used = new HashSet<AbstractBundleState>();
for (Object user : users)
{
AbstractBundleState using = manager.getBundleForUser(user);
- if (used.contains(using) == false)
- {
- used.add(using); // add so we don't remove duplicates
- using.ungetContex(this); // ungetService will cleanup service cache
- }
+ using.ungetContex(this); // ungetService will cleanup service cache
}
}
}
More information about the jboss-cvs-commits
mailing list