tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [36/45] incubator-tamaya-sandbox git commit: TAMAYA-297: Unified commands in Karaf and Gogo. Added new commands for updater support.
Date Thu, 28 Sep 2017 20:12:50 GMT
TAMAYA-297: Unified commands in Karaf and Gogo. Added new commands for updater support.


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/509598d9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/509598d9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/509598d9

Branch: refs/heads/master
Commit: 509598d9ac52ada1319791da3ea86b9724f627bb
Parents: 8671315
Author: anatole <anatole@apache.org>
Authored: Sun Sep 24 21:36:03 2017 +0200
Committer: anatole <anatole@apache.org>
Committed: Sun Sep 24 21:36:03 2017 +0200

----------------------------------------------------------------------
 .../tamaya/osgi/DefaultOSGIConfigMapper.java    | 45 -------------
 .../karaf/shell/ApplyTamayaConfigCommand.java   | 55 ++++++++++++++++
 .../tamaya/karaf/shell/BackupCreateCommand.java |  3 -
 .../tamaya/karaf/shell/BackupDeleteCommand.java |  1 -
 .../karaf/shell/BackupRestoreCommand.java       | 46 +++++++++++++
 .../tamaya/karaf/shell/ConfigCommand.java       | 57 ----------------
 .../karaf/shell/DefaultDisableCommand.java      | 69 --------------------
 .../karaf/shell/DefaultEnableCommand.java       | 68 +++++++++++++++++++
 .../karaf/shell/DefaultEnabledCommand.java      | 63 ++++++++++++++++++
 .../tamaya/karaf/shell/OSGIConfigCommand.java   | 51 +++++++++++++++
 .../tamaya/karaf/shell/TamayaConfigCommand.java | 54 +++++++++++++++
 .../org/apache/tamaya/karaf/shell/commands      |  8 ++-
 12 files changed, 343 insertions(+), 177 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/509598d9/osgi/common/src/main/java/org/apache/tamaya/osgi/DefaultOSGIConfigMapper.java
