This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.installer.factory.configuration-1.0.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-factory-configuration.git
commit 93642ddb4ed024574f5746479fa51ab210504c66 Author: Carsten Ziegeler <[email protected]> AuthorDate: Thu Mar 3 08:08:24 2011 +0000 SLING-2014 : Provide a possibility to not persist configuration changes git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/installer/factories/configuration@1076551 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 3 +++ .../configuration/ConfigurationConstants.java | 31 ++++++++++++++++++++++ .../configuration/impl/ConfigTaskCreator.java | 16 +++++++++-- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 60eb1c4..e5585b3 100644 --- a/pom.xml +++ b/pom.xml @@ -51,6 +51,9 @@ <Bundle-Activator> org.apache.sling.installer.factories.configuration.impl.Activator </Bundle-Activator> + <Export-Package> + org.apache.sling.installer.factories.configuration + </Export-Package> <Private-Package> org.apache.sling.installer.factories.configuration.impl.* </Private-Package> diff --git a/src/main/java/org/apache/sling/installer/factories/configuration/ConfigurationConstants.java b/src/main/java/org/apache/sling/installer/factories/configuration/ConfigurationConstants.java new file mode 100644 index 0000000..93afb48 --- /dev/null +++ b/src/main/java/org/apache/sling/installer/factories/configuration/ConfigurationConstants.java @@ -0,0 +1,31 @@ +/* + * 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.installer.factories.configuration; + +public abstract class ConfigurationConstants { + + /** + * This property defines if a configuration should be persisted by the + * installer. This property is a boolean value defaulting to true. + * + * The property should be used, if a configuration should not be persisted + * by clients creating the configuration. + */ + public static final String PROPERTY_PERSISTENCE = "org.apache.sling.installer.configuration.persist"; +} diff --git a/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigTaskCreator.java b/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigTaskCreator.java index ce608ff..1ef43bd 100644 --- a/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigTaskCreator.java +++ b/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigTaskCreator.java @@ -32,6 +32,7 @@ import org.apache.sling.installer.api.tasks.ResourceTransformer; import org.apache.sling.installer.api.tasks.TaskResource; import org.apache.sling.installer.api.tasks.TaskResourceGroup; import org.apache.sling.installer.api.tasks.TransformationResult; +import org.apache.sling.installer.factories.configuration.ConfigurationConstants; import org.osgi.framework.Constants; import org.osgi.service.cm.Configuration; import org.osgi.service.cm.ConfigurationAdmin; @@ -92,10 +93,21 @@ public class ConfigTaskCreator false); if ( config != null ) { final Dictionary<String, Object> dict = ConfigUtil.cleanConfiguration(config.getProperties()); - this.changeListener.resourceAddedOrUpdated(InstallableResource.TYPE_CONFIG, id, null, dict); + boolean persist = true; + final Object persistProp = dict.get(ConfigurationConstants.PROPERTY_PERSISTENCE); + if ( persistProp != null ) { + if (persistProp instanceof Boolean) { + persist = ((Boolean) persistProp).booleanValue(); + } else { + persist = Boolean.valueOf(String.valueOf(persistProp)); + } + } + if ( persist ) { + this.changeListener.resourceAddedOrUpdated(InstallableResource.TYPE_CONFIG, id, null, dict); + } } } catch ( final Exception ignore) { - // ignore for now (TODO) + // ignore for now } } } -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
