Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BE104200D43 for ; Tue, 17 Oct 2017 01:03:36 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id BCA23160BEA; Mon, 16 Oct 2017 23:03:36 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 91B14160BE9 for ; Tue, 17 Oct 2017 01:03:34 +0200 (CEST) Received: (qmail 39975 invoked by uid 500); 16 Oct 2017 23:03:33 -0000 Mailing-List: contact commits-help@tamaya.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tamaya.incubator.apache.org Delivered-To: mailing list commits@tamaya.incubator.apache.org Received: (qmail 39966 invoked by uid 99); 16 Oct 2017 23:03:33 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Oct 2017 23:03:33 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id A371B180860 for ; Mon, 16 Oct 2017 23:03:32 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.221 X-Spam-Level: X-Spam-Status: No, score=-4.221 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_SHORT=0.001, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id sUz4FTRAYP2Q for ; Mon, 16 Oct 2017 23:03:19 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 35B8460F10 for ; Mon, 16 Oct 2017 23:03:18 +0000 (UTC) Received: (qmail 39115 invoked by uid 99); 16 Oct 2017 23:03:17 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Oct 2017 23:03:17 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 64F32DFC3E; Mon, 16 Oct 2017 23:03:17 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: anatole@apache.org To: commits@tamaya.incubator.apache.org Date: Mon, 16 Oct 2017 23:03:19 -0000 Message-Id: <38dd263cebbe450f95eedf18d0bb7b02@git.apache.org> In-Reply-To: <0474e021f1a4444284592c582c34b708@git.apache.org> References: <0474e021f1a4444284592c582c34b708@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/7] incubator-tamaya-extensions git commit: TAMAYA-300 Added tests to improve mutation coverage. Movewd OSGI and MP to extensions. archived-at: Mon, 16 Oct 2017 23:03:36 -0000 http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/karaf-shell/pom.xml ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/pom.xml b/modules/osgi/karaf-shell/pom.xml new file mode 100644 index 0000000..119b264 --- /dev/null +++ b/modules/osgi/karaf-shell/pom.xml @@ -0,0 +1,63 @@ + + + + + + 4.0.0 + + + org.apache.tamaya.ext + tamaya-osgi-all + 0.4-incubating-SNAPSHOT + + + tamaya-osgi-karaf-shell + jar + Apache Tamaya :: OSGI :: Karaf :: Shell + Tamaya Karaf Shell Commands + + + + org.apache.tamaya.ext + tamaya-osgi + ${project.parent.version} + + + org.osgi + org.osgi.compendium + + + org.osgi + org.osgi.core + + + org.apache.karaf.shell + org.apache.karaf.shell.core + ${dependency.karaf.version} + provided + + + org.apache.karaf.shell + org.apache.karaf.shell.console + ${dependency.karaf.version} + provided + + + + http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/ApplyTamayaConfigCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/ApplyTamayaConfigCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/ApplyTamayaConfigCommand.java new file mode 100644 index 0000000..d6b13c6 --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/ApplyTamayaConfigCommand.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.Option; +import org.apache.karaf.shell.api.action.lifecycle.Service; +import org.apache.tamaya.osgi.TamayaConfigPlugin; +import org.apache.tamaya.osgi.commands.ConfigCommands; +import org.apache.tamaya.osgi.commands.TamayaConfigService; + +import java.io.IOException; + +@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 + TamayaConfigService 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-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupCreateCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupCreateCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupCreateCommand.java new file mode 100644 index 0000000..dda367a --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupCreateCommand.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.Option; +import org.apache.karaf.shell.api.action.lifecycle.Reference; +import org.apache.karaf.shell.api.action.lifecycle.Service; +import org.apache.tamaya.osgi.commands.BackupCommands; +import org.apache.tamaya.osgi.commands.TamayaConfigService; +import org.osgi.service.cm.ConfigurationAdmin; + +import java.io.IOException; + +@Command(scope = "tamaya", name = "tm_backup_create", description="Creates a backup of a current OSGI configuration.") +@Service +public class BackupCreateCommand implements Action{ + + @Reference + private TamayaConfigService configPlugin; + + @Argument(index = 0, name = "pid", description = "The target pid to backup.", + required = true, multiValued = false) + String pid; + + @Option(name = "--force", aliases = "-f", description = "Forces to (over)write a backup, even if one already exists.", + required = false, multiValued = false) + boolean replace; + + @org.apache.karaf.shell.api.action.lifecycle.Reference + ConfigurationAdmin cm; + + @Override + public Object execute() throws IOException { + return(BackupCommands.createBackup(configPlugin, cm, pid, replace)); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupDeleteCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupDeleteCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupDeleteCommand.java new file mode 100644 index 0000000..f8fe5fe --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupDeleteCommand.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.commands.BackupCommands; +import org.apache.tamaya.osgi.commands.TamayaConfigService; + +import java.io.IOException; + +@Command(scope = "tamaya", name = "tm_backup_delete", description="Deletes the OSGI configuration backup of Tamya.") +@Service +public class BackupDeleteCommand implements Action{ + + @Reference + private TamayaConfigService configPlugin; + + @Argument(index = 0, name = "pid", description = "Allows to filter on the given PID. '*' removes all backups.", + required = true, multiValued = false) + String pid; + + @Override + public Object execute() throws IOException { + return(BackupCommands.deleteBackup(configPlugin, pid)); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupListCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupListCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupListCommand.java new file mode 100644 index 0000000..edc5e88 --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupListCommand.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.commands.BackupCommands; +import org.apache.tamaya.osgi.commands.TamayaConfigService; + +import java.io.IOException; + +@Command(scope = "tamaya", name = "tm_backup_list", description="List the backed-up OSGI configuration before Tamya applied changes.") +@Service +public class BackupListCommand implements Action{ + + @Reference + private TamayaConfigService configPlugin; + + @Argument(index = 0, name = "pid", description = "Allows to filter on the given PID.", + required = false, multiValued = false) + String pid; + + @Override + public Object execute() throws IOException { + return(BackupCommands.listBackup(configPlugin, pid)); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupRestoreCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupRestoreCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/BackupRestoreCommand.java new file mode 100644 index 0000000..e053bd2 --- /dev/null +++ b/modules/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.commands.BackupCommands; +import org.apache.tamaya.osgi.commands.TamayaConfigService; + +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 + TamayaConfigService 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-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnableCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnableCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnableCommand.java new file mode 100644 index 0000000..1a7ebcf --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnableCommand.java @@ -0,0 +1,67 @@ +/* + * 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.Policy; +import org.apache.tamaya.osgi.commands.ConfigCommands; +import org.apache.tamaya.osgi.commands.TamayaConfigService; + +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 TamayaConfigService 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 candidates) { + StringsCompleter delegate = new StringsCompleter(); + for(Policy mode: Policy.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-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnabledCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnabledCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnabledCommand.java new file mode 100644 index 0000000..7b29af7 --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/DefaultEnabledCommand.java @@ -0,0 +1,62 @@ +/* + * 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.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.Policy; +import org.apache.tamaya.osgi.commands.ConfigCommands; +import org.apache.tamaya.osgi.commands.TamayaConfigService; + +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 TamayaConfigService 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 candidates) { + StringsCompleter delegate = new StringsCompleter(); + for(Policy mode: Policy.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-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/GetPolicyCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/GetPolicyCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/GetPolicyCommand.java new file mode 100644 index 0000000..71830ca --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/GetPolicyCommand.java @@ -0,0 +1,42 @@ +/* + * 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.Command; +import org.apache.karaf.shell.api.action.lifecycle.Reference; +import org.apache.karaf.shell.api.action.lifecycle.Service; +import org.apache.tamaya.osgi.commands.ConfigCommands; +import org.apache.tamaya.osgi.commands.TamayaConfigService; + +import java.io.IOException; + +@Command(scope = "tamaya", name = "tm_policy", description="Get the current Tamaya overriding policy.") +@Service +public class GetPolicyCommand implements Action{ + + @Reference + private TamayaConfigService configPlugin; + + @Override + public Object execute() throws IOException { + return ConfigCommands.getDefaultOpPolicy(configPlugin); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryDeleteAllCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryDeleteAllCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryDeleteAllCommand.java new file mode 100644 index 0000000..cca7c4c --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryDeleteAllCommand.java @@ -0,0 +1,43 @@ +/* + * 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.commands.HistoryCommands; +import org.apache.tamaya.osgi.commands.TamayaConfigService; + +import java.io.IOException; + +@Command(scope = "tamaya", name = "tm_history_delete_all", description="Deletes the full getHistory of changes Tamaya applied to the OSGI configuration.") +@Service +public class HistoryDeleteAllCommand implements Action{ + + @Reference + private TamayaConfigService configPlugin; + + @Override + public String execute() throws IOException { + return HistoryCommands.clearHistory(configPlugin, null); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryDeleteCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryDeleteCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryDeleteCommand.java new file mode 100644 index 0000000..d9df7e0 --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryDeleteCommand.java @@ -0,0 +1,45 @@ +/* + * 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.*; +import org.apache.karaf.shell.api.action.lifecycle.Reference; +import org.apache.karaf.shell.api.action.lifecycle.Service; +import org.apache.tamaya.osgi.commands.HistoryCommands; +import org.apache.tamaya.osgi.commands.TamayaConfigService; + +import java.io.IOException; + +@Command(scope = "tamaya", name = "tm_history_delete", description="Deletes the getHistory of changes Tamaya applied to the OSGI configuration.") +@Service +public class HistoryDeleteCommand implements Action{ + + @Argument(index = 0, name = "pid", description = "Allows to filter on the given PID.", + required = true, multiValued = false) + String pid; + + @Reference + private TamayaConfigService configPlugin; + + @Override + public String execute() throws IOException { + return HistoryCommands.clearHistory(configPlugin, pid); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryGetCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryGetCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryGetCommand.java new file mode 100644 index 0000000..ec221fc --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryGetCommand.java @@ -0,0 +1,69 @@ +/* + * 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.*; +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.ConfigHistory; +import org.apache.tamaya.osgi.commands.HistoryCommands; +import org.apache.tamaya.osgi.commands.TamayaConfigService; + +import java.io.IOException; +import java.util.List; + +@Command(scope = "tamaya", name = "tm_history", description="Gets the getHistory of changes Tamaya applied to the OSGI configuration.") +@Service +public class HistoryGetCommand implements Action{ + + @Reference + private TamayaConfigService configPlugin; + + @Argument(index = 0, name = "pid", description = "Allows to filter on the given PID.", + required = false, multiValued = false) + String pid; + + @Option(name = "--type", aliases = "-t", description = "Allows to filter the events types shown.", + required = false, multiValued = true) + @Completion(FilterCompleter.class) + private String[] eventTypes; + + @Override + public String execute() throws IOException { + return HistoryCommands.getHistory(configPlugin, pid, eventTypes); + } + + @Service + public static final class FilterCompleter implements Completer { + + @Override + public int complete(Session session, CommandLine commandLine, List candidates) { + StringsCompleter delegate = new StringsCompleter(); + for(ConfigHistory.TaskType taskType:ConfigHistory.TaskType.values()) { + delegate.getStrings().add(taskType.toString()); + } + return delegate.complete(session, commandLine, candidates); + } + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryMaxsizeCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryMaxsizeCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryMaxsizeCommand.java new file mode 100644 index 0000000..f736e4b --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryMaxsizeCommand.java @@ -0,0 +1,41 @@ +/* + * 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.*; +import org.apache.karaf.shell.api.action.lifecycle.Reference; +import org.apache.karaf.shell.api.action.lifecycle.Service; +import org.apache.tamaya.osgi.commands.HistoryCommands; +import org.apache.tamaya.osgi.commands.TamayaConfigService; + +import java.io.IOException; + +@Command(scope = "tamaya", name = "tm_history_maxsize", description="Gets the maximal size of stored getHistory entries.") +@Service +public class HistoryMaxsizeCommand implements Action{ + + @Reference + private TamayaConfigService configPlugin; + + @Override + public Object execute() throws IOException { + return(HistoryCommands.getMaxHistorySize(configPlugin)); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryMaxsizeSetCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryMaxsizeSetCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/HistoryMaxsizeSetCommand.java new file mode 100644 index 0000000..91f09ee --- /dev/null +++ b/modules/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.commands.HistoryCommands; +import org.apache.tamaya.osgi.commands.TamayaConfigService; + +import java.io.IOException; + +@Command(scope = "tamaya", name = "tm_history_maxsize_set", description="Sets the maximal size of Tamaya getHistory entries.") +@Service +public class HistoryMaxsizeSetCommand implements Action{ + + @Reference + private TamayaConfigService configPlugin; + + @Argument(index = 0, name = "size", description = "The maximum number of entries in the getHistory.", + required = true, multiValued = false) + int maxSize; + + @Override + public Object execute() throws IOException { + return(HistoryCommands.setMaxHistorySize(configPlugin, maxSize)); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/InfoCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/InfoCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/InfoCommand.java new file mode 100644 index 0000000..cb8f826 --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/InfoCommand.java @@ -0,0 +1,41 @@ +/* + * 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 java.io.IOException; + +import org.apache.karaf.shell.api.action.Action; +import org.apache.karaf.shell.api.action.Command; +import org.apache.karaf.shell.api.action.lifecycle.Reference; +import org.apache.karaf.shell.api.action.lifecycle.Service; +import org.apache.tamaya.osgi.commands.ConfigCommands; +import org.apache.tamaya.osgi.commands.TamayaConfigService; + +@Command(scope = "tamaya", name = "tm_info", description="Show he current Tamaya status.") +@Service +public class InfoCommand implements Action { + + @Reference + private TamayaConfigService configPlugin; + + public Object execute() throws IOException { + return(ConfigCommands.getInfo(configPlugin)); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/OSGIConfigCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/OSGIConfigCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/OSGIConfigCommand.java new file mode 100644 index 0000000..128aa78 --- /dev/null +++ b/modules/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.commands.ConfigCommands; +import org.apache.tamaya.osgi.commands.TamayaConfigService; + +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 + TamayaConfigService 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-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PolicyGetCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PolicyGetCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PolicyGetCommand.java new file mode 100644 index 0000000..e38e017 --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PolicyGetCommand.java @@ -0,0 +1,42 @@ +/* + * 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.Command; +import org.apache.karaf.shell.api.action.lifecycle.Reference; +import org.apache.karaf.shell.api.action.lifecycle.Service; +import org.apache.tamaya.osgi.commands.ConfigCommands; +import org.apache.tamaya.osgi.commands.TamayaConfigService; + +import java.io.IOException; + +@Command(scope = "tamaya", name = "tm_policy", description="Gets the current Tamaya operation policy.") +@Service +public class PolicyGetCommand implements Action{ + + @Reference + private TamayaConfigService configPlugin; + + @Override + public Object execute() throws IOException { + return(ConfigCommands.getDefaultOpPolicy(configPlugin)); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PolicySetCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PolicySetCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PolicySetCommand.java new file mode 100644 index 0000000..10e317f --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PolicySetCommand.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.Policy; +import org.apache.tamaya.osgi.commands.ConfigCommands; +import org.apache.tamaya.osgi.commands.TamayaConfigService; + +import java.io.IOException; +import java.util.List; + +@Command(scope = "tamaya", name = "tm_policy_set", description="Sets the current Tamaya operation policy.") +@Service +public class PolicySetCommand implements Action{ + + @Reference + private TamayaConfigService configPlugin; + + @Argument(index = 0, name = "tm_policy_set", description = "The operation policy how Tamaya intercepts OSGI configuration.", + required = true, multiValued = false) + @Completion(OperationModeCompleter.class) + String policy = null; + + @Override + public Object execute() throws IOException { + return(ConfigCommands.setDefaultOpPolicy(configPlugin, policy)); + } + + @Service + public static final class OperationModeCompleter implements Completer { + + @Override + public int complete(Session session, CommandLine commandLine, List candidates) { + StringsCompleter delegate = new StringsCompleter(); + for(Policy mode: Policy.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-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesCommand.java new file mode 100644 index 0000000..129e9fc --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesCommand.java @@ -0,0 +1,44 @@ +/* + * 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.Command; +import org.apache.karaf.shell.api.action.lifecycle.Reference; +import org.apache.karaf.shell.api.action.lifecycle.Service; +import org.apache.tamaya.osgi.commands.TamayaConfigService; + +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 TamayaConfigService 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-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesSetCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesSetCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesSetCommand.java new file mode 100644 index 0000000..ff5dc95 --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropagateUpdatesSetCommand.java @@ -0,0 +1,49 @@ +/* + * 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.commands.ConfigCommands; +import org.apache.tamaya.osgi.commands.TamayaConfigService; + +import java.io.IOException; + +@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 TamayaConfigService 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-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertyGetCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertyGetCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertyGetCommand.java new file mode 100644 index 0000000..72f5b4a --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertyGetCommand.java @@ -0,0 +1,49 @@ +/* + * 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.commands.ConfigCommands; + +import java.io.IOException; + +@Command(scope = "tamaya", name = "tm_property", description="Get a Tamaya property.") +@Service +public class PropertyGetCommand implements Action{ + + @Argument(index = 0, name = "key", description = "The target property source id.", + required = false, multiValued = false) + String key = null; + + @Option(name="extended", aliases = "e", description = "Also print extended property value attributes.") + boolean extended; + + @Option(name = "propertysource", aliases = "ps", description = "The target property source id.", + required = false, multiValued = false) + String propertysource = null; + + public Object execute() throws IOException { + return(ConfigCommands.getProperty(propertysource, key, extended)); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertySourceCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertySourceCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertySourceCommand.java new file mode 100644 index 0000000..97ff4ae --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertySourceCommand.java @@ -0,0 +1,41 @@ +/* + * 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.ConfigCommands; + +import java.io.IOException; + +@Command(scope = "tamaya", name = "tm_propertysource", description="Show the current Tamaya entries of a propertysource.") +@Service +public class PropertySourceCommand implements Action{ + + @Argument(index = 0, name = "propertysource", description = "The target property source id.", + required = false, multiValued = false) + String propertysource = null; + + public Object execute() throws IOException { + return(ConfigCommands.getPropertySource(propertysource)); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertySourcesCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertySourcesCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertySourcesCommand.java new file mode 100644 index 0000000..7aa660d --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/PropertySourcesCommand.java @@ -0,0 +1,39 @@ +/* + * 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.Command; +import org.apache.karaf.shell.api.action.lifecycle.Service; +import org.apache.tamaya.Configuration; +import org.apache.tamaya.ConfigurationProvider; +import org.apache.tamaya.osgi.commands.ConfigCommands; +import org.apache.tamaya.spi.PropertySource; + +import java.io.IOException; + +@Command(scope = "tamaya", name = "tm_propertysources", description="Get a list of currently registered propertysources.") +@Service +public class PropertySourcesCommand implements Action{ + + public Object execute() throws IOException { + return(ConfigCommands.getPropertySourceOverview()); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/TamayaConfigCommand.java ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/TamayaConfigCommand.java b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/TamayaConfigCommand.java new file mode 100644 index 0000000..e66d27b --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/java/org/apache/tamaya/karaf/shell/TamayaConfigCommand.java @@ -0,0 +1,53 @@ +/* + * 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.Command; +import org.apache.karaf.shell.api.action.Option; +import org.apache.karaf.shell.api.action.lifecycle.Service; +import org.apache.tamaya.osgi.commands.ConfigCommands; +import org.apache.tamaya.osgi.commands.TamayaConfigService; + +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 + TamayaConfigService 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-extensions/blob/a1cd433a/modules/osgi/karaf-shell/src/main/resources/META-INF/services/org/apache/tamaya/karaf/shell/commands ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-shell/src/main/resources/META-INF/services/org/apache/tamaya/karaf/shell/commands b/modules/osgi/karaf-shell/src/main/resources/META-INF/services/org/apache/tamaya/karaf/shell/commands new file mode 100644 index 0000000..0876782 --- /dev/null +++ b/modules/osgi/karaf-shell/src/main/resources/META-INF/services/org/apache/tamaya/karaf/shell/commands @@ -0,0 +1,44 @@ +# +# 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.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.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 +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 + + + http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/osgi/pom.xml ---------------------------------------------------------------------- diff --git a/modules/osgi/pom.xml b/modules/osgi/pom.xml new file mode 100644 index 0000000..0bcc741 --- /dev/null +++ b/modules/osgi/pom.xml @@ -0,0 +1,107 @@ + + + + + + 4.0.0 + + + org.apache.tamaya.ext + tamaya-extensions + 0.4-incubating-SNAPSHOT + + + + tamaya-osgi-all + pom + Apache Tamaya :: OSGi Integration :: ALL + Tamaya OSGI Integration + + + 1.5.0 + 1.5.1 + + 1.5.0 + 1.9.5 + 3.0 + 1.0 + 4.0.7 + 5.6.1 + 1.0.7 + + + + + + + org.apache.karaf.tooling + karaf-maven-plugin + ${dependency.karaf.version} + true + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18 + + + + + + + + org.osgi + org.osgi.service.cm + ${osgi.config.version} + provided + + + org.osgi + org.osgi.core + ${osgi.version} + provided + + + org.osgi + org.osgi.compendium + ${osgi.compendium.version} + provided + + + org.osgi + org.osgi.util.tracker + ${osgi.tracker.version} + provided + + + + + + common + updater + karaf-shell + karaf-features + gogo-shell + injection + + + http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a1cd433a/modules/pom.xml ---------------------------------------------------------------------- diff --git a/modules/pom.xml b/modules/pom.xml index 95feb73..fafe1f9 100644 --- a/modules/pom.xml +++ b/modules/pom.xml @@ -45,6 +45,8 @@ under the License. resources spring jndi + osgi + microprofile