----------------------------------------------------------------------
diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/DefaultOSGIConfigMapper.java
b/osgi/common/src/main/java/org/apache/tamaya/osgi/DefaultOSGIConfigMapper.java
deleted file mode 100644
index 861efb2..0000000
--- a/osgi/common/src/main/java/org/apache/tamaya/osgi/DefaultOSGIConfigMapper.java
+++ /dev/null
@@ -1,45 +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.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.functions.ConfigurationFunctions;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Arrays;
-
-/**
- * Created by atsticks on 18.09.17.
- */
-public class DefaultOSGIConfigMapper implements OSGIConfigMapper {
-
-    @Override
-    public org.apache.tamaya.Configuration getConfiguration(String pid) {
-        if (pid != null) {
-            return ConfigurationProvider.getConfiguration()
-                    .with(ConfigurationFunctions.section("[" + pid + ']', true));
-        }
-        return null;
-    }
-
-    @Override
-    public String toString() {
-        return "Default OSGIConfigRootMapper([symbolicName:version/properties] -> [bundle:symbolicName]";
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/509598d9/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/ApplyTamayaConfigCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/ApplyTamayaConfigCommand.java
b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/ApplyTamayaConfigCommand.java
new file mode 100644
index 0000000..f6a7dc8
--- /dev/null
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/ApplyTamayaConfigCommand.java
@@ -0,0 +1,55 @@
+/*
+ * 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.Option;
+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_apply_config", description="Show the current Tamaya
configuration.")
+@Service
+public class ApplyTamayaConfigCommand implements Action{
+
+    @Argument(index = 0, name = "pid", description = "The target OSGI component PID.",
+            required = true, multiValued = false)
+    String pid = null;
+
+    @Option(name = "operationMode", aliases={"-m","--opmode"}, description = "Explicitly
set (override) the operation mode to use.",
+            required = false, multiValued = false)
+    String opMode = null;
+
+    @Option(name = "dryRun", aliases={"-d","--dryrun"}, description = "If set to true no
OSGI configuration gets changed.",
+            required = false, multiValued = false)
+    boolean dryRun = false;
+
+    @org.apache.karaf.shell.api.action.lifecycle.Reference
+    TamayaConfigPlugin configPlugin;
+
+
+    public Object execute() throws IOException {
+        return(ConfigCommands.applyTamayaConfiguration(configPlugin, pid, opMode, dryRun));
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/509598d9/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 4109258..4aa3f8d 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
@@ -23,13 +23,10 @@ import org.apache.karaf.shell.api.action.Argument;
 import org.apache.karaf.shell.api.action.Command;
 import org.apache.karaf.shell.api.action.Option;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.tamaya.osgi.InitialState;
 import org.apache.tamaya.osgi.commands.BackupCommands;
-import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
 
 import java.io.IOException;
-import java.util.Dictionary;
 
 @Command(scope = "tamaya", name = "tm_backup_create", description="Creates a backup of a
current OSGI configuration.")
 @Service

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/509598d9/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 75cc04a..6bf6162 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
@@ -22,7 +22,6 @@ 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.InitialState;
 import org.apache.tamaya.osgi.commands.BackupCommands;
 
 import java.io.IOException;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/509598d9/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupRestoreCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupRestoreCommand.java
b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupRestoreCommand.java
new file mode 100644
index 0000000..8434d45
--- /dev/null
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupRestoreCommand.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.Service;
+import org.apache.tamaya.osgi.TamayaConfigPlugin;
+import org.apache.tamaya.osgi.commands.BackupCommands;
+
+import java.io.IOException;
+
+@Command(scope = "tamaya", name = "tm_backup_restore", description="Restores the OSGI configuration
backup of Tamya and disabled the PID for Tamaya configuration.")
+@Service
+public class BackupRestoreCommand implements Action{
+
+    @Argument(index = 0, name = "pid", description = "The target PID. '*' restores all backups.",
+            required = true, multiValued = false)
+    String pid;
+
+    @org.apache.karaf.shell.api.action.lifecycle.Reference
+    TamayaConfigPlugin configPlugin;
+
+    @Override
+    public Object execute() throws IOException {
+        return(BackupCommands.restoreBackup(configPlugin, pid));
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/509598d9/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
deleted file mode 100644
index 2221029..0000000
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/ConfigCommand.java
+++ /dev/null
@@ -1,57 +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.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.functions.ConfigurationFunctions;
-import org.apache.tamaya.osgi.TamayaConfigPlugin;
-import org.apache.tamaya.osgi.commands.ConfigCommands;
-
-import java.io.IOException;
-
-@Command(scope = "tamaya", name = "tm_config", description="Show the current Tamaya configuration.")
-@Service
-public class ConfigCommand implements Action{
-
-    @Argument(index = 0, name = "section", description = "A regular expression selecting
the section to be filtered.",
-            required = false, multiValued = false)
-    String section = null;
-
-    @Option(name = "pid", aliases={"-p.--pid"}, description = "Apply filtering for the given
OSGI component PID.",
-            required = false, multiValued = false)
-    String pid = null;
-
-    @org.apache.karaf.shell.api.action.lifecycle.Reference
-    TamayaConfigPlugin configPlugin;
-
-
-    public Object execute() throws IOException {
-        if(pid!=null){
-            return(ConfigCommands.readConfig(configPlugin, pid, section));
-        }
-        return(ConfigCommands.readConfig(section));
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/509598d9/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
deleted file mode 100644
index e65f5be..0000000
--- a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultDisableCommand.java
+++ /dev/null
@@ -1,69 +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.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_disable", description="Disables Tamaya by default for
all bundles/services (default=false)." +
-        " Disabling it allows to explicitly enable bundles using 'Tamaya-Enable^manifest
entries.")
-@Service
-public class DefaultDisableCommand implements Action{
-
-    @Reference
-    private TamayaConfigPlugin configPlugin;
-
-    @Argument(index = 0, name = "disabled", description = "The boolean value to disable Tamaya
by default.",
-            required = true, multiValued = false)
-    @Completion(OperationModeCompleter.class)
-    boolean disabled;
-
-    @Override
-    public Object execute() throws IOException {
-        return(ConfigCommands.setDefaultDisabled(configPlugin, disabled));
-    }
-
-    @Service
-    public static final class OperationModeCompleter implements Completer {
-
-        @Override
-        public int complete(Session session, CommandLine commandLine, List<String>
candidates) {
-            StringsCompleter delegate = new StringsCompleter();
-            for(OperationMode mode: OperationMode.values()) {
-                delegate.getStrings().add(mode.toString());
-            }
-            return delegate.complete(session, commandLine, candidates);
-        }
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/509598d9/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnableCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnableCommand.java
b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnableCommand.java
new file mode 100644
index 0000000..376b453
--- /dev/null
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnableCommand.java
@@ -0,0 +1,68 @@
+/*
+ * 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_enable", description="Enables or disable Tamaya by
default for all bundles/services (default: enabled=false)." +
+        " Disabling still allows to explicitly enable bundles using 'tamaya-enable' manifest
or OSGI config entries.")
+@Service
+public class DefaultEnableCommand implements Action{
+
+    @Reference
+    private TamayaConfigPlugin configPlugin;
+
+    @Argument(index = 0, name = "enabled", description = "The boolean value to enabled/disable
Tamaya by default.",
+            required = true, multiValued = false)
+    boolean enabled;
+
+    @Override
+    public Object execute() throws IOException {
+        return(ConfigCommands.setDefaultEnabled(configPlugin, enabled));
+    }
+
+    @Service
+    public static final class OperationModeCompleter implements Completer {
+
+        @Override
+        public int complete(Session session, CommandLine commandLine, List<String>
candidates) {
+            StringsCompleter delegate = new StringsCompleter();
+            for(OperationMode mode: OperationMode.values()) {
+                delegate.getStrings().add(mode.toString());
+            }
+            return delegate.complete(session, commandLine, candidates);
+        }
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/509598d9/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnabledCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnabledCommand.java
b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnabledCommand.java
new file mode 100644
index 0000000..04f8404
--- /dev/null
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnabledCommand.java
@@ -0,0 +1,63 @@
+/*
+ * 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.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_enabled", description="Check if Tamaya is currently
by default enabled for all bundles/services (default: enabled=false)." +
+        " If disabled still Tamaya allows to explicitly enable bundles using 'tamaya-enable'
manifest or OSGI config entries.")
+@Service
+public class DefaultEnabledCommand implements Action{
+
+    @Reference
+    private TamayaConfigPlugin configPlugin;
+
+    @Override
+    public Object execute() throws IOException {
+        return(ConfigCommands.getDefaultEnabled(configPlugin));
+    }
+
+    @Service
+    public static final class OperationModeCompleter implements Completer {
+
+        @Override
+        public int complete(Session session, CommandLine commandLine, List<String>
candidates) {
+            StringsCompleter delegate = new StringsCompleter();
+            for(OperationMode mode: OperationMode.values()) {
+                delegate.getStrings().add(mode.toString());
+            }
+            return delegate.complete(session, commandLine, candidates);
+        }
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/509598d9/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/OSGIConfigCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/OSGIConfigCommand.java
b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/OSGIConfigCommand.java
new file mode 100644
index 0000000..807d08d
--- /dev/null
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/OSGIConfigCommand.java
@@ -0,0 +1,51 @@
+/*
+ * 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.Option;
+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_osgi_config", description="Show the current OSGI configuration.")
+@Service
+public class OSGIConfigCommand implements Action{
+
+    @Option(name = "section", aliases={"-s","--section"}, description = "A starting expression
selecting the keys to be filtered.",
+            required = false, multiValued = false)
+    String section = null;
+
+    @Argument(index = 0, name = "pid", description = "The target OSGI component PID.",
+            required = true, multiValued = false)
+    String pid = null;
+
+    @org.apache.karaf.shell.api.action.lifecycle.Reference
+    TamayaConfigPlugin configPlugin;
+
+
+    public Object execute() throws IOException {
+        return(ConfigCommands.readOSGIConfiguration(configPlugin, pid, section));
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/509598d9/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/TamayaConfigCommand.java
----------------------------------------------------------------------
diff --git a/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/TamayaConfigCommand.java
b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/TamayaConfigCommand.java
new file mode 100644
index 0000000..b161996
--- /dev/null
+++ b/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/TamayaConfigCommand.java
@@ -0,0 +1,54 @@
+/*
+ * 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.Option;
+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_config", description="Show the current Tamaya configuration.")
+@Service
+public class TamayaConfigCommand implements Action{
+
+    @Option(name = "section", aliases={"-s","--section"}, description = "A starting expression
selecting the section to be filtered.",
+            required = false, multiValued = false)
+    String section = null;
+
+    @Option(name = "pid", aliases={"-p","--pid"}, description = "Apply filtering for the
given OSGI component PID.",
+            required = false, multiValued = false)
+    String pid = null;
+
+    @org.apache.karaf.shell.api.action.lifecycle.Reference
+    TamayaConfigPlugin configPlugin;
+
+
+    public Object execute() throws IOException {
+        if(pid!=null){
+            return(ConfigCommands.readTamayaConfig4PID(pid, section));
+        }
+        return(ConfigCommands.readTamayaConfig(section, null));
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/509598d9/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 f5e9c5c..0876782 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,13 +16,15 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+org.apache.tamaya.karaf.shell.ApplyTamayaConfig
 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.BackupRestoreCommand
+org.apache.tamaya.karaf.shell.DefaultEnableCommand
+org.apache.tamaya.karaf.shell.DefaultEnabledCommand
 org.apache.tamaya.karaf.shell.GetPolicyCommand
 org.apache.tamaya.karaf.shell.HistoryDeleteAllCommand
 org.apache.tamaya.karaf.shell.HistoryDeleteCommand
@@ -30,11 +32,13 @@ org.apache.tamaya.karaf.shell.HistoryGetCommand
 org.apache.tamaya.karaf.shell.HistoryMaxsizeCommand
 org.apache.tamaya.karaf.shell.HistoryMaxsizeSetCommand
 org.apache.tamaya.karaf.shell.InfoCommand
+org.apache.tamaya.karaf.shell.OSGIConfigCommand
 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
+org.apache.tamaya.karaf.shell.TamayaConfigCommand
 
 
 


Mime
View raw message