You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2017/10/12 10:27:31 UTC
[1/4] incubator-tamaya-sandbox git commit: TAMAYA-260 Fixed MP
Optional and Provider injection (and a corresponding issue in core in the
Optional converter).
Repository: incubator-tamaya-sandbox
Updated Branches:
refs/heads/master 66f7b1e3f -> 2b878fa18
TAMAYA-260 Fixed MP Optional and Provider injection (and a corresponding issue in core in the Optional converter).
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/commit/9f79a5a5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/9f79a5a5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/9f79a5a5
Branch: refs/heads/master
Commit: 9f79a5a53692bff04c23d233e52b9c1a607e6f43
Parents: 66f7b1e
Author: Anatole Tresch <an...@apache.org>
Authored: Thu Oct 12 11:46:48 2017 +0200
Committer: Anatole Tresch <an...@apache.org>
Committed: Thu Oct 12 11:59:05 2017 +0200
----------------------------------------------------------------------
microprofile/pom.xml | 2 +-
.../cdi/MicroprofileConfigurationProducer.java | 21 -------
.../converter/ProviderConverter.java | 42 ++++++++++++-
.../imported/OptionalValuesBean.java | 64 ++++++++++++++++++++
.../tck/TamayaConfigArchiveProcessor.java | 2 +
microprofile/src/test/tck-suite.xml | 14 ++---
6 files changed, 113 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/9f79a5a5/microprofile/pom.xml
----------------------------------------------------------------------
diff --git a/microprofile/pom.xml b/microprofile/pom.xml
index e3bad3e..a7639a6 100644
--- a/microprofile/pom.xml
+++ b/microprofile/pom.xml
@@ -92,7 +92,7 @@ under the License.
</dependency>
<dependency>
<groupId>org.jboss.weld.se</groupId>
- <artifactId>weld-se-shaded</artifactId>
+ <artifactId>weld-se</artifactId>
<version>${weld.version}</version>
<scope>test</scope>
</dependency>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/9f79a5a5/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java
----------------------------------------------------------------------
diff --git a/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java b/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java
index 8445407..c260023 100644
--- a/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java
+++ b/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java
@@ -136,26 +136,5 @@ public class MicroprofileConfigurationProducer {
return ConfigProviderResolver.instance().getBuilder();
}
-// @Produces
-// @ConfigProperty
-// public Provider getConfiguredProvider(InjectionPoint injectionPoint){
-// final ConfigProperty annotation = injectionPoint.getAnnotated().getAnnotation(ConfigProperty.class);
-// String key = annotation.name();
-//
-// // unless the extension is not installed, this should never happen because the extension
-// // enforces the resolvability of the config
-//
-// String defaultTextValue = annotation.defaultValue().isEmpty() ? null : annotation.defaultValue();
-// ConversionContext conversionContext = createConversionContext(key, injectionPoint);
-// return () -> {
-// Object value = resolveValue(defaultTextValue, conversionContext, injectionPoint);
-// if (value == null) {
-// throw new ConfigException(String.format(
-// "Can't resolve any of the possible config keys: %s to the required target type: %s, supported formats: %s",
-// key, conversionContext.getTargetType(), conversionContext.getSupportedFormats().toString()));
-// }
-// return value;
-// };
-// }
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/9f79a5a5/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java
----------------------------------------------------------------------
diff --git a/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java b/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java
index b8b5068..163481d 100644
--- a/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java
+++ b/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java
@@ -19,6 +19,8 @@
package org.apache.tamaya.microprofile.converter;
import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.ConfigQuery;
+import org.apache.tamaya.Configuration;
import org.apache.tamaya.TypeLiteral;
import org.apache.tamaya.spi.ConversionContext;
import org.apache.tamaya.spi.PropertyConverter;
@@ -26,6 +28,9 @@ import org.apache.tamaya.spi.PropertyConverter;
import javax.annotation.Priority;
import javax.inject.Provider;
import java.lang.reflect.Type;
+import java.util.List;
+import java.util.Objects;
+import java.util.logging.Level;
import java.util.logging.Logger;
/**
@@ -34,14 +39,15 @@ import java.util.logging.Logger;
@Priority(-1)
public class ProviderConverter implements PropertyConverter<Provider> {
- private final Logger LOG = Logger.getLogger(getClass().getName());
+ private static final Logger LOG = Logger.getLogger(ProviderConverter.class.getName());
@Override
public Provider convert(String value, ConversionContext context) {
return () -> {
try{
Type targetType = context.getTargetType().getType();
- return context.getConfiguration().get(value, TypeLiteral.of(targetType));
+ ConvertQuery converter = new ConvertQuery(value, TypeLiteral.of(targetType));
+ return context.getConfiguration().query(converter);
}catch(Exception e){
throw new ConfigException("Error evaluating config value.", e);
}
@@ -57,4 +63,36 @@ public class ProviderConverter implements PropertyConverter<Provider> {
public int hashCode(){
return getClass().hashCode();
}
+
+ private static final class ConvertQuery<T> implements ConfigQuery<T> {
+
+ private String rawValue;
+ private TypeLiteral<T> type;
+
+ public ConvertQuery(String rawValue, TypeLiteral<T> type) {
+ this.rawValue = Objects.requireNonNull(rawValue);
+ this.type = Objects.requireNonNull(type);
+ }
+
+ @Override
+ public T query(Configuration config) {
+ List<PropertyConverter<T>> converters = config.getContext().getPropertyConverters(type);
+ ConversionContext context = new ConversionContext.Builder(type).setConfigurationContext(config.getContext())
+ .setConfiguration(config).setKey(ConvertQuery.class.getName()).build();
+ for(PropertyConverter<?> conv: converters) {
+ try{
+ if(conv instanceof ProviderConverter){
+ continue;
+ }
+ T result = (T)conv.convert(rawValue, context);
+ if(result!=null){
+ return result;
+ }
+ }catch(Exception e){
+ LOG.log(Level.FINEST, e, () -> "Converter "+ conv +" failed to convert to " + type);
+ }
+ }
+ return null;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/9f79a5a5/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/OptionalValuesBean.java
----------------------------------------------------------------------
diff --git a/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/OptionalValuesBean.java b/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/OptionalValuesBean.java
new file mode 100644
index 0000000..b962f21
--- /dev/null
+++ b/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/OptionalValuesBean.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2016-2017 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * Licensed 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.tamaya.microprofile.imported;
+/**
+ * Declare a bean for config property injections.
+ * @author <a href="mailto:struberg@apache.org">Mark Struberg</a>
+ * @author <a href="mailto:emijiang@uk.ibm.com">Emily Jiang</a>
+ */
+
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+import javax.enterprise.context.Dependent;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import java.util.Optional;
+
+@Singleton
+public class OptionalValuesBean {
+ @Inject
+ @ConfigProperty(name="my.optional.int.property")
+ private Optional<Integer> intProperty;
+
+ @Inject
+ @ConfigProperty(name="my.notexisting.property")
+ private Optional<Integer> notexistingProperty;
+
+ private Optional<String> notAnnotatedStringValue;
+
+ private Optional<String> stringValue;
+
+ @Inject
+ public void setStringValue(@ConfigProperty(name="my.optional.string.property") Optional<String> stringValue) {
+ this.stringValue = stringValue;
+ }
+
+ public Optional<String> getStringValue() {
+ return stringValue;
+ }
+
+ public Optional<Integer> getIntProperty() {
+ return intProperty;
+ }
+
+ public Optional<Integer> getNotexistingProperty() {
+ return notexistingProperty;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/9f79a5a5/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigArchiveProcessor.java
----------------------------------------------------------------------
diff --git a/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigArchiveProcessor.java b/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigArchiveProcessor.java
index 7108c4a..61cd11c 100644
--- a/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigArchiveProcessor.java
+++ b/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigArchiveProcessor.java
@@ -18,6 +18,7 @@
*/
package org.apache.tamaya.microprofile.tck;
+import org.apache.tamaya.core.internal.converters.OptionalConverter;
import org.apache.tamaya.microprofile.MicroprofileAdapter;
import org.apache.tamaya.microprofile.MicroprofileConfigProviderResolver;
import org.apache.tamaya.microprofile.cdi.MicroprofileCDIExtension;
@@ -66,6 +67,7 @@ public class TamayaConfigArchiveProcessor implements ApplicationArchiveProcessor
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsServiceProvider(ConfigProviderResolver.class, MicroprofileConfigProviderResolver.class)
.addAsServiceProvider(PropertyConverter.class, BooleanAsIntegerConverterFix.class)
+ .addAsServiceProvider(PropertyConverter.class, OptionalConverter.class)
.addAsServiceProvider(Extension.class, MicroprofileCDIExtension.class);
((WebArchive) applicationArchive).addAsLibraries(
configJar)
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/9f79a5a5/microprofile/src/test/tck-suite.xml
----------------------------------------------------------------------
diff --git a/microprofile/src/test/tck-suite.xml b/microprofile/src/test/tck-suite.xml
index 7efa750..84d36ad 100644
--- a/microprofile/src/test/tck-suite.xml
+++ b/microprofile/src/test/tck-suite.xml
@@ -18,12 +18,10 @@ specific language governing permissions and limitations
under the License.
-->
<suite name="microprofile-config-TCK" verbose="2" configfailurepolicy="continue" >
-
- <test name="microprofile-config 1.0 TCK">
- <packages>
- <package name="org.eclipse.microprofile.config.tck.*">
- </package>
- </packages>
- </test>
-
+ <test name="microprofile-config 1.1 TCK">
+ <packages>
+ <package name="org.eclipse.microprofile.config.tck.*">
+ </package>
+ </packages>
+ </test>
</suite>
\ No newline at end of file
[4/4] incubator-tamaya-sandbox git commit: TAMAYA-274 Added Tamaya
Configuration Service and reduced exposed artifacts.
Posted by an...@apache.org.
TAMAYA-274 Added Tamaya Configuration Service and reduced exposed artifacts.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/commit/2b878fa1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/2b878fa1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/2b878fa1
Branch: refs/heads/master
Commit: 2b878fa18225ed965e63ed5ceeb19309c6beb420
Parents: 7d463e3
Author: Anatole Tresch <an...@apache.org>
Authored: Thu Oct 12 12:27:13 2017 +0200
Committer: Anatole Tresch <an...@apache.org>
Committed: Thu Oct 12 12:27:13 2017 +0200
----------------------------------------------------------------------
osgi/common/bnd.bnd | 2 +-
.../java/org/apache/tamaya/osgi/Activator.java | 7 +-
.../java/org/apache/tamaya/osgi/Backups.java | 4 +-
.../org/apache/tamaya/osgi/ConfigHistory.java | 41 ++--
.../apache/tamaya/osgi/TamayaConfigPlugin.java | 98 ++++++++-
.../tamaya/osgi/commands/BackupCommands.java | 36 ++--
.../tamaya/osgi/commands/ConfigCommands.java | 31 ++-
.../tamaya/osgi/commands/HistoryCommands.java | 25 ++-
.../osgi/commands/TamayaConfigService.java | 206 +++++++++++++++++++
.../apache/tamaya/osgi/AbstractOSGITest.java | 3 +-
.../org/apache/tamaya/osgi/ActivatorTest.java | 3 +-
.../apache/tamaya/osgi/ConfigHistoryTest.java | 40 ++--
.../tamaya/osgi/TamayaConfigPluginTest.java | 28 +--
.../osgi/commands/BackupCommandsTest.java | 34 ++-
.../osgi/commands/ConfigCommandsTest.java | 15 +-
.../osgi/commands/HistoryCommandsTest.java | 43 ++--
.../tamaya/gogo/shell/BackupCommands.java | 16 +-
.../tamaya/gogo/shell/ConfigCommands.java | 4 +-
.../tamaya/gogo/shell/HistoryCommands.java | 36 ++--
.../tamaya/gogo/shell/SettingsCommands.java | 16 +-
.../tamaya/gogo/shell/AbstractOSGITest.java | 7 +-
.../OSGIConfigAdminPropertySource.java | 19 +-
.../injection/OSGIConfigurationInjector.java | 18 ++
.../tamaya/karaf/shell/BackupCreateCommand.java | 7 +-
.../tamaya/karaf/shell/BackupDeleteCommand.java | 7 +-
.../tamaya/karaf/shell/BackupListCommand.java | 7 +-
.../karaf/shell/BackupRestoreCommand.java | 4 +-
.../karaf/shell/DefaultEnableCommand.java | 4 +-
.../karaf/shell/DefaultEnabledCommand.java | 4 +-
.../tamaya/karaf/shell/GetPolicyCommand.java | 4 +-
.../karaf/shell/HistoryDeleteAllCommand.java | 9 +-
.../karaf/shell/HistoryDeleteCommand.java | 9 +-
.../tamaya/karaf/shell/HistoryGetCommand.java | 8 +-
.../karaf/shell/HistoryMaxsizeCommand.java | 10 +-
.../karaf/shell/HistoryMaxsizeSetCommand.java | 10 +-
.../apache/tamaya/karaf/shell/InfoCommand.java | 7 +-
.../tamaya/karaf/shell/OSGIConfigCommand.java | 4 +-
.../tamaya/karaf/shell/PolicyGetCommand.java | 4 +-
.../tamaya/karaf/shell/PolicySetCommand.java | 4 +-
.../karaf/shell/PropagateUpdatesCommand.java | 6 +-
.../karaf/shell/PropagateUpdatesSetCommand.java | 4 +-
.../tamaya/karaf/shell/PropertyGetCommand.java | 4 -
.../karaf/shell/PropertySourceCommand.java | 4 -
.../tamaya/karaf/shell/TamayaConfigCommand.java | 5 +-
.../apache/tamaya/osgi/updater/Activator.java | 6 +-
.../tamaya/osgi/updater/EventListener.java | 6 +-
46 files changed, 613 insertions(+), 256 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/common/bnd.bnd
----------------------------------------------------------------------
diff --git a/osgi/common/bnd.bnd b/osgi/common/bnd.bnd
index 4731c08..e937379 100644
--- a/osgi/common/bnd.bnd
+++ b/osgi/common/bnd.bnd
@@ -30,4 +30,4 @@ Import-Package: \
org.apache.tamaya.spi,\
org.apache.tamaya.functions,\
org.apache.tamaya.spisupport
-Export-Service: org.apache.tamaya.osgi.TamayaConfigPlugin
+Export-Service: org.apache.tamaya.osgi.commands.TamayaConfigService
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/common/src/main/java/org/apache/tamaya/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/Activator.java b/osgi/common/src/main/java/org/apache/tamaya/osgi/Activator.java
index d3a138f..aef323d 100644
--- a/osgi/common/src/main/java/org/apache/tamaya/osgi/Activator.java
+++ b/osgi/common/src/main/java/org/apache/tamaya/osgi/Activator.java
@@ -18,6 +18,7 @@
*/
package org.apache.tamaya.osgi;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import org.osgi.framework.*;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
@@ -44,7 +45,7 @@ public class Activator implements BundleActivator {
private static final Logger LOG = Logger.getLogger(Activator.class.getName());
- private ServiceRegistration<TamayaConfigPlugin> registration;
+ private ServiceRegistration<TamayaConfigService> registration;
private TamayaConfigPlugin plugin;
@@ -57,9 +58,9 @@ public class Activator implements BundleActivator {
this.plugin = new TamayaConfigPlugin(context);
Dictionary<String, Object> props = new Hashtable<>();
props.put(Constants.SERVICE_RANKING, DEFAULT_RANKING);
- LOG.info("Registering Tamaya OSGI Config plugin as service...");
+ LOG.info("Registering Tamaya OSGI Config Service...");
registration = context.registerService(
- TamayaConfigPlugin.class,
+ TamayaConfigService.class,
this.plugin, props);
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/common/src/main/java/org/apache/tamaya/osgi/Backups.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/Backups.java b/osgi/common/src/main/java/org/apache/tamaya/osgi/Backups.java
index 6205895..0ae1048 100644
--- a/osgi/common/src/main/java/org/apache/tamaya/osgi/Backups.java
+++ b/osgi/common/src/main/java/org/apache/tamaya/osgi/Backups.java
@@ -32,7 +32,7 @@ import java.util.logging.Logger;
* Config with Tamaya settings. This allows to restore the configuration in
* case of issues.
*/
-public final class Backups {
+final class Backups {
private static final Logger LOG = Logger.getLogger(Backups.class.getName());
public static final String TAMAYA_BACKUP = "tamaya.backup";
@@ -151,7 +151,7 @@ public final class Backups {
ois.close();
}
} catch (Exception e) {
- LOG.log(Level.WARNING, "Failed to store getConfig change history.", e);
+ LOG.log(Level.WARNING, "Failed to store getConfig change getHistory.", e);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigHistory.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigHistory.java b/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigHistory.java
index cdb915c..dc41787 100644
--- a/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigHistory.java
+++ b/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigHistory.java
@@ -118,7 +118,7 @@ public final class ConfigHistory implements Serializable{
* Sets the maximum history size.
* @param maxHistory the size
*/
- public static void setMaxHistory(int maxHistory){
+ static void setMaxHistory(int maxHistory){
ConfigHistory.maxHistory = maxHistory;
}
@@ -126,7 +126,7 @@ public final class ConfigHistory implements Serializable{
* Get the max history size.
* @return the max size
*/
- public static int getMaxHistory(){
+ static int getMaxHistory(){
return maxHistory;
}
@@ -134,14 +134,14 @@ public final class ConfigHistory implements Serializable{
* Access the current history.
* @return the current history, never null.
*/
- public static List<ConfigHistory> history(){
- return history(null);
+ static List<ConfigHistory> getHistory(){
+ return getHistory(null);
}
/**
* Clears the history.
*/
- public static void clearHistory(){
+ static void clearHistory(){
clearHistory(null);
}
@@ -149,12 +149,12 @@ public final class ConfigHistory implements Serializable{
* Clears the history for a PID.
* @param pid the pid, null clears the full history.
*/
- public static void clearHistory(String pid){
+ static void clearHistory(String pid){
synchronized (history){
if("*".equals(pid)) {
history.clear();
}else{
- history.removeAll(history(pid));
+ history.removeAll(getHistory(pid));
}
}
}
@@ -164,7 +164,7 @@ public final class ConfigHistory implements Serializable{
* @param pid the pid, null returns the full history.
* @return
*/
- public static List<ConfigHistory> history(String pid) {
+ public static List<ConfigHistory> getHistory(String pid) {
if(pid==null || pid.isEmpty()){
return new ArrayList<>(history);
}
@@ -214,12 +214,23 @@ public final class ConfigHistory implements Serializable{
return this;
}
+ @Override
+ public String toString() {
+ return "ConfigHistory{" +
+ "timestamp=" + timestamp +
+ ", previousValue=" + previousValue +
+ ", value=" + value +
+ ", key='" + key + '\'' +
+ '}';
+ }
+
+
/**
* This methd saves the (serialized) history in the plugin's OSGI configuration using
* the HISTORY_KEY key.
* @param osgiConfig the plugin config, not null.
*/
- public static void save(Dictionary<String,Object> osgiConfig){
+ static void save(Dictionary<String,Object> osgiConfig){
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
@@ -235,7 +246,7 @@ public final class ConfigHistory implements Serializable{
* Restores the history from the plugin's OSGI configuration.
* @param osgiConfig
*/
- public static void restore(Dictionary<String,Object> osgiConfig){
+ static void restore(Dictionary<String,Object> osgiConfig){
try{
String serialized = (String)osgiConfig.get(HISTORY_KEY);
if(serialized!=null) {
@@ -249,16 +260,6 @@ public final class ConfigHistory implements Serializable{
}
}
- @Override
- public String toString() {
- return "ConfigHistory{" +
- "timestamp=" + timestamp +
- ", previousValue=" + previousValue +
- ", value=" + value +
- ", key='" + key + '\'' +
- '}';
- }
-
private static void checkHistorySize(){
while(history.size() > maxHistory){
history.remove(0);
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/common/src/main/java/org/apache/tamaya/osgi/TamayaConfigPlugin.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/TamayaConfigPlugin.java b/osgi/common/src/main/java/org/apache/tamaya/osgi/TamayaConfigPlugin.java
index 50c3860..e095b14 100644
--- a/osgi/common/src/main/java/org/apache/tamaya/osgi/TamayaConfigPlugin.java
+++ b/osgi/common/src/main/java/org/apache/tamaya/osgi/TamayaConfigPlugin.java
@@ -18,15 +18,13 @@
*/
package org.apache.tamaya.osgi;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import org.osgi.framework.*;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
import java.io.IOException;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Objects;
+import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -34,7 +32,7 @@ import java.util.logging.Logger;
* Tamaya plugin that updates/extends the component configurations managed
* by {@link ConfigurationAdmin}, based on the configured {@link Policy}.
*/
-public class TamayaConfigPlugin implements BundleListener, ServiceListener{
+public class TamayaConfigPlugin implements TamayaConfigService,BundleListener, ServiceListener{
static final String COMPONENTID = "TamayaConfigPlugin";
/** the logger. */
private static final Logger LOG = Logger.getLogger(TamayaConfigPlugin.class.getName());
@@ -83,25 +81,30 @@ public class TamayaConfigPlugin implements BundleListener, ServiceListener{
initConfigs();
}
+ @Override
public void setAutoUpdateEnabled(boolean enabled){
this.autoUpdateEnabled = enabled;
setConfigValue(TAMAYA_AUTO_UPDATE_ENABLED_PROP, enabled);
}
+ @Override
public void setTamayaEnabledByDefault(boolean enabledByDefault){
this.enabledByDefault = enabledByDefault;
setConfigValue(TAMAYA_ENABLED_PROP, enabledByDefault);
}
+ @Override
public boolean isTamayaEnabledByDefault(){
return enabledByDefault;
}
- public Policy getDefaultOperationMode(){
+ @Override
+ public Policy getDefaultPolicy(){
return defaultPolicy;
}
- public void setDefaultOperationMode(Policy mode){
+ @Override
+ public void setDefaultPolicy(Policy mode){
this.defaultPolicy = Objects.requireNonNull(mode);
setConfigValue(Policy.class.getSimpleName(), defaultPolicy.toString());
}
@@ -145,14 +148,17 @@ public class TamayaConfigPlugin implements BundleListener, ServiceListener{
setPluginConfig(props);
}
+ @Override
public Dictionary<String,Object> updateConfig(String pid) {
return updateConfig(pid, defaultPolicy, false, false);
}
+ @Override
public Dictionary<String,Object> updateConfig(String pid, boolean dryRun) {
return updateConfig(pid, defaultPolicy, false, dryRun);
}
+ @Override
public Dictionary<String,Object> updateConfig(String pid, Policy opMode, boolean explicitMode, boolean dryRun) {
if(dryRun){
return configChanger.configure(pid, null, opMode, explicitMode, true);
@@ -187,6 +193,7 @@ public class TamayaConfigPlugin implements BundleListener, ServiceListener{
setPluginConfig(props);
}
+ @Override
public boolean isBundleEnabled(Bundle bundle){
// Optional MANIFEST entries
String bundleEnabledVal = bundle.getHeaders().get(TAMAYA_ENABLED_MANIFEST);
@@ -319,19 +326,85 @@ public class TamayaConfigPlugin implements BundleListener, ServiceListener{
return configChanger.getTamayaConfiguration(root);
}
+ @Override
public boolean isAutoUpdateEnabled() {
return this.autoUpdateEnabled;
}
- public boolean restoreBackup(String pid)throws IOException{
+ @Override
+ public Dictionary<String, ?> getBackup(String pid) {
+ return Backups.get(pid);
+ }
+
+ @Override
+ public Set<String> getBackupPids() {
+ return Backups.getPids();
+ }
+
+ @Override
+ public boolean restoreBackup(String pid){
Dictionary<String,Object> config = (Dictionary<String,Object>) Backups.get(pid);
if(config==null){
return false;
}
- this.configChanger.restoreBackup(pid, config);
- return true;
+ try {
+ this.configChanger.restoreBackup(pid, config);
+ return true;
+ } catch (IOException e) {
+ LOG.log(Level.WARNING, "Error restoring backup for PID: " + pid, e);
+ return false;
+ }
+ }
+
+ @Override
+ public boolean createBackup(String pid) {
+ if(!Backups.contains(pid)) {
+ Backups.set(pid, getOSGIConfiguration(pid, null));
+ return true;
+ }
+ return false;
}
+ @Override
+ public boolean deleteBackup(String pid) {
+ if(Backups.contains(pid)) {
+ Backups.remove(pid);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void setMaxHistorySize(int maxHistory) {
+ ConfigHistory.setMaxHistory(maxHistory);
+ }
+
+ @Override
+ public int getMaxHistorySize() {
+ return ConfigHistory.getMaxHistory();
+ }
+
+ @Override
+ public List<ConfigHistory> getHistory() {
+ return ConfigHistory.getHistory();
+ }
+
+ @Override
+ public void clearHistory() {
+ ConfigHistory.clearHistory();
+ }
+
+ @Override
+ public void clearHistory(String pid) {
+ ConfigHistory.clearHistory(pid);
+ }
+
+ @Override
+ public List<ConfigHistory> getHistory(String pid) {
+ return ConfigHistory.getHistory(pid);
+ }
+
+ @Override
public Dictionary<String, Object> getOSGIConfiguration(String pid, String section) {
try {
Configuration config = configChanger.getConfigurationAdmin().getConfiguration(pid);
@@ -351,6 +424,11 @@ public class TamayaConfigPlugin implements BundleListener, ServiceListener{
}
}
+ @Override
+ public boolean containsBackup(String pid) {
+ return Backups.contains(pid);
+ }
+
private Dictionary<String, Object> filter(Dictionary<String, Object> props, String section) {
Hashtable<String, Object> result = new Hashtable<>();
Enumeration<String> keys = props.keys();
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/BackupCommands.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/BackupCommands.java b/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/BackupCommands.java
index 13c811b..d8734f7 100644
--- a/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/BackupCommands.java
+++ b/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/BackupCommands.java
@@ -18,8 +18,6 @@
*/
package org.apache.tamaya.osgi.commands;
-import org.apache.tamaya.osgi.Backups;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
@@ -28,7 +26,6 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Dictionary;
import java.util.Enumeration;
-import java.util.Map;
/**
@@ -39,15 +36,16 @@ public final class BackupCommands {
/** Singleton constructor. */
private BackupCommands(){}
- public static String createBackup(ConfigurationAdmin cm, String pid, boolean force) throws IOException {
+ public static String createBackup(TamayaConfigService service, ConfigurationAdmin cm, String pid, boolean force) throws IOException {
Configuration cfg = cm.getConfiguration(pid);
if(cfg!=null){
Dictionary<String,?> props = cfg.getProperties();
if(props!=null){
- if(force || !Backups.contains(pid)){
- Backups.set(pid, props);
- return "Backup created, PID = " + pid + '\n' +
- printProps(props);
+ if(force && service.getBackup(pid)!=null) {
+ service.deleteBackup(pid);
+ }
+ if(service.createBackup(pid)){
+ return "Backup created, PID = " + pid + '\n' + printProps(props);
}else{
return "Creating backup failed. Backup already existing, PID = " + pid;
}
@@ -56,21 +54,23 @@ public final class BackupCommands {
return "Creating backup failed. No Config found, PID = " + pid;
}
- public static String deleteBackup(String pid) throws IOException {
+ public static String deleteBackup(TamayaConfigService service, String pid) throws IOException {
if("*".equals(pid)){
- Backups.removeAll();
+ for(String current: service.getBackupPids()){
+ service.deleteBackup(current);
+ }
return "All Backups deleted.";
}else {
- Backups.remove(pid);
+ service.deleteBackup(pid);
return "Backup deleted: " + pid;
}
}
- public static String restoreBackup(TamayaConfigPlugin plugin, String pid) throws IOException {
+ public static String restoreBackup(TamayaConfigService plugin, String pid) throws IOException {
StringBuilder b = new StringBuilder("Restored Configurations:\n")
.append("------------------------\n");
if("*".equals(pid)){
- for(String current: Backups.getPids()){
+ for(String current: plugin.getBackupPids()){
try{
if(plugin.restoreBackup(current)){
b.append(current).append(" -> restored.\n");
@@ -95,9 +95,9 @@ public final class BackupCommands {
}
}
- public static String listBackup(String pid) throws IOException {
+ public static String listBackup(TamayaConfigService plugin, String pid) throws IOException {
if(pid!=null){
- Dictionary<String, ?> props = Backups.get(pid);
+ Dictionary<String, ?> props = plugin.getBackup(pid);
if(props==null){
return "No backup found: " + pid;
}else{
@@ -107,9 +107,9 @@ public final class BackupCommands {
}else {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
- for(Map.Entry<String, Dictionary<String,?>> en: Backups.get().entrySet()){
- pw.println("PID: " + en.getKey());
- pw.println(printProps(en.getValue()));
+ for(String current: plugin.getBackupPids()){
+ pw.println("PID: " + current);
+ pw.println(printProps(plugin.getBackup(current)));
}
return sw.toString();
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/ConfigCommands.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/ConfigCommands.java b/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/ConfigCommands.java
index 50e8666..061b066 100644
--- a/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/ConfigCommands.java
+++ b/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/ConfigCommands.java
@@ -22,7 +22,6 @@ import org.apache.tamaya.Configuration;
import org.apache.tamaya.ConfigurationProvider;
import org.apache.tamaya.functions.ConfigurationFunctions;
import org.apache.tamaya.osgi.Policy;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
import org.apache.tamaya.spi.PropertySource;
import org.apache.tamaya.spi.PropertyValue;
@@ -39,10 +38,10 @@ public final class ConfigCommands {
/** Singleton constructor. */
private ConfigCommands(){}
- public static String getInfo(TamayaConfigPlugin configPlugin) throws IOException {
+ public static String getInfo(TamayaConfigService configPlugin) throws IOException {
Configuration config = ConfigurationProvider.getConfiguration();
return config.toString() + "\n\n"
- + StringUtil.format("Default Policy:", 30) + configPlugin.getDefaultOperationMode() + '\n'
+ + StringUtil.format("Default Policy:", 30) + configPlugin.getDefaultPolicy() + '\n'
+ StringUtil.format("Default Enabled: ", 30) + configPlugin.isTamayaEnabledByDefault();
}
@@ -66,7 +65,7 @@ public final class ConfigCommands {
return readTamayaConfig("["+pid+"]", filter);
}
- public static String applyTamayaConfiguration(TamayaConfigPlugin configPlugin, String pid, String operationMode, boolean dryRun){
+ public static String applyTamayaConfiguration(TamayaConfigService configPlugin, String pid, String operationMode, boolean dryRun){
Dictionary<String,Object> config = null;
if(operationMode!=null){
config = configPlugin.updateConfig(pid, Policy.valueOf(operationMode), true, dryRun);
@@ -81,13 +80,13 @@ public final class ConfigCommands {
return "Full configuration\n" +
"------------------\n" +
"PID : " + pid + "\n" +
- "Policy : "+ configPlugin.getDefaultOperationMode() + "\n" +
+ "Policy : "+ configPlugin.getDefaultPolicy() + "\n" +
"Applied : " + !dryRun + "\n" +
printOSGIConfig(pid, config);
}
}
- public static String readOSGIConfiguration(TamayaConfigPlugin configPlugin, String pid, String section) {
+ public static String readOSGIConfiguration(TamayaConfigService configPlugin, String pid, String section) {
Dictionary<String,Object> config = configPlugin.getOSGIConfiguration(pid, section);
return printOSGIConfig(pid, config);
}
@@ -113,13 +112,13 @@ public final class ConfigCommands {
return b.toString();
}
- public static String getDefaultOpPolicy(TamayaConfigPlugin configPlugin) throws IOException {
- return String.valueOf(configPlugin.getDefaultOperationMode());
+ public static String getDefaultOpPolicy(TamayaConfigService configPlugin) throws IOException {
+ return String.valueOf(configPlugin.getDefaultPolicy());
}
- public static String setDefaultOpPolicy(TamayaConfigPlugin configPlugin, String policy) throws IOException {
+ public static String setDefaultOpPolicy(TamayaConfigService configPlugin, String policy) throws IOException {
Policy opMode = Policy.valueOf(policy);
- configPlugin.setDefaultOperationMode(opMode);
+ configPlugin.setDefaultPolicy(opMode);
return "Policy="+opMode.toString();
}
@@ -225,21 +224,21 @@ public final class ConfigCommands {
return sw.toString();
}
- public static String setDefaultEnabled(TamayaConfigPlugin configPlugin, boolean enabled) throws IOException {
+ public static String setDefaultEnabled(TamayaConfigService configPlugin, boolean enabled) throws IOException {
configPlugin.setTamayaEnabledByDefault(enabled);
- return TamayaConfigPlugin.TAMAYA_ENABLED_PROP+"="+enabled;
+ return TamayaConfigService.TAMAYA_ENABLED_PROP+"="+enabled;
}
- public static String getDefaultEnabled(TamayaConfigPlugin configPlugin) {
+ public static String getDefaultEnabled(TamayaConfigService configPlugin) {
return String.valueOf(configPlugin.isTamayaEnabledByDefault());
}
- public static String setAutoUpdateEnabled(TamayaConfigPlugin configPlugin, boolean enabled) {
+ public static String setAutoUpdateEnabled(TamayaConfigService configPlugin, boolean enabled) {
configPlugin.setAutoUpdateEnabled(enabled);
- return TamayaConfigPlugin.TAMAYA_AUTO_UPDATE_ENABLED_PROP+"="+enabled;
+ return TamayaConfigService.TAMAYA_AUTO_UPDATE_ENABLED_PROP+"="+enabled;
}
- public static String getAutoUpdateEnabled(TamayaConfigPlugin configPlugin) {
+ public static String getAutoUpdateEnabled(TamayaConfigService configPlugin) {
return String.valueOf(configPlugin.isAutoUpdateEnabled());
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/HistoryCommands.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/HistoryCommands.java b/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/HistoryCommands.java
index 03fc304..f58516d 100644
--- a/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/HistoryCommands.java
+++ b/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/HistoryCommands.java
@@ -19,7 +19,6 @@
package org.apache.tamaya.osgi.commands;
import org.apache.tamaya.osgi.ConfigHistory;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
import java.io.IOException;
import java.io.PrintWriter;
@@ -31,23 +30,23 @@ import java.util.Set;
/**
- * Utility class implementing the available change history related commands.
+ * Utility class implementing the available change getHistory related commands.
*/
public final class HistoryCommands{
/** Singleton constructor. */
private HistoryCommands(){}
- public static String clearHistory(String pid) throws IOException {
- int size = ConfigHistory.history(pid).size();
- ConfigHistory.clearHistory(pid);
- return "Deleted history for PID: " + pid;
+ public static String clearHistory(TamayaConfigService service, String pid) throws IOException {
+ int size = service.getHistory(pid).size();
+ service.clearHistory(pid);
+ return "Deleted getHistory for PID: " + pid;
}
- public static String getHistory(String pid, String... events) throws IOException {
+ public static String getHistory(TamayaConfigService service, String pid, String... events) throws IOException {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
- List<ConfigHistory> history = ConfigHistory.history(pid);
+ List<ConfigHistory> history = service.getHistory(pid);
history = filterTypes(history, events);
pw.print(StringUtil.format("Type", 10));
pw.print(StringUtil.format("PID", 30));
@@ -66,13 +65,13 @@ public final class HistoryCommands{
return sw.toString();
}
- public static String getMaxHistorySize(){
- return String.valueOf(ConfigHistory.getMaxHistory());
+ public static String getMaxHistorySize(TamayaConfigService service){
+ return String.valueOf(service.getMaxHistorySize());
}
- public static String setMaxHistorySize(int maxSize){
- ConfigHistory.setMaxHistory(maxSize);
- return "tamaya-max-history-size="+maxSize;
+ public static String setMaxHistorySize(TamayaConfigService service, int maxSize){
+ service.setMaxHistorySize(maxSize);
+ return "tamaya-max-getHistory-size="+maxSize;
}
private static List<ConfigHistory> filterTypes(List<ConfigHistory> history, String... eventTypes) {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/TamayaConfigService.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/TamayaConfigService.java b/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/TamayaConfigService.java
new file mode 100644
index 0000000..99cd5fb
--- /dev/null
+++ b/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/TamayaConfigService.java
@@ -0,0 +1,206 @@
+/*
+ * 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.tamaya.osgi.commands;
+
+import org.apache.tamaya.osgi.ConfigHistory;
+import org.apache.tamaya.osgi.Policy;
+import org.osgi.framework.Bundle;
+
+import java.util.Dictionary;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Service exposing the Tamaya OSGI configuration logic.
+ */
+public interface TamayaConfigService{
+ /** The system/config property to set Tamaya's {@link Policy}. */
+ String TAMAYA_POLICY_PROP = "tamaya-policy";
+ /** The MANIFEST property to set Tamaya's {@link Policy}. */
+ String TAMAYA_POLICY_MANIFEST = "Tamaya-Policy";
+ /** The system/config property to define a customized Tamaya's configuration root, replacing the {@code [PID]} default
+ * prefix used. */
+ String TAMAYA_CUSTOM_ROOT_PROP = "tamaya-config-root";
+ /** The MANIFEST property to define a customized Tamaya's configuration root, replacing the {@code [PID]} default
+ * prefix used. */
+ String TAMAYA_CUSTOM_ROOT_MANIFEST = "Tamaya-Config-Root";
+ /** The system/config property to enable Tamaya. */
+ String TAMAYA_ENABLED_PROP = "tamaya-enabled";
+ /** The MANIFEST property to enable Tamaya. */
+ String TAMAYA_ENABLED_MANIFEST = "Tamaya-Enabled";
+ /** The system/config property to enable Tamaya automatic updates (requires Tamaya's Updater plugin to be loaded as well). */
+ String TAMAYA_AUTO_UPDATE_ENABLED_PROP = "tamaya-update-enabled";
+ /** The MANIFEST property to enable Tamaya automatic updates (requires Tamaya's Updater plugin to be loaded as well). */
+ String TAMAYA_AUTO_UPDATE_ENABLED_MANIFEST = "Tamaya-Update-Enabled";
+
+ /**
+ * Enables/disables automatic updates (requires Tamaya's Updater plugin to be loaded as well).
+ * @param enabled set to true to enable updates.
+ */
+ void setAutoUpdateEnabled(boolean enabled);
+
+ /**
+ * Enables/disables Tamaya config by default.
+ * @param enabled set to true to enable Tamaya for all bundles by default.
+ */
+ void setTamayaEnabledByDefault(boolean enabled);
+
+ /**
+ * Get the flag, if Tamaya is enabled by default for all bundles.
+ * @return true if Tamaya is enabled.
+ */
+ boolean isTamayaEnabledByDefault();
+
+ /**
+ * Get the default policy Tamaya is using for adapting OSGI configuration.
+ * @return the default policy, never null.
+ */
+ Policy getDefaultPolicy();
+
+ /**
+ * Set the default policy Tamaya is using for adapting OSGI configuration.
+ * @param policy the policy, not null.
+ */
+ void setDefaultPolicy(Policy policy);
+
+ /**
+ * Updates the given OSGI configuration with Tamaya configuration.
+ * @param pid the target PID, not null.
+ * @return the new configuration.
+ */
+ Dictionary<String,Object> updateConfig(String pid);
+
+ /**
+ * Updates the given OSGI configuration with Tamaya configuration.
+ * @param pid the target PID, not null.
+ * @param dryRun if true, the changes will not be applied to the OSGI configuration.
+ * @return the configuration that would be applied, has been applied.
+ */
+ Dictionary<String,Object> updateConfig(String pid, boolean dryRun);
+
+ /**
+ * Updates the given OSGI configuration with Tamaya configuration.
+ * @param pid the target PID, not null.
+ * @param policy the updating policy to be used, by default.
+ * @param forcePolicy if set to true, the given policy will be used, even if an alternate policy is configured
+ * for the given PID.
+ * @param dryRun if true, the changes will not be applied to the OSGI configuration.
+ * @return the configuration that would be applied, has been applied.
+ */
+ Dictionary<String,Object> updateConfig(String pid, Policy policy, boolean forcePolicy, boolean dryRun);
+
+ /**
+ * Checks if a bundle is enabled for Tamaya configuration.
+ * @param bundle the bundle, not null.
+ * @return true, if the bundle is enabled.
+ */
+ boolean isBundleEnabled(Bundle bundle);
+
+ /**
+ * Get the flag if automatic updates for config changes are enabled.
+ * @return true, if automatic updates for config changes are enabled.
+ */
+ boolean isAutoUpdateEnabled();
+
+ /**
+ * Get the backup written for a PID.
+ * @param pid the pid, not null.
+ * @return the backup, or null, if no backup is present.
+ */
+ Dictionary<String,?> getBackup(String pid);
+
+ /**
+ * Get all current known PIDs for which backups are registered.
+ * @return all known PIDs for which backups are registered.
+ */
+ Set<String> getBackupPids();
+
+ /**
+ * Restores a backup, replacing the current OSGI configuration with the backup and
+ * disabling Tamaya for this PID.
+ * @param pid the PID, not null.
+ * @return true, if a backup has been restored successfully.
+ */
+ boolean restoreBackup(String pid);
+
+ /**
+ * Stores the current OSGI configuration as a backup (only if no backup is existing).
+ * @param pid the target PID, not null.
+ * @return true, if a backup has been stored successfully.
+ */
+ boolean createBackup(String pid);
+
+ /**
+ * Deletes a backup, if existing.
+ * @param pid the target PID, not null.
+ * @return true, if a backup has been restored successfully.
+ */
+ boolean deleteBackup(String pid);
+
+ /**
+ * Sets the maximum getHistory size.
+ * @param maxHistory the max getHistory size. {@code 0} disables the getHistory function.
+ */
+ void setMaxHistorySize(int maxHistory);
+
+ /**
+ * Get the max getHistory size.
+ * @return the max getHistory size. {@code 0} means the getHistory function is disabled.
+ */
+ int getMaxHistorySize();
+
+ /**
+ * Access the current (full) change getHistory.
+ * @return the current getHistory, never null.
+ */
+ List<ConfigHistory> getHistory();
+
+ /**
+ * Clears the getHistory.
+ */
+ void clearHistory();
+
+ /**
+ * Clears the getHistory for a PID.
+ * @param pid the target PID, not null.
+ */
+ void clearHistory(String pid);
+
+ /**
+ * Get the getHistory for a PID.
+ * @param pid the target PID, not null.
+ * @return the PID's getHistory, never null.
+ */
+ List<ConfigHistory> getHistory(String pid);
+
+ /**
+ * Access the current OSGI configuration for a PID.
+ * @param pid the target PID, not null.
+ * @param section a subsection to be filter (using startsWith).
+ * @return the (optionally filtered) OSGI configuration.
+ */
+ Dictionary<String,Object> getOSGIConfiguration(String pid, String section);
+
+ /**
+ * Checks if a backup exists.
+ * @param pid the target PID, not null.
+ * @return true, if a backup exists.
+ */
+ boolean containsBackup(String pid);
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/common/src/test/java/org/apache/tamaya/osgi/AbstractOSGITest.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/test/java/org/apache/tamaya/osgi/AbstractOSGITest.java b/osgi/common/src/test/java/org/apache/tamaya/osgi/AbstractOSGITest.java
index 3794afa..20f6fea 100644
--- a/osgi/common/src/test/java/org/apache/tamaya/osgi/AbstractOSGITest.java
+++ b/osgi/common/src/test/java/org/apache/tamaya/osgi/AbstractOSGITest.java
@@ -18,6 +18,7 @@
*/
package org.apache.tamaya.osgi;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import org.junit.Before;
import org.mockito.Mock;
import org.mockito.stubbing.Answer;
@@ -53,7 +54,7 @@ public abstract class AbstractOSGITest {
@Mock
private ServiceReference<TamayaConfigPlugin> tamayaRef;
- protected TamayaConfigPlugin tamayaConfigPlugin;
+ protected TamayaConfigService tamayaConfigPlugin;
protected Dictionary<String,Object> getProperties(String pid){
return this.properties.get(pid);
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/common/src/test/java/org/apache/tamaya/osgi/ActivatorTest.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/test/java/org/apache/tamaya/osgi/ActivatorTest.java b/osgi/common/src/test/java/org/apache/tamaya/osgi/ActivatorTest.java
index 35a402b..c1510f8 100644
--- a/osgi/common/src/test/java/org/apache/tamaya/osgi/ActivatorTest.java
+++ b/osgi/common/src/test/java/org/apache/tamaya/osgi/ActivatorTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.tamaya.osgi;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
@@ -36,7 +37,7 @@ public class ActivatorTest extends AbstractOSGITest{
public void startStop() throws Exception {
Activator activator = new Activator();
activator.start(super.bundleContext);
- verify(bundleContext).registerService(eq(TamayaConfigPlugin.class), anyObject(), anyObject());
+ verify(bundleContext).registerService(eq(TamayaConfigService.class), anyObject(), anyObject());
activator.stop(super.bundleContext);
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/common/src/test/java/org/apache/tamaya/osgi/ConfigHistoryTest.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/test/java/org/apache/tamaya/osgi/ConfigHistoryTest.java b/osgi/common/src/test/java/org/apache/tamaya/osgi/ConfigHistoryTest.java
index 7e58176..a829f7b 100644
--- a/osgi/common/src/test/java/org/apache/tamaya/osgi/ConfigHistoryTest.java
+++ b/osgi/common/src/test/java/org/apache/tamaya/osgi/ConfigHistoryTest.java
@@ -69,9 +69,9 @@ public class ConfigHistoryTest {
@Test
public void history() throws Exception {
for(int i=0;i<100;i++){
- ConfigHistory.propertySet("history", "history"+i, "prev"+i, "new"+i);
+ ConfigHistory.propertySet("getHistory", "getHistory"+i, "prev"+i, "new"+i);
}
- List<ConfigHistory> hist = ConfigHistory.history();
+ List<ConfigHistory> hist = ConfigHistory.getHistory();
assertNotNull(hist);
assertTrue(hist.size()>=100);
}
@@ -80,19 +80,19 @@ public class ConfigHistoryTest {
public void history_pid() throws Exception {
ConfigHistory.configuring("history1", "history_pid");
for(int i=0;i<100;i++){
- ConfigHistory.propertySet("history1", "history"+i, "prev"+i, "new"+i);
+ ConfigHistory.propertySet("history1", "getHistory"+i, "prev"+i, "new"+i);
}
ConfigHistory.configured("history1", "history_pid");
for(int i=0;i<100;i++){
- ConfigHistory.propertySet("history2", "history"+i, "prev"+i, "new"+i);
+ ConfigHistory.propertySet("history2", "getHistory"+i, "prev"+i, "new"+i);
}
- List<ConfigHistory> hist = ConfigHistory.history("history1");
+ List<ConfigHistory> hist = ConfigHistory.getHistory("history1");
assertNotNull(hist);
assertTrue(hist.size()==102);
- hist = ConfigHistory.history("history2");
+ hist = ConfigHistory.getHistory("history2");
assertNotNull(hist);
assertTrue(hist.size()==100);
- hist = ConfigHistory.history(null);
+ hist = ConfigHistory.getHistory(null);
assertNotNull(hist);
assertTrue(hist.size()>=202);
}
@@ -100,21 +100,21 @@ public class ConfigHistoryTest {
@Test
public void clearHistory() throws Exception {
for(int i=0;i<100;i++){
- ConfigHistory.propertySet("history3", "history"+i, "prev"+i, "new"+i);
+ ConfigHistory.propertySet("history3", "getHistory"+i, "prev"+i, "new"+i);
}
for(int i=0;i<100;i++){
- ConfigHistory.propertySet("history4", "history"+i, "prev"+i, "new"+i);
+ ConfigHistory.propertySet("history4", "getHistory"+i, "prev"+i, "new"+i);
}
- List<ConfigHistory> hist = ConfigHistory.history("history3");
+ List<ConfigHistory> hist = ConfigHistory.getHistory("history3");
assertNotNull(hist);
assertTrue(hist.size()==100);
- assertEquals(ConfigHistory.history("history4").size(), 100);
+ assertEquals(ConfigHistory.getHistory("history4").size(), 100);
ConfigHistory.clearHistory("history3");
- assertEquals(ConfigHistory.history("history3").size(), 0);
- assertEquals(ConfigHistory.history("history4").size(), 100);
+ assertEquals(ConfigHistory.getHistory("history3").size(), 0);
+ assertEquals(ConfigHistory.getHistory("history4").size(), 100);
ConfigHistory.clearHistory(null);
- assertEquals(ConfigHistory.history().size(), 0);
- assertEquals(ConfigHistory.history("history4").size(), 0);
+ assertEquals(ConfigHistory.getHistory().size(), 0);
+ assertEquals(ConfigHistory.getHistory("history4").size(), 0);
}
@@ -133,16 +133,16 @@ public class ConfigHistoryTest {
@Test
public void saveRestore() throws Exception {
for(int i=0;i<10;i++){
- ConfigHistory.propertySet("save", "history"+i, "prev"+i, "new"+i);
+ ConfigHistory.propertySet("save", "getHistory"+i, "prev"+i, "new"+i);
}
- assertEquals(ConfigHistory.history("save").size(), 10);
+ assertEquals(ConfigHistory.getHistory("save").size(), 10);
Dictionary<String,Object> config = new Hashtable<>();
ConfigHistory.save(config);
- assertEquals(ConfigHistory.history("save").size(), 10);
+ assertEquals(ConfigHistory.getHistory("save").size(), 10);
ConfigHistory.clearHistory();
- assertEquals(ConfigHistory.history("save").size(), 0);
+ assertEquals(ConfigHistory.getHistory("save").size(), 0);
ConfigHistory.restore(config);
- assertEquals(ConfigHistory.history("save").size(), 10);
+ assertEquals(ConfigHistory.getHistory("save").size(), 10);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/common/src/test/java/org/apache/tamaya/osgi/TamayaConfigPluginTest.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/test/java/org/apache/tamaya/osgi/TamayaConfigPluginTest.java b/osgi/common/src/test/java/org/apache/tamaya/osgi/TamayaConfigPluginTest.java
index 9758c08..d597557 100644
--- a/osgi/common/src/test/java/org/apache/tamaya/osgi/TamayaConfigPluginTest.java
+++ b/osgi/common/src/test/java/org/apache/tamaya/osgi/TamayaConfigPluginTest.java
@@ -40,10 +40,10 @@ public class TamayaConfigPluginTest extends AbstractOSGITest{
@Test
public void testOperationMode() throws Exception {
- Policy om = tamayaConfigPlugin.getDefaultOperationMode();
- tamayaConfigPlugin.setDefaultOperationMode(Policy.EXTEND);
- assertEquals(Policy.EXTEND, tamayaConfigPlugin.getDefaultOperationMode());
- tamayaConfigPlugin.setDefaultOperationMode(Policy.OVERRIDE);
+ Policy om = tamayaConfigPlugin.getDefaultPolicy();
+ tamayaConfigPlugin.setDefaultPolicy(Policy.EXTEND);
+ assertEquals(Policy.EXTEND, tamayaConfigPlugin.getDefaultPolicy());
+ tamayaConfigPlugin.setDefaultPolicy(Policy.OVERRIDE);
}
@Test
@@ -67,21 +67,21 @@ public class TamayaConfigPluginTest extends AbstractOSGITest{
@Test
public void testSetPluginConfig() throws Exception {
Dictionary<String,Object> config = new Hashtable<>();
- tamayaConfigPlugin.setPluginConfig(config);
- assertEquals(tamayaConfigPlugin.getPluginConfig(), config);
+ ((TamayaConfigPlugin)tamayaConfigPlugin).setPluginConfig(config);
+ assertEquals(((TamayaConfigPlugin)tamayaConfigPlugin).getPluginConfig(), config);
}
@Test
public void testSetGetConfigValue() throws Exception {
Dictionary<String,Object> config = new Hashtable<>();
- String val = (String)tamayaConfigPlugin.getConfigValue("foo");
- tamayaConfigPlugin.setConfigValue("bar", "foo");
- assertEquals(tamayaConfigPlugin.getConfigValue("bar"), "foo");
+ String val = (String)((TamayaConfigPlugin)tamayaConfigPlugin).getConfigValue("foo");
+ ((TamayaConfigPlugin)tamayaConfigPlugin).setConfigValue("bar", "foo");
+ assertEquals(((TamayaConfigPlugin)tamayaConfigPlugin).getConfigValue("bar"), "foo");
}
@Test
public void getTMUpdateConfig() throws Exception {
- org.apache.tamaya.Configuration config = tamayaConfigPlugin.getTamayaConfiguration("java.");
+ org.apache.tamaya.Configuration config = ((TamayaConfigPlugin)tamayaConfigPlugin).getTamayaConfiguration("java.");
assertNotNull(config);
assertNull(config.get("jlkjllj"));
assertEquals(config.get("home"),System.getProperty("java.home"));
@@ -110,24 +110,24 @@ public class TamayaConfigPluginTest extends AbstractOSGITest{
@Test
public void getPluginConfig() throws Exception {
- Dictionary<String, Object> config = tamayaConfigPlugin.getPluginConfig();
+ Dictionary<String, Object> config = ((TamayaConfigPlugin)tamayaConfigPlugin).getPluginConfig();
assertNotNull(config);
assertEquals(config, super.getProperties(TamayaConfigPlugin.COMPONENTID));
}
@Test
public void getDefaultOperationMode() throws Exception {
- Policy om = tamayaConfigPlugin.getDefaultOperationMode();
+ Policy om = tamayaConfigPlugin.getDefaultPolicy();
assertNotNull(om);
Dictionary<String,Object> pluginConfig = super.getProperties(TamayaConfigPlugin.COMPONENTID);
pluginConfig.put(Policy.class.getSimpleName(), Policy.UPDATE_ONLY.toString());
TamayaConfigPlugin plugin = new TamayaConfigPlugin(bundleContext);
- om = plugin.getDefaultOperationMode();
+ om = plugin.getDefaultPolicy();
assertNotNull(om);
assertEquals(om, Policy.UPDATE_ONLY);
pluginConfig.put(Policy.class.getSimpleName(), Policy.OVERRIDE.toString());
plugin = new TamayaConfigPlugin(bundleContext);
- om = plugin.getDefaultOperationMode();
+ om = plugin.getDefaultPolicy();
assertNotNull(om);
assertEquals(om, Policy.OVERRIDE);
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/BackupCommandsTest.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/BackupCommandsTest.java b/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/BackupCommandsTest.java
index c7a5f62..20d2a78 100644
--- a/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/BackupCommandsTest.java
+++ b/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/BackupCommandsTest.java
@@ -19,8 +19,6 @@
package org.apache.tamaya.osgi.commands;
import org.apache.tamaya.osgi.AbstractOSGITest;
-import org.apache.tamaya.osgi.Backups;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
@@ -36,47 +34,47 @@ import static org.junit.Assert.*;
public class BackupCommandsTest extends AbstractOSGITest {
@Test
public void createBackup() throws Exception {
- String result = BackupCommands.createBackup(cm, "createBackup", false);
+ String result = BackupCommands.createBackup(tamayaConfigPlugin, cm, "createBackup", false);
assertNotNull(result);
assertTrue(result.contains("createBackup"));
assertTrue(result.contains("Backup created"));
- assertTrue(Backups.contains("createBackup"));
+ assertTrue(tamayaConfigPlugin.containsBackup("createBackup"));
// A backup with the given name already exists, so it fails
- result = BackupCommands.createBackup(cm, "createBackup", false);
+ result = BackupCommands.createBackup(tamayaConfigPlugin, cm, "createBackup", false);
assertNotNull(result);
assertTrue(result.contains("createBackup"));
assertTrue(result.contains("Creating backup failed"));
assertTrue(result.contains("already existing"));
- assertTrue(Backups.contains("createBackup"));
+ assertTrue(tamayaConfigPlugin.containsBackup("createBackup"));
// any existing backups gets overridden
- result = BackupCommands.createBackup(cm, "createBackup", true);
+ result = BackupCommands.createBackup(tamayaConfigPlugin, cm, "createBackup", true);
assertNotNull(result);
assertTrue(result.contains("createBackup"));
assertTrue(result.contains("Backup created"));
- assertTrue(Backups.contains("createBackup"));
+ assertTrue(tamayaConfigPlugin.containsBackup("createBackup"));
}
@Test
public void deleteBackup() throws Exception {
- BackupCommands.createBackup(cm, "deleteBackup", false);
- assertTrue(Backups.contains("deleteBackup"));
- String result = BackupCommands.deleteBackup("deleteBackup");
+ BackupCommands.createBackup(tamayaConfigPlugin, cm, "deleteBackup", false);
+ assertTrue(tamayaConfigPlugin.containsBackup("deleteBackup"));
+ String result = BackupCommands.deleteBackup(tamayaConfigPlugin, "deleteBackup");
assertNotNull(result);
assertTrue(result.contains("deleteBackup"));
assertTrue(result.contains("Backup deleted"));
- assertFalse(Backups.contains("deleteBackup"));
+ assertFalse(tamayaConfigPlugin.containsBackup("deleteBackup"));
}
@Test
public void restoreBackup() throws Exception {
- BackupCommands.createBackup(cm, "restoreBackup", false);
- assertTrue(Backups.contains("restoreBackup"));
+ BackupCommands.createBackup(tamayaConfigPlugin, cm, "restoreBackup", false);
+ assertTrue(tamayaConfigPlugin.containsBackup("restoreBackup"));
String result = BackupCommands.restoreBackup(tamayaConfigPlugin, "restoreBackup");
assertNotNull(result);
assertTrue(result.contains("restoreBackup"));
assertTrue(result.contains("Backup restored"));
- BackupCommands.deleteBackup("restoreBackup");
- assertFalse(Backups.contains("restoreBackup"));
+ BackupCommands.deleteBackup(tamayaConfigPlugin, "restoreBackup");
+ assertFalse(tamayaConfigPlugin.containsBackup("restoreBackup"));
result = BackupCommands.restoreBackup(tamayaConfigPlugin, "restoreBackup");
assertTrue(result.contains("Backup restore failed"));
assertTrue(result.contains("no backup found"));
@@ -84,8 +82,8 @@ public class BackupCommandsTest extends AbstractOSGITest {
@Test
public void listBackup() throws Exception {
- BackupCommands.createBackup(cm, "listBackup", false);
- String result = BackupCommands.listBackup("listBackup");
+ BackupCommands.createBackup(tamayaConfigPlugin, cm, "listBackup", false);
+ String result = BackupCommands.listBackup(tamayaConfigPlugin, "listBackup");
result.concat("listBackup");
result.contains("pid");
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/ConfigCommandsTest.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/ConfigCommandsTest.java b/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/ConfigCommandsTest.java
index 41a43b7..a2c273b 100644
--- a/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/ConfigCommandsTest.java
+++ b/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/ConfigCommandsTest.java
@@ -20,7 +20,6 @@ package org.apache.tamaya.osgi.commands;
import org.apache.tamaya.osgi.AbstractOSGITest;
import org.apache.tamaya.osgi.Policy;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
@@ -96,7 +95,7 @@ public class ConfigCommandsTest extends AbstractOSGITest{
@Test
public void getDefaultOpPolicy() throws Exception {
- Policy mode = tamayaConfigPlugin.getDefaultOperationMode();
+ Policy mode = tamayaConfigPlugin.getDefaultPolicy();
String result = ConfigCommands.getDefaultOpPolicy(tamayaConfigPlugin);
assertNotNull(result);
assertTrue(result.contains(mode.toString()));
@@ -107,11 +106,11 @@ public class ConfigCommandsTest extends AbstractOSGITest{
String result = ConfigCommands.setDefaultOpPolicy(tamayaConfigPlugin, Policy.EXTEND.toString());
assertNotNull(result);
assertTrue(result.contains("EXTEND"));
- assertEquals(tamayaConfigPlugin.getDefaultOperationMode(), Policy.EXTEND);
+ assertEquals(tamayaConfigPlugin.getDefaultPolicy(), Policy.EXTEND);
result = ConfigCommands.setDefaultOpPolicy(tamayaConfigPlugin, Policy.UPDATE_ONLY.toString());
assertNotNull(result);
assertTrue(result.contains("UPDATE_ONLY"));
- assertEquals(tamayaConfigPlugin.getDefaultOperationMode(), Policy.UPDATE_ONLY);
+ assertEquals(tamayaConfigPlugin.getDefaultPolicy(), Policy.UPDATE_ONLY);
}
@Test
@@ -156,11 +155,11 @@ public class ConfigCommandsTest extends AbstractOSGITest{
String result = ConfigCommands.setDefaultEnabled(tamayaConfigPlugin, true);
assertNotNull(result);
System.out.println(result);
- assertTrue(result.contains(TamayaConfigPlugin.TAMAYA_ENABLED_PROP+"=true"));
+ assertTrue(result.contains(TamayaConfigService.TAMAYA_ENABLED_PROP+"=true"));
assertTrue(tamayaConfigPlugin.isTamayaEnabledByDefault());
result = ConfigCommands.setDefaultEnabled(tamayaConfigPlugin, false);
assertNotNull(result);
- assertTrue(result.contains(TamayaConfigPlugin.TAMAYA_ENABLED_PROP+"=false"));
+ assertTrue(result.contains(TamayaConfigService.TAMAYA_ENABLED_PROP+"=false"));
assertFalse(tamayaConfigPlugin.isTamayaEnabledByDefault());
}
@@ -181,12 +180,12 @@ public class ConfigCommandsTest extends AbstractOSGITest{
assertNotNull(result);
System.out.println(result);
assertTrue(result.contains("true"));
- assertTrue(result.contains(TamayaConfigPlugin.TAMAYA_AUTO_UPDATE_ENABLED_PROP));
+ assertTrue(result.contains(TamayaConfigService.TAMAYA_AUTO_UPDATE_ENABLED_PROP));
assertTrue(tamayaConfigPlugin.isAutoUpdateEnabled());
result = ConfigCommands.setAutoUpdateEnabled(tamayaConfigPlugin, false);
assertNotNull(result);
assertTrue(result.contains("false"));
- assertTrue(result.contains(TamayaConfigPlugin.TAMAYA_AUTO_UPDATE_ENABLED_PROP));
+ assertTrue(result.contains(TamayaConfigService.TAMAYA_AUTO_UPDATE_ENABLED_PROP));
assertFalse(tamayaConfigPlugin.isAutoUpdateEnabled());
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/HistoryCommandsTest.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/HistoryCommandsTest.java b/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/HistoryCommandsTest.java
index 44c61ed..ad32857 100644
--- a/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/HistoryCommandsTest.java
+++ b/osgi/common/src/test/java/org/apache/tamaya/osgi/commands/HistoryCommandsTest.java
@@ -18,35 +18,40 @@
*/
package org.apache.tamaya.osgi.commands;
+import org.apache.tamaya.osgi.AbstractOSGITest;
import org.apache.tamaya.osgi.ConfigHistory;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
import static org.junit.Assert.*;
/**
* Created by atsti on 30.09.2017.
*/
-public class HistoryCommandsTest {
+@RunWith(MockitoJUnitRunner.class)
+public class HistoryCommandsTest extends AbstractOSGITest {
+
@Test
public void clearHistory() throws Exception {
ConfigHistory.configured("clearHistory1", "test");
ConfigHistory.configured("clearHistory2", "test");
- assertTrue(ConfigHistory.history("clearHistory1").size()==1);
- assertTrue(ConfigHistory.history("clearHistory2").size()==1);
- assertTrue(ConfigHistory.history("clearHistory3").size()==0);
- String result = HistoryCommands.clearHistory("clearHistory1");
+ assertTrue(ConfigHistory.getHistory("clearHistory1").size()==1);
+ assertTrue(ConfigHistory.getHistory("clearHistory2").size()==1);
+ assertTrue(ConfigHistory.getHistory("clearHistory3").size()==0);
+ String result = HistoryCommands.clearHistory(tamayaConfigPlugin, "clearHistory1");
assertTrue(result.contains("PID"));
assertTrue(result.contains("clearHistory1"));
- assertTrue(ConfigHistory.history("clearHistory1").size()==0);
- assertTrue(ConfigHistory.history("clearHistory2").size()==1);
- assertTrue(ConfigHistory.history("clearHistory3").size()==0);
+ assertTrue(ConfigHistory.getHistory("clearHistory1").size()==0);
+ assertTrue(ConfigHistory.getHistory("clearHistory2").size()==1);
+ assertTrue(ConfigHistory.getHistory("clearHistory3").size()==0);
ConfigHistory.configured("clearHistory1", "test");
- result = HistoryCommands.clearHistory("*");
+ result = HistoryCommands.clearHistory(tamayaConfigPlugin, "*");
assertTrue(result.contains("PID"));
assertTrue(result.contains("*"));
- assertTrue(ConfigHistory.history("clearHistory1").size()==0);
- assertTrue(ConfigHistory.history("clearHistory2").size()==0);
- assertTrue(ConfigHistory.history("clearHistory3").size()==0);
+ assertTrue(ConfigHistory.getHistory("clearHistory1").size()==0);
+ assertTrue(ConfigHistory.getHistory("clearHistory2").size()==0);
+ assertTrue(ConfigHistory.getHistory("clearHistory3").size()==0);
}
@@ -56,12 +61,12 @@ public class HistoryCommandsTest {
ConfigHistory.configuring("getHistory", "test");
ConfigHistory.propertySet("getHistory", "k1", "v1", null);
ConfigHistory.propertySet("getHistory", "k2", null, "v2");
- String result = HistoryCommands.getHistory("getHistory");
+ String result = HistoryCommands.getHistory(tamayaConfigPlugin, "getHistory");
assertNotNull(result);
assertTrue(result.contains("k1"));
assertTrue(result.contains("v1"));
assertTrue(result.contains("test"));
- result = HistoryCommands.getHistory("getHistory", ConfigHistory.TaskType.BEGIN.toString());
+ result = HistoryCommands.getHistory(tamayaConfigPlugin, "getHistory", ConfigHistory.TaskType.BEGIN.toString());
assertNotNull(result);
assertTrue(result.contains("getHistory"));
assertTrue(result.contains("test"));
@@ -71,11 +76,11 @@ public class HistoryCommandsTest {
@Test
public void getSetMaxHistorySize() throws Exception {
- String result = HistoryCommands.getMaxHistorySize();
- assertEquals(result, String.valueOf(ConfigHistory.getMaxHistory()));
- result = HistoryCommands.setMaxHistorySize(111);
- assertEquals(result, "tamaya-max-history-size=111");
- result = HistoryCommands.getMaxHistorySize();
+ String result = HistoryCommands.getMaxHistorySize(tamayaConfigPlugin);
+ assertEquals(result, String.valueOf(tamayaConfigPlugin.getMaxHistorySize()));
+ result = HistoryCommands.setMaxHistorySize(tamayaConfigPlugin, 111);
+ assertEquals(result, "tamaya-max-getHistory-size=111");
+ result = HistoryCommands.getMaxHistorySize(tamayaConfigPlugin);
assertEquals(result, "111");
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/BackupCommands.java
----------------------------------------------------------------------
diff --git a/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/BackupCommands.java b/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/BackupCommands.java
index 33fd333..67c7b66 100644
--- a/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/BackupCommands.java
+++ b/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/BackupCommands.java
@@ -20,7 +20,7 @@ package org.apache.tamaya.gogo.shell;
import org.apache.felix.service.command.Descriptor;
import org.apache.felix.service.command.Parameter;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.cm.ConfigurationAdmin;
@@ -47,26 +47,32 @@ public class BackupCommands {
@Descriptor("The PID (requred)") String pid,
@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-f", "--force"})
@Descriptor("If set any existing backup will be overriden, default is false.") Boolean force) throws IOException {
- System.out.println(org.apache.tamaya.osgi.commands.BackupCommands.createBackup(getService(ConfigurationAdmin.class), pid, force));
+ System.out.println(org.apache.tamaya.osgi.commands.BackupCommands.createBackup(
+ getService(TamayaConfigService.class),
+ getService(ConfigurationAdmin.class), pid, force));
}
@Descriptor("Deletes an OSGI ConfigAdmin configuration backup for a PID.")
public void tm_backup_delete(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-p", "--pid"})
@Descriptor("The target PID") String pid) throws IOException {
- System.out.println(org.apache.tamaya.osgi.commands.BackupCommands.deleteBackup(pid));
+ System.out.println(org.apache.tamaya.osgi.commands.BackupCommands.deleteBackup(
+ getService(TamayaConfigService.class),
+ pid));
}
@Descriptor("Restores an OSGI ConfigAdmin configuration backup for a PID and disabled Tamaya for the given PID.")
public void tm_backup_restore(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-p", "--pid"})
@Descriptor("The target PID") String pid) throws IOException {
System.out.println(org.apache.tamaya.osgi.commands.BackupCommands.restoreBackup(
- getService(TamayaConfigPlugin.class), pid));
+ getService(TamayaConfigService.class), pid));
}
@Descriptor("Shows the contents of the OSGI ConfigAdmin configuration backup for a PID.")
public void tm_backup_get(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-p", "--pid"})
@Descriptor("The PID (requred)") String pid) throws IOException {
- System.out.println(org.apache.tamaya.osgi.commands.BackupCommands.listBackup(Objects.requireNonNull(pid)));
+ System.out.println(org.apache.tamaya.osgi.commands.BackupCommands.listBackup(
+ getService(TamayaConfigService.class),
+ Objects.requireNonNull(pid)));
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/ConfigCommands.java
----------------------------------------------------------------------
diff --git a/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/ConfigCommands.java b/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/ConfigCommands.java
index addd5c5..8926ede 100644
--- a/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/ConfigCommands.java
+++ b/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/ConfigCommands.java
@@ -21,7 +21,7 @@ package org.apache.tamaya.gogo.shell;
import org.apache.felix.service.command.Descriptor;
import org.apache.felix.service.command.Parameter;
import org.apache.tamaya.osgi.Policy;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -63,7 +63,7 @@ public class ConfigCommands {
@Descriptor("If set to true no OSGI configuration gets changed.")
boolean dryRun){
System.out.println(org.apache.tamaya.osgi.commands.ConfigCommands.applyTamayaConfiguration(
- getService(TamayaConfigPlugin.class), pid, policy.toString(), dryRun));
+ getService(TamayaConfigService.class), pid, policy.toString(), dryRun));
}
@Descriptor("Gets the detailed property values.")
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/HistoryCommands.java
----------------------------------------------------------------------
diff --git a/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/HistoryCommands.java b/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/HistoryCommands.java
index 54ca024..906f471 100644
--- a/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/HistoryCommands.java
+++ b/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/HistoryCommands.java
@@ -20,6 +20,7 @@ package org.apache.tamaya.gogo.shell;
import org.apache.felix.service.command.Descriptor;
import org.apache.felix.service.command.Parameter;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -39,39 +40,50 @@ public class HistoryCommands {
this.context = Objects.requireNonNull(context);
}
- @Descriptor("Deletes the history of configuration changes.")
+ @Descriptor("Deletes the getHistory of configuration changes.")
public void tm_history_delete(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-p", "--pid"})
@Descriptor("The PID.") String pid) throws IOException {
- System.out.println(org.apache.tamaya.osgi.commands.HistoryCommands.clearHistory(pid));
+ System.out.println(org.apache.tamaya.osgi.commands.HistoryCommands.clearHistory(
+ getService(TamayaConfigService.class),
+ pid));
}
- @Descriptor("Deletes the full history of configuration changes.")
+ @Descriptor("Deletes the full getHistory of configuration changes.")
public void tm_history_delete_all() throws IOException {
- System.out.println(org.apache.tamaya.osgi.commands.HistoryCommands.clearHistory(null));
+ System.out.println(org.apache.tamaya.osgi.commands.HistoryCommands.clearHistory(
+ getService(TamayaConfigService.class),
+ null));
}
- @Descriptor("Read the history of configuration changes.")
+ @Descriptor("Read the getHistory of configuration changes.")
public void tm_history_get(@Parameter(absentValue = "", names={"-p", "--pid"})
@Descriptor("The PID.")String pid,
@Parameter(absentValue = "", names={"-t", "--eventtypes"})
@Descriptor("The comma separated Event types to filter, valid types are " +
"PROPERTY,BEGIN,END")String eventTypes) throws IOException {
if(eventTypes.isEmpty()){
- System.out.println(org.apache.tamaya.osgi.commands.HistoryCommands.getHistory(pid, null));
+ System.out.println(org.apache.tamaya.osgi.commands.HistoryCommands.getHistory(
+ getService(TamayaConfigService.class),
+ pid, null));
}else {
- System.out.println(org.apache.tamaya.osgi.commands.HistoryCommands.getHistory(pid, eventTypes.split(",")));
+ System.out.println(org.apache.tamaya.osgi.commands.HistoryCommands.getHistory(
+ getService(TamayaConfigService.class),
+ pid, eventTypes.split(",")));
}
}
- @Descriptor("Get the maximum configuration change history size.")
+ @Descriptor("Get the maximum configuration change getHistory size.")
public void tm_history_maxsize() throws IOException {
- System.out.println(String.valueOf(org.apache.tamaya.osgi.commands.HistoryCommands.getMaxHistorySize()));
+ System.out.println(String.valueOf(org.apache.tamaya.osgi.commands.HistoryCommands.getMaxHistorySize(
+ getService(TamayaConfigService.class))));
}
- @Descriptor("Sets the maximum configuration change history size.")
+ @Descriptor("Sets the maximum configuration change getHistory size.")
public void tm_history_maxsize_set(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-s", "--size"})
- @Descriptor("The maximum size of history entries stored.")int maxSize) throws IOException {
- System.out.println(org.apache.tamaya.osgi.commands.HistoryCommands.setMaxHistorySize(maxSize));
+ @Descriptor("The maximum size of getHistory entries stored.")int maxSize) throws IOException {
+ System.out.println(org.apache.tamaya.osgi.commands.HistoryCommands.setMaxHistorySize(
+ getService(TamayaConfigService.class),
+ maxSize));
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/SettingsCommands.java
----------------------------------------------------------------------
diff --git a/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/SettingsCommands.java b/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/SettingsCommands.java
index 6275242..cf79f0a 100644
--- a/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/SettingsCommands.java
+++ b/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/SettingsCommands.java
@@ -21,8 +21,8 @@ package org.apache.tamaya.gogo.shell;
import org.apache.felix.service.command.Descriptor;
import org.apache.felix.service.command.Parameter;
import org.apache.tamaya.osgi.Policy;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
import org.apache.tamaya.osgi.commands.ConfigCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -45,39 +45,39 @@ public class SettingsCommands {
@Descriptor("Allows to disable/enable Tamaya configuration by default.")
public void tm_enable(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-e", "--enable"})
@Descriptor("if true Tamaya is enabled by default (default=false)") boolean enabled) throws IOException {
- System.out.println(ConfigCommands.setDefaultEnabled(getService(TamayaConfigPlugin.class), enabled));
+ System.out.println(ConfigCommands.setDefaultEnabled(getService(TamayaConfigService.class), enabled));
}
@Descriptor("Access if Tamaya is currently enabled by default to change OSGI configuration.")
public void tm_enabled(){
- System.out.println(ConfigCommands.getDefaultEnabled(getService(TamayaConfigPlugin.class)));
+ System.out.println(ConfigCommands.getDefaultEnabled(getService(TamayaConfigService.class)));
}
@Descriptor("Get the default Tamaya configuration policy.")
public void tm_policy() throws IOException {
- System.out.println(ConfigCommands.getDefaultOpPolicy(getService(TamayaConfigPlugin.class)));
+ System.out.println(ConfigCommands.getDefaultOpPolicy(getService(TamayaConfigService.class)));
}
@Descriptor("Set the default Tamaya configuration policy.")
public void tm_policy_set(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-p", "--policy"})
@Descriptor("The policy to apply (required), one of: EXTEND, OVERRIDE, UPDATE_ONLY") Policy policy) throws IOException {
- System.out.println(ConfigCommands.setDefaultOpPolicy(getService(TamayaConfigPlugin.class), policy.toString()));
+ System.out.println(ConfigCommands.setDefaultOpPolicy(getService(TamayaConfigService.class), policy.toString()));
}
@Descriptor("Get info about the current Tamaya configuration settings.")
public void tm_info() throws IOException {
- System.out.println(ConfigCommands.getInfo(getService(TamayaConfigPlugin.class)));
+ System.out.println(ConfigCommands.getInfo(getService(TamayaConfigService.class)));
}
@Descriptor("Flag if Tamaya is automatically triggering OSGI config updates, when according " +
"Tamaya configuration changes.")
public void tm_propagate_updates() throws IOException {
- System.out.println(getService(TamayaConfigPlugin.class).isAutoUpdateEnabled());
+ System.out.println(getService(TamayaConfigService.class).isAutoUpdateEnabled());
}
@Descriptor("Configure if Tamaya is automatically triggering OSGI config updates, when according " +
"Tamaya configuration changes.")
public void tm_propagate_updates_set(boolean enabled) throws IOException {
- System.out.println(ConfigCommands.setAutoUpdateEnabled(getService(TamayaConfigPlugin.class), enabled));
+ System.out.println(ConfigCommands.setAutoUpdateEnabled(getService(TamayaConfigService.class), enabled));
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/AbstractOSGITest.java
----------------------------------------------------------------------
diff --git a/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/AbstractOSGITest.java b/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/AbstractOSGITest.java
index 511769a..918ff97 100644
--- a/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/AbstractOSGITest.java
+++ b/osgi/gogo-shell/src/test/java/org/apache/tamaya/gogo/shell/AbstractOSGITest.java
@@ -19,6 +19,7 @@
package org.apache.tamaya.gogo.shell;
import org.apache.tamaya.osgi.TamayaConfigPlugin;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import org.junit.Before;
import org.mockito.Mock;
import org.osgi.framework.Bundle;
@@ -51,9 +52,9 @@ public abstract class AbstractOSGITest {
@Mock
private ServiceReference<ConfigurationAdmin> cmRef;
@Mock
- private ServiceReference<TamayaConfigPlugin> tamayaRef;
+ private ServiceReference<TamayaConfigService> tamayaRef;
- protected TamayaConfigPlugin tamayaConfigPlugin;
+ protected TamayaConfigService tamayaConfigPlugin;
protected Dictionary<String,Object> getProperties(String pid){
return this.properties.get(pid);
@@ -70,7 +71,7 @@ public abstract class AbstractOSGITest {
doReturn(new Bundle[0]).when(bundleContext).getBundles();
doReturn(cmRef).when(bundleContext).getServiceReference(ConfigurationAdmin.class);
doReturn(cm).when(bundleContext).getService(cmRef);
- doReturn(tamayaRef).when(bundleContext).getServiceReference(TamayaConfigPlugin.class);
+ doReturn(tamayaRef).when(bundleContext).getServiceReference(TamayaConfigService.class);
tamayaConfigPlugin = new TamayaConfigPlugin(bundleContext);
doReturn(tamayaConfigPlugin).when(bundleContext).getService(tamayaRef);
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySource.java
----------------------------------------------------------------------
diff --git a/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySource.java b/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySource.java
index 6689b31..529468e 100644
--- a/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySource.java
+++ b/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySource.java
@@ -1,6 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * 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.tamaya.osgi.injection;
-import org.apache.tamaya.spi.PropertySource;
import org.apache.tamaya.spi.PropertyValue;
import org.apache.tamaya.spisupport.BasePropertySource;
import org.osgi.service.cm.Configuration;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigurationInjector.java
----------------------------------------------------------------------
diff --git a/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigurationInjector.java b/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigurationInjector.java
index ddec058..656f565 100644
--- a/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigurationInjector.java
+++ b/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigurationInjector.java
@@ -1,3 +1,21 @@
+/*
+ * 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.tamaya.osgi.injection;
import org.apache.tamaya.Configuration;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupCreateCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupCreateCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupCreateCommand.java
index 4aa3f8d..dda367a 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupCreateCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupCreateCommand.java
@@ -22,8 +22,10 @@ import org.apache.karaf.shell.api.action.Action;
import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.apache.tamaya.osgi.commands.BackupCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import org.osgi.service.cm.ConfigurationAdmin;
import java.io.IOException;
@@ -32,6 +34,9 @@ import java.io.IOException;
@Service
public class BackupCreateCommand implements Action{
+ @Reference
+ private TamayaConfigService configPlugin;
+
@Argument(index = 0, name = "pid", description = "The target pid to backup.",
required = true, multiValued = false)
String pid;
@@ -45,7 +50,7 @@ public class BackupCreateCommand implements Action{
@Override
public Object execute() throws IOException {
- return(BackupCommands.createBackup(cm, pid, replace));
+ return(BackupCommands.createBackup(configPlugin, cm, pid, replace));
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupDeleteCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupDeleteCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupDeleteCommand.java
index 6bf6162..f8fe5fe 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupDeleteCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupDeleteCommand.java
@@ -21,8 +21,10 @@ package org.apache.tamaya.karaf.shell;
import org.apache.karaf.shell.api.action.Action;
import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.apache.tamaya.osgi.commands.BackupCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import java.io.IOException;
@@ -30,13 +32,16 @@ import java.io.IOException;
@Service
public class BackupDeleteCommand implements Action{
+ @Reference
+ private TamayaConfigService configPlugin;
+
@Argument(index = 0, name = "pid", description = "Allows to filter on the given PID. '*' removes all backups.",
required = true, multiValued = false)
String pid;
@Override
public Object execute() throws IOException {
- return(BackupCommands.deleteBackup(pid));
+ return(BackupCommands.deleteBackup(configPlugin, pid));
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupListCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupListCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupListCommand.java
index 9a4a2ed..edc5e88 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupListCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupListCommand.java
@@ -21,8 +21,10 @@ package org.apache.tamaya.karaf.shell;
import org.apache.karaf.shell.api.action.Action;
import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.apache.tamaya.osgi.commands.BackupCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import java.io.IOException;
@@ -30,13 +32,16 @@ import java.io.IOException;
@Service
public class BackupListCommand implements Action{
+ @Reference
+ private TamayaConfigService configPlugin;
+
@Argument(index = 0, name = "pid", description = "Allows to filter on the given PID.",
required = false, multiValued = false)
String pid;
@Override
public Object execute() throws IOException {
- return(BackupCommands.listBackup(pid));
+ return(BackupCommands.listBackup(configPlugin, pid));
}
}
\ No newline at end of file
[3/4] incubator-tamaya-sandbox git commit: TAMAYA-274 Added Tamaya
Configuration Service and reduced exposed artifacts.
Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupRestoreCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupRestoreCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupRestoreCommand.java
index 8434d45..e053bd2 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupRestoreCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupRestoreCommand.java
@@ -22,8 +22,8 @@ import org.apache.karaf.shell.api.action.Action;
import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
import org.apache.tamaya.osgi.commands.BackupCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import java.io.IOException;
@@ -36,7 +36,7 @@ public class BackupRestoreCommand implements Action{
String pid;
@org.apache.karaf.shell.api.action.lifecycle.Reference
- TamayaConfigPlugin configPlugin;
+ TamayaConfigService configPlugin;
@Override
public Object execute() throws IOException {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnableCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnableCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnableCommand.java
index bbd2b06..1a7ebcf 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnableCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnableCommand.java
@@ -28,8 +28,8 @@ import org.apache.karaf.shell.api.console.Completer;
import org.apache.karaf.shell.api.console.Session;
import org.apache.karaf.shell.support.completers.StringsCompleter;
import org.apache.tamaya.osgi.Policy;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
import org.apache.tamaya.osgi.commands.ConfigCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import java.io.IOException;
import java.util.List;
@@ -40,7 +40,7 @@ import java.util.List;
public class DefaultEnableCommand implements Action{
@Reference
- private TamayaConfigPlugin configPlugin;
+ private TamayaConfigService configPlugin;
@Argument(index = 0, name = "enabled", description = "The boolean value to enabled/disable Tamaya by default.",
required = true, multiValued = false)
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnabledCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnabledCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnabledCommand.java
index 251cb6b..7b29af7 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnabledCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnabledCommand.java
@@ -27,8 +27,8 @@ import org.apache.karaf.shell.api.console.Completer;
import org.apache.karaf.shell.api.console.Session;
import org.apache.karaf.shell.support.completers.StringsCompleter;
import org.apache.tamaya.osgi.Policy;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
import org.apache.tamaya.osgi.commands.ConfigCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import java.io.IOException;
import java.util.List;
@@ -39,7 +39,7 @@ import java.util.List;
public class DefaultEnabledCommand implements Action{
@Reference
- private TamayaConfigPlugin configPlugin;
+ private TamayaConfigService configPlugin;
@Override
public Object execute() throws IOException {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/GetPolicyCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/GetPolicyCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/GetPolicyCommand.java
index 7a85f33..71830ca 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/GetPolicyCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/GetPolicyCommand.java
@@ -22,8 +22,8 @@ import org.apache.karaf.shell.api.action.Action;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
import org.apache.tamaya.osgi.commands.ConfigCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import java.io.IOException;
@@ -32,7 +32,7 @@ import java.io.IOException;
public class GetPolicyCommand implements Action{
@Reference
- private TamayaConfigPlugin configPlugin;
+ private TamayaConfigService configPlugin;
@Override
public Object execute() throws IOException {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryDeleteAllCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryDeleteAllCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryDeleteAllCommand.java
index fab4ccc..cca7c4c 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryDeleteAllCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryDeleteAllCommand.java
@@ -21,18 +21,23 @@ package org.apache.tamaya.karaf.shell;
import org.apache.karaf.shell.api.action.Action;
import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.apache.tamaya.osgi.commands.HistoryCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import java.io.IOException;
-@Command(scope = "tamaya", name = "tm_history_delete_all", description="Deletes the full history of changes Tamaya applied to the OSGI configuration.")
+@Command(scope = "tamaya", name = "tm_history_delete_all", description="Deletes the full getHistory of changes Tamaya applied to the OSGI configuration.")
@Service
public class HistoryDeleteAllCommand implements Action{
+ @Reference
+ private TamayaConfigService configPlugin;
+
@Override
public String execute() throws IOException {
- return HistoryCommands.clearHistory(null);
+ return HistoryCommands.clearHistory(configPlugin, null);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryDeleteCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryDeleteCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryDeleteCommand.java
index 655adf1..d9df7e0 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryDeleteCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryDeleteCommand.java
@@ -19,12 +19,14 @@
package org.apache.tamaya.karaf.shell;
import org.apache.karaf.shell.api.action.*;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.apache.tamaya.osgi.commands.HistoryCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import java.io.IOException;
-@Command(scope = "tamaya", name = "tm_history_delete", description="Deletes the history of changes Tamaya applied to the OSGI configuration.")
+@Command(scope = "tamaya", name = "tm_history_delete", description="Deletes the getHistory of changes Tamaya applied to the OSGI configuration.")
@Service
public class HistoryDeleteCommand implements Action{
@@ -32,9 +34,12 @@ public class HistoryDeleteCommand implements Action{
required = true, multiValued = false)
String pid;
+ @Reference
+ private TamayaConfigService configPlugin;
+
@Override
public String execute() throws IOException {
- return HistoryCommands.clearHistory(pid);
+ return HistoryCommands.clearHistory(configPlugin, pid);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryGetCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryGetCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryGetCommand.java
index 5abbbde..ec221fc 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryGetCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryGetCommand.java
@@ -26,18 +26,18 @@ import org.apache.karaf.shell.api.console.Completer;
import org.apache.karaf.shell.api.console.Session;
import org.apache.karaf.shell.support.completers.StringsCompleter;
import org.apache.tamaya.osgi.ConfigHistory;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
import org.apache.tamaya.osgi.commands.HistoryCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import java.io.IOException;
import java.util.List;
-@Command(scope = "tamaya", name = "tm_history", description="Gets the history of changes Tamaya applied to the OSGI configuration.")
+@Command(scope = "tamaya", name = "tm_history", description="Gets the getHistory of changes Tamaya applied to the OSGI configuration.")
@Service
public class HistoryGetCommand implements Action{
@Reference
- private TamayaConfigPlugin configPlugin;
+ private TamayaConfigService configPlugin;
@Argument(index = 0, name = "pid", description = "Allows to filter on the given PID.",
required = false, multiValued = false)
@@ -50,7 +50,7 @@ public class HistoryGetCommand implements Action{
@Override
public String execute() throws IOException {
- return HistoryCommands.getHistory(pid, eventTypes);
+ return HistoryCommands.getHistory(configPlugin, pid, eventTypes);
}
@Service
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryMaxsizeCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryMaxsizeCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryMaxsizeCommand.java
index d8dd37e..f736e4b 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryMaxsizeCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryMaxsizeCommand.java
@@ -19,19 +19,23 @@
package org.apache.tamaya.karaf.shell;
import org.apache.karaf.shell.api.action.*;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.tamaya.osgi.ConfigHistory;
import org.apache.tamaya.osgi.commands.HistoryCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import java.io.IOException;
-@Command(scope = "tamaya", name = "tm_history_maxsize", description="Gets the maximal size of stored history entries.")
+@Command(scope = "tamaya", name = "tm_history_maxsize", description="Gets the maximal size of stored getHistory entries.")
@Service
public class HistoryMaxsizeCommand implements Action{
+ @Reference
+ private TamayaConfigService configPlugin;
+
@Override
public Object execute() throws IOException {
- return(HistoryCommands.getMaxHistorySize());
+ return(HistoryCommands.getMaxHistorySize(configPlugin));
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryMaxsizeSetCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryMaxsizeSetCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryMaxsizeSetCommand.java
index a490dd6..91f09ee 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryMaxsizeSetCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryMaxsizeSetCommand.java
@@ -23,25 +23,25 @@ import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
import org.apache.tamaya.osgi.commands.HistoryCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import java.io.IOException;
-@Command(scope = "tamaya", name = "tm_history_maxsize_set", description="Sets the maximal size of Tamaya history entries.")
+@Command(scope = "tamaya", name = "tm_history_maxsize_set", description="Sets the maximal size of Tamaya getHistory entries.")
@Service
public class HistoryMaxsizeSetCommand implements Action{
@Reference
- private TamayaConfigPlugin configPlugin;
+ private TamayaConfigService configPlugin;
- @Argument(index = 0, name = "size", description = "The maximum number of entries in the history.",
+ @Argument(index = 0, name = "size", description = "The maximum number of entries in the getHistory.",
required = true, multiValued = false)
int maxSize;
@Override
public Object execute() throws IOException {
- return(HistoryCommands.setMaxHistorySize(maxSize));
+ return(HistoryCommands.setMaxHistorySize(configPlugin, maxSize));
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/InfoCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/InfoCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/InfoCommand.java
index b543d9c..cb8f826 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/InfoCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/InfoCommand.java
@@ -24,18 +24,15 @@ import org.apache.karaf.shell.api.action.Action;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
import org.apache.tamaya.osgi.commands.ConfigCommands;
-import org.apache.tamaya.osgi.commands.HistoryCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
@Command(scope = "tamaya", name = "tm_info", description="Show he current Tamaya status.")
@Service
public class InfoCommand implements Action {
@Reference
- private TamayaConfigPlugin configPlugin;
+ private TamayaConfigService configPlugin;
public Object execute() throws IOException {
return(ConfigCommands.getInfo(configPlugin));
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/OSGIConfigCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/OSGIConfigCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/OSGIConfigCommand.java
index 807d08d..128aa78 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/OSGIConfigCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/OSGIConfigCommand.java
@@ -23,8 +23,8 @@ import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.Option;
import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
import org.apache.tamaya.osgi.commands.ConfigCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import java.io.IOException;
@@ -41,7 +41,7 @@ public class OSGIConfigCommand implements Action{
String pid = null;
@org.apache.karaf.shell.api.action.lifecycle.Reference
- TamayaConfigPlugin configPlugin;
+ TamayaConfigService configPlugin;
public Object execute() throws IOException {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PolicyGetCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PolicyGetCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PolicyGetCommand.java
index 9b38018..e38e017 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PolicyGetCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PolicyGetCommand.java
@@ -22,8 +22,8 @@ import org.apache.karaf.shell.api.action.Action;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
import org.apache.tamaya.osgi.commands.ConfigCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import java.io.IOException;
@@ -32,7 +32,7 @@ import java.io.IOException;
public class PolicyGetCommand implements Action{
@Reference
- private TamayaConfigPlugin configPlugin;
+ private TamayaConfigService configPlugin;
@Override
public Object execute() throws IOException {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PolicySetCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PolicySetCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PolicySetCommand.java
index f1d1816..10e317f 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PolicySetCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PolicySetCommand.java
@@ -29,8 +29,8 @@ import org.apache.karaf.shell.api.console.Completer;
import org.apache.karaf.shell.api.console.Session;
import org.apache.karaf.shell.support.completers.StringsCompleter;
import org.apache.tamaya.osgi.Policy;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
import org.apache.tamaya.osgi.commands.ConfigCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import java.io.IOException;
import java.util.List;
@@ -40,7 +40,7 @@ import java.util.List;
public class PolicySetCommand implements Action{
@Reference
- private TamayaConfigPlugin configPlugin;
+ private TamayaConfigService configPlugin;
@Argument(index = 0, name = "tm_policy_set", description = "The operation policy how Tamaya intercepts OSGI configuration.",
required = true, multiValued = false)
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesCommand.java
index 4ad1baa..129e9fc 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesCommand.java
@@ -19,12 +19,10 @@
package org.apache.tamaya.karaf.shell;
import org.apache.karaf.shell.api.action.Action;
-import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
-import org.apache.tamaya.osgi.commands.ConfigCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import java.io.IOException;
@@ -35,7 +33,7 @@ import java.io.IOException;
public class PropagateUpdatesCommand implements Action{
@Reference
- private TamayaConfigPlugin configPlugin;
+ private TamayaConfigService configPlugin;
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesSetCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesSetCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesSetCommand.java
index 3832018..ff5dc95 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesSetCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesSetCommand.java
@@ -23,8 +23,8 @@ import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
import org.apache.tamaya.osgi.commands.ConfigCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import java.io.IOException;
@@ -35,7 +35,7 @@ import java.io.IOException;
public class PropagateUpdatesSetCommand implements Action{
@Reference
- private TamayaConfigPlugin configPlugin;
+ private TamayaConfigService configPlugin;
@Argument(index = 0, name = "enabled", description = "Set to true to enable Tamaya's updating trigger.",
required = true, multiValued = false)
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertyGetCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertyGetCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertyGetCommand.java
index 932225a..72f5b4a 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertyGetCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertyGetCommand.java
@@ -23,11 +23,7 @@ import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.Option;
import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
import org.apache.tamaya.osgi.commands.ConfigCommands;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertySourceCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertySourceCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertySourceCommand.java
index b6d9439..97ff4ae 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertySourceCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertySourceCommand.java
@@ -22,11 +22,7 @@ import org.apache.karaf.shell.api.action.Action;
import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
import org.apache.tamaya.osgi.commands.ConfigCommands;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/TamayaConfigCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/TamayaConfigCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/TamayaConfigCommand.java
index b161996..e66d27b 100644
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/TamayaConfigCommand.java
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/TamayaConfigCommand.java
@@ -19,12 +19,11 @@
package org.apache.tamaya.karaf.shell;
import org.apache.karaf.shell.api.action.Action;
-import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.Option;
import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
import org.apache.tamaya.osgi.commands.ConfigCommands;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import java.io.IOException;
@@ -41,7 +40,7 @@ public class TamayaConfigCommand implements Action{
String pid = null;
@org.apache.karaf.shell.api.action.lifecycle.Reference
- TamayaConfigPlugin configPlugin;
+ TamayaConfigService configPlugin;
public Object execute() throws IOException {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/updater/src/main/java/org/apache/tamaya/osgi/updater/Activator.java
----------------------------------------------------------------------
diff --git a/osgi/updater/src/main/java/org/apache/tamaya/osgi/updater/Activator.java b/osgi/updater/src/main/java/org/apache/tamaya/osgi/updater/Activator.java
index be72479..a83f18f 100644
--- a/osgi/updater/src/main/java/org/apache/tamaya/osgi/updater/Activator.java
+++ b/osgi/updater/src/main/java/org/apache/tamaya/osgi/updater/Activator.java
@@ -20,7 +20,7 @@ package org.apache.tamaya.osgi.updater;
import org.apache.tamaya.events.ConfigEventManager;
import org.apache.tamaya.events.ConfigurationChange;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import org.osgi.framework.*;
import org.osgi.service.cm.ConfigurationAdmin;
@@ -53,8 +53,8 @@ public class Activator implements BundleActivator {
listener = new EventListener(context);
ConfigEventManager.addListener(listener, ConfigurationChange.class);
LOG.info("Registered Tamaya getConfig trigger for OSGI.");
- ServiceReference<TamayaConfigPlugin> pluginRef = context.getServiceReference(TamayaConfigPlugin.class);
- TamayaConfigPlugin tamayaPlugin = context.getService(pluginRef);
+ ServiceReference<TamayaConfigService> pluginRef = context.getServiceReference(TamayaConfigService.class);
+ TamayaConfigService tamayaPlugin = context.getService(pluginRef);
updateTimer.schedule(new TimerTask() {
@Override
public void run() {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/2b878fa1/osgi/updater/src/main/java/org/apache/tamaya/osgi/updater/EventListener.java
----------------------------------------------------------------------
diff --git a/osgi/updater/src/main/java/org/apache/tamaya/osgi/updater/EventListener.java b/osgi/updater/src/main/java/org/apache/tamaya/osgi/updater/EventListener.java
index 29e7712..68e9bcb 100644
--- a/osgi/updater/src/main/java/org/apache/tamaya/osgi/updater/EventListener.java
+++ b/osgi/updater/src/main/java/org/apache/tamaya/osgi/updater/EventListener.java
@@ -22,7 +22,7 @@ import org.apache.tamaya.events.ConfigEvent;
import org.apache.tamaya.events.ConfigEventListener;
import org.apache.tamaya.events.ConfigurationChange;
import org.apache.tamaya.osgi.Policy;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
+import org.apache.tamaya.osgi.commands.TamayaConfigService;
import org.osgi.framework.*;
import org.osgi.service.cm.ConfigurationAdmin;
@@ -61,8 +61,8 @@ final class EventListener implements ConfigEventListener{
}
LOG.finest("Tamya Config change for pids: " + changedPids);
// Reload the given pids
- ServiceReference<TamayaConfigPlugin> pluginRef = context.getServiceReference(TamayaConfigPlugin.class);
- TamayaConfigPlugin tamayaPlugin = context.getService(pluginRef);
+ ServiceReference<TamayaConfigService> pluginRef = context.getServiceReference(TamayaConfigService.class);
+ TamayaConfigService tamayaPlugin = context.getService(pluginRef);
for(String pid:changedPids) {
tamayaPlugin.updateConfig(pid);
}
[2/4] incubator-tamaya-sandbox git commit: TAMAYA-260 Merged
conflicts.
Posted by an...@apache.org.
TAMAYA-260 Merged conflicts.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/commit/7d463e32
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/7d463e32
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/7d463e32
Branch: refs/heads/master
Commit: 7d463e32d57a3c77b2abc8d48e13f5e35022f9f3
Parents: 9f79a5a
Author: Anatole Tresch <an...@apache.org>
Authored: Thu Oct 12 12:25:57 2017 +0200
Committer: Anatole Tresch <an...@apache.org>
Committed: Thu Oct 12 12:25:57 2017 +0200
----------------------------------------------------------------------
microprofile/pom.xml | 2 +-
.../imported/OptionalValuesBean.java | 64 --------------------
2 files changed, 1 insertion(+), 65 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7d463e32/microprofile/pom.xml
----------------------------------------------------------------------
diff --git a/microprofile/pom.xml b/microprofile/pom.xml
index a7639a6..e3bad3e 100644
--- a/microprofile/pom.xml
+++ b/microprofile/pom.xml
@@ -92,7 +92,7 @@ under the License.
</dependency>
<dependency>
<groupId>org.jboss.weld.se</groupId>
- <artifactId>weld-se</artifactId>
+ <artifactId>weld-se-shaded</artifactId>
<version>${weld.version}</version>
<scope>test</scope>
</dependency>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7d463e32/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/OptionalValuesBean.java
----------------------------------------------------------------------
diff --git a/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/OptionalValuesBean.java b/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/OptionalValuesBean.java
deleted file mode 100644
index b962f21..0000000
--- a/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/OptionalValuesBean.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2016-2017 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * Licensed 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.tamaya.microprofile.imported;
-/**
- * Declare a bean for config property injections.
- * @author <a href="mailto:struberg@apache.org">Mark Struberg</a>
- * @author <a href="mailto:emijiang@uk.ibm.com">Emily Jiang</a>
- */
-
-import org.eclipse.microprofile.config.inject.ConfigProperty;
-
-import javax.enterprise.context.Dependent;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import java.util.Optional;
-
-@Singleton
-public class OptionalValuesBean {
- @Inject
- @ConfigProperty(name="my.optional.int.property")
- private Optional<Integer> intProperty;
-
- @Inject
- @ConfigProperty(name="my.notexisting.property")
- private Optional<Integer> notexistingProperty;
-
- private Optional<String> notAnnotatedStringValue;
-
- private Optional<String> stringValue;
-
- @Inject
- public void setStringValue(@ConfigProperty(name="my.optional.string.property") Optional<String> stringValue) {
- this.stringValue = stringValue;
- }
-
- public Optional<String> getStringValue() {
- return stringValue;
- }
-
- public Optional<Integer> getIntProperty() {
- return intProperty;
- }
-
- public Optional<Integer> getNotexistingProperty() {
- return notexistingProperty;
- }
-}
\ No newline at end of file