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/10/18 23:23:23 UTC

[sling-org-apache-sling-crankstart-test-services] 13/16: SLING-4728 - keep old Crankstart around, just in case

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-test-services.git

commit 8d9189f43170006cb8b16a9ef1516bbe85b2ae8a
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Jun 11 13:02:49 2015 +0000

    SLING-4728 - keep old Crankstart around, just in case
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1684873 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 79 ------------------
 .../crankstart/testservices/ConfigDumpServlet.java | 95 ----------------------
 .../testservices/ConfigFactoryServlet.java         | 61 --------------
 .../testservices/SingleConfigServlet.java          | 60 --------------
 .../testservices/SystemPropertyCommand.java        | 59 --------------
 .../sling/crankstart/testservices/TestServlet.java | 65 ---------------
 6 files changed, 419 deletions(-)

diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 3579169..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,79 +0,0 @@
-<?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.sling</groupId>
-        <artifactId>sling</artifactId>
-        <version>22</version>
-        <relativePath />
-    </parent>
-    
-    <groupId>org.apache.sling</groupId>
-    <artifactId>org.apache.sling.crankstart.test.services</artifactId>
-    <version>1.0.1-SNAPSHOT</version>
-    <packaging>bundle</packaging>
-    <name>Apache Sling Crankstart Test Services</name>
-    <description>Bundle used to test the Crankstart launcher</description>
-
-    <scm>
-      <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/test-services</connection>
-      <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/test-services</developerConnection>
-      <url>http://sling.apache.org</url>
-    </scm>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-scr-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Private-Package>org.apache.sling.crankstart.testservices.*</Private-Package>
-                        <Export-Package></Export-Package>
-                    </instructions>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-    
-    <dependencies>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.compendium</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.scr.annotations</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.commons.osgi</artifactId>
-            <version>2.2.0</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.crankstart.api</artifactId>
-            <version>1.0.1-SNAPSHOT</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>servlet-api</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-simple</artifactId>
-            <scope>provided</scope>
-        </dependency>
-    </dependencies>
-</project>
diff --git a/src/main/java/org/apache/sling/crankstart/testservices/ConfigDumpServlet.java b/src/main/java/org/apache/sling/crankstart/testservices/ConfigDumpServlet.java
deleted file mode 100644
index b57866c..0000000
--- a/src/main/java/org/apache/sling/crankstart/testservices/ConfigDumpServlet.java
+++ /dev/null
@@ -1,95 +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.testservices;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.Map;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.Service;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.http.HttpService;
-import org.osgi.service.http.NamespaceException;
-
-/** Dump configs, for testing
- */
-@Component(immediate=true,metatype=true)
-@Service(value=Servlet.class)
-@Reference(name="httpService",referenceInterface=HttpService.class)
-public class ConfigDumpServlet extends TestServlet {
-    private static final long serialVersionUID = -6918378772515948581L;
-    
-    @Reference
-    private ConfigurationAdmin configAdmin;
-
-    @Activate
-    protected void activate(Map<String, Object> config) throws ServletException, NamespaceException {
-        message = "no message yet";
-        path = "/test/config";
-        register();
-    }
-    
-    @Override
-    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
-        final String configPid = req.getPathInfo().substring(1);
-        final Configuration cfg = configAdmin.getConfiguration(configPid);
-        
-        final SortedSet<String> keys = new TreeSet<String>();
-        final Enumeration<?> e = cfg.getProperties().keys();
-        while(e.hasMoreElements()) {
-            keys.add(e.nextElement().toString());
-        }
-        final StringBuilder b = new StringBuilder();
-        b.append(configPid).append("#");
-        for(String key : keys) {
-            final Object value = cfg.getProperties().get(key);
-            b.append(key)
-            .append("=(")
-            .append(value.getClass().getSimpleName())
-            .append(")")
-            .append(prettyprint(value))
-            .append("#")
-            ;
-        }
-        b.append("#EOC#");
-        
-        resp.setContentType("text/plain");
-        resp.setCharacterEncoding("UTF-8");
-        resp.getWriter().write(b.toString());
-        resp.getWriter().flush();
-    }
-    
-    private static String prettyprint(Object value) {
-        if(value instanceof String []) {
-            return Arrays.asList((String[])value).toString();
-        } else {
-            return value.toString();
-        }
-    }
-}
diff --git a/src/main/java/org/apache/sling/crankstart/testservices/ConfigFactoryServlet.java b/src/main/java/org/apache/sling/crankstart/testservices/ConfigFactoryServlet.java
deleted file mode 100644
index 105bc7f..0000000
--- a/src/main/java/org/apache/sling/crankstart/testservices/ConfigFactoryServlet.java
+++ /dev/null
@@ -1,61 +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.testservices;
-
-import java.util.Map;
-
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.ConfigurationPolicy;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.Service;
-import org.apache.sling.commons.osgi.PropertiesUtil;
-import org.osgi.service.http.HttpService;
-import org.osgi.service.http.NamespaceException;
-
-/** Servlet that requires a configuration, used to test the
- *  Crankstart initial config feature with factory configs
- */
-@Component(immediate=true,configurationFactory=true, policy=ConfigurationPolicy.REQUIRE, metatype=true)
-@Service(value=Servlet.class)
-@Reference(name="httpService",referenceInterface=HttpService.class)
-public class ConfigFactoryServlet extends TestServlet {
-    private static final long serialVersionUID = -6918378772515948579L;
-    
-    @Property(value="default message")
-    protected static final String PROP_MESSAGE = "message";
-    
-    @Property(value="/default_path")
-    protected static final String PROP_PATH = "path";
-    
-    @Activate
-    protected void activate(Map<String, Object> config) throws ServletException, NamespaceException {
-        message = PropertiesUtil.toString(config.get(PROP_MESSAGE), "no message");
-        path = PropertiesUtil.toString(config.get(PROP_PATH), "no path");
-        register();
-    }
-    
-    @Deactivate
-    protected void deactivate(Map<String, Object> config) throws ServletException, NamespaceException {
-        unregister();
-    }
-}
diff --git a/src/main/java/org/apache/sling/crankstart/testservices/SingleConfigServlet.java b/src/main/java/org/apache/sling/crankstart/testservices/SingleConfigServlet.java
deleted file mode 100644
index c01eeb1..0000000
--- a/src/main/java/org/apache/sling/crankstart/testservices/SingleConfigServlet.java
+++ /dev/null
@@ -1,60 +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.testservices;
-
-import java.util.Map;
-
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.Service;
-import org.apache.sling.commons.osgi.PropertiesUtil;
-import org.osgi.service.http.HttpService;
-import org.osgi.service.http.NamespaceException;
-
-/** Servlet with a non-factory configuration, used to test the
- *  Crankstart initial config feature
- */
-@Component(immediate=true,metatype=true)
-@Service(value=Servlet.class)
-@Reference(name="httpService",referenceInterface=HttpService.class)
-public class SingleConfigServlet extends TestServlet {
-    private static final long serialVersionUID = -6918378772515948581L;
-    
-    @Property(value="default message")
-    protected static final String PROP_MESSAGE = "message";
-    
-    @Property(value="/default_path")
-    protected static final String PROP_PATH = "path";
-    
-    @Activate
-    protected void activate(Map<String, Object> config) throws ServletException, NamespaceException {
-        message = PropertiesUtil.toString(config.get(PROP_MESSAGE), "no message");
-        path = PropertiesUtil.toString(config.get(PROP_PATH), "/no_path");
-        register();
-    }
-    
-    @Deactivate
-    protected void deactivate(Map<String, Object> config) throws ServletException, NamespaceException {
-        unregister();
-    }
-}
diff --git a/src/main/java/org/apache/sling/crankstart/testservices/SystemPropertyCommand.java b/src/main/java/org/apache/sling/crankstart/testservices/SystemPropertyCommand.java
deleted file mode 100644
index 40c9e67..0000000
--- a/src/main/java/org/apache/sling/crankstart/testservices/SystemPropertyCommand.java
+++ /dev/null
@@ -1,59 +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.testservices;
-
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Service;
-import org.apache.sling.crankstart.api.CrankstartCommand;
-import org.apache.sling.crankstart.api.CrankstartCommandLine;
-import org.apache.sling.crankstart.api.CrankstartContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** CrankstartCommand provided by our test-services bundle
- *  to test crankstart extensions commands provided by OSGi bundles.
- */
-@Component
-@Service
-public class SystemPropertyCommand implements CrankstartCommand {
-    
-    public static final String I_SYSTEM_PROPERTY = "test.system.property";
-    private final Logger log = LoggerFactory.getLogger(getClass());
-
-    public boolean appliesTo(CrankstartCommandLine commandLine) {
-        return I_SYSTEM_PROPERTY.equals(commandLine.getVerb());
-    }
-    
-    public String getDescription() {
-        return I_SYSTEM_PROPERTY + ": set a system property";
-    }
-
-    public void execute(CrankstartContext crankstartContext, CrankstartCommandLine commandLine) throws Exception {
-        final String [] parts = commandLine.getQualifier().split(" ");
-        final String key = parts[0];
-        final StringBuilder sb = new StringBuilder();
-        for(int i=1 ; i < parts.length; i++) {
-            if(sb.length() > 0) {
-                sb.append(' ');
-            }
-            sb.append(parts[i]);
-        }
-        final String value = sb.toString();
-        System.setProperty(key, value);
-        log.info("System property [{}] set to [{}]", key, value);
-    }
-}
diff --git a/src/main/java/org/apache/sling/crankstart/testservices/TestServlet.java b/src/main/java/org/apache/sling/crankstart/testservices/TestServlet.java
deleted file mode 100644
index 3d03789..0000000
--- a/src/main/java/org/apache/sling/crankstart/testservices/TestServlet.java
+++ /dev/null
@@ -1,65 +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.testservices;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.osgi.service.http.HttpService;
-import org.osgi.service.http.NamespaceException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** Base class for our test servlets */
-abstract class TestServlet extends HttpServlet {
-    private static final long serialVersionUID = -6918378772515948578L;
-    protected String message;
-    protected String path;
-    protected final Logger log = LoggerFactory.getLogger(getClass());
-    
-    protected HttpService httpService;
-    
-    protected void register() throws ServletException, NamespaceException {
-        httpService.registerServlet(path, this, null, null);
-        log.info("Registered {} on path {}", this, path);
-    }
-    
-    protected void unregister() throws ServletException, NamespaceException {
-        httpService.unregister(path);
-        log.info("Unregistered path {}", path);
-    }
-    
-    protected void bindHttpService(HttpService s) {
-        httpService = s;
-    }
-    
-    protected void unbindHttpService(HttpService s) {
-        httpService = null;
-    }
-    
-    @Override
-    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
-        resp.setContentType("text/plain");
-        resp.setCharacterEncoding("UTF-8");
-        resp.getWriter().write(getClass().getSimpleName() + ":" + message);
-        resp.getWriter().flush();
-    }
-}

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.