Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2011-09-29 10:59:28 +0000
committerGlyn Normington2011-09-29 10:59:28 +0000
commit25d9b2e289a6d39cbb31ee06bede34e17c03e4d2 (patch)
treee332125751e36051bd949708aa4f9f5eb5d2d6a2 /org.eclipse.virgo.kernel.model/src
parentcac16d6e05b704c831bf20d8fbcc8af072e42f85 (diff)
downloadorg.eclipse.virgo.kernel-25d9b2e289a6d39cbb31ee06bede34e17c03e4d2.tar.gz
org.eclipse.virgo.kernel-25d9b2e289a6d39cbb31ee06bede34e17c03e4d2.tar.xz
org.eclipse.virgo.kernel-25d9b2e289a6d39cbb31ee06bede34e17c03e4d2.zip
bug 353996: distinguish config install artifacts
Diffstat (limited to 'org.eclipse.virgo.kernel.model/src')
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/configurationadmin/ConfigurationArtifact.java30
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerConfigArtifact.java37
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListener.java9
3 files changed, 75 insertions, 1 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 796f6b19..52563dc8 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
@@ -12,6 +12,10 @@
package org.eclipse.virgo.kernel.model.internal.configurationadmin;
import java.io.IOException;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.virgo.kernel.model.ArtifactState;
import org.eclipse.virgo.kernel.model.internal.AbstractArtifact;
@@ -19,6 +23,7 @@ import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.serviceability.NonNull;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Version;
+import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,6 +60,31 @@ final class ConfigurationArtifact extends AbstractArtifact {
public ArtifactState getState() {
return ArtifactState.ACTIVE;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Map<String, String> getProperties() {
+ 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();
+ 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);
+ }
+ }
+ }
+ } catch (IOException _) {
+ // Default to superclass behaviour
+ }
+ return properties;
+ }
/**
* {@inheritDoc}
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
new file mode 100644
index 00000000..b3f0d513
--- /dev/null
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/DeployerConfigArtifact.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.deployer;
+
+import org.eclipse.equinox.region.Region;
+import org.eclipse.virgo.kernel.install.artifact.InstallArtifact;
+import org.osgi.framework.BundleContext;
+
+
+/**
+ * {@link DeployerConfigArtifact} is a {@link DeployerArtifact} that understands
+ * a configuration install artifact's properties.
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * Thread safe.
+ */
+final class DeployerConfigArtifact extends DeployerArtifact {
+
+ private final InstallArtifact installArtifact;
+
+ public DeployerConfigArtifact(BundleContext bundleContext, InstallArtifact installArtifact, Region region) {
+ super(bundleContext, installArtifact, region);
+ this.installArtifact = installArtifact;
+ }
+
+
+}
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListener.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListener.java
index 930298c6..8661b6af 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListener.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/deployer/ModelInstallArtifactLifecycleListener.java
@@ -15,6 +15,7 @@ import org.eclipse.equinox.region.RegionDigraph;
import org.eclipse.equinox.region.Region;
import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
import org.eclipse.virgo.kernel.install.artifact.BundleInstallArtifact;
+import org.eclipse.virgo.kernel.install.artifact.ConfigInstallArtifact;
import org.eclipse.virgo.kernel.install.artifact.InstallArtifact;
import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListener;
import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListenerSupport;
@@ -79,11 +80,17 @@ class ModelInstallArtifactLifecycleListener extends InstallArtifactLifecycleList
addPlan((PlanInstallArtifact) installArtifact);
} else if (installArtifact instanceof BundleInstallArtifact) {
addOrReplaceBundle((BundleInstallArtifact) installArtifact);
- } else {
+ } else if (installArtifact instanceof ConfigInstallArtifact) {
+ addConfiguration((ConfigInstallArtifact) installArtifact);
+ }else {
addArtifact(installArtifact);
}
}
+ private void addConfiguration(ConfigInstallArtifact configInstallArtifact) {
+ this.artifactRepository.add(new DeployerConfigArtifact(this.bundleContext, configInstallArtifact, this.globalRegion));
+ }
+
private void addPlan(PlanInstallArtifact planInstallArtifact) {
this.artifactRepository.add(new DeployerCompositeArtifact(this.bundleContext, planInstallArtifact, this.globalRegion));
}

Back to the top