You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2024/12/13 14:13:31 UTC
(sling-org-apache-sling-feature-launcher) branch feature/SLING-12565-parent-62 created (now 80a1964)
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a change to branch feature/SLING-12565-parent-62
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-launcher.git
at 80a1964 SLING-12566 apply spotless formatting
This branch includes the following new commits:
new 8beab92 SLING-12565 Update to parent 62
new 80a1964 SLING-12566 apply spotless formatting
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(sling-org-apache-sling-feature-launcher) 01/02: SLING-12565 Update to parent 62
Posted by ss...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a commit to branch feature/SLING-12565-parent-62
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-launcher.git
commit 8beab92f45e122dbb2ddf9bbd656ec1db07fda30
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Fri Dec 13 15:12:55 2024 +0100
SLING-12565 Update to parent 62
---
.sling-module.json | 5 +++++
pom.xml | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/.sling-module.json b/.sling-module.json
new file mode 100644
index 0000000..cfad4d2
--- /dev/null
+++ b/.sling-module.json
@@ -0,0 +1,5 @@
+{
+ "jenkins": {
+ "jdks": [17, 21]
+ }
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index c739b01..a4f27c7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,7 +16,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>48</version>
+ <version>62</version>
<relativePath />
</parent>
@@ -149,7 +149,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>maven-enforcer-rules</artifactId>
- <version>1.0.0</version>
+ <version>1.2.0</version>
</dependency>
</dependencies>
<executions>
(sling-org-apache-sling-feature-launcher) 02/02: SLING-12566 apply spotless formatting
Posted by ss...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a commit to branch feature/SLING-12565-parent-62
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-launcher.git
commit 80a19648b7ba9b1788f22da65f0f22f30bed780e
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Fri Dec 13 15:13:23 2024 +0100
SLING-12566 apply spotless formatting
---
pom.xml | 310 +++++++++++----------
.../sling/feature/launcher/impl/Bootstrap.java | 150 ++++++----
.../launcher/impl/ExtensionContextImpl.java | 35 ++-
.../feature/launcher/impl/FeatureProcessor.java | 116 +++++---
.../sling/feature/launcher/impl/Installation.java | 34 +--
.../feature/launcher/impl/LauncherConfig.java | 37 +--
.../apache/sling/feature/launcher/impl/Main.java | 144 +++++-----
.../feature/launcher/impl/VariableSubstitutor.java | 28 +-
.../extensions/handlers/ContentPackageHandler.java | 42 ++-
.../impl/extensions/handlers/RepoInitHandler.java | 45 +--
.../launcher/impl/launchers/AbstractRunner.java | 240 +++++++++-------
.../launcher/impl/launchers/FrameworkLauncher.java | 74 ++---
.../launcher/impl/launchers/FrameworkRunner.java | 41 +--
.../sling/feature/launcher/spi/Launcher.java | 27 +-
.../launcher/spi/LauncherPrepareContext.java | 26 +-
.../feature/launcher/spi/LauncherRunContext.java | 28 +-
.../launcher/spi/extensions/ExtensionContext.java | 37 +--
.../launcher/spi/extensions/ExtensionHandler.java | 30 +-
.../launcher/impl/ExtensionContextImplTest.java | 34 +--
.../apache/sling/feature/launcher/impl/MainIT.java | 177 ++++++------
.../launcher/impl/VariableSubstitutorIT.java | 36 +--
21 files changed, 900 insertions(+), 791 deletions(-)
diff --git a/pom.xml b/pom.xml
index a4f27c7..f23012e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,5 +1,5 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
- <!--
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
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,
@@ -24,9 +24,14 @@
<version>1.3.1-SNAPSHOT</version>
<name>Apache Sling Feature Model Launcher</name>
- <description>
- A application launcher using Apache Sling Features
- </description>
+ <description>A application launcher using Apache Sling Features</description>
+
+ <scm>
+ <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-launcher.git</connection>
+ <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-launcher.git</developerConnection>
+ <tag>HEAD</tag>
+ <url>https://github.com/apache/sling-org-apache-sling-feature-launcher.git</url>
+ </scm>
<properties>
<sling.java.version>8</sling.java.version>
@@ -36,12 +41,100 @@
<project.build.outputTimestamp>1675867591</project.build.outputTimestamp>
</properties>
- <scm>
- <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-launcher.git</connection>
- <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-launcher.git</developerConnection>
- <url>https://github.com/apache/sling-org-apache-sling-feature-launcher.git</url>
- <tag>HEAD</tag>
- </scm>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-text</artifactId>
+ <version>1.10.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.12.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.core</artifactId>
+ <version>8.0.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.feature</artifactId>
+ <version>2.0.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.util.function</artifactId>
+ <version>1.0.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.util.converter</artifactId>
+ <version>1.0.9</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.cm.json</artifactId>
+ <version>2.0.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.4</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.json</groupId>
+ <artifactId>jakarta.json-api</artifactId>
+ <version>2.0.2</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-core</artifactId>
+ <version>1.2.19</version>
+ <classifier>jakarta</classifier>
+ <scope>compile</scope>
+ </dependency>
+ <!-- for generating service descriptor files -->
+ <dependency>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>biz.aQute.bnd.annotation</artifactId>
+ <version>${bnd.version}</version>
+ <scope>provided</scope>
+ <!-- not necessary at run time -->
+ </dependency>
+
+ <!-- Testing dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>3.3.3</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
<build>
<plugins>
@@ -50,8 +143,7 @@
<artifactId>bnd-maven-plugin</artifactId>
<version>${bnd.version}</version>
<configuration>
- <bnd>
- <![CDATA[
+ <bnd><![CDATA[
Main-Class: org.apache.sling.feature.launcher.impl.Main
-exportcontents:\
org.apache.sling.feature.launcher.spi.*
@@ -60,8 +152,7 @@
Import-Package:\
org.apache.commons.cli;resolution:=optional,\
*
- ]]>
- </bnd>
+ ]]></bnd>
</configuration>
<executions>
<execution>
@@ -125,10 +216,10 @@
<executions>
<execution>
<id>add-third-party</id>
- <phase>generate-resources</phase>
<goals>
<goal>add-third-party</goal>
</goals>
+ <phase>generate-resources</phase>
<configuration>
<fileTemplate>${basedir}/src/main/legal/LICENSE-with-deps</fileTemplate>
<thirdPartyFilename>LICENSE-with-deps</thirdPartyFilename>
@@ -142,7 +233,7 @@
</executions>
</plugin>
- <plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<dependencies>
@@ -152,47 +243,48 @@
<version>1.2.0</version>
</dependency>
</dependencies>
- <executions>
- <execution>
- <id>enforce-complete-runtime-classpath</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <configuration>
- <rules>
- <requireProvidedDependenciesInRuntimeClasspath implementation="org.apache.sling.maven.enforcer.RequireProvidedDependenciesInRuntimeClasspath">
- <excludes>
- <exclude>org.jetbrains:annotations</exclude><!-- exclude all annotations with class retention -->
- <exclude>org.osgi:osgi.annotation</exclude>
- <exclude>org.osgi:org.osgi.annotation.versioning</exclude>
- <exclude>org.apache.felix:org.apache.felix.converter</exclude><!-- relocated to org.osgi.util.converter -->
- <exclude>org.apache.felix:org.apache.felix.utils</exclude><!-- embedded in org.apache.sling.feature -->
- <exclude>org.apache.geronimo.specs:geronimo-json_1.1_spec</exclude><!-- not needed, jakarta.json is used -->
- <exclude>org.osgi:org.osgi.core</exclude><!-- contained in org.osgi:osgi.core -->
- <exclude>org.osgi:org.osgi.service.configurator</exclude><!-- wrongly flagged to be needed by cm.json -->
- <exclude>org.osgi:org.osgi.service.feature</exclude><!-- Optional dependency for feature model -->
- <exclude>org.osgi:org.osgi.framework</exclude><!-- Included via osgi.core -->
- <exclude>org.osgi:org.osgi.resource</exclude><!-- Included via osgi.core -->
- </excludes>
- </requireProvidedDependenciesInRuntimeClasspath>
- </rules>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>appassembler-maven-plugin</artifactId>
- <version>${appassembler-maven-plugin.version}</version>
<executions>
<execution>
- <phase>package</phase>
+ <id>enforce-complete-runtime-classpath</id>
<goals>
- <goal>assemble</goal>
+ <goal>enforce</goal>
</goals>
+ <configuration>
+ <rules>
+ <requireProvidedDependenciesInRuntimeClasspath implementation="org.apache.sling.maven.enforcer.RequireProvidedDependenciesInRuntimeClasspath">
+ <excludes>
+ <exclude>org.jetbrains:annotations</exclude>
+ <!-- exclude all annotations with class retention -->
+ <exclude>org.osgi:osgi.annotation</exclude>
+ <exclude>org.osgi:org.osgi.annotation.versioning</exclude>
+ <exclude>org.apache.felix:org.apache.felix.converter</exclude>
+ <!-- relocated to org.osgi.util.converter -->
+ <exclude>org.apache.felix:org.apache.felix.utils</exclude>
+ <!-- embedded in org.apache.sling.feature -->
+ <exclude>org.apache.geronimo.specs:geronimo-json_1.1_spec</exclude>
+ <!-- not needed, jakarta.json is used -->
+ <exclude>org.osgi:org.osgi.core</exclude>
+ <!-- contained in org.osgi:osgi.core -->
+ <exclude>org.osgi:org.osgi.service.configurator</exclude>
+ <!-- wrongly flagged to be needed by cm.json -->
+ <exclude>org.osgi:org.osgi.service.feature</exclude>
+ <!-- Optional dependency for feature model -->
+ <exclude>org.osgi:org.osgi.framework</exclude>
+ <!-- Included via osgi.core -->
+ <exclude>org.osgi:org.osgi.resource</exclude>
+ <!-- Included via osgi.core -->
+ </excludes>
+ </requireProvidedDependenciesInRuntimeClasspath>
+ </rules>
+ </configuration>
</execution>
</executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>appassembler-maven-plugin</artifactId>
+ <version>${appassembler-maven-plugin.version}</version>
<configuration>
<useWildcardClassPath>true</useWildcardClassPath>
<repositoryLayout>flat</repositoryLayout>
@@ -207,6 +299,14 @@
</program>
</programs>
</configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>assemble</goal>
+ </goals>
+ <phase>package</phase>
+ </execution>
+ </executions>
</plugin>
<plugin>
@@ -215,10 +315,10 @@
<executions>
<execution>
<id>assembly</id>
- <phase>package</phase>
<goals>
<goal>single</goal>
</goals>
+ <phase>package</phase>
<configuration>
<finalName>${project.build.finalName}</finalName>
<tarLongFileMode>gnu</tarLongFileMode>
@@ -233,100 +333,6 @@
</plugins>
</build>
- <dependencies>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-text</artifactId>
- <version>1.10.0</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.12.0</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.core</artifactId>
- <version>8.0.0</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.feature</artifactId>
- <version>2.0.0</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.util.function</artifactId>
- <version>1.0.0</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.util.converter</artifactId>
- <version>1.0.9</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.cm.json</artifactId>
- <version>2.0.0</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>commons-cli</groupId>
- <artifactId>commons-cli</artifactId>
- <version>1.4</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>jakarta.json</groupId>
- <artifactId>jakarta.json-api</artifactId>
- <version>2.0.2</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.johnzon</groupId>
- <artifactId>johnzon-core</artifactId>
- <classifier>jakarta</classifier>
- <version>1.2.19</version>
- <scope>compile</scope>
- </dependency>
- <!-- for generating service descriptor files -->
- <dependency>
- <groupId>biz.aQute.bnd</groupId>
- <artifactId>biz.aQute.bnd.annotation</artifactId>
- <version>${bnd.version}</version>
- <scope>provided</scope><!-- not necessary at run time -->
- </dependency>
-
- <!-- Testing dependencies -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>3.3.3</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
<profiles>
<profile>
<id>container</id>
@@ -349,10 +355,10 @@
<tag>latest</tag>
<tag>${project.version}</tag>
</tags>
- <dockerFileDir>.</dockerFileDir>
- <assembly>
- <descriptor>${project.basedir}/src/main/assembly/bin.xml</descriptor>
- </assembly>
+ <dockerFileDir>.</dockerFileDir>
+ <assembly>
+ <descriptor>${project.basedir}/src/main/assembly/bin.xml</descriptor>
+ </assembly>
</build>
</image>
</images>
@@ -360,10 +366,10 @@
<executions>
<execution>
<id>docker:build</id>
- <phase>package</phase>
<goals>
<goal>build</goal>
</goals>
+ <phase>package</phase>
</execution>
</executions>
</plugin>
diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/Bootstrap.java b/src/main/java/org/apache/sling/feature/launcher/impl/Bootstrap.java
index e094748..42fb755 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/Bootstrap.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/Bootstrap.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.impl;
@@ -65,34 +67,52 @@ public class Bootstrap {
* @throws IllegalArgumentException If the provided version is invalid
*/
private ArtifactId getFelixFrameworkId(final String version) {
- return new ArtifactId("org.apache.felix", "org.apache.felix.framework", version != null ? version : FELIX_FRAMEWORK_VERSION,
- null, null);
+ return new ArtifactId(
+ "org.apache.felix",
+ "org.apache.felix.framework",
+ version != null ? version : FELIX_FRAMEWORK_VERSION,
+ null,
+ null);
}
-
private void prepare() {
- this.config.getVariables().put("sling.home", this.config.getHomeDirectory().getAbsolutePath());
+ this.config
+ .getVariables()
+ .put("sling.home", this.config.getHomeDirectory().getAbsolutePath());
if (this.config.getVariables().get("repository.home") == null) {
- this.config.getVariables().put("repository.home",
- this.config.getHomeDirectory().getAbsolutePath() + File.separatorChar + "repository");
+ this.config
+ .getVariables()
+ .put(
+ "repository.home",
+ this.config.getHomeDirectory().getAbsolutePath() + File.separatorChar + "repository");
}
- this.config.getVariables().put("sling.launchpad",
- this.config.getHomeDirectory().getAbsolutePath() + "/launchpad");
+ this.config
+ .getVariables()
+ .put("sling.launchpad", this.config.getHomeDirectory().getAbsolutePath() + "/launchpad");
final Installation installation = this.config.getInstallation();
installation.setLogger(this.logger);
// set sling home, and use separate locations for launchpad and properties
- installation.getFrameworkProperties().put("sling.home", this.config.getHomeDirectory().getAbsolutePath());
- installation.getFrameworkProperties().put("sling.launchpad",
- this.config.getHomeDirectory().getAbsolutePath() + "/launchpad");
+ installation
+ .getFrameworkProperties()
+ .put("sling.home", this.config.getHomeDirectory().getAbsolutePath());
+ installation
+ .getFrameworkProperties()
+ .put("sling.launchpad", this.config.getHomeDirectory().getAbsolutePath() + "/launchpad");
if (!installation.getFrameworkProperties().containsKey("repository.home")) {
- installation.getFrameworkProperties().put("repository.home",
- this.config.getHomeDirectory().getAbsolutePath() + File.separatorChar + "repository");
+ installation
+ .getFrameworkProperties()
+ .put(
+ "repository.home",
+ this.config.getHomeDirectory().getAbsolutePath() + File.separatorChar + "repository");
}
installation.getFrameworkProperties().put("sling.properties", "conf/sling.properties");
- installation.getFrameworkProperties().put("sling.feature",
- getApplicationFeatureFile(this.config).toURI().toString());
+ installation
+ .getFrameworkProperties()
+ .put(
+ "sling.feature",
+ getApplicationFeatureFile(this.config).toURI().toString());
}
public void run() {
@@ -109,7 +129,6 @@ public class Bootstrap {
this.logger.info("Apache Sling Application Launcher");
this.logger.info("---------------------------------");
-
this.logger.info("Initializing...");
prepare();
@@ -156,8 +175,10 @@ public class Bootstrap {
FeatureProcessor.prepareLauncher(ctx, this.config, app, loadedFeatures);
- this.logger.info("Using {} local artifacts, {} cached artifacts, and {} downloaded artifacts",
- this.config.getLocalArtifacts(), this.config.getCachedArtifacts(),
+ this.logger.info(
+ "Using {} local artifacts, {} cached artifacts, and {} downloaded artifacts",
+ this.config.getLocalArtifacts(),
+ this.config.getCachedArtifacts(),
this.config.getDownloadedArtifacts());
if (this.config.getCacheOnly()) {
@@ -170,11 +191,10 @@ public class Bootstrap {
this.config.getInstallation().getConfigurations().clear();
this.config.getInstallation().getBundleMap().clear();
}
- } catch ( final Exception iae) {
+ } catch (final Exception iae) {
throw new IllegalStateException("Error while assembling launcher: " + iae.getMessage(), iae);
}
- }
- catch (IOException ex) {
+ } catch (IOException ex) {
throw new IOException("Unable to setup artifact manager: " + ex.getMessage(), ex);
}
@@ -182,45 +202,40 @@ public class Bootstrap {
}
private ArtifactId getFrameworkArtifactId(final Feature app) {
- if ( this.config.getFrameworkArtifact() != null ) {
+ if (this.config.getFrameworkArtifact() != null) {
return ArtifactId.parse(this.config.getFrameworkArtifact());
}
- if ( this.config.getFrameworkVersion() != null ) {
+ if (this.config.getFrameworkVersion() != null) {
return getFelixFrameworkId(this.config.getFrameworkVersion());
}
final ExecutionEnvironmentExtension env = ExecutionEnvironmentExtension.getExecutionEnvironmentExtension(app);
- if ( env != null && env.getFramework() != null ) {
+ if (env != null && env.getFramework() != null) {
return env.getFramework().getId();
}
return getFelixFrameworkId(null);
}
- private Feature assemble(final ArtifactManager artifactManager,
- Map<ArtifactId, Feature> loadedFeatures) throws IOException
- {
- if (this.config.getFeatureFiles().isEmpty() ) {
+ private Feature assemble(final ArtifactManager artifactManager, Map<ArtifactId, Feature> loadedFeatures)
+ throws IOException {
+ if (this.config.getFeatureFiles().isEmpty()) {
File application = getApplicationFeatureFile(this.config);
if (application.isFile()) {
this.config.addFeatureFiles(application.toURI().toURL().toString());
- }
- else {
+ } else {
Main.printHelp();
throw new IllegalStateException("No feature(s) to launch found and none where specified");
}
return FeatureProcessor.createApplication(this.logger, this.config, artifactManager, loadedFeatures);
- }
- else
- {
- final Feature app = FeatureProcessor.createApplication(this.logger, this.config, artifactManager,
- loadedFeatures);
+ } else {
+ final Feature app =
+ FeatureProcessor.createApplication(this.logger, this.config, artifactManager, loadedFeatures);
// write application back
final File file = getApplicationFeatureFile(this.config);
Files.createDirectories(file.getParentFile().toPath());
- try (final FileWriter writer = new FileWriter(file))
- {
+ try (final FileWriter writer = new FileWriter(file)) {
FeatureJSONWriter.write(writer, app);
}
@@ -229,7 +244,9 @@ public class Bootstrap {
}
private static File getApplicationFeatureFile(final LauncherConfig launcherConfig) {
- return new File(launcherConfig.getHomeDirectory(), "resources" + File.separatorChar + "provisioning" + File.separatorChar + "application.json");
+ return new File(
+ launcherConfig.getHomeDirectory(),
+ "resources" + File.separatorChar + "provisioning" + File.separatorChar + "application.json");
}
private static final String STORAGE_PROPERTY = "org.osgi.framework.storage";
@@ -250,25 +267,37 @@ public class Bootstrap {
final Installation installation = config.getInstallation();
// set sling home, and use separate locations for launchpad and properties
- installation.getFrameworkProperties().put("sling.home", config.getHomeDirectory().getAbsolutePath());
- installation.getFrameworkProperties().put("sling.launchpad", config.getHomeDirectory().getAbsolutePath() + "/launchpad");
+ installation
+ .getFrameworkProperties()
+ .put("sling.home", config.getHomeDirectory().getAbsolutePath());
+ installation
+ .getFrameworkProperties()
+ .put("sling.launchpad", config.getHomeDirectory().getAbsolutePath() + "/launchpad");
if (!installation.getFrameworkProperties().containsKey("repository.home")) {
- installation.getFrameworkProperties().put("repository.home", config.getHomeDirectory().getAbsolutePath() + File.separatorChar + "repository");
+ installation
+ .getFrameworkProperties()
+ .put(
+ "repository.home",
+ config.getHomeDirectory().getAbsolutePath() + File.separatorChar + "repository");
}
installation.getFrameworkProperties().put("sling.properties", "conf/sling.properties");
- installation.getFrameworkProperties().put("sling.feature", getApplicationFeatureFile(config).toURI().toString());
-
+ installation
+ .getFrameworkProperties()
+ .put("sling.feature", getApplicationFeatureFile(config).toURI().toString());
// additional OSGi properties
// move storage inside launcher
- installation.getFrameworkProperties()
- .putIfAbsent(STORAGE_PROPERTY, config.getHomeDirectory().getAbsolutePath() + File.separatorChar + "framework");
+ installation
+ .getFrameworkProperties()
+ .putIfAbsent(
+ STORAGE_PROPERTY,
+ config.getHomeDirectory().getAbsolutePath() + File.separatorChar + "framework");
// set start level to 30
- installation.getFrameworkProperties()
- .putIfAbsent(START_LEVEL_PROP, "30");
+ installation.getFrameworkProperties().putIfAbsent(START_LEVEL_PROP, "30");
- while (launcher.run(installation, createClassLoader(installation, launcher)) == FrameworkEvent.STOPPED_SYSTEM_REFRESHED) {
+ while (launcher.run(installation, createClassLoader(installation, launcher))
+ == FrameworkEvent.STOPPED_SYSTEM_REFRESHED) {
this.logger.info("Framework restart due to extension refresh");
}
}
@@ -286,7 +315,6 @@ public class Bootstrap {
list.add(Bootstrap.class.getProtectionDomain().getCodeSource().getLocation());
-
// create a paranoid class loader, loading from parent last
final Launcher.LauncherClassLoader cl = launcher.createClassLoader();
diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/ExtensionContextImpl.java b/src/main/java/org/apache/sling/feature/launcher/impl/ExtensionContextImpl.java
index 3d836e8..5b991d0 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/ExtensionContextImpl.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/ExtensionContextImpl.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.impl;
@@ -37,8 +39,7 @@ class ExtensionContextImpl implements ExtensionContext {
private final LauncherPrepareContext prepareContext;
private final Map<ArtifactId, Feature> loadedFeatures;
- ExtensionContextImpl(LauncherPrepareContext lpc, Installation inst,
- Map<ArtifactId, Feature> featureMap) {
+ ExtensionContextImpl(LauncherPrepareContext lpc, Installation inst, Map<ArtifactId, Feature> featureMap) {
prepareContext = lpc;
installation = inst;
loadedFeatures = featureMap;
@@ -102,12 +103,10 @@ class ExtensionContextImpl implements ExtensionContext {
@Override
public Feature getFeature(ArtifactId artifact) throws IOException {
Feature f = loadedFeatures.get(artifact);
- if (f != null)
- return f;
+ if (f != null) return f;
URL file = getArtifactFile(artifact);
- if (file == null)
- return null;
+ if (file == null) return null;
try (Reader r = new InputStreamReader(file.openStream(), "UTF-8")) {
return FeatureJSONReader.read(r, artifact.toMvnUrl());
diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/FeatureProcessor.java b/src/main/java/org/apache/sling/feature/launcher/impl/FeatureProcessor.java
index fd3f16e..b1f418a 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/FeatureProcessor.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/FeatureProcessor.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.impl;
@@ -62,13 +64,17 @@ public class FeatureProcessor {
* @return The merged feature representing the application
* @throws IOException when an IO exception occurs during application creation
*/
- public static Feature createApplication(final Logger logger, final LauncherConfig config,
- final ArtifactManager artifactManager, final Map<ArtifactId, Feature> loadedFeatures) throws IOException
- {
+ public static Feature createApplication(
+ final Logger logger,
+ final LauncherConfig config,
+ final ArtifactManager artifactManager,
+ final Map<ArtifactId, Feature> loadedFeatures)
+ throws IOException {
final BuilderContext builderContext = new BuilderContext(id -> {
try {
final ArtifactHandler handler = artifactManager.getArtifactHandler(id.toMvnUrl());
- try (final Reader r = new InputStreamReader(handler.getLocalURL().openStream(), "UTF-8")) {
+ try (final Reader r =
+ new InputStreamReader(handler.getLocalURL().openStream(), "UTF-8")) {
final Feature f = FeatureJSONReader.read(r, handler.getUrl());
return f;
}
@@ -96,31 +102,36 @@ public class FeatureProcessor {
builderContext.addConfigsOverrides(config.getConfigClashOverrides());
builderContext.addVariablesOverrides(config.getVariables());
builderContext.addFrameworkPropertiesOverrides(config.getInstallation().getFrameworkProperties());
- builderContext.addMergeExtensions(StreamSupport.stream(Spliterators.spliteratorUnknownSize(
- ServiceLoader.load(MergeHandler.class).iterator(), Spliterator.ORDERED), false)
- .toArray(MergeHandler[]::new));
- builderContext.addPostProcessExtensions(StreamSupport.stream(Spliterators.spliteratorUnknownSize(
- ServiceLoader.load(PostProcessHandler.class).iterator(), Spliterator.ORDERED), false)
+ builderContext.addMergeExtensions(StreamSupport.stream(
+ Spliterators.spliteratorUnknownSize(
+ ServiceLoader.load(MergeHandler.class).iterator(), Spliterator.ORDERED),
+ false)
+ .toArray(MergeHandler[]::new));
+ builderContext.addPostProcessExtensions(StreamSupport.stream(
+ Spliterators.spliteratorUnknownSize(
+ ServiceLoader.load(PostProcessHandler.class).iterator(), Spliterator.ORDERED),
+ false)
.toArray(PostProcessHandler[]::new));
- for (Map.Entry<String, Map<String,String>> entry : config.getExtensionConfiguration().entrySet()) {
+ for (Map.Entry<String, Map<String, String>> entry :
+ config.getExtensionConfiguration().entrySet()) {
builderContext.setHandlerConfiguration(entry.getKey(), entry.getValue());
}
List<Feature> features = new ArrayList<>();
for (final String featureFile : config.getFeatureFiles()) {
for (final String initFile : IOUtils.getFeatureFiles(config.getHomeDirectory(), featureFile)) {
- if ( initFile.endsWith(IOUtils.EXTENSION_FEATURE_ARCHIVE) ) {
+ if (initFile.endsWith(IOUtils.EXTENSION_FEATURE_ARCHIVE)) {
logger.debug("Reading feature archive {}", initFile);
final ArtifactHandler featureArtifact = artifactManager.getArtifactHandler(initFile);
try (final InputStream is = featureArtifact.getLocalURL().openStream()) {
- for(final Feature feature : ArchiveReader.read(is, (id, stream) -> {
- final File artifactFile = new File(config.getCacheDirectory(),
- id.toMvnPath().replace('/', File.separatorChar));
- if (!artifactFile.exists()) {
- artifactFile.getParentFile().mkdirs();
- Files.copy(stream, artifactFile.toPath());
- }
- })) {
+ for (final Feature feature : ArchiveReader.read(is, (id, stream) -> {
+ final File artifactFile = new File(
+ config.getCacheDirectory(), id.toMvnPath().replace('/', File.separatorChar));
+ if (!artifactFile.exists()) {
+ artifactFile.getParentFile().mkdirs();
+ Files.copy(stream, artifactFile.toPath());
+ }
+ })) {
features.add(feature);
loadedFeatures.put(feature.getId(), feature);
@@ -131,7 +142,8 @@ public class FeatureProcessor {
} else {
logger.debug("Reading feature file {}", initFile);
final ArtifactHandler featureArtifact = artifactManager.getArtifactHandler(initFile);
- try (final Reader r = new InputStreamReader(featureArtifact.getLocalURL().openStream(), "UTF-8")) {
+ try (final Reader r =
+ new InputStreamReader(featureArtifact.getLocalURL().openStream(), "UTF-8")) {
final Feature f = FeatureJSONReader.read(r, featureArtifact.getUrl());
loadedFeatures.put(f.getId(), f);
features.add(f);
@@ -142,7 +154,8 @@ public class FeatureProcessor {
}
}
- final Feature app = FeatureBuilder.assemble(config.getLaunchFeatureId(), builderContext, features.toArray(new Feature[0]));
+ final Feature app =
+ FeatureBuilder.assemble(config.getLaunchFeatureId(), builderContext, features.toArray(new Feature[0]));
loadedFeatures.put(app.getId(), app);
FeatureBuilder.resolveVariables(app, config.getVariables());
@@ -162,10 +175,15 @@ public class FeatureProcessor {
* were passed in via file:// URLs from the commandline
* @throws Exception when something goes wrong
*/
- public static void prepareLauncher(final LauncherPrepareContext ctx, final LauncherConfig config,
- final Feature app, Map<ArtifactId, Feature> loadedFeatures) throws Exception {
- for(final Map.Entry<Integer, List<Artifact>> entry : app.getBundles().getBundlesByStartOrder().entrySet()) {
- for(final Artifact a : entry.getValue()) {
+ public static void prepareLauncher(
+ final LauncherPrepareContext ctx,
+ final LauncherConfig config,
+ final Feature app,
+ Map<ArtifactId, Feature> loadedFeatures)
+ throws Exception {
+ for (final Map.Entry<Integer, List<Artifact>> entry :
+ app.getBundles().getBundlesByStartOrder().entrySet()) {
+ for (final Artifact a : entry.getValue()) {
final URL artifactFile = ctx.getArtifactFile(a.getId());
// add URL to feature metadata
@@ -176,29 +194,37 @@ public class FeatureProcessor {
for (final Configuration cfg : app.getConfigurations()) {
if (Configuration.isFactoryConfiguration(cfg.getPid())) {
- config.getInstallation().addConfiguration(Configuration.getName(cfg.getPid()),
- Configuration.getFactoryPid(cfg.getPid()), cfg.getConfigurationProperties());
+ config.getInstallation()
+ .addConfiguration(
+ Configuration.getName(cfg.getPid()),
+ Configuration.getFactoryPid(cfg.getPid()),
+ cfg.getConfigurationProperties());
} else {
config.getInstallation().addConfiguration(cfg.getPid(), null, cfg.getConfigurationProperties());
}
}
for (final Map.Entry<String, String> prop : app.getFrameworkProperties().entrySet()) {
- if ( !config.getInstallation().getFrameworkProperties().containsKey(prop.getKey()) ) {
+ if (!config.getInstallation().getFrameworkProperties().containsKey(prop.getKey())) {
config.getInstallation().getFrameworkProperties().put(prop.getKey(), prop.getValue());
}
}
- extensions: for(final Extension ext : app.getExtensions()) {
- for (ExtensionHandler handler : ServiceLoader.load(ExtensionHandler.class, FeatureProcessor.class.getClassLoader()))
- {
+ extensions:
+ for (final Extension ext : app.getExtensions()) {
+ for (ExtensionHandler handler :
+ ServiceLoader.load(ExtensionHandler.class, FeatureProcessor.class.getClassLoader())) {
ctx.getLogger().debug("Loaded handler {}", handler.getClass().getName());
if (handler.handle(new ExtensionContextImpl(ctx, config.getInstallation(), loadedFeatures), ext)) {
- ctx.getLogger().debug("Handled extension {} with handler {}", ext.getName(), handler.getClass().getName());
+ ctx.getLogger()
+ .debug(
+ "Handled extension {} with handler {}",
+ ext.getName(),
+ handler.getClass().getName());
continue extensions;
}
}
- if ( ext.getState() == ExtensionState.REQUIRED ) {
+ if (ext.getState() == ExtensionState.REQUIRED) {
throw new Exception("Unknown required extension " + ext.getName());
}
}
diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/Installation.java b/src/main/java/org/apache/sling/feature/launcher/impl/Installation.java
index f1945b3..5987cba 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/Installation.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/Installation.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.impl;
@@ -71,7 +73,7 @@ public class Installation implements LauncherRunContext {
*/
public void addBundle(final Integer startLevel, final URL file) {
List<URL> files = bundleMap.get(startLevel);
- if ( files == null ) {
+ if (files == null) {
files = new ArrayList<>();
bundleMap.put(startLevel, files);
}
@@ -92,7 +94,8 @@ public class Installation implements LauncherRunContext {
* @param factoryPid The factory pid
* @param properties The propertis
*/
- public void addConfiguration(final String pid, final String factoryPid, final Dictionary<String, Object> properties) {
+ public void addConfiguration(
+ final String pid, final String factoryPid, final Dictionary<String, Object> properties) {
this.configurations.add(new Object[] {pid, factoryPid, properties});
}
@@ -104,8 +107,7 @@ public class Installation implements LauncherRunContext {
return this.fwkProperties;
}
- public void addFrameworkProperty(String key, String value)
- {
+ public void addFrameworkProperty(String key, String value) {
this.fwkProperties.put(key, value);
}
diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/LauncherConfig.java b/src/main/java/org/apache/sling/feature/launcher/impl/LauncherConfig.java
index 64b5af6..d5e988a 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/LauncherConfig.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/LauncherConfig.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.impl;
@@ -32,8 +34,7 @@ import org.apache.sling.feature.io.artifacts.ArtifactManagerConfig;
/**
* This class holds the configuration of the launcher.
*/
-public class LauncherConfig
- extends ArtifactManagerConfig {
+public class LauncherConfig extends ArtifactManagerConfig {
private static final String HOME = "launcher";
@@ -41,9 +42,9 @@ public class LauncherConfig
private final List<ArtifactId> artifactClashOverrides = new ArrayList<>();
- private final Map<String,String> configClashOverrides = new LinkedHashMap<>();
+ private final Map<String, String> configClashOverrides = new LinkedHashMap<>();
- private final Map<String, Map<String,String>> extensionConfiguration = new HashMap<>();
+ private final Map<String, Map<String, String>> extensionConfiguration = new HashMap<>();
/** The feature files or directories. */
private final LinkedHashSet<String> featureFiles = new LinkedHashSet<>();
@@ -52,7 +53,7 @@ public class LauncherConfig
private volatile File home = new File(HOME);
- private final Map<String,String> variables = new HashMap<>();
+ private final Map<String, String> variables = new HashMap<>();
private volatile String frameworkVersion;
@@ -115,7 +116,7 @@ public class LauncherConfig
return this.installation;
}
- public Map<String,String> getVariables() {
+ public Map<String, String> getVariables() {
return this.variables;
}
diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/Main.java b/src/main/java/org/apache/sling/feature/launcher/impl/Main.java
index 478f8c0..4397aaa 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/Main.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/Main.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.impl;
@@ -81,8 +83,8 @@ public class Main {
private static Options options;
- private static final List<String> logLevels = Arrays.asList("trace", "debug", "info", "warn",
- "error", "off");
+ private static final List<String> logLevels = Arrays.asList("trace", "debug", "info", "warn", "error", "off");
+
private static Logger LOG() {
if (LOGGER == null) {
@@ -96,9 +98,9 @@ public class Main {
final int pos = keyVal.indexOf('=');
if (pos == -1) {
- return new String[] { keyVal, "true" };
+ return new String[] {keyVal, "true"};
}
- return new String[] { keyVal.substring(0, pos), keyVal.substring(pos + 1) };
+ return new String[] {keyVal.substring(0, pos), keyVal.substring(pos + 1)};
}
static Map.Entry<String, Map<String, String>> splitMap2(final String val) {
@@ -128,8 +130,7 @@ public class Main {
return extractValueFromOption(cl, opt, null);
}
- private static Optional<String> extractValueFromOption(CommandLine cl, String opt,
- String defaultVaue) {
+ private static Optional<String> extractValueFromOption(CommandLine cl, String opt, String defaultVaue) {
return Optional.ofNullable(cl.getOptionValue(opt, defaultVaue));
}
@@ -145,7 +146,7 @@ public class Main {
/**
* Parse the command line parameters and update a configuration object.
- *
+ *
* @param args Command line parameters
* @param config Configuration object
* @return Options object.
@@ -239,8 +240,7 @@ public class Main {
final Option frameworkVersionOption = Option.builder(OPT_FELIX_FRAMEWORK_VERSION)
.longOpt("felix-framework-version")
- .desc("Set Apache Felix framework version (default "
- .concat(Bootstrap.FELIX_FRAMEWORK_VERSION) + ")")
+ .desc("Set Apache Felix framework version (default ".concat(Bootstrap.FELIX_FRAMEWORK_VERSION) + ")")
.optionalArg(true)
.numberOfArgs(1)
.build();
@@ -253,12 +253,12 @@ public class Main {
.build();
final Option printInsideContainerHelp = Option.builder(OPT_PRINT_CONTAINER_ENV_HELP)
-
.desc("print additional help information for container env vars.")
.optionalArg(true)
.build();
-
- options = new Options().addOption(artifactClashOverride)
+
+ options = new Options()
+ .addOption(artifactClashOverride)
.addOption(configClashOverride)
.addOption(repoOption)
.addOption(featureOption)
@@ -274,39 +274,42 @@ public class Main {
.addOption(frameworkArtifactOption)
.addOption(printInsideContainerHelp);
-
final CommandLineParser clp = new DefaultParser();
try {
final CommandLine cl = clp.parse(options, args);
- extractValuesFromOption(cl, OPT_REPOSITORY_URLS).ifPresent(
- values -> config.setRepositoryUrls(values.stream().toArray(String[]::new)));
-
- extractValuesFromOption(cl, OPT_ARTICACT_CLASH).ifPresent(values -> values
- .forEach(v -> config.getArtifactClashOverrides().add(ArtifactId.parse(v))));
-
- extractValuesFromOption(cl, OPT_CONFIG_CLASH).orElseGet(ArrayList::new)
- .forEach(value -> {
- final String[] keyVal = split(value);
- config.getConfigClashOverrides().put(keyVal[0], keyVal[1]);
- });
-
- extractValuesFromOption(cl, OPT_FRAMEWORK_PROPERTIES).orElseGet(ArrayList::new)
- .forEach(value -> {
- final String[] keyVal = split(value);
- config.getInstallation().getFrameworkProperties().put(keyVal[0], keyVal[1]);
- });
-
- extractValuesFromOption(cl, OPT_VARIABLE_VALUES).orElseGet(ArrayList::new)
- .forEach(value -> {
- final String[] keyVal = split(value);
- config.getVariables().put(keyVal[0], keyVal[1]);
- });
+ extractValuesFromOption(cl, OPT_REPOSITORY_URLS)
+ .ifPresent(
+ values -> config.setRepositoryUrls(values.stream().toArray(String[]::new)));
+
+ extractValuesFromOption(cl, OPT_ARTICACT_CLASH)
+ .ifPresent(values -> values.forEach(
+ v -> config.getArtifactClashOverrides().add(ArtifactId.parse(v))));
+
+ extractValuesFromOption(cl, OPT_CONFIG_CLASH)
+ .orElseGet(ArrayList::new)
+ .forEach(value -> {
+ final String[] keyVal = split(value);
+ config.getConfigClashOverrides().put(keyVal[0], keyVal[1]);
+ });
+
+ extractValuesFromOption(cl, OPT_FRAMEWORK_PROPERTIES)
+ .orElseGet(ArrayList::new)
+ .forEach(value -> {
+ final String[] keyVal = split(value);
+ config.getInstallation().getFrameworkProperties().put(keyVal[0], keyVal[1]);
+ });
+
+ extractValuesFromOption(cl, OPT_VARIABLE_VALUES)
+ .orElseGet(ArrayList::new)
+ .forEach(value -> {
+ final String[] keyVal = split(value);
+ config.getVariables().put(keyVal[0], keyVal[1]);
+ });
if (cl.hasOption(OPT_VERBOSE)) {
extractValueFromOption(cl, OPT_VERBOSE, "debug").ifPresent(value -> {
-
if (isLoglevel(value)) {
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", value);
}
@@ -314,20 +317,18 @@ public class Main {
} // if not the `org.slf4j.simpleLogger.defaultLogLevel` is by default `info`
if (cl.hasOption(OPT_CACHE_ONLY)) {
- config.setCacheOnly(true);
+ config.setCacheOnly(true);
}
- extractValuesFromOption(cl, OPT_FEATURE_FILES).orElseGet(ArrayList::new)
+ extractValuesFromOption(cl, OPT_FEATURE_FILES)
+ .orElseGet(ArrayList::new)
.forEach(config::addFeatureFiles);
- extractValueFromOption(cl, OPT_LAUNCH_FEATURE_ID)
- .ifPresent(config::setLaunchFeatureId);
+ extractValueFromOption(cl, OPT_LAUNCH_FEATURE_ID).ifPresent(config::setLaunchFeatureId);
- extractValueFromOption(cl, OPT_CACHE_DIR).map(File::new)
- .ifPresent(config::setCacheDirectory);
+ extractValueFromOption(cl, OPT_CACHE_DIR).map(File::new).ifPresent(config::setCacheDirectory);
- extractValueFromOption(cl, OPT_HOME_DIR).map(File::new)
- .ifPresent(config::setHomeDirectory);
+ extractValueFromOption(cl, OPT_HOME_DIR).map(File::new).ifPresent(config::setHomeDirectory);
extractValuesFromOption(cl, OPT_EXTENSION_CONFIGURATION)
.ifPresent(values -> values.forEach(v -> {
@@ -341,11 +342,9 @@ public class Main {
c.putAll(xc.getValue());
}));
- extractValueFromOption(cl, OPT_FELIX_FRAMEWORK_VERSION)
- .ifPresent(config::setFrameworkVersion);
+ extractValueFromOption(cl, OPT_FELIX_FRAMEWORK_VERSION).ifPresent(config::setFrameworkVersion);
- extractValueFromOption(cl, OPT_OSGI_FRAMEWORK_ARTIFACT)
- .ifPresent(config::setFrameworkArtifact);
+ extractValueFromOption(cl, OPT_OSGI_FRAMEWORK_ARTIFACT).ifPresent(config::setFrameworkArtifact);
} catch (final ParseException pe) {
Main.LOG().error("Unable to parse command line: {}", pe.getMessage(), pe);
@@ -370,11 +369,10 @@ public class Main {
formatter.printHelp("launcher", options);
if (options.getOption(OPT_PRINT_CONTAINER_ENV_HELP) != null) {
- try (PrintWriter writer = new PrintWriter(System.out);) {
+ try (PrintWriter writer = new PrintWriter(System.out); ) {
writer.println("");
- writer.println(
- "If you are running sling-feature-launcher as an container please use env vars.");
+ writer.println("If you are running sling-feature-launcher as an container please use env vars.");
writer.println("");
writer.println(" cli-arg - container ENV variable");
@@ -382,17 +380,17 @@ public class Main {
writer.println(" -" + OPT_ARTICACT_CLASH + " - ARTIFACT_CLASH");
writer.println(" -" + OPT_CONFIG_CLASH + " - CONFIG_CLASH");
writer.println(" -" + OPT_CACHE_DIR + " - CACHE_DIR");
- writer.println(" -" + OPT_FRAMEWORK_PROPERTIES + " - FRAMEWORK_PROPERTIES format: `key1=val1` for more `key1=val1 -D key2=val2`");
+ writer.println(" -" + OPT_FRAMEWORK_PROPERTIES
+ + " - FRAMEWORK_PROPERTIES format: `key1=val1` for more `key1=val1 -D key2=val2`");
writer.println(" -" + OPT_FEATURE_FILES + " - FEATURE_FILES");
writer.println(" -" + OPT_HOME_DIR + " - HOME_DIR");
writer.println(" -" + OPT_REPOSITORY_URLS + " - REPOSITORY_URLS");
- writer.println(" -" + OPT_VARIABLE_VALUES + " - VARIABLE_VALUES format: `variable1=value1` for more `variable1=val1 -V variable2=val2`");
- writer.println(
- " -" + OPT_EXTENSION_CONFIGURATION + " - EXTENSION_CONFIGURATION");
- writer.println(
- " -" + OPT_FELIX_FRAMEWORK_VERSION + " - FELIX_FRAMEWORK_VERSION");
writer.println(
- " -" + OPT_OSGI_FRAMEWORK_ARTIFACT + " - OSGI_FRAMEWORK_ARTIFACT");
+ " -" + OPT_VARIABLE_VALUES
+ + " - VARIABLE_VALUES format: `variable1=value1` for more `variable1=val1 -V variable2=val2`");
+ writer.println(" -" + OPT_EXTENSION_CONFIGURATION + " - EXTENSION_CONFIGURATION");
+ writer.println(" -" + OPT_FELIX_FRAMEWORK_VERSION + " - FELIX_FRAMEWORK_VERSION");
+ writer.println(" -" + OPT_OSGI_FRAMEWORK_ARTIFACT + " - OSGI_FRAMEWORK_ARTIFACT");
writer.println(" -" + OPT_VERBOSE + " - VERBOSE {trace, debug, info, warn, error, off}");
writer.println("");
@@ -400,17 +398,17 @@ public class Main {
writer.flush();
}
}
-
}
/** Split a string into key and value */
private static String[] split(final String val) {
final int pos = val.indexOf('=');
- if ( pos == -1 ) {
+ if (pos == -1) {
return new String[] {val, "true"};
}
return new String[] {val.substring(0, pos), val.substring(pos + 1)};
}
+
public static void main(final String[] args) {
// setup logging
diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/VariableSubstitutor.java b/src/main/java/org/apache/sling/feature/launcher/impl/VariableSubstitutor.java
index 5058570..0ba5b85 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/VariableSubstitutor.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/VariableSubstitutor.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.impl;
@@ -36,4 +38,4 @@ public class VariableSubstitutor extends StringSubstitutor {
});
setEnableSubstitutionInVariables(true);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/extensions/handlers/ContentPackageHandler.java b/src/main/java/org/apache/sling/feature/launcher/impl/extensions/handlers/ContentPackageHandler.java
index 3597dd8..01fb3cb 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/extensions/handlers/ContentPackageHandler.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/extensions/handlers/ContentPackageHandler.java
@@ -1,45 +1,43 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.impl.extensions.handlers;
import java.io.IOException;
+import aQute.bnd.annotation.spi.ServiceProvider;
import org.apache.sling.feature.Artifact;
import org.apache.sling.feature.Extension;
import org.apache.sling.feature.ExtensionType;
import org.apache.sling.feature.launcher.spi.extensions.ExtensionContext;
import org.apache.sling.feature.launcher.spi.extensions.ExtensionHandler;
-import aQute.bnd.annotation.spi.ServiceProvider;
-
-@ServiceProvider(value =ExtensionHandler.class )
-public class ContentPackageHandler implements ExtensionHandler
-{
+@ServiceProvider(value = ExtensionHandler.class)
+public class ContentPackageHandler implements ExtensionHandler {
@Override
- public boolean handle(ExtensionContext context, Extension extension) throws IOException
- {
+ public boolean handle(ExtensionContext context, Extension extension) throws IOException {
if (extension.getType() == ExtensionType.ARTIFACTS
&& extension.getName().equals(Extension.EXTENSION_NAME_CONTENT_PACKAGES)) {
- for(final Artifact a : extension.getArtifacts() ) {
+ for (final Artifact a : extension.getArtifacts()) {
context.addInstallableArtifact(context.getArtifactFile(a.getId()));
}
return true;
- }
- else {
+ } else {
return false;
}
}
diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/extensions/handlers/RepoInitHandler.java b/src/main/java/org/apache/sling/feature/launcher/impl/extensions/handlers/RepoInitHandler.java
index d49104e..ab30252 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/extensions/handlers/RepoInitHandler.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/extensions/handlers/RepoInitHandler.java
@@ -1,48 +1,49 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.impl.extensions.handlers;
import java.util.concurrent.atomic.AtomicInteger;
+import aQute.bnd.annotation.spi.ServiceProvider;
import org.apache.sling.feature.Configuration;
import org.apache.sling.feature.Extension;
import org.apache.sling.feature.ExtensionType;
import org.apache.sling.feature.launcher.spi.extensions.ExtensionContext;
import org.apache.sling.feature.launcher.spi.extensions.ExtensionHandler;
-import aQute.bnd.annotation.spi.ServiceProvider;
-
-@ServiceProvider(value =ExtensionHandler.class )
-public class RepoInitHandler implements ExtensionHandler
-{
+@ServiceProvider(value = ExtensionHandler.class)
+public class RepoInitHandler implements ExtensionHandler {
private static final AtomicInteger index = new AtomicInteger(1);
@Override
- public boolean handle(ExtensionContext context, Extension extension) throws Exception
- {
+ public boolean handle(ExtensionContext context, Extension extension) throws Exception {
if (extension.getName().equals(Extension.EXTENSION_NAME_REPOINIT)) {
- if ( extension.getType() != ExtensionType.TEXT ) {
+ if (extension.getType() != ExtensionType.TEXT) {
throw new Exception(Extension.EXTENSION_NAME_REPOINIT + " extension must be of type text");
}
final Configuration cfg = new Configuration("org.apache.sling.jcr.repoinit.RepositoryInitializer~repoinit"
+ String.valueOf(index.getAndIncrement()));
cfg.getProperties().put("scripts", extension.getText());
- context.addConfiguration(Configuration.getName(cfg.getPid()),
- Configuration.getFactoryPid(cfg.getPid()), cfg.getConfigurationProperties());
+ context.addConfiguration(
+ Configuration.getName(cfg.getPid()),
+ Configuration.getFactoryPid(cfg.getPid()),
+ cfg.getConfigurationProperties());
return true;
}
return false;
diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/launchers/AbstractRunner.java b/src/main/java/org/apache/sling/feature/launcher/impl/launchers/AbstractRunner.java
index ff80c43..b80b906 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/launchers/AbstractRunner.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/launchers/AbstractRunner.java
@@ -1,22 +1,23 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.impl.launchers;
-import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.lang.reflect.Array;
@@ -74,8 +75,8 @@ public abstract class AbstractRunner implements Callable<Integer> {
private static final String PM_FEATURE_LAUNCHER = "featurelauncher";
/** Filter expression to get the memory persistence manager. */
- private static final String PM_MEMORY_FILTER = "(&(" + Constants.OBJECTCLASS
- + "=org.apache.felix.cm.PersistenceManager)(name=memory))";
+ private static final String PM_MEMORY_FILTER =
+ "(&(" + Constants.OBJECTCLASS + "=org.apache.felix.cm.PersistenceManager)(name=memory))";
private volatile ServiceTracker<Object, Object> configAdminTracker;
@@ -105,32 +106,35 @@ public abstract class AbstractRunner implements Callable<Integer> {
this.bundleReporter = reporter;
}
- protected void setupFramework(final Framework framework, final Map<Integer, List<URL>> bundlesMap) throws BundleException {
+ protected void setupFramework(final Framework framework, final Map<Integer, List<URL>> bundlesMap)
+ throws BundleException {
// check for Apache Felix CM persistence manager config
final String pm = framework.getBundleContext().getProperty(CM_CONFIG_PM);
if (PM_FEATURE_LAUNCHER.equals(pm)) {
logger.info("Using feature launcher configuration admin persistence manager");
try {
// we start a tracker for the memory PM
- this.configAdminTracker = new ServiceTracker<>(framework.getBundleContext(),
+ this.configAdminTracker = new ServiceTracker<>(
+ framework.getBundleContext(),
framework.getBundleContext().createFilter(PM_MEMORY_FILTER),
-
new ServiceTrackerCustomizer<Object, Object>() {
private volatile ServiceRegistration<?> reg;
@Override
public Object addingService(final ServiceReference<Object> reference) {
// get memory pm
- final Object memoryPM = framework.getBundleContext().getService(reference);
+ final Object memoryPM =
+ framework.getBundleContext().getService(reference);
if (memoryPM != null) {
try {
// we re use the memory PM (it is not used anyway)
// and simply store the configs there using reflection
- final Method storeMethod = memoryPM.getClass().getDeclaredMethod("store",
- String.class, Dictionary.class);
+ final Method storeMethod = memoryPM.getClass()
+ .getDeclaredMethod("store", String.class, Dictionary.class);
for (final Object[] obj : configurations) {
@SuppressWarnings("unchecked")
- final Dictionary<String, Object> props = (Dictionary<String, Object>) obj[2];
+ final Dictionary<String, Object> props =
+ (Dictionary<String, Object>) obj[2];
final String pid;
if (obj[1] != null) {
final String factoryPid = (String) obj[1];
@@ -145,10 +149,16 @@ public abstract class AbstractRunner implements Callable<Integer> {
// register feature launcher pm
final Dictionary<String, Object> properties = new Hashtable<>();
properties.put("name", PM_FEATURE_LAUNCHER);
- reg = reference.getBundle().getBundleContext().registerService(
- "org.apache.felix.cm.PersistenceManager", memoryPM, properties);
- } catch (IllegalAccessException | IllegalArgumentException
- | InvocationTargetException | NoSuchMethodException | SecurityException e) {
+ reg = reference
+ .getBundle()
+ .getBundleContext()
+ .registerService(
+ "org.apache.felix.cm.PersistenceManager", memoryPM, properties);
+ } catch (IllegalAccessException
+ | IllegalArgumentException
+ | InvocationTargetException
+ | NoSuchMethodException
+ | SecurityException e) {
throw new RuntimeException(e);
}
}
@@ -176,8 +186,10 @@ public abstract class AbstractRunner implements Callable<Integer> {
this.configAdminTracker.open(true);
} else if (!configurations.isEmpty()) {
- this.configAdminTracker = new ServiceTracker<>(framework.getBundleContext(),
- "org.osgi.service.cm.ConfigurationAdmin", new ServiceTrackerCustomizer<Object, Object>() {
+ this.configAdminTracker = new ServiceTracker<>(
+ framework.getBundleContext(),
+ "org.osgi.service.cm.ConfigurationAdmin",
+ new ServiceTrackerCustomizer<Object, Object>() {
@Override
public Object addingService(final ServiceReference<Object> reference) {
@@ -205,16 +217,18 @@ public abstract class AbstractRunner implements Callable<Integer> {
});
this.configAdminTracker.open(true);
}
- if ( !installables.isEmpty() ) {
- this.installerTracker = new ServiceTracker<>(framework.getBundleContext(),
+ if (!installables.isEmpty()) {
+ this.installerTracker = new ServiceTracker<>(
+ framework.getBundleContext(),
"org.apache.sling.installer.api.OsgiInstaller",
new ServiceTrackerCustomizer<Object, Object>() {
@Override
public Object addingService(final ServiceReference<Object> reference) {
// get installer
- final Object installer = framework.getBundleContext().getService(reference);
- if ( installer != null ) {
+ final Object installer =
+ framework.getBundleContext().getService(reference);
+ if (installer != null) {
try {
install(installer);
} finally {
@@ -233,20 +247,19 @@ public abstract class AbstractRunner implements Callable<Integer> {
public void removedService(ServiceReference<Object> reference, Object service) {
// nothing to do
}
- });
+ });
this.installerTracker.open();
}
this.install(framework, bundlesMap);
}
- protected boolean startFramework(final Framework framework, long timeout, TimeUnit unit) throws BundleException, InterruptedException {
+ protected boolean startFramework(final Framework framework, long timeout, TimeUnit unit)
+ throws BundleException, InterruptedException {
Executor executor = Executors.newSingleThreadExecutor();
- Future<Void> result = ((ExecutorService) executor).submit(new Callable<Void>()
- {
+ Future<Void> result = ((ExecutorService) executor).submit(new Callable<Void>() {
@Override
- public Void call() throws Exception
- {
+ public Void call() throws Exception {
framework.start();
return null;
}
@@ -264,35 +277,40 @@ public abstract class AbstractRunner implements Callable<Integer> {
} else {
throw (RuntimeException) cause;
}
- }
- finally {
+ } finally {
((ExecutorService) executor).shutdownNow();
}
}
private void configure(final Object configAdmin) {
try {
- final Method createConfig = configAdmin.getClass().getDeclaredMethod("getConfiguration", String.class, String.class);
- final Method createFactoryConfig = configAdmin.getClass().getDeclaredMethod("getFactoryConfiguration", String.class, String.class, String.class);
+ final Method createConfig =
+ configAdmin.getClass().getDeclaredMethod("getConfiguration", String.class, String.class);
+ final Method createFactoryConfig = configAdmin
+ .getClass()
+ .getDeclaredMethod("getFactoryConfiguration", String.class, String.class, String.class);
Method updateMethod = null;
- for(final Object[] obj : this.configurations) {
+ for (final Object[] obj : this.configurations) {
final Object cfg;
- if ( obj[1] != null ) {
+ if (obj[1] != null) {
cfg = createFactoryConfig.invoke(configAdmin, obj[1], obj[0], null);
} else {
cfg = createConfig.invoke(configAdmin, obj[0], null);
}
- if ( updateMethod == null ) {
+ if (updateMethod == null) {
updateMethod = cfg.getClass().getDeclaredMethod("update", Dictionary.class);
}
updateMethod.invoke(cfg, obj[2]);
}
- } catch ( final Exception e) {
+ } catch (final Exception e) {
logger.error("Unable to create configurations", e);
throw new RuntimeException(e);
}
- final Thread t = new Thread(() -> { configAdminTracker.close(); configAdminTracker = null; });
+ final Thread t = new Thread(() -> {
+ configAdminTracker.close();
+ configAdminTracker = null;
+ });
t.setDaemon(false);
t.start();
this.configurations.clear();
@@ -300,15 +318,14 @@ public abstract class AbstractRunner implements Callable<Integer> {
private boolean isSystemBundleFragment(final Bundle installedBundle) {
final String fragmentHeader = getFragmentHostHeader(installedBundle);
- return fragmentHeader != null
- && fragmentHeader.indexOf(Constants.EXTENSION_DIRECTIVE) > 0;
+ return fragmentHeader != null && fragmentHeader.indexOf(Constants.EXTENSION_DIRECTIVE) > 0;
}
/**
* Gets the bundle's Fragment-Host header.
*/
private String getFragmentHostHeader(final Bundle b) {
- return b.getHeaders().get( Constants.FRAGMENT_HOST );
+ return b.getHeaders().get(Constants.FRAGMENT_HOST);
}
/**
@@ -319,10 +336,10 @@ public abstract class AbstractRunner implements Callable<Integer> {
private void install(final Framework framework, final Map<Integer, List<URL>> bundleMap) throws BundleException {
final BundleContext bc = framework.getBundleContext();
int defaultStartLevel = getProperty(bc, "felix.startlevel.bundle", 1);
- for(final Integer startLevel : sortStartLevels(bundleMap.keySet(), defaultStartLevel)) {
+ for (final Integer startLevel : sortStartLevels(bundleMap.keySet(), defaultStartLevel)) {
logger.debug("Installing bundles with start level {}", startLevel);
- for(final URL file : bundleMap.get(startLevel)) {
+ for (final URL file : bundleMap.get(startLevel)) {
logger.debug("- {}", file);
// use reference protocol if possible. This avoids copying the binary to the cache directory
@@ -336,14 +353,14 @@ public abstract class AbstractRunner implements Callable<Integer> {
final Bundle bundle = bc.installBundle(location, null);
// fragment?
- if ( !isSystemBundleFragment(bundle) && getFragmentHostHeader(bundle) == null ) {
- if ( startLevel > 0 ) {
+ if (!isSystemBundleFragment(bundle) && getFragmentHostHeader(bundle) == null) {
+ if (startLevel > 0) {
bundle.adapt(BundleStartLevel.class).setStartLevel(startLevel);
}
bundle.start();
}
- if ( this.bundleReporter != null ) {
+ if (this.bundleReporter != null) {
final Map<String, String> params = new HashMap<>();
params.put(Constants.BUNDLE_SYMBOLICNAME, bundle.getSymbolicName());
params.put(Constants.BUNDLE_VERSION, bundle.getVersion().toString());
@@ -351,52 +368,66 @@ public abstract class AbstractRunner implements Callable<Integer> {
this.bundleReporter.accept(file, params);
}
-
}
}
}
protected void finishStartup(final Framework framework) {
Bundle featureBundle = null;
- for(final Bundle bundle : framework.getBundleContext().getBundles()) {
- if ( featureSupplier != null && "org.apache.sling.feature".equals(bundle.getSymbolicName()) ) {
+ for (final Bundle bundle : framework.getBundleContext().getBundles()) {
+ if (featureSupplier != null && "org.apache.sling.feature".equals(bundle.getSymbolicName())) {
featureBundle = bundle;
}
}
- if ( featureBundle != null ) {
+ if (featureBundle != null) {
final Bundle bundle = featureBundle;
// the feature is registered as a prototype to give each client a copy as feature models are mutable
final Dictionary<String, Object> properties = new Hashtable<>();
properties.put("name", "org.apache.sling.feature.launcher");
- featureBundle.getBundleContext().registerService(new String[] {"org.apache.sling.feature.Feature"},
- new PrototypeServiceFactory<Object>() {
-
- @Override
- public Object getService(final Bundle client, final ServiceRegistration<Object> registration) {
- final ClassLoader cl = bundle.adapt(BundleWiring.class).getClassLoader();
- final ClassLoader oldTCCL = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(cl);
- try {
- final Class<?> readerClass = cl.loadClass("org.apache.sling.feature.io.json.FeatureJSONReader");
- final Method readMethod = readerClass.getDeclaredMethod("read", java.io.Reader.class, String.class);
- try( final StringReader reader = new StringReader(featureSupplier.get())) {
- return readMethod.invoke(null, reader, null);
- }
- } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalArgumentException | IllegalAccessException | InvocationTargetException e) {
- // ignore
- } finally {
- Thread.currentThread().setContextClassLoader(oldTCCL);
- }
- return null;
- }
+ featureBundle
+ .getBundleContext()
+ .registerService(
+ new String[] {"org.apache.sling.feature.Feature"},
+ new PrototypeServiceFactory<Object>() {
+
+ @Override
+ public Object getService(
+ final Bundle client, final ServiceRegistration<Object> registration) {
+ final ClassLoader cl =
+ bundle.adapt(BundleWiring.class).getClassLoader();
+ final ClassLoader oldTCCL =
+ Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(cl);
+ try {
+ final Class<?> readerClass =
+ cl.loadClass("org.apache.sling.feature.io.json.FeatureJSONReader");
+ final Method readMethod = readerClass.getDeclaredMethod(
+ "read", java.io.Reader.class, String.class);
+ try (final StringReader reader = new StringReader(featureSupplier.get())) {
+ return readMethod.invoke(null, reader, null);
+ }
+ } catch (ClassNotFoundException
+ | NoSuchMethodException
+ | SecurityException
+ | IllegalArgumentException
+ | IllegalAccessException
+ | InvocationTargetException e) {
+ // ignore
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldTCCL);
+ }
+ return null;
+ }
- @Override
- public void ungetService(final Bundle client, final ServiceRegistration<Object> registration,
- final Object service) {
- // nothing to do
- }
-
- }, properties);
+ @Override
+ public void ungetService(
+ final Bundle client,
+ final ServiceRegistration<Object> registration,
+ final Object service) {
+ // nothing to do
+ }
+ },
+ properties);
}
}
@@ -407,7 +438,8 @@ public abstract class AbstractRunner implements Callable<Integer> {
* @param startLevels integer start levels
* @return sorted start levels
*/
- private static Iterable<Integer> sortStartLevels(final Collection<Integer> startLevels, final int defaultStartLevel) {
+ private static Iterable<Integer> sortStartLevels(
+ final Collection<Integer> startLevels, final int defaultStartLevel) {
final List<Integer> result = new ArrayList<>(startLevels);
Collections.sort(result, (o1, o2) -> {
int i1 = o1 == 0 ? defaultStartLevel : o1;
@@ -428,33 +460,29 @@ public abstract class AbstractRunner implements Callable<Integer> {
private void install(final Object installer) {
try {
- final Class<?> installableResourceClass = installer.getClass().getClassLoader().loadClass("org.apache.sling.installer.api.InstallableResource");
+ final Class<?> installableResourceClass = installer
+ .getClass()
+ .getClassLoader()
+ .loadClass("org.apache.sling.installer.api.InstallableResource");
final Object resources = Array.newInstance(installableResourceClass, this.installables.size());
- final Method registerResources = installer.getClass().getDeclaredMethod("registerResources", String.class, resources.getClass());
- final Constructor<?> constructor = installableResourceClass.getDeclaredConstructor(String.class,
- InputStream.class,
- Dictionary.class,
- String.class,
- String.class,
- Integer.class);
-
- for(int i=0; i<this.installables.size();i++) {
+ final Method registerResources =
+ installer.getClass().getDeclaredMethod("registerResources", String.class, resources.getClass());
+ final Constructor<?> constructor = installableResourceClass.getDeclaredConstructor(
+ String.class, InputStream.class, Dictionary.class, String.class, String.class, Integer.class);
+
+ for (int i = 0; i < this.installables.size(); i++) {
final URL f = this.installables.get(i);
final Dictionary<String, Object> dict = new Hashtable<>();
dict.put("resource.uri.hint", f.toURI().toString());
- final Object rsrc = constructor.newInstance(f.getPath(),
- f.openStream(),
- dict,
- f.getPath(),
- "file",
- null);
+ final Object rsrc =
+ constructor.newInstance(f.getPath(), f.openStream(), dict, f.getPath(), "file", null);
Array.set(resources, i, rsrc);
}
registerResources.invoke(installer, "cloudlauncher", resources);
- } catch ( final Exception e) {
+ } catch (final Exception e) {
logger.error("Unable to contact installer and install additional artifacts", e);
throw new RuntimeException(e);
- } finally {
+ } finally {
final Thread t = new Thread(() -> {
installerTracker.close();
installerTracker = null;
diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/launchers/FrameworkLauncher.java b/src/main/java/org/apache/sling/feature/launcher/impl/launchers/FrameworkLauncher.java
index 07403c7..4859373 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/launchers/FrameworkLauncher.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/launchers/FrameworkLauncher.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.impl.launchers;
@@ -29,6 +31,7 @@ import java.util.concurrent.Callable;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
+import aQute.bnd.annotation.spi.ServiceProvider;
import org.apache.sling.feature.Artifact;
import org.apache.sling.feature.ArtifactId;
import org.apache.sling.feature.Feature;
@@ -38,8 +41,6 @@ import org.apache.sling.feature.launcher.spi.Launcher;
import org.apache.sling.feature.launcher.spi.LauncherPrepareContext;
import org.apache.sling.feature.launcher.spi.LauncherRunContext;
-import aQute.bnd.annotation.spi.ServiceProvider;
-
/**
* Launcher directly using the OSGi launcher API.
*/
@@ -49,9 +50,8 @@ public class FrameworkLauncher implements Launcher {
private Feature feature;
@Override
- public void prepare(final LauncherPrepareContext context,
- final ArtifactId frameworkId,
- final Feature app) throws Exception {
+ public void prepare(final LauncherPrepareContext context, final ArtifactId frameworkId, final Feature app)
+ throws Exception {
context.addAppJar(context.getArtifactFile(frameworkId));
this.feature = app;
}
@@ -70,19 +70,19 @@ public class FrameworkLauncher implements Launcher {
});
if (context.getLogger().isDebugEnabled()) {
context.getLogger().debug("Bundles:");
- for(final Integer key : context.getBundleMap().keySet()) {
+ for (final Integer key : context.getBundleMap().keySet()) {
context.getLogger().debug("-- Start Level {}", key);
- for(final URL f : context.getBundleMap().get(key)) {
+ for (final URL f : context.getBundleMap().get(key)) {
context.getLogger().debug(" - {}", f);
}
}
context.getLogger().debug("Settings: ");
- for(final Map.Entry<String, String> entry : properties.entrySet()) {
+ for (final Map.Entry<String, String> entry : properties.entrySet()) {
context.getLogger().debug("- {}={}", entry.getKey(), entry.getValue());
}
context.getLogger().debug("Configurations: ");
- for(final Object[] entry : context.getConfigurations()) {
- if ( entry[1] != null ) {
+ for (final Object[] entry : context.getConfigurations()) {
+ if (entry[1] != null) {
context.getLogger().debug("- Factory {} - {}", entry[1], entry[0]);
} else {
context.getLogger().debug("- {}", entry[0]);
@@ -92,43 +92,41 @@ public class FrameworkLauncher implements Launcher {
}
final Class<?> runnerClass = cl.loadClass(getFrameworkRunnerClass());
- final Constructor<?> constructor = runnerClass.getDeclaredConstructor(Map.class, Map.class, List.class,
- List.class);
+ final Constructor<?> constructor =
+ runnerClass.getDeclaredConstructor(Map.class, Map.class, List.class, List.class);
constructor.setAccessible(true);
@SuppressWarnings("unchecked")
- Callable<Integer> restart = (Callable<Integer>) constructor.newInstance(properties, context.getBundleMap(),
- context.getConfigurations(), context.getInstallableArtifacts());
+ Callable<Integer> restart = (Callable<Integer>) constructor.newInstance(
+ properties, context.getBundleMap(), context.getConfigurations(), context.getInstallableArtifacts());
setOptionalSupplier(restart, "setFeatureSupplier", new Supplier<Object>() {
@Override
public Object get() {
- try ( final StringWriter writer = new StringWriter()) {
+ try (final StringWriter writer = new StringWriter()) {
FeatureJSONWriter.write(writer, feature);
writer.flush();
return writer.toString();
- } catch ( final IOException ignore) {
+ } catch (final IOException ignore) {
// ignore
}
return null;
}
-
});
setOptionalBiConsumer(restart, "setBundleReporter", new BiConsumer<URL, Map<String, String>>() {
@Override
public void accept(final URL url, final Map<String, String> values) {
final String urlString = url.toString();
- for(final Artifact a : feature.getBundles()) {
- if ( urlString.equals(a.getMetadata().get(URL.class.getName()))) {
- for(final Map.Entry<String, String> entry : values.entrySet()) {
+ for (final Artifact a : feature.getBundles()) {
+ if (urlString.equals(a.getMetadata().get(URL.class.getName()))) {
+ for (final Map.Entry<String, String> entry : values.entrySet()) {
a.getMetadata().put(entry.getKey(), entry.getValue());
}
break;
}
}
}
-
});
return restart.call();
// nothing else to do, constructor starts everything
@@ -138,22 +136,24 @@ public class FrameworkLauncher implements Launcher {
return FrameworkRunner.class.getName();
}
- private void setOptionalSupplier(final Object restart, final String name, final Supplier<Object> supplier) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ private void setOptionalSupplier(final Object restart, final String name, final Supplier<Object> supplier)
+ throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
try {
final Method setSupplier = restart.getClass().getMethod(name, Supplier.class);
setSupplier.setAccessible(true);
setSupplier.invoke(restart, supplier);
- } catch ( final NoSuchMethodException nsme) {
+ } catch (final NoSuchMethodException nsme) {
// ignore
}
}
- private void setOptionalBiConsumer(final Object restart, final String name, final BiConsumer consumer) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ private void setOptionalBiConsumer(final Object restart, final String name, final BiConsumer consumer)
+ throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
try {
final Method setMethod = restart.getClass().getMethod(name, BiConsumer.class);
setMethod.setAccessible(true);
setMethod.invoke(restart, consumer);
- } catch ( final NoSuchMethodException nsme) {
+ } catch (final NoSuchMethodException nsme) {
// ignore
}
}
diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/launchers/FrameworkRunner.java b/src/main/java/org/apache/sling/feature/launcher/impl/launchers/FrameworkRunner.java
index ac5b6ee..b526623 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/launchers/FrameworkRunner.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/launchers/FrameworkRunner.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.impl.launchers;
@@ -43,15 +45,17 @@ public class FrameworkRunner extends AbstractRunner {
private final Map<Integer, List<URL>> bundlesMap;
- public FrameworkRunner(final Map<String, String> frameworkProperties,
+ public FrameworkRunner(
+ final Map<String, String> frameworkProperties,
final Map<Integer, List<URL>> bundlesMap,
final List<Object[]> configurations,
- final List<URL> installables) throws Exception {
+ final List<URL> installables)
+ throws Exception {
super(configurations, installables);
this.frameworkProperties = frameworkProperties;
this.bundlesMap = bundlesMap;
}
-
+
/**
* Get the framework factory
* @return Return the first factory found via service loaders
@@ -60,11 +64,11 @@ public class FrameworkRunner extends AbstractRunner {
protected FrameworkFactory getFrameworkFactory() throws Exception {
final ServiceLoader<FrameworkFactory> loader = ServiceLoader.load(FrameworkFactory.class);
FrameworkFactory factory = null;
- for(FrameworkFactory f : loader) {
+ for (FrameworkFactory f : loader) {
factory = f;
break;
}
- if ( factory == null ) {
+ if (factory == null) {
throw new Exception("Unable to locate framework factory.");
}
return factory;
@@ -88,8 +92,7 @@ public class FrameworkRunner extends AbstractRunner {
framework.stop();
FrameworkEvent waitForStop = framework.waitForStop(graceTime * 1000);
if (waitForStop.getType() != FrameworkEvent.STOPPED) {
- logger.warn("Framework stopped with: " + waitForStop.getType(),
- waitForStop.getThrowable());
+ logger.warn("Framework stopped with: " + waitForStop.getType(), waitForStop.getThrowable());
} else {
logger.info("Framework stopped");
}
diff --git a/src/main/java/org/apache/sling/feature/launcher/spi/Launcher.java b/src/main/java/org/apache/sling/feature/launcher/spi/Launcher.java
index 8c64ff0..3a78a85 100644
--- a/src/main/java/org/apache/sling/feature/launcher/spi/Launcher.java
+++ b/src/main/java/org/apache/sling/feature/launcher/spi/Launcher.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.spi;
@@ -36,6 +38,7 @@ public interface Launcher {
static {
ClassLoader.registerAsParallelCapable();
}
+
public LauncherClassLoader() {
super(new URL[0]);
}
diff --git a/src/main/java/org/apache/sling/feature/launcher/spi/LauncherPrepareContext.java b/src/main/java/org/apache/sling/feature/launcher/spi/LauncherPrepareContext.java
index e0ec94d..f8ab1a0 100644
--- a/src/main/java/org/apache/sling/feature/launcher/spi/LauncherPrepareContext.java
+++ b/src/main/java/org/apache/sling/feature/launcher/spi/LauncherPrepareContext.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.spi;
diff --git a/src/main/java/org/apache/sling/feature/launcher/spi/LauncherRunContext.java b/src/main/java/org/apache/sling/feature/launcher/spi/LauncherRunContext.java
index 5c6d9fe..831576a 100644
--- a/src/main/java/org/apache/sling/feature/launcher/spi/LauncherRunContext.java
+++ b/src/main/java/org/apache/sling/feature/launcher/spi/LauncherRunContext.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.spi;
@@ -60,7 +62,7 @@ public interface LauncherRunContext {
/**
* Get the central logger
- *
+ *
* @return The logger
*/
Logger getLogger();
diff --git a/src/main/java/org/apache/sling/feature/launcher/spi/extensions/ExtensionContext.java b/src/main/java/org/apache/sling/feature/launcher/spi/extensions/ExtensionContext.java
index 3491442..95a71f1 100644
--- a/src/main/java/org/apache/sling/feature/launcher/spi/extensions/ExtensionContext.java
+++ b/src/main/java/org/apache/sling/feature/launcher/spi/extensions/ExtensionContext.java
@@ -1,30 +1,32 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.spi.extensions;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Dictionary;
+
import org.apache.sling.feature.ArtifactId;
import org.apache.sling.feature.Feature;
import org.apache.sling.feature.launcher.spi.LauncherPrepareContext;
import org.apache.sling.feature.launcher.spi.LauncherRunContext;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Dictionary;
-
/**
* This context object is provided to launcher extensions.
*/
@@ -48,7 +50,8 @@ public interface ExtensionContext extends LauncherPrepareContext, LauncherRunCon
* @param factoryPid The factory pid
* @param properties The propertis
*/
- public void addConfiguration(final String pid, final String factoryPid, final Dictionary<String, Object> properties);
+ public void addConfiguration(
+ final String pid, final String factoryPid, final Dictionary<String, Object> properties);
/**
* Add a framework property to be set by the launcher.
diff --git a/src/main/java/org/apache/sling/feature/launcher/spi/extensions/ExtensionHandler.java b/src/main/java/org/apache/sling/feature/launcher/spi/extensions/ExtensionHandler.java
index 976b065..d2eb4ab 100644
--- a/src/main/java/org/apache/sling/feature/launcher/spi/extensions/ExtensionHandler.java
+++ b/src/main/java/org/apache/sling/feature/launcher/spi/extensions/ExtensionHandler.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.spi.extensions;
@@ -29,7 +31,7 @@ import org.apache.sling.feature.Extension;
*/
public interface ExtensionHandler {
- /**
+ /**
* Try to handle the extension. As soon as a handler returns {@code true},
* no other handler is invoked for this extension.
*
@@ -37,6 +39,6 @@ public interface ExtensionHandler {
* @param extension The feature model extension
* @return {@code true} if the handler handled the extension.
* @throws Exception If an error occurs during processing of the extension.
- */
+ */
public boolean handle(ExtensionContext context, Extension extension) throws Exception;
}
diff --git a/src/test/java/org/apache/sling/feature/launcher/impl/ExtensionContextImplTest.java b/src/test/java/org/apache/sling/feature/launcher/impl/ExtensionContextImplTest.java
index 2b113bb..4c21652 100644
--- a/src/test/java/org/apache/sling/feature/launcher/impl/ExtensionContextImplTest.java
+++ b/src/test/java/org/apache/sling/feature/launcher/impl/ExtensionContextImplTest.java
@@ -1,31 +1,33 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.impl;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.sling.feature.ArtifactId;
import org.apache.sling.feature.Feature;
import org.apache.sling.feature.launcher.spi.LauncherPrepareContext;
import org.junit.Test;
import org.mockito.Mockito;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
diff --git a/src/test/java/org/apache/sling/feature/launcher/impl/MainIT.java b/src/test/java/org/apache/sling/feature/launcher/impl/MainIT.java
index a3e6450..7548ba4 100644
--- a/src/test/java/org/apache/sling/feature/launcher/impl/MainIT.java
+++ b/src/test/java/org/apache/sling/feature/launcher/impl/MainIT.java
@@ -1,28 +1,23 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.impl;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
import java.security.Permission;
import java.util.AbstractMap;
import java.util.Collections;
@@ -36,6 +31,13 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
/**
* Run this as part of integration tests to help make sure we embed the right
* Apache commons classes.
@@ -92,18 +94,18 @@ public class MainIT {
@Test
public void testSplitCommandlineArgs() {
- assertArrayEquals(new String[] { "hi", "ho" }, Main.splitKeyVal("hi=ho"));
- assertArrayEquals(new String[] { "hi.de.hi", "true" }, Main.splitKeyVal("hi.de.hi"));
+ assertArrayEquals(new String[] {"hi", "ho"}, Main.splitKeyVal("hi=ho"));
+ assertArrayEquals(new String[] {"hi.de.hi", "true"}, Main.splitKeyVal("hi.de.hi"));
}
@Test
public void testSplitMapCommandlineArgs() {
- assertEquals(new AbstractMap.SimpleEntry<>("foo", Collections.singletonMap("bar", "tar")),
+ assertEquals(
+ new AbstractMap.SimpleEntry<>("foo", Collections.singletonMap("bar", "tar")),
Main.splitMap2("foo:bar=tar"));
- assertEquals(new AbstractMap.SimpleEntry<>("hello", Collections.emptyMap()),
- Main.splitMap2("hello"));
+ assertEquals(new AbstractMap.SimpleEntry<>("hello", Collections.emptyMap()), Main.splitMap2("hello"));
Map<String, String> em = new HashMap<>();
em.put("a.b.c", "d.e.f");
@@ -128,86 +130,77 @@ public class MainIT {
Options os = mock(Options.class);
Option o = mock(Option.class);
when(os.getOption(Main.OPT_PRINT_CONTAINER_ENV_HELP)).thenReturn(o);
-
}
@Test
public void testParseVerbose() {
- Main.parseArgs(noActionAllowesConfig, new String[] { });
+ Main.parseArgs(noActionAllowesConfig, new String[] {});
assertNull(System.getProperty("org.slf4j.simpleLogger.defaultLogLevel"));
- Main.parseArgs(noActionAllowesConfig, new String[] { "-" + Main.OPT_VERBOSE });
+ Main.parseArgs(noActionAllowesConfig, new String[] {"-" + Main.OPT_VERBOSE});
assertEquals("debug", System.getProperty("org.slf4j.simpleLogger.defaultLogLevel"));
- Main.parseArgs(noActionAllowesConfig, new String[] { "-" + Main.OPT_VERBOSE, "debug" });
+ Main.parseArgs(noActionAllowesConfig, new String[] {"-" + Main.OPT_VERBOSE, "debug"});
assertEquals("debug", System.getProperty("org.slf4j.simpleLogger.defaultLogLevel"));
- Main.parseArgs(noActionAllowesConfig, new String[] { "-" + Main.OPT_VERBOSE, "warn" });
+ Main.parseArgs(noActionAllowesConfig, new String[] {"-" + Main.OPT_VERBOSE, "warn"});
assertEquals("warn", System.getProperty("org.slf4j.simpleLogger.defaultLogLevel"));
-
}
@Test
public void testParseHome() {
- Main.parseArgs(noActionAllowesConfig, new String[] { "-" + Main.OPT_HOME_DIR });
+ Main.parseArgs(noActionAllowesConfig, new String[] {"-" + Main.OPT_HOME_DIR});
LauncherConfig config = new LauncherConfig();
- Main.parseArgs(config, new String[] { "-" + Main.OPT_HOME_DIR, "foo" });
+ Main.parseArgs(config, new String[] {"-" + Main.OPT_HOME_DIR, "foo"});
assertEquals("foo", config.getHomeDirectory().toString());
-
}
@Test
public void testParseCacheDir() {
- Main.parseArgs(noActionAllowesConfig, new String[] { "-" + Main.OPT_CACHE_DIR });
+ Main.parseArgs(noActionAllowesConfig, new String[] {"-" + Main.OPT_CACHE_DIR});
LauncherConfig config = new LauncherConfig();
- Main.parseArgs(config, new String[] { "-" + Main.OPT_CACHE_DIR, "foo" });
+ Main.parseArgs(config, new String[] {"-" + Main.OPT_CACHE_DIR, "foo"});
assertEquals("foo", config.getCacheDirectory().toString());
-
}
@Test
public void testParseFelixFwVersion() {
- Main.parseArgs(noActionAllowesConfig,
- new String[] { "-" + Main.OPT_FELIX_FRAMEWORK_VERSION });
+ Main.parseArgs(noActionAllowesConfig, new String[] {"-" + Main.OPT_FELIX_FRAMEWORK_VERSION});
LauncherConfig config = new LauncherConfig();
- Main.parseArgs(config, new String[] { "-" + Main.OPT_FELIX_FRAMEWORK_VERSION, "foo" });
+ Main.parseArgs(config, new String[] {"-" + Main.OPT_FELIX_FRAMEWORK_VERSION, "foo"});
assertEquals("foo", config.getFrameworkVersion().toString());
-
}
@Test
public void testParseOSGiFwArtifact() {
- Main.parseArgs(noActionAllowesConfig,
- new String[] { "-" + Main.OPT_OSGI_FRAMEWORK_ARTIFACT });
+ Main.parseArgs(noActionAllowesConfig, new String[] {"-" + Main.OPT_OSGI_FRAMEWORK_ARTIFACT});
LauncherConfig config = new LauncherConfig();
- Main.parseArgs(config, new String[] { "-" + Main.OPT_OSGI_FRAMEWORK_ARTIFACT, "foo" });
+ Main.parseArgs(config, new String[] {"-" + Main.OPT_OSGI_FRAMEWORK_ARTIFACT, "foo"});
assertEquals("foo", config.getFrameworkArtifact());
-
}
@Test
public void testParse_Config_Clash() {
- Main.parseArgs(noActionAllowesConfig, new String[] { "-" + Main.OPT_CONFIG_CLASH });
+ Main.parseArgs(noActionAllowesConfig, new String[] {"-" + Main.OPT_CONFIG_CLASH});
- assertEquals( Main.OPT_CONFIG_CLASH,"CC");
+ assertEquals(Main.OPT_CONFIG_CLASH, "CC");
LauncherConfig config = new LauncherConfig();
- Main.parseArgs(config,args("-CC a=1"));
+ Main.parseArgs(config, args("-CC a=1"));
assertTrue(config.getConfigClashOverrides().containsKey("a"));
assertEquals("1", config.getConfigClashOverrides().get("a"));
-
config = new LauncherConfig();
Main.parseArgs(config, args("-CC a=1 -CC b=2"));
@@ -215,123 +208,132 @@ public class MainIT {
assertEquals("1", config.getConfigClashOverrides().get("a"));
assertTrue(config.getConfigClashOverrides().containsKey("b"));
assertEquals("2", config.getConfigClashOverrides().get("b"));
-
}
@Test
public void testParse_OptVarVal() {
- Main.parseArgs(noActionAllowesConfig, new String[] { "-" + Main.OPT_VARIABLE_VALUES });
+ Main.parseArgs(noActionAllowesConfig, new String[] {"-" + Main.OPT_VARIABLE_VALUES});
- assertEquals( Main.OPT_VARIABLE_VALUES,"V");
+ assertEquals(Main.OPT_VARIABLE_VALUES, "V");
LauncherConfig config = new LauncherConfig();
- Main.parseArgs(config,args("-V a=1"));
+ Main.parseArgs(config, args("-V a=1"));
assertTrue(config.getVariables().containsKey("a"));
assertEquals("1", config.getVariables().get("a"));
-
config = new LauncherConfig();
- Main.parseArgs(config,args("-V a=1 -V b=2"));
+ Main.parseArgs(config, args("-V a=1 -V b=2"));
assertTrue(config.getVariables().containsKey("a"));
assertEquals("1", config.getVariables().get("a"));
assertTrue(config.getVariables().containsKey("b"));
assertEquals("2", config.getVariables().get("b"));
-
}
@Test
public void testParse_FW_Prop() {
- Main.parseArgs(noActionAllowesConfig, new String[] { "-" + Main.OPT_FRAMEWORK_PROPERTIES });
+ Main.parseArgs(noActionAllowesConfig, new String[] {"-" + Main.OPT_FRAMEWORK_PROPERTIES});
- assertEquals( Main.OPT_FRAMEWORK_PROPERTIES,"D");
+ assertEquals(Main.OPT_FRAMEWORK_PROPERTIES, "D");
LauncherConfig configSpaceSingle = new LauncherConfig();
Main.parseArgs(configSpaceSingle, args("-D a=1"));
assertTrue(configSpaceSingle.getInstallation().getFrameworkProperties().containsKey("a"));
- assertEquals("1", configSpaceSingle.getInstallation().getFrameworkProperties().get("a"));
+ assertEquals(
+ "1",
+ configSpaceSingle.getInstallation().getFrameworkProperties().get("a"));
LauncherConfig configSpaceNoSeparator = new LauncherConfig();
Main.parseArgs(configSpaceNoSeparator, args("-D a=1,b=2"));
-
- assertTrue(configSpaceNoSeparator.getInstallation().getFrameworkProperties().containsKey("a"));
- assertEquals("1,b=2", configSpaceNoSeparator.getInstallation().getFrameworkProperties().get("a"));
+
+ assertTrue(configSpaceNoSeparator
+ .getInstallation()
+ .getFrameworkProperties()
+ .containsKey("a"));
+ assertEquals(
+ "1,b=2",
+ configSpaceNoSeparator
+ .getInstallation()
+ .getFrameworkProperties()
+ .get("a"));
LauncherConfig configSpaceMultiple = new LauncherConfig();
Main.parseArgs(configSpaceMultiple, args("-D a=1 -D b=2"));
- assertTrue(configSpaceMultiple.getInstallation().getFrameworkProperties().containsKey("a"));
- assertEquals("1", configSpaceMultiple.getInstallation().getFrameworkProperties().get("a"));
- assertTrue(configSpaceMultiple.getInstallation().getFrameworkProperties().containsKey("b"));
- assertEquals("2", configSpaceMultiple.getInstallation().getFrameworkProperties().get("b"));
+ assertTrue(
+ configSpaceMultiple.getInstallation().getFrameworkProperties().containsKey("a"));
+ assertEquals(
+ "1",
+ configSpaceMultiple.getInstallation().getFrameworkProperties().get("a"));
+ assertTrue(
+ configSpaceMultiple.getInstallation().getFrameworkProperties().containsKey("b"));
+ assertEquals(
+ "2",
+ configSpaceMultiple.getInstallation().getFrameworkProperties().get("b"));
}
@Test
public void testParse_Artifact_Clash() {
- Main.parseArgs(noActionAllowesConfig, new String[] { "-" + Main.OPT_ARTICACT_CLASH });
+ Main.parseArgs(noActionAllowesConfig, new String[] {"-" + Main.OPT_ARTICACT_CLASH});
LauncherConfig config = new LauncherConfig();
- Main.parseArgs(config, new String[] { "-" + Main.OPT_ARTICACT_CLASH, "foo:bar:1" });
+ Main.parseArgs(config, new String[] {"-" + Main.OPT_ARTICACT_CLASH, "foo:bar:1"});
assertTrue(config.getArtifactClashOverrides().contains(ArtifactId.parse("foo:bar:1")));
config = new LauncherConfig();
- Main.parseArgs(config,
- new String[] { "-" + Main.OPT_ARTICACT_CLASH, "foo:bar:1", "foo:bar:2" });
+ Main.parseArgs(config, new String[] {"-" + Main.OPT_ARTICACT_CLASH, "foo:bar:1", "foo:bar:2"});
assertTrue(config.getArtifactClashOverrides().contains(ArtifactId.parse("foo:bar:1")));
assertTrue(config.getArtifactClashOverrides().contains(ArtifactId.parse("foo:bar:2")));
config = new LauncherConfig();
- Main.parseArgs(config, new String[] { "-" + Main.OPT_ARTICACT_CLASH, "foo:bar:1",
- "-" + Main.OPT_ARTICACT_CLASH, "foo:bar:2" });
+ Main.parseArgs(
+ config,
+ new String[] {"-" + Main.OPT_ARTICACT_CLASH, "foo:bar:1", "-" + Main.OPT_ARTICACT_CLASH, "foo:bar:2"});
assertTrue(config.getArtifactClashOverrides().contains(ArtifactId.parse("foo:bar:1")));
assertTrue(config.getArtifactClashOverrides().contains(ArtifactId.parse("foo:bar:2")));
-
}
@Test
public void testParse_RepoUrls() {
- Main.parseArgs(noActionAllowesConfig, new String[] { "-" + Main.OPT_REPOSITORY_URLS });
+ Main.parseArgs(noActionAllowesConfig, new String[] {"-" + Main.OPT_REPOSITORY_URLS});
LauncherConfig config = new LauncherConfig();
- Main.parseArgs(config, new String[] { "-" + Main.OPT_REPOSITORY_URLS, "foo" });
- assertArrayEquals(config.getRepositoryUrls(), new Object[] { "foo" });
+ Main.parseArgs(config, new String[] {"-" + Main.OPT_REPOSITORY_URLS, "foo"});
+ assertArrayEquals(config.getRepositoryUrls(), new Object[] {"foo"});
config = new LauncherConfig();
- Main.parseArgs(config, new String[] { "-" + Main.OPT_REPOSITORY_URLS, "foo", "bar" });
- assertArrayEquals(config.getRepositoryUrls(), new Object[] { "foo", "bar" });
+ Main.parseArgs(config, new String[] {"-" + Main.OPT_REPOSITORY_URLS, "foo", "bar"});
+ assertArrayEquals(config.getRepositoryUrls(), new Object[] {"foo", "bar"});
config = new LauncherConfig();
- Main.parseArgs(config, new String[] { "-" + Main.OPT_REPOSITORY_URLS, "foo",
- "-" + Main.OPT_REPOSITORY_URLS, "bar" });
- assertArrayEquals(config.getRepositoryUrls(), new Object[] { "foo", "bar" });
-
+ Main.parseArgs(
+ config, new String[] {"-" + Main.OPT_REPOSITORY_URLS, "foo", "-" + Main.OPT_REPOSITORY_URLS, "bar"});
+ assertArrayEquals(config.getRepositoryUrls(), new Object[] {"foo", "bar"});
}
@Test
public void testParse_FeatureFiles() {
- Main.parseArgs(noActionAllowesConfig, new String[] { "-" + Main.OPT_FEATURE_FILES });
+ Main.parseArgs(noActionAllowesConfig, new String[] {"-" + Main.OPT_FEATURE_FILES});
LauncherConfig config = new LauncherConfig();
- Main.parseArgs(config, new String[] { "-" + Main.OPT_FEATURE_FILES, "foo" });
+ Main.parseArgs(config, new String[] {"-" + Main.OPT_FEATURE_FILES, "foo"});
assertTrue(config.getFeatureFiles().contains("foo"));
config = new LauncherConfig();
- Main.parseArgs(config, new String[] { "-" + Main.OPT_FEATURE_FILES, "foo", "bar" });
+ Main.parseArgs(config, new String[] {"-" + Main.OPT_FEATURE_FILES, "foo", "bar"});
assertTrue(config.getFeatureFiles().contains("foo"));
assertTrue(config.getFeatureFiles().contains("bar"));
config = new LauncherConfig();
- Main.parseArgs(config, new String[] { "-" + Main.OPT_FEATURE_FILES, "foo",
- "-" + Main.OPT_FEATURE_FILES, "bar" });
+ Main.parseArgs(config, new String[] {"-" + Main.OPT_FEATURE_FILES, "foo", "-" + Main.OPT_FEATURE_FILES, "bar"});
assertTrue(config.getFeatureFiles().contains("foo"));
assertTrue(config.getFeatureFiles().contains("bar"));
-
}
public static String[] args(String value) {
@@ -349,6 +351,5 @@ public class MainIT {
} catch (SystemExitException e) {
assertEquals("Exit status", 1, e.status);
}
-
}
}
diff --git a/src/test/java/org/apache/sling/feature/launcher/impl/VariableSubstitutorIT.java b/src/test/java/org/apache/sling/feature/launcher/impl/VariableSubstitutorIT.java
index cab834b..6caa4fc 100644
--- a/src/test/java/org/apache/sling/feature/launcher/impl/VariableSubstitutorIT.java
+++ b/src/test/java/org/apache/sling/feature/launcher/impl/VariableSubstitutorIT.java
@@ -1,21 +1,26 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.launcher.impl;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.sling.feature.launcher.spi.LauncherRunContext;
import org.junit.Before;
import org.junit.Test;
@@ -24,12 +29,9 @@ import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import java.util.HashMap;
-import java.util.Map;
-
/** Run this as part of integration tests to help make sure we
* embed the right Apache commons classes.
-*/
+ */
public class VariableSubstitutorIT {
private VariableSubstitutor vs;
@@ -38,7 +40,7 @@ public class VariableSubstitutorIT {
final LauncherRunContext context = mock(LauncherRunContext.class);
final Map<String, String> props = new HashMap<>();
- props.put("1","one exactly");
+ props.put("1", "one exactly");
props.put("two", "here's ${1} and two");
when(context.getFrameworkProperties()).thenReturn(props);