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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <!-- + + 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. + --> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.tamaya.ext</groupId> + <artifactId>tamaya-osgi-all</artifactId> + <version>0.4-incubating-SNAPSHOT</version> + </parent> + + <artifactId>tamaya-osgi-karaf-shell</artifactId> + <packaging>jar</packaging> + <name>Apache Tamaya :: OSGI :: Karaf :: Shell</name> + <description>Tamaya Karaf Shell Commands</description> + + <dependencies> + <dependency> + <groupId>org.apache.tamaya.ext</groupId> + <artifactId>tamaya-osgi</artifactId> + <version>${project.parent.version}</version> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.compendium</artifactId> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.karaf.shell</groupId> + <artifactId>org.apache.karaf.shell.core</artifactId> + <version>${dependency.karaf.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.karaf.shell</groupId> + <artifactId>org.apache.karaf.shell.console</artifactId> + <version>${dependency.karaf.version}</version> + <scope>provided</scope> + </dependency> + </dependencies> + +</project>
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<String> 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<String> 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<String> 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<String> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <!-- + + 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. + --> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.tamaya.ext</groupId> + <artifactId>tamaya-extensions</artifactId> + <version>0.4-incubating-SNAPSHOT</version> + <relativePath/> + </parent> + + <artifactId>tamaya-osgi-all</artifactId> + <packaging>pom</packaging> + <name>Apache Tamaya :: OSGi Integration :: ALL</name> + <description>Tamaya OSGI Integration</description> + + <properties> + <osgi.config.version>1.5.0</osgi.config.version> + <osgi.tracker.version>1.5.1</osgi.tracker.version> + + <dependency.base.version>1.5.0</dependency.base.version> + <dependency.mockito.version>1.9.5</dependency.mockito.version> + <dependency.asm.version>3.0</dependency.asm.version> + <dependency.atinject.version>1.0</dependency.atinject.version> + <dependency.karaf.version>4.0.7</dependency.karaf.version> + <dependency.felix.version>5.6.1</dependency.felix.version> + <dependency.logback.version>1.0.7</dependency.logback.version> + </properties> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.karaf.tooling</groupId> + <artifactId>karaf-maven-plugin</artifactId> + <version>${dependency.karaf.version}</version> + <extensions>true</extensions> + </plugin> + </plugins> + </pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.18</version> + </plugin> + </plugins> + </build> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.service.cm</artifactId> + <version>${osgi.config.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <version>${osgi.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.compendium</artifactId> + <version>${osgi.compendium.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.util.tracker</artifactId> + <version>${osgi.tracker.version}</version> + <scope>provided</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <modules> + <module>common</module> + <module>updater</module> + <module>karaf-shell</module> + <module>karaf-features</module> + <module>gogo-shell</module> + <module>injection</module> + </modules> + +</project> 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. <module>resources</module> <module>spring</module> <module>jndi</module> + <module>osgi</module> + <module>microprofile</module> </modules> </project>
