JBoss-OSGI SVN: r102034 - in projects/jboss-osgi/projects: vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21 and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-06 14:32:13 -0500 (Sat, 06 Mar 2010)
New Revision: 102034
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java
projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSEntryPathsEnumeration.java
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSEntryPathsEnumeration.java
Log:
Fix getEntries
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java 2010-03-06 17:11:05 UTC (rev 102033)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java 2010-03-06 19:32:13 UTC (rev 102034)
@@ -104,7 +104,6 @@
assertNoEntries(bundle, "", "", false);
assertNoEntries(bundle, "", "", true);
assertEntryPaths("", bundle,
- "/",
"root.xml",
"root-no-suffix",
"entry1.xml",
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSEntryPathsEnumeration.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSEntryPathsEnumeration.java 2010-03-06 17:11:05 UTC (rev 102033)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSEntryPathsEnumeration.java 2010-03-06 19:32:13 UTC (rev 102034)
@@ -54,15 +54,22 @@
throw new IllegalArgumentException("Null root");
if (file == null)
throw new IllegalArgumentException("Null file");
-
+
String rootPath = root.getPathName();
ArrayList<String> paths = new ArrayList<String>();
- paths.add(fixPath(rootPath, file));
+ String fixedPath = fixPath(rootPath, file);
+ if (fixedPath != null)
+ paths.add(fixedPath);
+
List<VirtualFile> children = file.getChildrenRecursively();
for (VirtualFile child : children)
- paths.add(fixPath(rootPath, child));
-
+ {
+ fixedPath = fixPath(rootPath, child);
+ if (fixedPath != null)
+ paths.add(fixedPath);
+ }
+
this.paths = paths.iterator();
}
@@ -76,29 +83,25 @@
return paths.next();
}
- private String fixPath(String rootPath, VirtualFile file)
+ private String fixPath(String rootPath, VirtualFile file) throws IOException
{
- try
- {
- String result = file.getPathName();
-
- int length = rootPath.length();
- if (length != 0)
- result = result.substring(length);
-
- // Returned paths indicating subdirectory paths end with a "/"
- if (file.isLeaf() == false && result.endsWith("/") == false)
- result += "/";
-
- // The returned paths are all relative to the root of this bundle and must not begin with "/".
- if (result.startsWith("/"))
- result = result.substring(1);
-
- return result;
- }
- catch (IOException e)
- {
- throw new RuntimeException("Error fixing path for " + file, e);
- }
+ String result = file.getPathName();
+
+ int length = rootPath.length();
+ if (length != 0)
+ result = result.substring(length);
+
+ // Returned paths indicating subdirectory paths end with a "/"
+ if (file.isLeaf() == false && result.endsWith("/") == false)
+ result += "/";
+
+ // The returned paths are all relative to the root of this bundle and must not begin with "/".
+ if (result.startsWith("/"))
+ result = result.substring(1);
+
+ if (result.isEmpty())
+ return null;
+
+ return result;
}
}
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSEntryPathsEnumeration.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSEntryPathsEnumeration.java 2010-03-06 17:11:05 UTC (rev 102033)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSEntryPathsEnumeration.java 2010-03-06 19:32:13 UTC (rev 102034)
@@ -57,11 +57,18 @@
String rootPath = root.getPathName();
ArrayList<String> paths = new ArrayList<String>();
- paths.add(fixPath(rootPath, file));
+
+ String fixedPath = fixPath(rootPath, file);
+ if (fixedPath != null)
+ paths.add(fixedPath);
List<VirtualFile> children = file.getChildrenRecursively();
for (VirtualFile child : children)
- paths.add(fixPath(rootPath, child));
+ {
+ fixedPath = fixPath(rootPath, child);
+ if (fixedPath != null)
+ paths.add(fixedPath);
+ }
this.paths = paths.iterator();
}
@@ -87,11 +94,14 @@
// Returned paths indicating subdirectory paths end with a "/"
if (file.isDirectory() && result.endsWith("/") == false)
result += "/";
-
+
// The returned paths are all relative to the root of this bundle and must not begin with "/".
if (result.startsWith("/"))
result = result.substring(1);
+ if (result.isEmpty())
+ return null;
+
return result;
}
}
14 years, 4 months
JBoss-OSGI SVN: r101950 - in projects/jboss-osgi: projects/runtime/framework/trunk/bundle/scripts and 2 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-05 07:17:44 -0500 (Fri, 05 Mar 2010)
New Revision: 101950
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-all.xml
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java
projects/jboss-osgi/trunk/testsuite/pom.xml
Log:
Use vfs30 for remote jbossas/trunk testing
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml 2010-03-05 11:56:55 UTC (rev 101949)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml 2010-03-05 12:17:44 UTC (rev 101950)
@@ -39,11 +39,6 @@
<version>${version}</version>
</dependency>
<dependency>
- <groupId>org.jboss.osgi.framework</groupId>
- <artifactId>jboss-osgi-framework-vfs21</artifactId>
- <version>${version}</version>
- </dependency>
- <dependency>
<groupId>biz.aQute</groupId>
<artifactId>bnd</artifactId>
</dependency>
@@ -167,6 +162,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework-vfs21</artifactId>
+ <version>${version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.jboss.osgi.vfs</groupId>
<artifactId>jboss-osgi-vfs21</artifactId>
<scope>test</scope>
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-all.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-all.xml 2010-03-05 11:56:55 UTC (rev 101949)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-all.xml 2010-03-05 12:17:44 UTC (rev 101950)
@@ -39,7 +39,7 @@
<include>*:jboss-osgi-deployers-vfs21:jar</include>
<include>*:jboss-osgi-spi:jar</include>
<include>*:jboss-reflect:jar</include>
- <include>*:jboss-vfs:jar</include>
+ <!-- include>*:jboss-vfs:jar</include -->
<include>*:jbossxb:jar</include>
<include>*:mcann-core:jar</include>
<include>*:org.osgi.core:jar</include>
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java 2010-03-05 11:56:55 UTC (rev 101949)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java 2010-03-05 12:17:44 UTC (rev 101950)
@@ -32,6 +32,7 @@
import java.util.concurrent.atomic.AtomicLong;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentResourceLoader;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.osgi.deployment.deployer.Deployment;
import org.jboss.osgi.framework.deployers.AbstractDeployment;
@@ -75,7 +76,7 @@
public AbstractDeployedBundleState(OSGiBundleManager bundleManager, DeploymentUnit unit)
{
super(bundleManager);
-
+
if (unit == null)
throw new IllegalArgumentException("Null deployment unit");
@@ -168,7 +169,7 @@
checkInstalled();
if (noAdminPermission(AdminPermission.RESOURCE))
return null;
-
+
return getEntryInternal(path);
}
@@ -178,7 +179,7 @@
checkInstalled();
if (noAdminPermission(AdminPermission.RESOURCE))
return null;
-
+
try
{
return rootFile.getEntryPaths(path);
@@ -188,34 +189,30 @@
throw new RuntimeException("Error determining entry paths for " + rootFile + " path=" + path);
}
}
-
+
@Override
protected URL getEntryInternal(String path)
{
- DeploymentUnit unit = getDeploymentUnit();
- if (unit instanceof VFSDeploymentUnit)
- {
- VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit)unit;
+ VFSDeploymentUnit unit = (VFSDeploymentUnit)getDeploymentUnit();
+ if (path.startsWith("/"))
+ path = path.substring(1);
- if (path.startsWith("/"))
- path = path.substring(1);
-
- return vfsDeploymentUnit.getResourceLoader().getResource(path);
- }
- return null;
+ VFSDeploymentResourceLoader loader = unit.getResourceLoader();
+ URL resource = loader.getResource(path);
+ return resource;
}
-
+
public void uninstall() throws BundleException
{
- checkAdminPermission(AdminPermission.LIFECYCLE);
+ checkAdminPermission(AdminPermission.LIFECYCLE);
// If this bundle's state is UNINSTALLED then an IllegalStateException is thrown
if (getState() == Bundle.UNINSTALLED)
throw new IllegalStateException("Bundle already uninstalled: " + this);
-
+
// Cache the headers in the default locale
headersOnUninstall = getHeaders(null);
-
+
getBundleManager().uninstallBundle(this);
}
@@ -224,13 +221,13 @@
{
if (path == null)
throw new IllegalArgumentException("Null path");
-
+
checkInstalled();
if (noAdminPermission(AdminPermission.RESOURCE))
return null;
-
+
resolveBundle();
-
+
try
{
return rootFile.findEntries(path, pattern, recurse);
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2010-03-05 11:56:55 UTC (rev 101949)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2010-03-05 12:17:44 UTC (rev 101950)
@@ -283,10 +283,6 @@
<groupId>org.jboss.osgi.runtime</groupId>
<artifactId>jboss-osgi-equinox</artifactId>
</dependency>
- <dependency>
- <groupId>org.jboss.osgi.vfs</groupId>
- <artifactId>jboss-osgi-vfs21</artifactId>
- </dependency>
</dependencies>
</profile>
@@ -310,10 +306,6 @@
<groupId>org.jboss.osgi.runtime</groupId>
<artifactId>jboss-osgi-felix</artifactId>
</dependency>
- <dependency>
- <groupId>org.jboss.osgi.vfs</groupId>
- <artifactId>jboss-osgi-vfs21</artifactId>
- </dependency>
</dependencies>
</profile>
@@ -340,10 +332,6 @@
<groupId>org.jboss.osgi.framework</groupId>
<artifactId>jboss-osgi-framework</artifactId>
</dependency>
- <dependency>
- <groupId>org.jboss.osgi.vfs</groupId>
- <artifactId>jboss-osgi-vfs21</artifactId>
- </dependency>
</dependencies>
</profile>
<profile>
@@ -364,10 +352,6 @@
<groupId>org.jboss.osgi.framework</groupId>
<artifactId>jboss-osgi-framework</artifactId>
</dependency>
- <dependency>
- <groupId>org.jboss.osgi.vfs</groupId>
- <artifactId>jboss-osgi-vfs21</artifactId>
- </dependency>
</dependencies>
</profile>
@@ -417,6 +401,10 @@
<target.container.excludes>org/jboss/test/osgi/jbossas/**</target.container.excludes>
</properties>
<dependencies>
+ <dependency>
+ <groupId>org.jboss.osgi.vfs</groupId>
+ <artifactId>jboss-osgi-vfs21</artifactId>
+ </dependency>
</dependencies>
</profile>
@@ -442,6 +430,10 @@
<version>${version.jmx.invoker.adaptor.client}</version>
<type>pom</type>
</dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.vfs</groupId>
+ <artifactId>jboss-osgi-vfs21</artifactId>
+ </dependency>
</dependencies>
</profile>
@@ -468,6 +460,10 @@
<scope>test</scope>
<type>pom</type>
</dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.vfs</groupId>
+ <artifactId>jboss-osgi-vfs21</artifactId>
+ </dependency>
</dependencies>
</profile>
@@ -494,6 +490,10 @@
<scope>test</scope>
<type>pom</type>
</dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.vfs</groupId>
+ <artifactId>jboss-osgi-vfs21</artifactId>
+ </dependency>
</dependencies>
</profile>
@@ -526,6 +526,10 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.vfs</groupId>
+ <artifactId>jboss-osgi-vfs21</artifactId>
+ </dependency>
</dependencies>
</profile>
@@ -558,6 +562,10 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.vfs</groupId>
+ <artifactId>jboss-osgi-vfs30</artifactId>
+ </dependency>
</dependencies>
</profile>
14 years, 4 months
JBoss-OSGI SVN: r101943 - in projects/jboss-osgi/projects/vfs/trunk: api and 4 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-05 06:24:13 -0500 (Fri, 05 Mar 2010)
New Revision: 101943
Modified:
projects/jboss-osgi/projects/vfs/trunk/api/pom.xml
projects/jboss-osgi/projects/vfs/trunk/pom.xml
projects/jboss-osgi/projects/vfs/trunk/vfs21/pom.xml
projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSEntryPathsEnumeration.java
projects/jboss-osgi/projects/vfs/trunk/vfs30/pom.xml
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSEntryPathsEnumeration.java
Log:
Fix findEntries for vfs30
Modified: projects/jboss-osgi/projects/vfs/trunk/api/pom.xml
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/api/pom.xml 2010-03-05 11:02:24 UTC (rev 101942)
+++ projects/jboss-osgi/projects/vfs/trunk/api/pom.xml 2010-03-05 11:24:13 UTC (rev 101943)
@@ -14,7 +14,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <name>JBossOSGi - VFS API</name>
+ <name>JBossOSGi VFS - API</name>
<description>The JBossOSGi VFS Abstration</description>
<groupId>org.jboss.osgi.vfs</groupId>
Modified: projects/jboss-osgi/projects/vfs/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/pom.xml 2010-03-05 11:02:24 UTC (rev 101942)
+++ projects/jboss-osgi/projects/vfs/trunk/pom.xml 2010-03-05 11:24:13 UTC (rev 101943)
@@ -14,7 +14,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <name>JBossOSGi - VFS</name>
+ <name>JBossOSGi VFS</name>
<description>The JBossOSGi VFS Abstration</description>
<groupId>org.jboss.osgi.vfs</groupId>
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs21/pom.xml
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs21/pom.xml 2010-03-05 11:02:24 UTC (rev 101942)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs21/pom.xml 2010-03-05 11:24:13 UTC (rev 101943)
@@ -14,7 +14,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <name>JBossOSGi - VFS21</name>
+ <name>JBossOSGi VFS - VFS21</name>
<description>The JBossOSGi VFS Abstration</description>
<groupId>org.jboss.osgi.vfs</groupId>
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSEntryPathsEnumeration.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSEntryPathsEnumeration.java 2010-03-05 11:02:24 UTC (rev 101942)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSEntryPathsEnumeration.java 2010-03-05 11:24:13 UTC (rev 101943)
@@ -86,9 +86,14 @@
if (length != 0)
result = result.substring(length);
+ // Returned paths indicating subdirectory paths end with a "/"
if (file.isLeaf() == false && result.endsWith("/") == false)
result += "/";
+ // The returned paths are all relative to the root of this bundle and must not begin with "/".
+ if (result.startsWith("/"))
+ result = result.substring(1);
+
return result;
}
catch (IOException e)
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs30/pom.xml
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs30/pom.xml 2010-03-05 11:02:24 UTC (rev 101942)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/pom.xml 2010-03-05 11:24:13 UTC (rev 101943)
@@ -14,7 +14,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <name>JBossOSGi - VFS30</name>
+ <name>JBossOSGi VFS - VFS30</name>
<description>The JBossOSGi VFS Abstration</description>
<groupId>org.jboss.osgi.vfs</groupId>
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSEntryPathsEnumeration.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSEntryPathsEnumeration.java 2010-03-05 11:02:24 UTC (rev 101942)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSEntryPathsEnumeration.java 2010-03-05 11:24:13 UTC (rev 101943)
@@ -84,8 +84,13 @@
if (length != 0)
result = result.substring(length);
+ // Returned paths indicating subdirectory paths end with a "/"
if (file.isDirectory() && result.endsWith("/") == false)
result += "/";
+
+ // The returned paths are all relative to the root of this bundle and must not begin with "/".
+ if (result.startsWith("/"))
+ result = result.substring(1);
return result;
}
14 years, 4 months
JBoss-OSGI SVN: r101931 - projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-04 23:37:23 -0500 (Thu, 04 Mar 2010)
New Revision: 101931
Modified:
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
Log:
Cache MBeanServer
Modified: projects/jboss-osgi/projects/testing/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-05 04:37:07 UTC (rev 101930)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java 2010-03-05 04:37:23 UTC (rev 101931)
@@ -57,6 +57,8 @@
{
// Provide logging
private static final Logger log = Logger.getLogger(EmbeddedRuntime.class);
+
+ private MBeanServer server;
public EmbeddedRuntime(OSGiTestHelper helper)
{
@@ -163,17 +165,18 @@
public MBeanServerConnection getMBeanServer()
{
- ArrayList<MBeanServer> serverArr = MBeanServerFactory.findMBeanServer(null);
- if (serverArr.size() > 1)
- throw new IllegalStateException("Multiple MBeanServer instances not supported");
+ if (server == null)
+ {
+ ArrayList<MBeanServer> serverArr = MBeanServerFactory.findMBeanServer(null);
+ if (serverArr.size() > 1)
+ throw new IllegalStateException("Multiple MBeanServer instances not supported");
- MBeanServer server = null;
- if (serverArr.size() == 1)
- server = serverArr.get(0);
+ if (serverArr.size() == 1)
+ server = serverArr.get(0);
- if (server == null)
- server = MBeanServerFactory.createMBeanServer();
-
+ if (server == null)
+ server = MBeanServerFactory.createMBeanServer();
+ }
return server;
}
14 years, 4 months
JBoss-OSGI SVN: r101930 - in projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi: capabilities and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-04 23:37:07 -0500 (Thu, 04 Mar 2010)
New Revision: 101930
Added:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi298/
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi298/OSGi298TestCase.java
Modified:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/capabilities/CapabilityTestCase.java
Log:
[JBOSGI-298] InstanceAlreadyExistsException: osgi.core:type=framework,version=1.5
Add test case
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-05 04:18:36 UTC (rev 101929)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/capabilities/CapabilityTestCase.java 2010-03-05 04:37:07 UTC (rev 101930)
@@ -39,6 +39,7 @@
import org.jboss.osgi.jbossxb.XMLBindingCapability;
import org.jboss.osgi.jmx.JMXCapability;
import org.jboss.osgi.jndi.JNDICapability;
+import org.jboss.osgi.spi.capability.CompendiumCapability;
import org.jboss.osgi.spi.capability.LogServiceCapability;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
@@ -106,8 +107,8 @@
runtime.addCapability(new JAXBCapability());
- OSGiServiceReference saxRef = runtime.getServiceReference(JAXBService.class.getName());
- assertNotNull("JAXBService registered", saxRef);
+ OSGiServiceReference sref = runtime.getServiceReference(JAXBService.class.getName());
+ assertNotNull("JAXBService registered", sref);
}
finally
{
@@ -128,8 +129,8 @@
runtime.addCapability(new XMLBindingCapability());
- OSGiServiceReference saxRef = runtime.getServiceReference(UnmarshallerService.class.getName());
- assertNotNull("UnmarshallerService registered", saxRef);
+ OSGiServiceReference sref = runtime.getServiceReference(UnmarshallerService.class.getName());
+ assertNotNull("UnmarshallerService registered", sref);
}
finally
{
@@ -150,8 +151,8 @@
runtime.addCapability(new JNDICapability());
- OSGiServiceReference saxRef = runtime.getServiceReference(InitialContext.class.getName());
- assertNotNull("InitialContext registered", saxRef);
+ OSGiServiceReference sref = runtime.getServiceReference(InitialContext.class.getName());
+ assertNotNull("InitialContext registered", sref);
}
finally
{
@@ -165,15 +166,15 @@
OSGiRuntime runtime = getEmbeddedRuntime();
try
{
- runtime.addCapability(new LogServiceCapability());
+ runtime.addCapability(new CompendiumCapability());
OSGiBundle bundle = runtime.getBundle("jboss-osgi-jmx", null);
assertNull("Test bundle null", bundle);
runtime.addCapability(new JMXCapability());
- OSGiServiceReference saxRef = runtime.getServiceReference(MBeanServer.class.getName());
- assertNotNull("MBeanServer registered", saxRef);
+ OSGiServiceReference sref = runtime.getServiceReference(MBeanServer.class.getName());
+ assertNotNull("MBeanServer registered", sref);
}
finally
{
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi298/OSGi298TestCase.java 2010-03-05 04:37:07 UTC (rev 101930)
@@ -0,0 +1,97 @@
+/*
+ * 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.
+ */
+
+//$Id: CapabilityTestCase.java 97030 2009-11-26 14:42:11Z thomas.diesler(a)jboss.com $
+package org.jboss.test.osgi.jbosgi298;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.jboss.osgi.jmx.JMXCapability;
+import org.jboss.osgi.spi.capability.CompendiumCapability;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiTest;
+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;
+import org.osgi.jmx.framework.ServiceStateMBean;
+
+/**
+ * [JBOSGI-298] InstanceAlreadyExistsException: osgi.core:type=framework,version=1.5
+ *
+ * https://jira.jboss.org/jira/browse/JBOSGI-298
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 05-Mar-2010
+ */
+@Ignore
+public class OSGi298TestCase extends OSGiTest
+{
+ private OSGiRuntime runtime;
+
+ @Before
+ public void setUp() throws Exception
+ {
+ runtime = getEmbeddedRuntime();
+ runtime.addCapability(new CompendiumCapability());
+ }
+
+ @After
+ public void tearDown()
+ {
+ runtime.shutdown();
+ }
+
+ @Test
+ public void testJMXCapability() throws Exception
+ {
+ JMXCapability capability = new JMXCapability();
+
+ 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));
+
+ runtime.removeCapability(capability);
+
+ 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
+ {
+ MBeanServer server = (MBeanServer)runtime.getMBeanServer();
+ return server.isRegistered(ObjectName.getInstance(oname));
+ }
+}
\ No newline at end of file
14 years, 4 months
JBoss-OSGI SVN: r101927 - projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-04 22:46:43 -0500 (Thu, 04 Mar 2010)
New Revision: 101927
Modified:
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
Log:
Prevent getBundles failure due to remote bundle getting uninstalled
Modified: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-03-05 03:46:34 UTC (rev 101926)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-03-05 03:46:43 UTC (rev 101927)
@@ -57,7 +57,7 @@
* @author Thomas.Diesler(a)jboss.org
* @since 25-Sep-2008
*/
-public class RemoteBundle extends OSGiBundleImpl
+class RemoteBundle extends OSGiBundleImpl
{
// Provide logging
private static final Logger log = Logger.getLogger(RemoteBundle.class);
@@ -71,30 +71,24 @@
private Version version;
boolean uninstalled;
- public RemoteBundle(OSGiRuntime runtime, long bundleId)
+ RemoteBundle(OSGiRuntime runtime, long bundleId) throws IOException
{
super(runtime);
this.bundleId = bundleId;
ObjectName objectName = ObjectNameFactory.create(BundleStateMBeanExt.OBJECTNAME);
bundleState = MBeanProxy.get(runtime.getMBeanServer(), objectName, BundleStateMBeanExt.class);
- try
- {
- symbolicName = bundleState.getSymbolicName(bundleId);
- location = bundleState.getLocation(bundleId);
+
+ symbolicName = bundleState.getSymbolicName(bundleId);
+ location = bundleState.getLocation(bundleId);
- String versionStr = bundleState.getVersion(bundleId);
- version = Version.parseVersion(versionStr);
+ String versionStr = bundleState.getVersion(bundleId);
+ version = Version.parseVersion(versionStr);
- // The getHeaders methods must continue to provide the manifest header
- // information after the bundle enters the UNINSTALLED state.
- defaultHeaders = getHeadersInternal(null);
- rawHeaders = getHeadersInternal("");
- }
- catch (IOException ex)
- {
- throw new IllegalStateException("Cannot initialize remote bundle", ex);
- }
+ // The getHeaders methods must continue to provide the manifest header
+ // information after the bundle enters the UNINSTALLED state.
+ defaultHeaders = getHeadersInternal(null);
+ rawHeaders = getHeadersInternal("");
}
@SuppressWarnings("unchecked")
@@ -133,15 +127,17 @@
return Bundle.STOPPING;
if ("UNINSTALLED".equals(state))
return Bundle.UNINSTALLED;
-
+ else
+ throw new IllegalStateException("Unsupported state: " + state);
}
catch (Exception rte)
{
Throwable cause = rte.getCause() != null ? rte.getCause() : rte;
if (cause instanceof InstanceNotFoundException == false)
log.warn("Cannot get state for bundle: " + bundleId, cause);
+
+ return Bundle.UNINSTALLED;
}
- return Bundle.UNINSTALLED;
}
@Override
@@ -208,7 +204,7 @@
CompositeData propData = bundleState.getProperty(bundleId, key);
if (propData == null)
return null;
-
+
return (String)propData.get(JmxConstants.VALUE);
}
catch (IOException ex)
Modified: projects/jboss-osgi/projects/testing/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-05 03:46:34 UTC (rev 101926)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2010-03-05 03:46:43 UTC (rev 101927)
@@ -39,6 +39,7 @@
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;
@@ -59,6 +60,9 @@
*/
public class RemoteRuntime extends OSGiRuntimeImpl
{
+ // Provide logging
+ private static final Logger log = Logger.getLogger(RemoteRuntime.class);
+
private MBeanServerConnection mbeanServer;
public RemoteRuntime(OSGiTestHelper helper)
@@ -116,15 +120,25 @@
Iterator<?> iterator = listBundles.values().iterator();
while (iterator.hasNext())
{
- CompositeData next = (CompositeData)iterator.next();
- Object bundleId = next.get(BundleStateMBean.IDENTIFIER);
- bundles.add(new RemoteBundle(this, (Long)bundleId));
+ 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);
14 years, 4 months
JBoss-OSGI SVN: r101925 - in projects/jboss-osgi/trunk/testsuite: functional/src/test/java/org/jboss/test/osgi/jbosgi99 and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-04 22:45:41 -0500 (Thu, 04 Mar 2010)
New Revision: 101925
Modified:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGi99TestCase.java
projects/jboss-osgi/trunk/testsuite/pom.xml
Log:
Promote the framework core dependencies
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-05 03:44:26 UTC (rev 101924)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGi99TestCase.java 2010-03-05 03:45:41 UTC (rev 101925)
@@ -130,12 +130,12 @@
}
@Test
- // [JBOSGI-210] Bundle installed but not started with hot deploy
public void testHotDeploy() throws Exception
{
if (runtime.isRemoteRuntime() == false)
return;
+ // [JBOSGI-210] Bundle installed but not started with hot deploy
File inFile = getTestArchiveFile("jbosgi99-allgood.jar");
// Copy the bundle to the data directory
@@ -148,7 +148,7 @@
File deployFile = new File(outPath + "deploy/jbosgi99-allgood.jar");
outFile.renameTo(deployFile);
- int timeout = 5000;
+ int timeout = 8000;
OSGiBundle bundle = null;
while (timeout > 0)
{
@@ -166,7 +166,7 @@
// Delete the bundle from the deploy directory
deployFile.delete();
- timeout = 5000;
+ timeout = 8000;
while (timeout > 0)
{
if (bundle.getState() == Bundle.UNINSTALLED)
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2010-03-05 03:44:26 UTC (rev 101924)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2010-03-05 03:45:41 UTC (rev 101925)
@@ -330,8 +330,14 @@
</property>
</activation>
<dependencies>
+ <!-- Promote the framework core dependencies -->
<dependency>
<groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework-core</artifactId>
+ <version>${version.jboss.osgi.framework}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.framework</groupId>
<artifactId>jboss-osgi-framework</artifactId>
</dependency>
<dependency>
@@ -348,8 +354,14 @@
</property>
</activation>
<dependencies>
+ <!-- Promote the framework core dependencies -->
<dependency>
<groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework-core</artifactId>
+ <version>${version.jboss.osgi.framework}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.framework</groupId>
<artifactId>jboss-osgi-framework</artifactId>
</dependency>
<dependency>
@@ -453,7 +465,7 @@
<groupId>org.jboss.osgi.runtime</groupId>
<artifactId>jmx-invoker-adaptor-client</artifactId>
<version>${version.jmx.invoker.adaptor.client}</version>
- <scope>provided</scope>
+ <scope>test</scope>
<type>pom</type>
</dependency>
</dependencies>
@@ -479,7 +491,7 @@
<groupId>org.jboss.osgi.runtime</groupId>
<artifactId>jmx-invoker-adaptor-client</artifactId>
<version>${version.jmx.invoker.adaptor.client}</version>
- <scope>provided</scope>
+ <scope>test</scope>
<type>pom</type>
</dependency>
</dependencies>
@@ -504,8 +516,8 @@
<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-client</artifactId>
- <version>6.0.0.M1</version>
- <scope>provided</scope>
+ <version>6.0.0.20100216-M2</version>
+ <scope>test</scope>
<type>pom</type>
<exclusions>
<exclusion>
@@ -536,8 +548,8 @@
<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-client</artifactId>
- <version>6.0.0.M1</version>
- <scope>provided</scope>
+ <version>6.0.0.20100216-M2</version>
+ <scope>test</scope>
<type>pom</type>
<exclusions>
<exclusion>
14 years, 4 months
JBoss-OSGI SVN: r101913 - in projects/jboss-osgi/projects/runtime/framework/trunk: bundle/scripts and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-04 17:49:29 -0500 (Thu, 04 Mar 2010)
New Revision: 101913
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-all.xml
projects/jboss-osgi/projects/runtime/framework/trunk/core/pom.xml
projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
Log:
Use jboss-osgi-deployer-vfs21
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-all.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-all.xml 2010-03-04 22:38:17 UTC (rev 101912)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-all.xml 2010-03-04 22:49:29 UTC (rev 101913)
@@ -36,7 +36,7 @@
<include>*:jboss-mdr:jar</include>
<include>*:jboss-metatype:jar</include>
<include>*:jboss-osgi-deployment:jar</include>
- <include>*:jboss-osgi-deployers:jar</include>
+ <include>*:jboss-osgi-deployers-vfs21:jar</include>
<include>*:jboss-osgi-spi:jar</include>
<include>*:jboss-reflect:jar</include>
<include>*:jboss-vfs:jar</include>
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/pom.xml 2010-03-04 22:38:17 UTC (rev 101912)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/pom.xml 2010-03-04 22:49:29 UTC (rev 101913)
@@ -133,13 +133,15 @@
<groupId>org.jboss</groupId>
<artifactId>jboss-mdr</artifactId>
</dependency>
+
+ <!-- JBoss OSGi Dependencies -->
<dependency>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-spi</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.osgi.runtime</groupId>
- <artifactId>jboss-osgi-deployers</artifactId>
+ <groupId>org.jboss.osgi.deployers</groupId>
+ <artifactId>jboss-osgi-deployers-vfs21</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.osgi.runtime</groupId>
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2010-03-04 22:38:17 UTC (rev 101912)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2010-03-04 22:49:29 UTC (rev 101913)
@@ -167,17 +167,24 @@
<artifactId>jboss-mdr</artifactId>
<version>${version.jboss.mdr}</version>
</dependency>
+
+ <!-- JBoss OSGi Dependencies -->
<dependency>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-spi</artifactId>
<version>${version.jboss.osgi.spi}</version>
</dependency>
<dependency>
- <groupId>org.jboss.osgi.runtime</groupId>
- <artifactId>jboss-osgi-deployers</artifactId>
+ <groupId>org.jboss.osgi.deployers</groupId>
+ <artifactId>jboss-osgi-deployers-vfs21</artifactId>
<version>${version.jboss.osgi.deployers}</version>
</dependency>
<dependency>
+ <groupId>org.jboss.osgi.deployers</groupId>
+ <artifactId>jboss-osgi-deployers-vfs30</artifactId>
+ <version>${version.jboss.osgi.deployers}</version>
+ </dependency>
+ <dependency>
<groupId>org.jboss.osgi.runtime</groupId>
<artifactId>jboss-osgi-deployment</artifactId>
<version>${version.jboss.osgi.deployment}</version>
14 years, 4 months
JBoss-OSGI SVN: r101912 - in projects/jboss-osgi/projects/vfs/trunk/vfs30: src/main/java/org/jboss/osgi/vfs30 and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-04 17:38:17 -0500 (Thu, 04 Mar 2010)
New Revision: 101912
Added:
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSEntryPathsEnumeration.java
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSFindEntriesEnumeration.java
Modified:
projects/jboss-osgi/projects/vfs/trunk/vfs30/pom.xml
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java
Log:
Implement getEntryPaths, findEntries
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs30/pom.xml
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs30/pom.xml 2010-03-04 22:19:11 UTC (rev 101911)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/pom.xml 2010-03-04 22:38:17 UTC (rev 101912)
@@ -30,7 +30,7 @@
<!-- Properties -->
<properties>
- <version.jboss.vfs>3.0.0.CR2</version.jboss.vfs>
+ <version.jboss.vfs>3.0.0.CR3</version.jboss.vfs>
</properties>
<!-- Dependencies -->
Added: projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSEntryPathsEnumeration.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSEntryPathsEnumeration.java (rev 0)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSEntryPathsEnumeration.java 2010-03-04 22:38:17 UTC (rev 101912)
@@ -0,0 +1,92 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.vfs30;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.vfs.VirtualFile;
+
+/**
+ * An enumeration of VFS entry paths.
+ *
+ * @author <a href="adrian(a)jboss.com">Adrian Brock</a>
+ * @author thomas.diesler(a)jboss.com
+ * @version $Revision: 1.1 $
+ */
+class VFSEntryPathsEnumeration implements Enumeration<String>
+{
+ /** The paths */
+ private Iterator<String> paths;
+
+ /**
+ * Create a new VFSEntryPathsEnumeration.
+ *
+ * @param root the root file
+ * @param file the file to enumerate
+ * @throws IOException for any error
+ */
+ public VFSEntryPathsEnumeration(VirtualFile root, VirtualFile file) throws IOException
+ {
+ if (root == null)
+ throw new IllegalArgumentException("Null root");
+ if (file == null)
+ throw new IllegalArgumentException("Null file");
+
+ String rootPath = root.getPathName();
+ ArrayList<String> paths = new ArrayList<String>();
+ paths.add(fixPath(rootPath, file));
+
+ List<VirtualFile> children = file.getChildrenRecursively();
+ for (VirtualFile child : children)
+ paths.add(fixPath(rootPath, child));
+
+ this.paths = paths.iterator();
+ }
+
+ public boolean hasMoreElements()
+ {
+ return paths.hasNext();
+ }
+
+ public String nextElement()
+ {
+ return paths.next();
+ }
+
+ private String fixPath(String rootPath, VirtualFile file)
+ {
+ String result = file.getPathName();
+
+ int length = rootPath.length();
+ if (length != 0)
+ result = result.substring(length);
+
+ if (file.isDirectory() && result.endsWith("/") == false)
+ result += "/";
+
+ return result;
+ }
+}
Added: projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSFindEntriesEnumeration.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSFindEntriesEnumeration.java (rev 0)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSFindEntriesEnumeration.java 2010-03-04 22:38:17 UTC (rev 101912)
@@ -0,0 +1,134 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.vfs30;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.jboss.vfs.VirtualFile;
+import org.jboss.vfs.VirtualFileVisitor;
+import org.jboss.vfs.VisitorAttributes;
+import org.jboss.vfs.util.MatchAllVirtualFileFilter;
+
+
+/**
+ * An enumeration of VFS entries.
+ *
+ * @author <a href="adrian(a)jboss.com">Adrian Brock</a>
+ * @author thomas.diesler(a)jboss.com
+ * @version $Revision: 1.1 $
+ */
+class VFSFindEntriesEnumeration implements Enumeration<URL>
+{
+ /** The paths */
+ private Iterator<URL> paths;
+
+ /**
+ * Create a new VFSFindEntriesEnumeration.
+ *
+ * @param root the root file
+ * @param file the file to enumerate
+ * @param filePattern the file pattern
+ * @param recurse whether to recurse
+ * @throws IOException for any error
+ */
+ public VFSFindEntriesEnumeration(VirtualFile root, VirtualFile file, String filePattern, boolean recurse) throws IOException
+ {
+ if (root == null)
+ throw new IllegalArgumentException("Null root");
+ if (file == null)
+ throw new IllegalArgumentException("Null file");
+
+ String rootPath = root.getPathName();
+ VisitorAttributes attributes = new VisitorAttributes();
+ attributes.setIncludeRoot(false);
+ attributes.setLeavesOnly(true);
+ if (recurse)
+ attributes.setRecurseFilter(MatchAllVirtualFileFilter.INSTANCE);
+
+ VisitorImpl visitor = new VisitorImpl(rootPath, filePattern, attributes);
+ file.visit(visitor);
+
+ this.paths = visitor.paths.iterator();
+ }
+
+ public boolean hasMoreElements()
+ {
+ return paths.hasNext();
+ }
+
+ public URL nextElement()
+ {
+ return paths.next();
+ }
+
+ static class VisitorImpl implements VirtualFileVisitor
+ {
+ ArrayList<URL> paths = new ArrayList<URL>();
+
+ Pattern filter;
+ String rootPath;
+ VisitorAttributes attributes;
+
+ VisitorImpl(String rootPath, String filter, VisitorAttributes attributes)
+ {
+ this.rootPath = rootPath;
+ this.filter = convertToPattern(filter);
+ this.attributes = attributes;
+ }
+
+ public VisitorAttributes getAttributes()
+ {
+ return attributes;
+ }
+
+ public void visit(VirtualFile virtualFile)
+ {
+ // See if the filter matches
+ Matcher matcher = filter.matcher(virtualFile.getName());
+ if (matcher.find() == false)
+ return;
+
+ try
+ {
+ paths.add(virtualFile.toURL());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Error visiting " + virtualFile, e);
+ }
+ }
+
+ // Convert file pattern (RFC 1960-based Filter) into a RegEx pattern
+ private static Pattern convertToPattern(String filePattern)
+ {
+ filePattern = filePattern.replace("*", ".*");
+ return Pattern.compile("^" + filePattern + "$");
+ }
+
+ }
+}
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-04 22:19:11 UTC (rev 101911)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java 2010-03-04 22:38:17 UTC (rev 101912)
@@ -77,7 +77,7 @@
public VirtualFile getChild(String path) throws IOException
{
org.jboss.vfs.VirtualFile child = delegate.getChild(path);
- if (child == null)
+ if (child.exists() == false)
return null;
return new VirtualFileAdaptor30(child);
@@ -94,12 +94,35 @@
public Enumeration<URL> findEntries(String path, String pattern, boolean recurse) throws IOException
{
- throw new IllegalArgumentException("not implemented");
+ if (path == null)
+ throw new IllegalArgumentException("Null path");
+
+ if (pattern == null)
+ pattern = "*";
+
+ if (path.startsWith("/"))
+ path = path.substring(1);
+
+ org.jboss.vfs.VirtualFile child = delegate.getChild(path);
+ if (child.exists() == false)
+ return null;
+
+ return new VFSFindEntriesEnumeration(delegate, child, pattern, recurse);
}
- public Enumeration<String> getEntryPaths(String path)
+ public Enumeration<String> getEntryPaths(String path) throws IOException
{
- throw new IllegalArgumentException("not implemented");
+ if (path == null)
+ throw new IllegalArgumentException("Null path");
+
+ if (path.startsWith("/"))
+ path = path.substring(1);
+
+ org.jboss.vfs.VirtualFile child = delegate.getChild(path);
+ if (child.exists() == false)
+ return null;
+
+ return new VFSEntryPathsEnumeration(delegate, child);
}
public InputStream openStream() throws IOException
14 years, 4 months
JBoss-OSGI SVN: r101891 - in projects/jboss-osgi/projects/deployers/trunk: vfs30/src/main/java/org/jboss/osgi/deployer and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-04 15:23:10 -0500 (Thu, 04 Mar 2010)
New Revision: 101891
Modified:
projects/jboss-osgi/projects/deployers/trunk/vfs21/src/main/java/org/jboss/osgi/deployer/BundleStartLevelDeployer.java
projects/jboss-osgi/projects/deployers/trunk/vfs30/src/main/java/org/jboss/osgi/deployer/BundleStartLevelDeployer.java
Log:
Prevent NPE when Deployment is not attached
Modified: projects/jboss-osgi/projects/deployers/trunk/vfs21/src/main/java/org/jboss/osgi/deployer/BundleStartLevelDeployer.java
===================================================================
--- projects/jboss-osgi/projects/deployers/trunk/vfs21/src/main/java/org/jboss/osgi/deployer/BundleStartLevelDeployer.java 2010-03-04 20:14:33 UTC (rev 101890)
+++ projects/jboss-osgi/projects/deployers/trunk/vfs21/src/main/java/org/jboss/osgi/deployer/BundleStartLevelDeployer.java 2010-03-04 20:23:10 UTC (rev 101891)
@@ -50,7 +50,6 @@
public BundleStartLevelDeployer()
{
super(Bundle.class);
- addInput(Deployment.class);
}
public void setSystemContext(BundleContext systemContext)
@@ -61,7 +60,7 @@
public void deploy(DeploymentUnit unit, Bundle bundle) throws DeploymentException
{
Deployment dep = unit.getAttachment(Deployment.class);
- Integer propStart = dep.getStartLevel();
+ Integer propStart = (dep != null ? dep.getStartLevel() : null);
StartLevel startLevel = getStartLevel();
if (propStart != null && startLevel != null)
Modified: projects/jboss-osgi/projects/deployers/trunk/vfs30/src/main/java/org/jboss/osgi/deployer/BundleStartLevelDeployer.java
===================================================================
--- projects/jboss-osgi/projects/deployers/trunk/vfs30/src/main/java/org/jboss/osgi/deployer/BundleStartLevelDeployer.java 2010-03-04 20:14:33 UTC (rev 101890)
+++ projects/jboss-osgi/projects/deployers/trunk/vfs30/src/main/java/org/jboss/osgi/deployer/BundleStartLevelDeployer.java 2010-03-04 20:23:10 UTC (rev 101891)
@@ -50,7 +50,6 @@
public BundleStartLevelDeployer()
{
super(Bundle.class);
- addInput(Deployment.class);
}
public void setSystemContext(BundleContext systemContext)
@@ -61,7 +60,7 @@
public void deploy(DeploymentUnit unit, Bundle bundle) throws DeploymentException
{
Deployment dep = unit.getAttachment(Deployment.class);
- Integer propStart = dep.getStartLevel();
+ Integer propStart = dep != null ? dep.getStartLevel() : null;
StartLevel startLevel = getStartLevel();
if (propStart != null && startLevel != null)
14 years, 4 months