Author: thomas.diesler(a)jboss.com
Date: 2010-03-17 08:05:14 -0400 (Wed, 17 Mar 2010)
New Revision: 102510
Modified:
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/JMXCapability.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/Capability.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
Log:
Add more logging
Modified:
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/JMXCapability.java
===================================================================
---
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/JMXCapability.java 2010-03-17
10:40:38 UTC (rev 102509)
+++
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/JMXCapability.java 2010-03-17
12:05:14 UTC (rev 102510)
@@ -57,7 +57,7 @@
public class JMXCapability extends Capability
{
// Provide logging
- private static final Logger log = Logger.getLogger(Capability.class);
+ private static final Logger log = Logger.getLogger(JMXCapability.class);
public JMXCapability()
{
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/Capability.java
===================================================================
---
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/Capability.java 2010-03-17
10:40:38 UTC (rev 102509)
+++
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/Capability.java 2010-03-17
12:05:14 UTC (rev 102510)
@@ -194,6 +194,7 @@
public void install(OSGiRuntime runtime) throws BundleException
{
+ log.debug("Install capability: " + this);
for (BundleInfo info : getBundles())
{
String location = info.getLocation();
@@ -213,6 +214,7 @@
public void start(OSGiRuntime runtime) throws BundleException
{
+ log.debug("Start capability: " + this);
for (OSGiBundle bundle : getInstalledBundles())
{
bundle.start();
@@ -221,6 +223,7 @@
public void stop(OSGiRuntime runtime)
{
+ log.debug("Stop capability: " + this);
List<OSGiBundle> installedReverse = new
ArrayList<OSGiBundle>(getInstalledBundles());
Collections.reverse(installedReverse);
@@ -232,6 +235,7 @@
public void uninstall(OSGiRuntime runtime)
{
+ log.debug("Uninstall capability: " + this);
List<OSGiBundle> installedReverse = new
ArrayList<OSGiBundle>(getInstalledBundles());
Collections.reverse(installedReverse);
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java
===================================================================
---
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java 2010-03-17
10:40:38 UTC (rev 102509)
+++
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java 2010-03-17
12:05:14 UTC (rev 102510)
@@ -25,6 +25,7 @@
import java.net.URL;
import java.util.Dictionary;
+import org.jboss.logging.Logger;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Version;
@@ -37,6 +38,8 @@
*/
public abstract class OSGiBundle
{
+ // Provide logging
+ private static final Logger log = Logger.getLogger(OSGiBundle.class);
/**
* Get the runtime associated with this bundle.
*/
@@ -114,18 +117,36 @@
/**
* Starts this bundle.
*/
- public abstract void start() throws BundleException;
+ public void start() throws BundleException
+ {
+ log.debug("Start bundle: " + this);
+ startInternal();
+ }
+ protected abstract void startInternal() throws BundleException;
+
/**
* Stops this bundle.
*/
- public abstract void stop() throws BundleException;
+ public void stop() throws BundleException
+ {
+ log.debug("Stop bundle: " + this);
+ stopInternal();
+ }
+ protected abstract void stopInternal() throws BundleException;
+
/**
* Uninstalls this bundle.
*/
- public abstract void uninstall() throws BundleException;
+ public void uninstall() throws BundleException
+ {
+ log.debug("Uninstall bundle: " + this);
+ uninstallInternal();
+ }
+ protected abstract void uninstallInternal() throws BundleException;
+
/**
* Return true if symbolic name and version are equal
*/
@@ -154,6 +175,6 @@
*/
public String toString()
{
- return "[" + getSymbolicName() + "," + getVersion() +
"]";
+ return "[" + getSymbolicName() + ":" + getVersion() +
"]";
}
}
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java
===================================================================
---
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java 2010-03-17
10:40:38 UTC (rev 102509)
+++
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java 2010-03-17
12:05:14 UTC (rev 102510)
@@ -135,7 +135,7 @@
}
@Override
- public void start() throws BundleException
+ protected void startInternal() throws BundleException
{
bundle.start();
@@ -144,13 +144,13 @@
}
@Override
- public void stop() throws BundleException
+ protected void stopInternal() throws BundleException
{
bundle.stop();
}
@Override
- public void uninstall() throws BundleException
+ protected void uninstallInternal() throws BundleException
{
assertNotUninstalled();
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
===================================================================
---
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java 2010-03-17
10:40:38 UTC (rev 102509)
+++
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java 2010-03-17
12:05:14 UTC (rev 102510)
@@ -67,7 +67,7 @@
super(helper);
}
- OSGiBundle installBundle(BundleInfo info) throws BundleException
+ OSGiBundle installBundleInternal(BundleInfo info) throws BundleException
{
try
{
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
===================================================================
---
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java 2010-03-17
10:40:38 UTC (rev 102509)
+++
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java 2010-03-17
12:05:14 UTC (rev 102510)
@@ -32,9 +32,6 @@
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
@@ -156,8 +153,9 @@
public OSGiBundle installBundle(Archive<?> archive) throws BundleException,
IOException
{
- VirtualFile file = toVirtualFile(archive);
- return installBundle(file);
+ VirtualFile virtualFile = toVirtualFile(archive);
+ BundleInfo info = BundleInfo.createBundleInfo(virtualFile);
+ return installBundle(info);
}
public OSGiBundle installBundle(VirtualFile virtualFile) throws BundleException
@@ -166,8 +164,14 @@
return installBundle(info);
}
- abstract OSGiBundle installBundle(BundleInfo info) throws BundleException;
+ private OSGiBundle installBundle(BundleInfo info) throws BundleException
+ {
+ log.debug("Install bundle: " + info);
+ return installBundleInternal(info);
+ }
+ abstract OSGiBundle installBundleInternal(BundleInfo info) throws BundleException;
+
public void shutdown()
{
log.debug("Start Shutdown");
@@ -288,14 +292,14 @@
public OSGiServiceReference getServiceReference(String clazz, long timeout)
{
- int fraktion = 200;
- timeout = timeout / fraktion;
+ int fraction = 200;
+ timeout = timeout / fraction;
OSGiServiceReference sref = getServiceReference(clazz);
while (sref == null && 0 < timeout--)
{
try
{
- Thread.sleep(fraktion);
+ Thread.sleep(fraction);
}
catch (InterruptedException e)
{
@@ -306,7 +310,7 @@
return sref;
}
- OSGiBundle getBundle(String symbolicName, Version version, boolean mustExist)
+ private OSGiBundle getBundle(String symbolicName, Version version, boolean mustExist)
{
OSGiBundle bundle = null;
List<OSGiBundle> bundles = Arrays.asList(getBundles());
@@ -328,32 +332,6 @@
return bundle;
}
- String getManifestEntry(String location, String key)
- {
- Manifest manifest = getManifest(location);
- Attributes attribs = manifest.getMainAttributes();
- String value = attribs.getValue(key);
- return value;
- }
-
- Manifest getManifest(String location)
- {
- Manifest manifest;
- try
- {
- File archiveFile = getTestHelper().getTestArchiveFile(location);
- JarFile jarFile = new JarFile(archiveFile);
- manifest = jarFile.getManifest();
- jarFile.close();
- }
- catch (IOException ex)
- {
- throw new IllegalStateException("Cannot get manifest from: " +
location);
-
- }
- return manifest;
- }
-
OSGiBundle registerBundle(String location, OSGiBundle bundle)
{
if (bundle == null)
@@ -383,7 +361,7 @@
}
}
- VirtualFile toVirtualFile(Archive<?> archive) throws IOException,
MalformedURLException
+ private VirtualFile toVirtualFile(Archive<?> archive) throws IOException,
MalformedURLException
{
ZipExporter exporter = archive.as(ZipExporter.class);
File target = File.createTempFile("archive_", ".jar");
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
===================================================================
---
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-03-17
10:40:38 UTC (rev 102509)
+++
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-03-17
12:05:14 UTC (rev 102510)
@@ -272,7 +272,7 @@
}
@Override
- public void start() throws BundleException
+ protected void startInternal() throws BundleException
{
assertNotUninstalled();
try
@@ -286,7 +286,7 @@
}
@Override
- public void stop() throws BundleException
+ protected void stopInternal() throws BundleException
{
assertNotUninstalled();
try
@@ -300,7 +300,7 @@
}
@Override
- public void uninstall() throws BundleException
+ protected void uninstallInternal() throws BundleException
{
assertNotUninstalled();
try
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
===================================================================
---
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2010-03-17
10:40:38 UTC (rev 102509)
+++
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2010-03-17
12:05:14 UTC (rev 102510)
@@ -70,7 +70,7 @@
super(helper);
}
- OSGiBundle installBundle(BundleInfo info) throws BundleException
+ OSGiBundle installBundleInternal(BundleInfo info) throws BundleException
{
try
{