Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Frost2011-05-13 13:23:08 -0400
committerChristopher Frost2011-05-13 13:23:08 -0400
commit551889d0bd85f1479e68409cb01f33dc7c5a1361 (patch)
tree6de01d133455c5f1544dbc53b853e8bf36f8f29d
parentcd71143b0b786e34479cc0ce64628217de98a258 (diff)
downloadorg.eclipse.virgo.kernel-551889d0bd85f1479e68409cb01f33dc7c5a1361.tar.gz
org.eclipse.virgo.kernel-551889d0bd85f1479e68409cb01f33dc7c5a1361.tar.xz
org.eclipse.virgo.kernel-551889d0bd85f1479e68409cb01f33dc7c5a1361.zip
344672 Renaming the KernelModel to ArtifactModel and adding all artifacts to it without changing the existing Model beans
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/AbstractRAMIntegrationTests.java9
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/OnStartedFailureTests.java2
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMBundleRefreshTests.java10
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMConfigurationRefreshTests.java6
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMParRefreshTests.java4
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMPlanRefreshTests.java4
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/StubRegion.java155
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/BundleArtifact.java7
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleArtifact.java6
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerBundleArtifact.java14
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/ManageableBundleArtifact.java7
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/RuntimeArtifactModelObjectNameCreator.java21
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DefaultRuntimeArtifactModelObjectNameCreator.java30
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingInstaller.java2
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableArtifact.java19
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableBundleArtifact.java18
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableCompositeArtifact.java4
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/JmxArtifactRepositoryListener.java77
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DefaultArtifactObjectNameCreatorTests.java24
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableArtifactTests.java12
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableCompositeArtifactTests.java6
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/JmxArtifactRepositoryListenerTests.java4
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/util/ArtifactRetriever.java4
-rw-r--r--org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/commands/StubRuntimeArtifactModelObjectNameCreator.java13
24 files changed, 349 insertions, 109 deletions
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/AbstractRAMIntegrationTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/AbstractRAMIntegrationTests.java
index cb73e82b..e076c6c8 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/AbstractRAMIntegrationTests.java
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/AbstractRAMIntegrationTests.java
@@ -17,6 +17,7 @@ import javax.management.JMX;
import javax.management.MBeanServer;
import javax.management.ObjectName;
+import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
import org.eclipse.virgo.kernel.model.management.ManageableArtifact;
import org.eclipse.virgo.kernel.model.management.RuntimeArtifactModelObjectNameCreator;
@@ -26,13 +27,13 @@ import org.eclipse.virgo.kernel.osgi.framework.OsgiFrameworkUtils;
public class AbstractRAMIntegrationTests extends AbstractDeployerIntegrationTest {
- public ManageableArtifact getManageableArtifact(DeploymentIdentity deploymentIdentity) {
- return getManageableArtifact(deploymentIdentity.getType(), deploymentIdentity.getSymbolicName(), new Version(deploymentIdentity.getVersion()));
+ public ManageableArtifact getManageableArtifact(DeploymentIdentity deploymentIdentity, Region region) {
+ return getManageableArtifact(deploymentIdentity.getType(), deploymentIdentity.getSymbolicName(), new Version(deploymentIdentity.getVersion()), region);
}
- public ManageableArtifact getManageableArtifact(String type, String name, Version version) {
+ public ManageableArtifact getManageableArtifact(String type, String name, Version version, Region region) {
RuntimeArtifactModelObjectNameCreator objectNameCreator = OsgiFrameworkUtils.getService(this.kernelContext, RuntimeArtifactModelObjectNameCreator.class).getService();
- ObjectName objectName = objectNameCreator.create(type, name, version);
+ ObjectName objectName = objectNameCreator.createArtifactModel(type, name, version, region);
return getManageableArtifact(objectName);
}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/OnStartedFailureTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/OnStartedFailureTests.java
index c538097e..92b0daab 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/OnStartedFailureTests.java
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/OnStartedFailureTests.java
@@ -75,7 +75,7 @@ public class OnStartedFailureTests extends AbstractRAMIntegrationTests {
registerListener();
try {
- ManageableArtifact manageableArtifact = getManageableArtifact(deployed);
+ ManageableArtifact manageableArtifact = getManageableArtifact(deployed, new StubRegion("org.eclipse.virgo.region.user"));
manageableArtifact.stop();
try {
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMBundleRefreshTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMBundleRefreshTests.java
index 06c72302..46460a76 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMBundleRefreshTests.java
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMBundleRefreshTests.java
@@ -57,7 +57,7 @@ public class RAMBundleRefreshTests extends AbstractRAMIntegrationTests {
copyToDeploy.delete(true);
refresh.copy(copyToDeploy, true);
- ManageableArtifact artifact = getManageableArtifact(deployed);
+ ManageableArtifact artifact = getManageableArtifact(deployed, new StubRegion("org.eclipse.virgo.region.user"));
assertTrue(artifact.refresh());
assertEquals("ACTIVE", artifact.getState());
@@ -113,7 +113,7 @@ public class RAMBundleRefreshTests extends AbstractRAMIntegrationTests {
copyToDeploy.delete(true);
refresh.copy(copyToDeploy, true);
- ManageableArtifact artifact = getManageableArtifact("bundle", "refresh", new Version(1,0,0));
+ ManageableArtifact artifact = getManageableArtifact("bundle", "refresh", new Version(1,0,0), new StubRegion("org.eclipse.virgo.region.user"));
assertTrue(artifact.refresh());
assertEquals("ACTIVE", artifact.getState());
@@ -151,7 +151,7 @@ public class RAMBundleRefreshTests extends AbstractRAMIntegrationTests {
refreshTarget.delete(true);
refreshSource.copy(refreshTarget, true);
- ManageableArtifact artifact = getManageableArtifact("bundle", "bundle-refresh-1-refresh", new Version(1,0,0));
+ ManageableArtifact artifact = getManageableArtifact("bundle", "bundle-refresh-1-refresh", new Version(1,0,0), new StubRegion("org.eclipse.virgo.region.user"));
assertTrue(artifact.refresh());
assertEquals("ACTIVE", artifact.getState());
@@ -176,7 +176,7 @@ public class RAMBundleRefreshTests extends AbstractRAMIntegrationTests {
assertEquals("no-bsn-no-version", deployed.getSymbolicName());
assertEquals("0.0.0", deployed.getVersion());
- ManageableArtifact artifact = getManageableArtifact(deployed);
+ ManageableArtifact artifact = getManageableArtifact(deployed, new StubRegion("org.eclipse.virgo.region.user"));
assertTrue(artifact.refresh());
assertEquals("ACTIVE", artifact.getState());
@@ -208,7 +208,7 @@ public class RAMBundleRefreshTests extends AbstractRAMIntegrationTests {
copyToDeploy.delete(true);
refresh.copy(copyToDeploy, true);
- ManageableArtifact artifact = getManageableArtifact("bundle", "bundle-refresh-1-refresh", new Version(1,0,0));
+ ManageableArtifact artifact = getManageableArtifact("bundle", "bundle-refresh-1-refresh", new Version(1,0,0), new StubRegion("org.eclipse.virgo.region.user"));
assertTrue(artifact.refresh());
assertEquals("ACTIVE", artifact.getState());
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMConfigurationRefreshTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMConfigurationRefreshTests.java
index 008cc97b..45702e18 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMConfigurationRefreshTests.java
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMConfigurationRefreshTests.java
@@ -57,7 +57,7 @@ public class RAMConfigurationRefreshTests extends AbstractRAMIntegrationTests {
copyToDeploy.delete();
refresh.copy(copyToDeploy);
- ManageableArtifact artifact = getManageableArtifact(deployed);
+ ManageableArtifact artifact = getManageableArtifact(deployed, new StubRegion("global"));
artifact.refresh();
configuration = getConfiguration("test");
@@ -86,7 +86,7 @@ public class RAMConfigurationRefreshTests extends AbstractRAMIntegrationTests {
propertiesToRefresh.delete();
refresh.copy(propertiesToRefresh);
- ManageableArtifact artifact = getManageableArtifact("configuration", "test", new Version(0,0,0));
+ ManageableArtifact artifact = getManageableArtifact("configuration", "test", new Version(0,0,0), new StubRegion("global"));
artifact.refresh();
configuration = getConfiguration("test");
@@ -125,7 +125,7 @@ public class RAMConfigurationRefreshTests extends AbstractRAMIntegrationTests {
configurationCopy.delete();
refresh.copy(configurationCopy);
- ManageableArtifact artifact = getManageableArtifact("configuration", "test", new Version(0,0,0));
+ ManageableArtifact artifact = getManageableArtifact("configuration", "test", new Version(0,0,0), new StubRegion("global"));
artifact.refresh();
configuration = getConfiguration("test");
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMParRefreshTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMParRefreshTests.java
index 23a944c2..8843d554 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMParRefreshTests.java
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMParRefreshTests.java
@@ -20,8 +20,6 @@ import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
import org.eclipse.virgo.kernel.model.management.ManageableArtifact;
import org.junit.Test;
-
-
/**
* Tests for refreshing a PAR via its entry in the runtime artifact model
*
@@ -37,7 +35,7 @@ public class RAMParRefreshTests extends AbstractRAMIntegrationTests {
@Test
public void refreshNotSupported() throws DeploymentException {
DeploymentIdentity deployed = this.deployer.deploy(new File("src/test/resources/ram-par-refresh/refresh.par").toURI());
- ManageableArtifact manageableArtifact = getManageableArtifact(deployed);
+ ManageableArtifact manageableArtifact = getManageableArtifact(deployed, new StubRegion("global"));
assertFalse(manageableArtifact.refresh());
}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMPlanRefreshTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMPlanRefreshTests.java
index 44e022d0..9828ccf4 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMPlanRefreshTests.java
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMPlanRefreshTests.java
@@ -20,8 +20,6 @@ import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
import org.eclipse.virgo.kernel.model.management.ManageableArtifact;
import org.junit.Test;
-
-
/**
* Tests for refreshing a plan via its entry in the runtime artifact model
*
@@ -37,7 +35,7 @@ public class RAMPlanRefreshTests extends AbstractRAMIntegrationTests {
@Test
public void refreshNotSupported() throws DeploymentException {
DeploymentIdentity deployed = this.deployer.deploy(new File("src/test/resources/ram-plan-refresh/test.plan").toURI());
- ManageableArtifact manageableArtifact = getManageableArtifact(deployed);
+ ManageableArtifact manageableArtifact = getManageableArtifact(deployed, new StubRegion("global"));
assertFalse(manageableArtifact.refresh());
}
}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/StubRegion.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/StubRegion.java
new file mode 100644
index 00000000..09fa04fb
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/StubRegion.java
@@ -0,0 +1,155 @@
+/*
+ * This file is part of the Eclipse Virgo project.
+ *
+ * Copyright (c) 2011 copyright_holder
+ * 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:
+ * cgfrost - initial contribution
+ */
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import java.io.InputStream;
+import java.util.Set;
+
+import org.eclipse.equinox.region.Region;
+import org.eclipse.equinox.region.RegionDigraph;
+import org.eclipse.equinox.region.RegionDigraphVisitor;
+import org.eclipse.equinox.region.RegionFilter;
+import org.eclipse.equinox.region.RegionDigraph.FilteredRegion;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Version;
+
+/**
+ * StubRegion
+ */
+public class StubRegion implements Region {
+
+ private final String name;
+
+ public StubRegion(String name) {
+ this.name = name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addBundle(Bundle bundle) throws BundleException {
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addBundle(long bundleId) {
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Bundle installBundle(String location, InputStream input) throws BundleException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Bundle installBundle(String location) throws BundleException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Set<Long> getBundleIds() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean contains(Bundle bundle) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean contains(long bundleId) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Bundle getBundle(String symbolicName, Version version) {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void connectRegion(Region headRegion, RegionFilter filter) throws BundleException {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public RegionDigraph getRegionDigraph() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void removeBundle(Bundle bundle) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void removeBundle(long bundleId) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Set<FilteredRegion> getEdges() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void visitSubgraph(RegionDigraphVisitor visitor) {
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/BundleArtifact.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/BundleArtifact.java
index f1adde24..6c373cd2 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/BundleArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/BundleArtifact.java
@@ -39,5 +39,12 @@ public interface BundleArtifact extends Artifact {
* @param targetPath The bundle relative path to delete
*/
void deleteEntry(String targetPath);
+
+ /**
+ * Gets the id of this bundle
+ *
+ * @return long id of this bundle
+ */
+ long getBundleId();
}
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleArtifact.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleArtifact.java
index 1f25abc6..a5786f18 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleArtifact.java
@@ -66,7 +66,6 @@ final class BundleArtifact extends AbstractArtifact {
} catch (BundleException e) {
logger.error("Unable to update bundle '{}:{}'", this.bundle.getSymbolicName(), this.bundle.getVersion());
throw new RuntimeException(String.format("Unable to update bundle '%s:%s'", this.bundle.getSymbolicName(), this.bundle.getVersion()), e);
-
}
}
@@ -79,7 +78,6 @@ final class BundleArtifact extends AbstractArtifact {
} catch (BundleException e) {
logger.error("Unable to start bundle '{}:{}'", this.bundle.getSymbolicName(), this.bundle.getVersion());
throw new RuntimeException(String.format("Unable to start bundle '%s:%s'", this.bundle.getSymbolicName(), this.bundle.getVersion()), e);
-
}
}
@@ -92,7 +90,6 @@ final class BundleArtifact extends AbstractArtifact {
} catch (BundleException e) {
logger.error("Unable to stop bundle '{}:{}'", this.bundle.getSymbolicName(), this.bundle.getVersion());
throw new RuntimeException(String.format("Unable to stop bundle '%s:%s'", this.bundle.getSymbolicName(), this.bundle.getVersion()), e);
-
}
}
@@ -104,8 +101,7 @@ final class BundleArtifact extends AbstractArtifact {
this.bundle.uninstall();
} catch (BundleException e) {
logger.error("Unable to uninstall bundle '{}:{}'", this.bundle.getSymbolicName(), this.bundle.getVersion());
- throw new RuntimeException(String.format("Unable to uninstall bundle '%s:%s'", this.bundle.getSymbolicName(), this.bundle.getVersion()),
- e);
+ throw new RuntimeException(String.format("Unable to uninstall bundle '%s:%s'", this.bundle.getSymbolicName(), this.bundle.getVersion()), e);
}
}
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerBundleArtifact.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerBundleArtifact.java
index 0380241d..c200881c 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerBundleArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerBundleArtifact.java
@@ -28,13 +28,25 @@ final class DeployerBundleArtifact extends DeployerArtifact implements BundleArt
this.installArtifact = installArtifact;
}
+ /**
+ * {@inheritDoc}
+ */
public void deleteEntry(String targetPath) {
this.installArtifact.deleteEntry(targetPath);
-
}
+ /**
+ * {@inheritDoc}
+ */
public void updateEntry(String inputPath, String targetPath) {
this.installArtifact.updateEntry(URI.create(inputPath), targetPath);
}
+ /**
+ * {@inheritDoc}
+ */
+ public long getBundleId() {
+ return this.installArtifact.getBundle().getBundleId();
+ }
+
}
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/ManageableBundleArtifact.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/ManageableBundleArtifact.java
index 32297c0e..68abe39e 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/ManageableBundleArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/ManageableBundleArtifact.java
@@ -42,4 +42,11 @@ public interface ManageableBundleArtifact extends ManageableArtifact {
* @param targetPath The bundle relative path to delete
*/
void deleteEntry(String targetPath);
+
+ /**
+ * Gets the id of this bundle
+ *
+ * @return long id of this bundle
+ */
+ long getBundleId();
}
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/RuntimeArtifactModelObjectNameCreator.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/RuntimeArtifactModelObjectNameCreator.java
index 5ef83b1a..ee101100 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/RuntimeArtifactModelObjectNameCreator.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/RuntimeArtifactModelObjectNameCreator.java
@@ -30,26 +30,35 @@ import org.osgi.framework.Version;
public interface RuntimeArtifactModelObjectNameCreator {
/**
- * Create an {@link ObjectName} based on an input {@link Artifact}. Names generated from equal (
+ * Create an Model {@link ObjectName} based on an input {@link Artifact}. Names generated from equal (
* {@link AbstractArtifact#equals(Object)}) {@link Artifact}s should be equal as well.
*
* @param artifact The artifact to generate an {@link ObjectName} for
* @return The {@link ObjectName} for the {@link Artifact}
*/
- ObjectName create(Artifact artifact);
+ ObjectName createModel(Artifact artifact);
/**
- * Creates an {@link ObjectName} based on an input type, name, and version.
+ * Create an ArtifactModel {@link ObjectName} based on an input {@link Artifact}. Names generated from equal (
+ * {@link AbstractArtifact#equals(Object)}) {@link Artifact}s should be equal as well.
+ *
+ * @param artifact The artifact to generate an {@link ObjectName} for
+ * @return The {@link ObjectName} for the {@link Artifact}
+ */
+ ObjectName createArtifactModel(Artifact artifact);
+
+ /**
+ * Creates a Model {@link ObjectName} based on an input type, name, and version.
*
* @param type The type of the object to create an @{link ObjectName} for
* @param name The name of the object to create an @{link ObjectName} for
* @param version The version of the object to create an @{link ObjectName} for
* @return An {@link ObjectName} for the runtime artifact represented by this type, name, and version
*/
- ObjectName create(String type, String name, Version version);
+ ObjectName createModel(String type, String name, Version version);
/**
- * Creates an {@link ObjectName} based on an input type, name, version, and region.
+ * Creates an ArtifactModel {@link ObjectName} based on an input type, name, version, and region.
*
* @param type The type of the object to create an @{link ObjectName} for
* @param name The name of the object to create an @{link ObjectName} for
@@ -57,7 +66,7 @@ public interface RuntimeArtifactModelObjectNameCreator {
* @param region The {@link Region} of the object to create an @{link ObjectName} for
* @return An {@link ObjectName} for the runtime artifact represented by this type, name, version, and region
*/
- ObjectName create(String type, String name, Version version, Region region);
+ ObjectName createArtifactModel(String type, String name, Version version, Region region);
/**
* Creates a query {@link ObjectName} that can be used to enumerate all of the user region artifacts in the runtime
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DefaultRuntimeArtifactModelObjectNameCreator.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DefaultRuntimeArtifactModelObjectNameCreator.java
index 47e0c6ca..ffc0cfcd 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DefaultRuntimeArtifactModelObjectNameCreator.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DefaultRuntimeArtifactModelObjectNameCreator.java
@@ -24,6 +24,8 @@ import org.osgi.framework.Version;
* The default implementation of {@link RuntimeArtifactModelObjectNameCreator}. This implementation creates names based
* on the following pattern:
* <p />
+ * <code>&lt;domain&gt;:type=ArtifactModel,artifact-type=&lt;type&gt;,name=&lt;name&gt;,version=&lt;version&gt;,region=&lt;region&gt;</code>
+ * and
* <code>&lt;domain&gt;:type=Model,artifact-type=&lt;type&gt;,name=&lt;name&gt;,version=&lt;version&gt;</code>
*
* <strong>Concurrent Semantics</strong><br />
@@ -33,10 +35,6 @@ import org.osgi.framework.Version;
*/
public final class DefaultRuntimeArtifactModelObjectNameCreator implements RuntimeArtifactModelObjectNameCreator {
- private static final String USER_REGION_NAME = "org.eclipse.virgo.region.user";
-
- private static final String GLOBAL_REGION_NAME = "global";
-
private static final String ARTIFACTS_FORMAT = "%s:type=Model,*";
private static final String ALL_ARTIFACTS_FORMAT = "%s:type=*Model,*";
@@ -47,7 +45,7 @@ public final class DefaultRuntimeArtifactModelObjectNameCreator implements Runti
private static final String ARTIFACT_FORMAT = "%s:type=Model,artifact-type=%s,name=%s,version=%s";
- private static final String EXTENDED_ARTIFACT_FORMAT = "%s:type=KernelModel,artifact-type=%s,name=%s,version=%s,region=%s";
+ private static final String EXTENDED_ARTIFACT_FORMAT = "%s:type=ArtifactModel,artifact-type=%s,name=%s,version=%s,region=%s";
private static final String KEY_TYPE = "artifact-type";
@@ -64,32 +62,34 @@ public final class DefaultRuntimeArtifactModelObjectNameCreator implements Runti
/**
* {@inheritDoc}
*/
- public ObjectName create(@NonNull Artifact artifact) {
- Region region = artifact.getRegion();
- // Treat user region artifacts specially to preserve JMX compatibility with Virgo 2.1.0.
- if (USER_REGION_NAME.equals(region.getName()) || GLOBAL_REGION_NAME.equals(region.getName()) ) {
- return create(artifact.getType(), artifact.getName(), artifact.getVersion());
- }
- return create(artifact.getType(), artifact.getName(), artifact.getVersion(), region);
+ public ObjectName createModel(@NonNull Artifact artifact) {
+ return createModel(artifact.getType(), artifact.getName(), artifact.getVersion());
}
/**
* {@inheritDoc}
*/
- public ObjectName create(String type, String name, Version version, Region region) {
- return createObjectName(String.format(EXTENDED_ARTIFACT_FORMAT, this.domain, type, name, version, region.getName()));
+ public ObjectName createArtifactModel(@NonNull Artifact artifact) {
+ return createArtifactModel(artifact.getType(), artifact.getName(), artifact.getVersion(), artifact.getRegion());
}
/**
* {@inheritDoc}
*/
- public ObjectName create(String type, String name, Version version) {
+ public ObjectName createModel(String type, String name, Version version) {
return createObjectName(String.format(ARTIFACT_FORMAT, this.domain, type, name, version));
}
/**
* {@inheritDoc}
*/
+ public ObjectName createArtifactModel(String type, String name, Version version, Region region) {
+ return createObjectName(String.format(EXTENDED_ARTIFACT_FORMAT, this.domain, type, name, version, region.getName()));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public ObjectName createArtifactsOfTypeQuery(String type) {
return createObjectName(String.format(ARTIFACTS_OF_TYPE_FORMAT, this.domain, type));
}
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingInstaller.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingInstaller.java
index 9d9a7950..8d16d82d 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingInstaller.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingInstaller.java
@@ -51,7 +51,7 @@ public final class DelegatingInstaller implements Installer {
} catch (DeploymentException e) {
throw new InstallException(String.format("Exception encountered while installing '%s'", uri), e);
}
- return this.artifactObjectNameCreator.create(deploymentIdentity.getType(), deploymentIdentity.getSymbolicName(), new Version(deploymentIdentity.getVersion()));
+ return this.artifactObjectNameCreator.createModel(deploymentIdentity.getType(), deploymentIdentity.getSymbolicName(), new Version(deploymentIdentity.getVersion()));
}
}
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableArtifact.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableArtifact.java
index 203aaed9..b89e32ab 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableArtifact.java
@@ -17,7 +17,6 @@ import java.util.Set;
import javax.management.ObjectName;
-import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.management.ManageableArtifact;
import org.eclipse.virgo.kernel.model.management.RuntimeArtifactModelObjectNameCreator;
@@ -41,9 +40,12 @@ class DelegatingManageableArtifact implements ManageableArtifact {
private final Artifact artifact;
- public DelegatingManageableArtifact(@NonNull RuntimeArtifactModelObjectNameCreator artifactObjectNameCreator, @NonNull Artifact artifact) {
+ private final boolean newModel;
+
+ public DelegatingManageableArtifact(@NonNull RuntimeArtifactModelObjectNameCreator artifactObjectNameCreator, @NonNull Artifact artifact, boolean newModel) {
this.artifactObjectNameCreator = artifactObjectNameCreator;
this.artifact = artifact;
+ this.newModel = newModel;
}
/**
@@ -85,12 +87,7 @@ class DelegatingManageableArtifact implements ManageableArtifact {
* {@inheritDoc}
*/
public String getRegion() {
- Region region = this.artifact.getRegion();
- if(region != null){
- return region.toString();
- } else {
- return "";
- }
+ return this.artifact.getRegion().getName();
}
/**
@@ -137,7 +134,11 @@ class DelegatingManageableArtifact implements ManageableArtifact {
protected final ObjectName[] convertToObjectNames(Set<Artifact> artifacts) {
Set<ObjectName> objectNames = new HashSet<ObjectName>(artifacts.size());
for (Artifact artifact : artifacts) {
- objectNames.add(artifactObjectNameCreator.create(artifact));
+ if(newModel){
+ objectNames.add(artifactObjectNameCreator.createArtifactModel(artifact));
+ } else {
+ objectNames.add(artifactObjectNameCreator.createModel(artifact));
+ }
}
return objectNames.toArray(new ObjectName[objectNames.size()]);
}
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableBundleArtifact.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableBundleArtifact.java
index 54dbd62c..fc49bf4a 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableBundleArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableBundleArtifact.java
@@ -32,18 +32,30 @@ final class DelegatingManageableBundleArtifact extends DelegatingManageableArtif
private final BundleArtifact bundleArtifact;
- public DelegatingManageableBundleArtifact(@NonNull RuntimeArtifactModelObjectNameCreator artifactObjectNameCreator,
- @NonNull BundleArtifact bundleArtifact) {
- super(artifactObjectNameCreator, bundleArtifact);
+ public DelegatingManageableBundleArtifact(@NonNull RuntimeArtifactModelObjectNameCreator artifactObjectNameCreator, @NonNull BundleArtifact bundleArtifact, boolean newModel) {
+ super(artifactObjectNameCreator, bundleArtifact, newModel);
this.bundleArtifact = bundleArtifact;
}
+ /**
+ * {@inheritDoc}
+ */
public void deleteEntry(String targetPath) {
this.bundleArtifact.deleteEntry(targetPath);
}
+ /**
+ * {@inheritDoc}
+ */
public void updateEntry(String inputPath, String targetPath) {
this.bundleArtifact.updateEntry(inputPath, targetPath);
}
+ /**
+ * {@inheritDoc}
+ */
+ public long getBundleId() {
+ return this.bundleArtifact.getBundleId();
+ }
+
}
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableCompositeArtifact.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableCompositeArtifact.java
index f0520145..9b6c0098 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableCompositeArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableCompositeArtifact.java
@@ -32,8 +32,8 @@ final class DelegatingManageableCompositeArtifact extends DelegatingManageableAr
private final CompositeArtifact planArtifact;
- public DelegatingManageableCompositeArtifact(@NonNull RuntimeArtifactModelObjectNameCreator artifactObjectNameCreator, @NonNull CompositeArtifact planArtifact) {
- super(artifactObjectNameCreator, planArtifact);
+ public DelegatingManageableCompositeArtifact(@NonNull RuntimeArtifactModelObjectNameCreator artifactObjectNameCreator, @NonNull CompositeArtifact planArtifact, boolean newModel) {
+ super(artifactObjectNameCreator, planArtifact, newModel);
this.planArtifact = planArtifact;
}
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/JmxArtifactRepositoryListener.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/JmxArtifactRepositoryListener.java
index 8ad46e48..86fc5518 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/JmxArtifactRepositoryListener.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/JmxArtifactRepositoryListener.java
@@ -43,6 +43,10 @@ import org.slf4j.LoggerFactory;
*/
public class JmxArtifactRepositoryListener implements ArtifactRepositoryListener {
+ private static final String USER_REGION_NAME = "org.eclipse.virgo.region.user";
+
+ private static final String GLOBAL_REGION_NAME = "global";
+
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
@@ -57,17 +61,47 @@ public class JmxArtifactRepositoryListener implements ArtifactRepositoryListener
* {@inheritDoc}
*/
public void added(Artifact artifact) {
- ObjectName objectName = this.artifactObjectNameCreator.create(artifact);
+ String regionName = artifact.getRegion().getName();
+ if (USER_REGION_NAME.equals(regionName) || GLOBAL_REGION_NAME.equals(regionName) ) {
+ publish(artifact, false);
+ }
+ publish(artifact, true);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removed(Artifact artifact) {
+ String regionName = artifact.getRegion().getName();
+ if (USER_REGION_NAME.equals(regionName) || GLOBAL_REGION_NAME.equals(regionName) ) {
+ retract(artifact, false);
+ }
+ retract(artifact, true);
+ }
+
+ public void destroy() {
+ Set<ObjectName> objectNames = this.server.queryNames(this.artifactObjectNameCreator.createAllArtifactsQuery(), null);
+ for (ObjectName objectName : objectNames) {
+ try {
+ this.server.unregisterMBean(objectName);
+ } catch (MBeanRegistrationException e) {
+ // Swallow exception to allow others to proceed
+ } catch (InstanceNotFoundException e) {
+ // Swallow exception to allow others to proceed
+ }
+ }
+ }
+
+ private void publish(Artifact artifact, boolean newModel){
+ ObjectName objectName = getModelObjectName(artifact, newModel);
try {
if (artifact instanceof CompositeArtifact) {
- this.server.registerMBean(new DelegatingManageableCompositeArtifact(this.artifactObjectNameCreator, (CompositeArtifact) artifact),
- objectName);
+ this.server.registerMBean(new DelegatingManageableCompositeArtifact(this.artifactObjectNameCreator, (CompositeArtifact) artifact, newModel), objectName);
} else if (artifact instanceof BundleArtifact) {
- this.server.registerMBean(new DelegatingManageableBundleArtifact(this.artifactObjectNameCreator, (BundleArtifact) artifact),
- objectName);
+ this.server.registerMBean(new DelegatingManageableBundleArtifact(this.artifactObjectNameCreator, (BundleArtifact) artifact, newModel), objectName);
} else {
- this.server.registerMBean(new DelegatingManageableArtifact(this.artifactObjectNameCreator, artifact), objectName);
+ this.server.registerMBean(new DelegatingManageableArtifact(this.artifactObjectNameCreator, artifact, newModel), objectName);
}
} catch (InstanceAlreadyExistsException e) {
logger.error(String.format("Unable to register '%s'", objectName.toString()), e);
@@ -77,13 +111,11 @@ public class JmxArtifactRepositoryListener implements ArtifactRepositoryListener
logger.error(String.format("Unable to register '%s'", objectName.toString()), e);
}
}
-
- /**
- * {@inheritDoc}
- */
- public void removed(Artifact artifact) {
- ObjectName objectName = this.artifactObjectNameCreator.create(artifact);
-
+
+
+ private void retract(Artifact artifact, boolean newModel){
+ ObjectName objectName = getModelObjectName(artifact, newModel);
+
try {
this.server.unregisterMBean(objectName);
} catch (MBeanRegistrationException e) {
@@ -92,17 +124,14 @@ public class JmxArtifactRepositoryListener implements ArtifactRepositoryListener
logger.error(String.format("Unable to unregister '%s'", objectName.toString()), e);
}
}
-
- public void destroy() {
- Set<ObjectName> objectNames = this.server.queryNames(this.artifactObjectNameCreator.createAllArtifactsQuery(), null);
- for (ObjectName objectName : objectNames) {
- try {
- this.server.unregisterMBean(objectName);
- } catch (MBeanRegistrationException e) {
- // Swallow exception to allow others to proceed
- } catch (InstanceNotFoundException e) {
- // Swallow exception to allow others to proceed
- }
+
+ private ObjectName getModelObjectName(Artifact artifact, boolean newModel){
+ ObjectName objectName;
+ if(newModel){
+ objectName = this.artifactObjectNameCreator.createArtifactModel(artifact);
+ } else {
+ objectName = this.artifactObjectNameCreator.createModel(artifact);
}
+ return objectName;
}
}
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DefaultArtifactObjectNameCreatorTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DefaultArtifactObjectNameCreatorTests.java
index 479b30c7..19c974f0 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DefaultArtifactObjectNameCreatorTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DefaultArtifactObjectNameCreatorTests.java
@@ -25,16 +25,28 @@ import org.junit.Test;
public class DefaultArtifactObjectNameCreatorTests {
private final DefaultRuntimeArtifactModelObjectNameCreator creator = new DefaultRuntimeArtifactModelObjectNameCreator("test-domain");
-
+
+ @Test(expected = FatalAssertionException.class)
+ public void nullModelArtifact() {
+ creator.createModel(null);
+ }
+
@Test(expected = FatalAssertionException.class)
- public void nullArtifact() {
- creator.create(null);
+ public void nullArtifactModelArtifact() {
+ creator.createArtifactModel(null);
+ }
+
+ @Test
+ public void successModel() {
+ ObjectName objectName = creator.createModel(new StubCompositeArtifact());
+ assertNotNull(objectName);
+ assertEquals("test-domain:artifact-type=test-type,name=test-name,type=Model,version=0.0.0", objectName.getCanonicalName());
}
@Test
- public void success() {
- ObjectName objectName = creator.create(new StubCompositeArtifact());
+ public void successArtifactModel() {
+ ObjectName objectName = creator.createArtifactModel(new StubCompositeArtifact());
assertNotNull(objectName);
- assertEquals("test-domain:artifact-type=test-type,name=test-name,region=test-region,type=KernelModel,version=0.0.0", objectName.getCanonicalName());
+ assertEquals("test-domain:artifact-type=test-type,name=test-name,region=test-region,type=ArtifactModel,version=0.0.0", objectName.getCanonicalName());
}
}
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableArtifactTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableArtifactTests.java
index a717ad98..4ee9a4e2 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableArtifactTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableArtifactTests.java
@@ -40,12 +40,12 @@ public class DelegatingManageableArtifactTests {
@Test(expected = FatalAssertionException.class)
public void nullCreator() {
- new DelegatingManageableArtifact(null, new StubCompositeArtifact());
+ new DelegatingManageableArtifact(null, new StubCompositeArtifact(), true);
}
@Test(expected = FatalAssertionException.class)
public void nullArtifact() {
- new DelegatingManageableArtifact(createMock(RuntimeArtifactModelObjectNameCreator.class), null);
+ new DelegatingManageableArtifact(createMock(RuntimeArtifactModelObjectNameCreator.class), null, true);
}
@Test
@@ -53,12 +53,12 @@ public class DelegatingManageableArtifactTests {
RuntimeArtifactModelObjectNameCreator creator = createMock(RuntimeArtifactModelObjectNameCreator.class);
Artifact artifact = createMock(Artifact.class);
- DelegatingManageableArtifact manageableArtifact = new DelegatingManageableArtifact(creator, artifact);
+ DelegatingManageableArtifact manageableArtifact = new DelegatingManageableArtifact(creator, artifact, true);
expect(artifact.getDependents()).andReturn(getArtifacts());
- expect(creator.create(isA(Artifact.class))).andReturn(new ObjectName("domain:key=value1"));
- expect(creator.create(isA(Artifact.class))).andReturn(new ObjectName("domain:key=value2"));
- expect(creator.create(isA(Artifact.class))).andReturn(new ObjectName("domain:key=value3"));
+ expect(creator.createArtifactModel(isA(Artifact.class))).andReturn(new ObjectName("domain:key=value1"));
+ expect(creator.createArtifactModel(isA(Artifact.class))).andReturn(new ObjectName("domain:key=value2"));
+ expect(creator.createArtifactModel(isA(Artifact.class))).andReturn(new ObjectName("domain:key=value3"));
expect(artifact.getName()).andReturn("test-name");
expect(artifact.getState()).andReturn(ArtifactState.ACTIVE);
expect(artifact.getType()).andReturn("test-type");
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableCompositeArtifactTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableCompositeArtifactTests.java
index 8671ae95..b8efb544 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableCompositeArtifactTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableCompositeArtifactTests.java
@@ -31,12 +31,12 @@ public class DelegatingManageableCompositeArtifactTests {
@Test(expected = FatalAssertionException.class)
public void nullCreator() {
- new DelegatingManageableCompositeArtifact(null, new StubCompositeArtifact());
+ new DelegatingManageableCompositeArtifact(null, new StubCompositeArtifact(), true);
}
@Test(expected = FatalAssertionException.class)
public void nullArtifact() {
- new DelegatingManageableCompositeArtifact(createMock(RuntimeArtifactModelObjectNameCreator.class), null);
+ new DelegatingManageableCompositeArtifact(createMock(RuntimeArtifactModelObjectNameCreator.class), null, true);
}
@Test
@@ -44,7 +44,7 @@ public class DelegatingManageableCompositeArtifactTests {
RuntimeArtifactModelObjectNameCreator creator = createMock(RuntimeArtifactModelObjectNameCreator.class);
CompositeArtifact artifact = createMock(CompositeArtifact.class);
- DelegatingManageableCompositeArtifact manageablePlanArtifact = new DelegatingManageableCompositeArtifact(creator, artifact);
+ DelegatingManageableCompositeArtifact manageablePlanArtifact = new DelegatingManageableCompositeArtifact(creator, artifact, true);
expect(artifact.isAtomic()).andReturn(true);
expect(artifact.isScoped()).andReturn(true);
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/JmxArtifactRepositoryListenerTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/JmxArtifactRepositoryListenerTests.java
index 9207a4d1..7d672130 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/JmxArtifactRepositoryListenerTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/JmxArtifactRepositoryListenerTests.java
@@ -47,7 +47,7 @@ public class JmxArtifactRepositoryListenerTests {
@Test
public void added() throws MalformedObjectNameException, NullPointerException {
- expect(this.creator.create(isA(Artifact.class))).andReturn(new ObjectName("test:key=1"));
+ expect(this.creator.createArtifactModel(isA(Artifact.class))).andReturn(new ObjectName("test:key=1"));
replay(creator);
int initial = this.server.getMBeanCount();
@@ -58,7 +58,7 @@ public class JmxArtifactRepositoryListenerTests {
@Test
public void removed() throws MalformedObjectNameException, NullPointerException {
- expect(this.creator.create(isA(Artifact.class))).andReturn(new ObjectName("test:key=1")).times(2);
+ expect(this.creator.createArtifactModel(isA(Artifact.class))).andReturn(new ObjectName("test:key=1")).times(2);
replay(creator);
this.listener.added(new StubCompositeArtifact());
diff --git a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/util/ArtifactRetriever.java b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/util/ArtifactRetriever.java
index 600a55c6..198970a6 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/util/ArtifactRetriever.java
+++ b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/util/ArtifactRetriever.java
@@ -66,7 +66,7 @@ public final class ArtifactRetriever<T extends ManageableArtifact> {
* @throws InstanceNotFoundException
*/
public T getArtifact(String name, Version version) throws InstanceNotFoundException {
- return getArtifact(this.objectNameCreator.create(this.type, name, version));
+ return getArtifact(this.objectNameCreator.createModel(this.type, name, version));
}
/**
@@ -77,7 +77,7 @@ public final class ArtifactRetriever<T extends ManageableArtifact> {
* @throws InstanceNotFoundException
*/
public T getArtifact(String name, Version version, Region region) throws InstanceNotFoundException {
- return getArtifact(this.objectNameCreator.create(this.type, name, version, region));
+ return getArtifact(this.objectNameCreator.createArtifactModel(this.type, name, version, region));
}
/**
diff --git a/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/commands/StubRuntimeArtifactModelObjectNameCreator.java b/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/commands/StubRuntimeArtifactModelObjectNameCreator.java
index e7fba419..1d53b273 100644
--- a/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/commands/StubRuntimeArtifactModelObjectNameCreator.java
+++ b/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/commands/StubRuntimeArtifactModelObjectNameCreator.java
@@ -21,11 +21,15 @@ import org.osgi.framework.Version;
public final class StubRuntimeArtifactModelObjectNameCreator implements RuntimeArtifactModelObjectNameCreator {
- public ObjectName create(Artifact artifact) {
+ public ObjectName createModel(Artifact artifact) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ObjectName createArtifactModel(Artifact artifact) {
throw new UnsupportedOperationException();
}
- public ObjectName create(String type, String name, Version version) {
+ public ObjectName createModel(String type, String name, Version version) {
try {
return new ObjectName("test:type=Model,artifact-type=" + type + ",name=" + name + ",version=" + version);
} catch (MalformedObjectNameException e) {
@@ -35,10 +39,9 @@ public final class StubRuntimeArtifactModelObjectNameCreator implements RuntimeA
}
@Override
- public ObjectName create(String type, String name, Version version, Region region) {
+ public ObjectName createArtifactModel(String type, String name, Version version, Region region) {
try {
- return new ObjectName("test:type=KernelModel,artifact-type=" + type + ",name=" + name + ",version=" + version + "region="
- + region.getName());
+ return new ObjectName("test:type=ArtifactModel,artifact-type=" + type + ",name=" + name + ",version=" + version + "region=" + region.getName());
} catch (MalformedObjectNameException e) {
} catch (NullPointerException e) {
}

Back to the top