Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ConfigurationArtifact.java14
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerConfigArtifact.java2
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/InstallException.java35
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/Installer.java38
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/RuntimeArtifactModelObjectNameCreator.java14
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DefaultRuntimeArtifactModelObjectNameCreator.java31
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingInstaller.java57
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableArtifact.java20
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableBundleArtifact.java4
-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.java75
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/module-context.xml22
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/osgi-context.xml2
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubCompositeArtifact.java5
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DefaultArtifactObjectNameCreatorTests.java12
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingManageableArtifactTests.java14
-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.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/commands/StubRuntimeArtifactModelObjectNameCreator.java17
18 files changed, 79 insertions, 293 deletions
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ConfigurationArtifact.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ConfigurationArtifact.java
index e213750c..5caffe22 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ConfigurationArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ConfigurationArtifact.java
@@ -69,15 +69,13 @@ final class ConfigurationArtifact extends AbstractArtifact {
Map<String, String> properties = new HashMap<String, String>(super.getProperties());
try {
Configuration configuration = this.configurationAdmin.getConfiguration(this.pid, null);
- Dictionary dictionary = configuration.getProperties();
- Enumeration keys = dictionary.keys();
+ Dictionary<String, Object> dictionary = configuration.getProperties();
+ Enumeration<String> keys = dictionary.keys();
while (keys.hasMoreElements()) {
- Object key = keys.nextElement();
- if (key instanceof String) {
- Object value = dictionary.get(key);
- if (value instanceof String) {
- properties.put((String)key, (String)value);
- }
+ String key = keys.nextElement();
+ Object value = dictionary.get(key);
+ if (value instanceof String) {
+ properties.put(key, (String)value);
}
}
} catch (IOException _) {
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerConfigArtifact.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerConfigArtifact.java
index fc00b2bd..67794b41 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerConfigArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerConfigArtifact.java
@@ -47,7 +47,7 @@ final class DeployerConfigArtifact extends DeployerArtifact {
Map<String, String> properties = new HashMap<String, String>(super.getProperties());
try {
Properties props = this.configInstallArtifact.getProperties();
- Enumeration keys = props.keys();
+ Enumeration<Object> keys = props.keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
if (key instanceof String) {
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/InstallException.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/InstallException.java
deleted file mode 100644
index 4a5162d3..00000000
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/InstallException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * 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.management;
-
-/**
- * An exception thrown during the process of installing an artifact
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- *
- * Thread-safe
- *
- */
-public final class InstallException extends Exception {
-
- private static final long serialVersionUID = -7001124052781481556L;
-
- public InstallException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public InstallException(String message) {
- super(message);
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/Installer.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/Installer.java
deleted file mode 100644
index a6ae50b4..00000000
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/Installer.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * 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.management;
-
-import javax.management.MXBean;
-import javax.management.ObjectName;
-
-/**
- * Allows the installation of an artifact from a URI.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- *
- * Implementations must be threadsafe
- *
- */
-@MXBean
-public interface Installer {
-
- /**
- * Install an artifact from a URI. This URI's scheme can be something like <code>file:</code> or
- * <code>repository:</code>.
- *
- * @param uri The artifacts URI
- * @return The name of the Object in the model
- * @throws InstallException
- */
- ObjectName install(String uri) throws InstallException;
-}
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 64cbf7b4..5c4dcd63 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
@@ -36,7 +36,7 @@ public interface RuntimeArtifactModelObjectNameCreator {
* @param artifact The artifact to generate an {@link ObjectName} for
* @return The {@link ObjectName} for the {@link Artifact}
*/
- ObjectName createModel(Artifact artifact);
+ //ObjectName createModel(Artifact artifact);
/**
* Create an ArtifactModel {@link ObjectName} based on an input {@link Artifact}. Names generated from equal (
@@ -55,7 +55,7 @@ public interface RuntimeArtifactModelObjectNameCreator {
* @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 createModel(String type, String name, Version version);
+ //ObjectName createModel(String type, String name, Version version);
/**
* Creates an ArtifactModel {@link ObjectName} based on an input type, name, version, and region.
@@ -101,7 +101,7 @@ public interface RuntimeArtifactModelObjectNameCreator {
* @param objectName The identifying {@link ObjectName}
* @return The type of the artifact
*/
- String getType(ObjectName objectName);
+ //String getType(ObjectName objectName);
/**
* Gets the name of an artifact identified by an {@link ObjectName}
@@ -119,4 +119,12 @@ public interface RuntimeArtifactModelObjectNameCreator {
*/
String getVersion(ObjectName objectName);
+ /**
+ * Gets the version of an artifact identified by an {@link ObjectName}
+ *
+ * @param objectName The identifying {@link ObjectName}
+ * @return The version of the artifact
+ */
+ String getRegion(ObjectName objectName);
+
}
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 2255bf43..a4b7933d 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
@@ -38,17 +38,15 @@ public final class DefaultRuntimeArtifactModelObjectNameCreator implements Runti
private static final String ARTIFACTS_OF_TYPE_FORMAT = "%s:type=ArtifactModel,artifact-type=%s,*";
private static final String ARTIFACTS_OF_TYPE_AND_NAME_FORMAT = "%s:type=ArtifactModel,artifact-type=%s,name=%s,*";
-
- private static final String ARTIFACT_FORMAT = "%s:type=ArtifactModel,artifact-type=%s,name=%s,version=%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";
+ private static final String ARTIFACT_FORMAT = "%s:type=ArtifactModel,artifact-type=%s,name=%s,version=%s,region=%s";
private static final String KEY_NAME = "name";
private static final String KEY_VERSION = "version";
+ private static final String KEY_REGION = "region";
+
private final String domain;
public DefaultRuntimeArtifactModelObjectNameCreator(String domain) {
@@ -58,13 +56,6 @@ public final class DefaultRuntimeArtifactModelObjectNameCreator implements Runti
/**
* {@inheritDoc}
*/
- public ObjectName createModel(@NonNull Artifact artifact) {
- return createModel(artifact.getType(), artifact.getName(), artifact.getVersion());
- }
-
- /**
- * {@inheritDoc}
- */
public ObjectName createArtifactModel(@NonNull Artifact artifact) {
return createArtifactModel(artifact.getType(), artifact.getName(), artifact.getVersion(), artifact.getRegion());
}
@@ -72,15 +63,8 @@ public final class DefaultRuntimeArtifactModelObjectNameCreator implements Runti
/**
* {@inheritDoc}
*/
- public ObjectName createModel(String type, String name, Version version) {
- return createObjectName(String.format(ARTIFACT_FORMAT, this.domain, this.quoteValueIfNeeded(type), this.quoteValueIfNeeded(name), this.quoteValueIfNeeded(version.toString())));
- }
-
- /**
- * {@inheritDoc}
- */
public ObjectName createArtifactModel(String type, String name, Version version, Region region) {
- return createObjectName(String.format(EXTENDED_ARTIFACT_FORMAT, this.domain, this.quoteValueIfNeeded(type), this.quoteValueIfNeeded(name), this.quoteValueIfNeeded(version.toString()), this.quoteValueIfNeeded(region.getName())));
+ return createObjectName(String.format(ARTIFACT_FORMAT, this.domain, this.quoteValueIfNeeded(type), this.quoteValueIfNeeded(name), this.quoteValueIfNeeded(version.toString()), this.quoteValueIfNeeded(region.getName())));
}
/**
@@ -107,9 +91,9 @@ public final class DefaultRuntimeArtifactModelObjectNameCreator implements Runti
/**
* {@inheritDoc}
*/
- public String getType(ObjectName objectName) {
- return objectName.getKeyProperty(KEY_TYPE);
- }
+ public String getRegion(ObjectName objectName) {
+ return objectName.getKeyProperty(KEY_REGION);
+ }
/**
* {@inheritDoc}
@@ -141,4 +125,5 @@ public final class DefaultRuntimeArtifactModelObjectNameCreator implements Runti
throw new RuntimeException(String.format("Unable to create object name '%s'", objectName), e);
}
}
+
}
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
deleted file mode 100644
index 5ea65ebb..00000000
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/management/internal/DelegatingInstaller.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * 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.management.internal;
-
-import java.net.URI;
-
-import javax.management.ObjectName;
-
-import org.eclipse.virgo.nano.deployer.api.core.ApplicationDeployer;
-import org.eclipse.virgo.nano.deployer.api.core.DeploymentException;
-import org.eclipse.virgo.nano.deployer.api.core.DeploymentIdentity;
-import org.eclipse.virgo.kernel.model.management.InstallException;
-import org.eclipse.virgo.kernel.model.management.Installer;
-import org.eclipse.virgo.kernel.model.management.RuntimeArtifactModelObjectNameCreator;
-import org.osgi.framework.Version;
-
-
-/**
- * Implementation of {@link Installer} that delegates to the deployer
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- *
- * Threadsafe
- *
- */
-public final class DelegatingInstaller implements Installer {
-
- private final ApplicationDeployer deployer;
-
- private final RuntimeArtifactModelObjectNameCreator artifactObjectNameCreator;
-
- public DelegatingInstaller(ApplicationDeployer deployer, RuntimeArtifactModelObjectNameCreator artifactObjectNameCreator) {
- this.deployer = deployer;
- this.artifactObjectNameCreator = artifactObjectNameCreator;
- }
-
- public ObjectName install(String uri) throws InstallException {
- DeploymentIdentity deploymentIdentity;
- try {
- deploymentIdentity = this.deployer.install(URI.create(uri));
- } catch (DeploymentException e) {
- throw new InstallException(String.format("Exception encountered while installing '%s'", uri), e);
- }
- 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 588c5188..795465cb 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
@@ -35,21 +35,14 @@ import org.eclipse.virgo.nano.serviceability.NonNull;
* @see Artifact
*/
class DelegatingManageableArtifact implements ManageableArtifact {
-
- private static final String USER_REGION_NAME = "org.eclipse.virgo.region.user";
-
- private static final String GLOBAL_REGION_NAME = "global";
private final RuntimeArtifactModelObjectNameCreator artifactObjectNameCreator;
private final Artifact artifact;
- private final boolean newModel;
-
- public DelegatingManageableArtifact(@NonNull RuntimeArtifactModelObjectNameCreator artifactObjectNameCreator, @NonNull Artifact artifact, boolean newModel) {
+ public DelegatingManageableArtifact(@NonNull RuntimeArtifactModelObjectNameCreator artifactObjectNameCreator, @NonNull Artifact artifact) {
this.artifactObjectNameCreator = artifactObjectNameCreator;
this.artifact = artifact;
- this.newModel = newModel;
}
/**
@@ -137,15 +130,10 @@ class DelegatingManageableArtifact implements ManageableArtifact {
*/
private final ObjectName[] convertToObjectNames(Set<Artifact> artifacts) {
Set<ObjectName> objectNames = new HashSet<ObjectName>(artifacts.size());
- String regionName;
for (Artifact artifact : artifacts) {
- regionName = artifact.getRegion().getName();
- if(newModel || (!USER_REGION_NAME.equals(regionName) && !GLOBAL_REGION_NAME.equals(regionName)) ){
- objectNames.add(artifactObjectNameCreator.createArtifactModel(artifact));
- } else {
- objectNames.add(artifactObjectNameCreator.createModel(artifact));
- }
+ objectNames.add(artifactObjectNameCreator.createArtifactModel(artifact));
}
- return objectNames.toArray(new ObjectName[objectNames.size()]);
+ ObjectName[] objectNamesArray = new ObjectName[objectNames.size()];
+ return objectNames.toArray(objectNamesArray);
}
}
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 81021d67..8de55511 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,8 +32,8 @@ final class DelegatingManageableBundleArtifact extends DelegatingManageableArtif
private final BundleArtifact bundleArtifact;
- public DelegatingManageableBundleArtifact(@NonNull RuntimeArtifactModelObjectNameCreator artifactObjectNameCreator, @NonNull BundleArtifact bundleArtifact, boolean newModel) {
- super(artifactObjectNameCreator, bundleArtifact, newModel);
+ public DelegatingManageableBundleArtifact(@NonNull RuntimeArtifactModelObjectNameCreator artifactObjectNameCreator, @NonNull BundleArtifact bundleArtifact) {
+ super(artifactObjectNameCreator, bundleArtifact);
this.bundleArtifact = bundleArtifact;
}
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 ee385bd0..996d8edd 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, boolean newModel) {
- super(artifactObjectNameCreator, planArtifact, newModel);
+ public DelegatingManageableCompositeArtifact(@NonNull RuntimeArtifactModelObjectNameCreator artifactObjectNameCreator, @NonNull CompositeArtifact planArtifact) {
+ super(artifactObjectNameCreator, planArtifact);
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 45c85776..20293e5c 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,10 +43,6 @@ 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();
@@ -61,47 +57,15 @@ public class JmxArtifactRepositoryListener implements ArtifactRepositoryListener
* {@inheritDoc}
*/
public void added(Artifact 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);
+ ObjectName objectName = getModelObjectName(artifact);
try {
if (artifact instanceof CompositeArtifact) {
- this.server.registerMBean(new DelegatingManageableCompositeArtifact(this.artifactObjectNameCreator, (CompositeArtifact) artifact, newModel), objectName);
+ this.server.registerMBean(new DelegatingManageableCompositeArtifact(this.artifactObjectNameCreator, (CompositeArtifact) artifact), objectName);
} else if (artifact instanceof BundleArtifact) {
- this.server.registerMBean(new DelegatingManageableBundleArtifact(this.artifactObjectNameCreator, (BundleArtifact) artifact, newModel), objectName);
+ this.server.registerMBean(new DelegatingManageableBundleArtifact(this.artifactObjectNameCreator, (BundleArtifact) artifact), objectName);
} else {
- this.server.registerMBean(new DelegatingManageableArtifact(this.artifactObjectNameCreator, artifact, newModel), objectName);
+ this.server.registerMBean(new DelegatingManageableArtifact(this.artifactObjectNameCreator, artifact), objectName);
}
} catch (InstanceAlreadyExistsException e) {
logger.error(String.format("Unable to register '%s'", objectName.toString()), e);
@@ -111,10 +75,12 @@ public class JmxArtifactRepositoryListener implements ArtifactRepositoryListener
logger.error(String.format("Unable to register '%s'", objectName.toString()), e);
}
}
-
-
- private void retract(Artifact artifact, boolean newModel){
- ObjectName objectName = getModelObjectName(artifact, newModel);
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removed(Artifact artifact) {
+ ObjectName objectName = getModelObjectName(artifact);
try {
this.server.unregisterMBean(objectName);
@@ -124,14 +90,23 @@ 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){
+ private ObjectName getModelObjectName(Artifact artifact){
ObjectName objectName;
- if(newModel){
- objectName = this.artifactObjectNameCreator.createArtifactModel(artifact);
- } else {
- objectName = this.artifactObjectNameCreator.createModel(artifact);
- }
+ objectName = this.artifactObjectNameCreator.createArtifactModel(artifact);
return objectName;
}
}
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 a35ab570..e9b71552 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
@@ -56,30 +56,8 @@
<constructor-arg value="#{kernelConfig.getProperty('domain')}"/>
</bean>
- <bean id="installer" class="org.eclipse.virgo.kernel.model.management.internal.DelegatingInstaller">
- <constructor-arg ref="applicationDeployer"/>
- <constructor-arg ref="runtimeArtifactModelObjectNameCreator"/>
- </bean>
-
<osgi:reference id="kernelConfig" interface="org.eclipse.virgo.nano.core.KernelConfig"/>
<context:annotation-config/>
- <bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
- <property name="beans">
- <map>
- <entry key="installer" value-ref="installer"/>
- </map>
- </property>
- <property name="namingStrategy">
- <bean class="org.springframework.jmx.export.naming.KeyNamingStrategy">
- <property name="mappings">
- <props>
- <prop key="installer">#{kernelConfig.getProperty('domain')}:type=ArtifactModel,name=installer</prop>
- </props>
- </property>
- </bean>
- </property>
- </bean>
-
</beans>
diff --git a/org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/osgi-context.xml b/org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/osgi-context.xml
index d22e33bd..55ae6d4f 100644
--- a/org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/osgi-context.xml
+++ b/org.eclipse.virgo.kernel.model/src/main/resources/META-INF/spring/osgi-context.xml
@@ -39,8 +39,6 @@
<reference id="runtimeArtifactModel" interface="org.eclipse.virgo.kernel.deployer.model.RuntimeArtifactModel"/>
- <reference id="applicationDeployer" interface="org.eclipse.virgo.nano.deployer.api.core.ApplicationDeployer"/>
-
<reference id="regionDigraph" interface="org.eclipse.equinox.region.RegionDigraph" />
<reference id="globalRegion" interface="org.eclipse.equinox.region.Region" filter="(org.eclipse.virgo.kernel.region.name=global)" />
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubCompositeArtifact.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubCompositeArtifact.java
index e8e74e4b..7c0d677e 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubCompositeArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubCompositeArtifact.java
@@ -86,5 +86,10 @@ public class StubCompositeArtifact implements CompositeArtifact {
public Map<String, String> getProperties() {
throw new UnsupportedOperationException();
}
+
+ @Override
+ public String toString() {
+ return "StubCompositeRegion type:" + this.type + " name:" + this.name + " region:" + this.region.getName();
+ }
}
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 f2b571da..cb105e0c 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
@@ -27,23 +27,11 @@ 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 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=ArtifactModel,version=0.0.0", objectName.getCanonicalName());
- }
-
- @Test
public void successArtifactModel() {
ObjectName objectName = creator.createArtifactModel(new StubCompositeArtifact());
assertNotNull(objectName);
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 0d6ee300..30174d94 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
@@ -41,12 +41,12 @@ public class DelegatingManageableArtifactTests {
@Test(expected = FatalAssertionException.class)
public void nullCreator() {
- new DelegatingManageableArtifact(null, new StubCompositeArtifact(), true);
+ new DelegatingManageableArtifact(null, new StubCompositeArtifact());
}
@Test(expected = FatalAssertionException.class)
public void nullArtifact() {
- new DelegatingManageableArtifact(createMock(RuntimeArtifactModelObjectNameCreator.class), null, true);
+ new DelegatingManageableArtifact(createMock(RuntimeArtifactModelObjectNameCreator.class), null);
}
@Test
@@ -54,13 +54,13 @@ public class DelegatingManageableArtifactTests {
RuntimeArtifactModelObjectNameCreator creator = createMock(RuntimeArtifactModelObjectNameCreator.class);
Artifact artifact = createMock(Artifact.class);
- DelegatingManageableArtifact manageableArtifact = new DelegatingManageableArtifact(creator, artifact, false);
+ DelegatingManageableArtifact manageableArtifact = new DelegatingManageableArtifact(creator, artifact);
expect(artifact.getDependents()).andReturn(getArtifacts());
- 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(creator.createModel(isA(Artifact.class))).andReturn(new ObjectName("domain:key=value3,region=global"));
+ expect(creator.createArtifactModel(isA(Artifact.class))).andReturn(new ObjectName("domain:key=value1,region=global"));
+ expect(creator.createArtifactModel(isA(Artifact.class))).andReturn(new ObjectName("domain:key=value2,region=global"));
+ expect(creator.createArtifactModel(isA(Artifact.class))).andReturn(new ObjectName("domain:key=value3,region=global"));
+ expect(creator.createArtifactModel(isA(Artifact.class))).andReturn(new ObjectName("domain:key=value3,region=other"));
expect(artifact.getName()).andReturn("test-name");
expect(artifact.getState()).andReturn(ArtifactState.ACTIVE);
expect(artifact.getRegion()).andReturn(new StubRegion("test-region"));
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 5b8c3acf..29caea3a 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(), true);
+ new DelegatingManageableCompositeArtifact(null, new StubCompositeArtifact());
}
@Test(expected = FatalAssertionException.class)
public void nullArtifact() {
- new DelegatingManageableCompositeArtifact(createMock(RuntimeArtifactModelObjectNameCreator.class), null, true);
+ new DelegatingManageableCompositeArtifact(createMock(RuntimeArtifactModelObjectNameCreator.class), null);
}
@Test
@@ -44,7 +44,7 @@ public class DelegatingManageableCompositeArtifactTests {
RuntimeArtifactModelObjectNameCreator creator = createMock(RuntimeArtifactModelObjectNameCreator.class);
CompositeArtifact artifact = createMock(CompositeArtifact.class);
- DelegatingManageableCompositeArtifact manageablePlanArtifact = new DelegatingManageableCompositeArtifact(creator, artifact, true);
+ DelegatingManageableCompositeArtifact manageablePlanArtifact = new DelegatingManageableCompositeArtifact(creator, artifact);
expect(artifact.isAtomic()).andReturn(true);
expect(artifact.isScoped()).andReturn(true);
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 f29ae286..133cf1a2 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
@@ -20,19 +20,11 @@ import org.eclipse.virgo.kernel.model.management.RuntimeArtifactModelObjectNameC
import org.osgi.framework.Version;
public final class StubRuntimeArtifactModelObjectNameCreator implements RuntimeArtifactModelObjectNameCreator {
-
- public ObjectName createModel(Artifact artifact) {
- throw new UnsupportedOperationException();
- }
public ObjectName createArtifactModel(Artifact artifact) {
throw new UnsupportedOperationException();
}
- public ObjectName createModel(String type, String name, Version version) {
- throw new RuntimeException("Not supported");
- }
-
@Override
public ObjectName createArtifactModel(String type, String name, Version version, Region region) {
try {
@@ -74,12 +66,13 @@ public final class StubRuntimeArtifactModelObjectNameCreator implements RuntimeA
return objectName.getKeyProperty("name");
}
- public String getType(ObjectName objectName) {
- return objectName.getKeyProperty("type");
- }
-
public String getVersion(ObjectName objectName) {
return objectName.getKeyProperty("version");
}
+ @Override
+ public String getRegion(ObjectName objectName) {
+ return objectName.getKeyProperty("region");
+ }
+
}

Back to the top