Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2011-02-16 04:34:36 -0500
committerGlyn Normington2011-02-16 04:34:36 -0500
commit25706e2f9f25ecb5b89158d699148090bb217189 (patch)
tree11310a5112abafdc5005413f77b47e1c46f74b6d /org.eclipse.virgo.kernel.model
parentb8a931c0ab33ac20b2b757acda2ac17d699d32eb (diff)
parent3dd8206d5ef6fdd190a49ea65834cc19b57b77e7 (diff)
downloadorg.eclipse.virgo.kernel-25706e2f9f25ecb5b89158d699148090bb217189.tar.gz
org.eclipse.virgo.kernel-25706e2f9f25ecb5b89158d699148090bb217189.tar.xz
org.eclipse.virgo.kernel-25706e2f9f25ecb5b89158d699148090bb217189.zip
Merge branch 'master' of ssh://git.eclipse.org/gitroot/virgo/org.eclipse.virgo.kernel
Diffstat (limited to 'org.eclipse.virgo.kernel.model')
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/KernelRegionBundle.java101
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/NotifyingRuntimeArtifactRepository.java8
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/module-context.xml1
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/KernelRegionBundleTests.java35
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/NotifyingArtifactRepositoryTests.java12
5 files changed, 153 insertions, 4 deletions
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/KernelRegionBundle.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/KernelRegionBundle.java
new file mode 100644
index 00000000..42bb5245
--- /dev/null
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/KernelRegionBundle.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.model.internal;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.virgo.kernel.model.Artifact;
+import org.eclipse.virgo.kernel.model.ArtifactState;
+import org.osgi.framework.Version;
+
+
+/**
+ * TODO Delete this class when the RAM is upgraded (Bug
+ *
+ * KernelRegionBundle is a placeholder for dependencies that cross the Region boundary in to the Kernel Region.
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * KernelRegionBundle is ThreadSafe
+ */
+public class KernelRegionBundle implements Artifact{
+
+ private static final String TYPE = "bundle";
+
+ private static final String NAME = "org.eclipse.virgo.kernel";
+
+ private final Version version;
+
+ public KernelRegionBundle(Version version) {
+ this.version = version;
+ }
+
+ @Override
+ public void start() {
+ // no-op
+ }
+
+ @Override
+ public void stop() {
+ // no-op
+ }
+
+ @Override
+ public boolean refresh() {
+ // no-op
+ return false;
+ }
+
+ @Override
+ public void uninstall() {
+ // no-op
+ }
+
+ @Override
+ public String getType() {
+ return TYPE;
+ }
+
+ @Override
+ public String getName() {
+ return NAME;
+ }
+
+ @Override
+ public Version getVersion() {
+ return this.version;
+ }
+
+ @Override
+ public ArtifactState getState() {
+ return ArtifactState.ACTIVE;
+ }
+
+ @Override
+ public Set<Artifact> getDependents() {
+ return new HashSet<Artifact>();
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ return Collections.emptyMap();
+ }
+
+ @Override
+ public String toString() {
+ return String.format("type: %s, name: %s, version: %s", TYPE, NAME, this.version.toString());
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/NotifyingRuntimeArtifactRepository.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/NotifyingRuntimeArtifactRepository.java
index eacd17b8..f9b917ab 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/NotifyingRuntimeArtifactRepository.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/NotifyingRuntimeArtifactRepository.java
@@ -18,6 +18,7 @@ import java.util.Set;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
+import org.osgi.framework.BundleContext;
import org.osgi.framework.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,8 +45,11 @@ public final class NotifyingRuntimeArtifactRepository implements RuntimeArtifact
private final List<ArtifactRepositoryListener> listeners;
- public NotifyingRuntimeArtifactRepository(ArtifactRepositoryListener... listeners) {
+ private final KernelRegionBundle kernelRegionBundle;
+
+ public NotifyingRuntimeArtifactRepository(BundleContext bundleContext, ArtifactRepositoryListener... listeners) {
this.listeners = Arrays.asList(listeners);
+ this.kernelRegionBundle = new KernelRegionBundle(bundleContext.getBundle().getVersion());
}
/**
@@ -106,7 +110,7 @@ public final class NotifyingRuntimeArtifactRepository implements RuntimeArtifact
return artifact;
}
}
- return null;
+ return this.kernelRegionBundle;
}
}
diff --git a/org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/module-context.xml b/org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/module-context.xml
index c07ea468..7ca61dc8 100644
--- a/org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/module-context.xml
+++ b/org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/module-context.xml
@@ -35,6 +35,7 @@
</bean>
<bean id="artifactRepository" class="org.eclipse.virgo.kernel.model.internal.NotifyingRuntimeArtifactRepository">
+ <constructor-arg ref="bundleContext"/>
<constructor-arg ref="artifactRepositoryListener"/>
</bean>
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/KernelRegionBundleTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/KernelRegionBundleTests.java
new file mode 100644
index 00000000..0d5e8fdf
--- /dev/null
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/KernelRegionBundleTests.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.model.internal;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Version;
+
+
+public class KernelRegionBundleTests {
+
+ private KernelRegionBundle kernelRegionBundle;
+
+ @Before
+ public void setUp(){
+ this.kernelRegionBundle = new KernelRegionBundle(new Version("3.0.0"));
+ }
+
+ @Test
+ public void kernelVersion() {
+ assertEquals("3.0.0", this.kernelRegionBundle.getVersion().toString());
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/NotifyingArtifactRepositoryTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/NotifyingArtifactRepositoryTests.java
index 00e0e128..818578cf 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/NotifyingArtifactRepositoryTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/NotifyingArtifactRepositoryTests.java
@@ -18,16 +18,24 @@ import static org.junit.Assert.assertTrue;
import java.util.Set;
+import org.osgi.framework.Version;
+
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.StubCompositeArtifact;
import org.eclipse.virgo.kernel.model.internal.ArtifactRepositoryListener;
import org.eclipse.virgo.kernel.model.internal.NotifyingRuntimeArtifactRepository;
+import org.eclipse.virgo.teststubs.osgi.framework.StubBundle;
+import org.eclipse.virgo.teststubs.osgi.framework.StubBundleContext;
import org.junit.Test;
public class NotifyingArtifactRepositoryTests {
- private final NotifyingRuntimeArtifactRepository artifactRepository = new NotifyingRuntimeArtifactRepository();
+ private StubBundle stubBundle = new StubBundle("org.eclipse.virgo.kernel", new Version("3.0.0"));
+
+ private StubBundleContext stubBundleContext = new StubBundleContext(stubBundle);
+
+ private final NotifyingRuntimeArtifactRepository artifactRepository = new NotifyingRuntimeArtifactRepository(stubBundleContext);
@Test
public void add() {
@@ -48,7 +56,7 @@ public class NotifyingArtifactRepositoryTests {
public void listeners() {
StubArtifactRepositoryListener listener1 = new StubArtifactRepositoryListener(true);
StubArtifactRepositoryListener listener2 = new StubArtifactRepositoryListener(false);
- NotifyingRuntimeArtifactRepository artifactRepository = new NotifyingRuntimeArtifactRepository(listener1, listener2);
+ NotifyingRuntimeArtifactRepository artifactRepository = new NotifyingRuntimeArtifactRepository(stubBundleContext, listener1, listener2);
StubCompositeArtifact artifact = new StubCompositeArtifact();
artifactRepository.add(artifact);
artifactRepository.remove(artifact.getType(), artifact.getName(), artifact.getVersion());

Back to the top