JBoss-OSGI SVN: r102536 - in projects/jboss-osgi/projects/vfs/trunk: vfs30/src/test/java/org/jboss/test/osgi/vfs30 and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-17 20:09:56 -0400 (Wed, 17 Mar 2010)
New Revision: 102536
Modified:
projects/jboss-osgi/projects/vfs/trunk/vfs21/src/test/java/org/jboss/test/osgi/vfs21/SimpleVFS21Test.java
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/test/java/org/jboss/test/osgi/vfs30/SimpleVFS30Test.java
Log:
Prevent NPE in afterClass
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs21/src/test/java/org/jboss/test/osgi/vfs21/SimpleVFS21Test.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs21/src/test/java/org/jboss/test/osgi/vfs21/SimpleVFS21Test.java 2010-03-17 22:47:26 UTC (rev 102535)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs21/src/test/java/org/jboss/test/osgi/vfs21/SimpleVFS21Test.java 2010-03-18 00:09:56 UTC (rev 102536)
@@ -103,7 +103,8 @@
@AfterClass
public static void afterClass() throws IOException
{
- virtualFile.close();
+ if (virtualFile != null)
+ virtualFile.close();
}
@Test
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs30/src/test/java/org/jboss/test/osgi/vfs30/SimpleVFS30Test.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs30/src/test/java/org/jboss/test/osgi/vfs30/SimpleVFS30Test.java 2010-03-17 22:47:26 UTC (rev 102535)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/src/test/java/org/jboss/test/osgi/vfs30/SimpleVFS30Test.java 2010-03-18 00:09:56 UTC (rev 102536)
@@ -103,7 +103,8 @@
@AfterClass
public static void afterClass() throws IOException
{
- virtualFile.close();
+ if (virtualFile != null)
+ virtualFile.close();
}
@Test
14 years, 3 months
JBoss-OSGI SVN: r102534 - in projects/jboss-osgi/projects: spi/trunk/src/main/java/org/jboss/osgi/testing and 2 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-17 18:22:42 -0400 (Wed, 17 Mar 2010)
New Revision: 102534
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.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/OSGiBundleImpl.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
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java
Log:
Add close() semantics to BundleInfo
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java 2010-03-17 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java 2010-03-17 22:22:42 UTC (rev 102534)
@@ -243,6 +243,15 @@
return Version.parseVersion(bundleVersion);
}
+ /**
+ * Closes the accociated resources.
+ */
+ public void close()
+ {
+ if (rootFile != null)
+ rootFile.close();
+ }
+
private Manifest getManifest()
{
if (manifest == null)
@@ -324,7 +333,7 @@
private String toEqualString()
{
- return "[" + symbolicName + "-" + bundleVersion + ",url=" + rootURL + "]";
+ return "[" + symbolicName + ":" + bundleVersion + ",url=" + rootURL + "]";
}
private static String getManifestHeaderInternal(Manifest manifest, String key)
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 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java 2010-03-17 22:22:42 UTC (rev 102534)
@@ -25,7 +25,6 @@
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;
@@ -36,59 +35,57 @@
* @author Thomas.Diesler(a)jboss.org
* @since 25-Sep-2008
*/
-public abstract class OSGiBundle
+public interface OSGiBundle
{
- // Provide logging
- private static final Logger log = Logger.getLogger(OSGiBundle.class);
/**
* Get the runtime associated with this bundle.
*/
- public abstract OSGiRuntime getRuntime();
+ OSGiRuntime getRuntime();
/**
* Returns this bundle's unique identifier.
*/
- public abstract long getBundleId();
+ long getBundleId();
/**
* Returns the symbolic name of this bundle as specified by its Bundle-SymbolicName manifest header.
*/
- public abstract String getSymbolicName();
+ String getSymbolicName();
/**
* Returns the version of this bundle.
*/
- public abstract Version getVersion();
+ Version getVersion();
/**
* Returns this bundle's location.
*/
- public abstract String getLocation();
+ String getLocation();
/**
* Returns this bundle's Manifest headers and values.
*/
- public abstract Dictionary<String, String> getHeaders();
+ Dictionary<String, String> getHeaders();
/**
* Returns this bundle's Manifest headers and values localized to the specified locale.
*/
- public abstract Dictionary<String, String> getHeaders(String locale);
+ Dictionary<String, String> getHeaders(String locale);
/**
* Returns this bundle's current state.
*/
- public abstract int getState();
+ int getState();
/**
* Returns the value of the specified property.
*/
- public abstract String getProperty(String key);
+ String getProperty(String key);
/**
* Creates a File object for a file in the persistent storage area provided for the bundle by the Framework.
*/
- public abstract File getDataFile(String filename);
+ File getDataFile(String filename);
/**
* Loads the specified class using this bundle's class loader.
@@ -97,7 +94,7 @@
* @return The OSGiBundle that is wired to this bundle class loader and contains the class.
* @throws ClassNotFoundException If no such class can be found or if this bundle is a fragment bundle
*/
- public abstract OSGiBundle loadClass(String name) throws ClassNotFoundException;
+ OSGiBundle loadClass(String name) throws ClassNotFoundException;
/**
* Returns a URL to the entry at the specified path in this bundle.
@@ -105,76 +102,27 @@
* @param path The path name of the entry
* @return A URL to the entry, or null if no entry could be found
*/
- public abstract URL getEntry(String path);
+ URL getEntry(String path);
/**
* Find the specified resource from this bundle's class loader.
* @param name The name of the resource.
* @return A URL to the named resource, or null if the resource could not be found
*/
- public abstract URL getResource(String name);
+ URL getResource(String name);
/**
* Starts this bundle.
*/
- public void start() throws BundleException
- {
- log.debug("Start bundle: " + this);
- startInternal();
- }
+ void start() throws BundleException;
- protected abstract void startInternal() throws BundleException;
-
/**
* Stops this bundle.
*/
- public void stop() throws BundleException
- {
- log.debug("Stop bundle: " + this);
- stopInternal();
- }
+ void stop() throws BundleException;
- protected abstract void stopInternal() throws BundleException;
-
/**
* Uninstalls this bundle.
*/
- 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
- */
- public boolean equals(Object obj)
- {
- if ((obj instanceof OSGiBundle) == false)
- return false;
-
- OSGiBundle other = (OSGiBundle)obj;
-
- boolean isEqual = getSymbolicName().equals(other.getSymbolicName());
- isEqual = isEqual && getVersion().equals(other.getVersion());
- return isEqual;
- }
-
- /**
- * Returns the hash code for this bundle.
- */
- public int hashCode()
- {
- return toString().hashCode();
- }
-
- /**
- * Returns the string representation of this bundle
- */
- public String toString()
- {
- return "[" + getSymbolicName() + ":" + getVersion() + "]";
- }
+ void uninstall() throws BundleException;
}
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 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java 2010-03-17 22:22:42 UTC (rev 102534)
@@ -153,11 +153,9 @@
protected void uninstallInternal() throws BundleException
{
assertNotUninstalled();
-
bundle.uninstall();
-
OSGiRuntimeImpl runtimeImpl = (OSGiRuntimeImpl)getRuntime();
- runtimeImpl.unregisterBundle(this);
+ runtimeImpl.uninstallBundle(this);
}
private PackageAdmin getPackageAdmin()
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 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java 2010-03-17 22:22:42 UTC (rev 102534)
@@ -74,9 +74,8 @@
VirtualFile rootFile = info.getRoot();
BundleContext context = getSystemContext();
Bundle auxBundle = context.installBundle(info.getLocation(), rootFile.openStream());
- OSGiBundle bundle = new EmbeddedBundle(this, auxBundle);
- return registerBundle(bundle.getLocation(), bundle);
- }
+ return new EmbeddedBundle(this, auxBundle);
+ }
catch (IOException ex)
{
throw new BundleException("Cannot install bundle: " + info, ex);
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiBundleImpl.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiBundleImpl.java 2010-03-17 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiBundleImpl.java 2010-03-17 22:22:42 UTC (rev 102534)
@@ -23,9 +23,11 @@
// $Id$
+import org.jboss.logging.Logger;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
/**
* An abstract implementation of a {@link OSGiBundle}
@@ -33,8 +35,11 @@
* @author Thomas.Diesler(a)jboss.org
* @since 25-Sep-2008
*/
-public abstract class OSGiBundleImpl extends OSGiBundle
+public abstract class OSGiBundleImpl implements OSGiBundle
{
+ // Provide logging
+ private static final Logger log = Logger.getLogger(OSGiBundleImpl.class);
+
private OSGiRuntime runtime;
OSGiBundleImpl(OSGiRuntime runtime)
@@ -47,6 +52,70 @@
return runtime;
}
+ /**
+ * Starts this bundle.
+ */
+ public void start() throws BundleException
+ {
+ log.debug("Start bundle: " + this);
+ startInternal();
+ }
+
+ protected abstract void startInternal() throws BundleException;
+
+ /**
+ * Stops this bundle.
+ */
+ public void stop() throws BundleException
+ {
+ log.debug("Stop bundle: " + this);
+ stopInternal();
+ }
+
+ protected abstract void stopInternal() throws BundleException;
+
+ /**
+ * Uninstalls this bundle.
+ */
+ 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
+ */
+ public boolean equals(Object obj)
+ {
+ if ((obj instanceof OSGiBundle) == false)
+ return false;
+
+ OSGiBundle other = (OSGiBundle)obj;
+
+ boolean isEqual = getSymbolicName().equals(other.getSymbolicName());
+ isEqual = isEqual && getVersion().equals(other.getVersion());
+ return isEqual;
+ }
+
+ /**
+ * Returns the hash code for this bundle.
+ */
+ public int hashCode()
+ {
+ return toString().hashCode();
+ }
+
+ /**
+ * Returns the string representation of this bundle
+ */
+ public String toString()
+ {
+ return "[" + getSymbolicName() + ":" + getVersion() + "]";
+ }
+
void assertNotUninstalled()
{
if (getState() == Bundle.UNINSTALLED)
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 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java 2010-03-17 22:22:42 UTC (rev 102534)
@@ -30,8 +30,6 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
@@ -74,7 +72,7 @@
private static final Logger log = Logger.getLogger(OSGiRuntimeImpl.class);
private OSGiRuntimeHelper helper;
- private Map<String, OSGiBundle> bundles = new LinkedHashMap<String, OSGiBundle>();
+ private Map<String, BundleTuple> bundles = new LinkedHashMap<String, BundleTuple>();
private List<Capability> capabilities = new ArrayList<Capability>();
private FrameworkMBean frameworkState;
@@ -167,7 +165,9 @@
private OSGiBundle installBundle(BundleInfo info) throws BundleException
{
log.debug("Install bundle: " + info);
- return installBundleInternal(info);
+ OSGiBundle bundle = installBundleInternal(info);
+ bundles.put(info.getLocation(), new BundleTuple(info, bundle));
+ return bundle;
}
abstract OSGiBundle installBundleInternal(BundleInfo info) throws BundleException;
@@ -183,8 +183,8 @@
while (locations.size() > 0)
{
String location = locations.remove(0);
- OSGiBundle bundle = bundles.remove(location);
- OSGiRuntimeHelper.failsafeUninstall(bundle);
+ BundleTuple tuple = bundles.remove(location);
+ tuple.uninstall();
}
// Uninstall the capabilities
@@ -332,33 +332,14 @@
return bundle;
}
- OSGiBundle registerBundle(String location, OSGiBundle bundle)
+ void uninstallBundle(OSGiBundle bundle)
{
if (bundle == null)
- throw new IllegalArgumentException("Cannot register null bundle for: " + location);
-
- bundles.put(location, bundle);
- return bundle;
- }
-
- void unregisterBundle(OSGiBundle bundle)
- {
- if (bundle == null)
throw new IllegalArgumentException("Cannot unregister null bundle");
- if (bundles.containsValue(bundle))
- {
- Set<Entry<String, OSGiBundle>> entrySet = bundles.entrySet();
- for (Entry<String, OSGiBundle> entry : entrySet)
- {
- if (bundle.equals(entry.getValue()))
- {
- String key = entry.getKey();
- bundles.remove(key);
- break;
- }
- }
- }
+ String location = bundle.getLocation();
+ BundleTuple tuple = bundles.get(location);
+ tuple.uninstall();
}
private VirtualFile toVirtualFile(Archive<?> archive) throws IOException, MalformedURLException
@@ -370,4 +351,22 @@
return AbstractVFS.getRoot(target.toURI().toURL());
}
+
+ class BundleTuple
+ {
+ BundleInfo info;
+ OSGiBundle bundle;
+
+ BundleTuple(BundleInfo info, OSGiBundle bundle)
+ {
+ this.info = info;
+ this.bundle = bundle;
+ }
+
+ public void uninstall()
+ {
+ OSGiRuntimeHelper.failsafeUninstall(bundle);
+ info.close();
+ }
+ }
}
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 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-03-17 22:22:42 UTC (rev 102534)
@@ -307,7 +307,7 @@
{
OSGiRuntimeImpl runtimeImpl = (OSGiRuntimeImpl)getRuntime();
runtimeImpl.getFrameworkMBean().uninstallBundle(bundleId);
- runtimeImpl.unregisterBundle(this);
+ runtimeImpl.uninstallBundle(this);
uninstalled = true;
}
catch (RuntimeException rte)
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 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2010-03-17 22:22:42 UTC (rev 102534)
@@ -77,8 +77,7 @@
String location = info.getLocation();
String streamURL = info.getRoot().getStreamURL().toExternalForm();
long bundleId = getFrameworkMBean().installBundle(location, streamURL);
- RemoteBundle bundle = new RemoteBundle(this, bundleId);
- return registerBundle(bundle.getLocation(), bundle);
+ return new RemoteBundle(this, bundleId);
}
catch (RuntimeException rte)
{
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java 2010-03-17 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java 2010-03-17 22:22:42 UTC (rev 102534)
@@ -71,10 +71,10 @@
if (other instanceof org.jboss.vfs.VirtualFile == false)
throw new IllegalArgumentException("Not a org.jboss.vfs.VirtualFile: " + other);
- org.jboss.vfs.VirtualFile nativeFile = (org.jboss.vfs.VirtualFile)other;
- VirtualFile abstractFile = registry.get(other);
- if (abstractFile != null)
- return abstractFile;
+ org.jboss.vfs.VirtualFile vfsFile = (org.jboss.vfs.VirtualFile)other;
+ VirtualFile absFile = registry.get(other);
+ if (absFile != null)
+ return absFile;
// Accept the file for mounting
Closeable closeable = null;
@@ -83,7 +83,7 @@
try
{
TempFileProvider tmp = TempFileProvider.create("osgimount-", null);
- closeable = VFS.mountZip(nativeFile, nativeFile, tmp);
+ closeable = VFS.mountZip(vfsFile, vfsFile, tmp);
}
catch (IOException ex)
{
@@ -92,17 +92,17 @@
}
// Register the VirtualFile abstraction
- abstractFile = new VirtualFileAdaptor30(nativeFile, closeable);
- registry.put(nativeFile, abstractFile);
- return abstractFile;
+ absFile = new VirtualFileAdaptor30(vfsFile, closeable);
+ registry.put(vfsFile, absFile);
+ return absFile;
}
- private boolean acceptForMount(org.jboss.vfs.VirtualFile nativeFile)
+ private boolean acceptForMount(org.jboss.vfs.VirtualFile vfsFile)
{
boolean accept = false;
- if (nativeFile.isFile() == true)
+ if (vfsFile.isFile() == true)
{
- String rootName = nativeFile.getName();
+ String rootName = vfsFile.getName();
for (String suffix : suffixes)
{
if (rootName.endsWith(suffix))
@@ -115,17 +115,17 @@
return accept;
}
- public Object adapt(VirtualFile virtualFile)
+ public Object adapt(VirtualFile absFile)
{
- if (virtualFile == null)
+ if (absFile == null)
return null;
- VirtualFileAdaptor30 adaptor = (VirtualFileAdaptor30)virtualFile;
+ VirtualFileAdaptor30 adaptor = (VirtualFileAdaptor30)absFile;
return adaptor.getDelegate();
}
- static void safeClose(VirtualFileAdaptor30 virtualFile)
+ static void safeClose(VirtualFileAdaptor30 absFile)
{
- registry.remove(virtualFile.getDelegate());
+ registry.remove(absFile.getDelegate());
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java 2010-03-17 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java 2010-03-17 22:22:42 UTC (rev 102534)
@@ -50,7 +50,8 @@
{
private org.jboss.vfs.VirtualFile delegate;
private Closeable closeable;
- private URL streamURL;
+ private TempDir streamDir;
+ private File streamFile;
VirtualFileAdaptor30(org.jboss.vfs.VirtualFile root, Closeable closeable)
{
@@ -100,33 +101,28 @@
@Override
public URL getStreamURL() throws IOException
{
- if (streamURL == null)
+ if (delegate.isFile() == true)
+ return delegate.toURL();
+
+ if (streamFile == null)
{
- if (delegate.isFile() == true)
+ TempFileProvider tmpProvider = TempFileProvider.create("osgiurl-", null);
+ streamDir = tmpProvider.createTempDir(getName());
+ streamFile = streamDir.getFile(getName());
+ JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(streamFile));
+
+ VirtualJarInputStream jarIn = (VirtualJarInputStream)delegate.openStream();
+ ZipEntry nextEntry = jarIn.getNextEntry();
+ while (nextEntry != null)
{
- streamURL = delegate.toURL();
+ jarOut.putNextEntry(nextEntry);
+ VFSUtils.copyStream(jarIn, jarOut);
+ nextEntry = jarIn.getNextEntry();
}
- else
- {
- TempFileProvider tmpProvider = TempFileProvider.create("osgiurl-", null);
- TempDir tmpDir = tmpProvider.createTempDir(getName());
- File file = tmpDir.getFile(getName());
- JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(file));
-
- VirtualJarInputStream jarIn = (VirtualJarInputStream)delegate.openStream();
- ZipEntry nextEntry = jarIn.getNextEntry();
- while(nextEntry != null)
- {
- jarOut.putNextEntry(nextEntry);
- VFSUtils.copyStream(jarIn, jarOut);
- nextEntry = jarIn.getNextEntry();
- }
- jarOut.close();
- jarIn.close();
- streamURL = file.toURI().toURL();
- }
+ jarOut.close();
+ jarIn.close();
}
- return streamURL;
+ return streamFile.toURI().toURL();
}
@Override
@@ -196,7 +192,7 @@
{
if (closeable != null)
return getStreamURL().openStream();
-
+
return delegate.openStream();
}
@@ -205,6 +201,23 @@
{
VFSUtils.safeClose(closeable);
VFSAdaptor30.safeClose(this);
+ if (streamFile != null)
+ {
+ streamFile.delete();
+ streamFile = null;
+ }
+ try
+ {
+ if (streamDir != null)
+ {
+ streamDir.close();
+ streamDir = null;
+ }
+ }
+ catch (IOException ex)
+ {
+ // ignore
+ }
}
@Override
14 years, 3 months
JBoss-OSGI SVN: r102516 - projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-17 09:55:06 -0400 (Wed, 17 Mar 2010)
New Revision: 102516
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/Capability.java
Log:
Prevent stop of already uninstalled capability bundle
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 13:21:21 UTC (rev 102515)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/Capability.java 2010-03-17 13:55:06 UTC (rev 102516)
@@ -34,6 +34,7 @@
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
import org.jboss.osgi.testing.OSGiRuntimeHelper;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Version;
@@ -229,7 +230,8 @@
for (OSGiBundle bundle : installedReverse)
{
- OSGiRuntimeHelper.failsafeStop(bundle);
+ if (bundle.getState() != Bundle.UNINSTALLED)
+ OSGiRuntimeHelper.failsafeStop(bundle);
}
}
@@ -241,7 +243,8 @@
for (OSGiBundle bundle : installedReverse)
{
- OSGiRuntimeHelper.failsafeUninstall(bundle);
+ if (bundle.getState() != Bundle.UNINSTALLED)
+ OSGiRuntimeHelper.failsafeUninstall(bundle);
installed.remove(bundle);
}
}
14 years, 3 months
JBoss-OSGI SVN: r102515 - in projects/jboss-osgi/projects/vfs/trunk: vfs30 and 2 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-17 09:21:21 -0400 (Wed, 17 Mar 2010)
New Revision: 102515
Modified:
projects/jboss-osgi/projects/vfs/trunk/vfs21/src/test/java/org/jboss/test/osgi/vfs21/SimpleVFS21Test.java
projects/jboss-osgi/projects/vfs/trunk/vfs30/pom.xml
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/test/java/org/jboss/test/osgi/vfs30/SimpleVFS30Test.java
Log:
Copy VirtualJarInputStream
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs21/src/test/java/org/jboss/test/osgi/vfs21/SimpleVFS21Test.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs21/src/test/java/org/jboss/test/osgi/vfs21/SimpleVFS21Test.java 2010-03-17 13:13:04 UTC (rev 102514)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs21/src/test/java/org/jboss/test/osgi/vfs21/SimpleVFS21Test.java 2010-03-17 13:21:21 UTC (rev 102515)
@@ -37,6 +37,7 @@
import java.util.Set;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
import org.jboss.osgi.vfs.AbstractVFS;
@@ -62,7 +63,6 @@
{
private static File archiveFile;
private static VirtualFile virtualFile;
- private static int fileLength;
@BeforeClass
public static void beforeClass() throws IOException
@@ -96,7 +96,6 @@
FileInputStream fis = new FileInputStream(archiveFile);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
VFSUtils.copyStream(fis, baos);
- fileLength = baos.toByteArray().length;
virtualFile = AbstractVFS.getRoot(archiveFile.toURI().toURL());
}
@@ -172,12 +171,24 @@
}
@Test
- public void testURLStreamAccess() throws Exception
+ public void testStreamURLAccess() throws Exception
{
+ URL streamURL = virtualFile.getStreamURL();
+ JarInputStream jarIn = new JarInputStream(streamURL.openStream());
+ Manifest manifest = jarIn.getManifest();
+ Attributes attributes = manifest.getMainAttributes();
+ String symbolicName = attributes.getValue(Constants.BUNDLE_SYMBOLICNAME);
+ assertEquals("example-simple", symbolicName);
+ }
+
+ @Test
+ public void testStreamAccess() throws Exception
+ {
InputStream instream = virtualFile.openStream();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- VFSUtils.copyStream(instream, baos);
- int actualLength = baos.toByteArray().length;
- assertEquals(fileLength, actualLength);
+ JarInputStream jarIn = new JarInputStream(instream);
+ Manifest manifest = jarIn.getManifest();
+ Attributes attributes = manifest.getMainAttributes();
+ String symbolicName = attributes.getValue(Constants.BUNDLE_SYMBOLICNAME);
+ assertEquals("example-simple", symbolicName);
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs30/pom.xml
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs30/pom.xml 2010-03-17 13:13:04 UTC (rev 102514)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/pom.xml 2010-03-17 13:21:21 UTC (rev 102515)
@@ -31,7 +31,7 @@
<!-- Properties -->
<properties>
<version.jboss.shrinkwrap>1.0.0-SNAPSHOT</version.jboss.shrinkwrap>
- <version.jboss.vfs>3.0.0-SNAPSHOT</version.jboss.vfs>
+ <version.jboss.vfs>3.0.0.CR5</version.jboss.vfs>
<version.osgi>4.2.0</version.osgi>
</properties>
@@ -47,6 +47,10 @@
<artifactId>jboss-vfs</artifactId>
<version>${version.jboss.vfs}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </dependency>
<dependency>
<groupId>junit</groupId>
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java 2010-03-17 13:13:04 UTC (rev 102514)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java 2010-03-17 13:21:21 UTC (rev 102515)
@@ -21,6 +21,7 @@
*/
package org.jboss.osgi.vfs30;
+import java.io.Closeable;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
@@ -33,8 +34,6 @@
import org.jboss.osgi.vfs.VirtualFile;
import org.jboss.vfs.TempFileProvider;
import org.jboss.vfs.VFS;
-import org.jboss.vfs.VFSUtils;
-import org.jboss.vfs.spi.MountHandle;
/**
* An adaptor to the jboss-vfs-3.0.x VFS.
@@ -78,13 +77,13 @@
return abstractFile;
// Accept the file for mounting
- MountHandle mountHandle = null;
+ Closeable closeable = null;
if (acceptForMount((org.jboss.vfs.VirtualFile)other) == true)
{
try
{
TempFileProvider tmp = TempFileProvider.create("osgimount-", null);
- mountHandle = VFS.mountZip(nativeFile, nativeFile, tmp);
+ closeable = VFS.mountZip(nativeFile, nativeFile, tmp);
}
catch (IOException ex)
{
@@ -93,7 +92,7 @@
}
// Register the VirtualFile abstraction
- abstractFile = new VirtualFileAdaptor30(nativeFile, mountHandle);
+ abstractFile = new VirtualFileAdaptor30(nativeFile, closeable);
registry.put(nativeFile, abstractFile);
return abstractFile;
}
@@ -128,9 +127,5 @@
static void safeClose(VirtualFileAdaptor30 virtualFile)
{
registry.remove(virtualFile.getDelegate());
-
- MountHandle mountHandle = virtualFile.getMountHandle();
- if (mountHandle != null)
- VFSUtils.safeClose(mountHandle);
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java 2010-03-17 13:13:04 UTC (rev 102514)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java 2010-03-17 13:21:21 UTC (rev 102515)
@@ -21,8 +21,9 @@
*/
package org.jboss.osgi.vfs30;
+import java.io.Closeable;
import java.io.File;
-import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -30,9 +31,14 @@
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
+import java.util.jar.JarOutputStream;
+import java.util.zip.ZipEntry;
import org.jboss.osgi.vfs.VirtualFile;
-import org.jboss.vfs.spi.MountHandle;
+import org.jboss.vfs.TempDir;
+import org.jboss.vfs.TempFileProvider;
+import org.jboss.vfs.VFSUtils;
+import org.jboss.vfs.VirtualJarInputStream;
/**
* An adaptor to the jboss-vfs-3.0.x VirtualFile.
@@ -43,12 +49,13 @@
class VirtualFileAdaptor30 implements VirtualFile
{
private org.jboss.vfs.VirtualFile delegate;
- private MountHandle mountHandle;
+ private Closeable closeable;
+ private URL streamURL;
- VirtualFileAdaptor30(org.jboss.vfs.VirtualFile root, MountHandle mountHandle)
+ VirtualFileAdaptor30(org.jboss.vfs.VirtualFile root, Closeable closeable)
{
this(root);
- this.mountHandle = mountHandle;
+ this.closeable = closeable;
}
VirtualFileAdaptor30(org.jboss.vfs.VirtualFile delegate)
@@ -63,11 +70,6 @@
return delegate;
}
- MountHandle getMountHandle()
- {
- return mountHandle;
- }
-
public String getName()
{
return delegate.getName();
@@ -98,11 +100,33 @@
@Override
public URL getStreamURL() throws IOException
{
- if (mountHandle == null)
- return null;
-
- File mountSource = mountHandle.getMountSource();
- return mountSource.toURI().toURL();
+ if (streamURL == null)
+ {
+ if (delegate.isFile() == true)
+ {
+ streamURL = delegate.toURL();
+ }
+ else
+ {
+ TempFileProvider tmpProvider = TempFileProvider.create("osgiurl-", null);
+ TempDir tmpDir = tmpProvider.createTempDir(getName());
+ File file = tmpDir.getFile(getName());
+ JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(file));
+
+ VirtualJarInputStream jarIn = (VirtualJarInputStream)delegate.openStream();
+ ZipEntry nextEntry = jarIn.getNextEntry();
+ while(nextEntry != null)
+ {
+ jarOut.putNextEntry(nextEntry);
+ VFSUtils.copyStream(jarIn, jarOut);
+ nextEntry = jarIn.getNextEntry();
+ }
+ jarOut.close();
+ jarIn.close();
+ streamURL = file.toURI().toURL();
+ }
+ }
+ return streamURL;
}
@Override
@@ -170,17 +194,16 @@
@Override
public InputStream openStream() throws IOException
{
- if (mountHandle != null)
- {
- File mountSource = mountHandle.getMountSource();
- return new FileInputStream(mountSource);
- }
+ if (closeable != null)
+ return getStreamURL().openStream();
+
return delegate.openStream();
}
@Override
public void close()
{
+ VFSUtils.safeClose(closeable);
VFSAdaptor30.safeClose(this);
}
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs30/src/test/java/org/jboss/test/osgi/vfs30/SimpleVFS30Test.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs30/src/test/java/org/jboss/test/osgi/vfs30/SimpleVFS30Test.java 2010-03-17 13:13:04 UTC (rev 102514)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/src/test/java/org/jboss/test/osgi/vfs30/SimpleVFS30Test.java 2010-03-17 13:21:21 UTC (rev 102515)
@@ -37,6 +37,7 @@
import java.util.Set;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
import org.jboss.osgi.vfs.AbstractVFS;
@@ -62,7 +63,6 @@
{
private static File archiveFile;
private static VirtualFile virtualFile;
- private static int fileLength;
@BeforeClass
public static void beforeClass() throws IOException
@@ -96,7 +96,6 @@
FileInputStream fis = new FileInputStream(archiveFile);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
VFSUtils.copyStream(fis, baos);
- fileLength = baos.toByteArray().length;
virtualFile = AbstractVFS.getRoot(archiveFile.toURI().toURL());
}
@@ -172,12 +171,24 @@
}
@Test
- public void testURLStreamAccess() throws Exception
+ public void testStreamURLAccess() throws Exception
{
+ URL streamURL = virtualFile.getStreamURL();
+ JarInputStream jarIn = new JarInputStream(streamURL.openStream());
+ Manifest manifest = jarIn.getManifest();
+ Attributes attributes = manifest.getMainAttributes();
+ String symbolicName = attributes.getValue(Constants.BUNDLE_SYMBOLICNAME);
+ assertEquals("example-simple", symbolicName);
+ }
+
+ @Test
+ public void testStreamAccess() throws Exception
+ {
InputStream instream = virtualFile.openStream();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- VFSUtils.copyStream(instream, baos);
- int actualLength = baos.toByteArray().length;
- assertEquals(fileLength, actualLength);
+ JarInputStream jarIn = new JarInputStream(instream);
+ Manifest manifest = jarIn.getManifest();
+ Attributes attributes = manifest.getMainAttributes();
+ String symbolicName = attributes.getValue(Constants.BUNDLE_SYMBOLICNAME);
+ assertEquals("example-simple", symbolicName);
}
}
\ No newline at end of file
14 years, 3 months
JBoss-OSGI SVN: r102510 - in projects/jboss-osgi/projects: spi/trunk/src/main/java/org/jboss/osgi/spi/capability and 2 other directories.
by jboss-osgi-commits@lists.jboss.org
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
{
14 years, 3 months
JBoss-OSGI SVN: r102500 - in projects/jboss-osgi: projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx and 4 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-17 00:16:20 -0400 (Wed, 17 Mar 2010)
New Revision: 102500
Modified:
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/pom.xml
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/OSGiRuntimeHelper.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi298/OSGi298TestCase.java
Log:
[JBOSGI-298] InstanceAlreadyExistsException: osgi.core:type=framework,version=1.5
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/pom.xml 2010-03-17 04:05:59 UTC (rev 102499)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/pom.xml 2010-03-17 04:16:20 UTC (rev 102500)
@@ -124,6 +124,7 @@
<!-- jboss-osgi -->
org.jboss.osgi.jmx;version="[1.0,2.0)",
org.jboss.osgi.spi*;version="[1.0,2.0)",
+ org.jboss.osgi.testing*;version="[1.0,2.0)",
<!-- osgi -->
org.osgi.framework;version="[1.5,2.0)",
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 04:05:59 UTC (rev 102499)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/JMXCapability.java 2010-03-17 04:16:20 UTC (rev 102500)
@@ -24,10 +24,16 @@
//$Id$
import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import org.jboss.logging.Logger;
import org.jboss.osgi.spi.capability.Capability;
import org.jboss.osgi.spi.capability.CompendiumCapability;
import org.jboss.osgi.testing.OSGiRuntime;
+import org.osgi.framework.BundleException;
+import org.osgi.jmx.framework.BundleStateMBean;
+import org.osgi.jmx.framework.FrameworkMBean;
+import org.osgi.jmx.framework.ServiceStateMBean;
/**
* Adds the JMX capability to the {@link OSGiRuntime}
@@ -50,6 +56,9 @@
*/
public class JMXCapability extends Capability
{
+ // Provide logging
+ private static final Logger log = Logger.getLogger(Capability.class);
+
public JMXCapability()
{
super(MBeanServer.class.getName());
@@ -62,4 +71,49 @@
addBundle("bundles/jboss-osgi-jmx.jar");
addBundle("bundles/org.apache.aries.jmx.jar");
}
+
+ @Override
+ public void start(OSGiRuntime runtime) throws BundleException
+ {
+ super.start(runtime);
+ assertMBeanRegistration(runtime, true);
+ }
+
+ @Override
+ public void stop(OSGiRuntime runtime)
+ {
+ super.stop(runtime);
+ assertMBeanRegistration(runtime, false);
+ }
+
+ private void assertMBeanRegistration(OSGiRuntime runtime, boolean state)
+ {
+ MBeanServer server = (MBeanServer)runtime.getMBeanServer();
+ ObjectName fwkName = ObjectNameFactory.create(FrameworkMBean.OBJECTNAME);
+ ObjectName bndName = ObjectNameFactory.create(BundleStateMBean.OBJECTNAME);
+ ObjectName srvName = ObjectNameFactory.create(ServiceStateMBean.OBJECTNAME);
+
+ int timeout = 2000;
+ while ( 0 < (timeout -= 200))
+ {
+ if (server.isRegistered(fwkName) != state || server.isRegistered(bndName) != state || server.isRegistered(srvName) != state)
+ {
+ try
+ {
+ Thread.sleep(200);
+ }
+ catch (InterruptedException e)
+ {
+ // ignore
+ }
+ }
+ }
+
+ if (server.isRegistered(fwkName) != state)
+ log.warn("FrameworkMBean " + (state ? "not" : "still") + " registered");
+ if (server.isRegistered(bndName) != state)
+ log.warn("BundleStateMBean " + (state ? "not" : "still") + " registered");
+ if (server.isRegistered(srvName) != state)
+ log.warn("ServiceStateMBean " + (state ? "not" : "still") + " registered");
+ }
}
\ No newline at end of file
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 04:05:59 UTC (rev 102499)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/Capability.java 2010-03-17 04:16:20 UTC (rev 102500)
@@ -29,8 +29,13 @@
import java.util.List;
import java.util.Map;
+import org.jboss.logging.Logger;
import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.osgi.framework.BundleException;
+import org.osgi.framework.Version;
/**
* An abstract OSGi capability that can be installed in an OSGiRuntime.
@@ -44,12 +49,16 @@
*/
public abstract class Capability
{
+ // Provide logging
+ private static final Logger log = Logger.getLogger(Capability.class);
+
private String serviceName;
private String filter;
private Map<String, String> systemProperties;
private List<Capability> dependencies;
private List<BundleInfo> bundles;
+ private List<OSGiBundle> installed = new ArrayList<OSGiBundle>();
/**
* Construct a capability that is identified by the given service name.
@@ -148,7 +157,7 @@
Throwable cause = ex.getCause();
if (cause instanceof RuntimeException)
throw (RuntimeException)cause;
-
+
throw new IllegalArgumentException("Cannot create bundle info for: " + location, ex);
}
getBundlesInternal().add(info);
@@ -177,4 +186,59 @@
return bundles;
}
+
+ public List<OSGiBundle> getInstalledBundles()
+ {
+ return Collections.unmodifiableList(installed);
+ }
+
+ public void install(OSGiRuntime runtime) throws BundleException
+ {
+ for (BundleInfo info : getBundles())
+ {
+ String location = info.getLocation();
+ String symName = info.getSymbolicName();
+ Version version = info.getVersion();
+ if (runtime.getBundle(symName, version) == null)
+ {
+ OSGiBundle bundle = runtime.installBundle(location);
+ installed.add(bundle);
+ }
+ else
+ {
+ log.debug("Skip bundle: " + location);
+ }
+ }
+ }
+
+ public void start(OSGiRuntime runtime) throws BundleException
+ {
+ for (OSGiBundle bundle : getInstalledBundles())
+ {
+ bundle.start();
+ }
+ }
+
+ public void stop(OSGiRuntime runtime)
+ {
+ List<OSGiBundle> installedReverse = new ArrayList<OSGiBundle>(getInstalledBundles());
+ Collections.reverse(installedReverse);
+
+ for (OSGiBundle bundle : installedReverse)
+ {
+ OSGiRuntimeHelper.failsafeStop(bundle);
+ }
+ }
+
+ public void uninstall(OSGiRuntime runtime)
+ {
+ List<OSGiBundle> installedReverse = new ArrayList<OSGiBundle>(getInstalledBundles());
+ Collections.reverse(installedReverse);
+
+ for (OSGiBundle bundle : installedReverse)
+ {
+ OSGiRuntimeHelper.failsafeUninstall(bundle);
+ installed.remove(bundle);
+ }
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntimeHelper.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntimeHelper.java 2010-03-17 04:05:59 UTC (rev 102499)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntimeHelper.java 2010-03-17 04:16:20 UTC (rev 102500)
@@ -21,10 +21,12 @@
*/
package org.jboss.osgi.testing;
+import org.jboss.logging.Logger;
import org.jboss.osgi.spi.framework.OSGiBootstrap;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
import org.jboss.osgi.testing.internal.EmbeddedRuntime;
import org.jboss.osgi.testing.internal.RemoteRuntime;
+import org.osgi.framework.Bundle;
/**
* A helper for the OSGi runtime abstraction.
@@ -34,6 +36,9 @@
*/
public class OSGiRuntimeHelper extends OSGiTestHelper
{
+ // Provide logging
+ private static final Logger log = Logger.getLogger(OSGiRuntimeHelper.class);
+
// The OSGiBootstrapProvider is a lazy property of the helper
private OSGiBootstrapProvider bootProvider;
private boolean skipBootstrap;
@@ -85,4 +90,35 @@
{
return new RemoteRuntime(this);
}
+
+ public static void failsafeStop(OSGiBundle bundle)
+ {
+ if (bundle != null)
+ {
+ try
+ {
+ bundle.stop();
+ }
+ catch (Exception ex)
+ {
+ log.warn("Cannot stop bundle: " + bundle, ex);
+ }
+ }
+ }
+
+ public static void failsafeUninstall(OSGiBundle bundle)
+ {
+ if (bundle != null)
+ {
+ try
+ {
+ if (bundle.getState() != Bundle.UNINSTALLED)
+ bundle.uninstall();
+ }
+ catch (Exception ex)
+ {
+ log.warn("Cannot uninstall bundle: " + bundle, ex);
+ }
+ }
+ }
}
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 04:05:59 UTC (rev 102499)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java 2010-03-17 04:16:20 UTC (rev 102500)
@@ -58,7 +58,6 @@
import org.jboss.osgi.vfs.VirtualFile;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.exporter.ZipExporter;
-import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Version;
import org.osgi.jmx.framework.BundleStateMBean;
@@ -112,30 +111,13 @@
if (srefs == null || srefs.length == 0)
{
log.debug("Add capability: " + capability);
-
+
// Install the capability bundles
- List<OSGiBundle> installed = new ArrayList<OSGiBundle>();
- for (BundleInfo info : capability.getBundles())
- {
- String location = info.getLocation();
- String symName = info.getSymbolicName();
- Version version = info.getVersion();
- if (bundles.get(location) == null && getBundle(symName, version) == null)
- {
- OSGiBundle bundle = installBundle(location);
- installed.add(bundle);
- }
- else
- {
- log.debug("Skip bundle: " + location);
- }
- }
-
- // Start the capability bundles
- for (OSGiBundle bundle : installed)
- {
- bundle.start();
- }
+ capability.install(this);
+
+ // Start the capability bundles
+ capability.start(this);
+
capabilities.add(capability);
}
else
@@ -150,20 +132,12 @@
{
log.debug("Remove capability : " + capability);
- List<BundleInfo> bundleInfos = new ArrayList<BundleInfo>(capability.getBundles());
- Collections.reverse(bundleInfos);
-
- for (BundleInfo info : bundleInfos)
- {
- OSGiBundle bundle = bundles.get(info.getLocation());
- failsafeStop(bundle);
- }
+ // Install the capability bundles
+ capability.stop(this);
- for (BundleInfo info : bundleInfos)
- {
- OSGiBundle bundle = bundles.remove(info.getLocation());
- failsafeUninstall(bundle);
- }
+ // Start the capability bundles
+ capability.uninstall(this);
+
}
List<Capability> dependencies = new ArrayList<Capability>(capability.getDependencies());
@@ -205,7 +179,8 @@
while (locations.size() > 0)
{
String location = locations.remove(0);
- failsafeUninstall(bundles.remove(location));
+ OSGiBundle bundle = bundles.remove(location);
+ OSGiRuntimeHelper.failsafeUninstall(bundle);
}
// Uninstall the capabilities
@@ -417,35 +392,4 @@
return AbstractVFS.getRoot(target.toURI().toURL());
}
-
- private void failsafeStop(OSGiBundle bundle)
- {
- if (bundle != null)
- {
- try
- {
- bundle.stop();
- }
- catch (Exception ex)
- {
- log.warn("Cannot stop bundle: " + bundle, ex);
- }
- }
- }
-
- private void failsafeUninstall(OSGiBundle bundle)
- {
- if (bundle != null)
- {
- try
- {
- if (bundle.getState() != Bundle.UNINSTALLED)
- bundle.uninstall();
- }
- catch (Exception ex)
- {
- log.warn("Cannot uninstall bundle: " + bundle, ex);
- }
- }
- }
}
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi298/OSGi298TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi298/OSGi298TestCase.java 2010-03-17 04:05:59 UTC (rev 102499)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi298/OSGi298TestCase.java 2010-03-17 04:16:20 UTC (rev 102500)
@@ -36,7 +36,6 @@
import org.jboss.osgi.testing.OSGiRuntimeTest;
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.osgi.jmx.framework.BundleStateMBean;
import org.osgi.jmx.framework.FrameworkMBean;
@@ -50,7 +49,6 @@
* @author thomas.diesler(a)jboss.com
* @since 05-Mar-2010
*/
-@Ignore
public class OSGi298TestCase extends OSGiRuntimeTest
{
private OSGiRuntime runtime;
@@ -72,21 +70,17 @@
public void testJMXCapability() throws Exception
{
JMXCapability capability = new JMXCapability();
+ runtime.addCapability(capability);
- for (int i = 0; i < 10; i++)
- {
- runtime.addCapability(capability);
+ assertTrue("FrameworkMBean registered", isRegistered(FrameworkMBean.OBJECTNAME));
+ assertTrue("BundleStateMBean registered", isRegistered(BundleStateMBean.OBJECTNAME));
+ assertTrue("ServiceStateMBean registered", isRegistered(ServiceStateMBean.OBJECTNAME));
- assertTrue("FrameworkMBean registered", isRegistered(FrameworkMBean.OBJECTNAME));
- assertTrue("BundleStateMBean registered", isRegistered(BundleStateMBean.OBJECTNAME));
- assertTrue("ServiceStateMBean registered", isRegistered(ServiceStateMBean.OBJECTNAME));
+ runtime.removeCapability(capability);
- runtime.removeCapability(capability);
-
- assertFalse("FrameworkMBean registered", isRegistered(FrameworkMBean.OBJECTNAME));
- assertFalse("BundleStateMBean registered", isRegistered(BundleStateMBean.OBJECTNAME));
- assertFalse("ServiceStateMBean registered", isRegistered(ServiceStateMBean.OBJECTNAME));
- }
+ assertFalse("FrameworkMBean registered", isRegistered(FrameworkMBean.OBJECTNAME));
+ assertFalse("BundleStateMBean registered", isRegistered(BundleStateMBean.OBJECTNAME));
+ assertFalse("ServiceStateMBean registered", isRegistered(ServiceStateMBean.OBJECTNAME));
}
private boolean isRegistered(String oname) throws MalformedObjectNameException
14 years, 3 months
JBoss-OSGI SVN: r102493 - in projects/jboss-osgi: projects/bundles/blueprint/trunk and 37 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-16 19:51:30 -0400 (Tue, 16 Mar 2010)
New Revision: 102493
Added:
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/JMXCapability.java
Removed:
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/JMXCapability.java
Modified:
projects/jboss-osgi/projects/bundles/apache-xerces/trunk/.project
projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml
projects/jboss-osgi/projects/bundles/blueprint/trunk/pom.xml
projects/jboss-osgi/projects/bundles/blueprint/trunk/scripts/assembly-bundles.xml
projects/jboss-osgi/projects/bundles/blueprint/trunk/src/main/java/org/jboss/osgi/blueprint/BlueprintCapability.java
projects/jboss-osgi/projects/bundles/blueprint/trunk/src/test/java/org/jboss/test/osgi/blueprint/container/BlueprintContainerTestCase.java
projects/jboss-osgi/projects/bundles/blueprint/trunk/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
projects/jboss-osgi/projects/bundles/common/trunk/pom.xml
projects/jboss-osgi/projects/bundles/husky/trunk/pom.xml
projects/jboss-osgi/projects/bundles/jaxb/trunk/pom.xml
projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/pom.xml
projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/scripts/assembly-bundles.xml
projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/src/test/java/org/jboss/test/osgi/jbossxb/refresh/UnmarshallerServiceRefreshTestCase.java
projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/src/test/java/org/jboss/test/osgi/jbossxb/simple/BasicXMLBindingTestCase.java
projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/src/test/resources/jboss-osgi-framework.properties
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/pom.xml
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/pom.xml
projects/jboss-osgi/projects/bundles/serviceloader/trunk/src/main/java/org/jboss/osgi/serviceloader/ServiceLoaderCapability.java
projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/WebAppCapability.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml
projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/installer/install-definition.xml
projects/jboss-osgi/trunk/distribution/javadoc/scripts/assembly-javadoc-src.xml
projects/jboss-osgi/trunk/distribution/pom.xml
projects/jboss-osgi/trunk/pom.xml
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/enterprise/jmx/JMXEnterpriseTestCase.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/HttpServiceTestCase.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/interceptor/InterceptorTestCase.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/serviceloader/ServiceLoaderTestCase.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jaxb/CourseBooking.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/capabilities/CapabilityTestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi112/OSGi112TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGi92TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGi99TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGi36TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/localization/LocalizationTestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/performance/blueprint/BlueprintStressTestCase.java
projects/jboss-osgi/trunk/testsuite/pom.xml
Log:
Prepare for Capability/Runtime integration
Modified: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/.project
===================================================================
--- projects/jboss-osgi/projects/bundles/apache-xerces/trunk/.project 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/.project 2010-03-16 23:51:30 UTC (rev 102493)
@@ -6,6 +6,11 @@
</projects>
<buildSpec>
<buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
@@ -19,5 +24,6 @@
<natures>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>
Modified: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml 2010-03-16 23:51:30 UTC (rev 102493)
@@ -30,17 +30,10 @@
<version>1.0.5-SNAPSHOT</version>
</parent>
- <!-- Subversion -->
- <scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/projec...</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/...</developerConnection>
- <url>http://fisheye.jboss.com/qsearch/JBossOSGi</url>
- </scm>
-
<!-- Properties -->
<properties>
<version.apache.xerces>2.9.1</version.apache.xerces>
- <version.jboss.osgi.common>1.0.3</version.jboss.osgi.common>
+ <version.jboss.osgi.common>1.0.4-SNAPSHOT</version.jboss.osgi.common>
<version.jboss.osgi.spi>1.0.5-SNAPSHOT</version.jboss.osgi.spi>
<version.wutka.dtdparser>1.2.1</version.wutka.dtdparser>
<version.xml.resolver>1.2</version.xml.resolver>
@@ -110,7 +103,7 @@
org.jboss.osgi.xml.internal
</Privat-Package>
<Export-Package>
- org.jboss.osgi.xml;version=2.9.1
+ org.jboss.osgi.xml;version=${version}
</Export-Package>
<Import-Package>
javax.xml.datatype,
@@ -122,9 +115,9 @@
org.xml.sax*,
<!-- import -->
- org.jboss.logging;version="[2.1,2.2)",
- org.jboss.osgi.common.log;version="[1.0,1.1)",
- org.jboss.osgi.spi.capability;version="[1.0,1.1)",
+ org.jboss.logging;version="[2.1,3.0)",
+ org.jboss.osgi.common.log;version="[1.0,2.0)",
+ org.jboss.osgi.spi*;version="[1.0,2.0)",
org.osgi.framework,
org.osgi.service.log,
org.osgi.util.xml,
@@ -146,4 +139,12 @@
</plugin>
</plugins>
</build>
+
+ <!-- Subversion -->
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/projec...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/...</developerConnection>
+ <url>http://fisheye.jboss.com/qsearch/JBossOSGi</url>
+ </scm>
+
</project>
Modified: projects/jboss-osgi/projects/bundles/blueprint/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/blueprint/trunk/pom.xml 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/blueprint/trunk/pom.xml 2010-03-16 23:51:30 UTC (rev 102493)
@@ -37,23 +37,18 @@
<version>1.0.5-SNAPSHOT</version>
</parent>
- <!-- Subversion -->
- <scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/projec...</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/...</developerConnection>
- <url>http://fisheye.jboss.com/qsearch/JBossOSGi</url>
- </scm>
-
<!-- Properties -->
<properties>
<version.apache.aries.blueprint>1.0.0-incubating-SNAPSHOT</version.apache.aries.blueprint>
+ <version.apache.aries.jmx>1.0.0-incubating-SNAPSHOT</version.apache.aries.jmx>
<version.apache.aries.util>1.0.0-incubating-SNAPSHOT</version.apache.aries.util>
+ <version.apache.felix.log>1.0.0</version.apache.felix.log>
<version.jboss.osgi.common>1.0.4-SNAPSHOT</version.jboss.osgi.common>
<version.jboss.osgi.framework>1.0.0.Alpha4-SNAPSHOT</version.jboss.osgi.framework>
<version.jboss.osgi.husky>1.0.4-SNAPSHOT</version.jboss.osgi.husky>
<version.jboss.osgi.jmx>1.0.4-SNAPSHOT</version.jboss.osgi.jmx>
<version.jboss.osgi.spi>1.0.5-SNAPSHOT</version.jboss.osgi.spi>
- <version.jboss.osgi.testing>1.0.0-SNAPSHOT</version.jboss.osgi.testing>
+ <version.jboss.osgi.vfs>1.0.0-SNAPSHOT</version.jboss.osgi.vfs>
<version.osgi>4.2.0</version.osgi>
<surefire.jpda.args />
@@ -87,6 +82,12 @@
</exclusions>
</dependency>
<dependency>
+ <groupId>org.apache.aries.jmx</groupId>
+ <artifactId>org.apache.aries.jmx</artifactId>
+ <version>${version.apache.aries.jmx}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.aries</groupId>
<artifactId>org.apache.aries.util</artifactId>
<version>${version.apache.aries.util}</version>
@@ -99,6 +100,22 @@
</exclusions>
</dependency>
<dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.log</artifactId>
+ <version>${version.apache.felix.log}</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>org.jboss.osgi.bundles</groupId>
<artifactId>jboss-osgi-common</artifactId>
<version>${version.jboss.osgi.common}</version>
@@ -116,12 +133,6 @@
<version>${version.jboss.osgi.jmx}</version>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.jboss.osgi.runtime</groupId>
- <artifactId>jboss-osgi-framework</artifactId>
- <version>${version.jboss.osgi.framework}</version>
- <scope>provided</scope>
- </dependency>
<!-- OSGi Dependencies -->
<dependency>
@@ -139,9 +150,9 @@
<!-- Test Dependencies -->
<dependency>
- <groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-testing</artifactId>
- <version>${version.jboss.osgi.testing}</version>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework-vfs30</artifactId>
+ <version>${version.jboss.osgi.framework}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -273,7 +284,7 @@
<systemProperties>
<property>
<name>java.protocol.handler.pkgs</name>
- <value>org.jboss.net.protocol|org.jboss.virtual.protocol</value>
+ <value>org.jboss.net.protocol|org.jboss.vfs.protocol</value>
</property>
<property>
<name>log4j.output.dir</name>
@@ -295,58 +306,17 @@
</plugins>
</build>
+ <!-- Subversion -->
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/projec...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/...</developerConnection>
+ <url>http://fisheye.jboss.com/qsearch/JBossOSGi</url>
+ </scm>
+
<!-- Profiles -->
<profiles>
<!--
- Name: framework-equinox
- Descr: Setup for Equinox framework integration testing
- -->
- <profile>
- <id>framework-equinox</id>
- <activation>
- <property>
- <name>framework</name>
- <value>equinox</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skipTests>true</skipTests>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <!--
- Name: framework-felix
- Descr: Setup for Equinox framework integration testing
- -->
- <profile>
- <id>framework-felix</id>
- <activation>
- <property>
- <name>framework</name>
- <value>felix</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skipTests>true</skipTests>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <!--
Name: jpda
Descr: Enable JPDA remote debuging
-->
Modified: projects/jboss-osgi/projects/bundles/blueprint/trunk/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/blueprint/trunk/scripts/assembly-bundles.xml 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/blueprint/trunk/scripts/assembly-bundles.xml 2010-03-16 23:51:30 UTC (rev 102493)
@@ -15,11 +15,11 @@
<outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
<include>*:jboss-osgi-common:jar</include>
- <include>*:jboss-osgi-common-core:jar</include>
<include>*:jboss-osgi-husky:jar</include>
<include>*:jboss-osgi-jmx:jar</include>
- <include>*:jboss-osgi-jndi:jar</include>
+ <include>*:org.apache.aries.jmx:jar</include>
<include>*:org.apache.aries.util:jar</include>
+ <include>*:org.apache.felix.log:jar</include>
</includes>
<useStrictFiltering>true</useStrictFiltering>
<scope>provided</scope>
Modified: projects/jboss-osgi/projects/bundles/blueprint/trunk/src/main/java/org/jboss/osgi/blueprint/BlueprintCapability.java
===================================================================
--- projects/jboss-osgi/projects/bundles/blueprint/trunk/src/main/java/org/jboss/osgi/blueprint/BlueprintCapability.java 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/blueprint/trunk/src/main/java/org/jboss/osgi/blueprint/BlueprintCapability.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -24,6 +24,7 @@
//$Id$
import org.jboss.osgi.spi.capability.Capability;
+import org.jboss.osgi.testing.OSGiRuntime;
/**
* Adds the Blueprint capability to the {@link OSGiRuntime}
Modified: projects/jboss-osgi/projects/bundles/blueprint/trunk/src/test/java/org/jboss/test/osgi/blueprint/container/BlueprintContainerTestCase.java
===================================================================
--- projects/jboss-osgi/projects/bundles/blueprint/trunk/src/test/java/org/jboss/test/osgi/blueprint/container/BlueprintContainerTestCase.java 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/blueprint/trunk/src/test/java/org/jboss/test/osgi/blueprint/container/BlueprintContainerTestCase.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -41,9 +41,10 @@
import org.jboss.osgi.husky.HuskyCapability;
import org.jboss.osgi.husky.RuntimeContext;
import org.jboss.osgi.jmx.JMXCapability;
+import org.jboss.osgi.spi.capability.LogServiceCapability;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
-import org.jboss.osgi.testing.OSGiTestHelper;
+import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.jboss.test.osgi.blueprint.container.bundle.BeanA;
import org.jboss.test.osgi.blueprint.container.bundle.BeanB;
import org.jboss.test.osgi.blueprint.container.bundle.ServiceA;
@@ -79,13 +80,14 @@
{
if (context == null)
{
- runtime = new OSGiTestHelper().getEmbeddedRuntime();
+ runtime = new OSGiRuntimeHelper().getEmbeddedRuntime();
runtime.addCapability(new HuskyCapability());
+ runtime.addCapability(new LogServiceCapability());
runtime.addCapability(new JMXCapability());
runtime.addCapability(new BlueprintCapability());
-
+
huskyBridge = BridgeFactory.getBridge();
-
+
OSGiBundle bundle = runtime.installBundle("container-basic.jar");
bundle.start();
}
@@ -103,9 +105,9 @@
{
if (context == null)
huskyBridge.run();
-
+
assumeNotNull(context);
-
+
Bundle bundle = context.getBundle();
assertEquals("container-basic", bundle.getSymbolicName());
}
@@ -115,9 +117,9 @@
{
if (context == null)
huskyBridge.run();
-
+
assumeNotNull(context);
-
+
BlueprintContainer bpContainer = getBlueprintContainer();
assertNotNull("BlueprintContainer available", bpContainer);
}
@@ -127,9 +129,9 @@
{
if (context == null)
huskyBridge.run();
-
+
assumeNotNull(context);
-
+
BlueprintContainer bpContainer = getBlueprintContainer();
BeanA beanA = (BeanA)bpContainer.getComponentInstance("beanA");
assertNotNull("ComponentInstance available", beanA);
@@ -140,25 +142,25 @@
{
if (context == null)
huskyBridge.run();
-
+
assumeNotNull(context);
-
+
ServiceReference srefA = context.getServiceReference(ServiceA.class.getName());
assertNotNull("ServiceReference available", srefA);
-
+
ServiceA serviceA = (ServiceA)context.getService(srefA);
assertNotNull("Service available", serviceA);
-
+
ServiceReference srefB = context.getServiceReference(ServiceB.class.getName());
assertNotNull("ServiceReference available", srefB);
-
+
ServiceB serviceB = (ServiceB)context.getService(srefB);
assertNotNull("Service available", serviceB);
-
+
BeanB beanB = (BeanB)serviceB;
BeanA beanA = beanB.getBeanA();
assertNotNull("BeanA available", beanA);
-
+
MBeanServer mbeanServer = beanA.getMbeanServer();
assertNotNull("MBeanServer available", mbeanServer);
}
@@ -168,12 +170,12 @@
{
if (context == null)
huskyBridge.run();
-
+
assumeNotNull(context);
-
+
BlueprintContainer bpContainer = getBlueprintContainer();
ComponentMetadata compMetadata = bpContainer.getComponentMetadata("beanA");
-
+
assertNotNull("ComponentMetadata not null", compMetadata);
assertEquals("beanA", compMetadata.getId());
}
@@ -183,9 +185,9 @@
{
if (context == null)
huskyBridge.run();
-
+
assumeNotNull(context);
-
+
BlueprintContainer bpContainer = getBlueprintContainer();
Set<String> compNames = bpContainer.getComponentIds();
@@ -202,15 +204,15 @@
{
if (context == null)
huskyBridge.run();
-
+
assumeNotNull(context);
-
+
BlueprintContainer bpContainer = getBlueprintContainer();
Collection<BeanMetadata> bcMetadata = bpContainer.getMetadata(BeanMetadata.class);
-
+
assertNotNull("BeanComponentsMetadata not null", bcMetadata);
assertEquals("BeanComponentsMetadata size", 2, bcMetadata.size());
-
+
BeanMetadata bmd = bcMetadata.iterator().next();
assertEquals("beanA", bmd.getId());
assertEquals(BeanA.class.getName(), bmd.getClassName());
@@ -221,27 +223,27 @@
{
if (context == null)
huskyBridge.run();
-
+
assumeNotNull(context);
-
+
BlueprintContainer bpContainer = getBlueprintContainer();
Collection<ServiceMetadata> servicesMetadata = bpContainer.getMetadata(ServiceMetadata.class);
assertNotNull("ServiceMetadata not null", servicesMetadata);
assertEquals("ServiceMetadata size", 2, servicesMetadata.size());
-
+
Iterator<ServiceMetadata> itServices = servicesMetadata.iterator();
ServiceMetadata serviceA = itServices.next();
assertEquals("serviceA", serviceA.getId());
-
+
List<String> interfaceNamesA = serviceA.getInterfaces();
assertNotNull("InterfaceNames not null", interfaceNamesA);
assertEquals("InterfaceNames size", 1, interfaceNamesA.size());
assertEquals("InterfaceName", ServiceA.class.getName(), interfaceNamesA.get(0));
-
+
ServiceMetadata serviceB = itServices.next();
assertEquals("serviceB", serviceB.getId());
-
+
List<String> interfaceNamesB = serviceB.getInterfaces();
assertNotNull("InterfaceNames not null", interfaceNamesB);
assertEquals("InterfaceNames size", 1, interfaceNamesB.size());
@@ -253,18 +255,18 @@
{
if (context == null)
huskyBridge.run();
-
+
assumeNotNull(context);
-
+
BlueprintContainer bpContainer = getBlueprintContainer();
Collection<ReferenceMetadata> srefsMetadata = bpContainer.getMetadata(ReferenceMetadata.class);
assertNotNull("ReferenceMetadata not null", srefsMetadata);
assertEquals("ReferenceMetadata size", 1, srefsMetadata.size());
-
+
ReferenceMetadata srefMetadata = srefsMetadata.iterator().next();
assertEquals("mbeanService", srefMetadata.getId());
-
+
String interfaceName = srefMetadata.getInterface();
assertNotNull("InterfaceName not null", interfaceName);
assertEquals("InterfaceName", MBeanServer.class.getName(), interfaceName);
@@ -274,7 +276,7 @@
{
// 10sec for processing of STARTING event
int timeout = 50;
-
+
ServiceReference sref = null;
while (sref == null && 0 < timeout--)
{
@@ -282,7 +284,7 @@
Thread.sleep(200);
}
assertNotNull("BlueprintContainer not null", sref);
-
+
BlueprintContainer bpContainer = (BlueprintContainer)context.getService(sref);
return bpContainer;
}
Modified: projects/jboss-osgi/projects/bundles/blueprint/trunk/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/blueprint/trunk/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/blueprint/trunk/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2010-03-16 23:51:30 UTC (rev 102493)
@@ -35,9 +35,10 @@
org.jboss.osgi.spi;version=1.0,
org.jboss.osgi.spi.capability;version=1.0,
org.jboss.osgi.spi.framework;version=1.0,
- org.jboss.osgi.spi.management;version=1.0,
org.jboss.osgi.spi.service;version=1.0,
- org.jboss.osgi.spi.util;version=1.0
+ org.jboss.osgi.spi.util;version=1.0,
+ org.jboss.osgi.testing;version=1.0,
+ org.jboss.osgi.vfs;version=1.0
</value></entry>
</map>
</property>
@@ -184,12 +185,11 @@
<!-- OSGI Deployment -->
<bean name="OSGiBundleActivatorDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleActivatorDeployer" />
- <bean name="OSGiBundleStateAddDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleStateAddDeployer">
+ <bean name="OSGiBundleStateCreateDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleStateCreateDeployer">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
- <bean name="OSGiBundleStateRemoveDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleStateRemoveDeployer">
- <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
- </bean>
+ <bean name="OSGiBundleStateInstallDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleStateInstallDeployer"/>
+ <bean name="OSGiBundleStateResolveDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleStateResolveDeployer"/>
<bean name="OSGiContextTrackerDeployer" class="org.jboss.osgi.framework.deployers.OSGiContextTrackerDeployer" />
<bean name="OSGiManifestParsingDeployer" class="org.jboss.osgi.framework.deployers.OSGiManifestParsingDeployer" />
<bean name="OSGiNativeCodeMetaDataDeployer" class="org.jboss.osgi.framework.deployers.OSGiNativeCodeMetaDataDeployer" />
Modified: projects/jboss-osgi/projects/bundles/common/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/common/trunk/pom.xml 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/common/trunk/pom.xml 2010-03-16 23:51:30 UTC (rev 102493)
@@ -30,13 +30,6 @@
<version>1.0.5-SNAPSHOT</version>
</parent>
- <!-- SCM -->
- <scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/projec...</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/...</developerConnection>
- <url>http://fisheye.jboss.com/qsearch/JBossOSGi</url>
- </scm>
-
<!-- Properties -->
<properties>
<version.jboss.osgi.spi>1.0.5-SNAPSHOT</version.jboss.osgi.spi>
@@ -98,8 +91,7 @@
<Import-Package>
javax.management,
org.apache.log4j;version=1.2;resolution:=optional,
- org.jboss.osgi.spi.capability;version=1.0,
- org.jboss.osgi.spi.util;version=1.0,
+ org.jboss.osgi.spi*;version="[1.0,2.0)",
org.osgi.framework;version=1.4,
org.osgi.service.log;version=1.3,
org.osgi.util.tracker
@@ -141,4 +133,12 @@
</plugin>
</plugins>
</build>
+
+ <!-- Subversion -->
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/projec...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/...</developerConnection>
+ <url>http://fisheye.jboss.com/qsearch/JBossOSGi</url>
+ </scm>
+
</project>
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/pom.xml 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/pom.xml 2010-03-16 23:51:30 UTC (rev 102493)
@@ -46,7 +46,6 @@
<version.jboss.osgi.deployment>1.0.2-SNAPSHOT</version.jboss.osgi.deployment>
<version.jboss.osgi.felix>2.0.2.SP1-SNAPSHOT</version.jboss.osgi.felix>
<version.jboss.osgi.jmx>1.0.4-SNAPSHOT</version.jboss.osgi.jmx>
- <version.jboss.osgi.testing>1.0.0-SNAPSHOT</version.jboss.osgi.testing>
<version.jboss.osgi.vfs>1.0.0-SNAPSHOT</version.jboss.osgi.vfs>
<version.osgi>4.2.0</version.osgi>
</properties>
@@ -135,12 +134,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-testing</artifactId>
- <version>${version.jboss.osgi.testing}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.jboss.osgi.vfs</groupId>
<artifactId>jboss-osgi-vfs21</artifactId>
<version>${version.jboss.osgi.vfs}</version>
Modified: projects/jboss-osgi/projects/bundles/jaxb/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/jaxb/trunk/pom.xml 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/jaxb/trunk/pom.xml 2010-03-16 23:51:30 UTC (rev 102493)
@@ -30,16 +30,9 @@
<version>1.0.4</version>
</parent>
- <!-- Subversion -->
- <scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/projec...</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/...</developerConnection>
- <url>http://fisheye.jboss.com/qsearch/JBossOSGi</url>
- </scm>
-
<!-- Properties -->
<properties>
- <version.jboss.osgi.apache.xerces>2.9.1.SP3</version.jboss.osgi.apache.xerces>
+ <version.jboss.osgi.apache.xerces>2.9.1.SP4-SNAPSHOT</version.jboss.osgi.apache.xerces>
<version.xml.bind>2.1.10</version.xml.bind>
<version.osgi>4.2.0</version.osgi>
</properties>
@@ -85,7 +78,7 @@
org.jboss.osgi.jaxb.internal
</Private-Package>
<Export-Package>
- org.jboss.osgi.jaxb;version=2.1.10
+ org.jboss.osgi.jaxb;version=${version}
</Export-Package>
<Import-Package>
<!-- system -->
@@ -99,9 +92,8 @@
org.xml.sax*,
<!-- import -->
- org.jboss.osgi.spi.capability;version=1.0,
- org.jboss.osgi.spi.util;version=1.0,
- org.jboss.osgi.xml,
+ org.jboss.osgi.spi*;version="[1.0,2.0)",
+ org.jboss.osgi.xml;version="[2.9,3.0)",
org.osgi.framework,
org.osgi.service.log,
@@ -128,4 +120,11 @@
</plugins>
</build>
+ <!-- Subversion -->
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/projec...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/...</developerConnection>
+ <url>http://fisheye.jboss.com/qsearch/JBossOSGi</url>
+ </scm>
+
</project>
Modified: projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/pom.xml 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/pom.xml 2010-03-16 23:51:30 UTC (rev 102493)
@@ -30,23 +30,20 @@
<version>1.0.5-SNAPSHOT</version>
</parent>
- <!-- Subversion -->
- <scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/projec...</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/...</developerConnection>
- <url>http://fisheye.jboss.com/qsearch/JBossOSGi</url>
- </scm>
-
<!-- Properties -->
<properties>
- <version.jboss.osgi.runtime.felix>2.0.2.SP1-SNAPSHOT</version.jboss.osgi.runtime.felix>
+ <version.apache.aries.jmx>1.0.0-incubating-SNAPSHOT</version.apache.aries.jmx>
+ <version.apache.aries.util>1.0.0-incubating-SNAPSHOT</version.apache.aries.util>
<version.jboss.xb>2.0.2.Beta4</version.jboss.xb>
- <version.jboss.osgi.common>1.0.3</version.jboss.osgi.common>
+ <version.jboss.osgi.common>1.0.4-SNAPSHOT</version.jboss.osgi.common>
<version.jboss.osgi.common.core>2.2.13.GA</version.jboss.osgi.common.core>
+ <version.jboss.osgi.felix>2.0.2.SP1-SNAPSHOT</version.jboss.osgi.felix>
<version.jboss.osgi.husky>1.0.4-SNAPSHOT</version.jboss.osgi.husky>
- <version.jboss.osgi.jaxb>2.1.10.SP3</version.jboss.osgi.jaxb>
+ <version.jboss.osgi.jaxb>2.1.10.SP4-SNAPSHOT</version.jboss.osgi.jaxb>
+ <version.jboss.osgi.jmx>1.0.4-SNAPSHOT</version.jboss.osgi.jmx>
<version.jboss.osgi.reflect>2.2.0</version.jboss.osgi.reflect>
<version.jboss.osgi.spi>1.0.5-SNAPSHOT</version.jboss.osgi.spi>
+ <version.jboss.osgi.vfs>1.0.0-SNAPSHOT</version.jboss.osgi.vfs>
<version.osgi>4.2.0</version.osgi>
</properties>
@@ -75,6 +72,24 @@
<!-- Provided Dependencies -->
<dependency>
+ <groupId>org.apache.aries.jmx</groupId>
+ <artifactId>org.apache.aries.jmx</artifactId>
+ <version>${version.apache.aries.jmx}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries</groupId>
+ <artifactId>org.apache.aries.util</artifactId>
+ <version>${version.apache.aries.util}</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>org.jboss.osgi.bundles</groupId>
<artifactId>jboss-osgi-common</artifactId>
<version>${version.jboss.osgi.common}</version>
@@ -99,6 +114,12 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.jboss.osgi.jmx</groupId>
+ <artifactId>jboss-osgi-jmx</artifactId>
+ <version>${version.jboss.osgi.jmx}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.jboss.osgi.bundles</groupId>
<artifactId>jboss-osgi-reflect</artifactId>
<version>${version.jboss.osgi.reflect}</version>
@@ -121,11 +142,17 @@
<!-- Test Dependencies -->
<dependency>
- <groupId>org.jboss.osgi.runtime</groupId>
- <artifactId>jboss-osgi-runtime-felix</artifactId>
- <version>${version.jboss.osgi.runtime.felix}</version>
+ <groupId>org.jboss.osgi.felix</groupId>
+ <artifactId>jboss-osgi-felix</artifactId>
+ <version>${version.jboss.osgi.felix}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.vfs</groupId>
+ <artifactId>jboss-osgi-vfs30</artifactId>
+ <version>${version.jboss.osgi.vfs}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -261,6 +288,13 @@
</plugins>
</build>
+ <!-- Subversion -->
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/projec...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/...</developerConnection>
+ <url>http://fisheye.jboss.com/qsearch/JBossOSGi</url>
+ </scm>
+
<!-- Profiles -->
<profiles>
Modified: projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/scripts/assembly-bundles.xml 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/scripts/assembly-bundles.xml 2010-03-16 23:51:30 UTC (rev 102493)
@@ -20,7 +20,10 @@
<include>*:jboss-osgi-common-core:jar</include>
<include>*:jboss-osgi-husky:jar</include>
<include>*:jboss-osgi-jaxb:jar</include>
+ <include>*:jboss-osgi-jmx:jar</include>
<include>*:jboss-osgi-reflect:jar</include>
+ <include>*:org.apache.aries.jmx:jar</include>
+ <include>*:org.apache.aries.util:jar</include>
<include>*:org.osgi.compendium:jar</include>
</includes>
<useStrictFiltering>true</useStrictFiltering>
Modified: projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/src/test/java/org/jboss/test/osgi/jbossxb/refresh/UnmarshallerServiceRefreshTestCase.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/src/test/java/org/jboss/test/osgi/jbossxb/refresh/UnmarshallerServiceRefreshTestCase.java 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/src/test/java/org/jboss/test/osgi/jbossxb/refresh/UnmarshallerServiceRefreshTestCase.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -24,11 +24,12 @@
//$Id: BasicXMLBindingTestCase.java 97031 2009-11-26 14:54:08Z thomas.diesler(a)jboss.com $
import org.jboss.osgi.jbossxb.XMLBindingCapability;
+import org.jboss.osgi.jmx.JMXCapability;
import org.jboss.osgi.testing.OSGiBundle;
-import org.jboss.osgi.testing.OSGiPackageAdmin;
import org.jboss.osgi.testing.OSGiRuntime;
-import org.jboss.osgi.testing.OSGiTest;
+import org.jboss.osgi.testing.OSGiRuntimeTest;
import org.junit.Test;
+import org.osgi.jmx.framework.FrameworkMBean;
/**
* Test XMLBindingService
@@ -36,7 +37,7 @@
* @author thomas.diesler(a)jboss.com
* @since 26-Nov-2009
*/
-public class UnmarshallerServiceRefreshTestCase extends OSGiTest
+public class UnmarshallerServiceRefreshTestCase extends OSGiRuntimeTest
{
@Test
public void testUnmarshaller() throws Exception
@@ -44,6 +45,7 @@
OSGiRuntime runtime = getDefaultRuntime();
try
{
+ runtime.addCapability(new JMXCapability());
runtime.addCapability(new XMLBindingCapability());
OSGiBundle serviceBundle = runtime.getBundle("jboss-osgi-xml-binding", null);
@@ -55,8 +57,8 @@
serviceBundle.uninstall();
- OSGiPackageAdmin packageAdmin = runtime.getPackageAdmin();
- packageAdmin.refreshPackages(null);
+ FrameworkMBean frameworkMBean = runtime.getFrameworkMBean();
+ frameworkMBean.refreshBundles(null);
serviceBundle = runtime.installBundle("bundles/jboss-osgi-xml-binding.jar");
serviceBundle.start();
Modified: projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/src/test/java/org/jboss/test/osgi/jbossxb/simple/BasicXMLBindingTestCase.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/src/test/java/org/jboss/test/osgi/jbossxb/simple/BasicXMLBindingTestCase.java 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/src/test/java/org/jboss/test/osgi/jbossxb/simple/BasicXMLBindingTestCase.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -35,7 +35,7 @@
import org.jboss.osgi.jbossxb.XMLBindingCapability;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
-import org.jboss.osgi.testing.OSGiTest;
+import org.jboss.osgi.testing.OSGiRuntimeTest;
import org.jboss.test.osgi.jbossxb.simple.bundle.CourseBooking;
import org.junit.After;
import org.junit.Before;
@@ -51,7 +51,7 @@
* @author thomas.diesler(a)jboss.com
* @since 26-Nov-2009
*/
-public class BasicXMLBindingTestCase extends OSGiTest
+public class BasicXMLBindingTestCase extends OSGiRuntimeTest
{
@RuntimeContext
public BundleContext context;
Modified: projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/src/test/resources/jboss-osgi-framework.properties
===================================================================
--- projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/src/test/resources/jboss-osgi-framework.properties 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/src/test/resources/jboss-osgi-framework.properties 2010-03-16 23:51:30 UTC (rev 102493)
@@ -24,6 +24,7 @@
org.jboss.osgi.spi.management;version=1.0, \
org.jboss.osgi.spi.service;version=1.0, \
org.jboss.osgi.spi.util;version=1.0, \
+ org.jboss.osgi.testing;version=1.0, \
org.jboss.logging;version=2.1, \
org.jboss.virtual;version=2.1, \
org.osgi.framework;version=1.5
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/pom.xml 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/pom.xml 2010-03-16 23:51:30 UTC (rev 102493)
@@ -31,10 +31,6 @@
<!-- Dependencies -->
<dependencies>
<dependency>
- <groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-spi</artifactId>
- </dependency>
- <dependency>
<groupId>org.apache.aries.jmx</groupId>
<artifactId>org.apache.aries.jmx.api</artifactId>
</dependency>
@@ -45,16 +41,6 @@
<artifactId>org.osgi.core</artifactId>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
</dependencies>
-
- <build>
- <plugins>
- </plugins>
- </build>
</project>
Deleted: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/JMXCapability.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/JMXCapability.java 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/JMXCapability.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.jmx;
-
-//$Id$
-
-import javax.management.MBeanServer;
-
-import org.jboss.osgi.spi.capability.Capability;
-import org.jboss.osgi.spi.capability.CompendiumCapability;
-
-/**
- * Adds the JMX capability to the {@link OSGiRuntime}
- * under test.
- *
- * It is ignored if the {@link MBeanServer} is already registered.
- *
- * Installed bundles: jboss-osgi-jmx.jar
- *
- * Default properties set by this capability
- *
- * <table>
- * <tr><th>Property</th><th>Value</th></tr>
- * <tr><td>org.jboss.osgi.jmx.host</td><td>${jboss.bind.address}</td></tr>
- * <tr><td>org.jboss.osgi.jmx.rmi.port</td><td>1198</td></tr>
- * </table>
- *
- * @author thomas.diesler(a)jboss.com
- * @since 05-May-2009
- */
-public class JMXCapability extends Capability
-{
- public JMXCapability()
- {
- super(MBeanServer.class.getName());
-
- addSystemProperty("org.jboss.osgi.jmx.host", System.getProperty("jboss.bind.address", "localhost"));
- addSystemProperty("org.jboss.osgi.jmx.rmi.port", "1198");
-
- addDependency(new CompendiumCapability());
-
- addBundle("bundles/jboss-osgi-jmx.jar");
- addBundle("bundles/org.apache.aries.jmx.jar");
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/pom.xml 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/pom.xml 2010-03-16 23:51:30 UTC (rev 102493)
@@ -36,8 +36,8 @@
<version>${version}</version>
</dependency>
<dependency>
- <groupId>org.apache.aries.jmx</groupId>
- <artifactId>org.apache.aries.jmx.api</artifactId>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-spi</artifactId>
</dependency>
<!-- Provided Dependencies -->
@@ -122,8 +122,8 @@
org.jboss.logging;version="[2.1,3.0)",
<!-- jboss-osgi -->
+ org.jboss.osgi.jmx;version="[1.0,2.0)",
org.jboss.osgi.spi*;version="[1.0,2.0)",
- org.jboss.osgi.jmx;version="[1.0,2.0)",
<!-- osgi -->
org.osgi.framework;version="[1.5,2.0)",
Copied: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/JMXCapability.java (from rev 101598, projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/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 (rev 0)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/JMXCapability.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.jmx;
+
+//$Id$
+
+import javax.management.MBeanServer;
+
+import org.jboss.osgi.spi.capability.Capability;
+import org.jboss.osgi.spi.capability.CompendiumCapability;
+import org.jboss.osgi.testing.OSGiRuntime;
+
+/**
+ * Adds the JMX capability to the {@link OSGiRuntime}
+ * under test.
+ *
+ * It is ignored if the {@link MBeanServer} is already registered.
+ *
+ * Installed bundles: jboss-osgi-jmx.jar
+ *
+ * Default properties set by this capability
+ *
+ * <table>
+ * <tr><th>Property</th><th>Value</th></tr>
+ * <tr><td>org.jboss.osgi.jmx.host</td><td>${jboss.bind.address}</td></tr>
+ * <tr><td>org.jboss.osgi.jmx.rmi.port</td><td>1198</td></tr>
+ * </table>
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 05-May-2009
+ */
+public class JMXCapability extends Capability
+{
+ public JMXCapability()
+ {
+ super(MBeanServer.class.getName());
+
+ addSystemProperty("org.jboss.osgi.jmx.host", System.getProperty("jboss.bind.address", "localhost"));
+ addSystemProperty("org.jboss.osgi.jmx.rmi.port", "1198");
+
+ addDependency(new CompendiumCapability());
+
+ addBundle("bundles/jboss-osgi-jmx.jar");
+ addBundle("bundles/org.apache.aries.jmx.jar");
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/bundles/serviceloader/trunk/src/main/java/org/jboss/osgi/serviceloader/ServiceLoaderCapability.java
===================================================================
--- projects/jboss-osgi/projects/bundles/serviceloader/trunk/src/main/java/org/jboss/osgi/serviceloader/ServiceLoaderCapability.java 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/serviceloader/trunk/src/main/java/org/jboss/osgi/serviceloader/ServiceLoaderCapability.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -24,6 +24,7 @@
//$Id$
import org.jboss.osgi.spi.capability.Capability;
+import org.jboss.osgi.testing.OSGiRuntime;
/**
* Adds the Blueprint capability to the {@link OSGiRuntime}
Modified: projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/WebAppCapability.java
===================================================================
--- projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/WebAppCapability.java 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/WebAppCapability.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -25,6 +25,7 @@
import org.jboss.osgi.spi.capability.Capability;
import org.jboss.osgi.spi.capability.HttpServiceCapability;
+import org.jboss.osgi.testing.OSGiRuntime;
/**
* Adds the WebApp (WAR) capability to the {@link OSGiRuntime}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml 2010-03-16 23:51:30 UTC (rev 102493)
@@ -167,11 +167,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-testing</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.jboss.osgi.framework</groupId>
<artifactId>jboss-osgi-framework-vfs30</artifactId>
<version>${version}</version>
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2010-03-16 23:51:30 UTC (rev 102493)
@@ -62,7 +62,6 @@
<version.jboss.osgi.jndi>1.0.3-SNAPSHOT</version.jboss.osgi.jndi>
<version.jboss.osgi.reflect>2.2.0</version.jboss.osgi.reflect>
<version.jboss.osgi.spi>1.0.5-SNAPSHOT</version.jboss.osgi.spi>
- <version.jboss.osgi.testing>1.0.0-SNAPSHOT</version.jboss.osgi.testing>
<version.jboss.osgi.vfs>1.0.0-SNAPSHOT</version.jboss.osgi.vfs>
<version.jboss.osgi.xml.binding>2.0.2.Beta4</version.jboss.osgi.xml.binding>
<version.jboss.test>1.1.4.GA</version.jboss.test>
@@ -236,11 +235,6 @@
<version>${version.jboss.test}</version>
</dependency>
<dependency>
- <groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-testing</artifactId>
- <version>${version.jboss.osgi.testing}</version>
- </dependency>
- <dependency>
<groupId>org.jboss.osgi.vfs</groupId>
<artifactId>jboss-osgi-vfs21</artifactId>
<version>${version.jboss.osgi.vfs}</version>
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/installer/install-definition.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/installer/install-definition.xml 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/installer/install-definition.xml 2010-03-16 23:51:30 UTC (rev 102493)
@@ -152,7 +152,6 @@
<include name="jboss-osgi-felix-sources.jar" />
<include name="jboss-osgi-jbossas-sources.jar" />
<include name="jboss-osgi-spi-sources.jar" />
- <include name="jboss-osgi-testing-sources.jar" />
<include name="jboss-osgi-webapp-sources.jar" />
<include name="jboss-osgi-webconsole-sources.jar" />
<include name="jboss-osgi-xml-binding-sources.jar" />
@@ -189,7 +188,6 @@
<include name="jboss-logging-log4j.jar" />
<include name="jboss-osgi-deployment.jar" />
<include name="jboss-osgi-spi.jar" />
- <include name="jboss-osgi-testing.jar" />
<include name="jboss-osgi-vfs.jar" />
<include name="jboss-osgi-vfs30.jar" />
<include name="jboss-vfs.jar" />
@@ -407,7 +405,6 @@
<include name="jboss-osgi-deployment.jar" />
<include name="jboss-osgi-jbossas.jar" />
<include name="jboss-osgi-spi.jar" />
- <include name="jboss-osgi-testing.jar" />
<include name="jboss-osgi-vfs.jar" />
</fileset>
<fileset condition="!isJBoss601" dir="@{deploy.artifacts.dir}/lib" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deployers/osgi.deployer" override="true">
Modified: projects/jboss-osgi/trunk/distribution/javadoc/scripts/assembly-javadoc-src.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/javadoc/scripts/assembly-javadoc-src.xml 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/trunk/distribution/javadoc/scripts/assembly-javadoc-src.xml 2010-03-16 23:51:30 UTC (rev 102493)
@@ -23,7 +23,6 @@
<include>*:jboss-osgi-jndi-api:jar:sources</include>
<include>*:jboss-osgi-jta:jar:sources</include>
<include>*:jboss-osgi-spi:jar:sources</include>
- <include>*:jboss-osgi-testing:jar:sources</include>
<include>*:jboss-osgi-vfs:jar:sources</include>
<include>*:jboss-osgi-webapp:jar:sources</include>
<include>*:jboss-osgi-xml-binding:jar:sources</include>
Modified: projects/jboss-osgi/trunk/distribution/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/pom.xml 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/trunk/distribution/pom.xml 2010-03-16 23:51:30 UTC (rev 102493)
@@ -72,22 +72,6 @@
<classifier>javadoc</classifier>
</dependency>
<dependency>
- <groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-testing</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-testing</artifactId>
- <version>${version.jboss.osgi.testing}</version>
- <classifier>sources</classifier>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-testing</artifactId>
- <version>${version.jboss.osgi.testing}</version>
- <classifier>javadoc</classifier>
- </dependency>
- <dependency>
<groupId>org.jboss.osgi.deployers</groupId>
<artifactId>jboss-osgi-deployers-vfs30</artifactId>
</dependency>
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/trunk/pom.xml 2010-03-16 23:51:30 UTC (rev 102493)
@@ -66,7 +66,7 @@
<version.jboss.osgi.framework>1.0.0.Alpha4-SNAPSHOT</version.jboss.osgi.framework>
<version.jboss.osgi.hotdeploy>1.0.5-SNAPSHOT</version.jboss.osgi.hotdeploy>
<version.jboss.osgi.husky>1.0.4-SNAPSHOT</version.jboss.osgi.husky>
- <version.jboss.osgi.jaxb>2.1.10.SP3</version.jboss.osgi.jaxb>
+ <version.jboss.osgi.jaxb>2.1.10.SP4-SNAPSHOT</version.jboss.osgi.jaxb>
<version.jboss.osgi.jbossas>1.0.3-SNAPSHOT</version.jboss.osgi.jbossas>
<version.jboss.osgi.jmx>1.0.4-SNAPSHOT</version.jboss.osgi.jmx>
<version.jboss.osgi.jndi>1.0.3-SNAPSHOT</version.jboss.osgi.jndi>
@@ -74,7 +74,6 @@
<version.jboss.osgi.reflect>2.2.0</version.jboss.osgi.reflect>
<version.jboss.osgi.serviceloader>1.0.1-SNAPSHOT</version.jboss.osgi.serviceloader>
<version.jboss.osgi.spi>1.0.5-SNAPSHOT</version.jboss.osgi.spi>
- <version.jboss.osgi.testing>1.0.0-SNAPSHOT</version.jboss.osgi.testing>
<version.jboss.osgi.vfs>1.0.0-SNAPSHOT</version.jboss.osgi.vfs>
<version.jboss.osgi.webapp>0.7.2.SP2-SNAPSHOT</version.jboss.osgi.webapp>
<version.jboss.osgi.webconsole>1.0.2</version.jboss.osgi.webconsole>
@@ -127,11 +126,6 @@
<version>${version.jboss.osgi.spi}</version>
</dependency>
<dependency>
- <groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-testing</artifactId>
- <version>${version.jboss.osgi.testing}</version>
- </dependency>
- <dependency>
<groupId>org.jboss.osgi.deployers</groupId>
<artifactId>jboss-osgi-deployers-vfs21</artifactId>
<version>${version.jboss.osgi.deployers}</version>
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/enterprise/jmx/JMXEnterpriseTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/enterprise/jmx/JMXEnterpriseTestCase.java 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/enterprise/jmx/JMXEnterpriseTestCase.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -34,8 +34,8 @@
import org.jboss.osgi.jmx.MBeanProxy;
import org.jboss.osgi.jmx.ObjectNameFactory;
import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.jboss.osgi.testing.OSGiRuntimeTest;
-import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/HttpServiceTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/HttpServiceTestCase.java 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/HttpServiceTestCase.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -32,8 +32,8 @@
import org.jboss.osgi.spi.capability.HttpServiceCapability;
import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.jboss.osgi.testing.OSGiServiceReference;
-import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/interceptor/InterceptorTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/interceptor/InterceptorTestCase.java 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/interceptor/InterceptorTestCase.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -32,8 +32,8 @@
import org.jboss.osgi.spi.capability.HttpServiceCapability;
import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.jboss.osgi.testing.OSGiServiceReference;
-import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/serviceloader/ServiceLoaderTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/serviceloader/ServiceLoaderTestCase.java 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/serviceloader/ServiceLoaderTestCase.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -32,8 +32,8 @@
import org.jboss.osgi.spi.util.ServiceLoader;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiRuntimeTest;
import org.jboss.osgi.testing.OSGiServiceReference;
-import org.jboss.osgi.testing.OSGiRuntimeTest;
import org.jboss.test.osgi.example.serviceloader.service.AccountService;
import org.jboss.test.osgi.example.serviceloader.service.internal.AccountServiceImpl;
import org.junit.Test;
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jaxb/CourseBooking.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jaxb/CourseBooking.java 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jaxb/CourseBooking.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -11,6 +11,7 @@
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/capabilities/CapabilityTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/capabilities/CapabilityTestCase.java 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/capabilities/CapabilityTestCase.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -43,8 +43,8 @@
import org.jboss.osgi.spi.capability.LogServiceCapability;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiRuntimeTest;
import org.jboss.osgi.testing.OSGiServiceReference;
-import org.jboss.osgi.testing.OSGiRuntimeTest;
import org.jboss.osgi.xml.XMLParserCapability;
import org.junit.Test;
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi112/OSGi112TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi112/OSGi112TestCase.java 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi112/OSGi112TestCase.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -25,8 +25,8 @@
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.jboss.osgi.testing.OSGiRuntimeTest;
-import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGi92TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGi92TestCase.java 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGi92TestCase.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -31,9 +31,9 @@
import org.jboss.osgi.spi.capability.CompendiumCapability;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiRuntimeHelper;
+import org.jboss.osgi.testing.OSGiRuntimeTest;
import org.jboss.osgi.testing.OSGiServiceReference;
-import org.jboss.osgi.testing.OSGiRuntimeTest;
-import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGi99TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGi99TestCase.java 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGi99TestCase.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -35,8 +35,8 @@
import org.jboss.osgi.spi.util.ConstantsHelper;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.jboss.osgi.testing.OSGiRuntimeTest;
-import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGi36TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGi36TestCase.java 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGi36TestCase.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -28,8 +28,8 @@
import org.jboss.osgi.jmx.JMXCapability;
import org.jboss.osgi.jmx.MBeanProxy;
+import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.jboss.osgi.testing.OSGiRuntimeTest;
-import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.jboss.osgi.testing.internal.RemoteRuntime;
import org.jboss.test.osgi.jbossas.jbosgi36.mbean.FooMBean;
import org.junit.AfterClass;
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/localization/LocalizationTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/localization/LocalizationTestCase.java 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/localization/LocalizationTestCase.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -23,15 +23,15 @@
//$Id$
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
import java.util.Dictionary;
import java.util.Locale;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.jboss.osgi.testing.OSGiRuntimeTest;
-import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/performance/blueprint/BlueprintStressTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/performance/blueprint/BlueprintStressTestCase.java 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/performance/blueprint/BlueprintStressTestCase.java 2010-03-16 23:51:30 UTC (rev 102493)
@@ -28,8 +28,8 @@
import org.jboss.osgi.blueprint.BlueprintCapability;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.jboss.osgi.testing.OSGiServiceReference;
-import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.jboss.test.osgi.performance.blueprint.bundle.ServiceA;
import org.jboss.test.osgi.performance.blueprint.bundle.ServiceB;
import org.junit.Test;
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2010-03-16 23:49:00 UTC (rev 102492)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2010-03-16 23:51:30 UTC (rev 102493)
@@ -49,10 +49,6 @@
<artifactId>jboss-osgi-spi</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-testing</artifactId>
- </dependency>
- <dependency>
<groupId>org.jboss.osgi.runtime</groupId>
<artifactId>jboss-osgi-deployment</artifactId>
</dependency>
14 years, 3 months
JBoss-OSGI SVN: r102491 - in projects/jboss-osgi/projects/spi/trunk: src/main/java/org/jboss/osgi and 2 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-16 19:44:55 -0400 (Tue, 16 Mar 2010)
New Revision: 102491
Added:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntimeHelper.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntimeTest.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.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/RemoteRuntime.java
Removed:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.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/RemoteRuntime.java
Modified:
projects/jboss-osgi/projects/spi/trunk/pom.xml
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java
Log:
Prepare for SPI/Testing integration
Modified: projects/jboss-osgi/projects/spi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/pom.xml 2010-03-16 23:12:02 UTC (rev 102490)
+++ projects/jboss-osgi/projects/spi/trunk/pom.xml 2010-03-16 23:44:55 UTC (rev 102491)
@@ -29,17 +29,12 @@
<version>1.0.5-SNAPSHOT</version>
</parent>
- <!-- Subversion -->
- <scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/projec...</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/...</developerConnection>
- <url>http://fisheye.jboss.com/qsearch/JBossOSGi</url>
- </scm>
-
<!-- Properties -->
<properties>
<version.args4j>2.0.12</version.args4j>
+ <version.jboss.osgi.jmx>1.0.4-SNAPSHOT</version.jboss.osgi.jmx>
<version.jboss.osgi.vfs>1.0.0-SNAPSHOT</version.jboss.osgi.vfs>
+ <version.jboss.shrinkwrap>1.0.0-SNAPSHOT</version.jboss.shrinkwrap>
<version.osgi>4.2.0</version.osgi>
</properties>
@@ -57,10 +52,24 @@
<artifactId>jboss-logging-spi</artifactId>
</dependency>
<dependency>
+ <groupId>org.jboss.osgi.jmx</groupId>
+ <artifactId>jboss-osgi-jmx-api</artifactId>
+ <version>${version.jboss.osgi.jmx}</version>
+ </dependency>
+ <dependency>
<groupId>org.jboss.osgi.vfs</groupId>
<artifactId>jboss-osgi-vfs</artifactId>
<version>${version.jboss.osgi.vfs}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-impl-base</artifactId>
+ <version>${version.jboss.shrinkwrap}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
<!-- Provided Dependencies -->
<dependency>
@@ -128,4 +137,12 @@
</snapshots>
</repository>
</repositories>
+
+ <!-- Subversion -->
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/projec...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/...</developerConnection>
+ <url>http://fisheye.jboss.com/qsearch/JBossOSGi</url>
+ </scm>
+
</project>
Copied: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing (from rev 102159, projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing)
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java 2010-03-09 19:47:32 UTC (rev 102159)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java 2010-03-16 23:44:55 UTC (rev 102491)
@@ -99,7 +99,7 @@
/**
* Returns a URL to the entry at the specified path in this bundle.
*
- * @param name The path name of the entry
+ * @param path The path name of the entry
* @return A URL to the entry, or null if no entry could be found
*/
public abstract URL getEntry(String path);
Copied: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntimeHelper.java (from rev 102342, projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntimeHelper.java)
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntimeHelper.java (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntimeHelper.java 2010-03-16 23:44:55 UTC (rev 102491)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing;
+
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.testing.internal.EmbeddedRuntime;
+import org.jboss.osgi.testing.internal.RemoteRuntime;
+
+/**
+ * A helper for the OSGi runtime abstraction.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 25-Sep-2008
+ */
+public class OSGiRuntimeHelper extends OSGiTestHelper
+{
+ // The OSGiBootstrapProvider is a lazy property of the helper
+ private OSGiBootstrapProvider bootProvider;
+ private boolean skipBootstrap;
+
+ public OSGiBootstrapProvider getBootstrapProvider()
+ {
+ if (bootProvider == null && skipBootstrap == false)
+ {
+ try
+ {
+ bootProvider = OSGiBootstrap.getBootstrapProvider();
+ }
+ catch (RuntimeException rte)
+ {
+ skipBootstrap = true;
+ throw rte;
+ }
+ }
+ return bootProvider;
+ }
+
+ public void ungetBootstrapProvider()
+ {
+ bootProvider = null;
+ }
+
+ public OSGiRuntime getDefaultRuntime()
+ {
+ OSGiRuntime runtime;
+
+ String target = System.getProperty("target.container");
+ if (target == null)
+ {
+ runtime = getEmbeddedRuntime();
+ }
+ else
+ {
+ runtime = getRemoteRuntime();
+ }
+ return runtime;
+ }
+
+ public OSGiRuntime getEmbeddedRuntime()
+ {
+ return new EmbeddedRuntime(this);
+ }
+
+ public OSGiRuntime getRemoteRuntime()
+ {
+ return new RemoteRuntime(this);
+ }
+}
Copied: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntimeTest.java (from rev 102342, projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntimeTest.java)
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntimeTest.java (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntimeTest.java 2010-03-16 23:44:55 UTC (rev 102491)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing;
+
+/**
+ * An abstract OSGi runtime test.
+ *
+ * A convenience wrapper for the functionality provided by {@link OSGiRuntimeHelper}.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 25-Sep-2008
+ */
+public abstract class OSGiRuntimeTest extends OSGiTest
+{
+ private OSGiRuntimeHelper helper;
+
+ /**
+ * Get the test helper used by this test
+ *
+ * Overwrite if you need to supply another helper
+ * i.e. one that you have statically setup
+ */
+ protected OSGiRuntimeHelper getRuntimeHelper()
+ {
+ if (helper == null)
+ helper = new OSGiRuntimeHelper();
+
+ return helper;
+ }
+
+ /**
+ * Delegates to {@link OSGiRuntimeHelper#getDefaultRuntime()}
+ */
+ protected OSGiRuntime getDefaultRuntime()
+ {
+ return getRuntimeHelper().getDefaultRuntime();
+ }
+
+ /**
+ * Delegates to {@link OSGiRuntimeHelper#getEmbeddedRuntime()}
+ */
+ protected OSGiRuntime getEmbeddedRuntime()
+ {
+ return getRuntimeHelper().getEmbeddedRuntime();
+ }
+
+ /**
+ * Delegates to {@link OSGiRuntimeHelper#getRemoteRuntime()}
+ */
+ public OSGiRuntime getRemoteRuntime()
+ {
+ return getRuntimeHelper().getRemoteRuntime();
+ }
+}
Deleted: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java 2010-03-09 19:47:32 UTC (rev 102159)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java 2010-03-16 23:44:55 UTC (rev 102491)
@@ -1,221 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.testing;
-
-import java.io.File;
-import java.net.URL;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.vfs.VirtualFile;
-import org.junit.After;
-import org.junit.Before;
-import org.osgi.framework.Bundle;
-
-/**
- * An abstract OSGi Test.
- *
- * {@link OSGiTest} is a convenience wrapper for the functionality provided
- * by {@link OSGiTestHelper}.
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 25-Sep-2008
- */
-public abstract class OSGiTest
-{
- // Provide logging
- private static final Logger log = Logger.getLogger(OSGiTest.class);
-
- private OSGiTestHelper helper;
-
- protected OSGiTest()
- {
- }
-
- /**
- * Get the test helper used by this test
- *
- * Overwrite if you need to supply another helper
- * i.e. one that you have statically setup
- */
- protected OSGiTestHelper getTestHelper()
- {
- if (helper == null)
- helper = new OSGiTestHelper();
-
- return helper;
- }
-
- /**
- * Writes a a debug start messge
- */
- @Before
- public void setUp() throws Exception
- {
- log.debug("### START " + getLongName());
- }
-
- /**
- * Writes a a debug stop messge
- */
- @After
- public void tearDown() throws Exception
- {
- log.debug("### END " + getLongName());
- }
-
- /**
- * Get the last token in the FQN of this test class.
- */
- protected String getShortName()
- {
- String shortName = getClass().getName();
- shortName = shortName.substring(shortName.lastIndexOf(".") + 1);
- return shortName;
- }
-
- /**
- * Get the the FQN of this test class.
- */
- protected String getLongName()
- {
- return getClass().getName();
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getDefaultRuntime()}
- */
- protected OSGiRuntime getDefaultRuntime()
- {
- return getTestHelper().getDefaultRuntime();
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getEmbeddedRuntime()}
- */
- protected OSGiRuntime getEmbeddedRuntime()
- {
- return getTestHelper().getEmbeddedRuntime();
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getRemoteRuntime()}
- */
- public OSGiRuntime getRemoteRuntime()
- {
- return getTestHelper().getRemoteRuntime();
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getResourceURL(String)}
- */
- protected URL getResourceURL(String resource)
- {
- return getTestHelper().getResourceURL(resource);
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getResourceFile(String)}
- */
- protected File getResourceFile(String resource)
- {
- return getTestHelper().getResourceFile(resource);
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getTestArchiveURL(String)}
- */
- protected URL getTestArchiveURL(String archive)
- {
- return getTestHelper().getTestArchiveURL(archive);
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getTestArchivePath(String)}
- */
- protected String getTestArchivePath(String archive)
- {
- return getTestHelper().getTestArchivePath(archive);
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getTestArchiveFile(String)}
- */
- protected File getTestArchiveFile(String archive)
- {
- return getTestHelper().getTestArchiveFile(archive);
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getInitialContext()}
- */
- public InitialContext getInitialContext() throws NamingException
- {
- return getTestHelper().getInitialContext();
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getServerHost()}
- */
- public String getServerHost()
- {
- return getTestHelper().getServerHost();
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getTargetContainer()}
- */
- public String getTargetContainer()
- {
- return getTestHelper().getTargetContainer();
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getFrameworkName()}
- */
- public String getFrameworkName()
- {
- return getTestHelper().getFrameworkName();
- }
-
- public VirtualFile assembleBundle(String name, String resource, Class<?>... packages) throws Exception
- {
- return getTestHelper().assembleBundle(name, resource, packages);
- }
-
- public VirtualFile assembleBundle(String name, String[] resources, Class<?>... packages) throws Exception
- {
- return getTestHelper().assembleBundle(name, resources, packages);
- }
-
- public void assertBundleState(int expState, int wasState)
- {
- getTestHelper().assertBundleState(expState, wasState);
- }
-
- public void assertBundleLoadClass(Bundle bundle, String className, boolean success)
- {
- getTestHelper().assertBundleLoadClass(bundle, className, success);
- }
-}
Copied: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java (from rev 102342, projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java)
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java 2010-03-16 23:44:55 UTC (rev 102491)
@@ -0,0 +1,212 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.vfs.VirtualFile;
+import org.junit.After;
+import org.junit.Before;
+import org.osgi.framework.Bundle;
+
+/**
+ * An abstract OSGi Test.
+ *
+ * A convenience wrapper for the functionality provided by {@link OSGiTestHelper}.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 25-Sep-2008
+ */
+public abstract class OSGiTest
+{
+ // Provide logging
+ private static final Logger log = Logger.getLogger(OSGiTest.class);
+
+ private OSGiTestHelper helper;
+
+ /**
+ * Get the test helper used by this test
+ *
+ * Overwrite if you need to supply another helper
+ * i.e. one that you have statically setup
+ */
+ protected OSGiTestHelper getTestHelper()
+ {
+ if (helper == null)
+ helper = new OSGiTestHelper();
+
+ return helper;
+ }
+
+ /**
+ * Writes a a debug start messge
+ */
+ @Before
+ public void setUp() throws Exception
+ {
+ log.debug("### START " + getLongName());
+ }
+
+ /**
+ * Writes a a debug stop messge
+ */
+ @After
+ public void tearDown() throws Exception
+ {
+ log.debug("### END " + getLongName());
+ }
+
+ /**
+ * Get the last token in the FQN of this test class.
+ */
+ protected String getShortName()
+ {
+ String shortName = getClass().getName();
+ shortName = shortName.substring(shortName.lastIndexOf(".") + 1);
+ return shortName;
+ }
+
+ /**
+ * Get the the FQN of this test class.
+ */
+ protected String getLongName()
+ {
+ return getClass().getName();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getResourceURL(String)}
+ */
+ protected URL getResourceURL(String resource)
+ {
+ return getTestHelper().getResourceURL(resource);
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getResourceFile(String)}
+ */
+ protected File getResourceFile(String resource)
+ {
+ return getTestHelper().getResourceFile(resource);
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getTestArchiveURL(String)}
+ */
+ protected URL getTestArchiveURL(String archive)
+ {
+ return getTestHelper().getTestArchiveURL(archive);
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getTestArchivePath(String)}
+ */
+ protected String getTestArchivePath(String archive)
+ {
+ return getTestHelper().getTestArchivePath(archive);
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getTestArchiveFile(String)}
+ */
+ protected File getTestArchiveFile(String archive)
+ {
+ return getTestHelper().getTestArchiveFile(archive);
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getInitialContext()}
+ */
+ public InitialContext getInitialContext() throws NamingException
+ {
+ return getTestHelper().getInitialContext();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getServerHost()}
+ */
+ public String getServerHost()
+ {
+ return getTestHelper().getServerHost();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getTargetContainer()}
+ */
+ public String getTargetContainer()
+ {
+ return getTestHelper().getTargetContainer();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getFrameworkName()}
+ */
+ public String getFrameworkName()
+ {
+ return getTestHelper().getFrameworkName();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#assembleArchive(String, String, Class...)}
+ */
+ public VirtualFile assembleArchive(String name, String resource, Class<?>... packages) throws Exception
+ {
+ return getTestHelper().assembleArchive(name, resource, packages);
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#assembleArchive(String, String[], Class...)}
+ */
+ public VirtualFile assembleArchive(String name, String[] resources, Class<?>... packages) throws Exception
+ {
+ return getTestHelper().assembleArchive(name, resources, packages);
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#assertBundleState(int, int)}
+ */
+ public void assertBundleState(int expState, int wasState)
+ {
+ getTestHelper().assertBundleState(expState, wasState);
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#assertLoadClass(Bundle, String)}
+ */
+ public Class<?> assertLoadClass(Bundle bundle, String className)
+ {
+ return getTestHelper().assertLoadClass(bundle, className);
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#assertLoadClassFail(Bundle, String)}
+ */
+ public void assertLoadClassFail(Bundle bundle, String className)
+ {
+ getTestHelper().assertLoadClassFail(bundle, className);
+ }
+}
Deleted: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2010-03-09 19:47:32 UTC (rev 102159)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2010-03-16 23:44:55 UTC (rev 102491)
@@ -1,334 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.testing;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Hashtable;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jboss.osgi.spi.framework.OSGiBootstrap;
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
-import org.jboss.osgi.spi.util.ConstantsHelper;
-import org.jboss.osgi.testing.internal.EmbeddedRuntime;
-import org.jboss.osgi.testing.internal.RemoteRuntime;
-import org.jboss.osgi.vfs.AbstractVFS;
-import org.jboss.osgi.vfs.VirtualFile;
-import org.jboss.shrinkwrap.api.Archives;
-import org.jboss.shrinkwrap.api.Asset;
-import org.jboss.shrinkwrap.api.exporter.ZipExporter;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.osgi.framework.Bundle;
-
-/**
- * An OSGi Test Helper
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 25-Sep-2008
- */
-public class OSGiTestHelper
-{
- private static final String SYSPROP_TEST_RESOURCES_DIRECTORY = "test.resources.directory";
- private static final String SYSPROP_TEST_ARCHIVE_DIRECTORY = "test.archive.directory";
-
- // The OSGiBootstrapProvider is a lazy property of the helper
- private OSGiBootstrapProvider bootProvider;
- private boolean skipCreateBootstrapProvider;
-
- private static String testResourcesDir;
- private static String testArchiveDir;
-
- public OSGiTestHelper()
- {
- testResourcesDir = System.getProperty(SYSPROP_TEST_RESOURCES_DIRECTORY, "target/test-classes");
- testArchiveDir = System.getProperty(SYSPROP_TEST_ARCHIVE_DIRECTORY, "target/test-libs");
- }
-
- public OSGiBootstrapProvider getBootstrapProvider()
- {
- if (bootProvider == null && skipCreateBootstrapProvider == false)
- {
- try
- {
- bootProvider = OSGiBootstrap.getBootstrapProvider();
- }
- catch (RuntimeException rte)
- {
- skipCreateBootstrapProvider = true;
- throw rte;
- }
- }
- return bootProvider;
- }
-
- public void ungetBootstrapProvider()
- {
- bootProvider = null;
- }
-
- public OSGiRuntime getDefaultRuntime()
- {
- OSGiRuntime runtime;
-
- String target = System.getProperty("target.container");
- if (target == null)
- {
- runtime = getEmbeddedRuntime();
- }
- else
- {
- runtime = getRemoteRuntime();
- }
- return runtime;
- }
-
- public OSGiRuntime getEmbeddedRuntime()
- {
- return new EmbeddedRuntime(this);
- }
-
- public OSGiRuntime getRemoteRuntime()
- {
- return new RemoteRuntime(this);
- }
-
- /** Try to discover the URL for the test resource */
- public URL getResourceURL(String resource)
- {
- URL resURL = null;
- try
- {
- File resourceFile = getResourceFile(resource);
- resURL = resourceFile.toURI().toURL();
- }
- catch (MalformedURLException e)
- {
- // ignore
- }
- return resURL;
- }
-
- /** Try to discover the File for the test resource */
- public File getResourceFile(String resource)
- {
- File file = new File(resource);
- if (file.exists())
- return file;
-
- file = new File(testResourcesDir + "/" + resource);
- if (file.exists())
- return file;
-
- throw new IllegalArgumentException("Cannot obtain '" + testResourcesDir + "/" + resource + "'");
- }
-
- /** Try to discover the URL for the deployment archive */
- public URL getTestArchiveURL(String archive)
- {
- try
- {
- return getTestArchiveFile(archive).toURI().toURL();
- }
- catch (MalformedURLException ex)
- {
- throw new IllegalStateException(ex);
- }
- }
-
- /** Try to discover the absolute path for the deployment archive */
- public String getTestArchivePath(String archive)
- {
- return getTestArchiveFile(archive).getAbsolutePath();
- }
-
- /** Try to discover the File for the deployment archive */
- public File getTestArchiveFile(String archive)
- {
- File file = new File(archive);
- if (file.exists())
- return file;
-
- file = new File(testArchiveDir + "/" + archive);
- if (file.exists())
- return file;
-
- throw new IllegalArgumentException("Cannot obtain '" + testArchiveDir + "/" + archive + "'.");
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public InitialContext getInitialContext() throws NamingException
- {
- String port = System.getProperty("jndi.server.port", "1099");
- Integer jndiPort = new Integer(port);
-
- Hashtable env = new Hashtable();
- env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
- env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
- env.put("java.naming.provider.url", "jnp://" + getServerHost() + ":" + jndiPort);
- return new InitialContext(env);
- }
-
- public String getServerHost()
- {
- String bindAddress = System.getProperty("jboss.bind.address", "localhost");
- return bindAddress;
- }
-
- public String getTargetContainer()
- {
- String targetContainer = System.getProperty("target.container");
- return targetContainer;
- }
-
- public String getFrameworkName()
- {
- String framework = System.getProperty("framework");
- if (framework == null || framework.length() == 0 || framework.equals("${framework}"))
- framework = "jbossmc";
-
- return framework;
- }
-
- public VirtualFile assembleBundle(String name, String resource, Class<?>... packages) throws Exception
- {
- return assembleBundle(name, new String[] { resource }, packages);
- }
-
- public VirtualFile assembleBundle(String name, String[] resources, Class<?>... packages) throws IOException
- {
- JavaArchive archive = Archives.create(name + ".jar", JavaArchive.class);
- if (resources != null)
- {
- for (String res : resources)
- {
- URL url = getClass().getResource(res);
- if (url == null)
- throw new IllegalArgumentException("Cannot load resource: " + res);
-
- final VirtualFile file = AbstractVFS.getChild(url);
- if (file.isDirectory())
- {
- addResources(archive, file, file);
- }
- else
- {
- addResource(archive, res, file);
- }
- }
- }
- if (packages != null)
- {
- for(Class<?> clazz : packages)
- {
- URL url = clazz.getResource("/");
- VirtualFile base = AbstractVFS.getChild(url);
-
- String path = clazz.getName().replace('.', '/');
- path = path.substring(0, path.lastIndexOf("/"));
-
- VirtualFile classes = base.getChild(path);
- addResources(archive, base, classes);
- }
- }
-
- // Convert archive to file URL
- ZipExporter exporter = archive.as(ZipExporter.class);
- File target = File.createTempFile("archive_", ".jar");
- exporter.exportZip(target, true);
- target.deleteOnExit();
-
- return AbstractVFS.getChild(target.toURI().toURL());
- }
-
- private void addResources(JavaArchive archive, VirtualFile basedir, VirtualFile resdir) throws IOException
- {
- String basepath = basedir.getPathName();
- for (final VirtualFile child : resdir.getChildrenRecursively())
- {
- if (child.isDirectory())
- continue;
-
- String path = child.getPathName();
- path = path.substring(basepath.length());
-
- addResource(archive, path, child);
- }
- }
-
- private void addResource(JavaArchive archive, String path, final VirtualFile file)
- {
- Asset asset = new Asset()
- {
- public InputStream openStream()
- {
- try
- {
- return file.openStream();
- }
- catch (IOException ex)
- {
- throw new IllegalStateException("Cannot open stream for: " + file, ex);
- }
- }
- };
- archive.add(asset, path);
- }
-
- public void assertBundleState(int expState, int wasState)
- {
- String expstr = ConstantsHelper.bundleState(expState);
- String wasstr = ConstantsHelper.bundleState(wasState);
- assertEquals("Bundle " + expstr, expstr, wasstr);
- }
-
- public void assertBundleLoadClass(Bundle bundle, String className, boolean success)
- {
- String message = bundle.getSymbolicName() + " loads " + className;
-
- Class<?> clazz;
- try
- {
- clazz = bundle.loadClass(className);
- if (success)
- {
- assertEquals(message, className, clazz.getName());
- }
- else
- {
- fail("ClassNotFoundException expected for: " + message + "\nLoaded from " + clazz.getClassLoader());
- }
- }
- catch (ClassNotFoundException ex)
- {
- if (success)
- fail("Unexpected ClassNotFoundException for: " + message);
- }
- }
-}
Copied: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java (from rev 102342, projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java)
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2010-03-16 23:44:55 UTC (rev 102491)
@@ -0,0 +1,282 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Hashtable;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.osgi.spi.util.ConstantsHelper;
+import org.jboss.osgi.vfs.AbstractVFS;
+import org.jboss.osgi.vfs.VirtualFile;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.Asset;
+import org.jboss.shrinkwrap.api.exporter.ZipExporter;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.osgi.framework.Bundle;
+
+/**
+ * An OSGi Test Helper
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 25-Sep-2008
+ */
+public class OSGiTestHelper
+{
+ private static final String SYSPROP_TEST_RESOURCES_DIRECTORY = "test.resources.directory";
+ private static final String SYSPROP_TEST_ARCHIVE_DIRECTORY = "test.archive.directory";
+
+ private static String testResourcesDir;
+ private static String testArchiveDir;
+
+ public OSGiTestHelper()
+ {
+ testResourcesDir = System.getProperty(SYSPROP_TEST_RESOURCES_DIRECTORY, "target/test-classes");
+ testArchiveDir = System.getProperty(SYSPROP_TEST_ARCHIVE_DIRECTORY, "target/test-libs");
+ }
+
+ /** Try to discover the URL for the test resource */
+ public URL getResourceURL(String resource)
+ {
+ URL resURL = null;
+ try
+ {
+ File resourceFile = getResourceFile(resource);
+ resURL = resourceFile.toURI().toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ // ignore
+ }
+ return resURL;
+ }
+
+ /** Try to discover the File for the test resource */
+ public File getResourceFile(String resource)
+ {
+ File file = new File(resource);
+ if (file.exists())
+ return file;
+
+ file = new File(testResourcesDir + "/" + resource);
+ if (file.exists())
+ return file;
+
+ throw new IllegalArgumentException("Cannot obtain '" + testResourcesDir + "/" + resource + "'");
+ }
+
+ /** Try to discover the URL for the deployment archive */
+ public URL getTestArchiveURL(String archive)
+ {
+ try
+ {
+ return getTestArchiveFile(archive).toURI().toURL();
+ }
+ catch (MalformedURLException ex)
+ {
+ throw new IllegalStateException(ex);
+ }
+ }
+
+ /** Try to discover the absolute path for the deployment archive */
+ public String getTestArchivePath(String archive)
+ {
+ return getTestArchiveFile(archive).getAbsolutePath();
+ }
+
+ /** Try to discover the File for the deployment archive */
+ public File getTestArchiveFile(String archive)
+ {
+ File file = new File(archive);
+ if (file.exists())
+ return file;
+
+ file = new File(testArchiveDir + "/" + archive);
+ if (file.exists())
+ return file;
+
+ throw new IllegalArgumentException("Cannot obtain '" + testArchiveDir + "/" + archive + "'.");
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public InitialContext getInitialContext() throws NamingException
+ {
+ String port = System.getProperty("jndi.server.port", "1099");
+ Integer jndiPort = new Integer(port);
+
+ Hashtable env = new Hashtable();
+ env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
+ env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
+ env.put("java.naming.provider.url", "jnp://" + getServerHost() + ":" + jndiPort);
+ return new InitialContext(env);
+ }
+
+ public String getServerHost()
+ {
+ String bindAddress = System.getProperty("jboss.bind.address", "localhost");
+ return bindAddress;
+ }
+
+ public String getTargetContainer()
+ {
+ String targetContainer = System.getProperty("target.container");
+ return targetContainer;
+ }
+
+ public String getFrameworkName()
+ {
+ String framework = System.getProperty("framework");
+ if (framework == null || framework.length() == 0 || framework.equals("${framework}"))
+ framework = "jbossmc";
+
+ return framework;
+ }
+
+ public VirtualFile assembleArchive(String name, String resource, Class<?>... packages) throws Exception
+ {
+ return assembleArchive(name, new String[] { resource }, packages);
+ }
+
+ public VirtualFile assembleArchive(String name, String[] resources, Class<?>... packages) throws IOException
+ {
+ JavaArchive archive = Archives.create(name + ".jar", JavaArchive.class);
+ if (resources != null)
+ {
+ for (String res : resources)
+ {
+ URL url = getClass().getResource(res);
+ if (url == null)
+ throw new IllegalArgumentException("Cannot load resource: " + res);
+
+ final VirtualFile file = AbstractVFS.getRoot(url);
+ if (file.isDirectory())
+ {
+ addResources(archive, file, file);
+ }
+ else
+ {
+ addResource(archive, res, file);
+ }
+ }
+ }
+ if (packages != null)
+ {
+ for (Class<?> clazz : packages)
+ {
+ URL url = clazz.getResource("/");
+ VirtualFile base = AbstractVFS.getRoot(url);
+
+ String path = clazz.getName().replace('.', '/');
+ path = path.substring(0, path.lastIndexOf("/"));
+
+ VirtualFile classes = base.getChild(path);
+ addResources(archive, base, classes);
+ }
+ }
+
+ // Convert archive to file URL
+ ZipExporter exporter = archive.as(ZipExporter.class);
+ File target = File.createTempFile("archive_", ".jar");
+ exporter.exportZip(target, true);
+ target.deleteOnExit();
+
+ return AbstractVFS.getRoot(target.toURI().toURL());
+ }
+
+ private void addResources(JavaArchive archive, VirtualFile basedir, VirtualFile resdir) throws IOException
+ {
+ String basepath = basedir.getPathName();
+ for (final VirtualFile child : resdir.getChildrenRecursively())
+ {
+ if (child.isDirectory())
+ continue;
+
+ String path = child.getPathName();
+ path = path.substring(basepath.length());
+
+ addResource(archive, path, child);
+ }
+ }
+
+ private void addResource(JavaArchive archive, String path, final VirtualFile file)
+ {
+ Asset asset = new Asset()
+ {
+ public InputStream openStream()
+ {
+ try
+ {
+ return file.openStream();
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot open stream for: " + file, ex);
+ }
+ }
+ };
+ archive.add(asset, path);
+ }
+
+ public void assertBundleState(int expState, int wasState)
+ {
+ String expstr = ConstantsHelper.bundleState(expState);
+ String wasstr = ConstantsHelper.bundleState(wasState);
+ assertEquals("Bundle " + expstr, expstr, wasstr);
+ }
+
+ public Class<?> assertLoadClass(Bundle bundle, String className)
+ {
+ try
+ {
+ return bundle.loadClass(className);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ String message = bundle.getSymbolicName() + " loads " + className;
+ fail("Unexpected ClassNotFoundException for: " + message);
+ return null;
+ }
+ }
+
+ public void assertLoadClassFail(Bundle bundle, String className)
+ {
+ try
+ {
+ Class<?> clazz = bundle.loadClass(className);
+ String message = bundle.getSymbolicName() + " loads " + className;
+ fail("ClassNotFoundException expected for: " + message + "\nLoaded from " + clazz.getClassLoader());
+ }
+ catch (ClassNotFoundException ex)
+ {
+ // expected
+ }
+ }
+}
Deleted: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java 2010-03-09 19:47:32 UTC (rev 102159)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java 2010-03-16 23:44:55 UTC (rev 102491)
@@ -1,204 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.testing.internal;
-
-// $Id$
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerFactory;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.spi.capability.Capability;
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
-import org.jboss.osgi.spi.util.BundleInfo;
-import org.jboss.osgi.testing.OSGiBundle;
-import org.jboss.osgi.testing.OSGiRuntime;
-import org.jboss.osgi.testing.OSGiServiceReference;
-import org.jboss.osgi.testing.OSGiTestHelper;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.launch.Framework;
-
-/**
- * An embedded implementation of the {@link OSGiRuntime}
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 25-Sep-2008
- */
-public class EmbeddedRuntime extends OSGiRuntimeImpl
-{
- // Provide logging
- private static final Logger log = Logger.getLogger(EmbeddedRuntime.class);
-
- private MBeanServer server;
-
- public EmbeddedRuntime(OSGiTestHelper helper)
- {
- super(helper);
- }
-
- OSGiBundle installBundle(BundleInfo info) throws BundleException
- {
- BundleContext context = getSystemContext();
- String location = fixVirtualFileURL(info.getRootURL()).toExternalForm();
- Bundle auxBundle = context.installBundle(location);
- OSGiBundle bundle = new EmbeddedBundle(this, auxBundle);
- return registerBundle(bundle.getLocation(), bundle);
- }
-
- public OSGiBundle[] getBundles()
- {
- List<OSGiBundle> absBundles = new ArrayList<OSGiBundle>();
- for (Bundle bundle : getSystemContext().getBundles())
- {
- absBundles.add(new EmbeddedBundle(this, bundle));
- }
- OSGiBundle[] bundleArr = new OSGiBundle[absBundles.size()];
- absBundles.toArray(bundleArr);
- return bundleArr;
- }
-
- public OSGiBundle getBundle(long bundleId)
- {
- Bundle bundle = getSystemContext().getBundle(bundleId);
- return bundle != null ? new EmbeddedBundle(this, bundle) : null;
- }
-
- public OSGiServiceReference getServiceReference(String clazz)
- {
- ServiceReference sref = getSystemContext().getServiceReference(clazz);
- return (sref != null ? new EmbeddedServiceReference(sref) : null);
- }
-
- public OSGiServiceReference[] getServiceReferences(String clazz, String filter)
- {
- OSGiServiceReference[] retRefs = null;
-
- ServiceReference[] srefs;
- try
- {
- srefs = getSystemContext().getServiceReferences(clazz, filter);
- }
- catch (InvalidSyntaxException e)
- {
- throw new IllegalArgumentException("Invalid filter syntax: " + filter);
- }
-
- if (srefs != null)
- {
- retRefs = new OSGiServiceReference[srefs.length];
- for (int i = 0; i < srefs.length; i++)
- retRefs[i] = new EmbeddedServiceReference(srefs[i]);
- }
- return retRefs;
- }
-
- @Override
- public void addCapability(Capability capability) throws BundleException
- {
- // Copy the properties to the System props
- Map<String, String> props = capability.getSystemProperties();
- for (Entry<String, String> entry : props.entrySet())
- {
- String value = System.getProperty(entry.getKey());
- if (value == null)
- System.setProperty(entry.getKey(), entry.getValue());
- }
-
- super.addCapability(capability);
- }
-
- @Override
- public void shutdown()
- {
- OSGiBootstrapProvider bootProvider = getTestHelper().getBootstrapProvider();
- if (bootProvider != null)
- {
- super.shutdown();
- try
- {
- Framework framework = bootProvider.getFramework();
- log.debug("Framework stop: " + framework);
- framework.stop();
- framework.waitForStop(5000);
- }
- catch (Exception ex)
- {
- log.error("Cannot stop the framework", ex);
- }
- finally
- {
- getTestHelper().ungetBootstrapProvider();
- }
- }
- }
-
- public MBeanServerConnection getMBeanServer()
- {
- if (server == null)
- {
- ArrayList<MBeanServer> serverArr = MBeanServerFactory.findMBeanServer(null);
- if (serverArr.size() > 1)
- throw new IllegalStateException("Multiple MBeanServer instances not supported");
-
- if (serverArr.size() == 1)
- server = serverArr.get(0);
-
- if (server == null)
- server = MBeanServerFactory.createMBeanServer();
- }
- return server;
- }
-
- public boolean isRemoteRuntime()
- {
- return false;
- }
-
- BundleContext getSystemContext()
- {
- OSGiBootstrapProvider bootProvider = getTestHelper().getBootstrapProvider();
- Framework framework = bootProvider.getFramework();
- if (framework.getState() != Bundle.ACTIVE)
- {
- try
- {
- log.debug("Framework start: " + framework);
- framework.start();
- }
- catch (BundleException ex)
- {
- throw new IllegalStateException("Cannot start framework", ex);
- }
- }
- return framework.getBundleContext();
- }
-}
Copied: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java (from rev 102342, projects/jboss-osgi/projects/testing/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 (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java 2010-03-16 23:44:55 UTC (rev 102491)
@@ -0,0 +1,213 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing.internal;
+
+// $Id$
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerConnection;
+import javax.management.MBeanServerFactory;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.spi.capability.Capability;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiRuntimeHelper;
+import org.jboss.osgi.testing.OSGiServiceReference;
+import org.jboss.osgi.vfs.VirtualFile;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * An embedded implementation of the {@link OSGiRuntime}
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 25-Sep-2008
+ */
+public class EmbeddedRuntime extends OSGiRuntimeImpl
+{
+ // Provide logging
+ private static final Logger log = Logger.getLogger(EmbeddedRuntime.class);
+
+ private MBeanServer server;
+
+ public EmbeddedRuntime(OSGiRuntimeHelper helper)
+ {
+ super(helper);
+ }
+
+ OSGiBundle installBundle(BundleInfo info) throws BundleException
+ {
+ try
+ {
+ VirtualFile rootFile = info.getRoot();
+ BundleContext context = getSystemContext();
+ Bundle auxBundle = context.installBundle(info.getLocation(), rootFile.openStream());
+ OSGiBundle bundle = new EmbeddedBundle(this, auxBundle);
+ return registerBundle(bundle.getLocation(), bundle);
+ }
+ catch (IOException ex)
+ {
+ throw new BundleException("Cannot install bundle: " + info, ex);
+ }
+ }
+
+ public OSGiBundle[] getBundles()
+ {
+ List<OSGiBundle> absBundles = new ArrayList<OSGiBundle>();
+ for (Bundle bundle : getSystemContext().getBundles())
+ {
+ absBundles.add(new EmbeddedBundle(this, bundle));
+ }
+ OSGiBundle[] bundleArr = new OSGiBundle[absBundles.size()];
+ absBundles.toArray(bundleArr);
+ return bundleArr;
+ }
+
+ public OSGiBundle getBundle(long bundleId)
+ {
+ Bundle bundle = getSystemContext().getBundle(bundleId);
+ return bundle != null ? new EmbeddedBundle(this, bundle) : null;
+ }
+
+ public OSGiServiceReference getServiceReference(String clazz)
+ {
+ ServiceReference sref = getSystemContext().getServiceReference(clazz);
+ return (sref != null ? new EmbeddedServiceReference(sref) : null);
+ }
+
+ public OSGiServiceReference[] getServiceReferences(String clazz, String filter)
+ {
+ OSGiServiceReference[] retRefs = null;
+
+ ServiceReference[] srefs;
+ try
+ {
+ srefs = getSystemContext().getServiceReferences(clazz, filter);
+ }
+ catch (InvalidSyntaxException e)
+ {
+ throw new IllegalArgumentException("Invalid filter syntax: " + filter);
+ }
+
+ if (srefs != null)
+ {
+ retRefs = new OSGiServiceReference[srefs.length];
+ for (int i = 0; i < srefs.length; i++)
+ retRefs[i] = new EmbeddedServiceReference(srefs[i]);
+ }
+ return retRefs;
+ }
+
+ @Override
+ public void addCapability(Capability capability) throws BundleException
+ {
+ // Copy the properties to the System props
+ Map<String, String> props = capability.getSystemProperties();
+ for (Entry<String, String> entry : props.entrySet())
+ {
+ String value = System.getProperty(entry.getKey());
+ if (value == null)
+ System.setProperty(entry.getKey(), entry.getValue());
+ }
+
+ super.addCapability(capability);
+ }
+
+ @Override
+ public void shutdown()
+ {
+ OSGiBootstrapProvider bootProvider = getTestHelper().getBootstrapProvider();
+ if (bootProvider != null)
+ {
+ super.shutdown();
+ try
+ {
+ Framework framework = bootProvider.getFramework();
+ log.debug("Framework stop: " + framework);
+ framework.stop();
+ framework.waitForStop(5000);
+ }
+ catch (Exception ex)
+ {
+ log.error("Cannot stop the framework", ex);
+ }
+ finally
+ {
+ getTestHelper().ungetBootstrapProvider();
+ }
+ }
+ }
+
+ public MBeanServerConnection getMBeanServer()
+ {
+ if (server == null)
+ {
+ ArrayList<MBeanServer> serverArr = MBeanServerFactory.findMBeanServer(null);
+ if (serverArr.size() > 1)
+ throw new IllegalStateException("Multiple MBeanServer instances not supported");
+
+ if (serverArr.size() == 1)
+ server = serverArr.get(0);
+
+ if (server == null)
+ server = MBeanServerFactory.createMBeanServer();
+ }
+ return server;
+ }
+
+ public boolean isRemoteRuntime()
+ {
+ return false;
+ }
+
+ BundleContext getSystemContext()
+ {
+ OSGiBootstrapProvider bootProvider = getTestHelper().getBootstrapProvider();
+ Framework framework = bootProvider.getFramework();
+ if (framework.getState() != Bundle.ACTIVE)
+ {
+ try
+ {
+ log.debug("Framework start: " + framework);
+ framework.start();
+ }
+ catch (BundleException ex)
+ {
+ throw new IllegalStateException("Cannot start framework", ex);
+ }
+ }
+ return framework.getBundleContext();
+ }
+}
Deleted: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java 2010-03-09 19:47:32 UTC (rev 102159)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java 2010-03-16 23:44:55 UTC (rev 102491)
@@ -1,449 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.testing.internal;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-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;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.jmx.BundleStateMBeanExt;
-import org.jboss.osgi.jmx.FrameworkMBeanExt;
-import org.jboss.osgi.jmx.MBeanProxy;
-import org.jboss.osgi.jmx.ObjectNameFactory;
-import org.jboss.osgi.jmx.PackageStateMBeanExt;
-import org.jboss.osgi.jmx.ServiceStateMBeanExt;
-import org.jboss.osgi.spi.capability.Capability;
-import org.jboss.osgi.spi.util.BundleInfo;
-import org.jboss.osgi.testing.OSGiBundle;
-import org.jboss.osgi.testing.OSGiRuntime;
-import org.jboss.osgi.testing.OSGiServiceReference;
-import org.jboss.osgi.testing.OSGiTestHelper;
-import org.jboss.osgi.vfs.AbstractVFS;
-import org.jboss.osgi.vfs.VirtualFile;
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.exporter.ZipExporter;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Version;
-import org.osgi.jmx.framework.BundleStateMBean;
-import org.osgi.jmx.framework.FrameworkMBean;
-import org.osgi.jmx.framework.PackageStateMBean;
-import org.osgi.jmx.framework.ServiceStateMBean;
-
-/**
- * An abstract implementation of the {@link OSGiRuntime}
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 25-Sep-2008
- */
-public abstract class OSGiRuntimeImpl implements OSGiRuntime
-{
- // Provide logging
- private static final Logger log = Logger.getLogger(OSGiRuntimeImpl.class);
-
- private OSGiTestHelper helper;
- private Map<String, OSGiBundle> bundles = new LinkedHashMap<String, OSGiBundle>();
- private List<Capability> capabilities = new ArrayList<Capability>();
-
- private FrameworkMBean frameworkState;
- private BundleStateMBean bundleState;
- private ServiceStateMBean serviceState;
- private PackageStateMBean packageState;
-
- public OSGiRuntimeImpl(OSGiTestHelper helper)
- {
- this.helper = helper;
- }
-
- public OSGiTestHelper getTestHelper()
- {
- return helper;
- }
-
- public void addCapability(Capability capability) throws BundleException
- {
- // Add dependent capabilies
- for (Capability dependency : capability.getDependencies())
- addCapability(dependency);
-
- OSGiServiceReference[] srefs = null;
-
- // Check if the service provided by the capability exists already
- String serviceName = capability.getServiceName();
- if (serviceName != null)
- srefs = getServiceReferences(serviceName, capability.getFilter());
-
- if (srefs == null || srefs.length == 0)
- {
- log.debug("Add capability: " + capability);
-
- // Install the capability bundles
- List<OSGiBundle> installed = new ArrayList<OSGiBundle>();
- for (BundleInfo info : capability.getBundles())
- {
- String location = info.getLocation();
- String symName = info.getSymbolicName();
- Version version = info.getVersion();
- if (bundles.get(location) == null && getBundle(symName, version) == null)
- {
- OSGiBundle bundle = installBundle(location);
- installed.add(bundle);
- }
- else
- {
- log.debug("Skip bundle: " + location);
- }
- }
-
- // Start the capability bundles
- for (OSGiBundle bundle : installed)
- {
- bundle.start();
- }
- capabilities.add(capability);
- }
- else
- {
- log.debug("Skip capability: " + capability);
- }
- }
-
- public void removeCapability(Capability capability)
- {
- if (capabilities.remove(capability))
- {
- log.debug("Remove capability : " + capability);
-
- List<BundleInfo> bundleInfos = new ArrayList<BundleInfo>(capability.getBundles());
- Collections.reverse(bundleInfos);
-
- for (BundleInfo info : bundleInfos)
- failsafeUninstall(bundles.remove(info.getLocation()));
- }
-
- List<Capability> dependencies = new ArrayList<Capability>(capability.getDependencies());
- Collections.reverse(dependencies);
-
- // Remove dependent capabilities
- for (Capability dependency : dependencies)
- removeCapability(dependency);
- }
-
- public OSGiBundle installBundle(String location) throws BundleException
- {
- BundleInfo info = BundleInfo.createBundleInfo(location);
- return installBundle(info);
- }
-
- public OSGiBundle installBundle(Archive<?> archive) throws BundleException, IOException
- {
- VirtualFile file = toVirtualFile(archive);
- return installBundle(file);
- }
-
- public OSGiBundle installBundle(VirtualFile virtualFile) throws BundleException
- {
- BundleInfo info = BundleInfo.createBundleInfo(virtualFile);
- return installBundle(info);
- }
-
- abstract OSGiBundle installBundle(BundleInfo info) throws BundleException;
-
- // [JBVFS-147] Cannot read from vfs: protocol URL
- URL fixVirtualFileURL(URL url)
- {
- if (url.getProtocol().equals("vfs"))
- {
- File file = new File(url.getPath());
- if (file.exists())
- {
- try
- {
- url = file.toURI().toURL();
- }
- catch (MalformedURLException e)
- {
- // ignore
- }
- }
- }
- return url;
- }
-
- public void shutdown()
- {
- log.debug("Start Shutdown");
-
- // Uninstall the registered bundles
- ArrayList<String> locations = new ArrayList<String>(bundles.keySet());
- Collections.reverse(locations);
-
- while (locations.size() > 0)
- {
- String location = locations.remove(0);
- failsafeUninstall(bundles.remove(location));
- }
-
- // Uninstall the capabilities
- Collections.reverse(capabilities);
- while (capabilities.size() > 0)
- {
- Capability capability = capabilities.get(0);
- removeCapability(capability);
- }
-
- log.debug("End Shutdown");
- }
-
- public FrameworkMBean getFrameworkMBean() throws IOException
- {
- if (frameworkState == null)
- {
- ObjectName objectName = ObjectNameFactory.create(FrameworkMBeanExt.OBJECTNAME);
- MBeanServerConnection server = getMBeanServer();
- if (server.isRegistered(objectName))
- {
- frameworkState = MBeanProxy.get(server, objectName, FrameworkMBeanExt.class);
- }
- else
- {
- objectName = ObjectNameFactory.create(FrameworkMBean.OBJECTNAME);
- frameworkState = MBeanProxy.get(server, objectName, FrameworkMBean.class);
- }
- }
- return frameworkState;
- }
-
- public BundleStateMBean getBundleStateMBean() throws IOException
- {
- if (bundleState == null)
- {
- MBeanServerConnection server = getMBeanServer();
- ObjectName objectName = ObjectNameFactory.create(BundleStateMBeanExt.OBJECTNAME);
- if (server.isRegistered(objectName))
- {
- bundleState = MBeanProxy.get(server, objectName, BundleStateMBeanExt.class);
- }
- else
- {
- objectName = ObjectNameFactory.create(BundleStateMBean.OBJECTNAME);
- bundleState = MBeanProxy.get(server, objectName, BundleStateMBean.class);
- }
- }
- return bundleState;
- }
-
- public PackageStateMBean getPackageStateMBean() throws IOException
- {
- if (packageState == null)
- {
- MBeanServerConnection server = getMBeanServer();
- ObjectName objectName = ObjectNameFactory.create(PackageStateMBeanExt.OBJECTNAME);
- if (server.isRegistered(objectName))
- {
- packageState = MBeanProxy.get(server, objectName, PackageStateMBeanExt.class);
- }
- else
- {
- objectName = ObjectNameFactory.create(PackageStateMBean.OBJECTNAME);
- packageState = MBeanProxy.get(server, objectName, PackageStateMBean.class);
- }
- }
- return packageState;
- }
-
- public ServiceStateMBean getServiceStateMBean() throws IOException
- {
- if (serviceState == null)
- {
- MBeanServerConnection server = getMBeanServer();
- ObjectName objectName = ObjectNameFactory.create(ServiceStateMBeanExt.OBJECTNAME);
- if (server.isRegistered(objectName))
- {
- serviceState = MBeanProxy.get(server, objectName, ServiceStateMBeanExt.class);
- }
- else
- {
- objectName = ObjectNameFactory.create(ServiceStateMBean.OBJECTNAME);
- serviceState = MBeanProxy.get(server, objectName, ServiceStateMBean.class);
- }
- }
- return serviceState;
- }
-
- public InitialContext getInitialContext() throws NamingException
- {
- return helper.getInitialContext();
- }
-
- public String getServerHost()
- {
- return helper.getServerHost();
- }
-
- public OSGiBundle getBundle(String symbolicName, Version version)
- {
- OSGiBundle bundle = getBundle(symbolicName, version, false);
- return bundle;
- }
-
- public OSGiServiceReference getServiceReference(String clazz, long timeout)
- {
- int fraktion = 200;
- timeout = timeout / fraktion;
- OSGiServiceReference sref = getServiceReference(clazz);
- while (sref == null && 0 < timeout--)
- {
- try
- {
- Thread.sleep(fraktion);
- }
- catch (InterruptedException e)
- {
- // ignore
- }
- sref = getServiceReference(clazz);
- }
- return sref;
- }
-
- OSGiBundle getBundle(String symbolicName, Version version, boolean mustExist)
- {
- OSGiBundle bundle = null;
- List<OSGiBundle> bundles = Arrays.asList(getBundles());
- for (OSGiBundle aux : bundles)
- {
- if (aux.getSymbolicName().equals(symbolicName))
- {
- if (version == null || version.equals(aux.getVersion()))
- {
- bundle = aux;
- break;
- }
- }
- }
-
- if (bundle == null && mustExist == true)
- throw new IllegalStateException("Cannot obtain bundle: " + symbolicName + "-" + version + ". We have " + bundles);
-
- 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)
- throw new IllegalArgumentException("Cannot register null bundle for: " + location);
-
- bundles.put(location, bundle);
- return bundle;
- }
-
- void unregisterBundle(OSGiBundle bundle)
- {
- if (bundle == null)
- throw new IllegalArgumentException("Cannot unregister null bundle");
-
- if (bundles.containsValue(bundle))
- {
- Set<Entry<String, OSGiBundle>> entrySet = bundles.entrySet();
- for (Entry<String, OSGiBundle> entry : entrySet)
- {
- if (bundle.equals(entry.getValue()))
- {
- String key = entry.getKey();
- bundles.remove(key);
- break;
- }
- }
- }
- }
-
- VirtualFile toVirtualFile(Archive<?> archive) throws IOException, MalformedURLException
- {
- ZipExporter exporter = archive.as(ZipExporter.class);
- File target = File.createTempFile("archive_", ".jar");
- exporter.exportZip(target, true);
- target.deleteOnExit();
-
- return AbstractVFS.getChild(target.toURI().toURL());
- }
-
- private void failsafeUninstall(OSGiBundle bundle)
- {
- if (bundle != null)
- {
- try
- {
- if (bundle.getState() != Bundle.UNINSTALLED)
- bundle.uninstall();
- }
- catch (Exception ex)
- {
- log.warn("Cannot uninstall bundle: " + bundle, ex);
- }
- }
- }
-}
Copied: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java (from rev 102467, projects/jboss-osgi/projects/testing/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 (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java 2010-03-16 23:44:55 UTC (rev 102491)
@@ -0,0 +1,451 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing.internal;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+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;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jmx.BundleStateMBeanExt;
+import org.jboss.osgi.jmx.FrameworkMBeanExt;
+import org.jboss.osgi.jmx.MBeanProxy;
+import org.jboss.osgi.jmx.ObjectNameFactory;
+import org.jboss.osgi.jmx.PackageStateMBeanExt;
+import org.jboss.osgi.jmx.ServiceStateMBeanExt;
+import org.jboss.osgi.spi.capability.Capability;
+import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiRuntimeHelper;
+import org.jboss.osgi.testing.OSGiServiceReference;
+import org.jboss.osgi.vfs.AbstractVFS;
+import org.jboss.osgi.vfs.VirtualFile;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.exporter.ZipExporter;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Version;
+import org.osgi.jmx.framework.BundleStateMBean;
+import org.osgi.jmx.framework.FrameworkMBean;
+import org.osgi.jmx.framework.PackageStateMBean;
+import org.osgi.jmx.framework.ServiceStateMBean;
+
+/**
+ * An abstract implementation of the {@link OSGiRuntime}
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 25-Sep-2008
+ */
+public abstract class OSGiRuntimeImpl implements OSGiRuntime
+{
+ // Provide logging
+ private static final Logger log = Logger.getLogger(OSGiRuntimeImpl.class);
+
+ private OSGiRuntimeHelper helper;
+ private Map<String, OSGiBundle> bundles = new LinkedHashMap<String, OSGiBundle>();
+ private List<Capability> capabilities = new ArrayList<Capability>();
+
+ private FrameworkMBean frameworkState;
+ private BundleStateMBean bundleState;
+ private ServiceStateMBean serviceState;
+ private PackageStateMBean packageState;
+
+ public OSGiRuntimeImpl(OSGiRuntimeHelper helper)
+ {
+ this.helper = helper;
+ }
+
+ public OSGiRuntimeHelper getTestHelper()
+ {
+ return helper;
+ }
+
+ public void addCapability(Capability capability) throws BundleException
+ {
+ // Add dependent capabilies
+ for (Capability dependency : capability.getDependencies())
+ addCapability(dependency);
+
+ OSGiServiceReference[] srefs = null;
+
+ // Check if the service provided by the capability exists already
+ String serviceName = capability.getServiceName();
+ if (serviceName != null)
+ srefs = getServiceReferences(serviceName, capability.getFilter());
+
+ if (srefs == null || srefs.length == 0)
+ {
+ log.debug("Add capability: " + capability);
+
+ // Install the capability bundles
+ List<OSGiBundle> installed = new ArrayList<OSGiBundle>();
+ for (BundleInfo info : capability.getBundles())
+ {
+ String location = info.getLocation();
+ String symName = info.getSymbolicName();
+ Version version = info.getVersion();
+ if (bundles.get(location) == null && getBundle(symName, version) == null)
+ {
+ OSGiBundle bundle = installBundle(location);
+ installed.add(bundle);
+ }
+ else
+ {
+ log.debug("Skip bundle: " + location);
+ }
+ }
+
+ // Start the capability bundles
+ for (OSGiBundle bundle : installed)
+ {
+ bundle.start();
+ }
+ capabilities.add(capability);
+ }
+ else
+ {
+ log.debug("Skip capability: " + capability);
+ }
+ }
+
+ public void removeCapability(Capability capability)
+ {
+ if (capabilities.remove(capability))
+ {
+ log.debug("Remove capability : " + capability);
+
+ List<BundleInfo> bundleInfos = new ArrayList<BundleInfo>(capability.getBundles());
+ Collections.reverse(bundleInfos);
+
+ for (BundleInfo info : bundleInfos)
+ {
+ OSGiBundle bundle = bundles.get(info.getLocation());
+ failsafeStop(bundle);
+ }
+
+ for (BundleInfo info : bundleInfos)
+ {
+ OSGiBundle bundle = bundles.remove(info.getLocation());
+ failsafeUninstall(bundle);
+ }
+ }
+
+ List<Capability> dependencies = new ArrayList<Capability>(capability.getDependencies());
+ Collections.reverse(dependencies);
+
+ // Remove dependent capabilities
+ for (Capability dependency : dependencies)
+ removeCapability(dependency);
+ }
+
+ public OSGiBundle installBundle(String location) throws BundleException
+ {
+ BundleInfo info = BundleInfo.createBundleInfo(location);
+ return installBundle(info);
+ }
+
+ public OSGiBundle installBundle(Archive<?> archive) throws BundleException, IOException
+ {
+ VirtualFile file = toVirtualFile(archive);
+ return installBundle(file);
+ }
+
+ public OSGiBundle installBundle(VirtualFile virtualFile) throws BundleException
+ {
+ BundleInfo info = BundleInfo.createBundleInfo(virtualFile);
+ return installBundle(info);
+ }
+
+ abstract OSGiBundle installBundle(BundleInfo info) throws BundleException;
+
+ public void shutdown()
+ {
+ log.debug("Start Shutdown");
+
+ // Uninstall the registered bundles
+ ArrayList<String> locations = new ArrayList<String>(bundles.keySet());
+ Collections.reverse(locations);
+
+ while (locations.size() > 0)
+ {
+ String location = locations.remove(0);
+ failsafeUninstall(bundles.remove(location));
+ }
+
+ // Uninstall the capabilities
+ Collections.reverse(capabilities);
+ while (capabilities.size() > 0)
+ {
+ Capability capability = capabilities.get(0);
+ removeCapability(capability);
+ }
+
+ log.debug("End Shutdown");
+ }
+
+ public FrameworkMBean getFrameworkMBean() throws IOException
+ {
+ if (frameworkState == null)
+ {
+ ObjectName objectName = ObjectNameFactory.create(FrameworkMBeanExt.OBJECTNAME);
+ MBeanServerConnection server = getMBeanServer();
+ if (server.isRegistered(objectName))
+ {
+ frameworkState = MBeanProxy.get(server, objectName, FrameworkMBeanExt.class);
+ }
+ else
+ {
+ objectName = ObjectNameFactory.create(FrameworkMBean.OBJECTNAME);
+ frameworkState = MBeanProxy.get(server, objectName, FrameworkMBean.class);
+ }
+ }
+ return frameworkState;
+ }
+
+ public BundleStateMBean getBundleStateMBean() throws IOException
+ {
+ if (bundleState == null)
+ {
+ MBeanServerConnection server = getMBeanServer();
+ ObjectName objectName = ObjectNameFactory.create(BundleStateMBeanExt.OBJECTNAME);
+ if (server.isRegistered(objectName))
+ {
+ bundleState = MBeanProxy.get(server, objectName, BundleStateMBeanExt.class);
+ }
+ else
+ {
+ objectName = ObjectNameFactory.create(BundleStateMBean.OBJECTNAME);
+ bundleState = MBeanProxy.get(server, objectName, BundleStateMBean.class);
+ }
+ }
+ return bundleState;
+ }
+
+ public PackageStateMBean getPackageStateMBean() throws IOException
+ {
+ if (packageState == null)
+ {
+ MBeanServerConnection server = getMBeanServer();
+ ObjectName objectName = ObjectNameFactory.create(PackageStateMBeanExt.OBJECTNAME);
+ if (server.isRegistered(objectName))
+ {
+ packageState = MBeanProxy.get(server, objectName, PackageStateMBeanExt.class);
+ }
+ else
+ {
+ objectName = ObjectNameFactory.create(PackageStateMBean.OBJECTNAME);
+ packageState = MBeanProxy.get(server, objectName, PackageStateMBean.class);
+ }
+ }
+ return packageState;
+ }
+
+ public ServiceStateMBean getServiceStateMBean() throws IOException
+ {
+ if (serviceState == null)
+ {
+ MBeanServerConnection server = getMBeanServer();
+ ObjectName objectName = ObjectNameFactory.create(ServiceStateMBeanExt.OBJECTNAME);
+ if (server.isRegistered(objectName))
+ {
+ serviceState = MBeanProxy.get(server, objectName, ServiceStateMBeanExt.class);
+ }
+ else
+ {
+ objectName = ObjectNameFactory.create(ServiceStateMBean.OBJECTNAME);
+ serviceState = MBeanProxy.get(server, objectName, ServiceStateMBean.class);
+ }
+ }
+ return serviceState;
+ }
+
+ public InitialContext getInitialContext() throws NamingException
+ {
+ return helper.getInitialContext();
+ }
+
+ public String getServerHost()
+ {
+ return helper.getServerHost();
+ }
+
+ public OSGiBundle getBundle(String symbolicName, Version version)
+ {
+ OSGiBundle bundle = getBundle(symbolicName, version, false);
+ return bundle;
+ }
+
+ public OSGiServiceReference getServiceReference(String clazz, long timeout)
+ {
+ int fraktion = 200;
+ timeout = timeout / fraktion;
+ OSGiServiceReference sref = getServiceReference(clazz);
+ while (sref == null && 0 < timeout--)
+ {
+ try
+ {
+ Thread.sleep(fraktion);
+ }
+ catch (InterruptedException e)
+ {
+ // ignore
+ }
+ sref = getServiceReference(clazz);
+ }
+ return sref;
+ }
+
+ OSGiBundle getBundle(String symbolicName, Version version, boolean mustExist)
+ {
+ OSGiBundle bundle = null;
+ List<OSGiBundle> bundles = Arrays.asList(getBundles());
+ for (OSGiBundle aux : bundles)
+ {
+ if (aux.getSymbolicName().equals(symbolicName))
+ {
+ if (version == null || version.equals(aux.getVersion()))
+ {
+ bundle = aux;
+ break;
+ }
+ }
+ }
+
+ if (bundle == null && mustExist == true)
+ throw new IllegalStateException("Cannot obtain bundle: " + symbolicName + "-" + version + ". We have " + bundles);
+
+ 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)
+ throw new IllegalArgumentException("Cannot register null bundle for: " + location);
+
+ bundles.put(location, bundle);
+ return bundle;
+ }
+
+ void unregisterBundle(OSGiBundle bundle)
+ {
+ if (bundle == null)
+ throw new IllegalArgumentException("Cannot unregister null bundle");
+
+ if (bundles.containsValue(bundle))
+ {
+ Set<Entry<String, OSGiBundle>> entrySet = bundles.entrySet();
+ for (Entry<String, OSGiBundle> entry : entrySet)
+ {
+ if (bundle.equals(entry.getValue()))
+ {
+ String key = entry.getKey();
+ bundles.remove(key);
+ break;
+ }
+ }
+ }
+ }
+
+ VirtualFile toVirtualFile(Archive<?> archive) throws IOException, MalformedURLException
+ {
+ ZipExporter exporter = archive.as(ZipExporter.class);
+ File target = File.createTempFile("archive_", ".jar");
+ exporter.exportZip(target, true);
+ target.deleteOnExit();
+
+ return AbstractVFS.getRoot(target.toURI().toURL());
+ }
+
+ private void failsafeStop(OSGiBundle bundle)
+ {
+ if (bundle != null)
+ {
+ try
+ {
+ bundle.stop();
+ }
+ catch (Exception ex)
+ {
+ log.warn("Cannot stop bundle: " + bundle, ex);
+ }
+ }
+ }
+
+ private void failsafeUninstall(OSGiBundle bundle)
+ {
+ if (bundle != null)
+ {
+ try
+ {
+ if (bundle.getState() != Bundle.UNINSTALLED)
+ bundle.uninstall();
+ }
+ catch (Exception ex)
+ {
+ log.warn("Cannot uninstall bundle: " + bundle, ex);
+ }
+ }
+ }
+}
Deleted: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2010-03-09 19:47:32 UTC (rev 102159)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2010-03-16 23:44:55 UTC (rev 102491)
@@ -1,225 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.testing.internal;
-
-// $Id$
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.TabularData;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.jmx.MBeanProxy;
-import org.jboss.osgi.jmx.ObjectNameFactory;
-import org.jboss.osgi.jmx.ServiceStateMBeanExt;
-import org.jboss.osgi.spi.util.BundleInfo;
-import org.jboss.osgi.testing.OSGiBundle;
-import org.jboss.osgi.testing.OSGiRuntime;
-import org.jboss.osgi.testing.OSGiServiceReference;
-import org.jboss.osgi.testing.OSGiTestHelper;
-import org.osgi.framework.BundleException;
-import org.osgi.jmx.framework.BundleStateMBean;
-import org.osgi.jmx.framework.ServiceStateMBean;
-
-/**
- * A remote implementation of the {@link OSGiRuntime}
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 25-Sep-2008
- */
-public class RemoteRuntime extends OSGiRuntimeImpl
-{
- // Provide logging
- private static final Logger log = Logger.getLogger(RemoteRuntime.class);
-
- private MBeanServerConnection mbeanServer;
-
- public RemoteRuntime(OSGiTestHelper helper)
- {
- super(helper);
- }
-
- OSGiBundle installBundle(BundleInfo info) throws BundleException
- {
- try
- {
- String location = fixVirtualFileURL(info.getRootURL()).toExternalForm();
- long bundleId = getFrameworkMBean().installBundle(location);
- RemoteBundle bundle = new RemoteBundle(this, bundleId);
- return registerBundle(bundle.getLocation(), bundle);
- }
- catch (RuntimeException rte)
- {
- throw rte;
- }
- catch (Exception ex)
- {
- throw new BundleException("Cannot install: " + info, ex);
- }
- }
-
- public void deploy(String location) throws Exception
- {
- URL archiveURL = getTestHelper().getTestArchiveURL(location);
- MainDeployerClient deployer = new MainDeployerClient(this);
- deployer.deploy(archiveURL);
- }
-
- public void undeploy(String location) throws Exception
- {
- URL archiveURL = getTestHelper().getTestArchiveURL(location);
- MainDeployerClient deployer = new MainDeployerClient(this);
- deployer.undeploy(archiveURL);
- }
-
- public OSGiBundle[] getBundles()
- {
- Set<OSGiBundle> bundles = new HashSet<OSGiBundle>();
- try
- {
- TabularData listBundles = getBundleStateMBean().listBundles();
- Iterator<?> iterator = listBundles.values().iterator();
- while (iterator.hasNext())
- {
- CompositeData bundleType = (CompositeData)iterator.next();
- Long bundleId = (Long)bundleType.get(BundleStateMBean.IDENTIFIER);
- try
- {
- bundles.add(new RemoteBundle(this, bundleId));
- }
- catch (IOException ex)
- {
- log.warn("Cannot initialize remote bundle: [" + bundleId + "] - " + ex.getMessage());
- }
- }
- OSGiBundle[] bundleArr = new OSGiBundle[bundles.size()];
- bundles.toArray(bundleArr);
- return bundleArr;
- }
- catch (RuntimeException rte)
- {
- throw rte;
- }
- catch (Exception ex)
- {
- throw new IllegalStateException("Cannot obtain remote bundles", ex);
- }
- }
-
- public OSGiBundle getBundle(long bundleId)
- {
- for (OSGiBundle bundle : getBundles())
- {
- if (bundleId == bundle.getBundleId())
- return bundle;
- }
- return null;
- }
-
- public OSGiServiceReference getServiceReference(String clazz)
- {
- CompositeData serviceData;
- TabularData propertiesData;
- try
- {
- ServiceStateMBeanExt serviceState = getServiceStateMBeanExt();
- serviceData = serviceState.getService(clazz);
- if (serviceData == null)
- return null;
-
- Long serviceId = (Long)serviceData.get(ServiceStateMBean.IDENTIFIER);
- propertiesData = serviceState.getProperties(serviceId);
- }
- catch (IOException ex)
- {
- throw new IllegalStateException(ex);
- }
- return new RemoteServiceReference(serviceData, propertiesData);
- }
-
- @SuppressWarnings("unchecked")
- public OSGiServiceReference[] getServiceReferences(String clazz, String filter)
- {
- TabularData servicesData;
- List<OSGiServiceReference> srefs;
- try
- {
- ServiceStateMBeanExt serviceState = getServiceStateMBeanExt();
- servicesData = serviceState.getServices(clazz, filter);
- if (servicesData == null)
- return null;
-
- srefs = new ArrayList<OSGiServiceReference>();
- for (CompositeData serviceData : (Collection<CompositeData>)servicesData.values())
- {
- Long serviceId = (Long)serviceData.get(ServiceStateMBean.IDENTIFIER);
- TabularData propertiesData = serviceState.getProperties(serviceId);
- srefs.add(new RemoteServiceReference(serviceData, propertiesData));
- }
- }
- catch (IOException ex)
- {
- throw new IllegalStateException(ex);
- }
- return srefs.toArray(new OSGiServiceReference[servicesData.size()]);
- }
-
- private ServiceStateMBeanExt getServiceStateMBeanExt()
- {
- ObjectName objectName = ObjectNameFactory.create(ServiceStateMBeanExt.OBJECTNAME);
- return MBeanProxy.get(getMBeanServer(), objectName, ServiceStateMBeanExt.class);
- }
-
- public MBeanServerConnection getMBeanServer()
- {
- if (mbeanServer == null)
- {
- try
- {
- InitialContext iniCtx = getInitialContext();
- mbeanServer = (MBeanServerConnection)iniCtx.lookup("jmx/invoker/RMIAdaptor");
- }
- catch (NamingException ex)
- {
- throw new IllegalStateException("Cannot obtain MBeanServerConnection", ex);
- }
- }
- return mbeanServer;
- }
-
- public boolean isRemoteRuntime()
- {
- return true;
- }
-}
Copied: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java (from rev 102342, projects/jboss-osgi/projects/testing/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 (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2010-03-16 23:44:55 UTC (rev 102491)
@@ -0,0 +1,226 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing.internal;
+
+// $Id$
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jmx.MBeanProxy;
+import org.jboss.osgi.jmx.ObjectNameFactory;
+import org.jboss.osgi.jmx.ServiceStateMBeanExt;
+import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiServiceReference;
+import org.jboss.osgi.testing.OSGiRuntimeHelper;
+import org.osgi.framework.BundleException;
+import org.osgi.jmx.framework.BundleStateMBean;
+import org.osgi.jmx.framework.ServiceStateMBean;
+
+/**
+ * A remote implementation of the {@link OSGiRuntime}
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 25-Sep-2008
+ */
+public class RemoteRuntime extends OSGiRuntimeImpl
+{
+ // Provide logging
+ private static final Logger log = Logger.getLogger(RemoteRuntime.class);
+
+ private MBeanServerConnection mbeanServer;
+
+ public RemoteRuntime(OSGiRuntimeHelper helper)
+ {
+ super(helper);
+ }
+
+ OSGiBundle installBundle(BundleInfo info) throws BundleException
+ {
+ try
+ {
+ String location = info.getLocation();
+ String streamURL = info.getRoot().getStreamURL().toExternalForm();
+ long bundleId = getFrameworkMBean().installBundle(location, streamURL);
+ RemoteBundle bundle = new RemoteBundle(this, bundleId);
+ return registerBundle(bundle.getLocation(), bundle);
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception ex)
+ {
+ throw new BundleException("Cannot install: " + info, ex);
+ }
+ }
+
+ public void deploy(String location) throws Exception
+ {
+ URL archiveURL = getTestHelper().getTestArchiveURL(location);
+ MainDeployerClient deployer = new MainDeployerClient(this);
+ deployer.deploy(archiveURL);
+ }
+
+ public void undeploy(String location) throws Exception
+ {
+ URL archiveURL = getTestHelper().getTestArchiveURL(location);
+ MainDeployerClient deployer = new MainDeployerClient(this);
+ deployer.undeploy(archiveURL);
+ }
+
+ public OSGiBundle[] getBundles()
+ {
+ Set<OSGiBundle> bundles = new HashSet<OSGiBundle>();
+ try
+ {
+ TabularData listBundles = getBundleStateMBean().listBundles();
+ Iterator<?> iterator = listBundles.values().iterator();
+ while (iterator.hasNext())
+ {
+ CompositeData bundleType = (CompositeData)iterator.next();
+ Long bundleId = (Long)bundleType.get(BundleStateMBean.IDENTIFIER);
+ try
+ {
+ bundles.add(new RemoteBundle(this, bundleId));
+ }
+ catch (IOException ex)
+ {
+ log.warn("Cannot initialize remote bundle: [" + bundleId + "] - " + ex.getMessage());
+ }
+ }
+ OSGiBundle[] bundleArr = new OSGiBundle[bundles.size()];
+ bundles.toArray(bundleArr);
+ return bundleArr;
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Cannot obtain remote bundles", ex);
+ }
+ }
+
+ public OSGiBundle getBundle(long bundleId)
+ {
+ for (OSGiBundle bundle : getBundles())
+ {
+ if (bundleId == bundle.getBundleId())
+ return bundle;
+ }
+ return null;
+ }
+
+ public OSGiServiceReference getServiceReference(String clazz)
+ {
+ CompositeData serviceData;
+ TabularData propertiesData;
+ try
+ {
+ ServiceStateMBeanExt serviceState = getServiceStateMBeanExt();
+ serviceData = serviceState.getService(clazz);
+ if (serviceData == null)
+ return null;
+
+ Long serviceId = (Long)serviceData.get(ServiceStateMBean.IDENTIFIER);
+ propertiesData = serviceState.getProperties(serviceId);
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException(ex);
+ }
+ return new RemoteServiceReference(serviceData, propertiesData);
+ }
+
+ @SuppressWarnings("unchecked")
+ public OSGiServiceReference[] getServiceReferences(String clazz, String filter)
+ {
+ TabularData servicesData;
+ List<OSGiServiceReference> srefs;
+ try
+ {
+ ServiceStateMBeanExt serviceState = getServiceStateMBeanExt();
+ servicesData = serviceState.getServices(clazz, filter);
+ if (servicesData == null)
+ return null;
+
+ srefs = new ArrayList<OSGiServiceReference>();
+ for (CompositeData serviceData : (Collection<CompositeData>)servicesData.values())
+ {
+ Long serviceId = (Long)serviceData.get(ServiceStateMBean.IDENTIFIER);
+ TabularData propertiesData = serviceState.getProperties(serviceId);
+ srefs.add(new RemoteServiceReference(serviceData, propertiesData));
+ }
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException(ex);
+ }
+ return srefs.toArray(new OSGiServiceReference[servicesData.size()]);
+ }
+
+ private ServiceStateMBeanExt getServiceStateMBeanExt()
+ {
+ ObjectName objectName = ObjectNameFactory.create(ServiceStateMBeanExt.OBJECTNAME);
+ return MBeanProxy.get(getMBeanServer(), objectName, ServiceStateMBeanExt.class);
+ }
+
+ public MBeanServerConnection getMBeanServer()
+ {
+ if (mbeanServer == null)
+ {
+ try
+ {
+ InitialContext iniCtx = getInitialContext();
+ mbeanServer = (MBeanServerConnection)iniCtx.lookup("jmx/invoker/RMIAdaptor");
+ }
+ catch (NamingException ex)
+ {
+ throw new IllegalStateException("Cannot obtain MBeanServerConnection", ex);
+ }
+ }
+ return mbeanServer;
+ }
+
+ public boolean isRemoteRuntime()
+ {
+ return true;
+ }
+}
14 years, 3 months
JBoss-OSGI SVN: r102476 - projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/.settings.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-16 14:25:54 -0400 (Tue, 16 Mar 2010)
New Revision: 102476
Modified:
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/.settings/org.eclipse.jdt.core.prefs
Log:
use jdk1.6 compile
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/.settings/org.eclipse.jdt.core.prefs 2010-03-16 18:20:44 UTC (rev 102475)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/.settings/org.eclipse.jdt.core.prefs 2010-03-16 18:25:54 UTC (rev 102476)
@@ -1,4 +1,4 @@
-#Fri Feb 19 13:54:44 CET 2010
+#Tue Mar 16 19:25:11 CET 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
14 years, 3 months
JBoss-OSGI SVN: r102467 - in projects/jboss-osgi: projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal and 2 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-16 12:18:49 -0400 (Tue, 16 Mar 2010)
New Revision: 102467
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/internal/OSGiBootstrapBean.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java
projects/jboss-osgi/trunk/pom.xml
Log:
Update to to vfs30 protocol handlers
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/internal/OSGiBootstrapBean.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/internal/OSGiBootstrapBean.java 2010-03-16 15:34:28 UTC (rev 102466)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/internal/OSGiBootstrapBean.java 2010-03-16 16:18:49 UTC (rev 102467)
@@ -57,6 +57,7 @@
private static Logger log;
private static final String JAVA_PROTOCOL_HANDLERS = "java.protocol.handler.pkgs";
+ private static final String DEFAULT_JAVA_PROTOCOL_HANDLERS = "org.jboss.net.protocol|org.jboss.virtual.protocol|org.jboss.vfs.protocol";
private static final String JBOSS_BIND_ADDRESS = "jboss.bind.address";
private static final String OSGI_SERVER_NAME = "osgi.server.name";
@@ -108,7 +109,7 @@
defaults.setProperty(OSGI_SERVER_NAME, serverName);
defaults.setProperty(OSGI_SERVER_HOME, osgiServerHome);
defaults.setProperty(JBOSS_BIND_ADDRESS, bindAddress);
- defaults.setProperty(JAVA_PROTOCOL_HANDLERS, "org.jboss.net.protocol|org.jboss.virtual.protocol");
+ defaults.setProperty(JAVA_PROTOCOL_HANDLERS, DEFAULT_JAVA_PROTOCOL_HANDLERS);
log.debug("JBoss OSGi System Properties");
log.debug(" " + OSGI_SERVER_HOME + "=" + osgiServerHome);
Modified: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java 2010-03-16 15:34:28 UTC (rev 102466)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java 2010-03-16 16:18:49 UTC (rev 102467)
@@ -154,7 +154,16 @@
Collections.reverse(bundleInfos);
for (BundleInfo info : bundleInfos)
- failsafeUninstall(bundles.remove(info.getLocation()));
+ {
+ OSGiBundle bundle = bundles.get(info.getLocation());
+ failsafeStop(bundle);
+ }
+
+ for (BundleInfo info : bundleInfos)
+ {
+ OSGiBundle bundle = bundles.remove(info.getLocation());
+ failsafeUninstall(bundle);
+ }
}
List<Capability> dependencies = new ArrayList<Capability>(capability.getDependencies());
@@ -409,6 +418,21 @@
return AbstractVFS.getRoot(target.toURI().toURL());
}
+ private void failsafeStop(OSGiBundle bundle)
+ {
+ if (bundle != null)
+ {
+ try
+ {
+ bundle.stop();
+ }
+ catch (Exception ex)
+ {
+ log.warn("Cannot stop bundle: " + bundle, ex);
+ }
+ }
+ }
+
private void failsafeUninstall(OSGiBundle bundle)
{
if (bundle != null)
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java 2010-03-16 15:34:28 UTC (rev 102466)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java 2010-03-16 16:18:49 UTC (rev 102467)
@@ -101,7 +101,7 @@
private boolean acceptForMount(org.jboss.vfs.VirtualFile nativeFile)
{
boolean accept = false;
- if (nativeFile.isFile() == false)
+ if (nativeFile.isFile() == true)
{
String rootName = nativeFile.getName();
for (String suffix : suffixes)
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2010-03-16 15:34:28 UTC (rev 102466)
+++ projects/jboss-osgi/trunk/pom.xml 2010-03-16 16:18:49 UTC (rev 102467)
@@ -461,7 +461,7 @@
</property>
<property>
<name>java.protocol.handler.pkgs</name>
- <value>org.jboss.net.protocol|org.jboss.virtual.protocol</value>
+ <value>org.jboss.vfs.protocol</value>
</property>
<property>
<name>jndi.server.port</name>
14 years, 3 months