You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2017/05/31 13:37:36 UTC
svn commit: r1797038 - in
/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature:
./ json/
Author: cziegeler
Date: Wed May 31 13:37:36 2017
New Revision: 1797038
URL: http://svn.apache.org/viewvc?rev=1797038&view=rev
Log:
Update javadocs
Modified:
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Application.java
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Artifact.java
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/ArtifactId.java
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Bundles.java
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Capability.java
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Configuration.java
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Extension.java
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/ExtensionType.java
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Feature.java
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Include.java
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Requirement.java
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/json/FeatureJSONReader.java
Modified: sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Application.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Application.java?rev=1797038&r1=1797037&r2=1797038&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Application.java (original)
+++ sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Application.java Wed May 31 13:37:36 2017
@@ -32,16 +32,22 @@ import java.util.List;
*/
public class Application {
+ /** Container for bundles. */
private final Bundles bundles = new Bundles();
+ /** List of configurations. */
private final List<Configuration> configurations = new ArrayList<>();
+ /** Map of framework properties. */
private final KeyValueMap<String> frameworkProperties = new KeyValueMap<>();
+ /** List of extensions. */
private final List<Extension> extensions = new ArrayList<>();
+ /** List of features. */
private final List<ArtifactId> features = new ArrayList<>();
+ /** The framework id. */
private ArtifactId framework;
/**
@@ -52,30 +58,57 @@ public class Application {
return this.bundles;
}
+ /**
+ * Get the configurations
+ * The list is modifiable.
+ * @return The list of configurations
+ */
public List<Configuration> getConfigurations() {
return this.configurations;
}
+ /**
+ * Get the framework properties
+ * The map is modifiable
+ * @return The map of properties
+ */
public KeyValueMap<String> getFrameworkProperties() {
return this.frameworkProperties;
}
+ /**
+ * Get the list of extensions
+ * The list is modifiable
+ * @return The list of extension
+ */
public List<Extension> getExtensions() {
return this.extensions;
}
+ /**
+ * Get the list of used features to build this application
+ * @return The list of features
+ */
+ public List<ArtifactId> getFeatureIds() {
+ return this.features;
+ }
+
+ /**
+ * Get the framework id
+ * @return The framework id or {@code null}
+ */
public ArtifactId getFramework() {
return framework;
}
+ /**
+ * Set the framework id
+ * @param framework The framework id
+ */
public void setFramework(ArtifactId framework) {
this.framework = framework;
}
- public List<ArtifactId> getFeatureIds() {
- return this.features;
- }
-
@Override
public String toString() {
return "Application [features=" + this.features
Modified: sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Artifact.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Artifact.java?rev=1797038&r1=1797037&r2=1797038&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Artifact.java (original)
+++ sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Artifact.java Wed May 31 13:37:36 2017
@@ -25,6 +25,7 @@ package org.apache.sling.feature;
*/
public class Artifact implements Comparable<Artifact> {
+ /** The artifact id. */
private final ArtifactId id;
/** Artifact metadata. */
Modified: sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/ArtifactId.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/ArtifactId.java?rev=1797038&r1=1797037&r2=1797038&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/ArtifactId.java (original)
+++ sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/ArtifactId.java Wed May 31 13:37:36 2017
@@ -20,8 +20,10 @@ import org.osgi.framework.Version;
/**
* An artifact identifier.
- * An artifact is described by it's Apache Maven coordinates consisting of group id, artifact id, and version.
- * In addition, the classifier and type can be specified as well. If no type is specified, "jar" is assumed.
+ *
+ * An artifact is described by it's Apache Maven coordinates consisting of group id,
+ * artifact id, and version. In addition, the classifier and type can be specified.
+ * If no type is specified, {@code jar} is assumed.
*/
public class ArtifactId implements Comparable<ArtifactId> {
@@ -61,6 +63,7 @@ public class ArtifactId implements Compa
this.groupId = groupId;
this.artifactId = artifactId;
this.version = version;
+ this.getOSGiVersion();
if ( "bundle".equals(type) || type == null || type.isEmpty() ) {
this.type = "jar";
} else {
@@ -196,7 +199,7 @@ public class ArtifactId implements Compa
/**
* Return the optional classifier.
- * @return The classifier or null.
+ * @return The classifier or {@code null}.
*/
public String getClassifier() {
return classifier;
@@ -223,7 +226,6 @@ public class ArtifactId implements Compa
* @param id The artifact id
* @return {@code true} if group id, artifact id, type and classifier equal
*/
-
public boolean isSame(final ArtifactId id) {
if ( this.groupId.equals(id.groupId)
&& this.artifactId.equals(id.artifactId)
@@ -241,7 +243,6 @@ public class ArtifactId implements Compa
/**
* Return the OSGi version
* @return The OSGi version
- * @throws IllegalArgumentException If the version is no valid OSGi version
*/
public Version getOSGiVersion() {
final int qualifier = this.version.indexOf('-');
Modified: sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Bundles.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Bundles.java?rev=1797038&r1=1797037&r2=1797038&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Bundles.java (original)
+++ sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Bundles.java Wed May 31 13:37:36 2017
@@ -27,6 +27,7 @@ import java.util.TreeMap;
*/
public class Bundles {
+ /** Map of bundles grouped by start level */
private final Map<Integer, List<Artifact>> startLevelMap = new TreeMap<>();
/**
@@ -38,12 +39,11 @@ public class Bundles {
return Collections.unmodifiableMap(this.startLevelMap);
}
- @Override
- public String toString() {
- return "Bundles [" + this.startLevelMap
- + "]";
- }
-
+ /**
+ * Add an artifact in the given start level.
+ * @param startLevel The start level
+ * @param bundle The bundle
+ */
public void add(final int startLevel, final Artifact bundle) {
List<Artifact> list = this.startLevelMap.get(startLevel);
if ( list == null ) {
@@ -53,6 +53,12 @@ public class Bundles {
list.add(bundle);
}
+ /**
+ * Remove the exact artifact.
+ * All start levels are searched for such an artifact. The first one found is removed.
+ * @param id The artifact id
+ * @return {@code true} if the artifact has been removed
+ */
public boolean removeExact(final ArtifactId id) {
for(final Map.Entry<Integer, List<Artifact>> entry : this.startLevelMap.entrySet()) {
for(final Artifact artifact : entry.getValue()) {
@@ -68,6 +74,12 @@ public class Bundles {
return false;
}
+ /**
+ * Remove the same artifact, neglecting the version.
+ * All start levels are searched for such an artifact. The first one found is removed.
+ * @param id The artifact id
+ * @return {@code true} if the artifact has been removed
+ */
public boolean removeSame(final ArtifactId id) {
for(final Map.Entry<Integer, List<Artifact>> entry : this.startLevelMap.entrySet()) {
for(final Artifact artifact : entry.getValue()) {
@@ -83,10 +95,18 @@ public class Bundles {
return false;
}
+ /**
+ * Clear the bundles map.
+ */
public void clear() {
this.startLevelMap.clear();
}
+ /**
+ * Get start level and artifact for the given id, neglecting the version
+ * @param id The artifact id
+ * @return A map entry with start level and artifact, {@code null} otherwise
+ */
public Map.Entry<Integer, Artifact> getSame(final ArtifactId id) {
for(final Map.Entry<Integer, List<Artifact>> entry : this.startLevelMap.entrySet()) {
for(final Artifact artifact : entry.getValue()) {
@@ -114,7 +134,12 @@ public class Bundles {
return null;
}
- public boolean contains(final ArtifactId id) {
+ /**
+ * Checks whether the exact artifact is available
+ * @param id The artifact id.
+ * @return {@code true} if the artifact exists
+ */
+ public boolean containsExact(final ArtifactId id) {
for(final Map.Entry<Integer, List<Artifact>> entry : this.startLevelMap.entrySet()) {
for(final Artifact artifact : entry.getValue()) {
if ( artifact.getId().equals(id)) {
@@ -124,4 +149,26 @@ public class Bundles {
}
return false;
}
+
+ /**
+ * Checks whether the same artifact is available, neglecting the version
+ * @param id The artifact id.
+ * @return {@code true} if the artifact exists
+ */
+ public boolean containsSame(final ArtifactId id) {
+ for(final Map.Entry<Integer, List<Artifact>> entry : this.startLevelMap.entrySet()) {
+ for(final Artifact artifact : entry.getValue()) {
+ if ( artifact.getId().isSame(id)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return "Bundles [" + this.startLevelMap
+ + "]";
+ }
}
Modified: sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Capability.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Capability.java?rev=1797038&r1=1797037&r2=1797038&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Capability.java (original)
+++ sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Capability.java Wed May 31 13:37:36 2017
@@ -16,26 +16,57 @@
*/
package org.apache.sling.feature;
+/**
+ * A capability of a feature.
+ * The capability is modeled after an OSGi capability: it
+ * belongs to a namespace and might have attributes and / or
+ * directives.
+ */
public class Capability {
+ /** The namspace. */
private final String namespace;
+ /** Map of attributes. */
private final KeyValueMap<String> attributes = new KeyValueMap<>();
+ /** Map of directives. */
private final KeyValueMap<String> directives = new KeyValueMap<>();
+ /**
+ * Create a new Capability.
+ * @param namespace The namespace
+ * @throws IllegalArgumentException If namespace is {@code null}.
+ */
public Capability(final String namespace) {
+ if ( namespace == null ) {
+ throw new IllegalArgumentException("namespace must not be null.");
+ }
this.namespace = namespace;
}
+ /**
+ * The namespace
+ * @return The namespace
+ */
public String getNamespace() {
return namespace;
}
+ /**
+ * Get the map of attributes.
+ * The map is modifiable.
+ * @return The map of attributes.
+ */
public KeyValueMap<String> getAttributes() {
return attributes;
}
+ /**
+ * Get the map of directives.
+ * The map is modifiable.
+ * @return The map of directives.
+ */
public KeyValueMap<String> getDirectives() {
return directives;
}
Modified: sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Configuration.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Configuration.java?rev=1797038&r1=1797037&r2=1797038&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Configuration.java (original)
+++ sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Configuration.java Wed May 31 13:37:36 2017
@@ -22,8 +22,10 @@ import java.util.Hashtable;
/**
* A configuration has either
- * - a pid
- * - or a factory pid and a name (pid)
+ * <ul>
+ * <li>a pid
+ * <li>or a factory pid and a name
+ * <ul>
* and properties.
*/
public class Configuration
@@ -110,6 +112,10 @@ public class Configuration
return this.factoryPid;
}
+ /**
+ * Return the name for a factory configuration.
+ * @return The name or {@code null}.
+ */
public String getName() {
if ( this.isFactoryConfiguration() ) {
return this.pid;
@@ -117,6 +123,10 @@ public class Configuration
return null;
}
+ /**
+ * Check whether this is a factory configuration
+ * @return {@code true} if it is a factory configuration
+ */
public boolean isFactoryConfiguration() {
return this.factoryPid != null;
}
Modified: sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Extension.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Extension.java?rev=1797038&r1=1797037&r2=1797038&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Extension.java (original)
+++ sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Extension.java Wed May 31 13:37:36 2017
@@ -20,7 +20,14 @@ import java.util.ArrayList;
import java.util.List;
/**
- * Extension
+ * An Extension can either be of type
+ * <ul>
+ * <li>Artifacts : it contains a list of artifacts
+ * <li>Text : it contains text
+ * <li>JSON : it contains a blob of JSON
+ * </ul>
+ *
+ * @see ExtensionType
*/
public class Extension {
Modified: sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/ExtensionType.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/ExtensionType.java?rev=1797038&r1=1797037&r2=1797038&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/ExtensionType.java (original)
+++ sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/ExtensionType.java Wed May 31 13:37:36 2017
@@ -17,7 +17,7 @@
package org.apache.sling.feature;
/**
- * Constants for common feature types.
+ * Enumeration for {@link Extension} types.
*/
public enum ExtensionType {
Modified: sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Feature.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Feature.java?rev=1797038&r1=1797037&r2=1797038&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Feature.java (original)
+++ sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Feature.java Wed May 31 13:37:36 2017
@@ -25,8 +25,8 @@ import java.util.List;
* <li>A unique id {@link ArtifactId}
* <li>Bundles
* <li>Configurations
- * <li>framework properties
- * <li>requirements and capabilities
+ * <li>Framework properties
+ * <li>Requirements and capabilities
* <li>Includes
* <li>Extensions
* </ul>
Modified: sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Include.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Include.java?rev=1797038&r1=1797037&r2=1797038&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Include.java (original)
+++ sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Include.java Wed May 31 13:37:36 2017
@@ -22,7 +22,13 @@ import java.util.List;
import java.util.Map;
/**
- * A include is an inclusion of a feature with optional removals
+ * A include is an inclusion of a feature with optional removals of
+ * <ul>
+ * <li>Configurations / configuration properties
+ * <li>Bundles
+ * <li>Framework properties
+ * <li>Extensions or artifacts from extensions
+ * </ul>
*/
public class Include implements Comparable<Include> {
Modified: sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Requirement.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Requirement.java?rev=1797038&r1=1797037&r2=1797038&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Requirement.java (original)
+++ sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Requirement.java Wed May 31 13:37:36 2017
@@ -16,26 +16,57 @@
*/
package org.apache.sling.feature;
+/**
+ * A requirement for a feature.
+ * The requirement is modeled after an OSGi requirement: it
+ * belongs to a namespace and might have attributes and / or
+ * directives.
+ */
public class Requirement {
+ /** The namspace. */
private final String namespace;
+ /** Map of attributes. */
private final KeyValueMap<String> attributes = new KeyValueMap<>();
+ /** Map of directives. */
private final KeyValueMap<String> directives = new KeyValueMap<>();
+ /**
+ * Create a new Requirement.
+ * @param namespace The namespace
+ * @throws IllegalArgumentException If namespace is {@code null}.
+ */
public Requirement(final String namespace) {
+ if ( namespace == null ) {
+ throw new IllegalArgumentException("namespace must not be null.");
+ }
this.namespace = namespace;
}
+ /**
+ * The namespace
+ * @return The namespace
+ */
public String getNamespace() {
return namespace;
}
+ /**
+ * Get the map of attributes.
+ * The map is modifiable.
+ * @return The map of attributes.
+ */
public KeyValueMap<String> getAttributes() {
return attributes;
}
+ /**
+ * Get the map of directives.
+ * The map is modifiable.
+ * @return The map of directives.
+ */
public KeyValueMap<String> getDirectives() {
return directives;
}
Modified: sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/json/FeatureJSONReader.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/json/FeatureJSONReader.java?rev=1797038&r1=1797037&r2=1797038&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/json/FeatureJSONReader.java (original)
+++ sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/json/FeatureJSONReader.java Wed May 31 13:37:36 2017
@@ -454,7 +454,7 @@ public class FeatureJSONReader {
final List<Artifact> list = new ArrayList<>();
readArtifacts("startLevel", "bundle", list, val);
for(final Artifact a : list) {
- if ( this.feature.getBundles().contains(a.getId()) ) {
+ if ( this.feature.getBundles().containsSame(a.getId()) ) {
throw new IOException(this.exceptionPrefix + "Duplicate bundle " + a.getId().toMvnId());
}
this.feature.getBundles().add(startLevel, a);