You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:56:59 UTC
[sling-org-apache-sling-provisioning-model] 03/34: Update javadocs
and rename subsystem to deliverable and run mode to feature
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.provisioning.model-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git
commit a86fcd40edf1be2e628c0c232f466fd6bb0a18b0
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Sep 22 11:55:29 2014 +0000
Update javadocs and rename subsystem to deliverable and run mode to feature
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/support/slingstart-model@1626744 13f79535-47bb-0310-9956-ffa450edef68
---
.../apache/sling/slingstart/model/SSMArtifact.java | 2 +-
.../sling/slingstart/model/SSMConfiguration.java | 2 +-
.../{SSMSubsystem.java => SSMDeliverable.java} | 65 +++++++++---------
.../model/{SSMRunMode.java => SSMFeature.java} | 21 +++---
.../apache/sling/slingstart/model/SSMSettings.java | 4 +-
.../sling/slingstart/model/SSMStartLevel.java | 5 +-
.../slingstart/model/xml/XMLSSMModelReader.java | 76 +++++++++++-----------
.../slingstart/model/xml/XMLSSMModelWriter.java | 34 +++++-----
8 files changed, 109 insertions(+), 100 deletions(-)
diff --git a/src/main/java/org/apache/sling/slingstart/model/SSMArtifact.java b/src/main/java/org/apache/sling/slingstart/model/SSMArtifact.java
index 02b7cc1..a26cdab 100644
--- a/src/main/java/org/apache/sling/slingstart/model/SSMArtifact.java
+++ b/src/main/java/org/apache/sling/slingstart/model/SSMArtifact.java
@@ -137,7 +137,7 @@ public class SSMArtifact {
@Override
public String toString() {
- return "CSArtifact [groupId=" + groupId + ", artifactId=" + artifactId
+ return "SSMArtifact [groupId=" + groupId + ", artifactId=" + artifactId
+ ", version=" + version + ", classifier=" + classifier
+ ", type=" + type + "]";
}
diff --git a/src/main/java/org/apache/sling/slingstart/model/SSMConfiguration.java b/src/main/java/org/apache/sling/slingstart/model/SSMConfiguration.java
index 89ab2fe..fed5e88 100644
--- a/src/main/java/org/apache/sling/slingstart/model/SSMConfiguration.java
+++ b/src/main/java/org/apache/sling/slingstart/model/SSMConfiguration.java
@@ -61,7 +61,7 @@ public class SSMConfiguration {
@Override
public String toString() {
- return "CSConfiguration [pid=" + pid + ", factoryPid=" + factoryPid
+ return "SSMConfiguration [pid=" + pid + ", factoryPid=" + factoryPid
+ ", properties=" + properties + "]";
}
}
diff --git a/src/main/java/org/apache/sling/slingstart/model/SSMSubsystem.java b/src/main/java/org/apache/sling/slingstart/model/SSMDeliverable.java
similarity index 70%
rename from src/main/java/org/apache/sling/slingstart/model/SSMSubsystem.java
rename to src/main/java/org/apache/sling/slingstart/model/SSMDeliverable.java
index bacb0cd..1ff8a9d 100644
--- a/src/main/java/org/apache/sling/slingstart/model/SSMSubsystem.java
+++ b/src/main/java/org/apache/sling/slingstart/model/SSMDeliverable.java
@@ -25,28 +25,31 @@ import java.util.List;
import java.util.Map;
/**
- * A subsystem is a set of run modes and properties.
- * The properties can be used for specifying artifact versions.
- * At least it has a "global" run mode which describes the common subsystem.
+ * A deliverable is the central object.
+ * It consists of a set of features and properties.
+ * The properties can be used for specifying artifact versions, referencing them
+ * with ${propertyName}
+ *
+ * At least it has a "global" feature which contains artifacts that are always installed..
*/
-public class SSMSubsystem {
+public class SSMDeliverable {
- public final List<SSMRunMode> runModes = new ArrayList<SSMRunMode>();
+ public final List<SSMFeature> features = new ArrayList<SSMFeature>();
public Map<String, String> properties = new HashMap<String, String>();
- public SSMSubsystem() {
- this.runModes.add(new SSMRunMode()); // global run mode
+ public SSMDeliverable() {
+ this.features.add(new SSMFeature()); // global features
}
/**
- * Find the run mode if available
+ * Find the feature if available
* @param runModes
- * @return The run mode or null.
+ * @return The feature or null.
*/
- private SSMRunMode findRunMode(final String[] runModes) {
- SSMRunMode result = null;
- for(final SSMRunMode current : this.runModes) {
+ private SSMFeature findFeature(final String[] runModes) {
+ SSMFeature result = null;
+ for(final SSMFeature current : this.features) {
if ( runModes == null && current.runModes == null ) {
result = current;
break;
@@ -66,26 +69,26 @@ public class SSMSubsystem {
}
/**
- * Get the run mode if available
- * @return The run mode or null
+ * Get the feature if available
+ * @return The feature or null
*/
- public SSMRunMode getRunMode(final String runMode) {
- return findRunMode(new String[] {runMode});
+ public SSMFeature getRunMode(final String runMode) {
+ return findFeature(new String[] {runMode});
}
/**
- * Get or create the run mode.
+ * Get or create the feature.
*/
- public SSMRunMode getOrCreateRunMode(final String[] runModes) {
- SSMRunMode result = findRunMode(runModes);
+ public SSMFeature getOrCreateFeature(final String[] runModes) {
+ SSMFeature result = findFeature(runModes);
if ( result == null ) {
- result = new SSMRunMode();
+ result = new SSMFeature();
result.runModes = runModes;
- this.runModes.add(result);
- Collections.sort(this.runModes, new Comparator<SSMRunMode>() {
+ this.features.add(result);
+ Collections.sort(this.features, new Comparator<SSMFeature>() {
@Override
- public int compare(final SSMRunMode o1, final SSMRunMode o2) {
+ public int compare(final SSMFeature o1, final SSMFeature o2) {
if ( o1.runModes == null ) {
if ( o2.runModes == null ) {
return 0;
@@ -113,8 +116,8 @@ public class SSMSubsystem {
* @throws IllegalStateException
*/
public void validate() {
- for(final SSMRunMode runMode : this.runModes) {
- runMode.validate();
+ for(final SSMFeature f : this.features) {
+ f.validate();
}
}
@@ -149,19 +152,19 @@ public class SSMSubsystem {
}
/**
- * Merge two subsystems.
+ * Merge two deliverables.
*/
- public void merge(final SSMSubsystem other) {
- for(final SSMRunMode mode : other.runModes) {
- final SSMRunMode mergeRunMode = this.getOrCreateRunMode(mode.runModes);
- mergeRunMode.merge(mode);
+ public void merge(final SSMDeliverable other) {
+ for(final SSMFeature mode : other.features) {
+ final SSMFeature mergeFeature = this.getOrCreateFeature(mode.runModes);
+ mergeFeature.merge(mode);
}
this.properties.putAll(other.properties);
}
@Override
public String toString() {
- return "SSMSubsystem [runModes=" + runModes + ", properties="
+ return "SSMDeliverable [features=" + features + ", properties="
+ properties + "]";
}
}
diff --git a/src/main/java/org/apache/sling/slingstart/model/SSMRunMode.java b/src/main/java/org/apache/sling/slingstart/model/SSMFeature.java
similarity index 91%
rename from src/main/java/org/apache/sling/slingstart/model/SSMRunMode.java
rename to src/main/java/org/apache/sling/slingstart/model/SSMFeature.java
index 3479210..671ec19 100644
--- a/src/main/java/org/apache/sling/slingstart/model/SSMRunMode.java
+++ b/src/main/java/org/apache/sling/slingstart/model/SSMFeature.java
@@ -24,12 +24,17 @@ import java.util.List;
import java.util.Set;
/**
- * A run mode is a collection of
+ * A feature is a collection of
* - artifacts (through start levels)
* - configurations
* - settings
+ *
+ * A feature might be tied to run modes. Only if all run modes are active,
+ * this feature is active.
+ * In addition to custom, user defined run modes, special run modes exists.
+ * A special run mode name starts with a colon.
*/
-public class SSMRunMode {
+public class SSMFeature {
public static final String RUN_MODE_BASE = ":base";
@@ -89,7 +94,7 @@ public class SSMRunMode {
}
/**
- * Check if this run mode is active wrt the given set of active run modes.
+ * Check if this feature is active wrt the given set of active run modes.
*/
public boolean isActive(final Set<String> activeRunModes) {
boolean active = true;
@@ -105,7 +110,7 @@ public class SSMRunMode {
}
/**
- * Check whether this run mode is a special run mode
+ * Check whether this feature is a special one
*/
public boolean isSpecial() {
if ( runModes != null && runModes.length == 1 && runModes[0].startsWith(":") ) {
@@ -115,7 +120,7 @@ public class SSMRunMode {
}
/**
- * Check if this run mode is a specific, single run mode.
+ * Check if this feature is tied to a single specific run mode.
*/
public boolean isRunMode(final String mode) {
if ( mode == null && this.runModes == null ) {
@@ -158,9 +163,9 @@ public class SSMRunMode {
}
/**
- * Merge another run mode with this one.
+ * Merge another feature with this one.
*/
- public void merge(final SSMRunMode mode) {
+ public void merge(final SSMFeature mode) {
for(final SSMStartLevel sl : mode.startLevels) {
// search for duplicates in other start levels
for(final SSMArtifact artifact : sl.artifacts) {
@@ -221,7 +226,7 @@ public class SSMRunMode {
@Override
public String toString() {
- return "CSRunMode [runModes=" + Arrays.toString(runModes)
+ return "SSMFeature [runModes=" + Arrays.toString(runModes)
+ ", startLevels=" + startLevels + ", configurations="
+ configurations + ", settings=" + settings + "]";
}
diff --git a/src/main/java/org/apache/sling/slingstart/model/SSMSettings.java b/src/main/java/org/apache/sling/slingstart/model/SSMSettings.java
index 5b69dfc..69b6185 100644
--- a/src/main/java/org/apache/sling/slingstart/model/SSMSettings.java
+++ b/src/main/java/org/apache/sling/slingstart/model/SSMSettings.java
@@ -18,7 +18,7 @@ package org.apache.sling.slingstart.model;
/**
- * The settings of a subsystem.
+ * The settings of a feature.
*/
public class SSMSettings {
@@ -48,6 +48,6 @@ public class SSMSettings {
@Override
public String toString() {
- return "CSSettings [properties=" + properties + "]";
+ return "SSMSettings [properties=" + properties + "]";
}
}
diff --git a/src/main/java/org/apache/sling/slingstart/model/SSMStartLevel.java b/src/main/java/org/apache/sling/slingstart/model/SSMStartLevel.java
index ba60950..a254d0b 100644
--- a/src/main/java/org/apache/sling/slingstart/model/SSMStartLevel.java
+++ b/src/main/java/org/apache/sling/slingstart/model/SSMStartLevel.java
@@ -20,7 +20,8 @@ import java.util.ArrayList;
import java.util.List;
/**
- * A start level holds a set of bundles.
+ * A start level holds a set of artifacts.
+ * A valid start level is positive, start level 0 means the default OSGi start level.
*/
public class SSMStartLevel {
@@ -73,7 +74,7 @@ public class SSMStartLevel {
@Override
public String toString() {
- return "CSStartLevel [level=" + level + ", artifacts=" + artifacts
+ return "SSMStartLevel [level=" + level + ", artifacts=" + artifacts
+ "]";
}
}
diff --git a/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelReader.java b/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelReader.java
index 48b5554..3c678f0 100644
--- a/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelReader.java
+++ b/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelReader.java
@@ -28,9 +28,9 @@ import javax.xml.parsers.SAXParserFactory;
import org.apache.sling.slingstart.model.SSMArtifact;
import org.apache.sling.slingstart.model.SSMConfiguration;
-import org.apache.sling.slingstart.model.SSMRunMode;
+import org.apache.sling.slingstart.model.SSMDeliverable;
+import org.apache.sling.slingstart.model.SSMFeature;
import org.apache.sling.slingstart.model.SSMSettings;
-import org.apache.sling.slingstart.model.SSMSubsystem;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
@@ -46,25 +46,25 @@ public class XMLSSMModelReader {
public enum MODE {
INIT(null, null),
- SUBSYSTEM(INIT, "subsystem"),
+ DELIVERABLE(INIT, "deliverable"),
- PROPERTIES(SUBSYSTEM, "properties"),
+ PROPERTIES(DELIVERABLE, "properties"),
- STARTLEVEL(SUBSYSTEM, "startLevel"),
- ARTIFACT(SUBSYSTEM, "artifact"),
+ STARTLEVEL(DELIVERABLE, "startLevel"),
+ ARTIFACT(DELIVERABLE, "artifact"),
STARTLEVEL_ARTIFACT(STARTLEVEL, "artifact"),
- CONFIGURATION(SUBSYSTEM, "configuration"),
- SETTINGS(SUBSYSTEM, "settings"),
+ CONFIGURATION(DELIVERABLE, "configuration"),
+ SETTINGS(DELIVERABLE, "settings"),
- RUNMODE(SUBSYSTEM, "runMode"),
- RUNMODE_STARTLEVEL(RUNMODE, "startLevel"),
- RUNMODE_ARTIFACT(RUNMODE, "artifact"),
- RUNMODE_STARTLEVEL_ARTIFACT(RUNMODE_STARTLEVEL, "artifact"),
+ FEATURE(DELIVERABLE, "feature"),
+ FEATURE_STARTLEVEL(FEATURE, "startLevel"),
+ FEATURE_ARTIFACT(FEATURE, "artifact"),
+ FEATURE_STARTLEVEL_ARTIFACT(FEATURE_STARTLEVEL, "artifact"),
- RUNMODE_CONFIGURATION(RUNMODE, "configuration"),
- RUNMODE_SETTINGS(RUNMODE, "settings");
+ FEATURE_CONFIGURATION(FEATURE, "configuration"),
+ FEATURE_SETTINGS(FEATURE, "settings");
public final MODE fromMode;
public final String elementName;
@@ -80,10 +80,10 @@ public class XMLSSMModelReader {
* The reader is not closed.
* @throws IOException
*/
- public static SSMSubsystem read(final Reader reader)
+ public static SSMDeliverable read(final Reader reader)
throws IOException {
try {
- final SSMSubsystem result = new SSMSubsystem();
+ final SSMDeliverable result = new SSMDeliverable();
final SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
@@ -102,8 +102,8 @@ public class XMLSSMModelReader {
/** The namespace for the read xml elements. */
private String namespace;
- /** The run mode */
- private SSMRunMode runMode;
+ /** The current feature */
+ private SSMFeature feature;
/** Current startlevel */
private int startLevel;
@@ -118,13 +118,13 @@ public class XMLSSMModelReader {
final Attributes atts)
throws SAXException {
if ( this.mode == MODE.INIT ) {
- if ( MODE.SUBSYSTEM.elementName.equals(localName) ) {
+ if ( MODE.DELIVERABLE.elementName.equals(localName) ) {
this.namespace = uri;
- this.mode = MODE.SUBSYSTEM;
- this.runMode = result.getOrCreateRunMode(null);
+ this.mode = MODE.DELIVERABLE;
+ this.feature = result.getOrCreateFeature(null);
this.startLevel = 0;
} else {
- throw new SAXException("Unknown root element (" + localName + "). Document must start with " + MODE.SUBSYSTEM.elementName);
+ throw new SAXException("Unknown root element (" + localName + "). Document must start with " + MODE.DELIVERABLE.elementName);
}
} else {
if ( (uri == null && this.namespace == null) || (uri != null && uri.equals(this.namespace)) ) {
@@ -140,40 +140,40 @@ public class XMLSSMModelReader {
throw new SAXException("Unknown element " + localName);
}
- if ( this.mode == MODE.STARTLEVEL || this.mode == MODE.RUNMODE_STARTLEVEL) {
+ if ( this.mode == MODE.STARTLEVEL || this.mode == MODE.FEATURE_STARTLEVEL) {
int level = 0;
final String levelVal = atts.getValue("level");
if ( levelVal != null ) {
level = Integer.valueOf(levelVal);
}
this.startLevel = level;
- } else if ( this.mode == MODE.ARTIFACT || this.mode == MODE.RUNMODE_ARTIFACT || this.mode == MODE.STARTLEVEL_ARTIFACT || this.mode == MODE.RUNMODE_STARTLEVEL_ARTIFACT) {
+ } else if ( this.mode == MODE.ARTIFACT || this.mode == MODE.FEATURE_ARTIFACT || this.mode == MODE.STARTLEVEL_ARTIFACT || this.mode == MODE.FEATURE_STARTLEVEL_ARTIFACT) {
final SSMArtifact artifact = new SSMArtifact();
- this.runMode.getOrCreateStartLevel(this.startLevel).artifacts.add(artifact);
+ this.feature.getOrCreateStartLevel(this.startLevel).artifacts.add(artifact);
artifact.groupId = atts.getValue("groupId");
artifact.artifactId = atts.getValue("artifactId");
artifact.version = atts.getValue("version");
artifact.type = atts.getValue("type");
artifact.classifier = atts.getValue("classifier");
- } else if ( this.mode == MODE.CONFIGURATION || this.mode == MODE.RUNMODE_CONFIGURATION) {
+ } else if ( this.mode == MODE.CONFIGURATION || this.mode == MODE.FEATURE_CONFIGURATION) {
this.configuration = new SSMConfiguration();
this.configuration.pid = atts.getValue("pid");
this.configuration.factoryPid = atts.getValue("factory");
- this.runMode.configurations.add(this.configuration);
+ this.feature.configurations.add(this.configuration);
this.text = new StringBuilder();
- } else if ( this.mode == MODE.SETTINGS || this.mode == MODE.RUNMODE_SETTINGS) {
- if ( this.runMode.settings != null ) {
+ } else if ( this.mode == MODE.SETTINGS || this.mode == MODE.FEATURE_SETTINGS) {
+ if ( this.feature.settings != null ) {
throw new SAXException("Duplicate settings section");
}
- this.runMode.settings = new SSMSettings();
+ this.feature.settings = new SSMSettings();
this.text = new StringBuilder();
- } else if ( this.mode == MODE.RUNMODE ) {
+ } else if ( this.mode == MODE.FEATURE ) {
final String runMode = atts.getValue("modes");
if ( runMode == null || runMode.trim().length() == 0 ) {
throw new SAXException("Required attribute runModes missing for runMode element");
}
- this.runMode = result.getOrCreateRunMode(runMode.split(","));
+ this.feature = result.getOrCreateFeature(runMode.split(","));
this.startLevel = 0;
} else {
@@ -212,15 +212,15 @@ public class XMLSSMModelReader {
if ( !found ) {
throw new SAXException("Unknown element " + localName);
}
- if ( prevMode == MODE.STARTLEVEL || prevMode == MODE.RUNMODE_STARTLEVEL ) {
+ if ( prevMode == MODE.STARTLEVEL || prevMode == MODE.FEATURE_STARTLEVEL ) {
this.startLevel = 0;
- } else if ( prevMode == MODE.CONFIGURATION || prevMode == MODE.RUNMODE_CONFIGURATION ) {
+ } else if ( prevMode == MODE.CONFIGURATION || prevMode == MODE.FEATURE_CONFIGURATION ) {
this.configuration.properties = textValue;
this.configuration = null;
- } else if ( prevMode == MODE.SETTINGS || prevMode == MODE.RUNMODE_SETTINGS) {
- this.runMode.settings.properties = textValue;
- } else if ( prevMode == MODE.RUNMODE ) {
- this.runMode = result.getOrCreateRunMode(null);
+ } else if ( prevMode == MODE.SETTINGS || prevMode == MODE.FEATURE_SETTINGS) {
+ this.feature.settings.properties = textValue;
+ } else if ( prevMode == MODE.FEATURE ) {
+ this.feature = result.getOrCreateFeature(null);
this.startLevel = 0;
} else if ( prevMode == MODE.PROPERTIES ) {
final LineNumberReader reader = new LineNumberReader(new StringReader(textValue));
diff --git a/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelWriter.java b/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelWriter.java
index acced8d..1b73e7a 100644
--- a/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelWriter.java
+++ b/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelWriter.java
@@ -23,16 +23,16 @@ import java.util.Map;
import org.apache.sling.slingstart.model.SSMArtifact;
import org.apache.sling.slingstart.model.SSMConfiguration;
-import org.apache.sling.slingstart.model.SSMRunMode;
+import org.apache.sling.slingstart.model.SSMDeliverable;
+import org.apache.sling.slingstart.model.SSMFeature;
import org.apache.sling.slingstart.model.SSMStartLevel;
-import org.apache.sling.slingstart.model.SSMSubsystem;
/**
* Simple writer for the a model
*/
public class XMLSSMModelWriter {
- private static void printRunModeAttribute(final PrintWriter pw, final SSMRunMode rmd) {
+ private static void printRunModeAttribute(final PrintWriter pw, final SSMFeature rmd) {
if ( rmd.runModes != null && rmd.runModes.length > 0 ) {
pw.print(" modes=\"");
boolean first = true;
@@ -59,11 +59,11 @@ public class XMLSSMModelWriter {
* @param subystem
* @throws IOException
*/
- public static void write(final Writer writer, final SSMSubsystem subsystem)
+ public static void write(final Writer writer, final SSMDeliverable subsystem)
throws IOException {
final PrintWriter pw = new PrintWriter(writer);
pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- pw.println("<subsystem>");
+ pw.println("<deliverable>");
// properties
if ( subsystem.properties.size() > 0 ) {
@@ -79,18 +79,18 @@ public class XMLSSMModelWriter {
pw.print(INDENT);
pw.println("]]></properties>");
}
- for(final SSMRunMode runMode : subsystem.runModes) {
- // TODO - don't write out empty run modes
+ for(final SSMFeature feature : subsystem.features) {
+ // TODO - don't write out empty features
String indent = INDENT;
- if ( runMode.runModes != null ) {
+ if ( feature.runModes != null ) {
pw.print(indent);
- pw.print("<runMode");
- printRunModeAttribute(pw, runMode);
+ pw.print("<feature");
+ printRunModeAttribute(pw, feature);
pw.println(">");
indent = indent + INDENT;
}
- for(final SSMStartLevel startLevel : runMode.startLevels) {
+ for(final SSMStartLevel startLevel : feature.startLevels) {
if ( startLevel.artifacts.size() == 0 ) {
continue;
}
@@ -131,7 +131,7 @@ public class XMLSSMModelWriter {
}
}
- for(final SSMConfiguration config : runMode.configurations) {
+ for(final SSMConfiguration config : feature.configurations) {
pw.print(indent);
pw.print("<configuration ");
if ( config.factoryPid != null ) {
@@ -147,22 +147,22 @@ public class XMLSSMModelWriter {
pw.println("]]></configuration>");
}
- if ( runMode.settings != null ) {
+ if ( feature.settings != null ) {
pw.print(indent);
pw.println("<settings><![CDATA[");
- pw.println(runMode.settings.properties);
+ pw.println(feature.settings.properties);
pw.print(indent);
pw.println("]]></settings>");
}
- if ( runMode.runModes != null ) {
+ if ( feature.runModes != null ) {
indent = indent.substring(0, indent.length() - INDENT.length());
pw.print(indent);
- pw.println("</runMode>");
+ pw.println("</feature>");
}
}
- pw.println("</subsystem>");
+ pw.println("</deliverable>");
}
/** Escape xml text */
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.