You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by si...@apache.org on 2019/04/01 13:34:55 UTC

[sling-whiteboard] branch master updated: [api-regions] initial checkin of api-regions APIs proposal

This is an automated email from the ASF dual-hosted git repository.

simonetripodi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 242e99c  [api-regions] initial checkin of api-regions APIs proposal
     new 1e16953  Merge branch 'master' of github.com:apache/sling-whiteboard
242e99c is described below

commit 242e99cdf2ab342952c503edc517832d57a82fc0
Author: Simo Tripodi <st...@adobe.com>
AuthorDate: Mon Apr 1 15:34:26 2019 +0200

    [api-regions] initial checkin of api-regions APIs proposal
---
 feature-api-regions/CODE_OF_CONDUCT.md             |  22 +++
 feature-api-regions/CONTRIBUTING.md                |  24 +++
 feature-api-regions/LICENSE                        | 201 +++++++++++++++++++++
 feature-api-regions/README.md                      | 164 +++++++++++++++++
 feature-api-regions/pom.xml                        |  76 ++++++++
 .../apache/sling/feature/apiregions/ApiRegion.java | 184 +++++++++++++++++++
 .../sling/feature/apiregions/ApiRegions.java       |  61 +++++++
 .../sling/feature/apiregions/JoinedIterator.java   |  54 ++++++
 .../apiregions/io/json/ApiRegionsJSONParser.java   | 137 ++++++++++++++
 .../io/json/ApiRegionsJSONSerializer.java          |  71 ++++++++
 .../feature/apiregions/io/json/JSONConstants.java  |  27 +++
 .../feature/apiregions/io/json/package-info.java   |  21 +++
 .../sling/feature/apiregions/package-info.java     |  21 +++
 .../sling/feature/apiregions/ApiRegionTest.java    | 109 +++++++++++
 .../sling/feature/apiregions/ApiRegionsTest.java   | 106 +++++++++++
 .../io/json/ApiRegionsJSONParserTest.java          | 101 +++++++++++
 .../io/json/ApiRegionsJSONSerializerTest.java      |  83 +++++++++
 17 files changed, 1462 insertions(+)

