Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2012-08-29 10:14:04 +0000
committerGlyn Normington2012-08-29 10:14:04 +0000
commitf5d09d1875ffe970cf12d119ee2fe6b922ab4572 (patch)
treeb4bb541ac9a17a967decc3c888b51676cb3a2954 /org.eclipse.virgo.kernel.services
parent74a3118ee863a41b2e78e89e8512a413a94f91b4 (diff)
downloadorg.eclipse.virgo.kernel-f5d09d1875ffe970cf12d119ee2fe6b922ab4572.tar.gz
org.eclipse.virgo.kernel-f5d09d1875ffe970cf12d119ee2fe6b922ab4572.tar.xz
org.eclipse.virgo.kernel-f5d09d1875ffe970cf12d119ee2fe6b922ab4572.zip
383876: cache unique ids for each scope and further shorten deployer work area paths
Diffstat (limited to 'org.eclipse.virgo.kernel.services')
-rw-r--r--org.eclipse.virgo.kernel.services/src/main/java/org/eclipse/virgo/kernel/services/work/StandardWorkArea.java10
-rw-r--r--org.eclipse.virgo.kernel.services/src/main/java/org/eclipse/virgo/kernel/services/work/WorkAreaServiceFactory.java2
-rw-r--r--org.eclipse.virgo.kernel.services/src/test/java/org/eclipse/virgo/kernel/services/work/StandardWorkAreaTests.java33
3 files changed, 35 insertions, 10 deletions
diff --git a/org.eclipse.virgo.kernel.services/src/main/java/org/eclipse/virgo/kernel/services/work/StandardWorkArea.java b/org.eclipse.virgo.kernel.services/src/main/java/org/eclipse/virgo/kernel/services/work/StandardWorkArea.java
index 12ca9e4f..f36e74b1 100644
--- a/org.eclipse.virgo.kernel.services/src/main/java/org/eclipse/virgo/kernel/services/work/StandardWorkArea.java
+++ b/org.eclipse.virgo.kernel.services/src/main/java/org/eclipse/virgo/kernel/services/work/StandardWorkArea.java
@@ -28,6 +28,8 @@ import org.eclipse.virgo.util.io.PathReference;
*/
final class StandardWorkArea implements WorkArea {
+ private static final String KERNEL_PREFIX = "org.eclipse.virgo.kernel.";
+
private final PathReference workDirectory;
private final Bundle owner;
@@ -45,7 +47,13 @@ final class StandardWorkArea implements WorkArea {
}
private String createOwnerDirectoryName(Bundle owner) {
- return String.format("%s_%s", owner.getSymbolicName(), owner.getVersion());
+ String ownerSymbolicName = owner.getSymbolicName();
+ if (ownerSymbolicName.startsWith(KERNEL_PREFIX)) {
+ // Give kernel bundles short work area names to reduce path name lengths on Windows.
+ return ownerSymbolicName.substring(KERNEL_PREFIX.length());
+ } else {
+ return String.format("%s_%s", ownerSymbolicName, owner.getVersion());
+ }
}
/**
diff --git a/org.eclipse.virgo.kernel.services/src/main/java/org/eclipse/virgo/kernel/services/work/WorkAreaServiceFactory.java b/org.eclipse.virgo.kernel.services/src/main/java/org/eclipse/virgo/kernel/services/work/WorkAreaServiceFactory.java
index 3af2097d..f056c76f 100644
--- a/org.eclipse.virgo.kernel.services/src/main/java/org/eclipse/virgo/kernel/services/work/WorkAreaServiceFactory.java
+++ b/org.eclipse.virgo.kernel.services/src/main/java/org/eclipse/virgo/kernel/services/work/WorkAreaServiceFactory.java
@@ -21,7 +21,7 @@ import org.osgi.framework.ServiceRegistration;
/**
* {@link ServiceFactory} that creates a {@link WorkArea} for a given {@link Bundle}. Bundles need only to import a
- * <code>WorkArea</code> servicein their module context file to get access to the correct work area location.
+ * <code>WorkArea</code> service in their module context file to get access to the correct work area location.
* <p />
*
* <strong>Concurrent Semantics</strong><br />
diff --git a/org.eclipse.virgo.kernel.services/src/test/java/org/eclipse/virgo/kernel/services/work/StandardWorkAreaTests.java b/org.eclipse.virgo.kernel.services/src/test/java/org/eclipse/virgo/kernel/services/work/StandardWorkAreaTests.java
index 45bf8f81..251b1ad9 100644
--- a/org.eclipse.virgo.kernel.services/src/test/java/org/eclipse/virgo/kernel/services/work/StandardWorkAreaTests.java
+++ b/org.eclipse.virgo.kernel.services/src/test/java/org/eclipse/virgo/kernel/services/work/StandardWorkAreaTests.java
@@ -25,31 +25,48 @@ import org.eclipse.virgo.test.stubs.framework.StubBundle;
import org.eclipse.virgo.util.io.FileSystemUtils;
import org.eclipse.virgo.util.io.PathReference;
-
/**
*/
public class StandardWorkAreaTests {
private static final String WORK_DIR_NAME = "com.foo";
-
+
+ private static final String KERNEL_WORK_DIR_NAME = "bar";
+
+ private static final String KERNEL_BSN = "org.eclipse.virgo.kernel." + KERNEL_WORK_DIR_NAME;
@Before
public void before() {
FileSystemUtils.deleteRecursively(new File("./target/work", WORK_DIR_NAME));
+ FileSystemUtils.deleteRecursively(new File("./target/work", KERNEL_WORK_DIR_NAME));
}
-
+
@Test
public void nonNullWorkDirectory() {
-
+
StubBundle bundle = new StubBundle(WORK_DIR_NAME, Version.emptyVersion);
-
+
StandardWorkArea manager = new StandardWorkArea(new File("./target/work"), bundle);
PathReference workDir = manager.getWorkDirectory();
-
+
assertNotNull(workDir);
- assertTrue("work dir does not exist", workDir.exists());
+ assertTrue("work dir does not exist", workDir.exists());
assertTrue(workDir.isDirectory());
-
+
assertTrue(new File("./target/work", WORK_DIR_NAME + "_" + Version.emptyVersion).exists());
}
+
+ @Test
+ public void kernelWorkDirectory() {
+ StubBundle bundle = new StubBundle(KERNEL_BSN, Version.emptyVersion);
+
+ StandardWorkArea manager = new StandardWorkArea(new File("./target/work"), bundle);
+ PathReference workDir = manager.getWorkDirectory();
+
+ assertNotNull(workDir);
+ assertTrue("work dir does not exist", workDir.exists());
+ assertTrue(workDir.isDirectory());
+
+ assertTrue(new File("./target/work", KERNEL_WORK_DIR_NAME).exists());
+ }
}

Back to the top