[jboss-osgi-commits] JBoss-OSGI SVN: r93079 - in projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins: facade/plugins and 1 other directories.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Tue Sep 1 11:58:08 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-09-01 11:58:07 -0400 (Tue, 01 Sep 2009)
New Revision: 93079
Modified:
projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/AbstractBundleState.java
projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java
projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/plugins/FrameworkEventsPluginImpl.java
projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/metadata/QNameAttributeListValueCreator.java
Log:
wip
Modified: projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/AbstractBundleState.java 2009-09-01 15:57:01 UTC (rev 93078)
+++ projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/AbstractBundleState.java 2009-09-01 15:58:07 UTC (rev 93079)
@@ -337,6 +337,20 @@
}
/**
+ * True if the use count of a service for this bundle is grater that 0.
+ *
+ * @param serviceState the service
+ */
+ boolean isServiceInUse(OSGiServiceState serviceState)
+ {
+ synchronized (servicesInUse)
+ {
+ Integer count = servicesInUse.get(serviceState);
+ return (count != null && count > 0);
+ }
+ }
+
+ /**
* Increment the use count of a service for this bundle
*
* @param serviceState the service
@@ -464,6 +478,11 @@
public boolean ungetService(ServiceReference reference)
{
+ // Check if the service is still in use by this bundle
+ OSGiServiceState serviceState = ((OSGiServiceReferenceWrapper)reference).getServiceState();
+ if (isServiceInUse(serviceState) == false)
+ return false;
+
checkValidBundleContext();
return getBundleManager().ungetService(this, reference);
@@ -626,7 +645,7 @@
*/
String getCanonicalName()
{
- return getSymbolicName() + ":" + osgiMetaData.getBundleVersion();
+ return getSymbolicName() + ":" + getVersion();
}
/**
@@ -734,7 +753,7 @@
{
BundleContext result = this.bundleContext;
if (result == null)
- throw new IllegalStateException("Bundle context is no longer valid");
+ throw new IllegalStateException("Bundle context is no longer valid: " + getCanonicalName());
return result;
}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java 2009-09-01 15:57:01 UTC (rev 93078)
+++ projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java 2009-09-01 15:58:07 UTC (rev 93079)
@@ -372,9 +372,13 @@
try
{
DeploymentUnit unit = deployerStructure.getDeploymentUnit(deployment.getName());
- AbstractBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
+ OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
if (bundleState == null)
throw new IllegalStateException("Unable to determine bundle state for " + deployment.getName());
+
+ // Try to resolve the bundle
+ resolve(bundleState, false);
+
return bundleState;
}
catch (Exception e)
@@ -594,14 +598,24 @@
{
try
{
- // [TODO] check actually changed state
- deployerClient.change(bundleState.getDeploymentUnit().getName(), DeploymentStages.CLASSLOADER);
+ String name = bundleState.getDeploymentUnit().getName();
+
+ deployerClient.change(name, DeploymentStages.CLASSLOADER);
+ deployerClient.checkComplete(name);
+
+ bundleState.changeState(Bundle.RESOLVED);
+
+ // [JBOSGI-136] Cannot resolve dependency against unstarted bundle
+ deployerClient.change(name, DeploymentStages.INSTALLED);
+ deployerClient.checkComplete(name);
+
return true;
}
catch (DeploymentException e)
{
if (errorOnFail)
throw new IllegalStateException("Error resolving bundle: " + bundleState, e);
+
return false;
}
}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/plugins/FrameworkEventsPluginImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/plugins/FrameworkEventsPluginImpl.java 2009-09-01 15:57:01 UTC (rev 93078)
+++ projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/plugins/FrameworkEventsPluginImpl.java 2009-09-01 15:58:07 UTC (rev 93079)
@@ -293,6 +293,7 @@
// Expose the wrapper not the state itself
bundle = assertBundle(bundle);
FrameworkEvent event = new FrameworkEvent(type, bundle, throwable);
+ String typeName = ConstantsHelper.frameworkEvent(event.getType());
// Call the listeners
for (Entry<Bundle, List<FrameworkListener>> entry : frameworkListeners.entrySet())
@@ -305,7 +306,7 @@
}
catch (Throwable t)
{
- log.warn("Error while firing framework event: " + event.getType() + " for bundle " + bundle, t);
+ log.warn("Error while firing framework event: " + typeName + " for bundle " + bundle, t);
}
}
}
@@ -331,6 +332,7 @@
bundle = assertBundle(bundle);
ServiceEvent event = new ServiceEvent(type, service.getReferenceInternal());
+ String typeName = ConstantsHelper.serviceEvent(event.getType());
// Call the listeners
for (Entry<Bundle, List<ServiceListenerRegistration>> entry : serviceListeners.entrySet())
@@ -348,7 +350,7 @@
}
catch (Throwable t)
{
- log.warn("Error while firing service event: " + type + " for service " + service, t);
+ log.warn("Error while firing service event: " + typeName + " for service " + service, t);
}
}
}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/metadata/QNameAttributeListValueCreator.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/metadata/QNameAttributeListValueCreator.java 2009-09-01 15:57:01 UTC (rev 93078)
+++ projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/metadata/QNameAttributeListValueCreator.java 2009-09-01 15:58:07 UTC (rev 93079)
@@ -40,7 +40,7 @@
}
catch (ParseException e)
{
- log.error("Exception parsing parameters.", e);
+ log.debug("Exception parsing parameters.", e);
}
}
}
More information about the jboss-osgi-commits
mailing list