diff --git a/feature-api-regions/CODE_OF_CONDUCT.md b/feature-api-regions/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..0fa18e5
--- /dev/null
+++ b/feature-api-regions/CODE_OF_CONDUCT.md
@@ -0,0 +1,22 @@
+<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
+Apache Software Foundation Code of Conduct
+====
+
+Being an Apache project, Apache Sling adheres to the Apache Software Foundation's [Code of Conduct](https://www.apache.org/foundation/policies/conduct.html).
diff --git a/feature-api-regions/CONTRIBUTING.md b/feature-api-regions/CONTRIBUTING.md
new file mode 100644
index 0000000..ac82a1a
--- /dev/null
+++ b/feature-api-regions/CONTRIBUTING.md
@@ -0,0 +1,24 @@
+<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
+Contributing
+====
+
+Thanks for choosing to contribute!
+
+You will find all the necessary details about how you can do this at https://sling.apache.org/contributing.html.
diff --git a/feature-api-regions/LICENSE b/feature-api-regions/LICENSE
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/feature-api-regions/LICENSE
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/feature-api-regions/README.md b/feature-api-regions/README.md
new file mode 100644
index 0000000..4c4f423
--- /dev/null
+++ b/feature-api-regions/README.md
@@ -0,0 +1,164 @@
+[<img src="http://sling.apache.org/res/logos/sling.png"/>](http://sling.apache.org)
+
+# Apache Sling Feature Model API Regions
+
+This small set of APIs aims to provide to Apache Sling users an easy-to-use layer to manipulate
+`api-regions` JSON extensions.
+
+## Motivation
+
+The `api-regions` extensions gained popularity via the [APIs Jar MOJO](https://github.com/apache/sling-slingfeature-maven-plugin/blob/master/src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java) that, for each selected Apache Sling Feature Model file, generates multiple Java Archives, one for each declared section in the `api-regions` extension, containing declared APIs in each region.
+
+During the time, business intelligence on top of `api-regions` extension will be required, i.e. analyzing the evolution of each region in each Apache Sling Feature Model file, to see what's removed and what's added (just to mention few operations), so having a single APIs set to manipulate `api-regions` will be helpful avoiding code redundancies across multiple applications.
+
+## Quick how-to
+
+`api-regions` extensions are generally obtained by parsing the JSON content in the `api-regions` declaration, i.e. given the following sample region:
+
+```json
+[
+  {
+    "name": "base",
+    "exports": [
+      "org.apache.felix.inventory",
+      "org.apache.felix.metatype"
+    ]
+  },
+  {
+    "name": "extended",
+    "exports": [
+      "org.apache.felix.scr.component",
+      "org.apache.felix.scr.info"
+    ]
+  }
+]
+```
+
+then obtaining simple APIs will look like:
+
+```java
+import org.apache.sling.feature.Feature;
+import org.apache.sling.feature.apiregions.ApiRegion;
+import org.apache.sling.feature.apiregions.ApiRegions;
+import org.apache.sling.feature.apiregions.io.json.ApiRegionsJSONParser;
+
+...
+
+Feature feature = [somehow obtained]
+// parseApiRegions method can be invoked also passing a org.apache.sling.feature.Extension instance
+// or a String which represents the JSON structure of an api-regions extension.
+ApiRegions regions = ApiRegionsJSONParser.parseApiRegions(feature);
+
+for (ApiRegion region : regions) {
+    System.out.println("-" + region.getName());
+
+    for (String api : region) {
+        System.out.println(" * " + api);
+    }
+
+    System.out.println("--------");
+}
+```
+
+That code will output:
+
+```
+- base
+ * org.apache.felix.inventory
+ * org.apache.felix.metatype
+--------
+- extended
+ * org.apache.felix.scr.component
+ * org.apache.felix.scr.info
+ * org.apache.felix.inventory
+ * org.apache.felix.metatype
+--------
+```
+
+## Note
+
+Pleas take in account that each declared region in `api-regions` inherits declared APIs from the previous declared region.
+
+
+## APIs to create regions
+
+Users can also use APIs to manually declare their `api-regions` instances:
+
+```java
+omit imports for brevity;
+
+...
+
+ApiRegions apiRegions = new ApiRegions();
+ApiRegion granpa = apiRegions.addNewRegion("granpa");
+granpa.addApi("org.apache.sling.feature.apiregions");
+
+ApiRegion father = apiRegions.addNewRegion("father");
+father.addApi("org.apache.sling.feature.apiregions.io");
+
+ApiRegion child = apiRegions.addNewRegion("child");
+child.addApi("org.apache.sling.feature.apiregions.io.json");
+
+for (ApiRegion region : apiRegions) {
+    System.out.println("-" + region.getName());
+
+    for (String api : region) {
+        System.out.println(" * " + api);
+    }
+
+    System.out.println("--------");
+}
+```
+
+That code will output:
+
+```
+- granpa
+ * org.apache.sling.feature.apiregions
+--------
+- father
+ * org.apache.sling.feature.apiregions
+ * org.apache.sling.feature.apiregions.io
+--------
+- child
+ * org.apache.sling.feature.apiregions
+ * org.apache.sling.feature.apiregions.io
+ * org.apache.sling.feature.apiregions.io.json
+--------
+```
+
+JSON serialization is available as well:
+
+```java
+import org.apache.sling.feature.apiregions.io.json.ApiRegionsJSONSerializer
+
+...
+
+ApiRegionsJSONSerializer.serializeApiRegions(ApiRegions, System.out);
+```
+
+that will output:
+
+```json
+[
+  {
+    "name":"granpa",
+    "exports":[
+      "org.apache.sling.feature.apiregions"
+    ]
+  },
+  {
+    "name":"father",
+    "exports":[
+      "org.apache.sling.feature.apiregions.io"
+    ]
+  },
+  {
+    "name":"child",
+    "exports":[
+      "org.apache.sling.feature.apiregions.io.json"
+    ]
+  }
+]
+
+```
diff --git a/feature-api-regions/pom.xml b/feature-api-regions/pom.xml
new file mode 100644
index 0000000..cdf876a
--- /dev/null
+++ b/feature-api-regions/pom.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with this
+ work for additional information regarding copyright ownership. The ASF
+ licenses this file to You under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ License for the specific language governing permissions and limitations under
+ the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.sling</groupId>
+    <artifactId>sling</artifactId>
+    <version>34</version>
+    <relativePath />
+  </parent>
+
+  <artifactId>org.apache.sling.feature.apiregions</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+
+  <name>Apache Sling Feature Model API Regions</name>
+  <description>Apache Sling Feature Model API Regions</description>
+
+  <properties>
+    <sling.java.version>8</sling.java.version>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <!--
+     | Sling Feature Model libraries
+    -->
+    <dependency>
+      <groupId>org.apache.sling</groupId>
+      <artifactId>org.apache.sling.feature</artifactId>
+      <version>1.0.0</version>
+      <scope>provided</scope>
+    </dependency>
+
+    <!-- Parse the JSON api-region extension -->
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-json_1.0_spec</artifactId>
+      <version>1.0-alpha-1</version>
+      <scope>provided</scope>
+    </dependency>
+
+    <!--
+     | Test only dependencies
+    -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.johnzon</groupId>
+      <artifactId>johnzon-core</artifactId>
+      <version>1.0.0</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>
diff --git a/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/ApiRegion.java b/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/ApiRegion.java
new file mode 100644
index 0000000..0dd60fe
--- /dev/null
+++ b/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/ApiRegion.java
@@ -0,0 +1,184 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.feature.apiregions;
+
+import static java.util.Objects.requireNonNull;
+
+import java.util.Formatter;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+public final class ApiRegion implements Iterable<String> {
+
+    private static final Pattern PACKAGE_NAME_VALIDATION =
+            Pattern.compile("^[a-z]+(\\.[a-zA-Z_][a-zA-Z0-9_]*)*$");
+
+    private static final Set<String> KEYWORDS = new HashSet<>();
+
+    static {
+        KEYWORDS.add("abstract");
+        KEYWORDS.add("continue");
+        KEYWORDS.add("for");
+        KEYWORDS.add("new");
+        KEYWORDS.add("switch");
+        KEYWORDS.add("assert");
+        KEYWORDS.add("default");
+        KEYWORDS.add("package");
+        KEYWORDS.add("synchronized");
+        KEYWORDS.add("boolean");
+        KEYWORDS.add("do");
+        KEYWORDS.add("if");
+        KEYWORDS.add("private");
+        KEYWORDS.add("this");
+        KEYWORDS.add("break");
+        KEYWORDS.add("double");
+        KEYWORDS.add("implements");
+        KEYWORDS.add("protected");
+        KEYWORDS.add("throw");
+        KEYWORDS.add("byte");
+        KEYWORDS.add("else");
+        KEYWORDS.add("import");
+        KEYWORDS.add("public");
+        KEYWORDS.add("throws");
+        KEYWORDS.add("case");
+        KEYWORDS.add("enum");
+        KEYWORDS.add("instanceof");
+        KEYWORDS.add("return");
+        KEYWORDS.add("transient");
+        KEYWORDS.add("catch");
+        KEYWORDS.add("extends");
+        KEYWORDS.add("int");
+        KEYWORDS.add("short");
+        KEYWORDS.add("try");
+        KEYWORDS.add("char");
+        KEYWORDS.add("final");
+        KEYWORDS.add("interface");
+        KEYWORDS.add("static");
+        KEYWORDS.add("void");
+        KEYWORDS.add("class");
+        KEYWORDS.add("finally");
+        KEYWORDS.add("long");
+        KEYWORDS.add("strictfp");
+        KEYWORDS.add("volatile");
+        KEYWORDS.add("float");
+        KEYWORDS.add("native");
+        KEYWORDS.add("super");
+        KEYWORDS.add("while");
+    }
+
+    private final Set<String> apis = new HashSet<>();
+
+    private final String name;
+
+    private final ApiRegion parent;
+
+    protected ApiRegion(String name, ApiRegion parent) {
+        this.name = name;
+        this.parent = parent;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public ApiRegion getParent() {
+        return parent;
+    }
+
+    public void addApis(Iterable<String> apis) {
+        requireNonNull(apis, "Impossible to import null APIs");
+
+        for (String api : apis) {
+            addApi(api);
+        }
+    }
+
+    public void addApi(String api) {
+        // ignore null, empty package and non well-formed packages names, i.e. javax.jms.doc-files
+        if (api == null
+                || api.isEmpty()
+                || !PACKAGE_NAME_VALIDATION.matcher(api).matches()) {
+            // ignore it
+            return;
+        }
+
+        // ignore packages with reserved keywords, i.e. org.apache.commons.lang.enum
+        for (String apiPart : api.split("\\.")) {
+            if (KEYWORDS.contains(apiPart)) {
+                return;
+            }
+        }
+
+        apis.add(api);
+    }
+
+    public boolean contains(String api) {
+        if (api == null || api.isEmpty()) {
+            return false;
+        }
+
+        boolean found = false;
+
+        if (parent != null) {
+            found = found || parent.contains(api);
+        }
+
+        return found || apis.contains(api);
+    }
+
+    @Override
+    public Iterator<String> iterator() {
+        List<Iterable<String>> iterators = new LinkedList<>();
+
+        ApiRegion region = this;
+        while (region != null) {
+            iterators.add(region.apis);
+            region = region.getParent();
+        }
+
+        return new JoinedIterator<String>(iterators.iterator());
+    }
+
+    public Iterable<String> getExports() {
+        return apis;
+    }
+
+    @Override
+    public String toString() {
+        Formatter formatter = new Formatter();
+        formatter.format("Region '%s'", name);
+
+        if (parent != null) {
+            formatter.format(" inherits from %n")
+                     .format(parent.toString());
+        }
+
+        for (String api : apis) {
+            formatter.format("%n * %s", api);
+        }
+
+        String toString = formatter.toString();
+        formatter.close();
+
+        return toString;
+    }
+
+}
diff --git a/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/ApiRegions.java b/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/ApiRegions.java
new file mode 100644
index 0000000..9fe5831
--- /dev/null
+++ b/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/ApiRegions.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.feature.apiregions;
+
+import static java.util.Objects.requireNonNull;
+
+import java.util.Iterator;
+import java.util.Stack;
+
+public final class ApiRegions implements Iterable<ApiRegion> {
+
+    private final Stack<ApiRegion> regions = new Stack<>();
+
+    public ApiRegion addNewRegion(String regionName) {
+        requireNonNull(regionName, "Impossible to create a new API Region without specifying the name");
+
+        if (regionName.isEmpty()) {
+            throw new IllegalArgumentException("Impossible to create a new API Region without specifying a valid name");
+        }
+
+        ApiRegion parent = regions.isEmpty() ? null : regions.peek(); // null parent means 'root' in the hierarchy
+        ApiRegion newRegion = new ApiRegion(regionName, parent);
+        return regions.push(newRegion);
+    }
+
+    public ApiRegion getByName(String regionName) {
+        requireNonNull(regionName, "Impossible to get an API Region without specifying a valid name");
+
+        if (regionName.isEmpty()) {
+            return null;
+        }
+
+        for (ApiRegion region : regions) {
+            if (regionName.equals(region.getName())) {
+                return region;
+            }
+        }
+
+        return null;
+    }
+
+    @Override
+    public Iterator<ApiRegion> iterator() {
+        return regions.iterator();
+    }
+
+}
diff --git a/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/JoinedIterator.java b/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/JoinedIterator.java
new file mode 100644
index 0000000..1ab03eb
--- /dev/null
+++ b/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/JoinedIterator.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.feature.apiregions;
+
+import java.util.Iterator;
+
+final class JoinedIterator<E> implements Iterator<E> {
+
+    private final Iterator<Iterable<E>> iterator;
+
+    private Iterator<E> currentIterator;
+
+    public JoinedIterator(Iterator<Iterable<E>> iterator) {
+        this.iterator = iterator;
+        currentIterator = null;
+    }
+
+    @Override
+    public boolean hasNext() {
+        if (currentIterator == null) {
+            if (iterator.hasNext()) {
+                currentIterator = iterator.next().iterator();
+            } else {
+                return false;
+            }
+        }
+
+        while (!currentIterator.hasNext() && iterator.hasNext()) {
+            currentIterator = iterator.next().iterator();
+        }
+
+        return currentIterator.hasNext();
+    }
+
+    @Override
+    public E next() {
+        return currentIterator.next();
+    }
+
+}
diff --git a/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/io/json/ApiRegionsJSONParser.java b/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/io/json/ApiRegionsJSONParser.java
new file mode 100644
index 0000000..df8add1
--- /dev/null
+++ b/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/io/json/ApiRegionsJSONParser.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.feature.apiregions.io.json;
+
+import static org.apache.sling.feature.ExtensionType.JSON;
+
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.json.Json;
+import javax.json.stream.JsonParser;
+import javax.json.stream.JsonParser.Event;
+
+import static java.util.Objects.requireNonNull;
+
+import org.apache.sling.feature.Extension;
+import org.apache.sling.feature.Extensions;
+import org.apache.sling.feature.Feature;
+import org.apache.sling.feature.apiregions.ApiRegion;
+import org.apache.sling.feature.apiregions.ApiRegions;
+
+public final class ApiRegionsJSONParser implements JSONConstants {
+
+    private ApiRegionsJSONParser() {
+        // this class must not be instantiated from outside
+    }
+
+    public static ApiRegions parseApiRegions(Feature feature) {
+        requireNonNull(feature, "Impossible to extract api-regions from a null feature");
+
+        Extensions extensions = feature.getExtensions();
+        Extension apiRegionsExtension = extensions.getByName(API_REGIONS_KEY);
+        if (apiRegionsExtension == null) {
+            return null;
+        }
+
+        return parseApiRegions(apiRegionsExtension);
+    }
+
+    public static ApiRegions parseApiRegions(Extension apiRegionsExtension) {
+        requireNonNull(apiRegionsExtension, "Impossible to extract api-regions from a null extension");
+
+        if (!API_REGIONS_KEY.equals(apiRegionsExtension.getName())) {
+            throw new IllegalArgumentException(apiRegionsExtension.getName() + " is not a recognised api-regions extension");
+        }
+        if (JSON != apiRegionsExtension.getType()) {
+            throw new IllegalArgumentException("api-regions extension must be of JSON type, "
+                                               + apiRegionsExtension.getType()
+                                               + " is not a recognised as valid api-regions extension");
+        }
+
+        return parseApiRegions(apiRegionsExtension.getJSON());
+    }
+
+    public static ApiRegions parseApiRegions(String jsonRepresentation) {
+        requireNonNull(jsonRepresentation, "Impossible to extract api-regions from a null JSON representation");
+
+        ApiRegions apiRegions = new ApiRegions();
+
+        // pointers
+        Event event;
+        String regionName;
+        Collection<String> apis;
+
+        JsonParser parser = Json.createParser(new StringReader(jsonRepresentation));
+        if (Event.START_ARRAY != parser.next()) {
+            throw new IllegalStateException("Expected 'api-region' element to start with an Array: "
+                                             + parser.getLocation());
+        }
+
+        while (Event.END_ARRAY != (event = parser.next())) {
+            if (Event.START_OBJECT != event) {
+                throw new IllegalStateException("Expected 'api-region' data to start with an Object: "
+                                                + parser.getLocation());
+            }
+
+            regionName = null;
+            apis = null;
+
+            while (Event.END_OBJECT != (event = parser.next())) {
+                if (Event.KEY_NAME == event) {
+                    switch (parser.getString()) {
+                        case NAME_KEY:
+                            parser.next();
+                            regionName = parser.getString();
+                            break;
+
+                        case EXPORTS_KEY:
+                            // start array
+                            parser.next();
+
+                            apis = new ArrayList<>();
+
+                            while (parser.hasNext() && Event.VALUE_STRING == parser.next()) {
+                                String api = parser.getString();
+                                // skip comments
+                                if ('#' != api.charAt(0)) {
+                                    apis.add(api);
+                                }
+                            }
+
+                            break;
+
+                        default:
+                            break;
+                    }
+                }
+            }
+
+            if (regionName != null
+                    && !regionName.isEmpty()
+                    && apis != null
+                    && !apis.isEmpty()) {
+                ApiRegion apiRegion = apiRegions.addNewRegion(regionName);
+                apiRegion.addApis(apis);
+            }
+        }
+
+        return apiRegions;
+    }
+
+}
diff --git a/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/io/json/ApiRegionsJSONSerializer.java b/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/io/json/ApiRegionsJSONSerializer.java
new file mode 100644
index 0000000..de073be
--- /dev/null
+++ b/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/io/json/ApiRegionsJSONSerializer.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.feature.apiregions.io.json;
+
+import static java.util.Objects.requireNonNull;
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.Collections;
+
+import javax.json.Json;
+import javax.json.stream.JsonGenerator;
+import javax.json.stream.JsonGeneratorFactory;
+
+import org.apache.sling.feature.apiregions.ApiRegion;
+import org.apache.sling.feature.apiregions.ApiRegions;
+
+public final class ApiRegionsJSONSerializer implements JSONConstants {
+
+    private static final JsonGeneratorFactory GENERATOR_FACTORY = Json.createGeneratorFactory(Collections.singletonMap(JsonGenerator.PRETTY_PRINTING, true));
+
+    private ApiRegionsJSONSerializer() {
+        // this class must not be instantiated from outside
+    }
+
+    public static void serializeApiRegions(ApiRegions apiRegions, OutputStream output) {
+        requireNonNull(output, "Impossible to serialize api-regions to a null stream");
+        serializeApiRegions(apiRegions, new OutputStreamWriter(output));
+    }
+
+    public static void serializeApiRegions(ApiRegions apiRegions, Writer writer) {
+        requireNonNull(apiRegions, "Impossible to serialize null api-regions");
+        requireNonNull(writer, "Impossible to serialize api-regions to a null stream");
+
+        JsonGenerator generator = GENERATOR_FACTORY.createGenerator(writer);
+        generator.writeStartArray();
+
+        for (ApiRegion apiRegion : apiRegions) {
+            generator.writeStartObject();
+
+            generator.write(NAME_KEY, apiRegion.getName());
+
+            generator.writeStartArray(EXPORTS_KEY);
+            for (String api : apiRegion.getExports()) {
+                generator.write(api);
+            }
+            generator.writeEnd();
+
+            generator.writeEnd();
+        }
+
+        generator.writeEnd();
+        generator.close();
+    }
+
+}
diff --git a/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/io/json/JSONConstants.java b/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/io/json/JSONConstants.java
new file mode 100644
index 0000000..93bdeb2
--- /dev/null
+++ b/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/io/json/JSONConstants.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.feature.apiregions.io.json;
+
+interface JSONConstants {
+
+    public static final String API_REGIONS_KEY = "api-regions";
+
+    public static final String NAME_KEY = "name";
+
+    public static final String EXPORTS_KEY = "exports";
+
+}
diff --git a/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/io/json/package-info.java b/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/io/json/package-info.java
new file mode 100644
index 0000000..36a97da
--- /dev/null
+++ b/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/io/json/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+/**
+ * <code>api-regions</code> Parser APIs.
+ */
+package org.apache.sling.feature.apiregions.io.json;
diff --git a/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/package-info.java b/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/package-info.java
new file mode 100644
index 0000000..a69b40f
--- /dev/null
+++ b/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+/**
+ * Basic <code>api-regions</code> APIs.
+ */
+package org.apache.sling.feature.apiregions;
diff --git a/feature-api-regions/src/test/java/org/apache/sling/feature/apiregions/ApiRegionTest.java b/feature-api-regions/src/test/java/org/apache/sling/feature/apiregions/ApiRegionTest.java
new file mode 100644
index 0000000..e0c78aa
--- /dev/null
+++ b/feature-api-regions/src/test/java/org/apache/sling/feature/apiregions/ApiRegionTest.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.feature.apiregions;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.Test;
+
+public class ApiRegionTest {
+
+    @Test
+    public void ignoreNullPackageName() {
+        ingnoreApi(null);
+    }
+
+    @Test
+    public void ignoreEmptyPackageName() {
+        ingnoreApi("");
+    }
+
+    @Test
+    public void ignoreInvalidPackageName() {
+        ingnoreApi("1inv4l1d.package");
+    }
+
+    @Test
+    public void ignoreReservedWords() {
+        ingnoreApi("org.apache.commons.lang.enum");
+    }
+
+    private void ingnoreApi(String api) {
+        ApiRegion testRegion = new ApiRegion(getClass().getName(), null);
+        testRegion.addApi(api);
+        assertFalse(testRegion.contains(api));
+    }
+
+    @Test
+    public void inheritanceCheck() {
+        ApiRegion granpa = new ApiRegion("granpa", null);
+        ApiRegion father = new ApiRegion("father", granpa);
+        ApiRegion child = new ApiRegion("child", father);
+
+        assertSame(father, child.getParent());
+        assertSame(granpa, father.getParent());
+        assertNull(granpa.getParent());
+    }
+
+    @Test
+    public void inheritanceContainsCheck() {
+        ApiRegion granpa = new ApiRegion("granpa", null);
+        granpa.addApi("org.apache.sling.feature.apiregions");
+
+        ApiRegion father = new ApiRegion("father", granpa);
+        father.addApi("org.apache.sling.feature.apiregions.io");
+
+        ApiRegion child = new ApiRegion("child", father);
+        child.addApi("org.apache.sling.feature.apiregions.io.json");
+
+        assertTrue(child.contains("org.apache.sling.feature.apiregions.io.json"));
+        assertTrue(child.contains("org.apache.sling.feature.apiregions.io")); // inherited
+        assertTrue(child.contains("org.apache.sling.feature.apiregions")); // inherited-inherited
+    }
+
+    @Test
+    public void inheritanceIteratorCheck() {
+        ApiRegion granpa = new ApiRegion("granpa", null);
+        granpa.addApi("org.apache.sling.feature.apiregions");
+
+        ApiRegion father = new ApiRegion("father", granpa);
+        father.addApi("org.apache.sling.feature.apiregions.io");
+
+        ApiRegion child = new ApiRegion("child", father);
+        child.addApi("org.apache.sling.feature.apiregions.io.json");
+
+        // build the expected packages
+
+        Set<String> packages = new HashSet<>();
+        packages.add("org.apache.sling.feature.apiregions.io.json");
+        packages.add("org.apache.sling.feature.apiregions.io");
+        packages.add("org.apache.sling.feature.apiregions");
+
+        for (String api : child) {
+            packages.remove(api);
+        }
+
+        assertTrue("Expected all packages removed, still found" + packages, packages.isEmpty());
+    }
+
+}
diff --git a/feature-api-regions/src/test/java/org/apache/sling/feature/apiregions/ApiRegionsTest.java b/feature-api-regions/src/test/java/org/apache/sling/feature/apiregions/ApiRegionsTest.java
new file mode 100644
index 0000000..906ca6c
--- /dev/null
+++ b/feature-api-regions/src/test/java/org/apache/sling/feature/apiregions/ApiRegionsTest.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.feature.apiregions;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ApiRegionsTest {
+
+    private ApiRegions apiRegions;
+
+    @Before
+    public void setUp() {
+        apiRegions = new ApiRegions();
+    }
+
+    @After
+    public void tearDown() {
+        apiRegions = null;
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void canNotCreateRegionWithNullName() {
+        apiRegions.addNewRegion(null);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void canNotCreateRegionWithEmptyName() {
+        apiRegions.addNewRegion("");
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void impossibleToGetRegionWithNullName() {
+        apiRegions.getByName(null);
+    }
+
+    @Test
+    public void impossibleToGetRegionWithEmptyName() {
+        assertNull(apiRegions.getByName(""));
+    }
+
+    @Test
+    public void impossibleToGetRegionWithNotRegisteredRegion() {
+        assertNull(apiRegions.getByName("not-registered-yet"));
+    }
+
+    @Test
+    public void getRegionWithRegisteredRegion() {
+        String regionName = "registered";
+        ApiRegion region = apiRegions.addNewRegion(regionName);
+        assertNotNull(region);
+        assertNotNull(apiRegions.getByName(regionName));
+    }
+
+    @Test
+    public void sequentialInheritance() {
+        ApiRegion granpa = apiRegions.addNewRegion("granpa");
+        ApiRegion father = apiRegions.addNewRegion("father");
+        ApiRegion child = apiRegions.addNewRegion("child");
+
+        assertSame(father, child.getParent());
+        assertSame(granpa, father.getParent());
+        assertNull(granpa.getParent());
+    }
+
+    @Test
+    public void iteratingOverRegions() {
+        apiRegions.addNewRegion("granpa");
+        apiRegions.addNewRegion("father");
+        apiRegions.addNewRegion("child");
+
+        List<String> expected = Arrays.asList("granpa", "father", "child");
+
+        List<String> actual = new LinkedList<>();
+        for (ApiRegion region : apiRegions) {
+            actual.add(region.getName());
+        }
+
+        assertEquals(expected, actual);
+    }
+
+}
diff --git a/feature-api-regions/src/test/java/org/apache/sling/feature/apiregions/io/json/ApiRegionsJSONParserTest.java b/feature-api-regions/src/test/java/org/apache/sling/feature/apiregions/io/json/ApiRegionsJSONParserTest.java
new file mode 100644
index 0000000..342c7c4
--- /dev/null
+++ b/feature-api-regions/src/test/java/org/apache/sling/feature/apiregions/io/json/ApiRegionsJSONParserTest.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.feature.apiregions.io.json;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.sling.feature.ArtifactId;
+import org.apache.sling.feature.Extension;
+import org.apache.sling.feature.ExtensionType;
+import org.apache.sling.feature.Feature;
+import org.apache.sling.feature.apiregions.ApiRegion;
+import org.apache.sling.feature.apiregions.ApiRegions;
+import org.junit.Test;
+
+public class ApiRegionsJSONParserTest {
+
+    @Test(expected = NullPointerException.class)
+    public void canNotParseNullFeature() {
+        ApiRegionsJSONParser.parseApiRegions((Feature) null);
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void canNotParseNullExtension() {
+        ApiRegionsJSONParser.parseApiRegions((Extension) null);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void canNotParseInvalidExtensionName() {
+        Extension extension = new Extension(ExtensionType.JSON, "invalid", false);
+        ApiRegionsJSONParser.parseApiRegions(extension);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void canNotParseInvalidExtensionType() {
+        Extension extension = new Extension(ExtensionType.TEXT, "api-regions", false);
+        ApiRegionsJSONParser.parseApiRegions(extension);
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void canNotParseNullJsonRepresentation() {
+        ApiRegionsJSONParser.parseApiRegions((String) null);
+    }
+
+    @Test
+    public void parseApiRegions() {
+        Extension extension = new Extension(ExtensionType.JSON, "api-regions", false);
+        extension.setJSON("[\n" + 
+                            "  {\n" + 
+                            "    \"name\":\"base\",\n" + 
+                            "    \"exports\":[\n" + 
+                            "      \"org.apache.felix.metatype\",\n" + 
+                            "      \"org.apache.felix.inventory\"\n" + 
+                            "    ]\n" + 
+                            "  },\n" + 
+                            "  {\n" + 
+                            "    \"name\":\"extended\",\n" + 
+                            "    \"exports\":[\n" + 
+                            "      \"org.apache.felix.scr.component\",\n" + 
+                            "      \"org.apache.felix.scr.info\",\n" + 
+                            "      \"org.apache.felix.metatype\",\n" + 
+                            "      \"org.apache.felix.inventory\"\n" + 
+                            "    ]\n" + 
+                            "  }\n" + 
+                            "]");
+        Feature feature = new Feature(ArtifactId.fromMvnId("org.apache.sling:org.apache.sling.feature.apiregions:1.0.0"));
+        feature.getExtensions().add(extension);
+
+        ApiRegions apiRegions = ApiRegionsJSONParser.parseApiRegions(feature);
+
+        ApiRegion base = apiRegions.getByName("base");
+        assertNull(base.getParent());
+        assertTrue(base.contains("org.apache.felix.inventory"));
+        assertTrue(base.contains("org.apache.felix.metatype"));
+
+        ApiRegion extended = apiRegions.getByName("extended");
+        assertNotNull(extended.getParent());
+        assertSame(base, extended.getParent());
+        assertTrue(extended.contains("org.apache.felix.inventory"));
+        assertTrue(extended.contains("org.apache.felix.metatype"));
+        assertTrue(extended.contains("org.apache.felix.scr.component"));
+        assertTrue(extended.contains("org.apache.felix.scr.info"));
+    }
+
+}
diff --git a/feature-api-regions/src/test/java/org/apache/sling/feature/apiregions/io/json/ApiRegionsJSONSerializerTest.java b/feature-api-regions/src/test/java/org/apache/sling/feature/apiregions/io/json/ApiRegionsJSONSerializerTest.java
new file mode 100644
index 0000000..5d7fc05
--- /dev/null
+++ b/feature-api-regions/src/test/java/org/apache/sling/feature/apiregions/io/json/ApiRegionsJSONSerializerTest.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.feature.apiregions.io.json;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.OutputStream;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import org.apache.sling.feature.apiregions.ApiRegion;
+import org.apache.sling.feature.apiregions.ApiRegions;
+import org.junit.Test;
+
+public final class ApiRegionsJSONSerializerTest {
+
+    @Test(expected = NullPointerException.class)
+    public void nullOutputStreamNotAccepted() {
+        ApiRegionsJSONSerializer.serializeApiRegions(null, (OutputStream) null);
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void nullApiRegionsNotAccepted() {
+        ApiRegionsJSONSerializer.serializeApiRegions(null, (Writer) null);
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void nullWriterNotAccepted() {
+        ApiRegionsJSONSerializer.serializeApiRegions(new ApiRegions(), (Writer) null);
+    }
+
+    @Test
+    public void serialization() {
+        String expected = "[\n" + 
+                            "  {\n" + 
+                            "    \"name\":\"base\",\n" + 
+                            "    \"exports\":[\n" + 
+                            "      \"org.apache.felix.metatype\",\n" + 
+                            "      \"org.apache.felix.inventory\"\n" + 
+                            "    ]\n" + 
+                            "  },\n" + 
+                            "  {\n" + 
+                            "    \"name\":\"extended\",\n" + 
+                            "    \"exports\":[\n" + 
+                            "      \"org.apache.felix.scr.component\",\n" + 
+                            "      \"org.apache.felix.scr.info\"\n" + 
+                            "    ]\n" + 
+                            "  }\n" + 
+                            "]";
+
+        ApiRegions apiRegions = new ApiRegions();
+
+        ApiRegion base = apiRegions.addNewRegion("base");
+        base.addApi("org.apache.felix.inventory");
+        base.addApi("org.apache.felix.metatype");
+
+        ApiRegion extended = apiRegions.addNewRegion("extended");
+        extended.addApi("org.apache.felix.scr.component");
+        extended.addApi("org.apache.felix.scr.info");
+
+        StringWriter writer = new StringWriter();
+        ApiRegionsJSONSerializer.serializeApiRegions(apiRegions, writer);
+
+        String actual = writer.toString();
+
+        assertEquals(expected, actual);
+    }
+
+}