TAMAYA-297: Fixes on OSGI commands, added propagation flag.
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/86713156 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/86713156 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/86713156 Branch: refs/heads/master Commit: 86713156b37270e8725c2cbceadd59defb00ee1c Parents: c2becbf Author: anatole <[email protected]> Authored: Fri Sep 22 23:44:36 2017 +0200 Committer: anatole <[email protected]> Committed: Fri Sep 22 23:44:36 2017 +0200 ---------------------------------------------------------------------- osgi/common/bnd.bnd | 5 +- .../org/apache/tamaya/osgi/ConfigChanger.java | 4 + .../org/apache/tamaya/osgi/ConfigHistory.java | 4 +- .../org/apache/tamaya/osgi/InitialState.java | 2 +- .../apache/tamaya/osgi/OSGIConfigMapper.java | 2 +- .../org/apache/tamaya/osgi/OperationMode.java | 4 +- .../apache/tamaya/osgi/TamayaConfigPlugin.java | 52 +++-- .../apache/tamaya/osgi/attic/ConfigPrinter.java | 115 ----------- .../tamaya/osgi/attic/ConfigPrinterService.java | 28 --- .../osgi/attic/TamayaConfigAdminImpl.java | 167 ---------------- .../osgi/attic/TamayaOSGIConfiguration.java | 139 ------------- .../tamaya/osgi/commands/BackupCommands.java | 103 ++++++++++ .../tamaya/osgi/commands/ConfigCommands.java | 195 +++++++++++++++++++ .../tamaya/osgi/commands/HistoryCommands.java | 3 +- .../tamaya/osgi/TamayaConfigPluginTest.java | 42 ++-- .../tamaya/felix/shell/BackupCreateCommand.java | 47 ----- .../tamaya/felix/shell/BackupDeleteCommand.java | 42 ---- .../tamaya/felix/shell/BackupListCommand.java | 41 ---- .../tamaya/felix/shell/ConfigCommand.java | 42 ---- .../felix/shell/DefaultDisableCommand.java | 47 ----- .../tamaya/felix/shell/GetPolicyCommand.java | 47 ----- .../felix/shell/HistoryDeleteCommand.java | 42 ---- .../tamaya/felix/shell/HistoryGetCommand.java | 47 ----- .../felix/shell/HistorySizeGetCommand.java | 42 ---- .../felix/shell/HistorySizeSetCommand.java | 47 ----- .../apache/tamaya/felix/shell/InfoCommand.java | 46 ----- .../tamaya/felix/shell/PolicyGetCommand.java | 47 ----- .../tamaya/felix/shell/PolicySetCommand.java | 49 ----- .../tamaya/felix/shell/PropertyGetCommand.java | 50 ----- .../felix/shell/PropertySourcesCommand.java | 42 ---- .../org/apache/tamaya/karaf/shell/commands | 37 ---- .../org/apache/tamaya/gogo/shell/Activator.java | 17 +- .../tamaya/gogo/shell/BackupCommands.java | 8 +- .../tamaya/gogo/shell/ConfigCommands.java | 8 +- .../tamaya/gogo/shell/HistoryCommands.java | 10 +- .../tamaya/gogo/shell/SettingsCommands.java | 19 +- .../tamaya/karaf/shell/BackupCreateCommand.java | 3 +- .../tamaya/karaf/shell/BackupDeleteCommand.java | 3 +- .../tamaya/karaf/shell/BackupListCommand.java | 3 +- .../tamaya/karaf/shell/ConfigCommand.java | 6 +- .../karaf/shell/DefaultDisableCommand.java | 3 +- .../tamaya/karaf/shell/GetPolicyCommand.java | 3 +- .../karaf/shell/HistoryDeleteAllCommand.java | 38 ++++ .../karaf/shell/HistoryDeleteCommand.java | 7 +- .../tamaya/karaf/shell/HistoryGetCommand.java | 5 +- .../karaf/shell/HistoryMaxsizeCommand.java | 3 +- .../karaf/shell/HistoryMaxsizeSetCommand.java | 47 +++++ .../karaf/shell/HistorySizeSetCommand.java | 48 ----- .../apache/tamaya/karaf/shell/InfoCommand.java | 3 +- .../tamaya/karaf/shell/PolicyGetCommand.java | 3 +- .../tamaya/karaf/shell/PolicySetCommand.java | 5 +- .../karaf/shell/PropagateUpdatesCommand.java | 46 +++++ .../karaf/shell/PropagateUpdatesSetCommand.java | 56 ++++++ .../tamaya/karaf/shell/PropertyGetCommand.java | 3 +- .../karaf/shell/PropertySourceCommand.java | 3 +- .../karaf/shell/PropertySourcesCommand.java | 3 +- .../org/apache/tamaya/karaf/shell/commands | 9 +- osgi/pom.xml | 1 + osgi/updater/bnd.bnd | 2 +- .../apache/tamaya/osgi/updater/Activator.java | 21 +- 60 files changed, 642 insertions(+), 1324 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/common/bnd.bnd ---------------------------------------------------------------------- diff --git a/osgi/common/bnd.bnd b/osgi/common/bnd.bnd index 22c802c..af8e245 100644 --- a/osgi/common/bnd.bnd +++ b/osgi/common/bnd.bnd @@ -21,10 +21,11 @@ Bundle-ContactAddress: [email protected] Bundle-DocURL: http://tamaya.apache.org Bundle-Activator: org.apache.tamaya.osgi.Activator Export-Package: \ - org.apache.tamaya.osgi + org.apache.tamaya.osgi,\ + org.apache.tamaya.osgi.commands Import-Package: \ - org.osgi.service.cm,\ org.osgi.framework,\ + org.osgi.service.cm,\ org.apache.tamaya,\ org.apache.tamaya.spi,\ org.apache.tamaya.functions,\ http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigChanger.java ---------------------------------------------------------------------- diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigChanger.java b/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigChanger.java index 1d48fad..f0ecdfb 100644 --- a/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigChanger.java +++ b/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigChanger.java @@ -177,4 +177,8 @@ final class ConfigChanger { } return mapper; } + + public org.apache.tamaya.Configuration getTamayaConfiguration(String pid) { + return configMapper().getConfiguration(pid); + } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 9a2e5a9..756fe98 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 @@ -171,7 +171,7 @@ public final class ConfigHistory implements Serializable{ Base64.getEncoder().encode(bos.toByteArray()); plugin.setConfigValue("history", Base64.getEncoder().encode(bos.toByteArray())); } catch (Exception e) { - LOG.log(Level.WARNING, "Failed to store config change history.", e); + LOG.log(Level.WARNING, "Failed to store getConfig change history.", e); } } @@ -185,7 +185,7 @@ public final class ConfigHistory implements Serializable{ ois.close(); } } catch (Exception e) { - LOG.log(Level.WARNING, "Failed to store config change history.", e); + LOG.log(Level.WARNING, "Failed to store getConfig change history.", e); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/common/src/main/java/org/apache/tamaya/osgi/InitialState.java ---------------------------------------------------------------------- diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/InitialState.java b/osgi/common/src/main/java/org/apache/tamaya/osgi/InitialState.java index 0a0de21..9cc0a4a 100644 --- a/osgi/common/src/main/java/org/apache/tamaya/osgi/InitialState.java +++ b/osgi/common/src/main/java/org/apache/tamaya/osgi/InitialState.java @@ -104,7 +104,7 @@ public final class InitialState { ois.close(); } } catch (Exception e) { - LOG.log(Level.WARNING, "Failed to store config change history.", e); + LOG.log(Level.WARNING, "Failed to store getConfig change history.", e); } } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/common/src/main/java/org/apache/tamaya/osgi/OSGIConfigMapper.java ---------------------------------------------------------------------- diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/OSGIConfigMapper.java b/osgi/common/src/main/java/org/apache/tamaya/osgi/OSGIConfigMapper.java index 3841d4b..2e90436 100644 --- a/osgi/common/src/main/java/org/apache/tamaya/osgi/OSGIConfigMapper.java +++ b/osgi/common/src/main/java/org/apache/tamaya/osgi/OSGIConfigMapper.java @@ -31,7 +31,7 @@ public interface OSGIConfigMapper { * default implemented) a configuration mapping for {@code pid/factoryPid==myBundle} could be {@code [bundle:myBundle]}. * This mapping is used as a prefix when collecting the corresponding entries for the OSGI configuration. * @param pid the OSGI pid, or null - * @return return the corresponding config root section. For ommitting any root section simply return an empty + * @return return the corresponding getConfig root section. For ommitting any root section simply return an empty * String. */ Configuration getConfiguration(String pid); http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/common/src/main/java/org/apache/tamaya/osgi/OperationMode.java ---------------------------------------------------------------------- diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/OperationMode.java b/osgi/common/src/main/java/org/apache/tamaya/osgi/OperationMode.java index 4489892..67c85e1 100644 --- a/osgi/common/src/main/java/org/apache/tamaya/osgi/OperationMode.java +++ b/osgi/common/src/main/java/org/apache/tamaya/osgi/OperationMode.java @@ -19,10 +19,10 @@ package org.apache.tamaya.osgi; /** - * Operation mode applied to the config read. + * Operation mode applied to the getConfig read. */ public enum OperationMode{ - /** Only add properties not existing in the config. */ + /** Only add properties not existing in the getConfig. */ EXTEND, /** Override existing properties and add new properties. */ OVERRIDE, http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 ad964b1..a4ed082 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 @@ -38,6 +38,7 @@ public class TamayaConfigPlugin implements BundleListener, ServiceListener{ /** the logger. */ private static final Logger LOG = Logger.getLogger(TamayaConfigPlugin.class.getName()); private static final String TAMAYA_DISABLED = "tamaya.disabled"; + private static final String TAMAYA_AUTO_UPDATE_ENABLED = "tamaya.autoUpdateEnabled"; public static final String TAMAYA_DISABLED_KEY = "Tamaya-Disabled"; public static final String TAMAYA_ENABLED_KEY = "Tamaya-Enabled"; public static final String TAMAYA_PID_KEY = "Tamaya-PID"; @@ -45,6 +46,7 @@ public class TamayaConfigPlugin implements BundleListener, ServiceListener{ private OperationMode defaultOpMode = OperationMode.OVERRIDE; private ConfigChanger configChanger; + private boolean autoUpdateEnabled; @Override public void serviceChanged(ServiceEvent event) { @@ -61,7 +63,7 @@ public class TamayaConfigPlugin implements BundleListener, ServiceListener{ /** - * Create a new config. + * Create a new getConfig. * @param context the OSGI context */ TamayaConfigPlugin(BundleContext context) { @@ -69,10 +71,16 @@ public class TamayaConfigPlugin implements BundleListener, ServiceListener{ InitialState.restore(this); ConfigHistory.restore(this); initDefaultEnabled(); + initAutoUpdateEnabled(); initDefaultOpMode(); initConfigs(); } + public void setAutoUpdateEnabled(boolean enabled){ + this.autoUpdateEnabled = enabled; + setConfigValue(TAMAYA_AUTO_UPDATE_ENABLED, enabled); + } + public void setDefaultDisabled(boolean disabled){ this.disabled = disabled; setConfigValue(TAMAYA_DISABLED, disabled); @@ -96,8 +104,6 @@ public class TamayaConfigPlugin implements BundleListener, ServiceListener{ switch(event.getType()){ case BundleEvent.STARTING: case BundleEvent.LAZY_ACTIVATION: -// case BundleEvent.UPDATED: -// TODO add checks for preventing endlee loop for updates here... configureBundle(event.getBundle()); break; } @@ -131,7 +137,7 @@ public class TamayaConfigPlugin implements BundleListener, ServiceListener{ } public void updateConfig(String pid) { - LOG.fine("Updating config for pid...: " + pid); + LOG.fine("Updating getConfig for pid...: " + pid); configChanger.configure(pid, null, defaultOpMode); InitialState.save(this); ConfigHistory.save(this); @@ -176,19 +182,30 @@ public class TamayaConfigPlugin implements BundleListener, ServiceListener{ return true; } + private void initAutoUpdateEnabled() { + String enabledVal = (String)getConfigValue(TAMAYA_AUTO_UPDATE_ENABLED); + if(enabledVal!=null){ + this.autoUpdateEnabled = Boolean.parseBoolean(enabledVal); + } + if(this.autoUpdateEnabled) { + LOG.info("Tamaya Automatic Config Updating is enabled."); + }else{ + LOG.info("Tamaya Automatic Config Updating is disabled."); + } + } private void initDefaultEnabled() { - String disabledVal = (String)getConfigValue("tamaya.disabled"); + String disabledVal = (String)getConfigValue(TAMAYA_DISABLED); if(disabledVal==null){ - disabledVal = System.getProperty("tamaya.disabled"); + disabledVal = System.getProperty(TAMAYA_DISABLED); } if(disabledVal!=null){ this.disabled = Boolean.parseBoolean(disabledVal); - if(this.disabled) { - LOG.info("Tamaya Config is disabled by default. Add Tamaya-Enabled to your bundle manifests to enable it."); - }else{ - LOG.info("Tamaya Config is enabled by default. Add Tamaya-Disabled to your bundle manifests to disable it."); - } + } + if(this.disabled) { + LOG.info("Tamaya Config is disabled by default. Add Tamaya-Enabled to your bundle manifests to enable it."); + }else{ + LOG.info("Tamaya Config is enabled by default. Add Tamaya-Disabled to your bundle manifests to disable it."); } } @@ -220,9 +237,9 @@ public class TamayaConfigPlugin implements BundleListener, ServiceListener{ props.put(key, value); config.update(props); } - LOG.finest("Updated Tamaya Plugin config: "+key + "=" + value); + LOG.finest("Updated Tamaya Plugin getConfig: "+key + "=" + value); } catch (IOException e) { - LOG.log(Level.WARNING, "Error writing Tamaya config.", e); + LOG.log(Level.WARNING, "Error writing Tamaya getConfig.", e); } } @@ -239,10 +256,17 @@ public class TamayaConfigPlugin implements BundleListener, ServiceListener{ return props.get(key); } } catch (IOException e) { - LOG.log(Level.WARNING, "Error reading Tamaya config.", e); + LOG.log(Level.WARNING, "Error reading Tamaya getConfig.", e); } return null; } + public org.apache.tamaya.Configuration getTamayaConfiguration(String pid) { + return configChanger.getTamayaConfiguration(pid); + } + + public boolean isAutoUpdateEnabled() { + return autoUpdateEnabled; + } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/common/src/main/java/org/apache/tamaya/osgi/attic/ConfigPrinter.java ---------------------------------------------------------------------- diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/attic/ConfigPrinter.java b/osgi/common/src/main/java/org/apache/tamaya/osgi/attic/ConfigPrinter.java deleted file mode 100644 index 519ea04..0000000 --- a/osgi/common/src/main/java/org/apache/tamaya/osgi/attic/ConfigPrinter.java +++ /dev/null @@ -1,115 +0,0 @@ -///* -// * Licensed to the Apache Software Foundation (ASF) under one -// * or more contributor license agreements. See the NOTICE file -// * distributed with this work for additional information -// * regarding copyright ownership. The ASF licenses this file -// * to you under the Apache License, Version 2.0 (the -// * "License"); you may not use this file except in compliance -// * with the License. You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, -// * software distributed under the License is distributed on an -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// * KIND, either express or implied. See the License for the -// * specific language governing permissions and limitations -// * under the License. -// */ -//package org.apache.tamaya.osgi; -// -//import org.osgi.service.cm.ConfigurationAdmin; -//import org.osgi.service.component.annotations.*; -// -//import java.util.Map; -//import java.util.concurrent.ExecutorService; -//import java.util.concurrent.Executors; -//import java.util.logging.Logger; -// -///** -// * Created by atsticks on 06.09.17. -// */ -//@Component(name = ConfigPrinter.COMPONENT_NAME, -// configurationPolicy = ConfigurationPolicy.OPTIONAL, -// configurationPid = ConfigPrinter.COMPONENT_NAME, -// service = ConfigPrinterService.class) -//public class ConfigPrinter implements ConfigPrinterService { -// -// public static final String COMPONENT_NAME = "ConfigPrinter"; -// public static final String COMPONENT_LABEL = "Managed ConfigPrinter Service"; -// -// private static final Logger LOG = Logger.getLogger(ConfigPrinter.class.getName()); -// -// private static ExecutorService executor = Executors.newCachedThreadPool(); -// private Worker worker = new Worker(); -// -// private ConfigurationAdmin cm; -// -// @Reference -// void setConfigurationAdmin(ConfigurationAdmin cm) { -// this.cm = cm; -// } -// -// /** -// * Called when all of the SCR Components required dependencies have been -// * satisfied. -// */ -// @Activate -// @Modified -// public void updateConfig(final Map<String,String> properties) { -// LOG.info("Activating the " + COMPONENT_LABEL); -// if(properties!=null) { -// worker.setConfig(properties.toString()); -// }else{ -// worker.setConfig("no config."); -// } -// } -// -// /** -// * Called when any of the SCR Components required dependencies become -// * unsatisfied. -// */ -// @Deactivate -// public void deactivate() { -// LOG.info("Deactivating the " + COMPONENT_LABEL); -// } -// -// @Override -// public void startPrinter() { -// executor.execute(worker); -// } -// -// @Override -// public void stopPrinter() { -// if (!executor.isTerminated()) { -// executor.shutdownNow(); -// } -// } -// -// /** -// * Thread worker that continuously prints a message. -// */ -// private static class Worker implements Runnable { -// -// private String config; -// -// public void run() { -// boolean running = true; -// int messageCount = 0; -// while (running) { -// try { -// LOG.info("Config " + (++messageCount) + ": " + config); -// Thread.sleep(1000); -// } catch (InterruptedException e) { -// running = false; -// LOG.info("Thread shutting down"); -// } -// } -// } -// -// public void setConfig(String config) { -// this.config = config; -// } -// -// } -//} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/common/src/main/java/org/apache/tamaya/osgi/attic/ConfigPrinterService.java ---------------------------------------------------------------------- diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/attic/ConfigPrinterService.java b/osgi/common/src/main/java/org/apache/tamaya/osgi/attic/ConfigPrinterService.java deleted file mode 100644 index 9eb7033..0000000 --- a/osgi/common/src/main/java/org/apache/tamaya/osgi/attic/ConfigPrinterService.java +++ /dev/null @@ -1,28 +0,0 @@ -///* -// * Licensed to the Apache Software Foundation (ASF) under one -// * or more contributor license agreements. See the NOTICE file -// * distributed with this work for additional information -// * regarding copyright ownership. The ASF licenses this file -// * to you under the Apache License, Version 2.0 (the -// * "License"); you may not use this file except in compliance -// * with the License. You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, -// * software distributed under the License is distributed on an -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// * KIND, either express or implied. See the License for the -// * specific language governing permissions and limitations -// * under the License. -// */ -//package org.apache.tamaya.osgi; -// -///** -// * Created by atsticks on 06.09.17. -// */ -//public interface ConfigPrinterService { -// void startPrinter(); -// -// void stopPrinter(); -//} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/common/src/main/java/org/apache/tamaya/osgi/attic/TamayaConfigAdminImpl.java ---------------------------------------------------------------------- diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/attic/TamayaConfigAdminImpl.java b/osgi/common/src/main/java/org/apache/tamaya/osgi/attic/TamayaConfigAdminImpl.java deleted file mode 100644 index 757c3be..0000000 --- a/osgi/common/src/main/java/org/apache/tamaya/osgi/attic/TamayaConfigAdminImpl.java +++ /dev/null @@ -1,167 +0,0 @@ -///* -// * Licensed to the Apache Software Foundation (ASF) under one -// * or more contributor license agreements. See the NOTICE file -// * distributed with this work for additional information -// * regarding copyright ownership. The ASF licenses this file -// * to you under the Apache License, Version 2.0 (the -// * "License"); you may not use this file except in compliance -// * with the License. You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, -// * software distributed under the License is distributed on an -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// * KIND, either express or implied. See the License for the -// * specific language governing permissions and limitations -// * under the License. -// */ -//package org.apache.tamaya.osgi; -// -//import java.io.IOException; -//import java.util.*; -//import java.util.concurrent.ConcurrentHashMap; -//import java.util.logging.Level; -//import java.util.logging.Logger; -// -//import org.osgi.framework.BundleContext; -//import org.osgi.framework.Filter; -//import org.osgi.framework.InvalidSyntaxException; -//import org.osgi.framework.ServiceReference; -//import org.osgi.service.cm.Configuration; -//import org.osgi.service.cm.ConfigurationAdmin; -// -///** -// * Tamaya based implementation of an OSGI {@link ConfigurationAdmin}. -// */ -//public class TamayaConfigAdminImpl implements ConfigurationAdmin { -// /** the logger. */ -// private static final Logger LOG = Logger.getLogger(TamayaConfigAdminImpl.class.getName()); -// -// /** The OSGI context. */ -// private final BundleContext context; -// /** The cached configurations. */ -// private Map<String,Configuration> configs = new ConcurrentHashMap<>(); -// /** The configuration section mapper. */ -// private OSGIConfigMapper configRootMapper; -// -// /** -// * Create a new config. -// * @param context the OSGI context -// */ -// TamayaConfigAdminImpl(BundleContext context) { -// this.context = context; -// this.configRootMapper = loadConfigRootMapper(); -// } -// -// @Override -// public Configuration createFactoryConfiguration(String factoryPid) throws IOException { -// return createFactoryConfiguration(factoryPid, null); -// } -// -// @Override -// public Configuration createFactoryConfiguration(String factoryPid, String location) throws IOException { -// String key = "factory:"+factoryPid; -// if(location!=null){ -// key += "::"+location; -// } -// Configuration config = this.configs.get(key); -// if (config == null) { -// Dictionary<String, Object> parentConfig = getParentConfig(null, factoryPid, location); -// config = new TamayaOSGIConfiguration(null, factoryPid, configRootMapper, parentConfig); -// this.configs.put(key, config); -// } -// return config; -// } -// -// @Override -// public Configuration getConfiguration(String pid, String location) throws IOException { -// String key = "config:"+pid; -// if(location!=null){ -// key += "::"+location; -// } -// Configuration config = this.configs.get(key); -// if (config == null) { -// Dictionary<String, Object> parentConfig = getParentConfig(pid, null, location); -// config = new TamayaOSGIConfiguration(pid, null, configRootMapper, parentConfig); -// this.configs.put(key, config); -// } -// return config; -// } -// -// @Override -// public Configuration getConfiguration(String pid) throws IOException { -// return getConfiguration(pid, null); -// } -// -// private Dictionary<String, Object> getParentConfig(String pid, String factoryPid, String location) { -// Dictionary<String, Object> parentConfig = null; -// if (context != null) { -// try { -// ServiceReference[] refs = context.getAllServiceReferences(ConfigurationAdmin.class.getName(), null); -// for (ServiceReference<ConfigurationAdmin> ref : refs) { -// ConfigurationAdmin parentCand = context.getService(ref); -// if (parentCand != null && !(parentCand instanceof TamayaConfigAdminImpl)) { -// try { -// parentConfig = parentCand.getConfiguration(pid, factoryPid).getProperties(); -// } catch (IOException e) { -// LOG.log(Level.WARNING, "Error reading parent OSGI config.", e); -// } -// } -// } -// } catch (Exception e) { -// LOG.log(Level.SEVERE, "Cannot not evaluate parent/base OSGI config.", e); -// } -// } -// return parentConfig; -// } -// -// @Override -// public Configuration[] listConfigurations(String filter) throws IOException, InvalidSyntaxException { -// List<Configuration> result = new ArrayList<>(); -// if (filter == null || context == null) { -// return this.configs.values().toArray(new Configuration[this.configs.size()]); -// } else { -// Filter flt = context.createFilter(filter); -// for(Configuration config:this.configs.values()) { -// if (flt.match(config.getProperties())) { -// result.add(config); -// } -// } -// return result.toArray(new Configuration[result.size()]); -// } -// } -// -// /** -// * Loads the configuration toor mapper using the OSGIConfigRootMapper OSGI service resolving mechanism. If no -// * such service is available it loads the default mapper. -// * @return the mapper to be used, bever null. -// */ -// private OSGIConfigMapper loadConfigRootMapper() { -// OSGIConfigMapper mapper = null; -// if(context!=null) { -// ServiceReference<OSGIConfigMapper> ref = context.getServiceReference(OSGIConfigMapper.class); -// if (ref != null) { -// mapper = context.getService(ref); -// } -// } -// if(mapper==null){ -// mapper = new OSGIConfigMapper() { -// @Override -// public String getTamayaConfigRoot(String pid, String factoryPid) { -// if(pid!=null) { -// return "[" + pid +']'; -// } else{ -// return "[" + factoryPid +']'; -// } -// } -// @Override -// public String toString(){ -// return "Default OSGIConfigRootMapper(pid -> [bundle:pid], factoryPid -> [bundle:factoryPid]"; -// } -// }; -// } -// return mapper; -// } -// -//} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/common/src/main/java/org/apache/tamaya/osgi/attic/TamayaOSGIConfiguration.java ---------------------------------------------------------------------- diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/attic/TamayaOSGIConfiguration.java b/osgi/common/src/main/java/org/apache/tamaya/osgi/attic/TamayaOSGIConfiguration.java deleted file mode 100644 index dfadfb8..0000000 --- a/osgi/common/src/main/java/org/apache/tamaya/osgi/attic/TamayaOSGIConfiguration.java +++ /dev/null @@ -1,139 +0,0 @@ -///* -// * Licensed to the Apache Software Foundation (ASF) under one -// * or more contributor license agreements. See the NOTICE file -// * distributed with this work for additional information -// * regarding copyright ownership. The ASF licenses this file -// * to you under the Apache License, Version 2.0 (the -// * "License"); you may not use this file except in compliance -// * with the License. You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, -// * software distributed under the License is distributed on an -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// * KIND, either express or implied. See the License for the -// * specific language governing permissions and limitations -// * under the License. -// */ -//package org.apache.tamaya.osgi; -// -//import java.io.IOException; -//import java.util.*; -//import java.util.logging.Logger; -// -//import org.apache.tamaya.ConfigurationProvider; -//import org.apache.tamaya.functions.ConfigurationFunctions; -//import org.osgi.service.cm.Configuration; -// -///** -// * Tamaya based implementation of an OSGI {@link Configuration}. -// */ -//public class TamayaOSGIConfiguration implements Configuration { -// private static final Logger LOG = Logger.getLogger(TamayaOSGIConfiguration.class.getName()); -// private final Dictionary<String, Object> parentConfig; -// private final String pid; -// private final String factoryPid; -// private OSGIConfigMapper rootMapper; -// private boolean overriding = true; -// private String bundleLocation; -// -// /** -// * Constructor. -// * @param confPid the OSGI pid -// * @param factoryPid the factory pid -// * @param configRootMapper the mapper that maps the pids to a tamaya root section. -// * @param parentConfig the OSGI config for the given context, may be null.. -// */ -// TamayaOSGIConfiguration(String confPid, String factoryPid, OSGIConfigMapper configRootMapper, -// Dictionary<String, Object> parentConfig) { -// this.pid = confPid; -// this.factoryPid = factoryPid; -// this.parentConfig = parentConfig; -// this.rootMapper = Objects.requireNonNull(configRootMapper); -// } -// -// public boolean isOverriding() { -// return overriding; -// } -// -// public void setOverriding(boolean overriding){ -// this.overriding = overriding; -// } -// -// @Override -// public String getPid() { -// return pid; -// } -// -// @Override -// public Dictionary<String, Object> getProperties() { -// Dictionary<String, Object> properties = new Hashtable<>(); -// -// final String rootKey = this.rootMapper.getTamayaConfigRoot(pid, factoryPid); -// LOG.info("Configuration: Evaluating Tamaya configuration for '" + rootKey + "'."); -// org.apache.tamaya.Configuration tamayConfig = ConfigurationProvider.getConfiguration(); -// if(overriding){ -// if(parentConfig!=null) { -// putAll(properties, parentConfig); -// } -// putAll(properties, tamayConfig.with(ConfigurationFunctions.section(rootKey, true)).getProperties()); -// }else{ -// putAll(properties, tamayConfig.with(ConfigurationFunctions.section(rootKey, true)).getProperties()); -// if(parentConfig!=null) { -// putAll(properties, parentConfig); -// } -// } -// return properties; -// } -// -// private void putAll(Dictionary<String, Object> target, Dictionary<String, Object> data) { -// Enumeration<String> keys = data.keys(); -// while(keys.hasMoreElements()){ -// String key = keys.nextElement(); -// target.put(key, data.get(key)); -// } -// } -// -// private void putAll(Dictionary<String, Object> target, Map<String, String> data) { -// for(Map.Entry<String,String> en:data.entrySet()){ -// target.put(en.getKey(), en.getValue()); -// } -// } -// -// @Override -// public void update(Dictionary<String, ?> properties) throws IOException { -// throw new UnsupportedOperationException("Mutability is not supported."); -// } -// -// @Override -// public void delete() throws IOException { -// throw new UnsupportedOperationException(); -// } -// -// @Override -// public String getFactoryPid() { -// return factoryPid; -// } -// -// @Override -// public void update() throws IOException { -// // Nothing to do since, we load everything dynamically. -// } -// -// @Override -// public void setBundleLocation(String location) { -// this.bundleLocation = location; -// } -// -// @Override -// public String getBundleLocation() { -// return this.bundleLocation; -// } -// -// @Override -// public long getChangeCount() { -// return 0; -// } -// -//} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 new file mode 100644 index 0000000..ee1b299 --- /dev/null +++ b/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/BackupCommands.java @@ -0,0 +1,103 @@ +/* + * 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.InitialState; +import org.osgi.service.cm.Configuration; +import org.osgi.service.cm.ConfigurationAdmin; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Dictionary; +import java.util.Enumeration; +import java.util.Map; + + +/** + * Utility class implementing the available backup related commands. + */ +public final class BackupCommands { + + /** Singleton constructor. */ + private BackupCommands(){} + + public static String createBackup(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 || !InitialState.contains(pid)){ + InitialState.set(pid, props); + return "Backup created, PID = " + pid + '\n' + + printProps(props); + } + } + } + return "No Config found, PID = " + pid; + } + + public static String deleteBackup(String pid) throws IOException { + if("*".equals(pid)){ + InitialState.removeAll(); + return "All Backups deleted."; + }else { + InitialState.remove(pid); + return "Backup deleted: " + pid; + } + } + + public static String listBackup(String pid) throws IOException { + if(pid!=null){ + Dictionary<String, ?> props = InitialState.get(pid); + if(props==null){ + return "No backup found: " + pid; + }else{ + return "PID: " + pid + '\n' + + printProps(props); + } + }else { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + for(Map.Entry<String, Dictionary<String,?>> en: InitialState.get().entrySet()){ + pw.println("PID: " + en.getKey()); + pw.println(printProps(en.getValue())); + } + return sw.toString(); + } + } + + public static String printProps(Dictionary<String, ?> props) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + pw.println(StringUtil.format(" Key", 50)); + pw.println(StringUtil.format(" Value", 50)); + pw.println(" " + StringUtil.printRepeat("-", 100)); + Enumeration<String> keys = props.keys(); + while(keys.hasMoreElements()){ + String key = keys.nextElement(); + pw.print(" " + StringUtil.format(key, 50)); + pw.println(" " + StringUtil.format(String.valueOf(props.get(key)), 50)); + } + pw.println(); + pw.flush(); + return sw.toString(); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 new file mode 100644 index 0000000..ae06a18 --- /dev/null +++ b/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/ConfigCommands.java @@ -0,0 +1,195 @@ +/* + * 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.Configuration; +import org.apache.tamaya.ConfigurationProvider; +import org.apache.tamaya.functions.ConfigurationFunctions; +import org.apache.tamaya.osgi.OperationMode; +import org.apache.tamaya.osgi.TamayaConfigPlugin; +import org.apache.tamaya.spi.PropertySource; +import org.apache.tamaya.spi.PropertyValue; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.List; + +/** + * Utility class implementing the available configuration related commands. + */ +public final class ConfigCommands { + + /** Singleton constructor. */ + private ConfigCommands(){} + + public static String getInfo(TamayaConfigPlugin configPlugin) throws IOException { + Configuration config = ConfigurationProvider.getConfiguration(); + return config.toString() + "\n\n" + + StringUtil.format("Default OperationMode:", 30) + configPlugin.getDefaultOperationMode() + '\n' + + StringUtil.format("Default Disabled: ", 30) + configPlugin.isDefaultDisabled(); + } + + public static String readConfig(String section) { + Configuration config = ConfigurationProvider.getConfiguration(); + if(section!=null){ + return config + .with(ConfigurationFunctions.section(section)) + .query(ConfigurationFunctions.textInfo()); + } + return config.query(ConfigurationFunctions.textInfo()); + } + + public static String readConfig(TamayaConfigPlugin configPlugin, String pid, String section) { + Configuration config = null; + if(pid!=null){ + config = configPlugin.getTamayaConfiguration(pid); + if(config==null){ + return "No Tamaya Config found for PID: " + pid; + } + }else { + config = ConfigurationProvider.getConfiguration(); + } + if(section!=null){ + return config + .with(ConfigurationFunctions.section(section)) + .query(ConfigurationFunctions.textInfo()); + } + return config.query(ConfigurationFunctions.textInfo()); + } + + public static String getDefaultOpPolicy(TamayaConfigPlugin configPlugin) throws IOException { + return String.valueOf(configPlugin.getDefaultOperationMode()); + } + + public static String setDefaultOpPolicy(TamayaConfigPlugin configPlugin, String policy) throws IOException { + OperationMode opMode = OperationMode.valueOf(policy); + configPlugin.setDefaultOperationMode(opMode); + return "OperationMode="+opMode.toString(); + } + + public static String getProperty(String propertysource, String key, boolean extended) throws IOException { + Configuration config = ConfigurationProvider.getConfiguration(); + if(propertysource!=null){ + PropertySource ps = config.getContext().getPropertySource(propertysource); + if(ps==null){ + return "ERR: No such propertysource: " + propertysource; + }else { + PropertyValue val = ps.get(key); + if(val==null){ + return "ERR: PropertySource: " + propertysource + " - undefined key: " + key; + }else { + if(extended) { + return StringUtil.format("PropertySource", 25) + StringUtil.format("Value", 25) + '\n' + + StringUtil.format(propertysource, 25) + StringUtil.format(val.getValue(), 55); + }else{ + return val.getValue(); + } + } + } + }else{ + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + pw.println(StringUtil.format("PropertySource", 25) + StringUtil.format("Value", 25)); + for(PropertySource ps:config.getContext().getPropertySources()){ + PropertyValue val = ps.get(key); + if(val!=null){ + if(extended) { + pw.println(StringUtil.format(propertysource, 25) + StringUtil.format(val.toString(), 55)); + }else{ + pw.println(StringUtil.format(propertysource, 25) + StringUtil.format(val.getValue(), 55)); + } + } + } + pw.flush(); + return sw.toString(); + } + } + + public static String getPropertySource(String propertysource) throws IOException { + Configuration config = ConfigurationProvider.getConfiguration(); + if(propertysource!=null){ + PropertySource ps = config.getContext().getPropertySource(propertysource); + if(ps==null){ + return "No such propertysource: " + propertysource; + }else { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + pw.println(StringUtil.format("ID:", 20) + ps.getName()); + pw.println(StringUtil.format("Ordinal:", 20) + ps.getOrdinal()); + pw.println(StringUtil.format("Class:", 20) + ps.getClass().getName()); + pw.println("Properties:"); + pw.print(StringUtil.format(" Key", 20)); + pw.print(StringUtil.format("Value", 20)); + pw.print(StringUtil.format("Source", 20)); + pw.println(StringUtil.format("Meta-Entries", 20)); + pw.println(StringUtil.printRepeat("-", 80)); + for(PropertyValue pv:ps.getProperties().values()) { + pw.print(" " + StringUtil.format(pv.getKey(), 20)); + pw.print(StringUtil.format(pv.getValue(), 20)); + pw.print(StringUtil.format(pv.getSource(), 20)); + pw.println(StringUtil.format(pv.getMetaEntries().toString(), 80)); + } + pw.flush(); + return sw.toString(); + } + } + // Get a name of existing propertysources + List<String> result = new ArrayList<>(); + for(PropertySource ps:config.getContext().getPropertySources()){ + result.add(ps.getName()); + } + StringBuilder b = new StringBuilder("Please select a property source:\n"); + for(String name:result){ + b.append(name).append('\n'); + } + return b.toString(); + } + + public static String getPropertySourceOverview() throws IOException { + Configuration config = ConfigurationProvider.getConfiguration(); + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + pw.print(StringUtil.format("ID", 20)); + pw.print(StringUtil.format("Ordinal", 20)); + pw.print(StringUtil.format("Class", 40)); + pw.println(StringUtil.format("Property Count", 5)); + pw.println(StringUtil.printRepeat("-", 80)); + for(PropertySource ps:config.getContext().getPropertySources()){ + pw.print(StringUtil.format(ps.getName(), 20)); + pw.print(StringUtil.format(String.valueOf(ps.getOrdinal()), 20)); + pw.print(StringUtil.format(ps.getClass().getName(), 40)); + pw.println(StringUtil.format(String.valueOf(ps.getProperties().size()), 5)); + pw.println("---"); + } + pw.flush(); + return sw.toString(); + } + + public static String setDefaultDisabled(TamayaConfigPlugin configPlugin, boolean disabled) throws IOException { + configPlugin.setDefaultDisabled(disabled); + return disabled?"Tamaya is disabled by default.":"Tamaya is enabled by default."; + } + + public static String setAutoUpdateEnabled(TamayaConfigPlugin configPlugin, boolean enabled) { + configPlugin.setAutoUpdateEnabled(enabled); + return "tamaya.autoUpdate="+enabled; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 ce73423..6429e8d 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 @@ -62,7 +62,8 @@ public final class HistoryCommands{ pw.print(StringUtil.format(String.valueOf(h.getValue()), 40)); pw.println(String.valueOf(h.getPreviousValue())); } - return pw.toString(); + pw.flush(); + return sw.toString(); } public static int getMaxHistorySize(){ http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 723c3d5..704a98e 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 @@ -32,38 +32,38 @@ public class TamayaConfigPluginTest { @Test public void createConfigurationOverride() throws Exception { -// Configuration config = configAdmin.createFactoryConfiguration("tamaya"); -// assertNotNull(config); -// assertFalse(config.getProperties().isEmpty()); -// assertEquals(config.getProperties().size(), 4); -// assertEquals(config.getProperties().get("my.testProperty1"), "success1"); +// Configuration getConfig = configAdmin.createFactoryConfiguration("tamaya"); +// assertNotNull(getConfig); +// assertFalse(getConfig.getProperties().isEmpty()); +// assertEquals(getConfig.getProperties().size(), 4); +// assertEquals(getConfig.getProperties().get("my.testProperty1"), "success1"); } // // @Test // public void createFactoryConfigurationWithLocation() throws Exception { -// Configuration config = configAdmin.createFactoryConfiguration("tamaya", "location"); -// assertNotNull(config); -// assertFalse(config.getProperties().isEmpty()); -// assertEquals(config.getProperties().size(), 4); -// assertEquals(config.getProperties().get("my.testProperty2"), "success2"); +// Configuration getConfig = configAdmin.createFactoryConfiguration("tamaya", "location"); +// assertNotNull(getConfig); +// assertFalse(getConfig.getProperties().isEmpty()); +// assertEquals(getConfig.getProperties().size(), 4); +// assertEquals(getConfig.getProperties().get("my.testProperty2"), "success2"); // } // // @Test -// public void getConfiguration() throws Exception { -// Configuration config = configAdmin.getConfiguration("tamaya"); -// assertNotNull(config); -// assertFalse(config.getProperties().isEmpty()); -// assertEquals(config.getProperties().size(), 4); -// assertEquals(config.getProperties().get("my.testProperty3"), "success3"); +// public void getTamayaConfiguration() throws Exception { +// Configuration getConfig = configAdmin.getTamayaConfiguration("tamaya"); +// assertNotNull(getConfig); +// assertFalse(getConfig.getProperties().isEmpty()); +// assertEquals(getConfig.getProperties().size(), 4); +// assertEquals(getConfig.getProperties().get("my.testProperty3"), "success3"); // } // // @Test // public void getConfigurationWithLocation() throws Exception { -// Configuration config = configAdmin.getConfiguration("tamaya", "location"); -// assertNotNull(config); -// assertFalse(config.getProperties().isEmpty()); -// assertEquals(config.getProperties().size(), 4); -// assertEquals(config.getProperties().get("my.testProperty4"), "success4"); +// Configuration getConfig = configAdmin.getTamayaConfiguration("tamaya", "location"); +// assertNotNull(getConfig); +// assertFalse(getConfig.getProperties().isEmpty()); +// assertEquals(getConfig.getProperties().size(), 4); +// assertEquals(getConfig.getProperties().get("my.testProperty4"), "success4"); // } // // @Test http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/BackupCreateCommand.java ---------------------------------------------------------------------- diff --git a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/BackupCreateCommand.java b/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/BackupCreateCommand.java deleted file mode 100644 index df40327..0000000 --- a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/BackupCreateCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.felix.shell; - -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.Service; -import org.apache.tamaya.osgi.commands.BackupCommands; -import org.osgi.service.cm.ConfigurationAdmin; -import org.osgi.service.component.annotations.Component; - -import java.io.IOException; - -@Component( - immediate = true, - property = { - "osgi.command.scope=tamaya:backup-create", - "osgi.command.function=create" - }, - service=BackupCreateCommand.class -) -@Service -public class BackupCreateCommand{ - - @Reference - ConfigurationAdmin cm; - - public Object create(String pid, boolean replace) throws IOException { - return BackupCommands.createBackup(cm, pid, replace); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/BackupDeleteCommand.java ---------------------------------------------------------------------- diff --git a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/BackupDeleteCommand.java b/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/BackupDeleteCommand.java deleted file mode 100644 index c7c8c79..0000000 --- a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/BackupDeleteCommand.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.felix.shell; - -import org.apache.felix.scr.annotations.Service; -import org.apache.tamaya.osgi.commands.BackupCommands; -import org.osgi.service.component.annotations.Component; - -import java.io.IOException; - -@Component( - immediate = true, - property = { - "osgi.command.scope=tamaya:backup-delete", - "osgi.command.function=delete" - }, - service=BackupDeleteCommand.class -) -@Service -public class BackupDeleteCommand{ - - public String execute(String pid) throws IOException { - return (BackupCommands.deleteBackup(pid)); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/BackupListCommand.java ---------------------------------------------------------------------- diff --git a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/BackupListCommand.java b/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/BackupListCommand.java deleted file mode 100644 index fec62ee..0000000 --- a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/BackupListCommand.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.felix.shell; - -import org.apache.felix.scr.annotations.Service; -import org.apache.tamaya.osgi.commands.BackupCommands; -import org.osgi.service.component.annotations.Component; - -import java.io.IOException; - -@Component( - immediate = true, - property = { - "osgi.command.scope=tamaya:backup-list", - "osgi.command.function=list" - }, - service=BackupListCommand.class -) -@Service -public class BackupListCommand{ - public String list(String pid) throws IOException { - return BackupCommands.listBackup(pid); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/ConfigCommand.java ---------------------------------------------------------------------- diff --git a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/ConfigCommand.java b/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/ConfigCommand.java deleted file mode 100644 index b4ce576..0000000 --- a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/ConfigCommand.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.felix.shell; - -import org.apache.felix.scr.annotations.Service; -import org.apache.tamaya.osgi.commands.ConfigCommands; -import org.osgi.service.component.annotations.Component; - -import java.io.IOException; - -@Component( - immediate = true, - property = { - "osgi.command.scope=tamaya:config", - "osgi.command.function=config" - }, - service=ConfigCommand.class -) -@Service -public class ConfigCommand{ - - public String config(String section) throws IOException { - return (ConfigCommands.readConfig(section)); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/DefaultDisableCommand.java ---------------------------------------------------------------------- diff --git a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/DefaultDisableCommand.java b/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/DefaultDisableCommand.java deleted file mode 100644 index b390933..0000000 --- a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/DefaultDisableCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.felix.shell; - -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.Service; -import org.apache.tamaya.osgi.TamayaConfigPlugin; -import org.apache.tamaya.osgi.commands.ConfigCommands; -import org.osgi.service.component.annotations.Component; - -import java.io.IOException; - -@Component( - immediate = true, - property = { - "osgi.command.scope=tamaya:disable-by-default", - "osgi.command.function=disable" - }, - service=DefaultDisableCommand.class -) -@Service -public class DefaultDisableCommand{ - - @Reference - private TamayaConfigPlugin configPlugin; - - public String disable(boolean disabled) throws IOException { - return(ConfigCommands.setDefaultDisabled(configPlugin, disabled)); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/GetPolicyCommand.java ---------------------------------------------------------------------- diff --git a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/GetPolicyCommand.java b/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/GetPolicyCommand.java deleted file mode 100644 index c75ec34..0000000 --- a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/GetPolicyCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.felix.shell; - -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.Service; -import org.apache.tamaya.osgi.TamayaConfigPlugin; -import org.apache.tamaya.osgi.commands.ConfigCommands; -import org.osgi.service.component.annotations.Component; - -import java.io.IOException; - -@Component( - immediate = true, - property = { - "osgi.command.scope=tamaya:default-policy", - "osgi.command.function=defaultOpPolicy" - }, - service=GetPolicyCommand.class -) -@Service -public class GetPolicyCommand{ - - @Reference - private TamayaConfigPlugin configPlugin; - - public String defaultOpPolicy() throws IOException { - return (ConfigCommands.getDefaultOpPolicy(configPlugin)); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/HistoryDeleteCommand.java ---------------------------------------------------------------------- diff --git a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/HistoryDeleteCommand.java b/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/HistoryDeleteCommand.java deleted file mode 100644 index c4c9802..0000000 --- a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/HistoryDeleteCommand.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.felix.shell; - -import org.apache.felix.scr.annotations.Service; -import org.apache.tamaya.osgi.commands.HistoryCommands; -import org.osgi.service.component.annotations.Component; - -import java.io.IOException; - -@Component( - immediate = true, - property = { - "osgi.command.scope=tamaya:history-delete", - "osgi.command.function=delete" - }, - service=HistoryDeleteCommand.class -) -@Service -public class HistoryDeleteCommand{ - - public String delete(String pid) throws IOException { - return (HistoryCommands.clearHistory(pid)); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/HistoryGetCommand.java ---------------------------------------------------------------------- diff --git a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/HistoryGetCommand.java b/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/HistoryGetCommand.java deleted file mode 100644 index 13c4f68..0000000 --- a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/HistoryGetCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.felix.shell; - -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.Service; -import org.apache.tamaya.osgi.TamayaConfigPlugin; -import org.apache.tamaya.osgi.commands.HistoryCommands; -import org.osgi.service.component.annotations.Component; - -import java.io.IOException; - -@Component( - immediate = true, - property = { - "osgi.command.scope=tamaya:history", - "osgi.command.function=getHistory" - }, - service=HistoryGetCommand.class -) -@Service -public class HistoryGetCommand{ - - @Reference - private TamayaConfigPlugin configPlugin; - - public String getHistory(String pid, String[] eventTypes) throws IOException { - return (HistoryCommands.getHistory(pid, eventTypes)); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/HistorySizeGetCommand.java ---------------------------------------------------------------------- diff --git a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/HistorySizeGetCommand.java b/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/HistorySizeGetCommand.java deleted file mode 100644 index c3b725f..0000000 --- a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/HistorySizeGetCommand.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.felix.shell; - -import org.apache.felix.scr.annotations.Service; -import org.apache.tamaya.osgi.commands.HistoryCommands; -import org.osgi.service.component.annotations.Component; - -import java.io.IOException; - -@Component( - immediate = true, - property = { - "osgi.command.scope=tamaya:history-size", - "osgi.command.function=getHistorySize" - }, - service=HistorySizeGetCommand.class -) -@Service -public class HistorySizeGetCommand{ - - public String getHistorySize() throws IOException { - return String.valueOf(HistoryCommands.getMaxHistorySize()); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/HistorySizeSetCommand.java ---------------------------------------------------------------------- diff --git a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/HistorySizeSetCommand.java b/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/HistorySizeSetCommand.java deleted file mode 100644 index a69c793..0000000 --- a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/HistorySizeSetCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.felix.shell; - -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.Service; -import org.apache.tamaya.osgi.TamayaConfigPlugin; -import org.apache.tamaya.osgi.commands.HistoryCommands; -import org.osgi.service.component.annotations.Component; - -import java.io.IOException; - -@Component( - immediate = true, - property = { - "osgi.command.scope=tamaya:history-size-set", - "osgi.command.function=setHistorySize" - }, - service=HistorySizeSetCommand.class -) -@Service -public class HistorySizeSetCommand{ - - @Reference - private TamayaConfigPlugin configPlugin; - - public String setHistorySize(int maxSize) throws IOException { - return HistoryCommands.setMaxHistorySize(maxSize); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/InfoCommand.java ---------------------------------------------------------------------- diff --git a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/InfoCommand.java b/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/InfoCommand.java deleted file mode 100644 index 00ebc84..0000000 --- a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/InfoCommand.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.felix.shell; - -import org.apache.felix.scr.annotations.Service; -import org.apache.tamaya.osgi.TamayaConfigPlugin; -import org.apache.tamaya.osgi.commands.ConfigCommands; -import org.osgi.service.component.annotations.Component; - -import java.io.IOException; - -@Component( - immediate = true, - property = { - "osgi.command.scope=tamaya:info", - "osgi.command.function=info" - }, - service=InfoCommand.class -) -@Service -public class InfoCommand { - - @org.apache.felix.scr.annotations.Reference - private TamayaConfigPlugin configPlugin; - - public String info() throws IOException { - return (ConfigCommands.getInfo(configPlugin)); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/PolicyGetCommand.java ---------------------------------------------------------------------- diff --git a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/PolicyGetCommand.java b/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/PolicyGetCommand.java deleted file mode 100644 index 776a0ed..0000000 --- a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/PolicyGetCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.felix.shell; - -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.Service; -import org.apache.tamaya.osgi.TamayaConfigPlugin; -import org.apache.tamaya.osgi.commands.ConfigCommands; -import org.osgi.service.component.annotations.Component; - -import java.io.IOException; - -@Component( - immediate = true, - property = { - "osgi.command.scope=tamaya:policy", - "osgi.command.function=policy" - }, - service=PolicyGetCommand.class -) -@Service -public class PolicyGetCommand{ - - @Reference - private TamayaConfigPlugin configPlugin; - - public String policy() throws IOException { - return ConfigCommands.getDefaultOpPolicy(configPlugin); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/PolicySetCommand.java ---------------------------------------------------------------------- diff --git a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/PolicySetCommand.java b/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/PolicySetCommand.java deleted file mode 100644 index 6e37f81..0000000 --- a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/PolicySetCommand.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.felix.shell; - -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.Service; -import org.apache.tamaya.osgi.OperationMode; -import org.apache.tamaya.osgi.TamayaConfigPlugin; -import org.apache.tamaya.osgi.commands.ConfigCommands; -import org.osgi.service.component.annotations.Component; - -import java.io.IOException; -import java.util.List; - -@Component( - immediate = true, - property = { - "osgi.command.scope=tamaya:policy-set", - "osgi.command.function=setPolicy" - }, - service=PolicySetCommand.class -) -@Service -public class PolicySetCommand{ - - @Reference - private TamayaConfigPlugin configPlugin; - - public String setPolicy(OperationMode policy) throws IOException { - return ConfigCommands.setDefaultOpPolicy(configPlugin, policy.toString()); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/PropertyGetCommand.java ---------------------------------------------------------------------- diff --git a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/PropertyGetCommand.java b/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/PropertyGetCommand.java deleted file mode 100644 index d3de8c8..0000000 --- a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/PropertyGetCommand.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.felix.shell; - -import org.apache.felix.scr.annotations.Service; -import org.apache.tamaya.osgi.commands.ConfigCommands; -import org.osgi.service.component.annotations.Component; - -import java.io.IOException; - -@Component( - immediate = true, - property = { - "osgi.command.scope=tamaya:property", - "osgi.command.function=property" - }, - service=PropertyGetCommand.class -) -@Service -public class PropertyGetCommand{ - - public String property(String propertysource, String key, boolean extended) throws IOException { - return ConfigCommands.getProperty(propertysource, key, extended); - } - - public String property(String propertysource, String key) throws IOException { - return property(propertysource, key, false); - } - - public String property(String key) throws IOException { - return property(null, key, false); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/PropertySourcesCommand.java ---------------------------------------------------------------------- diff --git a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/PropertySourcesCommand.java b/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/PropertySourcesCommand.java deleted file mode 100644 index 20a72e3..0000000 --- a/osgi/felix-shell/src/main/java/org/apache/tamaya/felix/shell/PropertySourcesCommand.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.felix.shell; - -import org.apache.felix.scr.annotations.Service; -import org.apache.tamaya.osgi.commands.ConfigCommands; -import org.osgi.service.component.annotations.Component; - -import java.io.IOException; - -@Component( - immediate = true, - property = { - "osgi.command.scope=tamaya:propertysources", - "osgi.command.function=propertysources" - }, - service=PropertySourcesCommand.class -) -@Service -public class PropertySourcesCommand{ - - public String propertysources() throws IOException { - return ConfigCommands.getPropertySourceOverview(); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/felix-shell/src/main/resources/META-INF/services/org/apache/tamaya/karaf/shell/commands ---------------------------------------------------------------------- diff --git a/osgi/felix-shell/src/main/resources/META-INF/services/org/apache/tamaya/karaf/shell/commands b/osgi/felix-shell/src/main/resources/META-INF/services/org/apache/tamaya/karaf/shell/commands deleted file mode 100644 index 56a9ff8..0000000 --- a/osgi/felix-shell/src/main/resources/META-INF/services/org/apache/tamaya/karaf/shell/commands +++ /dev/null @@ -1,37 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy current 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. -# -org.apache.tamaya.karaf.shell.BackupCreateCommand -org.apache.tamaya.karaf.shell.BackupDeleteCommand -org.apache.tamaya.karaf.shell.BackupListCommand -org.apache.tamaya.karaf.shell.ConfigCommand -org.apache.tamaya.karaf.shell.DefaultDisableCommand -org.apache.tamaya.karaf.shell.GetPolicyCommand -org.apache.tamaya.karaf.shell.HistoryClearCommand -org.apache.tamaya.karaf.shell.HistoryGetCommand -org.apache.tamaya.karaf.shell.HistorySizeGetCommand -org.apache.tamaya.karaf.shell.HistorySizeSetCommand -org.apache.tamaya.karaf.shell.InfoCommand -org.apache.tamaya.karaf.shell.PolicyGetCommand -org.apache.tamaya.karaf.shell.PolicySetCommand -org.apache.tamaya.karaf.shell.PropertyGetCommand -org.apache.tamaya.karaf.shell.PropertySourceCommand -org.apache.tamaya.karaf.shell.PropertySourcesCommand - - -
