http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/Activator.java ---------------------------------------------------------------------- diff --git a/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/Activator.java b/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/Activator.java index 8c07c24..ac83d0d 100644 --- a/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/Activator.java +++ b/osgi/gogo-shell/src/main/java/org/apache/tamaya/gogo/shell/Activator.java @@ -45,26 +45,27 @@ public class Activator implements BundleActivator { Dictionary<String, Object> props = new Hashtable<>(); props.put("osgi.command.scope", "tamaya"); props.put("osgi.command.function", - new String[] {"config", "property_get", - "propertysource_get","propertysources_get"}); + new String[] {"tm_config", "tm_property", + "tm_propertysource","tm_propertysources"}); configReg = context.registerService( ConfigCommands.class, new ConfigCommands(context), props); props.put("osgi.command.function", - new String[] {"history_get","history_delete", - "maxhistory_get", "maxhistory_set"}); + new String[] {"tm_history","tm_history_delete","tm_history_delete_all", + "tm_history_maxsize", "tm_history_maxsize_set"}); histReg = context.registerService( HistoryCommands.class, new HistoryCommands(context), props); props.put("osgi.command.function", - new String[] {"backup_create","backup_delete", - "backup_get"}); + new String[] {"tm_backup_create","tm_backup_delete", + "tm_backup"}); backupReg = context.registerService( BackupCommands.class, new BackupCommands(context), props); props.put("osgi.command.function", - new String[] {"tamaya_disable","tamaya_policy_get", - "tamaya_policy_set","tamaya_info"}); + new String[] {"tm_disable","tm_policy", + "tm_policy_set","tm_info", "tm_propagate_updates", + "tm_propagate_updates_set"}); settingsReg = context.registerService( SettingsCommands.class, new SettingsCommands(context), props);
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 79e4ca1..cd8caf2 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 @@ -42,21 +42,21 @@ public class BackupCommands { @Descriptor("Creates an OSGI ConfigAdmin configuration backup for a PID.") - public void backup_create(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-p", "--pid"}) + public void tm_backup_create(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-p", "--pid"}) @Descriptor("The PID (requred)") String pid, - @Parameter(absentValue = Parameter.UNSPECIFIED, names={"-f", "--force"}) + @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)); } @Descriptor("Deletes an OSGI ConfigAdmin configuration backup for a PID.") - public void backup_delete(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-p", "--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)); } @Descriptor("Shows the contents of the OSGI ConfigAdmin configuration backup for a PID.") - public void backup_get(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-p", "--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))); } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 313caea..9387c27 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 @@ -41,7 +41,7 @@ public class ConfigCommands { } @Descriptor("Shows the current Tamaya configuration.") - public void config(@Parameter(absentValue = "", names={"-s", "--section"}) + public void tm_config(@Parameter(absentValue = "", names={"-s", "--section"}) @Descriptor("The section start expression to filter.") String section, @Parameter(absentValue = "", names={"-p", "--pid"}) @Descriptor("The pid to filter (required).") String pid) throws IOException { @@ -54,7 +54,7 @@ public class ConfigCommands { @Descriptor("Gets the detailed property values.") - public void property_get(@Parameter(absentValue = "", names={"-ps", "--propertysource"}) + public void tm_property(@Parameter(absentValue = "", names={"-ps", "--propertysource"}) @Descriptor("The property source name")String propertysource, @Parameter(absentValue = Parameter.UNSPECIFIED, names={"-k", "--key"}) @Descriptor("The property key")String key, @@ -64,13 +64,13 @@ public class ConfigCommands { } @Descriptor("Get details of a property source.") - public void propertysource_get(@Parameter(absentValue = "", names={"-ps", "--propertysource"}) + public void tm_propertysource(@Parameter(absentValue = "", names={"-ps", "--propertysource"}) @Descriptor("The property source name, empty returns a list of possible values")String propertysource) throws IOException { System.out.println(org.apache.tamaya.osgi.commands.ConfigCommands.getPropertySource(propertysource)); } @Descriptor("Show details of all registered property sources.") - public void propertysources_get() throws IOException { + public void tm_propertysources() throws IOException { System.out.println(org.apache.tamaya.osgi.commands.ConfigCommands.getPropertySourceOverview()); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 69ee19a..54ca024 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 @@ -40,18 +40,18 @@ public class HistoryCommands { } @Descriptor("Deletes the history of configuration changes.") - public void history_delete(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-p", "--pid"}) + 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)); } @Descriptor("Deletes the full history of configuration changes.") - public void history_delete_all() throws IOException { + public void tm_history_delete_all() throws IOException { System.out.println(org.apache.tamaya.osgi.commands.HistoryCommands.clearHistory(null)); } @Descriptor("Read the history of configuration changes.") - public void history_get(@Parameter(absentValue = "", names={"-p", "--pid"}) + 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 " + @@ -64,12 +64,12 @@ public class HistoryCommands { } @Descriptor("Get the maximum configuration change history size.") - public void maxhistory_get() throws IOException { + public void tm_history_maxsize() throws IOException { System.out.println(String.valueOf(org.apache.tamaya.osgi.commands.HistoryCommands.getMaxHistorySize())); } @Descriptor("Sets the maximum configuration change history size.") - public void maxhistory_set(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-s", "--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)); } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 78afb79..7c4f9c8 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 @@ -43,25 +43,36 @@ public class SettingsCommands { } @Descriptor("Allows to disable/enable Tamaya configuration by default.") - public void tamaya_disable(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-d", "--disable"}) + public void tm_disable(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-d", "--disable"}) @Descriptor("if true Tamaya is disabled by default (default=false)") boolean disabled) throws IOException { System.out.println(ConfigCommands.setDefaultDisabled(getService(TamayaConfigPlugin.class), disabled)); } @Descriptor("Get the default Tamaya configuration policy.") - public void tamaya_policy_get() throws IOException { + public void tm_policy() throws IOException { System.out.println(ConfigCommands.getDefaultOpPolicy(getService(TamayaConfigPlugin.class))); } @Descriptor("Set the default Tamaya configuration policy.") - public void tamaya_policy_set(@Parameter(absentValue = Parameter.UNSPECIFIED, names={"-p", "--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") OperationMode policy) throws IOException { System.out.println(ConfigCommands.setDefaultOpPolicy(getService(TamayaConfigPlugin.class), policy.toString())); } @Descriptor("Get info about the current Tamaya configuration settings.") - public void tamaya_info() throws IOException { + public void tm_info() throws IOException { System.out.println(ConfigCommands.getInfo(getService(TamayaConfigPlugin.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()); + } + + @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)); + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 e2c6ca7..4109258 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 @@ -48,8 +48,7 @@ public class BackupCreateCommand implements Action{ @Override public Object execute() throws IOException { - System.out.println(BackupCommands.createBackup(cm, pid, replace)); - return null; + 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/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 58dd826..75cc04a 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 @@ -37,8 +37,7 @@ public class BackupDeleteCommand implements Action{ @Override public Object execute() throws IOException { - System.out.println(BackupCommands.deleteBackup(pid)); - return null; + return(BackupCommands.deleteBackup(pid)); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 781f2b9..9a4a2ed 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 @@ -36,8 +36,7 @@ public class BackupListCommand implements Action{ @Override public Object execute() throws IOException { - System.out.println(BackupCommands.listBackup(pid)); - return null; + return(BackupCommands.listBackup(pid)); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/ConfigCommand.java ---------------------------------------------------------------------- diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/ConfigCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/ConfigCommand.java index 3732f0a..2221029 100644 --- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/ConfigCommand.java +++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/ConfigCommand.java @@ -49,11 +49,9 @@ public class ConfigCommand implements Action{ public Object execute() throws IOException { if(pid!=null){ - System.out.println(ConfigCommands.readConfig(configPlugin, pid, section)); - }else { - System.out.println(ConfigCommands.readConfig(section)); + return(ConfigCommands.readConfig(configPlugin, pid, section)); } - return null; + return(ConfigCommands.readConfig(section)); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultDisableCommand.java ---------------------------------------------------------------------- diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultDisableCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultDisableCommand.java index 8d455a7..e65f5be 100644 --- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultDisableCommand.java +++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultDisableCommand.java @@ -50,8 +50,7 @@ public class DefaultDisableCommand implements Action{ @Override public Object execute() throws IOException { - System.out.println(ConfigCommands.setDefaultDisabled(configPlugin, disabled)); - return null; + return(ConfigCommands.setDefaultDisabled(configPlugin, disabled)); } @Service http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 8ccb5a4..7a85f33 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 @@ -36,8 +36,7 @@ public class GetPolicyCommand implements Action{ @Override public Object execute() throws IOException { - System.out.println(ConfigCommands.getDefaultOpPolicy(configPlugin)); - return null; + return ConfigCommands.getDefaultOpPolicy(configPlugin); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 new file mode 100644 index 0000000..fab4ccc --- /dev/null +++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryDeleteAllCommand.java @@ -0,0 +1,38 @@ +/* + * 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.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.Service; +import org.apache.tamaya.osgi.commands.HistoryCommands; + +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.") +@Service +public class HistoryDeleteAllCommand implements Action{ + + @Override + public String execute() throws IOException { + return HistoryCommands.clearHistory(null); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 4930e2f..655adf1 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 @@ -29,13 +29,12 @@ import java.io.IOException; public class HistoryDeleteCommand implements Action{ @Argument(index = 0, name = "pid", description = "Allows to filter on the given PID.", - required = false, multiValued = false) + required = true, multiValued = false) String pid; @Override - public Object execute() throws IOException { - System.out.println(HistoryCommands.clearHistory(pid)); - return null; + public String execute() 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/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 7f99031..5abbbde 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 @@ -49,9 +49,8 @@ public class HistoryGetCommand implements Action{ private String[] eventTypes; @Override - public Object execute() throws IOException { - System.out.println(HistoryCommands.getHistory(pid, eventTypes)); - return null; + public String execute() throws IOException { + return HistoryCommands.getHistory(pid, eventTypes); } @Service http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 92424d1..d8dd37e 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 @@ -31,8 +31,7 @@ public class HistoryMaxsizeCommand implements Action{ @Override public Object execute() throws IOException { - System.out.println(HistoryCommands.getMaxHistorySize()); - return null; + return(HistoryCommands.getMaxHistorySize()); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 new file mode 100644 index 0000000..a490dd6 --- /dev/null +++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryMaxsizeSetCommand.java @@ -0,0 +1,47 @@ +/* + * 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.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.HistoryCommands; + +import java.io.IOException; + +@Command(scope = "tamaya", name = "tm_history_maxsize_set", description="Sets the maximal size of Tamaya history entries.") +@Service +public class HistoryMaxsizeSetCommand implements Action{ + + @Reference + private TamayaConfigPlugin configPlugin; + + @Argument(index = 0, name = "size", description = "The maximum number of entries in the history.", + required = true, multiValued = false) + int maxSize; + + @Override + public Object execute() 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/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistorySizeSetCommand.java ---------------------------------------------------------------------- diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistorySizeSetCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistorySizeSetCommand.java deleted file mode 100644 index 5d7ffb7..0000000 --- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistorySizeSetCommand.java +++ /dev/null @@ -1,48 +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.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.HistoryCommands; - -import java.io.IOException; - -@Command(scope = "tamaya", name = "history_maxsize_set", description="Sets the maximal size of Tamaya history entries.") -@Service -public class HistorySizeSetCommand implements Action{ - - @Reference - private TamayaConfigPlugin configPlugin; - - @Argument(index = 0, name = "size", description = "The maximum number of entries in the history.", - required = true, multiValued = false) - int maxSize; - - @Override - public Object execute() throws IOException { - System.out.println(HistoryCommands.setMaxHistorySize(maxSize)); - return null; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 e954957..b543d9c 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 @@ -38,8 +38,7 @@ public class InfoCommand implements Action { private TamayaConfigPlugin configPlugin; public Object execute() throws IOException { - System.out.println(ConfigCommands.getInfo(configPlugin)); - return null; + return(ConfigCommands.getInfo(configPlugin)); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 72e4ccc..9b38018 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 @@ -36,8 +36,7 @@ public class PolicyGetCommand implements Action{ @Override public Object execute() throws IOException { - System.out.println(ConfigCommands.getDefaultOpPolicy(configPlugin)); - return null; + return(ConfigCommands.getDefaultOpPolicy(configPlugin)); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 2d2b478..ecb3232 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 @@ -35,7 +35,7 @@ import org.apache.tamaya.osgi.commands.ConfigCommands; import java.io.IOException; import java.util.List; -@Command(scope = "tamaya", name = "tamaya_policy_set", description="Sets the current Tamaya operation policy.") +@Command(scope = "tamaya", name = "tm_policy_set", description="Sets the current Tamaya operation policy.") @Service public class PolicySetCommand implements Action{ @@ -49,8 +49,7 @@ public class PolicySetCommand implements Action{ @Override public Object execute() throws IOException { - System.out.println(ConfigCommands.setDefaultOpPolicy(configPlugin, policy)); - return null; + return(ConfigCommands.setDefaultOpPolicy(configPlugin, policy)); } @Service http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 new file mode 100644 index 0000000..4ad1baa --- /dev/null +++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesCommand.java @@ -0,0 +1,46 @@ +/* + * 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.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 java.io.IOException; + +@Command(scope = "tamaya", name = "tm_propagate_updates", + description="Flag if Tamaya is automatically triggering OSGI config updates, when according " + + "Tamaya configuration changes.") +@Service +public class PropagateUpdatesCommand implements Action{ + + @Reference + private TamayaConfigPlugin configPlugin; + + + @Override + public Object execute() throws IOException { + return(configPlugin.isAutoUpdateEnabled()); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 new file mode 100644 index 0000000..fbd3b4a --- /dev/null +++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesSetCommand.java @@ -0,0 +1,56 @@ +/* + * 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.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.Completion; +import org.apache.karaf.shell.api.action.lifecycle.Reference; +import org.apache.karaf.shell.api.action.lifecycle.Service; +import org.apache.karaf.shell.api.console.CommandLine; +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.OperationMode; +import org.apache.tamaya.osgi.TamayaConfigPlugin; +import org.apache.tamaya.osgi.commands.ConfigCommands; + +import java.io.IOException; +import java.util.List; + +@Command(scope = "tamaya", name = "tm_propagate_updates_set", + description="Configure if Tamaya is automatically triggering OSGI config updates, when according " + + "Tamaya configuration changes.") +@Service +public class PropagateUpdatesSetCommand implements Action{ + + @Reference + private TamayaConfigPlugin configPlugin; + + @Argument(index = 0, name = "enabled", description = "Set to true to enable Tamaya's updating trigger.", + required = true, multiValued = false) + boolean enabled; + + @Override + public Object execute() throws IOException { + return(ConfigCommands.setAutoUpdateEnabled(configPlugin, enabled)); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 cda1a2b..932225a 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 @@ -47,8 +47,7 @@ public class PropertyGetCommand implements Action{ String propertysource = null; public Object execute() throws IOException { - System.out.println(ConfigCommands.getProperty(propertysource, key, extended)); - return null; + return(ConfigCommands.getProperty(propertysource, key, extended)); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/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 3a2f695..b6d9439 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 @@ -39,8 +39,7 @@ public class PropertySourceCommand implements Action{ String propertysource = null; public Object execute() throws IOException { - System.out.println(ConfigCommands.getPropertySource(propertysource)); - return null; + return(ConfigCommands.getPropertySource(propertysource)); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertySourcesCommand.java ---------------------------------------------------------------------- diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertySourcesCommand.java b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertySourcesCommand.java index 315e9a9..7aa660d 100644 --- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertySourcesCommand.java +++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertySourcesCommand.java @@ -33,8 +33,7 @@ import java.io.IOException; public class PropertySourcesCommand implements Action{ public Object execute() throws IOException { - System.out.println(ConfigCommands.getPropertySourceOverview()); - return null; + return(ConfigCommands.getPropertySourceOverview()); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/karaf-shell/src/main/resources/META-INF/services/org/apache/tamaya/karaf/shell/commands ---------------------------------------------------------------------- diff --git a/osgi/karaf-shell/src/main/resources/META-INF/services/org/apache/tamaya/karaf/shell/commands b/osgi/karaf-shell/src/main/resources/META-INF/services/org/apache/tamaya/karaf/shell/commands index 56a9ff8..f5e9c5c 100644 --- a/osgi/karaf-shell/src/main/resources/META-INF/services/org/apache/tamaya/karaf/shell/commands +++ b/osgi/karaf-shell/src/main/resources/META-INF/services/org/apache/tamaya/karaf/shell/commands @@ -16,16 +16,19 @@ # specific language governing permissions and limitations # under the License. # +org.apache.tamaya.karaf.shell.PropagateUpdatesCommand +org.apache.tamaya.karaf.shell.PropagateUpdatesSetCommand 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.HistoryDeleteAllCommand +org.apache.tamaya.karaf.shell.HistoryDeleteCommand org.apache.tamaya.karaf.shell.HistoryGetCommand -org.apache.tamaya.karaf.shell.HistorySizeGetCommand -org.apache.tamaya.karaf.shell.HistorySizeSetCommand +org.apache.tamaya.karaf.shell.HistoryMaxsizeCommand +org.apache.tamaya.karaf.shell.HistoryMaxsizeSetCommand org.apache.tamaya.karaf.shell.InfoCommand org.apache.tamaya.karaf.shell.PolicyGetCommand org.apache.tamaya.karaf.shell.PolicySetCommand http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/pom.xml ---------------------------------------------------------------------- diff --git a/osgi/pom.xml b/osgi/pom.xml index 8a30a69..838a9b8 100644 --- a/osgi/pom.xml +++ b/osgi/pom.xml @@ -290,6 +290,7 @@ <module>common</module> <module>updater</module> <module>karaf-shell</module> + <module>gogo-shell</module> <!--<module>karaf-features</module>--> </modules> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/86713156/osgi/updater/bnd.bnd ---------------------------------------------------------------------- diff --git a/osgi/updater/bnd.bnd b/osgi/updater/bnd.bnd index ef7d52d..416db00 100644 --- a/osgi/updater/bnd.bnd +++ b/osgi/updater/bnd.bnd @@ -24,8 +24,8 @@ Export-Package: \ org.apache.tamaya.osgi.updater Import-Package: \ org.apache.tamaya.osgi,\ - 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/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 4c2c50b..be72479 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,9 +20,12 @@ 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.osgi.framework.*; import org.osgi.service.cm.ConfigurationAdmin; +import java.util.Timer; +import java.util.TimerTask; import java.util.logging.Logger; /** @@ -41,19 +44,31 @@ public class Activator implements BundleActivator { private EventListener listener; + private static final long DELAY = 5000L; + private static final long PERIOD = 5000L; + private Timer updateTimer = new Timer("Tamaya OSGI update monitor.", true); + @Override public void start(BundleContext context) throws Exception { listener = new EventListener(context); ConfigEventManager.addListener(listener, ConfigurationChange.class); - LOG.info("Registered Tamaya config trigger for OSGI."); - ConfigEventManager.enableChangeMonitoring(true); + LOG.info("Registered Tamaya getConfig trigger for OSGI."); + ServiceReference<TamayaConfigPlugin> pluginRef = context.getServiceReference(TamayaConfigPlugin.class); + TamayaConfigPlugin tamayaPlugin = context.getService(pluginRef); + updateTimer.schedule(new TimerTask() { + @Override + public void run() { + ConfigEventManager.enableChangeMonitoring(tamayaPlugin.isAutoUpdateEnabled()); + } + }, DELAY, PERIOD); } @Override public void stop(BundleContext context) throws Exception { + updateTimer.cancel(); if (listener != null) { ConfigEventManager.removeListener(this.listener, ConfigurationChange.class); - LOG.info("Unregistered Tamaya config trigger for OSGI."); + LOG.info("Unregistered Tamaya getConfig trigger for OSGI."); ConfigEventManager.enableChangeMonitoring(false); } }
