You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ol...@apache.org on 2015/10/17 16:03:55 UTC

svn commit: r1709171 - in /sling/whiteboard/olli/settings: ./ simple/ simple/src/ simple/src/main/ simple/src/main/java/ simple/src/main/java/org/ simple/src/main/java/org/apache/ simple/src/main/java/org/apache/sling/ simple/src/main/java/org/apache/s...

Author: olli
Date: Sat Oct 17 14:03:55 2015
New Revision: 1709171

URL: http://svn.apache.org/viewvc?rev=1709171&view=rev
Log:
add module org.apache.sling.settings.simple

Added:
    sling/whiteboard/olli/settings/simple/
    sling/whiteboard/olli/settings/simple/pom.xml
    sling/whiteboard/olli/settings/simple/src/
    sling/whiteboard/olli/settings/simple/src/main/
    sling/whiteboard/olli/settings/simple/src/main/java/
    sling/whiteboard/olli/settings/simple/src/main/java/org/
    sling/whiteboard/olli/settings/simple/src/main/java/org/apache/
    sling/whiteboard/olli/settings/simple/src/main/java/org/apache/sling/
    sling/whiteboard/olli/settings/simple/src/main/java/org/apache/sling/settings/
    sling/whiteboard/olli/settings/simple/src/main/java/org/apache/sling/settings/simple/
    sling/whiteboard/olli/settings/simple/src/main/java/org/apache/sling/settings/simple/internal/
    sling/whiteboard/olli/settings/simple/src/main/java/org/apache/sling/settings/simple/internal/SimpleSlingSettingsService.java
Modified:
    sling/whiteboard/olli/settings/pom.xml

Modified: sling/whiteboard/olli/settings/pom.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/olli/settings/pom.xml?rev=1709171&r1=1709170&r2=1709171&view=diff
==============================================================================
--- sling/whiteboard/olli/settings/pom.xml (original)
+++ sling/whiteboard/olli/settings/pom.xml Sat Oct 17 14:03:55 2015
@@ -44,6 +44,7 @@
     <module>api</module>
     <module>core</module>
     <module>launchpad</module>
+    <module>simple</module>
   </modules>
 
 </project>

Added: sling/whiteboard/olli/settings/simple/pom.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/olli/settings/simple/pom.xml?rev=1709171&view=auto
==============================================================================
--- sling/whiteboard/olli/settings/simple/pom.xml (added)
+++ sling/whiteboard/olli/settings/simple/pom.xml Sat Oct 17 14:03:55 2015
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>25</version>
+        <relativePath/>
+    </parent>
+
+    <artifactId>org.apache.sling.settings.simple</artifactId>
+    <packaging>bundle</packaging>
+    <version>1.3.7-SNAPSHOT</version>
+
+    <name>Apache Sling Settings Simple</name>
+    <description>
+        Settings support including run modes
+    </description>
+
+    <scm>
+        <connection>
+            scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/settings
+        </connection>
+        <developerConnection>
+            scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/settings
+        </developerConnection>
+        <url>
+            http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/settings
+        </url>
+    </scm>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-DocURL>
+                            http://sling.apache.org/documentation/bundles/sling-settings-orgapacheslingsettings.html
+                        </Bundle-DocURL>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.settings.api</artifactId>
+            <version>1.3.7-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.settings.core</artifactId>
+            <version>1.3.7-SNAPSHOT</version>
+        </dependency>
+        <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.shell</artifactId>
+            <version>1.0.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+    </dependencies>
+</project>

Added: sling/whiteboard/olli/settings/simple/src/main/java/org/apache/sling/settings/simple/internal/SimpleSlingSettingsService.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/olli/settings/simple/src/main/java/org/apache/sling/settings/simple/internal/SimpleSlingSettingsService.java?rev=1709171&view=auto
==============================================================================
--- sling/whiteboard/olli/settings/simple/src/main/java/org/apache/sling/settings/simple/internal/SimpleSlingSettingsService.java (added)
+++ sling/whiteboard/olli/settings/simple/src/main/java/org/apache/sling/settings/simple/internal/SimpleSlingSettingsService.java Sat Oct 17 14:03:55 2015
@@ -0,0 +1,87 @@
+/*
+ * 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.settings.simple.internal;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.sling.settings.SlingSettingsService;
+import org.apache.sling.settings.service.AbstractSlingSettingsService;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SimpleSlingSettingsService extends AbstractSlingSettingsService implements SlingSettingsService {
+
+    private final Logger logger = LoggerFactory.getLogger(SimpleSlingSettingsService.class);
+
+    /**
+     * Set up run modes.
+     */
+    private void setupRunModes(final BundleContext context) {
+        final Set<String> modesSet = new HashSet<String>();
+
+        // check configuration property first
+        final String prop = context.getProperty(RUN_MODES_PROPERTY);
+        if (prop != null && prop.trim().length() > 0) {
+            final String[] modes = prop.split(",");
+            for(int i=0; i < modes.length; i++) {
+                modesSet.add(modes[i].trim());
+            }
+        }
+
+        //  handle configured options
+        this.handleOptions(modesSet, context.getProperty(RUN_MODE_OPTIONS));
+
+        /*
+        // handle configured install options
+        if ( startupMode != StartupMode.INSTALL ) {
+            // read persisted options if restart or update
+            final List<Options> storedOptions = readOptions(context);
+            if ( storedOptions != null ) {
+                for(final Options o : storedOptions) {
+                    for(final String m : o.modes) {
+                        modesSet.remove(m);
+                    }
+                    modesSet.add(o.selected);
+                }
+            }
+        }
+
+        // now install options
+        if ( startupMode != StartupMode.RESTART ) {
+            // process new install options if install or update
+            final List<Options> optionsList = this.handleOptions(modesSet, context.getProperty(RUN_MODE_INSTALL_OPTIONS));
+            // and always save new install options
+            writeOptions(context, optionsList);
+        }
+        */
+
+        // make the set unmodifiable and synced
+        // we probably don't need a synced set as it is read only
+        this.runModes = Collections.synchronizedSet(Collections.unmodifiableSet(modesSet));
+        if ( this.runModes.size() > 0 ) {
+            logger.info("Active run modes: {}", this.runModes);
+        } else {
+            logger.info("No run modes active");
+        }
+    }
+
+}