You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:24:57 UTC
[sling-org-apache-sling-crankstart-launcher] annotated tag
org.apache.sling.crankstart.launcher-1.0.0 created (now 2cbd75b)
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a change to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git.
at 2cbd75b (tag)
tagging a1fbd10c4beca9a5b1256cbf0091067e8dd071bb (commit)
by Bertrand Delacretaz
on Mon Sep 1 15:02:25 2014 +0000
- Log -----------------------------------------------------------------
org.apache.sling.crankstart.launcher-1.0.0
-----------------------------------------------------------------------
This annotated tag includes the following new commits:
new d0029e2 Make space for api module
new c8f35d3 Use more flexible command pattern
new 3ae1a28 Get OSGi dependencies from Maven repository as well
new 2e9d602 Remove obsolete commands package
new 1a46d8e Add a few OSGi properties as examples
new 32198ff Initial Sling crankstart definition file
new 201e085 CrankstartBootstrap and test
new 8c3c316 SLING-3527 - update slf4j to 1.7.6 - contributed by Artyom Stetsenko, thanks!
new 7f6e504 SLING-3528 - add test-services to prepare for config command testing
new b85b181 SLING-3528 - configure command, based on a contribution by Artyom Stetsenko, thanks!
new d9d1250 SLING-3528 - test the config command in CrankstartBootstrapTest
new 8fa2076 support variables in crankstart files, with default values
new ee26999 Use variables in launcher test
new 1de5fcf config.factory support
new 2976ec9 Add extension command support, with test in SystemPropertyCommand and launcher-test.crank.txt
new 50eaf27 Register resources with the Sling installer via a crankstart extension command
new b6d911f Fix build order
new 0d919ff Add support for configurations in Felix .config format
new 8ebb48b Accept null properties
new f5c47c4 Use AutoClose stream
new 358b3e4 SLING-3720 - set crankstart.jar.path - contributed by Artyom Stetsenko, thanks!
new 3d4007b Fix registration of multiple resources via the Sling installer
new 415617c Use CRANKSTART_CONFIG_ID property to avoid creating duplicate factory configs
new 3d930df Remove unnecessary snapshot
new d1e5507 Add support for bundle start levels, and move default values to CrankstartContext
new 4840821 Use org.ops4j.pax.url.mvn.localRepository to point to the same local repository that this build uses
new cfb1572 By default, stop intepreting the crankstart file once framework is started, except on first startup
new c2cb6db Add scm info
new 5b84eb7 Use released versions
new 0343af7 [maven-release-plugin] prepare release org.apache.sling.crankstart.launcher-1.0.0
new a1fbd10 [maven-release-plugin] copy for tag org.apache.sling.crankstart.launcher-1.0.0
The 31 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.
--
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].
[sling-org-apache-sling-crankstart-launcher] 08/31: SLING-3527 -
update slf4j to 1.7.6 - contributed by Artyom Stetsenko, thanks!
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 8c3c3166bde5fb00f31aadcd1da1ebd0ec8e7028
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu May 1 14:30:27 2014 +0000
SLING-3527 - update slf4j to 1.7.6 - contributed by Artyom Stetsenko, thanks!
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1591672 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 4 ++--
sling.crank.txt | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index a61a847..555db0e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -100,13 +100,13 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <version>1.6.2</version>
+ <version>1.7.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
- <version>1.6.2</version>
+ <version>1.7.6</version>
<scope>provided</scope>
</dependency>
<dependency>
diff --git a/sling.crank.txt b/sling.crank.txt
index 387ad82..c235723 100644
--- a/sling.crank.txt
+++ b/sling.crank.txt
@@ -5,8 +5,8 @@
# Set bootstrap classpath, mvn: protocol can be used
classpath mvn:org.apache.felix/org.apache.felix.framework/4.4.0
classpath mvn:org.osgi/org.osgi.compendium/4.2.0
-classpath mvn:org.slf4j/slf4j-api/1.6.2
-classpath mvn:org.slf4j/slf4j-simple/1.6.2
+classpath mvn:org.slf4j/slf4j-api/1.7.6
+classpath mvn:org.slf4j/slf4j-simple/1.7.6
classpath mvn:org.ops4j.pax.url/pax-url-aether/1.6.0
classpath mvn:org.ops4j.pax.url/pax-url-commons/1.6.0
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 27/31: By default,
stop intepreting the crankstart file once framework is started,
except on first startup
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit cfb1572095a67c5871f200aa7c2b73740ca5077a
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Aug 8 08:26:45 2014 +0000
By default, stop intepreting the crankstart file once framework is started, except on first startup
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1616687 13f79535-47bb-0310-9956-ffa450edef68
---
src/test/resources/launcher-test.crank.txt | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/test/resources/launcher-test.crank.txt b/src/test/resources/launcher-test.crank.txt
index 981be3b..f48cfbe 100644
--- a/src/test/resources/launcher-test.crank.txt
+++ b/src/test/resources/launcher-test.crank.txt
@@ -8,6 +8,7 @@ defaults felix.http.jetty.version 2.2.0
# Bootstrap classpath (variables are not supported here)
classpath mvn:org.apache.felix/org.apache.felix.framework/4.4.0
classpath mvn:org.slf4j/slf4j-api/1.6.2
+classpath mvn:org.slf4j/slf4j-simple/1.6.2
classpath mvn:org.apache.sling/org.apache.sling.crankstart.core/0.0.1-SNAPSHOT
classpath mvn:org.apache.sling/org.apache.sling.crankstart.api/0.0.1-SNAPSHOT
@@ -15,7 +16,8 @@ classpath mvn:org.apache.sling/org.apache.sling.crankstart.api/0.0.1-SNAPSHOT
osgi.property org.osgi.service.http.port ${http.port}
osgi.property org.osgi.framework.storage ${osgi.storage.path}
-# Start the framework
+# Start the framework. Crankstart file processing will stop here
+# if this is not the first startup.
start.framework
# Start ConfigAdmin, HTTP service and SCR
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 01/31: Make space for
api module
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit d0029e2675e5bdd73a7c083827b8746c7c62c8dc
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Apr 22 11:51:14 2014 +0000
Make space for api module
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1589096 13f79535-47bb-0310-9956-ffa450edef68
---
default.crank.txt | 23 ++++
pom.xml | 128 +++++++++++++++++++
.../sling/crankstart/CrankstartFileProcessor.java | 140 +++++++++++++++++++++
.../java/org/apache/sling/crankstart/Main.java | 42 +++++++
.../org/apache/sling/crankstart/MavenUrlTest.java | 35 ++++++
5 files changed, 368 insertions(+)
diff --git a/default.crank.txt b/default.crank.txt
new file mode 100644
index 0000000..3d581f0
--- /dev/null
+++ b/default.crank.txt
@@ -0,0 +1,23 @@
+# Minimal webconsole example for the Sling crankstart launcher
+
+# OSGi framework properties
+osgi.property org.osgi.service.http.port 1234
+
+# Once OSGi properties are set, start the framework
+start.framework
+
+# Install a minimal set of bundles for now, just to
+# demonstrate that we can start the webconsole
+# Crankstart gets bundles from a Maven repository, which
+# is not configurable for now.
+bundle org.apache.felix/org.apache.felix.configadmin/1.2.8
+bundle org.apache.felix/org.apache.felix.http.jetty/2.2.0
+bundle org.apache.felix/org.apache.felix.metatype/1.0.4
+bundle org.apache.felix/org.apache.felix.scr/1.6.0
+bundle org.apache.felix/org.apache.felix.webconsole/3.1.6
+bundle org.apache.sling/org.apache.sling.commons.log/2.1.2
+
+# Start all bundles and log a friendly message
+start.all.bundles
+log OSGi webconsole should soon be available at http://localhost:1234/system/console
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..72a30d4
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache</groupId>
+ <artifactId>apache</artifactId>
+ <version>10</version>
+ <relativePath />
+ </parent>
+
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.crankstart.launcher</artifactId>
+ <packaging>jar</packaging>
+ <version>0.0.1-SNAPSHOT</version>
+
+ <name>Apache Sling Crankstart Module</name>
+ <inceptionYear>2014</inceptionYear>
+
+ <description>
+ A different way of starting Sling
+ </description>
+
+ <properties>
+ <pax.url.version>1.6.0</pax.url.version>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.apache.sling.crankstart.Main</mainClass>
+ <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>embed-dependencies</id>
+ <goals>
+ <goal>unpack-dependencies</goal>
+ </goals>
+ <configuration>
+ <includeGroupIds>org.osgi,org.apache.felix,org.slf4j,javax.servlet,org.ops4j.pax.url</includeGroupIds>
+ <excludeTransitive>false</excludeTransitive>
+ <outputDirectory>${project.build.directory}/classes</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>false</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>${basedir}</directory>
+ <includes>
+ <include>felix-cache</include>
+ </includes>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>4.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.framework</artifactId>
+ <version>4.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.6.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.6.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.url</groupId>
+ <artifactId>pax-url-aether</artifactId>
+ <version>${pax.url.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.url</groupId>
+ <artifactId>pax-url-commons</artifactId>
+ <version>${pax.url.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/src/main/java/org/apache/sling/crankstart/CrankstartFileProcessor.java b/src/main/java/org/apache/sling/crankstart/CrankstartFileProcessor.java
new file mode 100644
index 0000000..424064b
--- /dev/null
+++ b/src/main/java/org/apache/sling/crankstart/CrankstartFileProcessor.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.crankstart;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Process a crankstart file */
+public class CrankstartFileProcessor {
+ public static final String I_BUNDLE = "bundle ";
+ public static final String I_START_ALL_BUNDLES = "start.all.bundles";
+ public static final String I_LOG = "log";
+ public static final String I_START_FRAMEWORK = "start.framework";
+ public static final String I_OSGI_PROPERTY = "osgi.property";
+
+ private Framework framework;
+ private final List<Bundle> bundles = new LinkedList<Bundle>();
+ private final Logger log = LoggerFactory.getLogger(getClass());
+ private final Map<String, String> osgiProperties = new HashMap<String, String>();
+
+ public CrankstartFileProcessor() {
+ System.setProperty( "java.protocol.handler.pkgs", "org.ops4j.pax.url" );
+ }
+
+ public void process(Reader input) throws IOException, BundleException {
+ final BufferedReader r = new BufferedReader(input);
+ String line = null;
+ while((line = r.readLine()) != null) {
+ processLine(line);
+ }
+ }
+
+ private String removePrefix(String line, String prefix) {
+ return line.substring(prefix.length()).trim();
+ }
+
+ private void processLine(String line) throws IOException, BundleException {
+ line = line.trim();
+ if(line.length() == 0 || line.startsWith("#")) {
+ // ignore comments and blank lines
+ } else if(line.startsWith(I_BUNDLE)) {
+ bundle(removePrefix(line, I_BUNDLE));
+ } else if(line.startsWith(I_START_ALL_BUNDLES)) {
+ startAllBundles();
+ } else if(line.startsWith(I_LOG)) {
+ log.info(removePrefix(line, I_LOG));
+ } else if(line.startsWith(I_START_FRAMEWORK)) {
+ startFramework();
+ } else if(line.startsWith(I_OSGI_PROPERTY)) {
+ osgiProperty(removePrefix(line, I_OSGI_PROPERTY));
+ } else {
+ log.warn("Invalid command line: [{}]", line);
+ }
+ }
+
+ private void osgiProperty(String line) {
+ final String [] parts = line.split(" ");
+ if(parts.length != 2) {
+ log.warn("Invalid OSGi property [{}]", line);
+ return;
+ }
+ final String key = parts[0].trim();
+ final String value = parts[1].trim();
+ log.info("Setting OSGI property {}={}", key, value);
+ osgiProperties.put(key, value);
+ }
+
+ private void startFramework() throws BundleException {
+ if(framework != null) {
+ throw new IllegalStateException("OSGi framework already created");
+ }
+
+ // TODO get framework as a Maven artifact?
+ FrameworkFactory frameworkFactory = java.util.ServiceLoader.load(FrameworkFactory.class).iterator().next();
+ framework = frameworkFactory.newFramework(osgiProperties);
+ framework.start();
+
+ log.info("OSGi framework started");
+ }
+
+ private void bundle(String line) throws IOException, BundleException {
+ final URL url = new URL( "mvn:" + line);
+ final BundleContext ctx = framework.getBundleContext();
+ final String ref = "crankstart://" + line;
+ final InputStream bundleStream = url.openStream();
+ try {
+ bundles.add(ctx.installBundle(ref, url.openStream()));
+ log.info("bundle installed: {}", ref);
+ } finally {
+ bundleStream.close();
+ }
+ }
+
+ public void waitForExit() throws InterruptedException {
+ log.info("Waiting for OSGi framework to exit...");
+ framework.waitForStop(0);
+ }
+
+ private void startAllBundles() throws BundleException {
+ for (Bundle bundle : bundles) {
+ log.info("Starting bundle {}", bundle.getSymbolicName());
+ bundle.start();
+ }
+
+ // TODO check that all bundles have started?
+ // or use a crankstart instruction for that?
+
+ log.info("{} bundles installed", bundles.size());
+ }
+
+}
diff --git a/src/main/java/org/apache/sling/crankstart/Main.java b/src/main/java/org/apache/sling/crankstart/Main.java
new file mode 100644
index 0000000..04c4a90
--- /dev/null
+++ b/src/main/java/org/apache/sling/crankstart/Main.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.crankstart;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.Reader;
+
+/** Execute a crankstart file */
+public class Main {
+ public static void main(String [] args) throws Exception {
+ String crankFile = "default.crank.txt";
+ if(args.length < 1) {
+ System.err.println("Using default crank file " + crankFile);
+ System.err.println("To use a different one, provide its name as a jar file argument");
+ } else {
+ crankFile = args[0];
+ }
+ final Reader r = new FileReader(new File(crankFile));
+ try {
+ final CrankstartFileProcessor p = new CrankstartFileProcessor();
+ p.process(r);
+ p.waitForExit();
+ } finally {
+ r.close();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/crankstart/MavenUrlTest.java b/src/test/java/org/apache/sling/crankstart/MavenUrlTest.java
new file mode 100644
index 0000000..ebd66bb
--- /dev/null
+++ b/src/test/java/org/apache/sling/crankstart/MavenUrlTest.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.crankstart;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.junit.Test;
+
+public class MavenUrlTest {
+ @Test
+ public void testResolveArtifactl() throws IOException {
+ System.setProperty( "java.protocol.handler.pkgs", "org.ops4j.pax.url" );
+
+ //TODO does pax url use the default local repo?
+ //System.setProperty( "org.ops4j.pax.url.mvn.localRepository", localRepoPath );
+
+ final URL url = new URL( "mvn:commons-lang/commons-lang/1.0" );
+ url.openStream().close();
+ }
+}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 25/31: Add support for
bundle start levels, and move default values to CrankstartContext
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit d1e55079739d3319af5d5769fcdbaf0dcdb69a83
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Jul 31 15:32:42 2014 +0000
Add support for bundle start levels, and move default values to CrankstartContext
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1614923 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 6 ++++
.../launcher/CrankstartBootstrapTest.java | 39 ++++++++++++++++++++++
src/test/resources/launcher-test.crank.txt | 5 +++
3 files changed, 50 insertions(+)
diff --git a/pom.xml b/pom.xml
index e1136e1..a91660d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -152,6 +152,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.json</artifactId>
+ <version>2.0.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1</version>
diff --git a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
index f5c8547..71a7aa4 100644
--- a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
+++ b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
@@ -22,6 +22,8 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
+import org.apache.sling.commons.json.JSONArray;
+import org.apache.sling.commons.json.JSONObject;
import org.apache.sling.commons.testing.junit.Retry;
import org.apache.sling.commons.testing.junit.RetryRule;
import org.junit.AfterClass;
@@ -242,6 +244,43 @@ public class CrankstartBootstrapTest {
}
}
+ @Test
+ @Retry(timeoutMsec=10000, intervalMsec=250)
+ public void testSpecificStartLevel() throws Exception {
+ // Verify that this bundle is only installed, as it's set to start level 99
+ setAdminCredentials();
+ final String path = "/system/console/bundles/org.apache.commons.collections.json";
+ final HttpUriRequest get = new HttpGet(baseUrl + path);
+ HttpResponse response = null;
+ try {
+ response = client.execute(get);
+ assertEquals("Expecting bundle status to be available at " + get.getURI(), 200, response.getStatusLine().getStatusCode());
+ assertNotNull("Expecting response entity", response.getEntity());
+ String encoding = "UTF-8";
+ if(response.getEntity().getContentEncoding() != null) {
+ encoding = response.getEntity().getContentEncoding().getValue();
+ }
+ final String content = IOUtils.toString(response.getEntity().getContent(), encoding);
+
+ // Start level is in the props array, with key="Start Level"
+ final JSONObject status = new JSONObject(content);
+ final JSONArray props = status.getJSONArray("data").getJSONObject(0).getJSONArray("props");
+ final String KEY = "key";
+ final String SL = "Start Level";
+ boolean found = false;
+ for(int i=0; i < props.length(); i++) {
+ final JSONObject o = props.getJSONObject(i);
+ if(o.has(KEY) && SL.equals(o.getString(KEY))) {
+ found = true;
+ assertEquals("Expecting the start level that we set", "99", o.getString("value"));
+ }
+ }
+ assertTrue("Expecting start level to be found in JSON output", found);
+ } finally {
+ closeConnection(response);
+ }
+ }
+
private static String getOsgiStoragePath() {
final File tmpRoot = new File(System.getProperty("java.io.tmpdir"));
final Random random = new Random();
diff --git a/src/test/resources/launcher-test.crank.txt b/src/test/resources/launcher-test.crank.txt
index 54b5461..179d4dd 100644
--- a/src/test/resources/launcher-test.crank.txt
+++ b/src/test/resources/launcher-test.crank.txt
@@ -42,6 +42,11 @@ bundle mvn:org.apache.sling/org.apache.sling.jcr.jcr-wrapper/2.0.0
bundle mvn:org.apache.sling/org.apache.sling.crankstart.sling.extensions/0.0.1-SNAPSHOT
bundle mvn:commons-io/commons-io/2.4
+# Install a bundle at a start level higher than the current one
+# to be able to check that it's not active
+defaults crankstart.bundle.start.level 99
+bundle mvn:commons-collections/commons-collections/3.2.1
+
# Now start our bundles
start.all.bundles
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 21/31: SLING-3720 -
set crankstart.jar.path - contributed by Artyom Stetsenko, thanks!
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 358b3e4a3938f04e2758c73732589e5b0a326a62
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Jul 1 08:35:48 2014 +0000
SLING-3720 - set crankstart.jar.path - contributed by Artyom Stetsenko, thanks!
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1607018 13f79535-47bb-0310-9956-ffa450edef68
---
src/main/java/org/apache/sling/crankstart/launcher/Main.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/Main.java b/src/main/java/org/apache/sling/crankstart/launcher/Main.java
index 8daf01f..5c4d30a 100644
--- a/src/main/java/org/apache/sling/crankstart/launcher/Main.java
+++ b/src/main/java/org/apache/sling/crankstart/launcher/Main.java
@@ -16,6 +16,8 @@
*/
package org.apache.sling.crankstart.launcher;
+import org.apache.sling.crankstart.api.CrankstartConstants;
+
/** Execute a crankstart file */
public class Main {
public static final String CLASSPATH_PREFIX = "classpath ";
@@ -28,6 +30,7 @@ public class Main {
} else {
crankFile = args[0];
}
+ System.setProperty(CrankstartConstants.CRANKSTART_JAR_PATH, Main.class.getProtectionDomain().getCodeSource().getLocation().getPath());
new CrankstartBootstrap(crankFile).start();
}
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 16/31: Register
resources with the Sling installer via a crankstart extension command
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 50eaf270238abb71cd82f49edf319576f35ad43a
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Jun 2 14:33:42 2014 +0000
Register resources with the Sling installer via a crankstart extension command
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1599226 13f79535-47bb-0310-9956-ffa450edef68
---
.../sling/crankstart/launcher/CrankstartBootstrapTest.java | 9 +++++++++
src/test/resources/launcher-test.crank.txt | 11 +++++++++++
2 files changed, 20 insertions(+)
diff --git a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
index 0de1a73..9c91184 100644
--- a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
+++ b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
@@ -135,6 +135,15 @@ public class CrankstartBootstrapTest {
assertEquals("was set by test-services bundle", System.getProperty(TEST_SYSTEM_PROPERTY));
}
+ @Test
+ @Retry(timeoutMsec=10000, intervalMsec=250)
+ public void testJUnitServlet() throws Exception {
+ final String path = "/system/sling/junit";
+ final GetMethod get = new GetMethod(baseUrl + path);
+ client.executeMethod(get);
+ assertEquals("Expecting JUnit servlet to be installed via sling extension command, at " + get.getURI(), 200, get.getStatusCode());
+ }
+
private static String getOsgiStoragePath() {
final File tmpRoot = new File(System.getProperty("java.io.tmpdir"));
final Random random = new Random();
diff --git a/src/test/resources/launcher-test.crank.txt b/src/test/resources/launcher-test.crank.txt
index a250a44..8bc7b3b 100644
--- a/src/test/resources/launcher-test.crank.txt
+++ b/src/test/resources/launcher-test.crank.txt
@@ -26,6 +26,7 @@ bundle mvn:org.apache.felix/org.apache.felix.metatype/1.0.10
bundle mvn:org.apache.sling/org.apache.sling.commons.osgi/2.2.1-SNAPSHOT
bundle mvn:org.apache.sling/org.apache.sling.commons.log/2.1.2
bundle mvn:org.apache.felix/org.apache.felix.configadmin/1.6.0
+bundle mvn:org.apache.felix/org.apache.felix.webconsole/3.1.6
# The crankstart.api.fragment bundle makes the crankstart.api package available
# to bundles, required for bundles to provide crankstart extension commands like
@@ -33,6 +34,13 @@ bundle mvn:org.apache.felix/org.apache.felix.configadmin/1.6.0
bundle mvn:org.apache.sling/org.apache.sling.crankstart.api.fragment/0.0.1-SNAPSHOT
bundle mvn:org.apache.sling/org.apache.sling.crankstart.test.services/0.0.1-SNAPSHOT
+# Test our Sling extension commands, that add a bundle via the Sling installer
+# (which requires commons.json and jcr-wrapper)
+bundle mvn:org.apache.sling/org.apache.sling.installer.core/3.5.0
+bundle mvn:org.apache.sling/org.apache.sling.commons.json/2.0.6
+bundle mvn:org.apache.sling/org.apache.sling.jcr.jcr-wrapper/2.0.0
+bundle mvn:org.apache.sling/org.apache.sling.crankstart.sling.extensions/0.0.1-SNAPSHOT
+
# Now start our bundles
start.all.bundles
@@ -52,5 +60,8 @@ config.factory org.apache.sling.crankstart.testservices.ConfigFactoryServlet
# Test an extension command provided by our test-services bundle
test.system.property the.test.system.property was set by test-services bundle
+# Add the JUnit core via the Sling installer and our sling.extensions
+sling.installer.resource mvn:org.apache.sling/org.apache.sling.junit.core/1.0.8
+
# Informative log
log felix http service should come up at http://localhost:${http.port}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 18/31: Add support for
configurations in Felix .config format
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 0d919ff93c512981d5c63b56e670b9439f7f4d7f
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Jun 6 12:18:30 2014 +0000
Add support for configurations in Felix .config format
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1600865 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 6 ++
.../launcher/CrankstartBootstrapTest.java | 111 +++++++++++++++++----
.../launcher/PreemptiveAuthInterceptor.java | 41 ++++++++
src/test/resources/launcher-test.crank.txt | 6 ++
4 files changed, 146 insertions(+), 18 deletions(-)
diff --git a/pom.xml b/pom.xml
index 6617f3f..137fcd3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -157,5 +157,11 @@
<version>4.1</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.4</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
index 9c91184..c0d7f0d 100644
--- a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
+++ b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
@@ -3,6 +3,7 @@ package org.apache.sling.crankstart.launcher;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.File;
@@ -13,11 +14,18 @@ import java.io.Reader;
import java.net.ServerSocket;
import java.util.Random;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.io.IOUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.util.EntityUtils;
import org.apache.sling.commons.testing.junit.Retry;
import org.apache.sling.commons.testing.junit.RetryRule;
import org.junit.AfterClass;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
@@ -28,7 +36,7 @@ import org.junit.Test;
public class CrankstartBootstrapTest {
private static final int port = getAvailablePort();
- private static final HttpClient client = new HttpClient();
+ private static DefaultHttpClient client;
private static Thread crankstartThread;
private static String baseUrl = "http://localhost:" + port;
public static final String TEST_RESOURCE = "/launcher-test.crank.txt";
@@ -55,6 +63,18 @@ public class CrankstartBootstrapTest {
return result;
}
+ @Before
+ public void setupHttpClient() {
+ client = new DefaultHttpClient();
+ }
+
+ private void setAdminCredentials() {
+ client.getCredentialsProvider().setCredentials(
+ AuthScope.ANY,
+ new UsernamePasswordCredentials("admin", "admin"));
+ client.addRequestInterceptor(new PreemptiveAuthInterceptor(), 0);
+ }
+
@BeforeClass
public static void testExtensionPropertyBeforeTests() {
assertNull(TEST_SYSTEM_PROPERTY + " should not be set before tests", System.getProperty(TEST_SYSTEM_PROPERTY));
@@ -62,7 +82,8 @@ public class CrankstartBootstrapTest {
@BeforeClass
public static void setup() {
- final GetMethod get = new GetMethod(baseUrl);
+ client = new DefaultHttpClient();
+ final HttpUriRequest get = new HttpGet(baseUrl);
System.setProperty("http.port", String.valueOf(port));
System.setProperty("osgi.storage.path", getOsgiStoragePath());
@@ -71,7 +92,7 @@ public class CrankstartBootstrapTest {
final Reader input = new InputStreamReader(is);
try {
- client.executeMethod(get);
+ client.execute(get);
fail("Expecting connection to " + port + " to fail before starting HTTP service");
} catch(IOException expected) {
}
@@ -101,20 +122,36 @@ public class CrankstartBootstrapTest {
crankstartThread.join();
}
+ private void closeConnection(HttpResponse r) throws IOException {
+ if(r != null && r.getEntity() != null) {
+ EntityUtils.consume(r.getEntity());
+ }
+ }
+
@Test
@Retry(timeoutMsec=10000, intervalMsec=250)
public void testHttpRoot() throws Exception {
- final GetMethod get = new GetMethod(baseUrl);
- client.executeMethod(get);
- assertEquals("Expecting page not found at " + get.getURI(), 404, get.getStatusCode());
+ final HttpUriRequest get = new HttpGet(baseUrl);
+ HttpResponse response = null;
+ try {
+ response = client.execute(get);
+ assertEquals("Expecting page not found at " + get.getURI(), 404, response.getStatusLine().getStatusCode());
+ } finally {
+ closeConnection(response);
+ }
}
@Test
@Retry(timeoutMsec=10000, intervalMsec=250)
public void testSingleConfigServlet() throws Exception {
- final GetMethod get = new GetMethod(baseUrl + "/single");
- client.executeMethod(get);
- assertEquals("Expecting success for " + get.getURI(), 200, get.getStatusCode());
+ final HttpUriRequest get = new HttpGet(baseUrl + "/single");
+ HttpResponse response = null;
+ try {
+ response = client.execute(get);
+ assertEquals("Expecting success for " + get.getURI(), 200, response.getStatusLine().getStatusCode());
+ } finally {
+ closeConnection(response);
+ }
}
@Test
@@ -122,9 +159,14 @@ public class CrankstartBootstrapTest {
public void testConfigFactoryServlet() throws Exception {
final String [] paths = { "/foo", "/bar/test" };
for(String path : paths) {
- final GetMethod get = new GetMethod(baseUrl + path);
- client.executeMethod(get);
- assertEquals("Expecting success for " + get.getURI(), 200, get.getStatusCode());
+ final HttpUriRequest get = new HttpGet(baseUrl + path);
+ HttpResponse response = null;
+ try {
+ response = client.execute(get);
+ assertEquals("Expecting success for " + get.getURI(), 200, response.getStatusLine().getStatusCode());
+ } finally {
+ closeConnection(response);
+ }
}
}
@@ -139,9 +181,42 @@ public class CrankstartBootstrapTest {
@Retry(timeoutMsec=10000, intervalMsec=250)
public void testJUnitServlet() throws Exception {
final String path = "/system/sling/junit";
- final GetMethod get = new GetMethod(baseUrl + path);
- client.executeMethod(get);
- assertEquals("Expecting JUnit servlet to be installed via sling extension command, at " + get.getURI(), 200, get.getStatusCode());
+ final HttpUriRequest get = new HttpGet(baseUrl + path);
+ HttpResponse response = null;
+ try {
+ response = client.execute(get);
+ assertEquals("Expecting JUnit servlet to be installed via sling extension command, at " + get.getURI(), 200, response.getStatusLine().getStatusCode());
+ } finally {
+ closeConnection(response);
+ }
+ }
+
+ @Test
+ @Retry(timeoutMsec=10000, intervalMsec=250)
+ public void testFelixFormatConfig() throws Exception {
+ setAdminCredentials();
+ final String path = "/system/console/config/configuration-status-20140606-1347+0200.txt";
+ final HttpUriRequest get = new HttpGet(baseUrl + path);
+ HttpResponse response = null;
+ try {
+ response = client.execute(get);
+ assertEquals("Expecting config dump to be available at " + get.getURI(), 200, response.getStatusLine().getStatusCode());
+ assertNotNull("Expecting response entity", response.getEntity());
+ String encoding = "UTF-8";
+ if(response.getEntity().getContentEncoding() != null) {
+ encoding = response.getEntity().getContentEncoding().getValue();
+ }
+ final String content = IOUtils.toString(response.getEntity().getContent(), encoding);
+ final String [] expected = new String[] {
+ "array = [foo, bar.from.launcher.test]",
+ "service.ranking.launcher.test = 54321"
+ };
+ for(String exp : expected) {
+ assertTrue("Expecting config content to contain " + exp, content.contains(exp));
+ }
+ } finally {
+ closeConnection(response);
+ }
}
private static String getOsgiStoragePath() {
@@ -154,4 +229,4 @@ public class CrankstartBootstrapTest {
tmpFolder.deleteOnExit();
return tmpFolder.getAbsolutePath();
}
-}
+}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/crankstart/launcher/PreemptiveAuthInterceptor.java b/src/test/java/org/apache/sling/crankstart/launcher/PreemptiveAuthInterceptor.java
new file mode 100644
index 0000000..5e82a54
--- /dev/null
+++ b/src/test/java/org/apache/sling/crankstart/launcher/PreemptiveAuthInterceptor.java
@@ -0,0 +1,41 @@
+package org.apache.sling.crankstart.launcher;
+
+import java.io.IOException;
+
+import org.apache.http.HttpException;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpRequestInterceptor;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.AuthState;
+import org.apache.http.auth.Credentials;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.protocol.ClientContext;
+import org.apache.http.impl.auth.BasicScheme;
+import org.apache.http.protocol.ExecutionContext;
+import org.apache.http.protocol.HttpContext;
+
+/** It's not like httpclient 4.1 makes this simple... */
+class PreemptiveAuthInterceptor implements HttpRequestInterceptor {
+
+ public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
+
+ AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
+ CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(ClientContext.CREDS_PROVIDER);
+ HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
+
+ // If not auth scheme has been initialized yet
+ if (authState.getAuthScheme() == null) {
+ AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort());
+
+ // Obtain credentials matching the target host
+ Credentials creds = credsProvider.getCredentials(authScope);
+
+ // If found, generate BasicScheme preemptively
+ if (creds != null) {
+ authState.setAuthScheme(new BasicScheme());
+ authState.setCredentials(creds);
+ }
+ }
+ }
+}
diff --git a/src/test/resources/launcher-test.crank.txt b/src/test/resources/launcher-test.crank.txt
index 8bc7b3b..6376370 100644
--- a/src/test/resources/launcher-test.crank.txt
+++ b/src/test/resources/launcher-test.crank.txt
@@ -57,6 +57,12 @@ config.factory org.apache.sling.crankstart.testservices.ConfigFactoryServlet
path=/bar/test
message=Not used
+# Test Felix format configs
+config felix.format.test FORMAT:felix.config
+ mongouri="mongodb://localhost:27017"
+ service.ranking.launcher.test=I"54321"
+ array=["foo","bar.from.launcher.test"]
+
# Test an extension command provided by our test-services bundle
test.system.property the.test.system.property was set by test-services bundle
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 05/31: Add a few OSGi
properties as examples
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 1a46d8e10d60d05d7a7d494c3667199139d8a43f
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Apr 22 19:41:45 2014 +0000
Add a few OSGi properties as examples
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1589269 13f79535-47bb-0310-9956-ffa450edef68
---
default.crank.txt | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/default.crank.txt b/default.crank.txt
index 7116683..77fc0de 100644
--- a/default.crank.txt
+++ b/default.crank.txt
@@ -14,6 +14,8 @@ classpath mvn:org.apache.sling/org.apache.sling.crankstart.api/0.0.1-SNAPSHOT
# Set OSGi framework properties
osgi.property org.osgi.service.http.port 1234
+osgi.property org.osgi.framework.startlevel.beginning 32
+osgi.property felix.startlevel.bundle 22
# Once OSGi properties are set, start the framework
start.framework
@@ -31,4 +33,4 @@ bundle mvn:org.apache.sling/org.apache.sling.commons.log/2.1.2
# Start all bundles and log a friendly message
start.all.bundles
log OSGi webconsole should soon be available at http://localhost:1234/system/console
-
\ No newline at end of file
+
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 13/31: Use variables
in launcher test
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit ee26999380ce85fdbcf03e4e5a4bc8503dd6a44c
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri May 16 12:15:23 2014 +0000
Use variables in launcher test
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1595172 13f79535-47bb-0310-9956-ffa450edef68
---
.../crankstart/launcher/CrankstartBootstrap.java | 5 ++-
.../launcher/CrankstartBootstrapTest.java | 42 +++++++++-------------
src/test/resources/launcher-test.txt | 39 ++++++++++++++++++++
3 files changed, 59 insertions(+), 27 deletions(-)
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/CrankstartBootstrap.java b/src/main/java/org/apache/sling/crankstart/launcher/CrankstartBootstrap.java
index 68ccd9d..80a47cc 100644
--- a/src/main/java/org/apache/sling/crankstart/launcher/CrankstartBootstrap.java
+++ b/src/main/java/org/apache/sling/crankstart/launcher/CrankstartBootstrap.java
@@ -17,6 +17,7 @@
package org.apache.sling.crankstart.launcher;
import java.io.BufferedReader;
+import java.io.Closeable;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
@@ -80,7 +81,9 @@ public class CrankstartBootstrap {
final Callable<Object> c = (Callable<Object>)launcherClassloader.loadClass(callableClass).newInstance();
c.call();
} finally {
- launcherClassloader.close();
+ if(launcherClassloader instanceof Closeable) {
+ ((Closeable)launcherClassloader).close();
+ }
cleanup();
}
}
diff --git a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
index d716d45..5e0fb50 100644
--- a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
+++ b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
@@ -1,11 +1,14 @@
package org.apache.sling.crankstart.launcher;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
-import java.io.StringReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
import java.net.ServerSocket;
import java.util.Random;
@@ -28,6 +31,7 @@ public class CrankstartBootstrapTest {
private static final HttpClient client = new HttpClient();
private static Thread crankstartThread;
private static String baseUrl = "http://localhost:" + port;
+ public static final String TEST_RESOURCE = "/launcher-test.txt";
@Rule
public final RetryRule retryRule = new RetryRule();
@@ -50,34 +54,15 @@ public class CrankstartBootstrapTest {
return result;
}
- private final static String CRANKSTART =
- "classpath mvn:org.apache.felix/org.apache.felix.framework/4.4.0\n"
- + "classpath mvn:org.slf4j/slf4j-api/1.6.2\n"
- + "classpath mvn:org.ops4j.pax.url/pax-url-aether/1.6.0\n"
- + "classpath mvn:org.ops4j.pax.url/pax-url-commons/1.6.0\n"
- + "classpath mvn:org.apache.sling/org.apache.sling.crankstart.core/0.0.1-SNAPSHOT\n"
- + "classpath mvn:org.apache.sling/org.apache.sling.crankstart.api/0.0.1-SNAPSHOT\n"
- + "osgi.property org.osgi.service.http.port ${http.port}\n"
- + "osgi.property org.osgi.framework.storage " + getOsgiStoragePath() + "\n"
- + "start.framework\n"
- + "bundle mvn:org.apache.felix/org.apache.felix.http.jetty/2.2.0\n"
- + "bundle mvn:org.apache.felix/org.apache.felix.eventadmin/1.3.2\n"
- + "bundle mvn:org.apache.felix/org.apache.felix.scr/1.8.2\n"
- + "bundle mvn:org.apache.sling/org.apache.sling.commons.osgi/2.2.1-SNAPSHOT\n"
- + "bundle mvn:org.apache.sling/org.apache.sling.commons.log/2.1.2\n"
- + "bundle mvn:org.apache.sling/org.apache.sling.crankstart.test.services/0.0.1-SNAPSHOT\n"
- + "bundle mvn:org.apache.felix/org.apache.felix.configadmin/1.6.0\n"
- + "start.all.bundles\n"
- + "config org.apache.sling.crankstart.testservices.SingleConfigServlet\n"
- + " path=/single\n"
- + " message=doesn't matter\n"
- + "log felix http service should come up at http://localhost:${http.port}\n"
- ;
-
@BeforeClass
public static void setup() {
final GetMethod get = new GetMethod(baseUrl);
System.setProperty("http.port", String.valueOf(port));
+ System.setProperty("osgi.storage.path", getOsgiStoragePath());
+
+ final InputStream is = CrankstartBootstrapTest.class.getResourceAsStream(TEST_RESOURCE);
+ assertNotNull("Expecting test resource to be found:" + TEST_RESOURCE, is);
+ final Reader input = new InputStreamReader(is);
try {
client.executeMethod(get);
@@ -88,9 +73,14 @@ public class CrankstartBootstrapTest {
crankstartThread = new Thread() {
public void run() {
try {
- new CrankstartBootstrap(new StringReader(CRANKSTART)).start();
+ new CrankstartBootstrap(input).start();
} catch(Exception e) {
fail("CrankstartBootstrap exception:" + e);
+ } finally {
+ try {
+ input.close();
+ } catch(IOException ignoreTheresNotMuchWeCanDoAnyway) {
+ }
}
}
};
diff --git a/src/test/resources/launcher-test.txt b/src/test/resources/launcher-test.txt
new file mode 100644
index 0000000..d1868c5
--- /dev/null
+++ b/src/test/resources/launcher-test.txt
@@ -0,0 +1,39 @@
+# Test the crankstart launcher by setting up an HTTP
+# server with a few servlets that require specific OSGi configurations
+
+# Default values for our variables
+defaults pax.version 1.6.0
+defaults single.path /single
+
+# Bootstrap classpath
+classpath mvn:org.apache.felix/org.apache.felix.framework/4.4.0
+classpath mvn:org.slf4j/slf4j-api/1.6.2
+classpath mvn:org.ops4j.pax.url/pax-url-aether/${pax.version}
+classpath mvn:org.ops4j.pax.url/pax-url-commons/${pax.version}
+classpath mvn:org.apache.sling/org.apache.sling.crankstart.core/0.0.1-SNAPSHOT
+classpath mvn:org.apache.sling/org.apache.sling.crankstart.api/0.0.1-SNAPSHOT
+
+# OSGi properties
+osgi.property org.osgi.service.http.port ${http.port}
+osgi.property org.osgi.framework.storage ${osgi.storage.path}
+
+# Start the framework
+start.framework
+
+# Start ConfigAdmin, HTTP service and SCR
+bundle mvn:org.apache.felix/org.apache.felix.http.jetty/2.2.0
+bundle mvn:org.apache.felix/org.apache.felix.eventadmin/1.3.2
+bundle mvn:org.apache.felix/org.apache.felix.scr/1.8.2
+bundle mvn:org.apache.sling/org.apache.sling.commons.osgi/2.2.1-SNAPSHOT
+bundle mvn:org.apache.sling/org.apache.sling.commons.log/2.1.2
+bundle mvn:org.apache.sling/org.apache.sling.crankstart.test.services/0.0.1-SNAPSHOT
+bundle mvn:org.apache.felix/org.apache.felix.configadmin/1.6.0
+start.all.bundles
+
+# OSGi configs that activate our test servlets
+config org.apache.sling.crankstart.testservices.SingleConfigServlet
+ path=${single.path}
+ message=doesn't matter
+
+# Informative log
+log felix http service should come up at http://localhost:${http.port}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 14/31: config.factory
support
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 1de5fcf54d7ea4a47ce7a9d5702e6035582d89f0
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri May 16 12:36:55 2014 +0000
config.factory support
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1595177 13f79535-47bb-0310-9956-ffa450edef68
---
.../crankstart/launcher/CrankstartBootstrapTest.java | 12 ++++++++----
.../{launcher-test.txt => launcher-test.crank.txt} | 19 +++++++++++++------
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
index 5e0fb50..ff12860 100644
--- a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
+++ b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
@@ -18,7 +18,6 @@ import org.apache.sling.commons.testing.junit.Retry;
import org.apache.sling.commons.testing.junit.RetryRule;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
@@ -31,7 +30,7 @@ public class CrankstartBootstrapTest {
private static final HttpClient client = new HttpClient();
private static Thread crankstartThread;
private static String baseUrl = "http://localhost:" + port;
- public static final String TEST_RESOURCE = "/launcher-test.txt";
+ public static final String TEST_RESOURCE = "/launcher-test.crank.txt";
@Rule
public final RetryRule retryRule = new RetryRule();
@@ -107,13 +106,18 @@ public class CrankstartBootstrapTest {
public void testSingleConfigServlet() throws Exception {
final GetMethod get = new GetMethod(baseUrl + "/single");
client.executeMethod(get);
- assertEquals("Expecting success " + get.getURI(), 200, get.getStatusCode());
+ assertEquals("Expecting success for " + get.getURI(), 200, get.getStatusCode());
}
@Test
@Retry(timeoutMsec=10000, intervalMsec=250)
- @Ignore("TODO - activate once we support config factories")
public void testConfigFactoryServlet() throws Exception {
+ final String [] paths = { "/foo", "/bar/test" };
+ for(String path : paths) {
+ final GetMethod get = new GetMethod(baseUrl + path);
+ client.executeMethod(get);
+ assertEquals("Expecting success for " + get.getURI(), 200, get.getStatusCode());
+ }
}
private static String getOsgiStoragePath() {
diff --git a/src/test/resources/launcher-test.txt b/src/test/resources/launcher-test.crank.txt
similarity index 73%
rename from src/test/resources/launcher-test.txt
rename to src/test/resources/launcher-test.crank.txt
index d1868c5..8af6a32 100644
--- a/src/test/resources/launcher-test.txt
+++ b/src/test/resources/launcher-test.crank.txt
@@ -2,14 +2,12 @@
# server with a few servlets that require specific OSGi configurations
# Default values for our variables
-defaults pax.version 1.6.0
defaults single.path /single
+defaults felix.http.jetty.version 2.2.0
-# Bootstrap classpath
+# Bootstrap classpath (variables are not supported here)
classpath mvn:org.apache.felix/org.apache.felix.framework/4.4.0
classpath mvn:org.slf4j/slf4j-api/1.6.2
-classpath mvn:org.ops4j.pax.url/pax-url-aether/${pax.version}
-classpath mvn:org.ops4j.pax.url/pax-url-commons/${pax.version}
classpath mvn:org.apache.sling/org.apache.sling.crankstart.core/0.0.1-SNAPSHOT
classpath mvn:org.apache.sling/org.apache.sling.crankstart.api/0.0.1-SNAPSHOT
@@ -21,9 +19,10 @@ osgi.property org.osgi.framework.storage ${osgi.storage.path}
start.framework
# Start ConfigAdmin, HTTP service and SCR
-bundle mvn:org.apache.felix/org.apache.felix.http.jetty/2.2.0
+bundle mvn:org.apache.felix/org.apache.felix.http.jetty/${felix.http.jetty.version}
bundle mvn:org.apache.felix/org.apache.felix.eventadmin/1.3.2
bundle mvn:org.apache.felix/org.apache.felix.scr/1.8.2
+bundle mvn:org.apache.felix/org.apache.felix.metatype/1.0.10
bundle mvn:org.apache.sling/org.apache.sling.commons.osgi/2.2.1-SNAPSHOT
bundle mvn:org.apache.sling/org.apache.sling.commons.log/2.1.2
bundle mvn:org.apache.sling/org.apache.sling.crankstart.test.services/0.0.1-SNAPSHOT
@@ -35,5 +34,13 @@ config org.apache.sling.crankstart.testservices.SingleConfigServlet
path=${single.path}
message=doesn't matter
+config.factory org.apache.sling.crankstart.testservices.ConfigFactoryServlet
+ path=/foo
+ message=Not used
+
+config.factory org.apache.sling.crankstart.testservices.ConfigFactoryServlet
+ path=/bar/test
+ message=Not used
+
# Informative log
-log felix http service should come up at http://localhost:${http.port}
+log felix http service should come up at http://localhost:${http.port}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 29/31: Use released
versions
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 5b84eb777a932c19c478f04b195dc20b00e6c93f
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Sep 1 15:01:39 2014 +0000
Use released versions
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1621815 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 10 +++++-----
src/test/resources/launcher-test.crank.txt | 10 +++++-----
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/pom.xml b/pom.xml
index 014e666..70e7b9e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -104,31 +104,31 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.crankstart.api</artifactId>
- <version>0.0.1-SNAPSHOT</version>
+ <version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.crankstart.api.fragment</artifactId>
- <version>0.0.1-SNAPSHOT</version>
+ <version>1.0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.crankstart.core</artifactId>
- <version>0.0.1-SNAPSHOT</version>
+ <version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.crankstart.test.services</artifactId>
- <version>0.0.1-SNAPSHOT</version>
+ <version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.crankstart.sling.extensions</artifactId>
- <version>0.0.1-SNAPSHOT</version>
+ <version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
diff --git a/src/test/resources/launcher-test.crank.txt b/src/test/resources/launcher-test.crank.txt
index f48cfbe..fe59f40 100644
--- a/src/test/resources/launcher-test.crank.txt
+++ b/src/test/resources/launcher-test.crank.txt
@@ -9,8 +9,8 @@ defaults felix.http.jetty.version 2.2.0
classpath mvn:org.apache.felix/org.apache.felix.framework/4.4.0
classpath mvn:org.slf4j/slf4j-api/1.6.2
classpath mvn:org.slf4j/slf4j-simple/1.6.2
-classpath mvn:org.apache.sling/org.apache.sling.crankstart.core/0.0.1-SNAPSHOT
-classpath mvn:org.apache.sling/org.apache.sling.crankstart.api/0.0.1-SNAPSHOT
+classpath mvn:org.apache.sling/org.apache.sling.crankstart.core/1.0.0
+classpath mvn:org.apache.sling/org.apache.sling.crankstart.api/1.0.0
# OSGi properties
osgi.property org.osgi.service.http.port ${http.port}
@@ -33,15 +33,15 @@ bundle mvn:org.apache.felix/org.apache.felix.webconsole/3.1.6
# The crankstart.api.fragment bundle makes the crankstart.api package available
# to bundles, required for bundles to provide crankstart extension commands like
# the test.system.property command below
-bundle mvn:org.apache.sling/org.apache.sling.crankstart.api.fragment/0.0.1-SNAPSHOT
-bundle mvn:org.apache.sling/org.apache.sling.crankstart.test.services/0.0.1-SNAPSHOT
+bundle mvn:org.apache.sling/org.apache.sling.crankstart.api.fragment/1.0.2
+bundle mvn:org.apache.sling/org.apache.sling.crankstart.test.services/1.0.0
# Test our Sling extension commands, that add a bundle via the Sling installer
# (which requires commons.json and jcr-wrapper)
bundle mvn:org.apache.sling/org.apache.sling.installer.core/3.5.0
bundle mvn:org.apache.sling/org.apache.sling.commons.json/2.0.6
bundle mvn:org.apache.sling/org.apache.sling.jcr.jcr-wrapper/2.0.0
-bundle mvn:org.apache.sling/org.apache.sling.crankstart.sling.extensions/0.0.1-SNAPSHOT
+bundle mvn:org.apache.sling/org.apache.sling.crankstart.sling.extensions/1.0.0
bundle mvn:commons-io/commons-io/2.4
# Install a bundle at a start level higher than the current one
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 10/31: SLING-3528 -
configure command, based on a contribution by Artyom Stetsenko, thanks!
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit b85b1817cd966566b96bfefd714a5cb9d5b0fdab
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed May 14 15:51:17 2014 +0000
SLING-3528 - configure command, based on a contribution by Artyom Stetsenko, thanks!
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1594621 13f79535-47bb-0310-9956-ffa450edef68
---
sling.crank.txt | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/sling.crank.txt b/sling.crank.txt
index c235723..c698b2a 100644
--- a/sling.crank.txt
+++ b/sling.crank.txt
@@ -28,14 +28,26 @@ osgi.property org.osgi.framework.startlevel.beginning 32
# Once OSGi properties are set, start the framework
start.framework
-# Install bundles
-# mvn: protocol can be used.
-bundle mvn:org.apache.felix/org.apache.felix.http.jetty/2.2.0
+# Start a minimal set of bundles to get the ConfigurationAdmin service
+# mvn: protocol can be used to get bundles
bundle mvn:org.slf4j/slf4j-api/1.7.6
bundle mvn:org.apache.sling/org.apache.sling.commons.log/4.0.0
bundle mvn:org.apache.sling/org.apache.sling.commons.logservice/1.0.2
bundle mvn:org.slf4j/jcl-over-slf4j/1.7.6
bundle mvn:org.slf4j/log4j-over-slf4j/1.7.6
+bundle mvn:org.apache.felix/org.apache.felix.configadmin/1.6.0
+start.all.bundles
+
+# Now set example configurations
+config some.example.config
+ some.search.path = /test1:123
+ some.search.path = /test2:456
+ another.property = This is just a test configuration
+config a.second.config
+ foo = bar
+
+# Install other bundles
+bundle mvn:org.apache.felix/org.apache.felix.http.jetty/2.2.0
bundle mvn:org.apache.sling/org.apache.sling.settings/1.3.0
bundle mvn:org.apache.sling/org.apache.sling.fragment.xml/1.0.2
bundle mvn:org.apache.sling/org.apache.sling.fragment.transaction/1.0.0
@@ -44,7 +56,6 @@ bundle mvn:org.apache.sling/org.apache.sling.fragment.ws/1.0.2
bundle mvn:org.apache.sling/org.apache.sling.launchpad.installer/1.2.0
bundle mvn:org.apache.sling/org.apache.sling.installer.core/3.5.0
bundle mvn:org.apache.sling/org.apache.sling.installer.provider.file/1.0.2
-bundle mvn:org.apache.felix/org.apache.felix.configadmin/1.6.0
bundle mvn:org.apache.felix/org.apache.felix.eventadmin/1.3.2
bundle mvn:commons-io/commons-io/1.4
bundle mvn:commons-fileupload/commons-fileupload/1.3.1
@@ -56,6 +67,7 @@ bundle mvn:org.apache.geronimo.bundles/commons-httpclient/3.1_1
bundle mvn:org.apache.sling/org.apache.sling.commons.osgi/2.2.1-SNAPSHOT
bundle mvn:org.apache.sling/org.apache.sling.commons.mime/2.1.4
bundle mvn:org.apache.sling/org.apache.sling.commons.classloader/1.3.0
+bundle mvn:org.apache.sling/org.apache.sling.commons.compiler/2.1.1-SNAPSHOT
bundle mvn:org.apache.sling/org.apache.sling.commons.scheduler/2.4.2
bundle mvn:org.apache.sling/org.apache.sling.commons.threads/3.2.0
bundle mvn:org.apache.sling/org.apache.sling.discovery.api/1.0.0
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 12/31: support
variables in crankstart files, with default values
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 8fa2076cc8aaa16ff6b105d3c98cdac00284cfee
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri May 16 06:49:28 2014 +0000
support variables in crankstart files, with default values
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1595123 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
sling.crank.txt | 7 ++++--
.../launcher/CrankstartBootstrapTest.java | 26 +++++++++++++++++++---
3 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/pom.xml b/pom.xml
index 1384639..e120a5b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -113,7 +113,7 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.6</version>
- <scope>provided</scope>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.url</groupId>
diff --git a/sling.crank.txt b/sling.crank.txt
index c698b2a..51aa387 100644
--- a/sling.crank.txt
+++ b/sling.crank.txt
@@ -2,6 +2,9 @@
# TODO: not all integration tests pass, we might be missing some
# bundles or properties that the Sling launchpad provides
+# Set default values for our variables
+defaults http.port 12345
+
# Set bootstrap classpath, mvn: protocol can be used
classpath mvn:org.apache.felix/org.apache.felix.framework/4.4.0
classpath mvn:org.osgi/org.osgi.compendium/4.2.0
@@ -15,7 +18,7 @@ classpath mvn:org.apache.sling/org.apache.sling.crankstart.core/0.0.1-SNAPSHOT
classpath mvn:org.apache.sling/org.apache.sling.crankstart.api/0.0.1-SNAPSHOT
# Set OSGi framework properties
-osgi.property org.osgi.service.http.port 1234
+osgi.property org.osgi.service.http.port ${http.port}
osgi.property sling.home sling-crankstart
osgi.property org.osgi.framework.storage sling-crankstart/osgi.framework.storage
osgi.property org.apache.sling.commons.log.level INFO
@@ -148,4 +151,4 @@ bundle mvn:org.apache.sling/org.apache.sling.launchpad.api/1.1.0
# Now start bundles
start.all.bundles
-log Sling will be available at http://localhost:1234/system/console
+log Sling will be available at http://localhost:${http.port}/system/console
diff --git a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
index 389f606..d716d45 100644
--- a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
+++ b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
@@ -6,6 +6,7 @@ import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
+import java.net.ServerSocket;
import java.util.Random;
import org.apache.commons.httpclient.HttpClient;
@@ -23,7 +24,7 @@ import org.junit.Test;
*/
public class CrankstartBootstrapTest {
- private static final int port = Integer.valueOf(System.getProperty("test.http.port", "12345"));
+ private static final int port = getAvailablePort();
private static final HttpClient client = new HttpClient();
private static Thread crankstartThread;
private static String baseUrl = "http://localhost:" + port;
@@ -31,6 +32,24 @@ public class CrankstartBootstrapTest {
@Rule
public final RetryRule retryRule = new RetryRule();
+ private static int getAvailablePort() {
+ int result = -1;
+ ServerSocket s = null;
+ try {
+ try {
+ s = new ServerSocket(0);
+ result = s.getLocalPort();
+ } finally {
+ if(s != null) {
+ s.close();
+ }
+ }
+ } catch(Exception e) {
+ throw new RuntimeException("getAvailablePort failed", e);
+ }
+ return result;
+ }
+
private final static String CRANKSTART =
"classpath mvn:org.apache.felix/org.apache.felix.framework/4.4.0\n"
+ "classpath mvn:org.slf4j/slf4j-api/1.6.2\n"
@@ -38,7 +57,7 @@ public class CrankstartBootstrapTest {
+ "classpath mvn:org.ops4j.pax.url/pax-url-commons/1.6.0\n"
+ "classpath mvn:org.apache.sling/org.apache.sling.crankstart.core/0.0.1-SNAPSHOT\n"
+ "classpath mvn:org.apache.sling/org.apache.sling.crankstart.api/0.0.1-SNAPSHOT\n"
- + "osgi.property org.osgi.service.http.port " + port + "\n"
+ + "osgi.property org.osgi.service.http.port ${http.port}\n"
+ "osgi.property org.osgi.framework.storage " + getOsgiStoragePath() + "\n"
+ "start.framework\n"
+ "bundle mvn:org.apache.felix/org.apache.felix.http.jetty/2.2.0\n"
@@ -52,12 +71,13 @@ public class CrankstartBootstrapTest {
+ "config org.apache.sling.crankstart.testservices.SingleConfigServlet\n"
+ " path=/single\n"
+ " message=doesn't matter\n"
- + "log felix http service should come up at http://localhost:" + port + "\n"
+ + "log felix http service should come up at http://localhost:${http.port}\n"
;
@BeforeClass
public static void setup() {
final GetMethod get = new GetMethod(baseUrl);
+ System.setProperty("http.port", String.valueOf(port));
try {
client.executeMethod(get);
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 23/31: Use
CRANKSTART_CONFIG_ID property to avoid creating duplicate factory configs
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 415617ccfffdcbe6a56ac99fccf6d26303fb99ed
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Jul 28 10:03:30 2014 +0000
Use CRANKSTART_CONFIG_ID property to avoid creating duplicate factory configs
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1613944 13f79535-47bb-0310-9956-ffa450edef68
---
src/test/resources/launcher-test.crank.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/test/resources/launcher-test.crank.txt b/src/test/resources/launcher-test.crank.txt
index 32266d5..54b5461 100644
--- a/src/test/resources/launcher-test.crank.txt
+++ b/src/test/resources/launcher-test.crank.txt
@@ -51,6 +51,7 @@ config org.apache.sling.crankstart.testservices.SingleConfigServlet
message=doesn't matter
config.factory org.apache.sling.crankstart.testservices.ConfigFactoryServlet
+ CRANKSTART_CONFIG_ID=some.unique.ID
path=/foo
message=Not used
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 19/31: Accept null
properties
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 8ebb48be7e89ac6cb43865979d9819d876eef5d7
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Jun 6 12:39:29 2014 +0000
Accept null properties
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1600870 13f79535-47bb-0310-9956-ffa450edef68
---
src/test/resources/launcher-test.crank.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/test/resources/launcher-test.crank.txt b/src/test/resources/launcher-test.crank.txt
index 6376370..f302721 100644
--- a/src/test/resources/launcher-test.crank.txt
+++ b/src/test/resources/launcher-test.crank.txt
@@ -63,6 +63,8 @@ config felix.format.test FORMAT:felix.config
service.ranking.launcher.test=I"54321"
array=["foo","bar.from.launcher.test"]
+config empty.config.should.work FORMAT:felix.config
+
# Test an extension command provided by our test-services bundle
test.system.property the.test.system.property was set by test-services bundle
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 28/31: Add scm info
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit c2cb6dbdd53b2c9443d67e595eba152a9913335b
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Sep 1 13:47:57 2014 +0000
Add scm info
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1621776 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/pom.xml b/pom.xml
index 84f0979..014e666 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,6 +22,12 @@
A different way of starting Sling
</description>
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher</developerConnection>
+ <url>http://sling.apache.org</url>
+ </scm>
+
<properties>
<pax.url.version>2.1.0</pax.url.version>
</properties>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 09/31: SLING-3528 -
add test-services to prepare for config command testing
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 7f6e504dfb2785ec5effab6746371e43172e156e
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri May 2 08:13:56 2014 +0000
SLING-3528 - add test-services to prepare for config command testing
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1591823 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 6 +++++
.../launcher/CrankstartBootstrapTest.java | 30 +++++++++++-----------
2 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/pom.xml b/pom.xml
index 555db0e..9e10b6b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -97,6 +97,12 @@
<version>0.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.crankstart.test.services</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
diff --git a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
index c559290..64c9205 100644
--- a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
+++ b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
@@ -6,8 +6,6 @@ import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.util.Random;
import org.apache.commons.httpclient.HttpClient;
@@ -16,6 +14,7 @@ import org.apache.sling.commons.testing.junit.Retry;
import org.apache.sling.commons.testing.junit.RetryRule;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
@@ -27,16 +26,8 @@ public class CrankstartBootstrapTest {
private static final int port = Integer.valueOf(System.getProperty("test.http.port", "12345"));
private static final HttpClient client = new HttpClient();
private static Thread crankstartThread;
- private static URL rootUrl = null;
+ private static String baseUrl = "http://localhost:" + port;
- static {
- try {
- rootUrl = new URL("http://localhost:" + port + "/");
- } catch(MalformedURLException mfe) {
- fail(mfe.toString());
- }
- }
-
@Rule
public final RetryRule retryRule = new RetryRule();
@@ -58,7 +49,7 @@ public class CrankstartBootstrapTest {
@BeforeClass
public static void setup() {
- final GetMethod get = new GetMethod(rootUrl.toExternalForm());
+ final GetMethod get = new GetMethod(baseUrl);
try {
client.executeMethod(get);
@@ -87,10 +78,19 @@ public class CrankstartBootstrapTest {
@Test
@Retry(timeoutMsec=10000, intervalMsec=250)
- public void testHttpResponse() throws Exception {
- final GetMethod get = new GetMethod(rootUrl.toExternalForm());
+ public void testHttpRoot() throws Exception {
+ final GetMethod get = new GetMethod(baseUrl);
+ client.executeMethod(get);
+ assertEquals("Expecting page not found at " + get.getURI(), 404, get.getStatusCode());
+ }
+
+ @Test
+ @Retry(timeoutMsec=10000, intervalMsec=250)
+ @Ignore("TODO: activate once config command is ready")
+ public void testSingleConfigServlet() throws Exception {
+ final GetMethod get = new GetMethod(baseUrl + "/single");
client.executeMethod(get);
- assertEquals("Expecting 404 at " + get.getURI(), 404, get.getStatusCode());
+ assertEquals("Expecting success " + get.getURI(), 200, get.getStatusCode());
}
private static String getOsgiStoragePath() {
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 11/31: SLING-3528 -
test the config command in CrankstartBootstrapTest
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit d9d1250bb059adba02ea68f28078163ec996522f
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed May 14 16:12:33 2014 +0000
SLING-3528 - test the config command in CrankstartBootstrapTest
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1594629 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 4 ++--
.../crankstart/launcher/CrankstartBootstrapTest.java | 15 ++++++++++++++-
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index 9e10b6b..1384639 100644
--- a/pom.xml
+++ b/pom.xml
@@ -75,7 +75,7 @@
<fileset>
<directory>${basedir}</directory>
<includes>
- <include>felix-cache</include>
+ <include>sling-crankstart</include>
</includes>
</fileset>
</filesets>
@@ -100,7 +100,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.crankstart.test.services</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>0.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
diff --git a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
index 64c9205..389f606 100644
--- a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
+++ b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
@@ -42,8 +42,16 @@ public class CrankstartBootstrapTest {
+ "osgi.property org.osgi.framework.storage " + getOsgiStoragePath() + "\n"
+ "start.framework\n"
+ "bundle mvn:org.apache.felix/org.apache.felix.http.jetty/2.2.0\n"
+ + "bundle mvn:org.apache.felix/org.apache.felix.eventadmin/1.3.2\n"
+ + "bundle mvn:org.apache.felix/org.apache.felix.scr/1.8.2\n"
+ + "bundle mvn:org.apache.sling/org.apache.sling.commons.osgi/2.2.1-SNAPSHOT\n"
+ "bundle mvn:org.apache.sling/org.apache.sling.commons.log/2.1.2\n"
+ + "bundle mvn:org.apache.sling/org.apache.sling.crankstart.test.services/0.0.1-SNAPSHOT\n"
+ + "bundle mvn:org.apache.felix/org.apache.felix.configadmin/1.6.0\n"
+ "start.all.bundles\n"
+ + "config org.apache.sling.crankstart.testservices.SingleConfigServlet\n"
+ + " path=/single\n"
+ + " message=doesn't matter\n"
+ "log felix http service should come up at http://localhost:" + port + "\n"
;
@@ -86,13 +94,18 @@ public class CrankstartBootstrapTest {
@Test
@Retry(timeoutMsec=10000, intervalMsec=250)
- @Ignore("TODO: activate once config command is ready")
public void testSingleConfigServlet() throws Exception {
final GetMethod get = new GetMethod(baseUrl + "/single");
client.executeMethod(get);
assertEquals("Expecting success " + get.getURI(), 200, get.getStatusCode());
}
+ @Test
+ @Retry(timeoutMsec=10000, intervalMsec=250)
+ @Ignore("TODO - activate once we support config factories")
+ public void testConfigFactoryServlet() throws Exception {
+ }
+
private static String getOsgiStoragePath() {
final File tmpRoot = new File(System.getProperty("java.io.tmpdir"));
final Random random = new Random();
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 26/31: Use
org.ops4j.pax.url.mvn.localRepository to point to the same local repository
that this build uses
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 48408210bfb5ca49184b79748156e0a07f5f47fd
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed Aug 6 08:41:59 2014 +0000
Use org.ops4j.pax.url.mvn.localRepository to point to the same local repository that this build uses
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1616128 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 12 +++++++++++-
src/test/resources/launcher-test.crank.txt | 2 +-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index a91660d..84f0979 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
</description>
<properties>
- <pax.url.version>1.6.0</pax.url.version>
+ <pax.url.version>2.1.0</pax.url.version>
</properties>
<build>
@@ -81,6 +81,16 @@
</filesets>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <!-- pax url needs the local Maven repository to find snapshots we just built -->
+ <org.ops4j.pax.url.mvn.localRepository>${settings.localRepository}/</org.ops4j.pax.url.mvn.localRepository>
+ </systemProperties>
+ </configuration>
+ </plugin>
</plugins>
</build>
diff --git a/src/test/resources/launcher-test.crank.txt b/src/test/resources/launcher-test.crank.txt
index 179d4dd..981be3b 100644
--- a/src/test/resources/launcher-test.crank.txt
+++ b/src/test/resources/launcher-test.crank.txt
@@ -23,7 +23,7 @@ bundle mvn:org.apache.felix/org.apache.felix.http.jetty/${felix.http.jetty.versi
bundle mvn:org.apache.felix/org.apache.felix.eventadmin/1.3.2
bundle mvn:org.apache.felix/org.apache.felix.scr/1.8.2
bundle mvn:org.apache.felix/org.apache.felix.metatype/1.0.10
-bundle mvn:org.apache.sling/org.apache.sling.commons.osgi/2.2.1-SNAPSHOT
+bundle mvn:org.apache.sling/org.apache.sling.commons.osgi/2.2.0
bundle mvn:org.apache.sling/org.apache.sling.commons.log/2.1.2
bundle mvn:org.apache.felix/org.apache.felix.configadmin/1.6.0
bundle mvn:org.apache.felix/org.apache.felix.webconsole/3.1.6
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 31/31:
[maven-release-plugin] copy for tag
org.apache.sling.crankstart.launcher-1.0.0
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit a1fbd10c4beca9a5b1256cbf0091067e8dd071bb
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Sep 1 15:02:25 2014 +0000
[maven-release-plugin] copy for tag org.apache.sling.crankstart.launcher-1.0.0
git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.crankstart.launcher-1.0.0@1621818 13f79535-47bb-0310-9956-ffa450edef68
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 06/31: Initial Sling
crankstart definition file
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 32198ff9a869aeae3759ef2da0c60eb0a119ba7a
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed Apr 23 08:57:13 2014 +0000
Initial Sling crankstart definition file
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1589355 13f79535-47bb-0310-9956-ffa450edef68
---
sling.crank.txt | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 139 insertions(+)
diff --git a/sling.crank.txt b/sling.crank.txt
new file mode 100644
index 0000000..387ad82
--- /dev/null
+++ b/sling.crank.txt
@@ -0,0 +1,139 @@
+# Start a full Sling instance with the Sling crankstart launcher
+# TODO: not all integration tests pass, we might be missing some
+# bundles or properties that the Sling launchpad provides
+
+# Set bootstrap classpath, mvn: protocol can be used
+classpath mvn:org.apache.felix/org.apache.felix.framework/4.4.0
+classpath mvn:org.osgi/org.osgi.compendium/4.2.0
+classpath mvn:org.slf4j/slf4j-api/1.6.2
+classpath mvn:org.slf4j/slf4j-simple/1.6.2
+classpath mvn:org.ops4j.pax.url/pax-url-aether/1.6.0
+classpath mvn:org.ops4j.pax.url/pax-url-commons/1.6.0
+
+# Except for the bootstrap launcher, crankstart jars are also provided via classpath
+classpath mvn:org.apache.sling/org.apache.sling.crankstart.core/0.0.1-SNAPSHOT
+classpath mvn:org.apache.sling/org.apache.sling.crankstart.api/0.0.1-SNAPSHOT
+
+# Set OSGi framework properties
+osgi.property org.osgi.service.http.port 1234
+osgi.property sling.home sling-crankstart
+osgi.property org.osgi.framework.storage sling-crankstart/osgi.framework.storage
+osgi.property org.apache.sling.commons.log.level INFO
+osgi.property org.apache.sling.commons.log.file logs/error.log
+osgi.property org.apache.sling.commons.log.file.number 5
+osgi.property org.apache.sling.commons.log.file.size '.'yyyy-MM-dd
+osgi.property felix.startlevel.bundle 22
+osgi.property org.osgi.framework.startlevel.beginning 32
+
+# Once OSGi properties are set, start the framework
+start.framework
+
+# Install bundles
+# mvn: protocol can be used.
+bundle mvn:org.apache.felix/org.apache.felix.http.jetty/2.2.0
+bundle mvn:org.slf4j/slf4j-api/1.7.6
+bundle mvn:org.apache.sling/org.apache.sling.commons.log/4.0.0
+bundle mvn:org.apache.sling/org.apache.sling.commons.logservice/1.0.2
+bundle mvn:org.slf4j/jcl-over-slf4j/1.7.6
+bundle mvn:org.slf4j/log4j-over-slf4j/1.7.6
+bundle mvn:org.apache.sling/org.apache.sling.settings/1.3.0
+bundle mvn:org.apache.sling/org.apache.sling.fragment.xml/1.0.2
+bundle mvn:org.apache.sling/org.apache.sling.fragment.transaction/1.0.0
+bundle mvn:org.apache.sling/org.apache.sling.javax.activation/0.1.0
+bundle mvn:org.apache.sling/org.apache.sling.fragment.ws/1.0.2
+bundle mvn:org.apache.sling/org.apache.sling.launchpad.installer/1.2.0
+bundle mvn:org.apache.sling/org.apache.sling.installer.core/3.5.0
+bundle mvn:org.apache.sling/org.apache.sling.installer.provider.file/1.0.2
+bundle mvn:org.apache.felix/org.apache.felix.configadmin/1.6.0
+bundle mvn:org.apache.felix/org.apache.felix.eventadmin/1.3.2
+bundle mvn:commons-io/commons-io/1.4
+bundle mvn:commons-fileupload/commons-fileupload/1.3.1
+bundle mvn:commons-collections/commons-collections/3.2.1
+bundle mvn:commons-codec/commons-codec/1.6
+bundle mvn:commons-lang/commons-lang/2.5
+bundle mvn:org.apache.commons/commons-math/2.2
+bundle mvn:org.apache.geronimo.bundles/commons-httpclient/3.1_1
+bundle mvn:org.apache.sling/org.apache.sling.commons.osgi/2.2.1-SNAPSHOT
+bundle mvn:org.apache.sling/org.apache.sling.commons.mime/2.1.4
+bundle mvn:org.apache.sling/org.apache.sling.commons.classloader/1.3.0
+bundle mvn:org.apache.sling/org.apache.sling.commons.scheduler/2.4.2
+bundle mvn:org.apache.sling/org.apache.sling.commons.threads/3.2.0
+bundle mvn:org.apache.sling/org.apache.sling.discovery.api/1.0.0
+bundle mvn:org.apache.sling/org.apache.sling.discovery.support/1.0.0
+bundle mvn:org.apache.sling/org.apache.sling.discovery.impl/1.0.4
+bundle mvn:org.apache.sling/org.apache.sling.event/3.3.6
+bundle mvn:org.apache.sling/org.apache.sling.api/2.7.0
+bundle mvn:org.apache.sling/org.apache.sling.serviceusermapper/1.0.0
+bundle mvn:org.apache.sling/org.apache.sling.resourceresolver/1.1.0
+bundle mvn:org.apache.sling/org.apache.sling.auth.core/1.1.7-SNAPSHOT
+bundle mvn:org.apache.sling/org.apache.sling.engine/2.3.2
+bundle mvn:org.apache.sling/org.apache.sling.auth.openid/1.0.3-SNAPSHOT
+bundle mvn:org.apache.sling/org.apache.sling.auth.form/1.0.5-SNAPSHOT
+bundle mvn:org.apache.sling/org.apache.sling.auth.selector/1.0.5-SNAPSHOT
+bundle mvn:org.apache.sling/org.apache.sling.adapter/2.1.0
+bundle mvn:org.apache.sling/org.apache.sling.servlets.resolver/2.3.2
+bundle mvn:org.apache.sling/org.apache.sling.servlets.get/2.1.8
+bundle mvn:org.apache.sling/org.apache.sling.servlets.post/2.3.4
+bundle mvn:org.apache.sling/org.apache.sling.jcr.contentloader/2.1.7-SNAPSHOT
+bundle mvn:org.apache.sling/org.apache.sling.jcr.resource/2.3.6
+bundle mvn:org.apache.sling/org.apache.sling.jcr.ocm/2.0.4-incubator
+bundle mvn:org.apache.sling/org.apache.sling.jcr.classloader/3.2.0
+bundle mvn:org.apache.sling/org.apache.sling.bundleresource.impl/2.2.0
+bundle mvn:org.apache.sling/org.apache.sling.fsresource/1.1.3-SNAPSHOT
+bundle mvn:org.apache.sling/org.apache.sling.launchpad.content/2.0.7-SNAPSHOT
+bundle mvn:org.apache.sling/org.apache.sling.scripting.api/2.1.6
+bundle mvn:org.apache.sling/org.apache.sling.scripting.core/2.0.26
+bundle mvn:org.apache.sling/org.apache.sling.scripting.javascript/2.0.12
+bundle mvn:org.apache.sling/org.apache.sling.scripting.jsp/2.0.29-SNAPSHOT
+bundle mvn:org.apache.sling/org.apache.sling.scripting.jsp.taglib/2.2.0
+bundle mvn:org.apache.geronimo.bundles/jstl/1.2_1
+bundle mvn:org.codehaus.groovy/groovy-all/1.8.2
+bundle mvn:org.apache.felix/org.apache.felix.http.whiteboard/2.2.0
+bundle mvn:org.apache.sling/org.apache.sling.installer.console/1.0.0
+bundle mvn:org.apache.sling/org.apache.sling.installer.factory.configuration/1.0.12
+bundle mvn:org.apache.sling/org.apache.sling.installer.provider.jcr/3.1.6
+bundle mvn:org.apache.sling/org.apache.sling.extensions.webconsolebranding/1.0.0
+bundle mvn:org.apache.sling/org.apache.sling.extensions.webconsolesecurityprovider/1.0.0
+bundle mvn:org.apache.felix/org.apache.felix.inventory/1.0.4
+bundle mvn:org.apache.felix/org.apache.felix.webconsole/4.2.2
+bundle mvn:org.apache.geronimo.bundles/json/20090211_1
+bundle mvn:org.apache.felix/org.apache.felix.webconsole.plugins.ds/1.0.0
+bundle mvn:org.apache.felix/org.apache.felix.webconsole.plugins.packageadmin/1.0.0
+bundle mvn:org.apache.felix/org.apache.felix.webconsole.plugins.event/1.0.2
+bundle mvn:org.apache.felix/org.apache.felix.webconsole.plugins.memoryusage/1.0.4
+bundle mvn:org.apache.sling/org.apache.sling.commons.json/2.0.6
+bundle mvn:org.apache.felix/org.apache.felix.bundlerepository/1.6.4
+bundle mvn:org.apache.sling/org.apache.sling.extensions.threaddump/0.2.2
+bundle mvn:org.apache.sling/org.apache.sling.jcr.webconsole/1.0.0
+bundle mvn:org.apache.sling/org.apache.sling.extensions.explorer/1.0.2
+bundle mvn:org.apache.sling/org.apache.sling.extensions.groovy/1.0.0-SNAPSHOT
+bundle mvn:org.apache.aries.jmx/org.apache.aries.jmx.api/0.3
+bundle mvn:org.apache.aries/org.apache.aries.util/0.3
+bundle mvn:org.apache.aries.jmx/org.apache.aries.jmx.core/0.3
+bundle mvn:org.apache.aries.jmx/org.apache.aries.jmx.whiteboard/0.3
+bundle mvn:org.apache.felix/org.apache.felix.scr/1.8.2
+bundle mvn:org.apache.felix/org.apache.felix.metatype/1.0.10
+bundle mvn:org.apache.tika/tika-core/1.2
+bundle mvn:org.apache.tika/tika-bundle/1.2
+bundle mvn:org.apache.sling/org.apache.sling.jcr.jcr-wrapper/2.0.0
+bundle mvn:org.apache.sling/org.apache.sling.jcr.api/2.2.0
+bundle mvn:org.apache.sling/org.apache.sling.jcr.base/2.2.2
+bundle mvn:org.apache.sling/org.apache.sling.jcr.registration/1.0.0
+bundle mvn:org.apache.jackrabbit/jackrabbit-api/2.7.1
+bundle mvn:org.apache.derby/derby/10.5.3.0_1
+bundle mvn:org.apache.sling/org.apache.sling.jcr.jackrabbit.server/2.1.3-SNAPSHOT
+bundle mvn:org.apache.sling/org.apache.sling.jcr.jackrabbit.usermanager/2.2.1-SNAPSHOT
+bundle mvn:org.apache.sling/org.apache.sling.jcr.jackrabbit.accessmanager/2.1.1-SNAPSHOT
+bundle mvn:org.apache.jackrabbit/jackrabbit-jcr-commons/2.7.1
+bundle mvn:org.apache.jackrabbit/jackrabbit-spi/2.7.1
+bundle mvn:org.apache.jackrabbit/jackrabbit-spi-commons/2.7.1
+bundle mvn:org.apache.jackrabbit/jackrabbit-webdav/2.7.1
+bundle mvn:org.apache.jackrabbit/jackrabbit-jcr-rmi/2.7.1
+bundle mvn:org.apache.sling/org.apache.sling.jcr.webdav/2.2.2
+bundle mvn:org.apache.sling/org.apache.sling.jcr.davex/1.2.1-SNAPSHOT
+bundle mvn:com.google.guava/guava/14.0.1
+bundle mvn:org.apache.sling/org.apache.sling.launchpad.api/1.1.0
+
+# Now start bundles
+start.all.bundles
+log Sling will be available at http://localhost:1234/system/console
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 22/31: Fix
registration of multiple resources via the Sling installer
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 3d4007b46f30377894e1e116e8afe07a57abdce0
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Jul 1 10:56:26 2014 +0000
Fix registration of multiple resources via the Sling installer
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1607039 13f79535-47bb-0310-9956-ffa450edef68
---
.../launcher/CrankstartBootstrapTest.java | 23 ++++++++++++++++++++++
src/test/resources/launcher-test.crank.txt | 7 ++++++-
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
index c0d7f0d..f5c8547 100644
--- a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
+++ b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
@@ -193,6 +193,29 @@ public class CrankstartBootstrapTest {
@Test
@Retry(timeoutMsec=10000, intervalMsec=250)
+ public void testAdditionalBundles() throws Exception {
+ setAdminCredentials();
+ final String basePath = "/system/console/bundles/";
+ final String [] addBundles = {
+ "org.apache.sling.commons.mime",
+ "org.apache.sling.settings"
+ };
+
+ for(String name : addBundles) {
+ final String path = basePath + name;
+ final HttpUriRequest get = new HttpGet(baseUrl + path);
+ HttpResponse response = null;
+ try {
+ response = client.execute(get);
+ assertEquals("Expecting additional bundle to be present at " + get.getURI(), 200, response.getStatusLine().getStatusCode());
+ } finally {
+ closeConnection(response);
+ }
+ }
+ }
+
+ @Test
+ @Retry(timeoutMsec=10000, intervalMsec=250)
public void testFelixFormatConfig() throws Exception {
setAdminCredentials();
final String path = "/system/console/config/configuration-status-20140606-1347+0200.txt";
diff --git a/src/test/resources/launcher-test.crank.txt b/src/test/resources/launcher-test.crank.txt
index 84435f6..32266d5 100644
--- a/src/test/resources/launcher-test.crank.txt
+++ b/src/test/resources/launcher-test.crank.txt
@@ -69,8 +69,13 @@ config empty.config.should.work FORMAT:felix.config
# Test an extension command provided by our test-services bundle
test.system.property the.test.system.property was set by test-services bundle
-# Add the JUnit core via the Sling installer and our sling.extensions
+# Prepare additional resources for the Sling installer
sling.installer.resource mvn:org.apache.sling/org.apache.sling.junit.core/1.0.8
+sling.installer.resource mvn:org.apache.sling/org.apache.sling.commons.mime/2.1.4
+sling.installer.resource mvn:org.apache.sling/org.apache.sling.settings/1.3.0
+
+# And register the installer resources
+sling.installer.register crankstart
# Informative log
log felix http service should come up at http://localhost:${http.port}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 02/31: Use more
flexible command pattern
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit c8f35d32605c2d001d503f07c499cbd0ff03a0c9
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Apr 22 12:40:50 2014 +0000
Use more flexible command pattern
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1589114 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 14 ++-
.../sling/crankstart/CrankstartFileProcessor.java | 140 ---------------------
.../launcher/CrankstartFileProcessor.java | 81 ++++++++++++
.../sling/crankstart/{ => launcher}/Main.java | 2 +-
.../launcher/commands/InstallBundle.java | 52 ++++++++
.../{Main.java => launcher/commands/Log.java} | 42 +++----
.../commands/SetOsgiFrameworkProperty.java | 47 +++++++
.../crankstart/launcher/commands/StartBundles.java | 48 +++++++
.../launcher/commands/StartFramework.java | 43 +++++++
.../{Main.java => launcher/commands/U.java} | 29 +----
10 files changed, 307 insertions(+), 191 deletions(-)
diff --git a/pom.xml b/pom.xml
index 72a30d4..54e8c79 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,7 +15,7 @@
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
- <name>Apache Sling Crankstart Module</name>
+ <name>Apache Sling Crankstart Launcher</name>
<inceptionYear>2014</inceptionYear>
<description>
@@ -34,7 +34,7 @@
<configuration>
<archive>
<manifest>
- <mainClass>org.apache.sling.crankstart.Main</mainClass>
+ <mainClass>org.apache.sling.crankstart.launcher.Main</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
@@ -50,7 +50,7 @@
<goal>unpack-dependencies</goal>
</goals>
<configuration>
- <includeGroupIds>org.osgi,org.apache.felix,org.slf4j,javax.servlet,org.ops4j.pax.url</includeGroupIds>
+ <includeGroupIds>org.osgi,org.apache.felix,org.slf4j,javax.servlet,org.ops4j.pax.url,org.apache.sling</includeGroupIds>
<excludeTransitive>false</excludeTransitive>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<overWriteReleases>false</overWriteReleases>
@@ -89,11 +89,19 @@
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
<version>4.2.0</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<version>4.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.crankstart.api</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
diff --git a/src/main/java/org/apache/sling/crankstart/CrankstartFileProcessor.java b/src/main/java/org/apache/sling/crankstart/CrankstartFileProcessor.java
deleted file mode 100644
index 424064b..0000000
--- a/src/main/java/org/apache/sling/crankstart/CrankstartFileProcessor.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sling.crankstart;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.launch.Framework;
-import org.osgi.framework.launch.FrameworkFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** Process a crankstart file */
-public class CrankstartFileProcessor {
- public static final String I_BUNDLE = "bundle ";
- public static final String I_START_ALL_BUNDLES = "start.all.bundles";
- public static final String I_LOG = "log";
- public static final String I_START_FRAMEWORK = "start.framework";
- public static final String I_OSGI_PROPERTY = "osgi.property";
-
- private Framework framework;
- private final List<Bundle> bundles = new LinkedList<Bundle>();
- private final Logger log = LoggerFactory.getLogger(getClass());
- private final Map<String, String> osgiProperties = new HashMap<String, String>();
-
- public CrankstartFileProcessor() {
- System.setProperty( "java.protocol.handler.pkgs", "org.ops4j.pax.url" );
- }
-
- public void process(Reader input) throws IOException, BundleException {
- final BufferedReader r = new BufferedReader(input);
- String line = null;
- while((line = r.readLine()) != null) {
- processLine(line);
- }
- }
-
- private String removePrefix(String line, String prefix) {
- return line.substring(prefix.length()).trim();
- }
-
- private void processLine(String line) throws IOException, BundleException {
- line = line.trim();
- if(line.length() == 0 || line.startsWith("#")) {
- // ignore comments and blank lines
- } else if(line.startsWith(I_BUNDLE)) {
- bundle(removePrefix(line, I_BUNDLE));
- } else if(line.startsWith(I_START_ALL_BUNDLES)) {
- startAllBundles();
- } else if(line.startsWith(I_LOG)) {
- log.info(removePrefix(line, I_LOG));
- } else if(line.startsWith(I_START_FRAMEWORK)) {
- startFramework();
- } else if(line.startsWith(I_OSGI_PROPERTY)) {
- osgiProperty(removePrefix(line, I_OSGI_PROPERTY));
- } else {
- log.warn("Invalid command line: [{}]", line);
- }
- }
-
- private void osgiProperty(String line) {
- final String [] parts = line.split(" ");
- if(parts.length != 2) {
- log.warn("Invalid OSGi property [{}]", line);
- return;
- }
- final String key = parts[0].trim();
- final String value = parts[1].trim();
- log.info("Setting OSGI property {}={}", key, value);
- osgiProperties.put(key, value);
- }
-
- private void startFramework() throws BundleException {
- if(framework != null) {
- throw new IllegalStateException("OSGi framework already created");
- }
-
- // TODO get framework as a Maven artifact?
- FrameworkFactory frameworkFactory = java.util.ServiceLoader.load(FrameworkFactory.class).iterator().next();
- framework = frameworkFactory.newFramework(osgiProperties);
- framework.start();
-
- log.info("OSGi framework started");
- }
-
- private void bundle(String line) throws IOException, BundleException {
- final URL url = new URL( "mvn:" + line);
- final BundleContext ctx = framework.getBundleContext();
- final String ref = "crankstart://" + line;
- final InputStream bundleStream = url.openStream();
- try {
- bundles.add(ctx.installBundle(ref, url.openStream()));
- log.info("bundle installed: {}", ref);
- } finally {
- bundleStream.close();
- }
- }
-
- public void waitForExit() throws InterruptedException {
- log.info("Waiting for OSGi framework to exit...");
- framework.waitForStop(0);
- }
-
- private void startAllBundles() throws BundleException {
- for (Bundle bundle : bundles) {
- log.info("Starting bundle {}", bundle.getSymbolicName());
- bundle.start();
- }
-
- // TODO check that all bundles have started?
- // or use a crankstart instruction for that?
-
- log.info("{} bundles installed", bundles.size());
- }
-
-}
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/CrankstartFileProcessor.java b/src/main/java/org/apache/sling/crankstart/launcher/CrankstartFileProcessor.java
new file mode 100644
index 0000000..c3e6794
--- /dev/null
+++ b/src/main/java/org/apache/sling/crankstart/launcher/CrankstartFileProcessor.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.crankstart.launcher;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.sling.crankstart.api.CrankstartCommand;
+import org.apache.sling.crankstart.api.CrankstartContext;
+import org.apache.sling.crankstart.launcher.commands.InstallBundle;
+import org.apache.sling.crankstart.launcher.commands.Log;
+import org.apache.sling.crankstart.launcher.commands.SetOsgiFrameworkProperty;
+import org.apache.sling.crankstart.launcher.commands.StartBundles;
+import org.apache.sling.crankstart.launcher.commands.StartFramework;
+import org.osgi.framework.BundleException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Process a crankstart file */
+public class CrankstartFileProcessor {
+ private final CrankstartContext crankstartContext = new CrankstartContext();
+ private final Logger log = LoggerFactory.getLogger(getClass());
+ private List<CrankstartCommand> commands = new ArrayList<CrankstartCommand>();
+
+ public CrankstartFileProcessor() {
+ System.setProperty( "java.protocol.handler.pkgs", "org.ops4j.pax.url" );
+
+ commands.add(new InstallBundle());
+ commands.add(new Log());
+ commands.add(new SetOsgiFrameworkProperty());
+ commands.add(new StartBundles());
+ commands.add(new StartFramework());
+ }
+
+ public void process(Reader input) throws IOException, BundleException {
+ final BufferedReader r = new BufferedReader(input);
+ String line = null;
+ while((line = r.readLine()) != null) {
+ if(line.length() == 0 || line.startsWith("#")) {
+ // ignore comments and blank lines
+ } else {
+ for(CrankstartCommand c : commands) {
+ if(c.appliesTo(line)) {
+ try {
+ c.execute(crankstartContext, line);
+ } catch(Exception e) {
+ log.warn("Command execution failed", e);
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ public void waitForExit() throws InterruptedException {
+ if(crankstartContext.getOsgiFramework() == null) {
+ throw new IllegalStateException("OSGi framework not started");
+ }
+ log.info("Waiting for OSGi framework to exit...");
+ crankstartContext.getOsgiFramework().waitForStop(0);
+ log.info("OSGi framework exited");
+ }
+}
diff --git a/src/main/java/org/apache/sling/crankstart/Main.java b/src/main/java/org/apache/sling/crankstart/launcher/Main.java
similarity index 97%
copy from src/main/java/org/apache/sling/crankstart/Main.java
copy to src/main/java/org/apache/sling/crankstart/launcher/Main.java
index 04c4a90..e858143 100644
--- a/src/main/java/org/apache/sling/crankstart/Main.java
+++ b/src/main/java/org/apache/sling/crankstart/launcher/Main.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.crankstart;
+package org.apache.sling.crankstart.launcher;
import java.io.File;
import java.io.FileReader;
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/commands/InstallBundle.java b/src/main/java/org/apache/sling/crankstart/launcher/commands/InstallBundle.java
new file mode 100644
index 0000000..1df274c
--- /dev/null
+++ b/src/main/java/org/apache/sling/crankstart/launcher/commands/InstallBundle.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.crankstart.launcher.commands;
+
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.sling.crankstart.api.CrankstartCommand;
+import org.apache.sling.crankstart.api.CrankstartContext;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** CrankstartCommand that installs a bundle */
+public class InstallBundle implements CrankstartCommand {
+ public static final String I_BUNDLE = "bundle ";
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ @Override
+ public boolean appliesTo(String commandLine) {
+ return commandLine.startsWith(I_BUNDLE);
+ }
+
+ @Override
+ public void execute(CrankstartContext crankstartContext, String commandLine) throws Exception {
+ final String bundleRef = U.removePrefix(I_BUNDLE, commandLine);
+ final URL url = new URL( "mvn:" + bundleRef);
+ final BundleContext ctx = crankstartContext.getOsgiFramework().getBundleContext();
+ final String ref = "crankstart://" + bundleRef;
+ final InputStream bundleStream = url.openStream();
+ try {
+ ctx.installBundle(ref, url.openStream());
+ log.info("bundle installed: {}", ref);
+ } finally {
+ bundleStream.close();
+ }
+ }
+}
diff --git a/src/main/java/org/apache/sling/crankstart/Main.java b/src/main/java/org/apache/sling/crankstart/launcher/commands/Log.java
similarity index 50%
copy from src/main/java/org/apache/sling/crankstart/Main.java
copy to src/main/java/org/apache/sling/crankstart/launcher/commands/Log.java
index 04c4a90..569c83d 100644
--- a/src/main/java/org/apache/sling/crankstart/Main.java
+++ b/src/main/java/org/apache/sling/crankstart/launcher/commands/Log.java
@@ -14,29 +14,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.crankstart;
+package org.apache.sling.crankstart.launcher.commands;
-import java.io.File;
-import java.io.FileReader;
-import java.io.Reader;
+import org.apache.sling.crankstart.api.CrankstartCommand;
+import org.apache.sling.crankstart.api.CrankstartContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-/** Execute a crankstart file */
-public class Main {
- public static void main(String [] args) throws Exception {
- String crankFile = "default.crank.txt";
- if(args.length < 1) {
- System.err.println("Using default crank file " + crankFile);
- System.err.println("To use a different one, provide its name as a jar file argument");
- } else {
- crankFile = args[0];
- }
- final Reader r = new FileReader(new File(crankFile));
- try {
- final CrankstartFileProcessor p = new CrankstartFileProcessor();
- p.process(r);
- p.waitForExit();
- } finally {
- r.close();
- }
+/** CrankstartCommand that logs a message */
+public class Log implements CrankstartCommand {
+ public static final String I_LOG = "log";
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ @Override
+ public boolean appliesTo(String commandLine) {
+ return commandLine.startsWith(I_LOG);
}
-}
\ No newline at end of file
+
+ @Override
+ public void execute(CrankstartContext crankstartContext, String commandLine) throws Exception {
+ log.info(U.removePrefix(I_LOG, commandLine));
+ }
+}
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/commands/SetOsgiFrameworkProperty.java b/src/main/java/org/apache/sling/crankstart/launcher/commands/SetOsgiFrameworkProperty.java
new file mode 100644
index 0000000..4661430
--- /dev/null
+++ b/src/main/java/org/apache/sling/crankstart/launcher/commands/SetOsgiFrameworkProperty.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.crankstart.launcher.commands;
+
+import org.apache.sling.crankstart.api.CrankstartCommand;
+import org.apache.sling.crankstart.api.CrankstartContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** CrankstartCommand that logs a message */
+public class SetOsgiFrameworkProperty implements CrankstartCommand {
+ public static final String I_OSGI_PROPERTY = "osgi.property";
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ @Override
+ public boolean appliesTo(String commandLine) {
+ return commandLine.startsWith(I_OSGI_PROPERTY);
+ }
+
+ @Override
+ public void execute(CrankstartContext crankstartContext, String commandLine) throws Exception {
+ final String args = U.removePrefix(I_OSGI_PROPERTY, commandLine);
+ final String [] parts = args.split(" ");
+ if(parts.length != 2) {
+ log.warn("Invalid OSGi property statement, ignored: [{}]", commandLine);
+ return;
+ }
+ final String key = parts[0].trim();
+ final String value = parts[1].trim();
+ log.info("Setting OSGI property {}={}", key, value);
+ crankstartContext.setOsgiFrameworkProperty(key, value);
+ }
+}
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/commands/StartBundles.java b/src/main/java/org/apache/sling/crankstart/launcher/commands/StartBundles.java
new file mode 100644
index 0000000..bcd0eda
--- /dev/null
+++ b/src/main/java/org/apache/sling/crankstart/launcher/commands/StartBundles.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.crankstart.launcher.commands;
+
+import org.apache.sling.crankstart.api.CrankstartCommand;
+import org.apache.sling.crankstart.api.CrankstartContext;
+import org.osgi.framework.Bundle;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** CrankstartCommand that logs a message */
+public class StartBundles implements CrankstartCommand {
+ public static final String I_START_ALL_BUNDLES = "start.all.bundles";
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ @Override
+ public boolean appliesTo(String commandLine) {
+ return commandLine.startsWith(I_START_ALL_BUNDLES);
+ }
+
+ @Override
+ public void execute(CrankstartContext crankstartContext, String commandLine) throws Exception {
+ int count = 0;
+ for (Bundle bundle : crankstartContext.getOsgiFramework().getBundleContext().getBundles()) {
+ log.info("Starting bundle {}", bundle.getSymbolicName());
+ bundle.start();
+ count++;
+ }
+
+ // TODO check that all bundles have started?
+ // or use a crankstart instruction for that?
+ log.info("{} bundles processed", count);
+ }
+}
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/commands/StartFramework.java b/src/main/java/org/apache/sling/crankstart/launcher/commands/StartFramework.java
new file mode 100644
index 0000000..205d1c9
--- /dev/null
+++ b/src/main/java/org/apache/sling/crankstart/launcher/commands/StartFramework.java
@@ -0,0 +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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.crankstart.launcher.commands;
+
+import org.apache.sling.crankstart.api.CrankstartCommand;
+import org.apache.sling.crankstart.api.CrankstartContext;
+import org.osgi.framework.launch.FrameworkFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** CrankstartCommand that logs a message */
+public class StartFramework implements CrankstartCommand {
+ public static final String I_START_FRAMEWORK = "start.framework";
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ @Override
+ public boolean appliesTo(String commandLine) {
+ return commandLine.startsWith(I_START_FRAMEWORK);
+ }
+
+ @Override
+ public void execute(CrankstartContext crankstartContext, String commandLine) throws Exception {
+ // TODO get framework as a Maven artifact?
+ FrameworkFactory frameworkFactory = java.util.ServiceLoader.load(FrameworkFactory.class).iterator().next();
+ crankstartContext.setOsgiFramework(frameworkFactory.newFramework(crankstartContext.getOsgiFrameworkProperties()));
+ crankstartContext.getOsgiFramework().start();
+ log.info("OSGi framework started");
+ }
+}
diff --git a/src/main/java/org/apache/sling/crankstart/Main.java b/src/main/java/org/apache/sling/crankstart/launcher/commands/U.java
similarity index 50%
rename from src/main/java/org/apache/sling/crankstart/Main.java
rename to src/main/java/org/apache/sling/crankstart/launcher/commands/U.java
index 04c4a90..d736771 100644
--- a/src/main/java/org/apache/sling/crankstart/Main.java
+++ b/src/main/java/org/apache/sling/crankstart/launcher/commands/U.java
@@ -14,29 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.crankstart;
+package org.apache.sling.crankstart.launcher.commands;
-import java.io.File;
-import java.io.FileReader;
-import java.io.Reader;
-
-/** Execute a crankstart file */
-public class Main {
- public static void main(String [] args) throws Exception {
- String crankFile = "default.crank.txt";
- if(args.length < 1) {
- System.err.println("Using default crank file " + crankFile);
- System.err.println("To use a different one, provide its name as a jar file argument");
- } else {
- crankFile = args[0];
- }
- final Reader r = new FileReader(new File(crankFile));
- try {
- final CrankstartFileProcessor p = new CrankstartFileProcessor();
- p.process(r);
- p.waitForExit();
- } finally {
- r.close();
- }
+class U {
+ static String removePrefix(String prefix, String line) {
+ return line.substring(prefix.length()).trim();
}
-}
\ No newline at end of file
+}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 15/31: Add extension
command support,
with test in SystemPropertyCommand and launcher-test.crank.txt
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 2976ec975df2fa82be835ea339114b2075fc19f3
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri May 16 14:50:49 2014 +0000
Add extension command support, with test in SystemPropertyCommand and launcher-test.crank.txt
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1595220 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 12 +++++++++---
.../crankstart/launcher/CrankstartBootstrapTest.java | 15 +++++++++++++++
src/test/resources/launcher-test.crank.txt | 12 +++++++++++-
3 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index e120a5b..c37eb97 100644
--- a/pom.xml
+++ b/pom.xml
@@ -93,14 +93,20 @@
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.crankstart.api.fragment</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.crankstart.core</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.crankstart.test.services</artifactId>
- <version>0.0.1-SNAPSHOT</version>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.crankstart.test.services</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
diff --git a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
index ff12860..0de1a73 100644
--- a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
+++ b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
@@ -2,6 +2,7 @@ package org.apache.sling.crankstart.launcher;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import java.io.File;
@@ -31,6 +32,7 @@ public class CrankstartBootstrapTest {
private static Thread crankstartThread;
private static String baseUrl = "http://localhost:" + port;
public static final String TEST_RESOURCE = "/launcher-test.crank.txt";
+ public static final String TEST_SYSTEM_PROPERTY = "the.test.system.property";
@Rule
public final RetryRule retryRule = new RetryRule();
@@ -54,6 +56,11 @@ public class CrankstartBootstrapTest {
}
@BeforeClass
+ public static void testExtensionPropertyBeforeTests() {
+ assertNull(TEST_SYSTEM_PROPERTY + " should not be set before tests", System.getProperty(TEST_SYSTEM_PROPERTY));
+ }
+
+ @BeforeClass
public static void setup() {
final GetMethod get = new GetMethod(baseUrl);
System.setProperty("http.port", String.valueOf(port));
@@ -74,6 +81,7 @@ public class CrankstartBootstrapTest {
try {
new CrankstartBootstrap(input).start();
} catch(Exception e) {
+ e.printStackTrace();
fail("CrankstartBootstrap exception:" + e);
} finally {
try {
@@ -120,6 +128,13 @@ public class CrankstartBootstrapTest {
}
}
+ @Test
+ public void testExtensionCommand() {
+ // The SystemPropertyCommand, provided by our test-services bundle, should have
+ // processed the test.system.property instruction in our launcher file
+ assertEquals("was set by test-services bundle", System.getProperty(TEST_SYSTEM_PROPERTY));
+ }
+
private static String getOsgiStoragePath() {
final File tmpRoot = new File(System.getProperty("java.io.tmpdir"));
final Random random = new Random();
diff --git a/src/test/resources/launcher-test.crank.txt b/src/test/resources/launcher-test.crank.txt
index 8af6a32..a250a44 100644
--- a/src/test/resources/launcher-test.crank.txt
+++ b/src/test/resources/launcher-test.crank.txt
@@ -25,8 +25,15 @@ bundle mvn:org.apache.felix/org.apache.felix.scr/1.8.2
bundle mvn:org.apache.felix/org.apache.felix.metatype/1.0.10
bundle mvn:org.apache.sling/org.apache.sling.commons.osgi/2.2.1-SNAPSHOT
bundle mvn:org.apache.sling/org.apache.sling.commons.log/2.1.2
-bundle mvn:org.apache.sling/org.apache.sling.crankstart.test.services/0.0.1-SNAPSHOT
bundle mvn:org.apache.felix/org.apache.felix.configadmin/1.6.0
+
+# The crankstart.api.fragment bundle makes the crankstart.api package available
+# to bundles, required for bundles to provide crankstart extension commands like
+# the test.system.property command below
+bundle mvn:org.apache.sling/org.apache.sling.crankstart.api.fragment/0.0.1-SNAPSHOT
+bundle mvn:org.apache.sling/org.apache.sling.crankstart.test.services/0.0.1-SNAPSHOT
+
+# Now start our bundles
start.all.bundles
# OSGi configs that activate our test servlets
@@ -42,5 +49,8 @@ config.factory org.apache.sling.crankstart.testservices.ConfigFactoryServlet
path=/bar/test
message=Not used
+# Test an extension command provided by our test-services bundle
+test.system.property the.test.system.property was set by test-services bundle
+
# Informative log
log felix http service should come up at http://localhost:${http.port}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 04/31: Remove obsolete
commands package
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 2e9d602e178945256af44c30d7e0200bc5925a25
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Apr 22 15:40:19 2014 +0000
Remove obsolete commands package
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1589177 13f79535-47bb-0310-9956-ffa450edef68
---
.../launcher/commands/InstallBundle.java | 52 ----------------------
.../sling/crankstart/launcher/commands/Log.java | 38 ----------------
.../commands/SetOsgiFrameworkProperty.java | 47 -------------------
.../crankstart/launcher/commands/StartBundles.java | 48 --------------------
.../launcher/commands/StartFramework.java | 43 ------------------
.../sling/crankstart/launcher/commands/U.java | 23 ----------
6 files changed, 251 deletions(-)
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/commands/InstallBundle.java b/src/main/java/org/apache/sling/crankstart/launcher/commands/InstallBundle.java
deleted file mode 100644
index 1df274c..0000000
--- a/src/main/java/org/apache/sling/crankstart/launcher/commands/InstallBundle.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sling.crankstart.launcher.commands;
-
-import java.io.InputStream;
-import java.net.URL;
-
-import org.apache.sling.crankstart.api.CrankstartCommand;
-import org.apache.sling.crankstart.api.CrankstartContext;
-import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** CrankstartCommand that installs a bundle */
-public class InstallBundle implements CrankstartCommand {
- public static final String I_BUNDLE = "bundle ";
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Override
- public boolean appliesTo(String commandLine) {
- return commandLine.startsWith(I_BUNDLE);
- }
-
- @Override
- public void execute(CrankstartContext crankstartContext, String commandLine) throws Exception {
- final String bundleRef = U.removePrefix(I_BUNDLE, commandLine);
- final URL url = new URL( "mvn:" + bundleRef);
- final BundleContext ctx = crankstartContext.getOsgiFramework().getBundleContext();
- final String ref = "crankstart://" + bundleRef;
- final InputStream bundleStream = url.openStream();
- try {
- ctx.installBundle(ref, url.openStream());
- log.info("bundle installed: {}", ref);
- } finally {
- bundleStream.close();
- }
- }
-}
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/commands/Log.java b/src/main/java/org/apache/sling/crankstart/launcher/commands/Log.java
deleted file mode 100644
index 569c83d..0000000
--- a/src/main/java/org/apache/sling/crankstart/launcher/commands/Log.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sling.crankstart.launcher.commands;
-
-import org.apache.sling.crankstart.api.CrankstartCommand;
-import org.apache.sling.crankstart.api.CrankstartContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** CrankstartCommand that logs a message */
-public class Log implements CrankstartCommand {
- public static final String I_LOG = "log";
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Override
- public boolean appliesTo(String commandLine) {
- return commandLine.startsWith(I_LOG);
- }
-
- @Override
- public void execute(CrankstartContext crankstartContext, String commandLine) throws Exception {
- log.info(U.removePrefix(I_LOG, commandLine));
- }
-}
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/commands/SetOsgiFrameworkProperty.java b/src/main/java/org/apache/sling/crankstart/launcher/commands/SetOsgiFrameworkProperty.java
deleted file mode 100644
index 4661430..0000000
--- a/src/main/java/org/apache/sling/crankstart/launcher/commands/SetOsgiFrameworkProperty.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sling.crankstart.launcher.commands;
-
-import org.apache.sling.crankstart.api.CrankstartCommand;
-import org.apache.sling.crankstart.api.CrankstartContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** CrankstartCommand that logs a message */
-public class SetOsgiFrameworkProperty implements CrankstartCommand {
- public static final String I_OSGI_PROPERTY = "osgi.property";
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Override
- public boolean appliesTo(String commandLine) {
- return commandLine.startsWith(I_OSGI_PROPERTY);
- }
-
- @Override
- public void execute(CrankstartContext crankstartContext, String commandLine) throws Exception {
- final String args = U.removePrefix(I_OSGI_PROPERTY, commandLine);
- final String [] parts = args.split(" ");
- if(parts.length != 2) {
- log.warn("Invalid OSGi property statement, ignored: [{}]", commandLine);
- return;
- }
- final String key = parts[0].trim();
- final String value = parts[1].trim();
- log.info("Setting OSGI property {}={}", key, value);
- crankstartContext.setOsgiFrameworkProperty(key, value);
- }
-}
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/commands/StartBundles.java b/src/main/java/org/apache/sling/crankstart/launcher/commands/StartBundles.java
deleted file mode 100644
index bcd0eda..0000000
--- a/src/main/java/org/apache/sling/crankstart/launcher/commands/StartBundles.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sling.crankstart.launcher.commands;
-
-import org.apache.sling.crankstart.api.CrankstartCommand;
-import org.apache.sling.crankstart.api.CrankstartContext;
-import org.osgi.framework.Bundle;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** CrankstartCommand that logs a message */
-public class StartBundles implements CrankstartCommand {
- public static final String I_START_ALL_BUNDLES = "start.all.bundles";
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Override
- public boolean appliesTo(String commandLine) {
- return commandLine.startsWith(I_START_ALL_BUNDLES);
- }
-
- @Override
- public void execute(CrankstartContext crankstartContext, String commandLine) throws Exception {
- int count = 0;
- for (Bundle bundle : crankstartContext.getOsgiFramework().getBundleContext().getBundles()) {
- log.info("Starting bundle {}", bundle.getSymbolicName());
- bundle.start();
- count++;
- }
-
- // TODO check that all bundles have started?
- // or use a crankstart instruction for that?
- log.info("{} bundles processed", count);
- }
-}
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/commands/StartFramework.java b/src/main/java/org/apache/sling/crankstart/launcher/commands/StartFramework.java
deleted file mode 100644
index 205d1c9..0000000
--- a/src/main/java/org/apache/sling/crankstart/launcher/commands/StartFramework.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sling.crankstart.launcher.commands;
-
-import org.apache.sling.crankstart.api.CrankstartCommand;
-import org.apache.sling.crankstart.api.CrankstartContext;
-import org.osgi.framework.launch.FrameworkFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** CrankstartCommand that logs a message */
-public class StartFramework implements CrankstartCommand {
- public static final String I_START_FRAMEWORK = "start.framework";
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Override
- public boolean appliesTo(String commandLine) {
- return commandLine.startsWith(I_START_FRAMEWORK);
- }
-
- @Override
- public void execute(CrankstartContext crankstartContext, String commandLine) throws Exception {
- // TODO get framework as a Maven artifact?
- FrameworkFactory frameworkFactory = java.util.ServiceLoader.load(FrameworkFactory.class).iterator().next();
- crankstartContext.setOsgiFramework(frameworkFactory.newFramework(crankstartContext.getOsgiFrameworkProperties()));
- crankstartContext.getOsgiFramework().start();
- log.info("OSGi framework started");
- }
-}
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/commands/U.java b/src/main/java/org/apache/sling/crankstart/launcher/commands/U.java
deleted file mode 100644
index d736771..0000000
--- a/src/main/java/org/apache/sling/crankstart/launcher/commands/U.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sling.crankstart.launcher.commands;
-
-class U {
- static String removePrefix(String prefix, String line) {
- return line.substring(prefix.length()).trim();
- }
-}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 07/31:
CrankstartBootstrap and test
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 201e085ce56c4255861011ae37be47ec2c0024e6
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed Apr 23 09:56:11 2014 +0000
CrankstartBootstrap and test
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1589362 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 18 ++++
.../{Main.java => CrankstartBootstrap.java} | 56 ++++++++---
.../org/apache/sling/crankstart/launcher/Main.java | 43 +--------
.../launcher/CrankstartBootstrapTest.java | 106 +++++++++++++++++++++
4 files changed, 169 insertions(+), 54 deletions(-)
diff --git a/pom.xml b/pom.xml
index a91b9f2..a61a847 100644
--- a/pom.xml
+++ b/pom.xml
@@ -121,5 +121,23 @@
<version>${pax.url.version}</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.testing</artifactId>
+ <version>2.0.17-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.1</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/Main.java b/src/main/java/org/apache/sling/crankstart/launcher/CrankstartBootstrap.java
similarity index 64%
copy from src/main/java/org/apache/sling/crankstart/launcher/Main.java
copy to src/main/java/org/apache/sling/crankstart/launcher/CrankstartBootstrap.java
index 225d859..68ccd9d 100644
--- a/src/main/java/org/apache/sling/crankstart/launcher/Main.java
+++ b/src/main/java/org/apache/sling/crankstart/launcher/CrankstartBootstrap.java
@@ -19,6 +19,7 @@ package org.apache.sling.crankstart.launcher;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
+import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.net.URL;
@@ -30,27 +31,58 @@ import java.util.concurrent.Callable;
import org.apache.sling.crankstart.api.CrankstartConstants;
/** Execute a crankstart file */
-public class Main {
+public class CrankstartBootstrap {
public static final String CLASSPATH_PREFIX = "classpath ";
+ private final String crankFile;
+ private final File tempFile;
- public static void main(String [] args) throws Exception {
- String crankFile = "default.crank.txt";
- if(args.length < 1) {
- System.err.println("Using default crank file " + crankFile);
- System.err.println("To use a different one, provide its name as a jar file argument");
- } else {
- crankFile = args[0];
+ public CrankstartBootstrap(String filename) {
+ tempFile = null;
+ crankFile = filename;
+ }
+
+ public CrankstartBootstrap(Reader r) throws IOException {
+ tempFile = File.createTempFile("CRANKSTART", "crank.txt");
+ tempFile.deleteOnExit();
+ crankFile = tempFile.getAbsolutePath();
+
+ final FileWriter w = new FileWriter(tempFile);
+ final char [] buf = new char[4096];
+ int len = 0;
+ try {
+ while( (len = r.read(buf, 0, buf.length)) > 0) {
+ w.write(buf, 0, len);
+ }
+ } finally {
+ w.flush();
+ w.close();
}
+ }
+
+ private void cleanup() {
+ if(tempFile != null) {
+ tempFile.delete();
+ }
+ }
+
+
+ public void start() throws Exception {
System.setProperty(CrankstartConstants.CRANKSTART_INPUT_FILENAME, crankFile);
System.setProperty( "java.protocol.handler.pkgs", "org.ops4j.pax.url" );
final URL [] launcherClasspath = getClasspath(crankFile);
final URLClassLoader launcherClassloader = new URLClassLoader(launcherClasspath, null);
- final String callableClass = "org.apache.sling.crankstart.core.CrankstartFileProcessor";
- @SuppressWarnings("unchecked")
- final Callable<Object> c = (Callable<Object>)launcherClassloader.loadClass(callableClass).newInstance();
- c.call();
+ try {
+ final String callableClass = "org.apache.sling.crankstart.core.CrankstartFileProcessor";
+
+ @SuppressWarnings("unchecked")
+ final Callable<Object> c = (Callable<Object>)launcherClassloader.loadClass(callableClass).newInstance();
+ c.call();
+ } finally {
+ launcherClassloader.close();
+ cleanup();
+ }
}
private static URL[] getClasspath(String filename) throws IOException {
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/Main.java b/src/main/java/org/apache/sling/crankstart/launcher/Main.java
index 225d859..8daf01f 100644
--- a/src/main/java/org/apache/sling/crankstart/launcher/Main.java
+++ b/src/main/java/org/apache/sling/crankstart/launcher/Main.java
@@ -16,19 +16,6 @@
*/
package org.apache.sling.crankstart.launcher;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Callable;
-
-import org.apache.sling.crankstart.api.CrankstartConstants;
-
/** Execute a crankstart file */
public class Main {
public static final String CLASSPATH_PREFIX = "classpath ";
@@ -41,34 +28,6 @@ public class Main {
} else {
crankFile = args[0];
}
- System.setProperty(CrankstartConstants.CRANKSTART_INPUT_FILENAME, crankFile);
- System.setProperty( "java.protocol.handler.pkgs", "org.ops4j.pax.url" );
- final URL [] launcherClasspath = getClasspath(crankFile);
-
- final URLClassLoader launcherClassloader = new URLClassLoader(launcherClasspath, null);
- final String callableClass = "org.apache.sling.crankstart.core.CrankstartFileProcessor";
-
- @SuppressWarnings("unchecked")
- final Callable<Object> c = (Callable<Object>)launcherClassloader.loadClass(callableClass).newInstance();
- c.call();
- }
-
- private static URL[] getClasspath(String filename) throws IOException {
- final List<URL> urls = new ArrayList<URL>();
- final Reader input = new FileReader(new File(filename));
- final BufferedReader r = new BufferedReader(input);
- try {
- String line = null;
- while((line = r.readLine()) != null) {
- if(line.length() == 0 || line.startsWith("#")) {
- // ignore comments and blank lines
- } else if(line.startsWith(CLASSPATH_PREFIX)){
- urls.add(new URL(line.substring(CLASSPATH_PREFIX.length()).trim()));
- }
- }
- return urls.toArray(new URL[] {});
- } finally {
- r.close();
- }
+ new CrankstartBootstrap(crankFile).start();
}
}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
new file mode 100644
index 0000000..c559290
--- /dev/null
+++ b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
@@ -0,0 +1,106 @@
+package org.apache.sling.crankstart.launcher;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Random;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.sling.commons.testing.junit.Retry;
+import org.apache.sling.commons.testing.junit.RetryRule;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+
+/** Verify that we can start the Felix HTTP service
+ * with a {@link CrankstartBootstrap}.
+ */
+public class CrankstartBootstrapTest {
+
+ private static final int port = Integer.valueOf(System.getProperty("test.http.port", "12345"));
+ private static final HttpClient client = new HttpClient();
+ private static Thread crankstartThread;
+ private static URL rootUrl = null;
+
+ static {
+ try {
+ rootUrl = new URL("http://localhost:" + port + "/");
+ } catch(MalformedURLException mfe) {
+ fail(mfe.toString());
+ }
+ }
+
+ @Rule
+ public final RetryRule retryRule = new RetryRule();
+
+ private final static String CRANKSTART =
+ "classpath mvn:org.apache.felix/org.apache.felix.framework/4.4.0\n"
+ + "classpath mvn:org.slf4j/slf4j-api/1.6.2\n"
+ + "classpath mvn:org.ops4j.pax.url/pax-url-aether/1.6.0\n"
+ + "classpath mvn:org.ops4j.pax.url/pax-url-commons/1.6.0\n"
+ + "classpath mvn:org.apache.sling/org.apache.sling.crankstart.core/0.0.1-SNAPSHOT\n"
+ + "classpath mvn:org.apache.sling/org.apache.sling.crankstart.api/0.0.1-SNAPSHOT\n"
+ + "osgi.property org.osgi.service.http.port " + port + "\n"
+ + "osgi.property org.osgi.framework.storage " + getOsgiStoragePath() + "\n"
+ + "start.framework\n"
+ + "bundle mvn:org.apache.felix/org.apache.felix.http.jetty/2.2.0\n"
+ + "bundle mvn:org.apache.sling/org.apache.sling.commons.log/2.1.2\n"
+ + "start.all.bundles\n"
+ + "log felix http service should come up at http://localhost:" + port + "\n"
+ ;
+
+ @BeforeClass
+ public static void setup() {
+ final GetMethod get = new GetMethod(rootUrl.toExternalForm());
+
+ try {
+ client.executeMethod(get);
+ fail("Expecting connection to " + port + " to fail before starting HTTP service");
+ } catch(IOException expected) {
+ }
+
+ crankstartThread = new Thread() {
+ public void run() {
+ try {
+ new CrankstartBootstrap(new StringReader(CRANKSTART)).start();
+ } catch(Exception e) {
+ fail("CrankstartBootstrap exception:" + e);
+ }
+ }
+ };
+ crankstartThread.setDaemon(true);
+ crankstartThread.start();
+ }
+
+ @AfterClass
+ public static void cleanup() throws InterruptedException {
+ crankstartThread.interrupt();
+ crankstartThread.join();
+ }
+
+ @Test
+ @Retry(timeoutMsec=10000, intervalMsec=250)
+ public void testHttpResponse() throws Exception {
+ final GetMethod get = new GetMethod(rootUrl.toExternalForm());
+ client.executeMethod(get);
+ assertEquals("Expecting 404 at " + get.getURI(), 404, get.getStatusCode());
+ }
+
+ private static String getOsgiStoragePath() {
+ final File tmpRoot = new File(System.getProperty("java.io.tmpdir"));
+ final Random random = new Random();
+ final File tmpFolder = new File(tmpRoot, System.currentTimeMillis() + "_" + random.nextInt());
+ if(!tmpFolder.mkdir()) {
+ fail("Failed to create " + tmpFolder.getAbsolutePath());
+ }
+ tmpFolder.deleteOnExit();
+ return tmpFolder.getAbsolutePath();
+ }
+}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 17/31: Fix build order
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit b6d911fc2a0b5a2ded69d5c1dc1100aeb338f84f
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Jun 2 17:08:52 2014 +0000
Fix build order
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1599270 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/pom.xml b/pom.xml
index c37eb97..6617f3f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -109,6 +109,12 @@
<version>0.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.crankstart.sling.extensions</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 20/31: Use AutoClose
stream
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit f5c47c48c3c04d1aca9b033933e69f08e3fa718f
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Jun 26 16:38:21 2014 +0000
Use AutoClose stream
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1605846 13f79535-47bb-0310-9956-ffa450edef68
---
src/test/resources/launcher-test.crank.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/test/resources/launcher-test.crank.txt b/src/test/resources/launcher-test.crank.txt
index f302721..84435f6 100644
--- a/src/test/resources/launcher-test.crank.txt
+++ b/src/test/resources/launcher-test.crank.txt
@@ -40,6 +40,7 @@ bundle mvn:org.apache.sling/org.apache.sling.installer.core/3.5.0
bundle mvn:org.apache.sling/org.apache.sling.commons.json/2.0.6
bundle mvn:org.apache.sling/org.apache.sling.jcr.jcr-wrapper/2.0.0
bundle mvn:org.apache.sling/org.apache.sling.crankstart.sling.extensions/0.0.1-SNAPSHOT
+bundle mvn:commons-io/commons-io/2.4
# Now start our bundles
start.all.bundles
@@ -72,4 +73,4 @@ test.system.property the.test.system.property was set by test-services bundle
sling.installer.resource mvn:org.apache.sling/org.apache.sling.junit.core/1.0.8
# Informative log
-log felix http service should come up at http://localhost:${http.port}
\ No newline at end of file
+log felix http service should come up at http://localhost:${http.port}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 03/31: Get OSGi
dependencies from Maven repository as well
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 3ae1a28837db5cc834682f7058e3bdc13e07461e
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Apr 22 15:38:20 2014 +0000
Get OSGi dependencies from Maven repository as well
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1589176 13f79535-47bb-0310-9956-ffa450edef68
---
default.crank.txt | 31 ++++++---
pom.xml | 25 ++-----
.../launcher/CrankstartFileProcessor.java | 81 ----------------------
.../org/apache/sling/crankstart/launcher/Main.java | 40 +++++++++--
.../org/apache/sling/crankstart/MavenUrlTest.java | 35 ----------
5 files changed, 64 insertions(+), 148 deletions(-)
diff --git a/default.crank.txt b/default.crank.txt
index 3d581f0..7116683 100644
--- a/default.crank.txt
+++ b/default.crank.txt
@@ -1,21 +1,32 @@
# Minimal webconsole example for the Sling crankstart launcher
-# OSGi framework properties
+# Set bootstrap classpath, mvn: protocol can be used
+classpath mvn:org.apache.felix/org.apache.felix.framework/4.4.0
+classpath mvn:org.osgi/org.osgi.compendium/4.2.0
+classpath mvn:org.slf4j/slf4j-api/1.6.2
+classpath mvn:org.slf4j/slf4j-simple/1.6.2
+classpath mvn:org.ops4j.pax.url/pax-url-aether/1.6.0
+classpath mvn:org.ops4j.pax.url/pax-url-commons/1.6.0
+
+# Except the bootstrap launcher, crankstart jars are also provided via classpath
+classpath mvn:org.apache.sling/org.apache.sling.crankstart.core/0.0.1-SNAPSHOT
+classpath mvn:org.apache.sling/org.apache.sling.crankstart.api/0.0.1-SNAPSHOT
+
+# Set OSGi framework properties
osgi.property org.osgi.service.http.port 1234
# Once OSGi properties are set, start the framework
start.framework
# Install a minimal set of bundles for now, just to
-# demonstrate that we can start the webconsole
-# Crankstart gets bundles from a Maven repository, which
-# is not configurable for now.
-bundle org.apache.felix/org.apache.felix.configadmin/1.2.8
-bundle org.apache.felix/org.apache.felix.http.jetty/2.2.0
-bundle org.apache.felix/org.apache.felix.metatype/1.0.4
-bundle org.apache.felix/org.apache.felix.scr/1.6.0
-bundle org.apache.felix/org.apache.felix.webconsole/3.1.6
-bundle org.apache.sling/org.apache.sling.commons.log/2.1.2
+# demonstrate that we can start the webconsole.
+# mvn: protocol can be used.
+bundle mvn:org.apache.felix/org.apache.felix.configadmin/1.2.8
+bundle mvn:org.apache.felix/org.apache.felix.http.jetty/2.2.0
+bundle mvn:org.apache.felix/org.apache.felix.metatype/1.0.4
+bundle mvn:org.apache.felix/org.apache.felix.scr/1.6.0
+bundle mvn:org.apache.felix/org.apache.felix.webconsole/3.1.6
+bundle mvn:org.apache.sling/org.apache.sling.commons.log/2.1.2
# Start all bundles and log a friendly message
start.all.bundles
diff --git a/pom.xml b/pom.xml
index 54e8c79..a91b9f2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,7 +50,7 @@
<goal>unpack-dependencies</goal>
</goals>
<configuration>
- <includeGroupIds>org.osgi,org.apache.felix,org.slf4j,javax.servlet,org.ops4j.pax.url,org.apache.sling</includeGroupIds>
+ <includeGroupIds>org.slf4j,org.ops4j.pax.url</includeGroupIds>
<excludeTransitive>false</excludeTransitive>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<overWriteReleases>false</overWriteReleases>
@@ -85,21 +85,15 @@
</build>
<dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.2.0</version>
- <scope>provided</scope>
- </dependency>
<dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.framework</artifactId>
- <version>4.0.0</version>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.crankstart.api</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.crankstart.api</artifactId>
+ <artifactId>org.apache.sling.crankstart.core</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
@@ -107,12 +101,13 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.2</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.2</version>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.url</groupId>
@@ -126,11 +121,5 @@
<version>${pax.url.version}</version>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/CrankstartFileProcessor.java b/src/main/java/org/apache/sling/crankstart/launcher/CrankstartFileProcessor.java
deleted file mode 100644
index c3e6794..0000000
--- a/src/main/java/org/apache/sling/crankstart/launcher/CrankstartFileProcessor.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sling.crankstart.launcher;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.sling.crankstart.api.CrankstartCommand;
-import org.apache.sling.crankstart.api.CrankstartContext;
-import org.apache.sling.crankstart.launcher.commands.InstallBundle;
-import org.apache.sling.crankstart.launcher.commands.Log;
-import org.apache.sling.crankstart.launcher.commands.SetOsgiFrameworkProperty;
-import org.apache.sling.crankstart.launcher.commands.StartBundles;
-import org.apache.sling.crankstart.launcher.commands.StartFramework;
-import org.osgi.framework.BundleException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** Process a crankstart file */
-public class CrankstartFileProcessor {
- private final CrankstartContext crankstartContext = new CrankstartContext();
- private final Logger log = LoggerFactory.getLogger(getClass());
- private List<CrankstartCommand> commands = new ArrayList<CrankstartCommand>();
-
- public CrankstartFileProcessor() {
- System.setProperty( "java.protocol.handler.pkgs", "org.ops4j.pax.url" );
-
- commands.add(new InstallBundle());
- commands.add(new Log());
- commands.add(new SetOsgiFrameworkProperty());
- commands.add(new StartBundles());
- commands.add(new StartFramework());
- }
-
- public void process(Reader input) throws IOException, BundleException {
- final BufferedReader r = new BufferedReader(input);
- String line = null;
- while((line = r.readLine()) != null) {
- if(line.length() == 0 || line.startsWith("#")) {
- // ignore comments and blank lines
- } else {
- for(CrankstartCommand c : commands) {
- if(c.appliesTo(line)) {
- try {
- c.execute(crankstartContext, line);
- } catch(Exception e) {
- log.warn("Command execution failed", e);
- }
- break;
- }
- }
- }
- }
- }
-
- public void waitForExit() throws InterruptedException {
- if(crankstartContext.getOsgiFramework() == null) {
- throw new IllegalStateException("OSGi framework not started");
- }
- log.info("Waiting for OSGi framework to exit...");
- crankstartContext.getOsgiFramework().waitForStop(0);
- log.info("OSGi framework exited");
- }
-}
diff --git a/src/main/java/org/apache/sling/crankstart/launcher/Main.java b/src/main/java/org/apache/sling/crankstart/launcher/Main.java
index e858143..225d859 100644
--- a/src/main/java/org/apache/sling/crankstart/launcher/Main.java
+++ b/src/main/java/org/apache/sling/crankstart/launcher/Main.java
@@ -16,12 +16,23 @@
*/
package org.apache.sling.crankstart.launcher;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
+import java.io.IOException;
import java.io.Reader;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+
+import org.apache.sling.crankstart.api.CrankstartConstants;
/** Execute a crankstart file */
public class Main {
+ public static final String CLASSPATH_PREFIX = "classpath ";
+
public static void main(String [] args) throws Exception {
String crankFile = "default.crank.txt";
if(args.length < 1) {
@@ -30,11 +41,32 @@ public class Main {
} else {
crankFile = args[0];
}
- final Reader r = new FileReader(new File(crankFile));
+ System.setProperty(CrankstartConstants.CRANKSTART_INPUT_FILENAME, crankFile);
+ System.setProperty( "java.protocol.handler.pkgs", "org.ops4j.pax.url" );
+ final URL [] launcherClasspath = getClasspath(crankFile);
+
+ final URLClassLoader launcherClassloader = new URLClassLoader(launcherClasspath, null);
+ final String callableClass = "org.apache.sling.crankstart.core.CrankstartFileProcessor";
+
+ @SuppressWarnings("unchecked")
+ final Callable<Object> c = (Callable<Object>)launcherClassloader.loadClass(callableClass).newInstance();
+ c.call();
+ }
+
+ private static URL[] getClasspath(String filename) throws IOException {
+ final List<URL> urls = new ArrayList<URL>();
+ final Reader input = new FileReader(new File(filename));
+ final BufferedReader r = new BufferedReader(input);
try {
- final CrankstartFileProcessor p = new CrankstartFileProcessor();
- p.process(r);
- p.waitForExit();
+ String line = null;
+ while((line = r.readLine()) != null) {
+ if(line.length() == 0 || line.startsWith("#")) {
+ // ignore comments and blank lines
+ } else if(line.startsWith(CLASSPATH_PREFIX)){
+ urls.add(new URL(line.substring(CLASSPATH_PREFIX.length()).trim()));
+ }
+ }
+ return urls.toArray(new URL[] {});
} finally {
r.close();
}
diff --git a/src/test/java/org/apache/sling/crankstart/MavenUrlTest.java b/src/test/java/org/apache/sling/crankstart/MavenUrlTest.java
deleted file mode 100644
index ebd66bb..0000000
--- a/src/test/java/org/apache/sling/crankstart/MavenUrlTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sling.crankstart;
-
-import java.io.IOException;
-import java.net.URL;
-
-import org.junit.Test;
-
-public class MavenUrlTest {
- @Test
- public void testResolveArtifactl() throws IOException {
- System.setProperty( "java.protocol.handler.pkgs", "org.ops4j.pax.url" );
-
- //TODO does pax url use the default local repo?
- //System.setProperty( "org.ops4j.pax.url.mvn.localRepository", localRepoPath );
-
- final URL url = new URL( "mvn:commons-lang/commons-lang/1.0" );
- url.openStream().close();
- }
-}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 30/31:
[maven-release-plugin] prepare release
org.apache.sling.crankstart.launcher-1.0.0
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 0343af732cf897909e171c51cee122f41532e8ae
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Sep 1 15:02:15 2014 +0000
[maven-release-plugin] prepare release org.apache.sling.crankstart.launcher-1.0.0
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1621817 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index 70e7b9e..b3f6b17 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,7 +13,7 @@
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.crankstart.launcher</artifactId>
<packaging>jar</packaging>
- <version>0.0.1-SNAPSHOT</version>
+ <version>1.0.0</version>
<name>Apache Sling Crankstart Launcher</name>
<inceptionYear>2014</inceptionYear>
@@ -23,9 +23,9 @@
</description>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher</developerConnection>
- <url>http://sling.apache.org</url>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.crankstart.launcher-1.0.0</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.crankstart.launcher-1.0.0</developerConnection>
+ <url>http://sling.apache.org/tags/org.apache.sling.crankstart.launcher-1.0.0</url>
</scm>
<properties>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-crankstart-launcher] 24/31: Remove
unnecessary snapshot
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit 3d930df8b6027e2bea15cee8c5c8687089addef0
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Jul 28 10:06:28 2014 +0000
Remove unnecessary snapshot
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1613945 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 137fcd3..e1136e1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -148,7 +148,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.commons.testing</artifactId>
- <version>2.0.17-SNAPSHOT</version>
+ <version>2.0.16</version>
<scope>test</scope>
</dependency>
<dependency>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.