[karaf] move trunk to karaf svn tree
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@958220 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/.gitignore b/karaf/.gitignore
deleted file mode 100644
index 7771151..0000000
--- a/karaf/.gitignore
+++ /dev/null
@@ -1,7 +0,0 @@
-*.iml
-*.ipr
-*.iws
-.project
-.classpath
-.settings
-target
diff --git a/karaf/BUILDING b/karaf/BUILDING
deleted file mode 100644
index 533852a..0000000
--- a/karaf/BUILDING
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-Building Apache Felix Karaf
-===================================
-
-Initial Setup
--------------
-
-1) Install J2SE 5.0 SDK, which can be downloaded from
- http://java.sun.com/j2se/1.5.0/download.jsp. Use version of 1.5.0_06 JDK.
-
-2) Make sure that your JAVA_HOME environment variable is set to the newly installed
- JDK location, and that your PATH includes %JAVA_HOME%\bin (windows) or
- $JAVA_HOME$/bin (unix).
-
-3) Install Maven 2.2.1, which can be downloaded from
- http://maven.apache.org/download.html. Make sure that your PATH includes
- the MVN_HOME/bin directory.
-
-
-Building
---------
-
-1) Change to the top level directory of Apache Felix Karaf source distribution.
-2) Run
- $> mvn
- This will compile Apache Felix Karaf and run all of the tests in the
- Apache Felix Karaf source distribution. Alternatively, you can run
- $> mvn -Pfastinstall
- This will compile Apache Felix Karaf without running the tests and takes less
- time to build.
- Depending on the load of remote Maven 2.0 repositories, you may have
- to run "mvn" several times until the required dependencies are
- all located in your local maven repository. It usually takes some time for
- maven to download required dependencies in the first build.
-3) The distributions will be available under "assembly/target" directory.
-
diff --git a/karaf/LICENSE b/karaf/LICENSE
deleted file mode 100644
index 6b0b127..0000000
--- a/karaf/LICENSE
+++ /dev/null
@@ -1,203 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed 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.
-
diff --git a/karaf/NOTICE b/karaf/NOTICE
deleted file mode 100644
index ddb6c19..0000000
--- a/karaf/NOTICE
+++ /dev/null
@@ -1,44 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-This product includes software written by
-Antony Lesuisse.
-Licensed under Public Domain.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-OPS4J (http://www.ops4j.org/).
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-FUSE Source (http://www.fusesource.org/).
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-JLine (http://jline.sourceforge.net).
-Licensed under the BSD License.
-
-This product uses software developed at
-SLF4J (http://www.slf4j.org/).
-Licensed under the MIT License.
-
-This product includes software from http://www.json.org.
-Copyright (c) 2002 JSON.org
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/README b/karaf/README
deleted file mode 100644
index bc6a670..0000000
--- a/karaf/README
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-Welcome to Apache Felix Karaf
-====================================
-Apache Felix Karaf is a small OSGi based kernel which provides a
-lightweight container onto which various bundles can be deployed.
-
-The following features are included:
- * Hot deployment: Karaf supports hot deployment of OSGi bundles by monitoring
- jar files inside the [home]/deploy directory. Each time a jar is copied in this folder,
- it will be installed inside the runtime. You can then update or delete it and changes will
- be handled automatically. In addition, the Kernel also supports exploded bundles and custom
- deployers (a spring one is included by default).
- * Dynamic configuration: Services are usually configured through the ConfigurationAdmin OSGi
- service. Such configuration can be defined in Karaf using property files inside
- the [home]/etc directory. These configurations are monitored and changes on the properties
- files will be propagated to the services.
- * Logging System: using a centralized logging back end supported by Log4J, Karaf
- supports a number of different APIs (JDK 1.4, JCL, SLF4J, Avalon, Tomcat, OSGi)
- * Provisioning: Provisioning of libraries or applications can be done through a number of
- different ways, by which they will be downloaded locally, installed and started.
- * Native OS integration: Karaf can be integrated into your own Operating System as
- a service so that the lifecycle will be bound to your Operating System.
- * Extensible Shell console: Karaf features a nice text console where you can manage the
- services, install new applications or libraries and manage their state. This shell is easily
- extensible by deploying new commands dynamically along with new features or applications.
- * Remote access: use any SSH client to connect to the kernel and issue commands in the console
- * Security framework based on JAAS
- * Managing instances: Karaf provides simple commands for managing instances of Karaf.
- You can easily create, delete, start and stop instances of Karaf through the console.
-
-Getting Started
-===============
-For an Apache Felix Karaf source distribution, please read
-BUILDING for instructions on building Apache Felix Karaf.
-
-For an Apache Felix Karaf binary distribution, please read
-RELEASE-NOTES for installation instructions and list of supported
-and unsupported features.
-
-The PDF manual is the right place to find any information about Karaf.
-
-Alternatively, you can also find out how to get started here:
- http://felix.apache.org/site/apache-felix-karaf.html
-
-If you need more help try talking to us on our mailing lists
- http://felix.apache.org/site/mailinglists.html
-
-If you find any issues with Apache Felix Karaf, please submit reports
-with JIRA here:
- http://issues.apache.org/jira/browse/FELIX
-
-We welcome contributions, and encourage you to get involved in the
-Felix community. If you'd like to learn more about how you can
-contribute, please see:
- http://felix.apache.org/site/contributing.html
-
-Many thanks for using Apache Felix Karaf.
-
-
-The Felix Team
-
diff --git a/karaf/RELEASE-NOTES b/karaf/RELEASE-NOTES
deleted file mode 100644
index c171666..0000000
--- a/karaf/RELEASE-NOTES
+++ /dev/null
@@ -1,605 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
- Apache Felix Karaf 1.2.0
- ========================
-
- Overview
- --------
-
- This release is mostly a bug fix release and contains a lot of bug fixes and improvements in the console,
- commands, features service, instance administration. The binary distribution now also includes the user's
- manual in pdf and html formats.
-
- Changelog
- ---------
-
- The following list shows the bug fixes and enhancements included in this release:
-
-** Sub-task
- * [FELIX-1701] - Aggregate all the Karaf related pages in one single Confluence page using the include macro
-
-** Bug
- * [FELIX-1620] - Script for running the created Karaf instances with a console
- * [FELIX-1626] - Configuration loaded from the etc/ directory are only available after a delay
- * [FELIX-1638] - [karaf] The branding properties load can't find the external branding file
- * [FELIX-1642] - osgi:shutdown just hang when use karaf-client.jar
- * [FELIX-1660] - karaf should not hardcode the "system" location of its maven-like repository
- * [FELIX-1681] - Bundles of webconsole feature are not assembled into distribution packages
- * [FELIX-1705] - [Karaf] Hot undeploy does not work after a Karaf restart
- * [FELIX-1715] - osgi:update on xml deployments will cause ZIPExceptions
- * [FELIX-1717] - osgi:list column for spring is sometimes filled and sometimes not
- * [FELIX-1723] - [Karaf] Slave instances on same host as Master instance does not properly lock.
- * [FELIX-1728] - Karaf itest fail on IBM JDK due to Pax Exam annotations not found
- * [FELIX-1730] - When displaying help for commands, arguments are not ordered correctly
- * [FELIX-1745] - Unable to alter/unset a log level after it has been set from the console
- * [FELIX-1751] - [karaf] admin:start silently fails to launch new instance
- * [FELIX-1766] - Refactor and enable AdminServiceMBean
- * [FELIX-1768] - should catch exception for FeaturesServiceImpl.internalAddRepository per uri
- * [FELIX-1771] - Feature deployer is broken on windows
- * [FELIX-1777] - Hitting backspace beyond last character causes LOUD BEEP
- * [FELIX-1778] - instances/myinst/bin/karaf.bat leaks environment variables to shell
- * [FELIX-1779] - The port for the jmx server needs to be configured at two locations
- * [FELIX-1784] - install one feature failed in org.apache.felix.karaf.features.cfg featuresBoot list shouldn't block install other features in this list
- * [FELIX-1786] - The features deployment listener tacks installed bundles and force their resolution
- * [FELIX-1793] - ensure launch karaf java process from KARAF_BASE folder
- * [FELIX-1799] - Hot-deployment does not work on admin:create'd instances
- * [FELIX-1801] - Case insensitive grep outputs all uppercase in match results
- * [FELIX-1802] - Grep command line prefix (-n) not working properly
- * [FELIX-1803] - Unable to edit or backspace on multiline commands
- * [FELIX-1805] - Upgrade equinox to 3.5.1
- * [FELIX-1817] - Backspace does not work anymore when connecting from the karaf-client
- * [FELIX-1818] - Ctrl-C kills the karaf-client, but it should be sent to the server
- * [FELIX-1855] - exec command eats first keystroke of subsequent commands
- * [FELIX-1857] - Backspace not working when using admin:connect
- * [FELIX-1858] - Remote commands via ssh only work once per restart
- * [FELIX-1869] - Need better UI feedback when features commands fail
- * [FELIX-1877] - karaf.main.BootstrapLogManager possible resource leak and ignored exception in open method.
- * [FELIX-1878] - karaf.main.Main possible resource leaks and ignored exceptions from mkdirs().
- * [FELIX-1887] - The stop script can't be used if the user or password has been changed
- * [FELIX-1888] - The karaf client hangs if the authentication fails
- * [FELIX-1899] - Karaf itest (CoreTest) fails on slower CI machines
-
-** Improvement
- * [FELIX-1064] - New goal for the features-maven-plugin: validate a features xml file
- * [FELIX-1207] - [PATCH] Ignore files generated by mvn:eclipse
- * [FELIX-1643] - Improvements / Fixes for Karaf commands and their helps
- * [FELIX-1655] - Provide an additional argument to the Karaf admin:create command that specifies the featuresBoot
- * [FELIX-1675] - karaf web demo README references old servicemix-client.jar
- * [FELIX-1682] - The newly installed bundles for a feature should be uninstalled when feature install failed
- * [FELIX-1689] - When deploying a feature, we need to refresh some bundles to cope with newly resolved optional dependencies
- * [FELIX-1693] - [karaf][shell] Make "system bundles" start level configurable via properties
- * [FELIX-1694] - [karaf][shell] Do not print stack traces on exceptions
- * [FELIX-1700] - Create quality PDF manual for Karaf
- * [FELIX-1706] - Highlight grep matches
- * [FELIX-1707] - Add OSGi framework information to InfoAction
- * [FELIX-1718] - karaf shell config:update command should persist / override configurations from the etc/ folder
- * [FELIX-1729] - The if / each commands are not available in the console
- * [FELIX-1737] - Upgrade to fileinstall 2.0.4
- * [FELIX-1744] - Add a -C/--context option to shell:grep
- * [FELIX-1748] - Make the command history persistent across restarts
- * [FELIX-1749] - Improve log:set command - add auto-completion for log levels and support lower case level
- * [FELIX-1752] - [Karaf] Extend DefaultJDBCLock to support MySQL out of the box.
- * [FELIX-1755] - Provide a script file that would be loaded when starting a new shell (to create closures, etc...)
- * [FELIX-1757] - Completer for session scopes
- * [FELIX-1759] - Upgrade to latest webconsole
- * [FELIX-1772] - Upgrade to felix framework 2.0.1
- * [FELIX-1791] - Update to the karaf web demo readme.
- * [FELIX-1810] - Improvements to Main startup class
- * [FELIX-1882] - [karaf] karaf-client should have the option to retry connection establishment
-
-** New Feature
- * [FELIX-1656] - new Shell command: shell:clear
-
-** Task
- * [FELIX-1091] - Re-enable gshell integration tests on windows
- * [FELIX-1761] - Include felix as a platform for the karaf integration tests
- * [FELIX-1762] - Upgrade to pax-web 0.7.1
- * [FELIX-1763] - Upgrade to latest pax-url
- * [FELIX-1848] - Include instance name in the JMX ObjectName for AdminService and FeaturesService MBeans
- * [FELIX-1849] - Provide Instance details for root instance via AdminServiceMBean.getInstances() attribute
- * [FELIX-1850] - Expose additional isRoot attribute on AdminServiceMBean
- * [FELIX-1892] - Upgrade to sshd-0.3.0, mina-2.0.0-RC1, gogo-0.2.2, jansi-1.1
-
-
-
- Apache Felix Karaf 1.0.0
- ========================
-
- Overview
- --------
-
- The Apache Felix Karaf 1.0.0 release is the first release since the move of ServiceMix Kernel to Apache Felix.
- This release brings a lot of new features:
- * Switch from Spring-DM to Blueprint for the default Dependency Injection container (Spring-DM is still
- fully supported and easy to install through the features service)
- * Switch from Geronimo GShell to Felix Gogo
- This changes is a bit disruptive for the command line syntax, but offers much more features such
- as closures
- * Integration with the Felix Web Console (easily installed using the features service).
- * Built-in support for Equinox
- * Upgrade to OSGi 4.2 frameworks (both Felix and Equinox)
- This release also contains a lot of small improvements and bug fixes. The changelog below contains the whole
- list of changes.
-
-
- Changelog
- ---------
-
- The following list shows the bug fixes and enhancements included in this release:
-
- ** Bug
- * [FELIX-1087] - Unable to log into ServiceMix Kernel using Windows putty SSH client
- * [FELIX-1097] - ServiceMix -> Karaf in base directory notices
- * [FELIX-1100] - Cat Command fails to display ?wsdl files
- * [FELIX-1125] - "features/list -i" returns "ERROR CommandLineExecutionFailed: org.apache.geronimo.gshell.command.CommandException: java.lang.ArrayStoreException: org.apache.servicemix.kernel.gshell.features.internal.FeatureImpl"
- * [FELIX-1128] - Features installed via the deploy directory aren't listed by the "features/list" command
- * [FELIX-1152] - wrapper scripts fail to start Karaf
- * [FELIX-1153] - change parent artifact id from kernel to karaf in some modules to make the build pass from clean local maven repo
- * [FELIX-1161] - Stange classloading issues when using compendium services
- * [FELIX-1192] - KARAF: Locking error in DefaultJDBCLock, also contains an eventual OutOfMemory error on locked processes.
- * [FELIX-1199] - Karaf: closing IO stream, removal of minor file descriptor leak.
- * [FELIX-1212] - Possible infinit loop when a remote ssh connection is closed
- * [FELIX-1218] - Existing configurations are not retrieved when installing a feature
- * [FELIX-1222] - [features-maven-plugin:add-features-to-repo] Incorrect parsing of pax mvn url string
- * [FELIX-1243] - Change the default port for the OSGI HTTP Service from 8080 to 8181
- * [FELIX-1253] - Cursor is blocked when the correct syntax is not displaed
- * [FELIX-1265] - The command refreshUrl does not work if the features.xml file is embedded in a Jar. The JVM caches jar entries
- * [FELIX-1274] - Spring deployer fails when bean class is from java.* packages
- * [FELIX-1315] - Karaf console is garbled on Windows
- * [FELIX-1320] - Authentication failed connecting via ssh on Windows
- * [FELIX-1361] - Issue with import/export version of the package : org.osgi.util.tracker in Apache Felix Karaf
- * [FELIX-1373] - featuresBoot in etc/org.apache.felix.karaf.featues no longer works
- * [FELIX-1375] - [Karaf] There's no 'help' command
- * [FELIX-1378] - Optional branding does not work in new gogo console
- * [FELIX-1391] - Unable to create new ConfigAdmin PID through karaf console
- * [FELIX-1423] - karaf fails to start in cygwin bash
- * [FELIX-1431] - Add a web console plugin to have access to the gogo shell
- * [FELIX-1449] - Tab completion doesn't work on Windows
- * [FELIX-1454] - install --help throws exception
- * [FELIX-1458] - 'servicemix server' and servicemix client' not working properly on windows
- * [FELIX-1459] - bin/karaf may fail to start when CDPATH is set (on POSIX shells)
- * [FELIX-1465] - Make symbolic names of Karaf webconsole bundles consistent with other bundles
- * [FELIX-1466] - org.apache.felix.karaf.features.FeaturesServiceTest fails
- * [FELIX-1468] - wrapper:install and admin:create prints old ansi output that need to be converted to real ansi
- * [FELIX-1472] - Better handling of configurations from the deployer and feature service
- * [FELIX-1515] - Entering an illegal command has an unusual effect
- * [FELIX-1517] - Manually deleting an instance breaks admin:list
- * [FELIX-1519] - Karaf Failover does not work with PostgreSQL and Oracle
- * [FELIX-1529] - The console does not work anymore when connecting to another karaf instance
- * [FELIX-1564] - Authentication failed when using admin:connect to connect to a newly created instance
- * [FELIX-1566] - Possible NPE when uninstalling a feature
- * [FELIX-1567] - When dropping an empty xml file (i.e. just an empty file with an xml extension) in the deploy folder, errors are printed to the console
- * [FELIX-1575] - The JMX connector can not be registered because of a clash in the name in the RMI registry
- * [FELIX-1576] - The features service should do a PackageAdmin.refresh() after uninstalling a feature
- * [FELIX-1602] - Unable to configure boot features on admin:create-d instance
- * [FELIX-1618] - in spring-dm feature, optional imports in spring-context won't get resolved
-
- ** Improvement
- * [FELIX-1062] - Upgrade to latest Felix Runtime
- * [FELIX-1063] - Upgrade to latest Felix Bundle Repository
- * [FELIX-1092] - The client jar / ssh deamon should support direct commands
- * [FELIX-1102] - Make gshell-core really independant of the MainService
- * [FELIX-1104] - Allow osgi/stop command to specify more than one bundle per command entry.
- * [FELIX-1107] - Make org.apache.servicemix.kernel.gshell.features dependency on org.apache.servicemix.kernel.filemonitor optional
- * [FELIX-1110] - Refactor filemonitor / deployers inside a deployer sub module
- * [FELIX-1112] - [PATCH] Allow osgi/start command to specify more than one bundle per command entry
- * [FELIX-1115] - Use better version ranges for imports
- * [FELIX-1121] - Add feature for installing Felix Web Console
- * [FELIX-1126] - No errors are generated for a bad URL passed to the "features/addUrl", "features/refreshUrl", or "features/list" commands.
- * [FELIX-1127] - Add a name for a repository
- * [FELIX-1133] - Allow usage of fragments in Karaf features
- * [FELIX-1149] - Describe ConfigAdmin configurations using metatype
- * [FELIX-1150] - Upgrade to SpringDM and SpringFramework
- * [FELIX-1172] - Rebrand Karaf locking mechanism.
- * [FELIX-1180] - Improve Karaf DefaultJDBCLock to use proper logging mechanism instead of System err prints.
- * [FELIX-1196] - Felix Web Console can't list Karaf features
- * [FELIX-1204] - Fix the karaf client to allow direct execution of commands
- * [FELIX-1220] - Remove unnecssary parts of a filter
- * [FELIX-1276] - There is no way to get all the Feature information from the FeaturesService
- * [FELIX-1303] - add an osgi/imports and osgi/exports to show a pretty-printed output of the imports/exports packages for a bundle
- * [FELIX-1450] - Karaf branding and plugins for Felix webconsole
- * [FELIX-1455] - OSGi Storage is hardcoded to be data/cache
- * [FELIX-1457] - Externalize and refactory management layer for FeatureService to be more scalable and more consistent with the OSGi management (using open mbeans)
- * [FELIX-1463] - Switch to Felix Fileinstall instead of our own file deployer
- * [FELIX-1467] - Add Karaf to top-level build files
- * [FELIX-1469] - Add svn:ignore property to a few Karaf projects
- * [FELIX-1528] - [karaf] Use a defined location for storing the list of managed instances create by the admin service
- * [FELIX-1555] - The osgi:list command should print spring-dm bundle state if spring-dm has been deployed
- * [FELIX-1558] - use com.sun.* instead of com.sun.management* for boot delegation
- * [FELIX-1594] - include blueprint bundle in karaf kit system folder
-
- ** New Feature
- * [FELIX-1109] - Deployer for blueprint applications
- * [FELIX-1111] - Ability to run Karaf on Equinox
- * [FELIX-1206] - [PATCH] config/propappend
- * [FELIX-1261] - Install/Uninstall Karaf Features from Felix WebConsole
- * [FELIX-1485] - Admin commands support in Karaf webconsole
- * [FELIX-1524] - Implement a better tac command
- * [FELIX-1547] - OS shell level admin commands for Karaf
-
- ** Task
- * [FELIX-1098] - Switch from spring-dm to blueprint
- * [FELIX-1099] - Switch from spring-dm integration tests to pax-exam
- * [FELIX-1116] - Rename to Apache Felix Karaf
- * [FELIX-1200] - Move features-maven-plugin into Karaf
- * [FELIX-1312] - Switch from gshell to gogo
- * [FELIX-1523] - Fix Karaf version to 0.9.0-SNAPSHOT as next release will be 1.0.0
-
- ** Sub-task
- * [FELIX-1117] - Update branding
- * [FELIX-1118] - Update shell scripts
- * [FELIX-1132] - Get rid of the JMX spring stuff in gshell-features
-
-
-
-
- Apache ServiceMix Kernel 1.1.0
- ==============================
-
- Overview
- --------
-
- The Apache ServiceMix Kernel 1.1.0 release brings a lot of new features enhancements and bug fixes:
- * remote connection using SSH protocol
- * provisioning enhancements: versioning / hot deployment of features
- * new commands, including OSGi related commands for the Configuration Admin and Package Admin services
- * improved spring integration: upgrade to spring 2.5.6 and spring-dm 1.2.0-m2, the osgi/list command
- now displays spring applications status
- * container level locking for master / slave deployments
- * support for JAXP 1.4 on all platforms
- * improved JMX support for managing the OSGi framework and features
- Note that the commands syntax has changed due to the upgrade to the latest gshell version.
-
- Known issues
- ============
-
- * [SMX4KNL-141] - The config/edit command changes does not takes precedence over configuration files in the etc folder at restart
- * [SMX4KNL-183] - features/uninstall behaves different in version selection than features/install
- * [SMX4KNL-189] - Shell completion works only in the root shell
- * [SMX4KNL-200] - The client jar / ssh daemon should support direct commands
- * [SMX4KNL-227] - Full support of fragment bundles
- * [SMX4KNL-228] - Warning messages when using OpenSSH 5.1 to connect to ServiceMix Kernel
- * [SMX4KNL-231] - Unable to log into ServiceMix Kernel using OpenSolaris SSH client
- * [SMX4KNL-232] - Unable to log into ServiceMix Kernel using Windows putty SSH client
-
- Changelog
- ---------
-
- The following list shows the bug fixes and enhancements included in this release:
-
- ** Bug
- * [SMX4KNL-72] - If there is no etc/startup.properties, the kernel hangs without displaying any error
- * [SMX4KNL-79] - When starting the kernel, a log entry states "Can not install feature ''"
- * [SMX4KNL-86] - When running integration tests, the container classpath contains all the test bundles which may cause problems
- * [SMX4KNL-87] - Problems with batch files on windows
- * [SMX4KNL-95] - kernel build failed in testing/itests
- * [SMX4KNL-96] - package missing for felix.config.properties
- * [SMX4KNL-97] - Dissociate the name and the location of ServiceMix Kernel instances managed by the admin shell
- * [SMX4KNL-100] - The client does not close when running "osgi shutdown" command
- * [SMX4KNL-102] - The file monitor should use ${servicemix.base} for default polling locations
- * [SMX4KNL-104] - When using a remote connection, errors are not reported correctly
- * [SMX4KNL-105] - Features are reinstalled on restart of servicemix
- * [SMX4KNL-112] - gshell pom needs to include gshell-config and gshell-packages modules
- * [SMX4KNL-115] - config.properties for SMX-Kernel needs to be updated
- * [SMX4KNL-117] - The Smx testing platform should take into account the boot delegation packages specified in the configuration file
- * [SMX4KNL-118] - The configuration file for felix comes from 3 different places in the svn tree, only one copy should be used
- * [SMX4KNL-122] - When using the client and trying to connect to another instance using the "admin connect" command, the console hangs
- * [SMX4KNL-123] - XML parsing does not work on non Sun JVMs and Sun's SAAJ bundle requires Sun's JAXP implementation
- * [SMX4KNL-124] - Issuing command "log d" fails with NullPointerException on AIX.
- * [SMX4KNL-126] - The user is no more authenticated with the new gshell integration
- * [SMX4KNL-128] - Remove OBR support from default distribution
- * [SMX4KNL-132] - osgi/list command should display the spring application state
- * [SMX4KNL-133] - jaxp-ri bundle miss javax.xml.datatype.DatatypeFactory factoryId under META-INF/services
- * [SMX4KNL-134] - XPathFactoryFinder in jaxp api should use factoryId to load the spi class in osgi enviroment
- * [SMX4KNL-135] - Remote shell missing help resources
- * [SMX4KNL-138] - No command history with Shell console
- * [SMX4KNL-140] - Shell commands references not cleaned up when bundle uninstalled
- * [SMX4KNL-142] - Starting a new instance that was created with admin on windows fails to start
- * [SMX4KNL-145] - java.lang.IllegalStateException: Streams not registered for thread
- * [SMX4KNL-148] - OPS4J maven repo missing form default search list
- * [SMX4KNL-149] - Build failure due to new sshd snapshot
- * [SMX4KNL-150] - Shell group name variable doesn't resolve
- * [SMX4KNL-151] - Update displayed version in Shell to be 1.1.0-SNAPSHOT for trunk
- * [SMX4KNL-153] - Stopping one of the "core" bundles of the servicemix engine block the server
- * [SMX4KNL-155] - Error changing manifest while bundle is deployed
- * [SMX4KNL-162] - The default jaas realm uses the config admin to store clear password
- * [SMX4KNL-164] - features/removeUrl does not remove the repository
- * [SMX4KNL-165] - Initial provisioning using features is very slow especially when using snapshots
- * [SMX4KNL-170] - Unknown protocol: org.apache.servicemix.kernel.gshell
- * [SMX4KNL-172] - the new command optional/cat from gshell can't support mvn/http protocol
- * [SMX4KNL-174] - NoClassDefFoundError jline/ConsoleReader when invoking servicemix-client
- * [SMX4KNL-176] - 'features/install xxx' tries to install version 0.0.0 instead of the latest one
- * [SMX4KNL-177] - Some of the Optional commands have moved to different packages in the latest snapshot of geronimo gshell
- * [SMX4KNL-178] - Remove debug log statements when booting
- * [SMX4KNL-180] - features/install xxx barfs when using non osgi compliant versions
- * [SMX4KNL-181] - osgi/install -s throws a NPE if the bundle can not be resolved
- * [SMX4KNL-182] - Upon restart, the list of previously installed features is not available anymore
- * [SMX4KNL-185] - Features JMX view does not reload persistent state on restart
- * [SMX4KNL-187] - Features JMX view making too much log noise
- * [SMX4KNL-188] - Gshell itests fail on windows
- * [SMX4KNL-190] - Deployment / Startup of spring xml configurations doesn't work correctly
- * [SMX4KNL-192] - ServiceMix Kernel startup blocks
- * [SMX4KNL-198] - The console / server / client arguments to servicemix shell script are broken
- * [SMX4KNL-199] - Missing resource bundle for obr shell
- * [SMX4KNL-201] - The client jar does not exit when running with --help argument
- * [SMX4KNL-202] - Startup of a pending to deploy Spring config file fails when all required bundles got installed
- * [SMX4KNL-204] - OsgiConfiguration.unregister() throw NPE when exit smx
- * [SMX4KNL-205] - "ld | grep WARN" does not filter while "log/display | grep WARN" does
- * [SMX4KNL-207] - features/install should install latest feature version for any dependency that does not explicitly specify a dependency
- * [SMX4KNL-208] - Bundle#loadClass sometimes return null instead of throwing a CNFE
- * [SMX4KNL-212] - Exceptions are displayed in the console when trying to load default xml catalogs
- * [SMX4KNL-215] - Don't attempt to stop fragments in filemonitor
- * [SMX4KNL-218] - Can't find bundle for base name org.apache.servicemix.kernel.gshell.wrapper.InstallCommand, locale fr_BE
- * [SMX4KNL-220] - The org.apache.servicemix.kernel.management bundle should not use DynamicImport-Package=*
-
- ** Improvement
- * [SMX4KNL-36] - Investigate having a different bootstrap mechanism for a remote client to not start all the bundles installed (maybe by not using osgi)
- * [SMX4KNL-62] - Enhance admin shell create command to allocate unique ports to new instances.
- * [SMX4KNL-74] - When using the spring deployer, allow the customization of the OSGi manifest entries
- * [SMX4KNL-78] - Small refactoring of the Feature interface
- * [SMX4KNL-85] - Extend Shell#waitForFrameworkToStart to wait 60 seconds instead of 5 seconds.
- * [SMX4KNL-101] - Reduce the amount of logging issued by mina
- * [SMX4KNL-106] - Support for container level lock to support master/slave deployments
- * [SMX4KNL-114] - prompt should print username@instance-name when using remote shell
- * [SMX4KNL-119] - Use boot delegation instead of listing sun packages for jaxp / url handlers
- * [SMX4KNL-120] - The ServiceMix Kernel testing platform should use the servicemix kernel main jar instead of the felix one
- * [SMX4KNL-121] - Improve the Main class to easily embed the whole ServiceMix Kernel distribution in another web application
- * [SMX4KNL-125] - Show command environment in kernel shell
- * [SMX4KNL-127] - Add the update command in the osgi shell
- * [SMX4KNL-130] - Support configurable lock directory for container level locking (for master/slave deployments).
- * [SMX4KNL-136] - Upgrade to pax logging 1.2.0
- * [SMX4KNL-154] - some Action moved from to another package cause kernel start up failed
- * [SMX4KNL-158] - Move jline into its own bundle instead of using a private package in gshell-core
- * [SMX4KNL-169] - Use the start level to implement the container level locking
- * [SMX4KNL-184] - Align the commands name with the gshell ones
- * [SMX4KNL-186] - features/uninstall should select the right version if only one version has been installed
- * [SMX4KNL-191] - Upgrade to pax-logging 1.3.0
- * [SMX4KNL-203] - When installing a feature, the service should first install all bundles, then start them all in order
- * [SMX4KNL-206] - Felix version in servicemix-kernel-1.1.0-snapshot doesn't seem to support fragment bundles.
- * [SMX4KNL-216] - Display fragments informations in the osgi list command
- * [SMX4KNL-230] - Log statements using java.util.logging are logged into both stderr and data/log/servicemix.log file
-
- ** New Feature
- * [SMX4KNL-28] - Create a config command to administer the ConfigAdmin service
- * [SMX4KNL-33] - Enhance admin shell to provide commands to start / stop / list / connect to known ServiceMix instances
- * [SMX4KNL-60] - Versionning of features
- * [SMX4KNL-76] - support to install/uninstall different version of features
- * [SMX4KNL-90] - Create new commands to leverage the PackageAdmin OSGi service
- * [SMX4KNL-94] - Provide a JMX frontend on top of the features service
- * [SMX4KNL-107] - Create a new "admin connect" command to easily connect to a named instance of servicemix
- * [SMX4KNL-108] - Add a new 'log de' command that displays the last exception from the log
- * [SMX4KNL-109] - Include the pax wrapper url handler in the kernel for ease of use of non osgi third party dependencies
- * [SMX4KNL-111] - Add a "starting" state to the admin list command
- * [SMX4KNL-113] - Upgrade to Felix 1.2.1
- * [SMX4KNL-116] - Allow repository descriptors to reference other repository descriptors
- * [SMX4KNL-131] - Include JAXP 1.4 API
- * [SMX4KNL-143] - Provide a way to make BouncyCastle work in ServiceMix Kernel
- * [SMX4KNL-144] - Use SSH as a remoting protocol to connect to a servicemix kernel
- * [SMX4KNL-147] - Upgrade to spring-DM 1.2.0-m2
- * [SMX4KNL-152] - The version number displayed in the console should be extract from resources (using maven filtering + properties file) but the branding should be easy to change so that people embedding the Kernel can define their own
- * [SMX4KNL-156] - Move core management feature to the kernel
- * [SMX4KNL-157] - Add a JAAS realm for authenticating users from SSH and JMX
- * [SMX4KNL-163] - Provide default jdbc lock impl for master/slave deployments
- * [SMX4KNL-167] - Upgrade to spring 2.5.6
- * [SMX4KNL-171] - Include RFC0139 (JMX management of OSGi)
- * [SMX4KNL-179] - Upgrade to felix 1.5.0-SNAPSHOT
- * [SMX4KNL-214] - Hot deployment of features through the deploy folder
-
- ** Task
- * [SMX4KNL-43] - Upgrade to latest gshell
- * [SMX4KNL-93] - Extract the admin commands in their own module
- * [SMX4KNL-98] - Use dependency management section for all dependencies
- * [SMX4KNL-99] - Remove ant from the kernel distribution and replace its use in the filemonitor
- * [SMX4KNL-129] - Make sure aliases and links commands work with the new gshell integration
- * [SMX4KNL-166] - Move the embedded smx demo into trunk
- * [SMX4KNL-168] - Downgrade to junit 3.8
- * [SMX4KNL-196] - gshell-core source jar should use the shade plugin to include the gshell sources
- * [SMX4KNL-197] - The client source jar should include the slf4j sources using the shade plugin
- * [SMX4KNL-211] - Remove one of jmock or easymock from the kernel
-
-
-
-
- Apache ServiceMix Kernel 1.0.0
- ==============================
-
- Overview
- --------
-
- This release is the first GA release of ServiceMix Kernel. A few bugs and enhancements have been done
- to the Kernel since the second release candidate. The most two important fixes from a user point of view
- are SMX4KNL-70 which makes sure the bundles provided in the distribution are used first instead of the ones
- from the user's local maven repository and SMx4KNL-77 which allows artifacts in the /deploy folder to be
- started when the needed dependencies have been installed successfully (the previous behavior was to fail
- if there were missing bundles when the artifact is processed).
- See the change log below for more informations.
-
- Changelog
- ---------
-
- The following list shows the bug fixes and enhancements included in this release:
-
- ** Bug
- * [SMX4KNL-70] - Bundles in /system folder should take precedence over local Maven repository
- * [SMX4KNL-79] - When starting the kernel, a log entry states "Can not install feature ''"
- * [SMX4KNL-80] - "features list" output has a "version" column but no infos
- * [SMX4KNL-81] - The wrapper feature can not be installed out of the box
- * [SMX4KNL-82] - The installation state of a feature is not displayed correctly after a restart when using the "features list" command
- * [SMX4KNL-83] - When using the wrapper command, ServiceMix Kernel does not start correctly
-
- ** Improvement
- * [SMX4KNL-69] - Add installation status for the 'features list' result.
- * [SMX4KNL-71] - Export the gshell CommandExecutor in the OSGi registry
- * [SMX4KNL-73] - Require work around for blocking in.read() call in ProxyIO for automated testing.
- * [SMX4KNL-75] - Modify Shell argument processing to execute multiple commands.
- * [SMX4KNL-77] - The deployer should keep a list of installed bundles that failed to start and retry those when new bundles have been resolved
- * [SMX4KNL-78] - Small refactoring of the Feature interface
-
-
-
- Apache ServiceMix Kernel 1.0.0-rc2
- ==================================
-
-Overview
---------
-
-This second Release Candidate of Apache ServiceMix Kernel includes a few bug fixes and a few new features.
-The main change is that the system folder that contains the OSGi bundles to install in the runtime is now
-organized as a maven 2 repository, though it should not directly affect users. A more detailed changelog
-is following.
-
-Changelog
----------
-
-The following list shows the bug fixes and enhancements included in this release:
-
-** Bug
- * [SMX4KNL-34] - snapshot jar name mismatch in startup.properties and in the system folder
- * [SMX4KNL-52] - Deployment of pain spring files does not work when using xml extensions because these are not available in the classpath
- * [SMX4KNL-53] - During starting, files are redeployed several times, one each time a new Deployer is registered in OSGi
- * [SMX4KNL-54] - Kernel does not start if system property "felix.cache.profiledir" is not defined
- * [SMX4KNL-56] - Kernel does not start on Windows if classpath contains spaces
- * [SMX4KNL-58] - Hot-deploy capability of FileMonitor does not update bundles properly on Windows.
- * [SMX4KNL-63] - Possible deadlock at startup caused by the filedeployer not running in its own thread the first time
- * [SMX4KNL-64] - The list of repositories for the features shell is not persisted across restart
- * [SMX4KNL-65] - After copying or moving the kernel, it does not start in a very clean way anymore
- * [SMX4KNL-68] - failed to start smx4
-
-** Improvement
- * [SMX4KNL-51] - Add a configuration file for the maven url handler so that adding default repositories is easy enough
- * [SMX4KNL-55] - Use maven shade plugin on the main module so that sources jar is correct
- * [SMX4KNL-66] - When the file monitor loads configuration for the config admin, allow the use of system properties using ${xxx}
-
-** New Feature
- * [SMX4KNL-61] - Organize the system folder as a maven 2 repository
- * [SMX4KNL-67] - Allow the features service to obtain a list of features to install at startup
-
-** Task
- * [SMX4KNL-57] - Extract bundles from the svn tree
- * [SMX4KNL-59] - Upgrade to spring 2.5.5 / spring-dm 1.1.0
-
-
-
- Apache ServiceMix Kernel 1.0-rc1
- ================================
-
-This first Release Candidate of Apache ServiceMix Kernel includes a security framework based on
-JAAS allowing authentication using JAAS realms deployed at runtime and also allow keystores and
-trustores to be deployed and accessed through OSGi. This allow the remote console to be secured
-correctly (if the console is activated in a production environment, we strongly recommand to
-deploy a custom JAAS realm and new keystores when using the SSL connection). A few bugs have been
-fixed too.
-
-A release candidate (RC) is a distribution that has not been proven completely stable, but the
-feature set is the one that will be available in the final release. The number of RCs has not
-been fixed and it will depend on the feedback we obtain from this release, so please give it a try
-and report any problems you can find.
-
-** Bug
- * [SMX4KNL-38] - Fix NullPointerException instead of Command not found in the console
- * [SMX4KNL-40] - Remote console does not display output
- * [SMX4KNL-41] - When using the remote command on the client from the command line, the process does not exit correctly
- * [SMX4KNL-44] - Changed bundles restarted twice
- * [SMX4KNL-45] - The "log display" command does not display anything when running from an instance that has been created using the "admin create" command
- * [SMX4KNL-46] - After using the 'admin create' command, cpu goes to 100% until another command is entered
- * [SMX4KNL-48] - ulimit error on MacOS X Leopard 10.5
- * [SMX4KNL-50] - Kernel does not start on Windows
-
-** Improvement
- * [SMX4KNL-39] - Make bundle locations for SMX configurable
- * [SMX4KNL-49] - Upgrade to Spring 2.5.4, Spring-DM 1.1.0-m2, PaxLogging 1.1.1
-
-** New Feature
- * [SMX4KNL-35] - Secure the connection between the client and the kernel in some way
- * [SMX4KNL-37] - JAAS support
-
-
- Apache ServiceMix Kernel 1.0-m3
- ================================
-
-This third milestone of Apache ServiceMix Kernel brings a lot of new features:
- * a provisioning system to install applications easily
- * a log shell to visualize the logging output and change log levels
- * pipe support on commands
- * a bunch of new commands: history, grep, cat, ava, exec, sleep
-
-Note that this milestone does not include the latest spring version because
-the latest ones have wrong OSGi manifest headers and do not work.
-
-** Bug
- * [SMX4KNL-22] - The console can not be reloaded at runtime
- * [SMX4KNL-29] - Shell commands are not unregistered automatically when the last command is unregistered
- * [SMX4KNL-31] - Aliases do not work when inside a subshell
-
-** Improvement
- * [SMX4KNL-5] - Show gshell sub-shell name in prompt
- * [SMX4KNL-6] - Error Message improvement on Gshell console.
- * [SMX4KNL-10] - Handle dependant features correctly
- * [SMX4KNL-21] - Allow pipes in command syntax
- * [SMX4KNL-25] - Feature commands enhancement.
- * [SMX4KNL-32] - Lazy load feature repositories to avoid delay when the url can not be accessed or things like that
-
-** New Feature
- * [SMX4KNL-1] - Implements a log command
- * [SMX4KNL-11] - Provisioning system
- * [SMX4KNL-20] - Adding a new OBR command to reload the repository url's
- * [SMX4KNL-23] - Add a grep command
- * [SMX4KNL-24] - Add a few utils commands: cat, java, exec, sleep
- * [SMX4KNL-26] - Spring URL handler to wrap xml spring files into bundles for direct installation.
- * [SMX4KNL-27] - Include an implementation of the Preferences service
- * [SMX4KNL-30] - Create an history command to be able to browse previous commands easily
-
-
- Apache ServiceMix Kernel 1.0-m2
- ================================
-
-This is the second milestone of ServiceMix Kernel, but mostly a bug fix release
-compared to the first milestone.
-
-** Bug
- * [SMX4KNL-13] - startup issue in recognizing new files in deploy folder
- * [SMX4KNL-15] - Display of memory size using the info command on Windows is ugly
- * [SMX4KNL-16] - Bad error message when startup.properties lists a unknown file (the file name is not displayed, but 'null' instead)
- * [SMX4KNL-18] - No need for DynamicImport-Package=* in filemonitor
- * [SMX4KNL-19] - Performance problems when using the OSGi classloaders in a certain way
-
-** Improvement
- * [SMX4KNL-4] - Add a start option on the 'osgi install' command so that the bundle is automatically started
-
-** Task
- * [SMX4KNL-17] - Remove all the warnings when building the distribution tar.gz
-
-See the README.txt file for more general informations about ServiceMix Kernel.
-
-
- Apache ServiceMix Kernel 1.0-m1
- ================================
-
-See the README.txt file for more general informations about ServiceMix Kernel.
-
-This is the first milestone of ServiceMix Kernel. All the features are not
-fully implemented yet and things may be changed until the final 1.0 release.
-Please refer to the web site for more informations and feel free to ask any
-questions on the ServiceMix mailing lists or simply to provide feedback
-(we appreciate it very much).
-
-Thanks you for downloading ServiceMix Kernel. Enjoy !
-
-The ServiceMix Team
-http://servicemix.apache.org/team.html
-
diff --git a/karaf/admin/command/NOTICE b/karaf/admin/command/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/admin/command/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/admin/command/pom.xml b/karaf/admin/command/pom.xml
deleted file mode 100644
index 069e7de..0000000
--- a/karaf/admin/command/pom.xml
+++ /dev/null
@@ -1,105 +0,0 @@
-<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/maven-v4_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.felix.karaf.admin</groupId>
- <artifactId>admin</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.admin</groupId>
- <artifactId>org.apache.felix.karaf.admin.command</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Admin Command</name>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix.karaf.admin</groupId>
- <artifactId>org.apache.felix.karaf.admin.core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymockclassextension</artifactId>
- <version>${easymock.version}</version>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Import-Package>
- !${project.artifactId}*,
- !org.apache.felix.karaf.admin.internal,
- javax.management,
- javax.management.loading,
- org.osgi.service.command,
- org.apache.felix.gogo.commands,
- org.apache.felix.karaf.shell.console,
- *
- </Import-Package>
- <Private-Package>
- org.apache.felix.karaf.admin.main
- </Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/AdminCommandSupport.java b/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/AdminCommandSupport.java
deleted file mode 100644
index 617d1db..0000000
--- a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/AdminCommandSupport.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin.command;
-
-import org.apache.felix.karaf.admin.AdminService;
-import org.apache.felix.karaf.admin.Instance;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-
-public abstract class AdminCommandSupport extends OsgiCommandSupport {
-
- private AdminService adminService;
-
- public AdminService getAdminService() {
- return adminService;
- }
-
- public void setAdminService(AdminService adminService) {
- this.adminService = adminService;
- }
-
- protected Instance getExistingInstance(String name) {
- Instance i = adminService.getInstance(name);
- if (i == null) {
- throw new IllegalArgumentException("Instance '" + name + "' does not exist");
- }
- return i;
- }
-}
diff --git a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/ChangePortCommand.java b/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/ChangePortCommand.java
deleted file mode 100644
index e096399..0000000
--- a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/ChangePortCommand.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin.command;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "admin", name = "change-port", description = "Changes the port of an existing container instance.")
-public class ChangePortCommand extends AdminCommandSupport {
-
- @Argument(index = 0, name = "name", description="The name of the container instance", required = true, multiValued = false)
- private String instance = null;
-
- @Argument(index = 1, name = "port", description = "The new port to set", required = true, multiValued = false)
- private int port = 0;
-
- protected Object doExecute() throws Exception {
- getExistingInstance(instance).changePort(port);
- return null;
- }
-}
diff --git a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/ConnectCommand.java b/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/ConnectCommand.java
deleted file mode 100644
index bf48a72..0000000
--- a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/ConnectCommand.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.admin.command;
-
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "admin", name = "connect", description = "Connects to an existing container instance.")
-public class ConnectCommand extends AdminCommandSupport {
-
- @Argument(index = 0, name="name", description="The name of the container instance", required = true, multiValued = false)
- private String instance = null;
-
- @Option(name="-u", aliases={"--username"}, description="Remote user name (Default: karaf)", required = false, multiValued = false)
- private String username = "karaf";
-
- @Option(name="-p", aliases={"--password"}, description="Remote user password (Default: karaf)", required = false, multiValued = false)
- private String password = "karaf";
-
- protected Object doExecute() throws Exception {
- int port = getExistingInstance(instance).getPort();
- session.execute("ssh -l " + username + " -P " + password + " -p " + port + " localhost");
- return null;
- }
-}
diff --git a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/CreateCommand.java b/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/CreateCommand.java
deleted file mode 100644
index a512fcb..0000000
--- a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/CreateCommand.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin.command;
-
-import java.util.List;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.karaf.admin.InstanceSettings;
-
-
-/**
- * Creates a new Karaf instance
- *
- * @version $Rev: 679826 $ $Date: 2008-07-25 17:00:12 +0200 (Fri, 25 Jul 2008) $
- */
-@Command(scope = "admin", name = "create", description = "Creates a new container instance.")
-public class CreateCommand extends AdminCommandSupport
-{
- @Option(name = "-p", aliases = {"--port"}, description = "Port number for remote shell connection", required = false, multiValued = false)
- int port = 0;
-
- @Option(name = "-l", aliases = {"--location"}, description = "Location of the new container instance in the file system", required = false, multiValued = false)
- String location;
-
- @Option(name = "-f", aliases = {"--feature"},
- description = "Initial features. This option can be specified multiple times to enable multiple initial features", required = false, multiValued = true)
- List<String> features;
-
- @Option(name = "-furl", aliases = {"--featureURL"},
- description = "Additional feature descriptor URLs. This option can be specified multiple times to add multiple URLs", required = false, multiValued = true)
- List<String> featureURLs;
-
- @Argument(index = 0, name = "name", description="The name of the new container instance", required = true, multiValued = false)
- String instance = null;
-
- protected Object doExecute() throws Exception {
- InstanceSettings settings = new InstanceSettings(port, location, featureURLs, features);
- getAdminService().createInstance(instance, settings);
- return null;
- }
-
-}
diff --git a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/DestroyCommand.java b/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/DestroyCommand.java
deleted file mode 100644
index 88919cb..0000000
--- a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/DestroyCommand.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin.command;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-/**
- * Destroy an existing Karaf instance
- *
- * @version $Rev: 679826 $ $Date: 2008-07-25 17:00:12 +0200 (Fri, 25 Jul 2008) $
- */
-@Command(scope = "admin", name = "destroy", description = "Destroys an existing container instance.")
-public class DestroyCommand extends AdminCommandSupport
-{
- @Argument(index = 0, name = "name", description="The name of the container instance to destroy", required = true, multiValued = false)
- private String instance = null;
-
- protected Object doExecute() throws Exception {
- getExistingInstance(instance).destroy();
- return null;
- }
-
-}
diff --git a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/ListCommand.java b/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/ListCommand.java
deleted file mode 100644
index bf15909..0000000
--- a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/ListCommand.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin.command;
-
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.karaf.admin.Instance;
-
-/**
- * List available instances
- */
-@Command(scope = "admin", name = "list", description = "List all existing container instances.")
-public class ListCommand extends AdminCommandSupport {
-
- @Option(name = "-l", aliases = { "--location" }, description = "Displays the location of the container instances", required = false, multiValued = false)
- boolean location;
-
- protected Object doExecute() throws Exception {
- Instance[] instances = getAdminService().getInstances();
- if (location) {
- System.out.println(" Port State Pid Location");
- } else {
- System.out.println(" Port State Pid Name");
- }
- for (Instance instance : instances) {
- StringBuilder sb = new StringBuilder();
- sb.append('[');
- String s = Integer.toString(instance.getPort());
- for (int i = s.length(); i < 5; i++) {
- sb.append(' ');
- }
- sb.append(s);
- sb.append("] [");
- String state = instance.getState();
- while (state.length() < "starting".length()) {
- state += " ";
- }
- sb.append(state);
- sb.append("] [");
- s = Integer.toString(instance.getPid());
- for (int i = s.length(); i < 5; i++) {
- sb.append(' ');
- }
- sb.append(s);
- sb.append("] ");
- if (location) {
- sb.append(instance.getLocation());
- } else {
- sb.append(instance.getName());
- }
- System.out.println(sb.toString());
- }
- return null;
- }
-
-}
diff --git a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/StartCommand.java b/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/StartCommand.java
deleted file mode 100644
index c14947c..0000000
--- a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/StartCommand.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin.command;
-
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "admin", name = "start", description = "Starts an existing container instance.")
-public class StartCommand extends AdminCommandSupport {
-
- @Option(name = "-o", aliases = { "--java-opts"}, description = "Java options when launching the instance", required = false, multiValued = false)
- private String javaOpts;
-
- @Argument(index = 0, name = "name", description = "The name of the container instance", required = true, multiValued = false)
- private String instance = null;
-
- protected Object doExecute() throws Exception {
- getExistingInstance(instance).start(javaOpts);
- return null;
- }
-}
diff --git a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/StopCommand.java b/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/StopCommand.java
deleted file mode 100644
index 1ad5789..0000000
--- a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/StopCommand.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin.command;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "admin", name = "stop", description = "Stops an existing container instance.")
-public class StopCommand extends AdminCommandSupport {
-
- @Argument(index = 0, name = "name", description = "The name of the container instance", required = true, multiValued = false)
- private String instance = null;
-
- protected Object doExecute() throws Exception {
- getExistingInstance(instance).stop();
- return null;
- }
-}
diff --git a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/completers/InstanceCompleter.java b/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/completers/InstanceCompleter.java
deleted file mode 100644
index 467989f..0000000
--- a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/command/completers/InstanceCompleter.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin.command.completers;
-
-import java.util.List;
-
-import org.apache.felix.karaf.admin.AdminService;
-import org.apache.felix.karaf.admin.Instance;
-import org.apache.felix.karaf.shell.console.completer.StringsCompleter;
-import org.apache.felix.karaf.shell.console.Completer;
-
-/**
- * {@link jline.Completor} for server instance names.
- *
- * Displays a list of configured server instances for the Admin commands.
- *
- */
-public class InstanceCompleter implements Completer {
- private AdminService adminService;
-
- public void setAdminService(AdminService adminService) {
- this.adminService = adminService;
- }
-
- public int complete(String buffer, int cursor, List candidates) {
- StringsCompleter delegate = new StringsCompleter();
- for (Instance instance : adminService.getInstances()) {
- delegate.getStrings().add(instance.getName());
- }
- return delegate.complete(buffer, cursor, candidates);
- }
-}
diff --git a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/main/Execute.java b/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/main/Execute.java
deleted file mode 100644
index 5466d7c..0000000
--- a/karaf/admin/command/src/main/java/org/apache/felix/karaf/admin/main/Execute.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin.main;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.apache.felix.gogo.commands.Action;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.basic.DefaultActionPreparator;
-import org.apache.felix.karaf.admin.command.AdminCommandSupport;
-import org.apache.felix.karaf.admin.command.ChangePortCommand;
-import org.apache.felix.karaf.admin.command.CreateCommand;
-import org.apache.felix.karaf.admin.command.DestroyCommand;
-import org.apache.felix.karaf.admin.command.ListCommand;
-import org.apache.felix.karaf.admin.command.StartCommand;
-import org.apache.felix.karaf.admin.command.StopCommand;
-import org.apache.felix.karaf.admin.internal.AdminServiceImpl;
-import org.fusesource.jansi.AnsiConsole;
-
-public class Execute {
- static Class<? extends Action> x = CreateCommand.class;
- private static final Class<?> [] COMMAND_CLASSES = new Class[] {
- CreateCommand.class,
- StartCommand.class,
- StopCommand.class,
- DestroyCommand.class,
- ListCommand.class,
- ChangePortCommand.class};
- private static final Map<String, Class<?>> COMMANDS = new TreeMap<String, Class<?>>();
- static {
- for (Class<?> c : COMMAND_CLASSES) {
- Command ann = c.getAnnotation(Command.class);
- if (ann == null) {
- continue;
- }
- COMMANDS.put(ann.name(), c);
- }
- }
-
- // For testing
- static boolean exitAllowed = true;
-
- public static void main(String[] args) throws Exception {
- AnsiConsole.systemInstall();
-
- if (args.length == 0) {
- listCommands();
- exit(0);
- }
-
- Class<?> cls = COMMANDS.get(args[0]);
- if (cls == null) {
- System.err.println("Command not found: " + args[0]);
- exit(-1);
- }
-
- String storage = System.getProperty("storage.location");
- if (storage == null) {
- System.err.println("System property 'storage.location' is not set. \n" +
- "This property needs to be set to the full path of the instance.properties file.");
- exit(-1);
- }
- File storageFile = new File(storage);
- System.setProperty("user.dir", storageFile.getParentFile().getParentFile().getCanonicalPath());
-
- Object command = cls.newInstance();
- if (command instanceof AdminCommandSupport) {
- execute((AdminCommandSupport) command, storageFile, args);
- } else {
- System.err.println("Not an admin command: " + args[0]);
- exit(-1);
- }
- }
-
- static void execute(AdminCommandSupport command, File storageFile, String[] args) throws Exception {
- DefaultActionPreparator dap = new DefaultActionPreparator();
- List<Object> params = new ArrayList<Object>(Arrays.asList(args));
- params.remove(0); // this is the actual command name
-
- if (!dap.prepare(command, null, params)) {
- return;
- }
-
- AdminServiceImpl admin = new AdminServiceImpl();
- admin.setStorageLocation(storageFile);
- admin.init();
- command.setAdminService(admin);
- command.execute(null);
- }
-
- private static void listCommands() {
- System.out.println("Available commands:");
- for (Map.Entry<String, Class<?>> entry : COMMANDS.entrySet()) {
- Command ann = entry.getValue().getAnnotation(Command.class);
- System.out.printf(" %s - %s\n", entry.getKey(), ann.description());
- }
-
- System.out.println("Type 'command --help' for more help on the specified command.");
- }
-
- private static void exit(int rc) {
- if (exitAllowed) {
- System.exit(rc);
- } else {
- throw new RuntimeException("" + rc);
- }
- }
-}
diff --git a/karaf/admin/command/src/main/resources/OSGI-INF/blueprint/admin-command.xml b/karaf/admin/command/src/main/resources/OSGI-INF/blueprint/admin-command.xml
deleted file mode 100644
index 2a62839..0000000
--- a/karaf/admin/command/src/main/resources/OSGI-INF/blueprint/admin-command.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
- default-activation="lazy">
-
- <command-bundle xmlns="http://felix.apache.org/karaf/xmlns/shell/v1.0.0">
- <command name="admin/create">
- <action class="org.apache.felix.karaf.admin.command.CreateCommand">
- <property name="adminService" ref="adminService" />
- </action>
- </command>
- <command name="admin/connect">
- <action class="org.apache.felix.karaf.admin.command.ConnectCommand">
- <property name="adminService" ref="adminService" />
- </action>
- <completers>
- <ref component-id="instanceCompleter" />
- <null/>
- </completers>
- </command>
- <command name="admin/list">
- <action class="org.apache.felix.karaf.admin.command.ListCommand">
- <property name="adminService" ref="adminService" />
- </action>
- </command>
- <command name="admin/start">
- <action class="org.apache.felix.karaf.admin.command.StartCommand">
- <property name="adminService" ref="adminService" />
- </action>
- <completers>
- <ref component-id="instanceCompleter" />
- <null/>
- </completers>
- </command>
- <command name="admin/stop">
- <action class="org.apache.felix.karaf.admin.command.StopCommand">
- <property name="adminService" ref="adminService" />
- </action>
- <completers>
- <ref component-id="instanceCompleter" />
- <null/>
- </completers>
- </command>
- <command name="admin/destroy">
- <action class="org.apache.felix.karaf.admin.command.DestroyCommand">
- <property name="adminService" ref="adminService" />
- </action>
- <completers>
- <ref component-id="instanceCompleter" />
- <null/>
- </completers>
- </command>
- <command name="admin/change-port">
- <action class="org.apache.felix.karaf.admin.command.ChangePortCommand">
- <property name="adminService" ref="adminService" />
- </action>
- <completers>
- <ref component-id="instanceCompleter" />
- <null/>
- </completers>
- </command>
- </command-bundle>
-
- <reference id="adminService" interface="org.apache.felix.karaf.admin.AdminService" />
-
- <bean id="instanceCompleter" class="org.apache.felix.karaf.admin.command.completers.InstanceCompleter">
- <property name="adminService" ref="adminService" />
- </bean>
-
-</blueprint>
diff --git a/karaf/admin/command/src/test/java/org/apache/felix/karaf/admin/command/CreateCommandTest.java b/karaf/admin/command/src/test/java/org/apache/felix/karaf/admin/command/CreateCommandTest.java
deleted file mode 100644
index b467713..0000000
--- a/karaf/admin/command/src/test/java/org/apache/felix/karaf/admin/command/CreateCommandTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin.command;
-
-import java.util.Arrays;
-import java.util.Collections;
-
-import junit.framework.TestCase;
-
-import org.apache.felix.karaf.admin.AdminService;
-import org.apache.felix.karaf.admin.InstanceSettings;
-import org.easymock.EasyMock;
-
-public class CreateCommandTest extends TestCase {
- public void testCreateCommandExecute() throws Exception {
- AdminService adminService = EasyMock.createMock(AdminService.class);
- EasyMock.replay(adminService);
-
- CreateCommand cc = new CreateCommand();
- cc.setAdminService(adminService);
- cc.port = 9941;
- cc.location = "top";
- cc.features = Arrays.asList("abc", "def");
- cc.featureURLs = Collections.singletonList("http://something");
- cc.instance = "myInstance";
-
- EasyMock.verify(adminService); // check precondition
- EasyMock.reset(adminService);
- InstanceSettings expectedIS =
- new InstanceSettings(9941, "top", Collections.singletonList("http://something"), Arrays.asList("abc", "def"));
- EasyMock.expect(adminService.createInstance("myInstance", expectedIS)).andReturn(null);
- EasyMock.replay(adminService);
-
- cc.doExecute();
- EasyMock.verify(adminService);
- }
-}
diff --git a/karaf/admin/command/src/test/java/org/apache/felix/karaf/admin/main/ExecuteTest.java b/karaf/admin/command/src/test/java/org/apache/felix/karaf/admin/main/ExecuteTest.java
deleted file mode 100644
index 268549b..0000000
--- a/karaf/admin/command/src/test/java/org/apache/felix/karaf/admin/main/ExecuteTest.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin.main;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.PrintStream;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import org.apache.felix.karaf.admin.AdminService;
-import org.apache.felix.karaf.admin.command.AdminCommandSupport;
-import org.apache.felix.karaf.admin.internal.AdminServiceImpl;
-import org.easymock.IAnswer;
-import org.easymock.classextension.EasyMock;
-
-public class ExecuteTest extends TestCase {
- private String userDir;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- Execute.exitAllowed = false;
- userDir = System.getProperty("user.dir");
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- Execute.exitAllowed = true;
- System.setProperty("user.dir", userDir);
- }
-
- public void testListCommands() throws Exception {
- PrintStream oldOut = System.out;
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream capturedOut = new PrintStream(baos);
- System.setOut(capturedOut);
-
- try {
- Execute.main(new String [] {});
- } catch (RuntimeException re) {
- assertEquals("0", re.getMessage());
-
- String s = new String(baos.toByteArray());
- assertTrue(s.contains("list"));
- assertTrue(s.contains("create"));
- assertTrue(s.contains("destroy"));
- } finally {
- System.setOut(oldOut);
- }
- }
-
- public void testNonexistingCommand() throws Exception {
- try {
- Execute.main(new String [] {"bheuaark"});
- } catch (RuntimeException re) {
- assertEquals("-1", re.getMessage());
- }
- }
-
- public void testNoStorageFile() throws Exception {
- PrintStream oldErr = System.err;
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream capturedErr = new PrintStream(baos);
- System.setErr(capturedErr);
-
- try {
- Execute.main(new String [] {"create"});
- } catch (RuntimeException re) {
- assertEquals("-1", re.getMessage());
-
- String s = new String(baos.toByteArray());
- assertTrue(s.contains("storage.location"));
- assertTrue(s.contains("instance.properties"));
- } finally {
- System.setErr(oldErr);
- }
- }
-
- public void testSetDir() throws Exception {
- Properties oldProps = (Properties) System.getProperties().clone();
- final File tempFile = createTempDir(getName());
- assertFalse("Precondition failed",
- tempFile.getParentFile().getParentFile().getCanonicalPath().equals(System.getProperty("user.dir")));
-
- System.setProperty("storage.location", tempFile.getCanonicalPath());
- try {
- Execute.main(new String [] {"list"});
- assertTrue(tempFile.getParentFile().getParentFile().getCanonicalPath().equals(System.getProperty("user.dir")));
- } finally {
- System.setProperties(oldProps);
- assertNull("Postcondition failed", System.getProperty("storage.location"));
- delete(tempFile);
- }
- }
-
- public void testExecute() throws Exception {
- final File tempFile = createTempDir(getName());
- Properties p = new Properties();
- p.setProperty("port", "1302");
- FileOutputStream fos = new FileOutputStream(new File(tempFile, AdminServiceImpl.STORAGE_FILE));
- p.store(fos, "");
- fos.close();
-
- final List<AdminServiceImpl> admins = new ArrayList<AdminServiceImpl>();
- try {
- AdminCommandSupport mockCommand = EasyMock.createStrictMock(AdminCommandSupport.class);
- mockCommand.setAdminService((AdminService) EasyMock.anyObject());
- EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
- public Object answer() throws Throwable {
- AdminServiceImpl svc = (AdminServiceImpl) EasyMock.getCurrentArguments()[0];
- assertEquals(tempFile, svc.getStorageLocation());
- admins.add(svc);
- return null;
- }
- });
-
- EasyMock.expect(mockCommand.execute(null)).andAnswer(new IAnswer<Object>() {
- public Object answer() throws Throwable {
- // The Admin Service should be initialized at this point.
- // One way to find this out is by reading out the port number
- AdminServiceImpl admin = admins.get(0);
- Field field = AdminServiceImpl.class.getDeclaredField("defaultPortStart");
- field.setAccessible(true);
- assertEquals(1302, field.get(admin));
- return null;
- }
- });
- EasyMock.replay(mockCommand);
-
- Execute.execute(mockCommand, tempFile, new String [] {"test"});
-
- EasyMock.verify(mockCommand);
- } finally {
- delete(tempFile);
- }
- }
-
- private static File createTempDir(String name) throws IOException {
- final File tempFile = File.createTempFile(name, null);
- tempFile.delete();
- tempFile.mkdirs();
- return tempFile.getCanonicalFile();
- }
-
- private static void delete(File tmp) {
- if (tmp.isDirectory()) {
- for (File f : tmp.listFiles()) {
- delete(f);
- }
- }
- tmp.delete();
- }
-}
diff --git a/karaf/admin/core/NOTICE b/karaf/admin/core/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/admin/core/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/admin/core/pom.xml b/karaf/admin/core/pom.xml
deleted file mode 100644
index 0a784eb..0000000
--- a/karaf/admin/core/pom.xml
+++ /dev/null
@@ -1,193 +0,0 @@
-<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/maven-v4_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.felix.karaf.admin</groupId>
- <artifactId>admin</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.admin</groupId>
- <artifactId>org.apache.felix.karaf.admin.core</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Admin Core</name>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.bundlerepository</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.obr</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <resources>
- <resource>
- <directory>${project.basedir}/src/main/resources</directory>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-config-properties</id>
- <!-- here the phase you need -->
- <phase>compile</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <outputDirectory>${basedir}/target/classes/org/apache/felix/karaf/admin/etc</outputDirectory>
- <resources>
- <resource>
- <directory>../../assembly/src/main/distribution/text/etc/</directory>
- <includes>
- <include>*.properties</include>
- <include>*.cfg</include>
- </includes>
- <excludes>
- <exclude>org.apache.felix.karaf.shell.cfg</exclude>
- <exclude>org.ops4j.pax.url.mvn.cfg</exclude>
- <exclude>system.properties</exclude>
- </excludes>
- </resource>
- </resources>
- </configuration>
- </execution>
- <execution>
- <id>copy-filtered</id>
- <!-- here the phase you need -->
- <phase>compile</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <outputDirectory>${basedir}/target/classes/org/apache/felix/karaf/admin/etc</outputDirectory>
- <resources>
- <resource>
- <directory>../../assembly/src/main/filtered-resources/etc</directory>
- <filtering>true</filtering>
- <includes>
- <include>*.properties</include>
- <include>*.cfg</include>
- </includes>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>
- org.apache.felix.karaf.admin;version=${project.version},
- org.apache.felix.karaf.jpm;version=${project.version}
- </Export-Package>
- <Import-Package>
- !org.apache.felix.karaf.admin,
- !org.apache.felix.karaf.jpm,
- javax.management,
- javax.management.loading,
- org.osgi.service.command,
- org.apache.felix.gogo.commands,
- org.apache.felix.karaf.shell.console,
- *
- </Import-Package>
- <Private-Package>
- org.apache.felix.karaf.admin.bin,
- org.apache.felix.karaf.admin.etc,
- org.apache.felix.karaf.admin.internal,
- org.apache.felix.karaf.jpm.impl,
- </Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <!-- this is not a unit test but an application used for testing -->
- <exclude>**/MainTest.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/karaf/admin/core/src/main/java/org/apache/felix/karaf/admin/AdminService.java b/karaf/admin/core/src/main/java/org/apache/felix/karaf/admin/AdminService.java
deleted file mode 100644
index e8d1cb5..0000000
--- a/karaf/admin/core/src/main/java/org/apache/felix/karaf/admin/AdminService.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin;
-
-public interface AdminService {
-
- Instance createInstance(String name, InstanceSettings settings) throws Exception;
-
- Instance[] getInstances();
-
- Instance getInstance(String name);
-}
diff --git a/karaf/admin/core/src/main/java/org/apache/felix/karaf/admin/Instance.java b/karaf/admin/core/src/main/java/org/apache/felix/karaf/admin/Instance.java
deleted file mode 100644
index 259704d..0000000
--- a/karaf/admin/core/src/main/java/org/apache/felix/karaf/admin/Instance.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin;
-
-public interface Instance {
-
- String STOPPED = "Stopped";
- String STARTING = "Starting";
- String STARTED = "Started";
- String ERROR = "Error";
-
- String getName();
-
- boolean isRoot();
-
- String getLocation();
-
- int getPid();
-
- int getPort();
-
- void changePort(int port) throws Exception;
-
- void start(String javaOpts) throws Exception;
-
- void stop() throws Exception;
-
- void destroy() throws Exception;
-
- String getState() throws Exception;
-
-}
diff --git a/karaf/admin/core/src/main/java/org/apache/felix/karaf/admin/InstanceSettings.java b/karaf/admin/core/src/main/java/org/apache/felix/karaf/admin/InstanceSettings.java
deleted file mode 100644
index 832e24f..0000000
--- a/karaf/admin/core/src/main/java/org/apache/felix/karaf/admin/InstanceSettings.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin;
-
-import java.util.List;
-
-public class InstanceSettings {
- private final int port;
- private final String location;
- private final List<String> featureURLs;
- private final List<String> features;
-
- public InstanceSettings(int port, String location, List<String> featureURLs, List<String> features) {
- this.port = port;
- this.location = location;
- this.featureURLs = featureURLs;
- this.features = features;
- }
-
- public int getPort() {
- return port;
- }
-
- public String getLocation() {
- return location;
- }
-
- public List<String> getFeatureURLs() {
- return featureURLs;
- }
-
- public List<String> getFeatures() {
- return features;
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- }
- if (!(o instanceof InstanceSettings)) {
- return false;
- }
- InstanceSettings is = (InstanceSettings) o;
- return is.port == port &&
- (location == null ? is.location == null : location.equals(is.location)) &&
- (featureURLs == null ? is.featureURLs == null : featureURLs.equals(is.featureURLs)) &&
- (features == null ? is.features == null : features.equals(is.features));
- }
-
- @Override
- public int hashCode() {
- int rc = 17;
- rc = 37 * port;
- if (location != null) {
- rc = 37 * location.hashCode();
- }
- if (featureURLs != null) {
- rc = 37 * featureURLs.hashCode();
- }
- if (features != null) {
- rc = 37 * features.hashCode();
- }
- return rc;
- }
-
-
-}
diff --git a/karaf/admin/core/src/main/java/org/apache/felix/karaf/admin/internal/AdminServiceImpl.java b/karaf/admin/core/src/main/java/org/apache/felix/karaf/admin/internal/AdminServiceImpl.java
deleted file mode 100644
index 69c7f4c..0000000
--- a/karaf/admin/core/src/main/java/org/apache/felix/karaf/admin/internal/AdminServiceImpl.java
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin.internal;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Scanner;
-
-import org.apache.felix.karaf.admin.AdminService;
-import org.apache.felix.karaf.admin.Instance;
-import org.apache.felix.karaf.admin.InstanceSettings;
-import org.fusesource.jansi.Ansi;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AdminServiceImpl implements AdminService {
- public static final String STORAGE_FILE = "instance.properties";
- private static final String FEATURES_CFG = "etc/org.apache.felix.karaf.features.cfg";
-
- private static final Logger LOGGER = LoggerFactory.getLogger(AdminServiceImpl.class);
-
- private Map<String, Instance> instances = new HashMap<String, Instance>();
-
- private int defaultPortStart = 8101;
-
- private File storageLocation;
-
- private long stopTimeout = 30000;
-
- public File getStorageLocation() {
- return storageLocation;
- }
-
- public void setStorageLocation(File storage) {
- this.storageLocation = storage;
- }
-
- public long getStopTimeout() {
- return stopTimeout;
- }
-
- public void setStopTimeout(long stopTimeout) {
- this.stopTimeout = stopTimeout;
- }
-
- private Properties loadStorage(File location) throws IOException {
- InputStream is = null;
- try {
- is = new FileInputStream(location);
- Properties props = new Properties();
- props.load(is);
- return props;
- } finally {
- if (is != null) {
- is.close();
- }
- }
- }
-
- private void saveStorage(Properties props, File location, String comment) throws IOException {
- OutputStream os = null;
- try {
- os = new FileOutputStream(location);
- props.store(os, comment);
- } finally {
- if (os != null) {
- os.close();
- }
- }
- }
-
- public synchronized void init() throws Exception {
- try {
- File storageFile = new File(storageLocation, STORAGE_FILE);
- if (!storageFile.isFile()) {
- if (storageFile.exists()) {
- LOGGER.error("Instances storage location should be a file: " + storageFile);
- }
- return;
- }
- Properties storage = loadStorage(storageFile);
- int count = Integer.parseInt(storage.getProperty("count", "0"));
- defaultPortStart = Integer.parseInt(storage.getProperty("port", Integer.toString(defaultPortStart)));
- Map<String, Instance> newInstances = new HashMap<String, Instance>();
- for (int i = 0; i < count; i++) {
- String name = storage.getProperty("item." + i + ".name", null);
- String loc = storage.getProperty("item." + i + ".loc", null);
- int pid = Integer.parseInt(storage.getProperty("item." + i + ".pid", "0"));
- boolean root = Boolean.parseBoolean(storage.getProperty("item." + i + ".root", "false"));
- if (name != null) {
- InstanceImpl instance = new InstanceImpl(this, name, loc, root);
- if (pid > 0) {
- try {
- instance.attach(pid);
- } catch (IOException e) {
- // Ignore
- }
- }
- newInstances.put(name, instance);
- }
- }
- instances = newInstances;
- } catch (Exception e) {
- LOGGER.warn("Unable to reload Karaf instance list", e);
- }
- }
-
- public synchronized Instance createInstance(String name, InstanceSettings settings) throws Exception {
- if (instances.get(name) != null) {
- throw new IllegalArgumentException("Instance '" + name + "' already exists");
- }
- String loc = settings.getLocation() != null ? settings.getLocation() : name;
- File karafBase = new File(loc);
- if (!karafBase.isAbsolute()) {
- karafBase = new File(storageLocation, loc);
- }
- int sshPort = settings.getPort();
- if (sshPort <= 0) {
- sshPort = ++defaultPortStart;
- }
- println(Ansi.ansi().a("Creating new instance on port ").a(sshPort).a(" at: ").a(Ansi.Attribute.INTENSITY_BOLD).a(karafBase).a(Ansi.Attribute.RESET).toString());
-
- mkdir(karafBase, "bin");
- mkdir(karafBase, "etc");
- mkdir(karafBase, "system");
- mkdir(karafBase, "deploy");
- mkdir(karafBase, "data");
-
- copyResourceToDir(karafBase, "etc/config.properties", true);
- copyResourceToDir(karafBase, "etc/java.util.logging.properties", true);
- copyResourceToDir(karafBase, "etc/org.apache.felix.fileinstall-deploy.cfg", true);
- copyResourceToDir(karafBase, "etc/org.apache.felix.karaf.log.cfg", true);
- copyResourceToDir(karafBase, FEATURES_CFG, true);
- copyResourceToDir(karafBase, "etc/org.apache.felix.karaf.management.cfg", true);
- copyResourceToDir(karafBase, "etc/org.ops4j.pax.logging.cfg", true);
- copyResourceToDir(karafBase, "etc/org.ops4j.pax.url.mvn.cfg", true);
- copyResourceToDir(karafBase, "etc/startup.properties", true);
- copyResourceToDir(karafBase, "etc/users.properties", true);
-
- HashMap<String, String> props = new HashMap<String, String>();
- props.put("${SUBST-KARAF-NAME}", name);
- props.put("${SUBST-KARAF-HOME}", System.getProperty("karaf.home"));
- props.put("${SUBST-KARAF-BASE}", karafBase.getPath());
- props.put("${SUBST-SSH-PORT}", Integer.toString(sshPort));
- copyFilteredResourceToDir(karafBase, "etc/system.properties", props);
- copyFilteredResourceToDir(karafBase, "etc/org.apache.felix.karaf.shell.cfg", props);
- if( System.getProperty("os.name").startsWith("Win") ) {
- copyFilteredResourceToDir(karafBase, "bin/karaf.bat", props);
- copyFilteredResourceToDir(karafBase, "bin/start.bat", props);
- copyFilteredResourceToDir(karafBase, "bin/stop.bat", props);
- } else {
- copyFilteredResourceToDir(karafBase, "bin/karaf", props);
- copyFilteredResourceToDir(karafBase, "bin/start", props);
- copyFilteredResourceToDir(karafBase, "bin/stop", props);
- chmod(new File(karafBase, "bin/karaf"), "a+x");
- chmod(new File(karafBase, "bin/start"), "a+x");
- chmod(new File(karafBase, "bin/stop"), "a+x");
- }
-
- handleFeatures(new File(karafBase, FEATURES_CFG), settings);
-
- Instance instance = new InstanceImpl(this, name, karafBase.toString());
- instances.put(name, instance);
- saveState();
- return instance;
- }
-
- void handleFeatures(File featuresCfg, InstanceSettings settings) throws IOException {
- Properties p = loadStorage(featuresCfg);
-
- appendToPropList(p, "featuresBoot", settings.getFeatures());
- appendToPropList(p, "featuresRepositories", settings.getFeatureURLs());
- saveStorage(p, featuresCfg, "Features Configuration");
- }
-
- private void appendToPropList(Properties p, String key, List<String> elements) {
- if (elements == null) {
- return;
- }
- StringBuilder sb = new StringBuilder(p.getProperty(key).trim());
- for (String f : elements) {
- if (sb.length() > 0) {
- sb.append(',');
- }
- sb.append(f);
- }
- p.setProperty(key, sb.toString());
- }
-
- public synchronized Instance[] getInstances() {
- return instances.values().toArray(new Instance[0]);
- }
-
- public synchronized Instance getInstance(String name) {
- return instances.get(name);
- }
-
- synchronized void forget(String name) {
- instances.remove(name);
- }
-
- synchronized void saveState() throws IOException {
- Properties storage = new Properties();
- Instance[] data = getInstances();
- storage.setProperty("port", Integer.toString(defaultPortStart));
- storage.setProperty("count", Integer.toString(data.length));
- for (int i = 0; i < data.length; i++) {
- storage.setProperty("item." + i + ".name", data[i].getName());
- storage.setProperty("item." + i + ".loc", data[i].getLocation());
- storage.setProperty("item." + i + ".pid", Integer.toString(data[i].getPid()));
- }
- saveStorage(storage, new File(storageLocation, STORAGE_FILE), "Admin Service storage");
- }
-
- private void copyResourceToDir(File target, String resource, boolean text) throws Exception {
- File outFile = new File(target, resource);
- if( !outFile.exists() ) {
- println(Ansi.ansi().a("Creating file: ").a(Ansi.Attribute.INTENSITY_BOLD).a(outFile.getPath()).a(Ansi.Attribute.RESET).toString());
- InputStream is = getClass().getClassLoader().getResourceAsStream("org/apache/felix/karaf/admin/" + resource);
- try {
- if( text ) {
- // Read it line at a time so that we can use the platform line ending when we write it out.
- PrintStream out = new PrintStream(new FileOutputStream(outFile));
- try {
- Scanner scanner = new Scanner(is);
- while (scanner.hasNextLine() ) {
- String line = scanner.nextLine();
- out.println(line);
- }
- } finally {
- safeClose(out);
- }
- } else {
- // Binary so just write it out the way it came in.
- FileOutputStream out = new FileOutputStream(new File(target, resource));
- try {
- int c=0;
- while((c=is.read())>=0) {
- out.write(c);
- }
- } finally {
- safeClose(out);
- }
- }
- } finally {
- safeClose(is);
- }
- }
- }
-
- private void println(String st) {
- System.out.println(st);
- }
-
- private void copyFilteredResourceToDir(File target, String resource, HashMap<String, String> props) throws Exception {
- File outFile = new File(target, resource);
- if( !outFile.exists() ) {
- println(Ansi.ansi().a("Creating file: ").a(Ansi.Attribute.INTENSITY_BOLD).a(outFile.getPath()).a(Ansi.Attribute.RESET).toString());
- InputStream is = getClass().getClassLoader().getResourceAsStream("org/apache/felix/karaf/admin/" + resource);
- try {
- // Read it line at a time so that we can use the platform line ending when we write it out.
- PrintStream out = new PrintStream(new FileOutputStream(outFile));
- try {
- Scanner scanner = new Scanner(is);
- while (scanner.hasNextLine() ) {
- String line = scanner.nextLine();
- line = filter(line, props);
- out.println(line);
- }
- } finally {
- safeClose(out);
- }
- } finally {
- safeClose(is);
- }
- }
- }
-
- private void safeClose(InputStream is) throws IOException {
- if (is == null) {
- return;
- }
- try {
- is.close();
- } catch (Throwable ignore) {
- }
- }
-
- private void safeClose(OutputStream is) throws IOException {
- if (is == null) {
- return;
- }
- try {
- is.close();
- } catch (Throwable ignore) {
- }
- }
-
- private String filter(String line, HashMap<String, String> props) {
- for (Map.Entry<String, String> i : props.entrySet()) {
- int p1 = line.indexOf(i.getKey());
- if( p1 >= 0 ) {
- String l1 = line.substring(0, p1);
- String l2 = line.substring(p1+i.getKey().length());
- line = l1+i.getValue()+l2;
- }
- }
- return line;
- }
-
- private void mkdir(File karafBase, String path) {
- File file = new File(karafBase, path);
- if( !file.exists() ) {
- println(Ansi.ansi().a("Creating dir: ").a(Ansi.Attribute.INTENSITY_BOLD).a(file.getPath()).a(Ansi.Attribute.RESET).toString());
- file.mkdirs();
- }
- }
-
- private int chmod(File serviceFile, String mode) throws Exception {
- ProcessBuilder builder = new ProcessBuilder();
- builder.command("chmod", mode, serviceFile.getCanonicalPath());
- Process p = builder.start();
-
- // gnodet: Fix SMX4KNL-46: cpu goes to 100% after running the 'admin create' command
- // Not sure exactly what happens, but commenting the process io redirection seems
- // to work around the problem.
- //
- //PumpStreamHandler handler = new PumpStreamHandler(io.inputStream, io.outputStream, io.errorStream);
- //handler.attach(p);
- //handler.start();
- int status = p.waitFor();
- //handler.stop();
- return status;
- }
-
-}
diff --git a/karaf/admin/core/src/main/java/org/apache/felix/karaf/admin/internal/InstanceImpl.java b/karaf/admin/core/src/main/java/org/apache/felix/karaf/admin/internal/InstanceImpl.java
deleted file mode 100644
index ed27f4a..0000000
--- a/karaf/admin/core/src/main/java/org/apache/felix/karaf/admin/internal/InstanceImpl.java
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin.internal;
-
-import java.io.*;
-import java.net.Socket;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.felix.karaf.admin.Instance;
-import org.apache.felix.karaf.jpm.Process;
-import org.apache.felix.karaf.jpm.ProcessBuilderFactory;
-import org.apache.felix.karaf.jpm.impl.ScriptUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class InstanceImpl implements Instance {
-
- private static final Logger LOG = LoggerFactory.getLogger(InstanceImpl.class);
-
- private static final String CONFIG_PROPERTIES_FILE_NAME = "config.properties";
-
- private static final String KARAF_SHUTDOWN_PORT = "karaf.shutdown.port";
-
- private static final String KARAF_SHUTDOWN_HOST = "karaf.shutdown.host";
-
- private static final String KARAF_SHUTDOWN_PORT_FILE = "karaf.shutdown.port.file";
-
- private static final String KARAF_SHUTDOWN_COMMAND = "karaf.shutdown.command";
-
- private static final String KARAF_SHUTDOWN_PID_FILE = "karaf.shutdown.pid.file";
-
- private static final String DEFAULT_SHUTDOWN_COMMAND = "SHUTDOWN";
-
- private AdminServiceImpl service;
- private String name;
- private String location;
- private Process process;
- private boolean root;
-
- public InstanceImpl(AdminServiceImpl service, String name, String location) {
- this(service, name, location, false);
- }
-
- public InstanceImpl(AdminServiceImpl service, String name, String location, boolean root) {
- this.service = service;
- this.name = name;
- this.location = location;
- this.root = root;
- }
-
- public void attach(int pid) throws IOException {
- checkProcess();
- if (this.process != null) {
- throw new IllegalStateException("Instance already started");
- }
- this.process = ProcessBuilderFactory.newInstance().newBuilder().attach(pid);
- }
-
- public String getName() {
- return this.name;
- }
-
- public boolean isRoot() {
- return root;
- }
-
- public String getLocation() {
- return location;
- }
-
- public boolean exists() {
- return new File(location).isDirectory();
- }
-
- public int getPid() {
- checkProcess();
- return this.process != null ? this.process.getPid() : 0;
- }
-
- public int getPort() {
- InputStream is = null;
- try {
- File f = new File(location, "etc/org.apache.felix.karaf.shell.cfg");
- is = new FileInputStream(f);
- Properties props = new Properties();
- props.load(is);
- String loc = props.getProperty("sshPort");
- return Integer.parseInt(loc);
- } catch (Exception e) {
- return 0;
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException e) {
- // Ignore
- }
- }
- }
- }
-
- public void changePort(int port) throws Exception {
- checkProcess();
- if (this.process != null) {
- throw new IllegalStateException("Instance not stopped");
- }
- Properties props = new Properties();
- File f = new File(location, "etc/org.apache.felix.karaf.shell.cfg");
- InputStream is = new FileInputStream(f);
- try {
- props.load(is);
- } finally {
- is.close();
- }
- props.setProperty("sshPort", Integer.toString(port));
- OutputStream os = new FileOutputStream(f);
- try {
- props.store(os, null);
- } finally {
- os.close();
- }
- }
-
- public synchronized void start(String javaOpts) throws Exception {
- checkProcess();
- if (this.process != null) {
- throw new IllegalStateException("Instance already started");
- }
- if (javaOpts == null) {
- javaOpts = "-server -Xmx512M -Dcom.sun.management.jmxremote";
- }
- File libDir = new File(System.getProperty("karaf.home"), "lib");
- File[] jars = libDir.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.endsWith(".jar");
- }
- });
- StringBuilder classpath = new StringBuilder();
- for (File jar : jars) {
- if (classpath.length() > 0) {
- classpath.append(System.getProperty("path.separator"));
- }
- classpath.append(jar.getCanonicalPath());
- }
- String command = new File(System.getProperty("java.home"), ScriptUtils.isWindows() ? "bin\\java.exe" : "bin/java").getCanonicalPath()
- + " " + javaOpts
- + " -Djava.util.logging.config.file=\"" + new File(location, "etc/java.util.logging.properties").getCanonicalPath() + "\""
- + " -Djava.endorsed.dirs=\"" + new File(new File(new File(System.getProperty("java.home"), "jre"), "lib"), "endorsed") + System.getProperty("path.separator") + new File(new File(System.getProperty("java.home"), "lib"), "endorsed") + System.getProperty("path.separator") + new File(libDir, "endorsed").getCanonicalPath() + "\""
- + " -Djava.ext.dirs=\"" + new File(new File(new File(System.getProperty("java.home"), "jre"), "lib"), "ext") + System.getProperty("path.separator") + new File(new File(System.getProperty("java.home"), "lib"), "ext") + System.getProperty("path.separator") + new File(libDir, "ext").getCanonicalPath() + "\""
- + " -Dkaraf.home=\"" + System.getProperty("karaf.home") + "\""
- + " -Dkaraf.base=\"" + new File(location).getCanonicalPath() + "\""
- + " -Dkaraf.startLocalConsole=false"
- + " -Dkaraf.startRemoteShell=true"
- + " -classpath " + classpath.toString()
- + " org.apache.felix.karaf.main.Main";
- LOG.debug("Starting instance " + name + " with command: " + command);
- this.process = ProcessBuilderFactory.newInstance().newBuilder()
- .directory(new File(location))
- .command(command)
- .start();
- this.service.saveState();
- }
-
- public synchronized void stop() throws Exception {
- checkProcess();
- if (this.process == null) {
- throw new IllegalStateException("Instance not started");
- }
- // Try a clean shutdown
- cleanShutdown();
- if (this.process != null) {
- this.process.destroy();
- }
- }
-
- public synchronized void destroy() throws Exception {
- checkProcess();
- if (this.process != null) {
- throw new IllegalStateException("Instance not stopped");
- }
- deleteFile(new File(location));
- this.service.forget(name);
- this.service.saveState();
- }
-
-
- public synchronized String getState() {
- int port = getPort();
- if (!exists() || port <= 0) {
- return ERROR;
- }
- checkProcess();
- if (this.process == null) {
- return STOPPED;
- } else {
- try {
- Socket s = new Socket("localhost", port);
- s.close();
- return STARTED;
- } catch (Exception e) {
- // ignore
- }
- return STARTING;
- }
- }
-
- protected void checkProcess() {
- if (this.process != null) {
- try {
- if (!this.process.isRunning()) {
- this.process = null;
- }
- } catch (IOException e) {
- }
- }
- }
-
- protected void cleanShutdown() {
- try {
- File file = new File(new File(location, "etc"), CONFIG_PROPERTIES_FILE_NAME);
- URL configPropURL = file.toURI().toURL();
- Properties props = loadPropertiesFile(configPropURL);
- props.put("karaf.base", new File(location).getCanonicalPath());
- props.put("karaf.home", System.getProperty("karaf.home"));
- for (Enumeration e = props.propertyNames(); e.hasMoreElements();) {
- String name = (String) e.nextElement();
- props.setProperty(name,
- substVars(props.getProperty(name), name, null, props));
- }
- int port = Integer.parseInt(props.getProperty(KARAF_SHUTDOWN_PORT, "0"));
- String host = props.getProperty(KARAF_SHUTDOWN_HOST, "localhost");
- String portFile = props.getProperty(KARAF_SHUTDOWN_PORT_FILE);
- String shutdown = props.getProperty(KARAF_SHUTDOWN_COMMAND, DEFAULT_SHUTDOWN_COMMAND);
- if (port == 0 && portFile != null) {
- BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(portFile)));
- String portStr = r.readLine();
- port = Integer.parseInt(portStr);
- r.close();
- }
- // We found the port, try to send the command
- if (port > 0) {
- Socket s = new Socket(host, port);
- s.getOutputStream().write(shutdown.getBytes());
- s.close();
- long t = System.currentTimeMillis() + service.getStopTimeout();
- do {
- Thread.sleep(100);
- checkProcess();
- } while (System.currentTimeMillis() < t && process != null);
- }
- } catch (Exception e) {
- LOG.debug("Unable to cleanly shutdown instance", e);
- }
- }
-
- protected static boolean deleteFile(File fileToDelete) {
- if (fileToDelete == null || !fileToDelete.exists()) {
- return true;
- }
- boolean result = true;
- if (fileToDelete.isDirectory()) {
- File[] files = fileToDelete.listFiles();
- if (files == null) {
- result = false;
- } else {
- for (int i = 0; i < files.length; i++) {
- File file = files[i];
- if (file.getName().equals(".") || file.getName().equals("..")) {
- continue;
- }
- if (file.isDirectory()) {
- result &= deleteFile(file);
- } else {
- result &= file.delete();
- }
- }
- }
- }
- result &= fileToDelete.delete();
- return result;
- }
-
- protected static Properties loadPropertiesFile(URL configPropURL) throws Exception {
- // Read the properties file.
- Properties configProps = new Properties();
- InputStream is = null;
- try {
- is = configPropURL.openConnection().getInputStream();
- configProps.load(is);
- is.close();
- }
- catch (Exception ex) {
- System.err.println(
- "Error loading config properties from " + configPropURL);
- System.err.println("Main: " + ex);
- try {
- if (is != null) is.close();
- }
- catch (IOException ex2) {
- // Nothing we can do.
- }
- return null;
- }
- return configProps;
- }
-
- private static final String DELIM_START = "${";
- private static final String DELIM_STOP = "}";
-
- protected static String substVars(String val, String currentKey,
- Map<String, String> cycleMap, Properties configProps)
- throws IllegalArgumentException {
- // If there is currently no cycle map, then create
- // one for detecting cycles for this invocation.
- if (cycleMap == null) {
- cycleMap = new HashMap<String, String>();
- }
-
- // Put the current key in the cycle map.
- cycleMap.put(currentKey, currentKey);
-
- // Assume we have a value that is something like:
- // "leading ${foo.${bar}} middle ${baz} trailing"
-
- // Find the first ending '}' variable delimiter, which
- // will correspond to the first deepest nested variable
- // placeholder.
- int stopDelim = val.indexOf(DELIM_STOP);
-
- // Find the matching starting "${" variable delimiter
- // by looping until we find a start delimiter that is
- // greater than the stop delimiter we have found.
- int startDelim = val.indexOf(DELIM_START);
- while (stopDelim >= 0) {
- int idx = val.indexOf(DELIM_START, startDelim + DELIM_START.length());
- if ((idx < 0) || (idx > stopDelim)) {
- break;
- } else if (idx < stopDelim) {
- startDelim = idx;
- }
- }
-
- // If we do not have a start or stop delimiter, then just
- // return the existing value.
- if ((startDelim < 0) && (stopDelim < 0)) {
- return val;
- }
- // At this point, we found a stop delimiter without a start,
- // so throw an exception.
- else if (((startDelim < 0) || (startDelim > stopDelim))
- && (stopDelim >= 0)) {
- throw new IllegalArgumentException(
- "stop delimiter with no start delimiter: "
- + val);
- }
-
- // At this point, we have found a variable placeholder so
- // we must perform a variable substitution on it.
- // Using the start and stop delimiter indices, extract
- // the first, deepest nested variable placeholder.
- String variable =
- val.substring(startDelim + DELIM_START.length(), stopDelim);
-
- // Verify that this is not a recursive variable reference.
- if (cycleMap.get(variable) != null) {
- throw new IllegalArgumentException(
- "recursive variable reference: " + variable);
- }
-
- // Get the value of the deepest nested variable placeholder.
- // Try to configuration properties first.
- String substValue = (configProps != null)
- ? configProps.getProperty(variable, null)
- : null;
- if (substValue == null) {
- // Ignore unknown property values.
- substValue = System.getProperty(variable, "");
- }
-
- // Remove the found variable from the cycle map, since
- // it may appear more than once in the value and we don't
- // want such situations to appear as a recursive reference.
- cycleMap.remove(variable);
-
- // Append the leading characters, the substituted value of
- // the variable, and the trailing characters to get the new
- // value.
- val = val.substring(0, startDelim)
- + substValue
- + val.substring(stopDelim + DELIM_STOP.length(), val.length());
-
- // Now perform substitution again, since there could still
- // be substitutions to make.
- val = substVars(val, currentKey, cycleMap, configProps);
-
- // Return the value.
- return val;
- }
-
-}
diff --git a/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/Process.java b/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/Process.java
deleted file mode 100644
index 0644f50..0000000
--- a/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/Process.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jpm;
-
-import java.io.IOException;
-import java.io.Serializable;
-
-/**
- * Interface representing a process
- */
-public interface Process extends Serializable {
-
- /**
- * Retrieves the PID of the process
- * @return the pid
- */
- int getPid();
-
- /**
- * Check if this process is still running
- * @return <code>true</code> if the process is running
- * @throws IOException if an error occurs
- */
- boolean isRunning() throws IOException;
-
- /**
- * Destroy the process.
- *
- * @throws IOException
- */
- void destroy() throws IOException;
-
-}
diff --git a/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/ProcessBuilder.java b/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/ProcessBuilder.java
deleted file mode 100644
index a81cf36..0000000
--- a/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/ProcessBuilder.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jpm;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.*;
-
-/**
- * Interface used to create new processes.
- */
-public interface ProcessBuilder {
-
- /**
- * Specified the current directory to run the command from
- *
- * @param dir the directory to run the command from
- * @return the ProcessBuilder instance
- */
- ProcessBuilder directory(File dir);
-
- /**
- * Set the command to execute
- *
- * @param command the command to execute
- * @return the ProcessBuilder instance
- */
- ProcessBuilder command(String command);
-
- /**
- * Create and start the process
- *
- * @return the process that has been started
- * @throws IOException if the process can not be created
- */
- org.apache.felix.karaf.jpm.Process start() throws IOException;
-
- /**
- * Attach to an existing process
- *
- * @return the process that has been attached
- * @throws IOException if the process can not be attached to
- */
- org.apache.felix.karaf.jpm.Process attach(int pid) throws IOException;
-
-}
diff --git a/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/ProcessBuilderFactory.java b/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/ProcessBuilderFactory.java
deleted file mode 100644
index 6c4980c..0000000
--- a/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/ProcessBuilderFactory.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jpm;
-
-import java.lang.*;
-
-import org.apache.felix.karaf.jpm.impl.ProcessBuilderFactoryImpl;
-
-/**
- * Factory for process builders.
- */
-public abstract class ProcessBuilderFactory {
-
- public static ProcessBuilderFactory newInstance() {
- return new ProcessBuilderFactoryImpl();
- }
-
- public abstract ProcessBuilder newBuilder();
-
-}
diff --git a/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/impl/ProcessBuilderFactoryImpl.java b/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/impl/ProcessBuilderFactoryImpl.java
deleted file mode 100644
index 23ee364..0000000
--- a/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/impl/ProcessBuilderFactoryImpl.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jpm.impl;
-
-import org.apache.felix.karaf.jpm.ProcessBuilder;
-import org.apache.felix.karaf.jpm.ProcessBuilderFactory;
-
-public class ProcessBuilderFactoryImpl extends ProcessBuilderFactory {
-
- public ProcessBuilder newBuilder() {
- return new ProcessBuilderImpl();
- }
-}
diff --git a/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/impl/ProcessBuilderImpl.java b/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/impl/ProcessBuilderImpl.java
deleted file mode 100644
index c6b622e..0000000
--- a/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/impl/ProcessBuilderImpl.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jpm.impl;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.felix.karaf.jpm.Process;
-import org.apache.felix.karaf.jpm.ProcessBuilder;
-
-
-public class ProcessBuilderImpl implements ProcessBuilder {
-
- private File dir;
- private String command;
-
- public ProcessBuilder directory(File dir) {
- this.dir = dir;
- return this;
- }
-
- public ProcessBuilder command(String command) {
- this.command = command;
- return this;
- }
-
- public Process start() throws IOException {
- return ProcessImpl.create(dir, command);
- }
-
- public Process attach(int pid) throws IOException {
- return ProcessImpl.attach(pid);
- }
-}
diff --git a/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/impl/ProcessImpl.java b/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/impl/ProcessImpl.java
deleted file mode 100644
index 27dec49..0000000
--- a/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/impl/ProcessImpl.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jpm.impl;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.InterruptedIOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.felix.karaf.jpm.Process;
-
-public class ProcessImpl implements Process {
-
- private int pid;
- //private File input;
- //private File output;
- //private File error;
-
- public ProcessImpl(int pid/*, File input, File output, File error*/) {
- this.pid = pid;
- //this.input = input;
- //this.output = output;
- //this.error = error;
- }
-
- public int getPid() {
- return pid;
- }
-
- public boolean isRunning() throws IOException {
- if (ScriptUtils.isWindows()) {
- Map<String, String> props = new HashMap<String, String>();
- props.put("${pid}", Integer.toString(pid));
- int ret = ScriptUtils.execute("running", props);
- return ret == 0;
- } else {
- try {
- java.lang.Process process = new java.lang.ProcessBuilder("ps", "-p", Integer.toString(pid)).start();
- BufferedReader r = new BufferedReader(new InputStreamReader(process.getInputStream()));
- r.readLine(); // skip headers
- String s = r.readLine();
- boolean running = s != null && s.length() > 0;
- int ret = process.waitFor();
- return running;
- } catch (InterruptedException e) {
- throw new InterruptedIOException();
- }
- }
- }
-
- public void destroy() throws IOException {
- int ret;
- if (ScriptUtils.isWindows()) {
- Map<String, String> props = new HashMap<String, String>();
- props.put("${pid}", Integer.toString(pid));
- ret = ScriptUtils.execute("destroy", props);
- } else {
- ret = ScriptUtils.executeProcess(new java.lang.ProcessBuilder("kill", "-9", Integer.toString(pid)));
- }
- if (ret != 0) {
- throw new IOException("Unable to destroy proces, it may be already terminated");
- }
- }
-
- /*
- public OutputStream getInputStream() throws FileNotFoundException {
- return new FileOutputStream(input);
- }
-
- public InputStream getOutputStream() throws FileNotFoundException {
- return new FileInputStream(output);
- }
-
- public InputStream getErrorStream() throws FileNotFoundException {
- return new FileInputStream(error);
- }
- */
-
- public int waitFor() throws InterruptedException {
- return 0;
- }
-
- public int exitValue() {
- return 0;
- }
-
- public static Process create(File dir, String command) throws IOException {
- //File input = File.createTempFile("jpm.", ".input");
- //File output = File.createTempFile("jpm.", ".output");
- //File error = File.createTempFile("jpm.", ".error");
- File pidFile = File.createTempFile("jpm.", ".pid");
- try {
- Map<String, String> props = new HashMap<String, String>();
- //props.put("${in.file}", input.getCanonicalPath());
- //props.put("${out.file}", output.getCanonicalPath());
- //props.put("${err.file}", error.getCanonicalPath());
- props.put("${pid.file}", pidFile.getCanonicalPath());
- props.put("${dir}", dir != null ? dir.getCanonicalPath() : "");
- if (ScriptUtils.isWindows()) {
- command = command.replaceAll("\"", "\"\"");
- }
- props.put("${command}", command);
- int ret = ScriptUtils.execute("start", props);
- if (ret != 0) {
- throw new IOException("Unable to create process (error code: " + ret + ")");
- }
- int pid = readPid(pidFile);
- return new ProcessImpl(pid/*, input, output, error*/);
- } finally {
- pidFile.delete();
- }
- }
-
- public static Process attach(int pid) throws IOException {
- return new ProcessImpl(pid);
- }
-
- private static int readPid(File pidFile) throws IOException {
- InputStream is = new FileInputStream(pidFile);
- try {
- BufferedReader r = new BufferedReader(new InputStreamReader(is));
- String pidString = r.readLine();
- return Integer.valueOf(pidString);
- } finally {
- try {
- is.close();
- } catch (IOException e) {}
- }
- }
-
-}
diff --git a/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/impl/ScriptUtils.java b/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/impl/ScriptUtils.java
deleted file mode 100644
index 0f29087..0000000
--- a/karaf/admin/core/src/main/java/org/apache/felix/karaf/jpm/impl/ScriptUtils.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jpm.impl;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InterruptedIOException;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.util.Map;
-import java.util.Scanner;
-
-public class ScriptUtils {
-
- public static int execute(String name, Map<String, String> props) throws IOException {
- File script = File.createTempFile("jpm.", ".script");
- try {
- if (isWindows()) {
- String res = "windows/" + name + ".vbs";
- ScriptUtils.copyFilteredResource(res, script, props);
- return executeProcess(new java.lang.ProcessBuilder("cscript",
- "/NOLOGO",
- "//E:vbs",
- script.getCanonicalPath()));
- } else {
- String res = "unix/" + name + ".sh";
- ScriptUtils.copyFilteredResource(res, script, props);
- return executeProcess(new java.lang.ProcessBuilder("/bin/sh",
- script.getCanonicalPath()));
- }
- } finally {
- script.delete();
- }
- }
-
- public static int executeProcess(java.lang.ProcessBuilder builder) throws IOException {
- try {
- java.lang.Process process = builder.start();
- return process.waitFor();
- } catch (InterruptedException e) {
- throw new InterruptedIOException();
- }
- }
-
- public static void copyFilteredResource(String resource, File outFile, Map<String, String> props) throws IOException {
- InputStream is = null;
- try {
- is = ScriptUtils.class.getResourceAsStream(resource);
- // Read it line at a time so that we can use the platform line ending when we write it out.
- PrintStream out = new PrintStream(new FileOutputStream(outFile));
- try {
- Scanner scanner = new Scanner(is);
- while (scanner.hasNextLine() ) {
- String line = scanner.nextLine();
- line = filter(line, props);
- out.println(line);
- }
- } finally {
- safeClose(out);
- }
- } finally {
- safeClose(is);
- }
- }
-
- private static void safeClose(InputStream is) throws IOException {
- if (is == null) {
- return;
- }
- try {
- is.close();
- } catch (Throwable ignore) {
- }
- }
-
- private static void safeClose(OutputStream is) throws IOException {
- if (is == null) {
- return;
- }
- try {
- is.close();
- } catch (Throwable ignore) {
- }
- }
-
- private static String filter(String line, Map<String, String> props) {
- for (Map.Entry<String, String> i : props.entrySet()) {
- int p1 = line.indexOf(i.getKey());
- if( p1 >= 0 ) {
- String l1 = line.substring(0, p1);
- String l2 = line.substring(p1+i.getKey().length());
- line = l1+i.getValue()+l2;
- }
- }
- return line;
- }
-
- private static final boolean windows;
-
- static {
- windows = System.getProperty("os.name").toLowerCase().indexOf("windows") != -1;
- }
-
- public static boolean isWindows() {
- return windows;
- }
-
-}
diff --git a/karaf/admin/core/src/main/resources/OSGI-INF/blueprint/admin-core.xml b/karaf/admin/core/src/main/resources/OSGI-INF/blueprint/admin-core.xml
deleted file mode 100644
index 4f994a8..0000000
--- a/karaf/admin/core/src/main/resources/OSGI-INF/blueprint/admin-core.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
- default-activation="lazy">
-
- <bean id="adminService" class="org.apache.felix.karaf.admin.internal.AdminServiceImpl" init-method="init">
- <property name="storageLocation" value="${karaf.home}/instances" />
- </bean>
-
- <service ref="adminService" interface="org.apache.felix.karaf.admin.AdminService" />
-
- <!-- Allow the use of system properties -->
- <ext:property-placeholder />
-
-</blueprint>
diff --git a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/bin/karaf b/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/bin/karaf
deleted file mode 100644
index 8967cea..0000000
--- a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/bin/karaf
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh
-################################################################################
-#
-# 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.
-#
-################################################################################
-
-KARAF_HOME=${SUBST-KARAF-HOME}
-KARAF_BASE=${SUBST-KARAF-BASE}
-
-export KARAF_BASE
-exec ${KARAF_HOME}/bin/karaf "$*"
diff --git a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/bin/karaf.bat b/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/bin/karaf.bat
deleted file mode 100644
index 312b66c..0000000
--- a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/bin/karaf.bat
+++ /dev/null
@@ -1,25 +0,0 @@
-@ECHO OFF
-REM =========================================================================
-REM
-REM Licensed to the Apache Software Foundation (ASF) under one or more
-REM contributor license agreements. See the NOTICE file distributed with
-REM this work for additional information regarding copyright ownership.
-REM The ASF licenses this file to You under the Apache License, Version 2.0
-REM (the "License"); you may not use this file except in compliance with
-REM the License. You may obtain a copy of the License at
-REM
-REM http://www.apache.org/licenses/LICENSE-2.0
-REM
-REM Unless required by applicable law or agreed to in writing, software
-REM distributed under the License is distributed on an "AS IS" BASIS,
-REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-REM See the License for the specific language governing permissions and
-REM limitations under the License.
-REM
-REM =========================================================================
-
-SETLOCAL
-SET KARAF_HOME=${SUBST-KARAF-HOME}
-SET KARAF_BASE=${SUBST-KARAF-BASE}
-
-%KARAF_HOME%\bin\karaf.bat %*
diff --git a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/bin/start b/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/bin/start
deleted file mode 100644
index 333cba1..0000000
--- a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/bin/start
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh
-################################################################################
-#
-# 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.
-#
-################################################################################
-
-KARAF_HOME=${SUBST-KARAF-HOME}
-KARAF_NAME=${SUBST-KARAF-NAME}
-
-exec ${KARAF_HOME}/bin/admin start ${KARAF_NAME} "$@"
-
diff --git a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/bin/start.bat b/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/bin/start.bat
deleted file mode 100644
index 822ed42..0000000
--- a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/bin/start.bat
+++ /dev/null
@@ -1,24 +0,0 @@
-@ECHO OFF
-REM =========================================================================
-REM
-REM Licensed to the Apache Software Foundation (ASF) under one or more
-REM contributor license agreements. See the NOTICE file distributed with
-REM this work for additional information regarding copyright ownership.
-REM The ASF licenses this file to You under the Apache License, Version 2.0
-REM (the "License"); you may not use this file except in compliance with
-REM the License. You may obtain a copy of the License at
-REM
-REM http://www.apache.org/licenses/LICENSE-2.0
-REM
-REM Unless required by applicable law or agreed to in writing, software
-REM distributed under the License is distributed on an "AS IS" BASIS,
-REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-REM See the License for the specific language governing permissions and
-REM limitations under the License.
-REM
-REM =========================================================================
-
-SET KARAF_HOME=${SUBST-KARAF-HOME}
-SET KARAF_NAME=${SUBST-KARAF-NAME}
-
-%KARAF_HOME%\bin\admin.bat start %KARAF_NAME%
diff --git a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/bin/stop b/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/bin/stop
deleted file mode 100644
index 459a488..0000000
--- a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/bin/stop
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh
-################################################################################
-#
-# 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.
-#
-################################################################################
-
-KARAF_HOME=${SUBST-KARAF-HOME}
-KARAF_NAME=${SUBST-KARAF-NAME}
-
-exec ${KARAF_HOME}/bin/admin stop ${KARAF_NAME} "$@"
-
diff --git a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/bin/stop.bat b/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/bin/stop.bat
deleted file mode 100644
index 31d92cb..0000000
--- a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/bin/stop.bat
+++ /dev/null
@@ -1,24 +0,0 @@
-@ECHO OFF
-REM =========================================================================
-REM
-REM Licensed to the Apache Software Foundation (ASF) under one or more
-REM contributor license agreements. See the NOTICE file distributed with
-REM this work for additional information regarding copyright ownership.
-REM The ASF licenses this file to You under the Apache License, Version 2.0
-REM (the "License"); you may not use this file except in compliance with
-REM the License. You may obtain a copy of the License at
-REM
-REM http://www.apache.org/licenses/LICENSE-2.0
-REM
-REM Unless required by applicable law or agreed to in writing, software
-REM distributed under the License is distributed on an "AS IS" BASIS,
-REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-REM See the License for the specific language governing permissions and
-REM limitations under the License.
-REM
-REM =========================================================================
-
-SET KARAF_HOME=${SUBST-KARAF-HOME}
-SET KARAF_NAME=${SUBST-KARAF-NAME}
-
-%KARAF_HOME%\bin\admin.bat stop %KARAF_NAME%
diff --git a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/etc/org.apache.felix.karaf.shell.cfg b/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/etc/org.apache.felix.karaf.shell.cfg
deleted file mode 100644
index 7c5ab59..0000000
--- a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/etc/org.apache.felix.karaf.shell.cfg
+++ /dev/null
@@ -1,24 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-#
-sshPort=${SUBST-SSH-PORT}
-sshHost=0.0.0.0
-sshRealm=karaf
-hostKey=${karaf.base}/etc/host.key
diff --git a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/etc/org.ops4j.pax.url.mvn.cfg b/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/etc/org.ops4j.pax.url.mvn.cfg
deleted file mode 100644
index 87480f2..0000000
--- a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/etc/org.ops4j.pax.url.mvn.cfg
+++ /dev/null
@@ -1,80 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-#
-# If set to true, the following property will not allow any certificate to be used
-# when accessing maven repositories through SSL
-#
-#org.ops4j.pax.url.mvn.certificateCheck=
-
-#
-# Path to the local maven settings file.
-# The repositories defined in this file will be automatically added to the list
-# of default repositories if the 'org.ops4j.pax.url.mvn.repositories' property
-# below is not set.
-# The following locations are checked for the existence of the settings.xml file
-# * 1. looks for the specified url
-# * 2. if not found looks for ${user.home}/.m2/settings.xml
-# * 3. if not found looks for ${maven.home}/conf/settings.xml
-# * 4. if not found looks for ${M2_HOME}/conf/settings.xml
-#
-#org.ops4j.pax.url.mvn.settings=
-
-#
-# Path to the local maven repository which is used to avoid downloading
-# artifacts when they already exist locally.
-# The value of this property will be extracted from the settings.xml file
-# above, or defaulted to:
-# System.getProperty( "user.home" ) + "/.m2/repository"
-#
-#org.ops4j.pax.url.mvn.localRepository=
-
-#
-# Comma separated list of repositories scanned when resolving an artifact.
-# Those repositories will be checked before iterating through the
- below list of repositories and even before the local repository
-# A repository url can be appended with zero or more of the following flags:
-# @snapshots : the repository contains snaphots
-# @noreleases : the repository does not contain any released artifacts
-#
-# The following property value will add the system folder as a repo.
-#
-org.ops4j.pax.url.mvn.defaultRepositories=file:${karaf.home}/${karaf.default.repository}@snapshots, \
- file:${karaf.base}/${karaf.default.repository}@snapshots
-
-#
-# Comma separated list of repositories scanned when resolving an artifact.
-# The default list includes the following repositories:
-# http://repo1.maven.org/maven2
-# http://repository.ops4j.org/maven2
-# To add repositories to the default ones, prepend '+' to the list of repositories
-# to add.
-# A repository url can be appended with zero or more of the following flags:
-# @snapshots : the repository contains snaphots
-# @noreleases : the repository does not contain any released artifacts
-#
-# The following property value will add the system folder as a repo.
-#
-org.ops4j.pax.url.mvn.repositories= \
- http://repo1.maven.org/maven2, \
- http://people.apache.org/repo/m2-snapshot-repository@snapshots@noreleases, \
- http://repository.ops4j.org/maven2, \
- http://svn.apache.org/repos/asf/servicemix/m2-repo, \
- http://repository.springsource.com/maven/bundles/release, \
- http://repository.springsource.com/maven/bundles/external
diff --git a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/etc/system.properties b/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/etc/system.properties
deleted file mode 100644
index d5fc11f..0000000
--- a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/admin/etc/system.properties
+++ /dev/null
@@ -1,61 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-#
-# The properties defined in this file will be made available through system
-# properties at the very beginning of the Karaf's boot process.
-#
-
-
-# Log level when the pax-logging service is not available
-# This level will only be used while the pax-logging service bundle
-# is not fully available.
-# To change log levels, please refer to the org.ops4j.pax.logging.cfg file
-# instead.
-org.ops4j.pax.logging.DefaultServiceLog.level=ERROR
-
-#
-# Name of this karaf instance.
-#
-karaf.name=${SUBST-KARAF-NAME}
-
-#
-# Default repository where bundles will be loaded from before using
-# other maven repositories. For the full maven configuration, see
-# the org.ops4j.pax.url.mvn.cfg file.
-#
-karaf.default.repository=system
-
-#
-# Location of a shell script that will be run when starting a shell
-# session. This script can be used to create aliases and define
-# additional commands.
-#
-karaf.shell.init.script=${karaf.home}/etc/shell.init.script
-
-#
-# Set this empty property to avoid errors when validating xml documents.
-#
-xml.catalog.files=
-
-#
-# Suppress the bell in the console when hitting backspace to many times
-# for example
-#
-jline.nobell=true
diff --git a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/jpm/impl/unix/start.sh b/karaf/admin/core/src/main/resources/org/apache/felix/karaf/jpm/impl/unix/start.sh
deleted file mode 100644
index 1d1d720..0000000
--- a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/jpm/impl/unix/start.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-################################################################################
-#
-# 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.
-#
-################################################################################
-
-#exec 1>${out.file}
-#exec 2>${err.file}
-exec 1>/dev/null
-exec 2>/dev/null
-if [ "x${dir}" != "x" ]; then
- cd ${dir}
-fi
-nohup ${command} &
-echo $! > ${pid.file}
diff --git a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/jpm/impl/windows/destroy.vbs b/karaf/admin/core/src/main/resources/org/apache/felix/karaf/jpm/impl/windows/destroy.vbs
deleted file mode 100644
index abd60eb..0000000
--- a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/jpm/impl/windows/destroy.vbs
+++ /dev/null
@@ -1,27 +0,0 @@
-'===============================================================================
-'
-' Licensed to the Apache Software Foundation (ASF) under one or more
-' contributor license agreements. See the NOTICE file distributed with
-' this work for additional information regarding copyright ownership.
-' The ASF licenses this file to You under the Apache License, Version 2.0
-' (the "License"); you may not use this file except in compliance with
-' the License. You may obtain a copy of the License at
-'
-' http://www.apache.org/licenses/LICENSE-2.0
-'
-' Unless required by applicable law or agreed to in writing, software
-' distributed under the License is distributed on an "AS IS" BASIS,
-' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-' See the License for the specific language governing permissions and
-' limitations under the License.
-'
-'===============================================================================
-
-Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
-Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where ProcessId = ${pid}")
-intRetVal = 1
-For Each objProcess in colProcessList
- objProcess.Terminate()
- intRetVal = 0
-Next
-WScript.Quit(intRetVal)
diff --git a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/jpm/impl/windows/running.vbs b/karaf/admin/core/src/main/resources/org/apache/felix/karaf/jpm/impl/windows/running.vbs
deleted file mode 100644
index 32c65c5..0000000
--- a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/jpm/impl/windows/running.vbs
+++ /dev/null
@@ -1,26 +0,0 @@
-'===============================================================================
-'
-' Licensed to the Apache Software Foundation (ASF) under one or more
-' contributor license agreements. See the NOTICE file distributed with
-' this work for additional information regarding copyright ownership.
-' The ASF licenses this file to You under the Apache License, Version 2.0
-' (the "License"); you may not use this file except in compliance with
-' the License. You may obtain a copy of the License at
-'
-' http://www.apache.org/licenses/LICENSE-2.0
-'
-' Unless required by applicable law or agreed to in writing, software
-' distributed under the License is distributed on an "AS IS" BASIS,
-' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-' See the License for the specific language governing permissions and
-' limitations under the License.
-'
-'===============================================================================
-
-Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
-Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where ProcessId = ${pid}")
-intRetVal = 1
-For Each objProcess in colProcessList
- intRetVal = 0
-Next
-WScript.Quit(intRetVal)
diff --git a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/jpm/impl/windows/start.vbs b/karaf/admin/core/src/main/resources/org/apache/felix/karaf/jpm/impl/windows/start.vbs
deleted file mode 100644
index 6004c86..0000000
--- a/karaf/admin/core/src/main/resources/org/apache/felix/karaf/jpm/impl/windows/start.vbs
+++ /dev/null
@@ -1,34 +0,0 @@
-'===============================================================================
-'
-' Licensed to the Apache Software Foundation (ASF) under one or more
-' contributor license agreements. See the NOTICE file distributed with
-' this work for additional information regarding copyright ownership.
-' The ASF licenses this file to You under the Apache License, Version 2.0
-' (the "License"); you may not use this file except in compliance with
-' the License. You may obtain a copy of the License at
-'
-' http://www.apache.org/licenses/LICENSE-2.0
-'
-' Unless required by applicable law or agreed to in writing, software
-' distributed under the License is distributed on an "AS IS" BASIS,
-' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-' See the License for the specific language governing permissions and
-' limitations under the License.
-'
-'===============================================================================
-
-Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
-Set objConfig = objWMIService.Get("Win32_ProcessStartup").SpawnInstance_
-objConfig.ShowWindow = SW_HIDE
-objConfig.CreateFlags = 8
-If Len("${dir}") > 0 Then
- intReturn = objWMIService.Get("Win32_Process").Create("${command}", "${dir}", objConfig, intProcessID)
-Else
- intReturn = objWMIService.Get("Win32_Process").Create("${command}", Null, objConfig, intProcessID)
-End If
-If intReturn = 0 Then
- Set objOutputFile = CreateObject("Scripting.fileSystemObject").CreateTextFile("${pid.file}", TRUE)
- objOutputFile.WriteLine(intProcessID)
- objOutputFile.Close
-End If
-WScript.Quit(intReturn)
diff --git a/karaf/admin/core/src/test/java/org/apache/felix/karaf/admin/InstanceSettingsTest.java b/karaf/admin/core/src/test/java/org/apache/felix/karaf/admin/InstanceSettingsTest.java
deleted file mode 100644
index cce8c80..0000000
--- a/karaf/admin/core/src/test/java/org/apache/felix/karaf/admin/InstanceSettingsTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import junit.framework.TestCase;
-import org.apache.felix.karaf.admin.InstanceSettings;
-import org.junit.Assert;
-
-public class InstanceSettingsTest extends TestCase {
- public void testInstanceSettings() {
- InstanceSettings is =
- new InstanceSettings(1, null, Collections.<String>emptyList(), Arrays.asList("hi"));
- assertEquals(1, is.getPort());
- Assert.assertNull(is.getLocation());
- assertEquals(Arrays.asList("hi"), is.getFeatures());
- assertEquals(0, is.getFeatureURLs().size());
- }
-
- public void testEqualsHashCode() {
- testEqualsHashCode(1, "top", Collections.<String>emptyList(), Arrays.asList("hi"));
- testEqualsHashCode(0, null, null, null);
- }
-
- private void testEqualsHashCode(int port, String location, List<String> featureURLs, List<String> features) {
- InstanceSettings is = new InstanceSettings(port, location, featureURLs, features);
- InstanceSettings is2 = new InstanceSettings(port, location, featureURLs, features);
- assertEquals(is, is2);
- assertEquals(is.hashCode(), is2.hashCode());
- }
-
- public void testEqualsHashCode2() {
- InstanceSettings is = new InstanceSettings(1, "top", Collections.<String>emptyList(), Arrays.asList("hi"));
- Assert.assertFalse(is.equals(null));
- Assert.assertFalse(is.equals(new Object()));
- assertEquals(is, is);
- }
-}
diff --git a/karaf/admin/core/src/test/java/org/apache/felix/karaf/admin/internal/AdminServiceImplTest.java b/karaf/admin/core/src/test/java/org/apache/felix/karaf/admin/internal/AdminServiceImplTest.java
deleted file mode 100644
index 89dac42..0000000
--- a/karaf/admin/core/src/test/java/org/apache/felix/karaf/admin/internal/AdminServiceImplTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin.internal;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Arrays;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-import org.apache.felix.karaf.admin.Instance;
-import org.apache.felix.karaf.admin.InstanceSettings;
-
-public class AdminServiceImplTest extends TestCase {
-
- public void testHandleFeatures() throws Exception {
- AdminServiceImpl as = new AdminServiceImpl();
-
- File f = File.createTempFile(getName(), ".test");
- try {
- Properties p = new Properties();
- p.put("featuresBoot", "abc,def ");
- p.put("featuresRepositories", "somescheme://xyz");
- OutputStream os = new FileOutputStream(f);
- try {
- p.store(os, "Test comment");
- } finally {
- os.close();
- }
-
- InstanceSettings s = new InstanceSettings(8122, null, null, Arrays.asList("test"));
- as.handleFeatures(f, s);
-
- Properties p2 = new Properties();
- InputStream is = new FileInputStream(f);
- try {
- p2.load(is);
- } finally {
- is.close();
- }
- assertEquals(2, p2.size());
- assertEquals("abc,def,test", p2.get("featuresBoot"));
- assertEquals("somescheme://xyz", p2.get("featuresRepositories"));
- } finally {
- f.delete();
- }
- }
-
- /**
- * Ensure the admin:create generates all the required configuration files
- * //TODO: fix this test so it can run in an IDE
- */
- public void testConfigurationFiles() throws Exception {
- AdminServiceImpl service = new AdminServiceImpl();
- service.setStorageLocation(new File("target/instances/" + System.currentTimeMillis()));
-
- InstanceSettings settings = new InstanceSettings(8122, getName(), null, null);
- Instance instance = service.createInstance(getName(), settings);
-
- assertFileExists(instance.getLocation(), "etc/config.properties");
- assertFileExists(instance.getLocation(), "etc/users.properties");
- assertFileExists(instance.getLocation(), "etc/startup.properties");
-
- assertFileExists(instance.getLocation(), "etc/java.util.logging.properties");
- assertFileExists(instance.getLocation(), "etc/org.apache.felix.karaf.features.cfg");
- assertFileExists(instance.getLocation(), "etc/org.apache.felix.fileinstall-deploy.cfg");
- assertFileExists(instance.getLocation(), "etc/org.apache.felix.karaf.log.cfg");
- assertFileExists(instance.getLocation(), "etc/org.apache.felix.karaf.management.cfg");
- assertFileExists(instance.getLocation(), "etc/org.ops4j.pax.logging.cfg");
- assertFileExists(instance.getLocation(), "etc/org.ops4j.pax.url.mvn.cfg");
- }
-
- private void assertFileExists(String path, String name) throws IOException {
- File file = new File(path, name);
- assertTrue("Expected " + file.getCanonicalPath() + " to exist",
- file.exists());
- }
-}
diff --git a/karaf/admin/core/src/test/java/org/apache/felix/karaf/jpm/MainTest.java b/karaf/admin/core/src/test/java/org/apache/felix/karaf/jpm/MainTest.java
deleted file mode 100644
index 2d4c80a..0000000
--- a/karaf/admin/core/src/test/java/org/apache/felix/karaf/jpm/MainTest.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jpm;
-
-public class MainTest {
-
- public static void main(String[] args) throws Exception {
- Thread.sleep(Long.parseLong(args[0]));
- }
-}
diff --git a/karaf/admin/core/src/test/java/org/apache/felix/karaf/jpm/ProcessTest.java b/karaf/admin/core/src/test/java/org/apache/felix/karaf/jpm/ProcessTest.java
deleted file mode 100644
index 8b6ebc4..0000000
--- a/karaf/admin/core/src/test/java/org/apache/felix/karaf/jpm/ProcessTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jpm;
-
-import java.io.File;
-
-import junit.framework.TestCase;
-import org.apache.felix.karaf.jpm.impl.ScriptUtils;
-import org.apache.felix.karaf.jpm.ProcessBuilder;
-
-public class ProcessTest extends TestCase {
-
- public void testCreate() throws Exception {
- String javaPath = new File(System.getProperty("java.home"), ScriptUtils.isWindows() ? "bin\\java.exe" : "bin/java").getCanonicalPath();
- System.err.println(javaPath);
- StringBuilder command = new StringBuilder();
- command.append(javaPath);
- command.append(" -Dprop=\"key\"");
- command.append(" -classpath ");
- String clRes = getClass().getName().replace('.', '/') + ".class";
- String str = getClass().getClassLoader().getResource(clRes).toString();
- str = str.substring("file:".length(), str.indexOf(clRes));
- command.append(str);
- command.append(" ");
- command.append(MainTest.class.getName());
- command.append(" ");
- command.append(60000);
- System.err.println("Executing: " + command.toString());
-
- ProcessBuilder builder = ProcessBuilderFactory.newInstance().newBuilder();
- org.apache.felix.karaf.jpm.Process p = builder.command(command.toString()).start();
- assertNotNull(p);
- System.err.println("Process: " + p.getPid());
- assertNotNull(p.getPid());
- Thread.currentThread().sleep(1000);
- System.err.println("Running: " + p.isRunning());
- assertTrue(p.isRunning());
- System.err.println("Destroying");
- p.destroy();
- Thread.currentThread().sleep(1000);
- System.err.println("Running: " + p.isRunning());
- assertFalse(p.isRunning());
- }
-
- /*
- * When the process creation fails, no error is reported by the script
- *
- public void testFailure() throws Exception {
- ProcessBuilder builder = ProcessBuilderFactory.newInstance().newBuilder();
- Process p = builder.command("ec").start();
- fail("An exception should have been thrown");
- }
- */
-}
diff --git a/karaf/admin/management/NOTICE b/karaf/admin/management/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/admin/management/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/admin/management/pom.xml b/karaf/admin/management/pom.xml
deleted file mode 100644
index 6b64a3b..0000000
--- a/karaf/admin/management/pom.xml
+++ /dev/null
@@ -1,98 +0,0 @@
-<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/maven-v4_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.felix.karaf.admin</groupId>
- <artifactId>admin</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.admin</groupId>
- <artifactId>org.apache.felix.karaf.admin.management</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Admin Management</name>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix.karaf.admin</groupId>
- <artifactId>org.apache.felix.karaf.admin.core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>org.apache.felix.karaf.management</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymockclassextension</artifactId>
- <version>${easymock.version}</version>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>
- ${project.artifactId}*;version=${project.version}
- </Export-Package>
- <Import-Package>
- !${project.artifactId}*,
- javax.management,
- javax.management.loading,
- org.osgi.service.command,
- org.apache.felix.gogo.commands,
- org.apache.felix.karaf.shell.console,
- *
- </Import-Package>
- <Private-Package>org.apache.felix.karaf.admin.management.internal</Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/karaf/admin/management/src/main/java/org/apache/felix/karaf/admin/management/AdminServiceMBean.java b/karaf/admin/management/src/main/java/org/apache/felix/karaf/admin/management/AdminServiceMBean.java
deleted file mode 100644
index 0decb21..0000000
--- a/karaf/admin/management/src/main/java/org/apache/felix/karaf/admin/management/AdminServiceMBean.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin.management;
-
-import javax.management.openmbean.TabularData;
-
-public interface AdminServiceMBean {
-
- String INSTANCE_PID = "Pid";
- String INSTANCE_NAME = "Name";
- String INSTANCE_IS_ROOT = "Is Root";
- String INSTANCE_PORT = "Port";
- String INSTANCE_STATE = "State";
- String INSTANCE_LOCATION = "Location";
-
- String[] INSTANCE = {INSTANCE_PID, INSTANCE_NAME, INSTANCE_IS_ROOT, INSTANCE_PORT,
- INSTANCE_STATE, INSTANCE_LOCATION };
-
- // Operations
- int createInstance(String name, int port, String location, String features, String featureURLs)
- throws Exception;
- void changePort(String name, int port) throws Exception;
- void destroyInstance(String name) throws Exception;
- void startInstance(String name, String opts) throws Exception;
- void stopInstance(String name) throws Exception;
-
- // Attributes
- TabularData getInstances() throws Exception;
-
-}
diff --git a/karaf/admin/management/src/main/java/org/apache/felix/karaf/admin/management/codec/JmxInstance.java b/karaf/admin/management/src/main/java/org/apache/felix/karaf/admin/management/codec/JmxInstance.java
deleted file mode 100644
index 264c5c9..0000000
--- a/karaf/admin/management/src/main/java/org/apache/felix/karaf/admin/management/codec/JmxInstance.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin.management.codec;
-
-import java.util.List;
-
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.SimpleType;
-import javax.management.openmbean.TabularData;
-import javax.management.openmbean.TabularDataSupport;
-import javax.management.openmbean.TabularType;
-
-import org.apache.felix.karaf.admin.management.AdminServiceMBean;
-import org.apache.felix.karaf.admin.Instance;
-
-public class JmxInstance {
- static final CompositeType INSTANCE;
- static final TabularType INSTANCE_TABLE;
-
- static {
- INSTANCE = createInstanceType();
- INSTANCE_TABLE = createInstanceTableType();
- }
-
- private final CompositeDataSupport data;
-
- private CompositeData asCompositeData() {
- return data;
- }
-
- public JmxInstance(Instance instance) {
- try {
- String[] itemNames = AdminServiceMBean.INSTANCE;
- Object[] itemValues = new Object[itemNames.length];
- itemValues[0] = instance.getPid();
- itemValues[1] = instance.getName();
- itemValues[2] = instance.isRoot();
- itemValues[3] = instance.getPort();
- try {
- itemValues[4] = instance.getState();
- } catch (Exception e) {
- itemValues[4] = "Error";
- }
- itemValues[5] = instance.getLocation();
-
- data = new CompositeDataSupport(INSTANCE, itemNames, itemValues);
- } catch (OpenDataException e) {
- throw new IllegalStateException("Cannot create instance open data", e);
- }
- }
-
- private static CompositeType createInstanceType() {
- try {
- String desc = "This type describes Karaf instances";
- String[] itemNames = AdminServiceMBean.INSTANCE;
- OpenType[] itemTypes = new OpenType[itemNames.length];
- String[] descriptions = new String[itemNames.length];
-
- itemTypes[0] = SimpleType.INTEGER;
- descriptions[0] = "The Process ID of the instance or 0 if not running.";
-
- itemTypes[1] = SimpleType.STRING;
- descriptions[1] = "The name of the instance.";
-
- itemTypes[2] = SimpleType.BOOLEAN;
- descriptions[2] = "Whether the instance is root.";
-
- itemTypes[3] = SimpleType.INTEGER;
- descriptions[3] = "The SSH port that can be used to connect to the instance.";
-
- itemTypes[4] = SimpleType.STRING;
- descriptions[4] = "The state of the instance.";
-
- itemTypes[5] = SimpleType.STRING;
- descriptions[5] = "The location of the instance.";
-
- return new CompositeType("Instance", desc, itemNames, descriptions, itemTypes);
- } catch (OpenDataException e) {
- throw new IllegalStateException("Unable to build instance type", e);
- }
- }
-
- private static TabularType createInstanceTableType() {
- try {
- return new TabularType("Instances", "Table of all Karaf instances", INSTANCE,
- new String[] {AdminServiceMBean.INSTANCE_NAME});
- } catch (OpenDataException e) {
- throw new IllegalStateException("Unable to build instance table type", e);
- }
- }
-
- public static TabularData tableFrom(List<JmxInstance> instances) {
- TabularDataSupport table = new TabularDataSupport(INSTANCE_TABLE);
- for (JmxInstance instance : instances) {
- table.put(instance.asCompositeData());
- }
- return table;
- }
-
-}
diff --git a/karaf/admin/management/src/main/java/org/apache/felix/karaf/admin/management/internal/AdminServiceMBeanImpl.java b/karaf/admin/management/src/main/java/org/apache/felix/karaf/admin/management/internal/AdminServiceMBeanImpl.java
deleted file mode 100644
index 9c0267a..0000000
--- a/karaf/admin/management/src/main/java/org/apache/felix/karaf/admin/management/internal/AdminServiceMBeanImpl.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin.management.internal;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.management.NotCompliantMBeanException;
-import javax.management.StandardMBean;
-import javax.management.openmbean.TabularData;
-
-import org.apache.felix.karaf.admin.management.AdminServiceMBean;
-import org.apache.felix.karaf.admin.AdminService;
-import org.apache.felix.karaf.admin.Instance;
-import org.apache.felix.karaf.admin.InstanceSettings;
-import org.apache.felix.karaf.admin.management.codec.JmxInstance;
-
-public class AdminServiceMBeanImpl extends StandardMBean implements AdminServiceMBean {
-
- private AdminService adminService;
-
- public AdminServiceMBeanImpl() throws NotCompliantMBeanException {
- super(AdminServiceMBean.class);
- }
-
- public AdminService getAdminService() {
- return adminService;
- }
-
- public void setAdminService(AdminService adminService) {
- this.adminService = adminService;
- }
-
- public int createInstance(String name, int port, String location, String features, String featureURLs)
- throws Exception {
- if ("".equals(location)) {
- location = null;
- }
-
- InstanceSettings settings = new InstanceSettings(port, location,
- parseStringList(featureURLs), parseStringList(features));
-
- Instance inst = adminService.createInstance(name, settings);
- if (inst != null) {
- return inst.getPid();
- } else {
- return -1;
- }
- }
-
- public void changePort(String name, int port) throws Exception {
- getExistingInstance(name).changePort(port);
- }
-
- public void destroyInstance(String name) throws Exception {
- getExistingInstance(name).destroy();
- }
-
- public void startInstance(String name, String opts) throws Exception {
- getExistingInstance(name).start(opts);
- }
-
- public void stopInstance(String name) throws Exception {
- getExistingInstance(name).stop();
- }
-
- public TabularData getInstances() throws Exception {
- List<Instance> allInstances = Arrays.asList(adminService.getInstances());
- List<JmxInstance> instances = new ArrayList<JmxInstance>();
- for (Instance instance : allInstances) {
- instances.add(new JmxInstance(instance));
- }
- TabularData table = JmxInstance.tableFrom(instances);
- return table;
- }
-
- private Instance getExistingInstance(String name) {
- Instance i = adminService.getInstance(name);
- if (i == null) {
- throw new IllegalArgumentException("Instance '" + name + "' does not exist");
- }
- return i;
- }
-
- private List<String> parseStringList(String value) {
- List<String> list = new ArrayList<String>();
- if (value != null) {
- for (String el : value.split(",")) {
- String trimmed = el.trim();
- if (trimmed.length() == 0) {
- continue;
- }
- list.add(trimmed);
- }
- }
- return list;
- }
-}
diff --git a/karaf/admin/management/src/main/resources/OSGI-INF/blueprint/admin-management.xml b/karaf/admin/management/src/main/resources/OSGI-INF/blueprint/admin-management.xml
deleted file mode 100644
index a1d5d26..0000000
--- a/karaf/admin/management/src/main/resources/OSGI-INF/blueprint/admin-management.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <reference id="adminService" interface="org.apache.felix.karaf.admin.AdminService" />
-
- <reference id="mbeanServer" interface="javax.management.MBeanServer">
- <reference-listener ref="mbeanRegister" bind-method="registerMBeanServer" unbind-method="unregisterMBeanServer" />
- </reference>
-
- <bean id="mbeanImpl" class="org.apache.felix.karaf.admin.management.internal.AdminServiceMBeanImpl">
- <property name="adminService" ref="adminService" />
- </bean>
-
- <bean id="mbeanRegister" class="org.apache.felix.karaf.management.MBeanRegistrer">
- <property name="mbeans">
- <map>
- <entry value="org.apache.felix.karaf:type=admin,name=${karaf.name}"
- key-ref="mbeanImpl" />
- </map>
- </property>
- </bean>
-
-
-</blueprint>
diff --git a/karaf/admin/management/src/test/java/org/apache/felix/karaf/admin/management/codec/JmxInstanceTest.java b/karaf/admin/management/src/test/java/org/apache/felix/karaf/admin/management/codec/JmxInstanceTest.java
deleted file mode 100644
index f2f174b..0000000
--- a/karaf/admin/management/src/test/java/org/apache/felix/karaf/admin/management/codec/JmxInstanceTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin.management.codec;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.TabularData;
-import javax.management.openmbean.TabularType;
-
-import junit.framework.TestCase;
-import org.apache.felix.karaf.admin.Instance;
-import org.apache.felix.karaf.admin.management.AdminServiceMBean;
-import org.easymock.EasyMock;
-import org.junit.Assert;
-
-public class JmxInstanceTest extends TestCase {
- public void testJMXInstanceStatics() {
- CompositeType it = JmxInstance.INSTANCE;
- Assert.assertEquals(
- new HashSet<String>(Arrays.asList(AdminServiceMBean.INSTANCE)),
- it.keySet());
-
- TabularType tt = JmxInstance.INSTANCE_TABLE;
- Assert.assertEquals("Instances", tt.getTypeName());
- }
-
- public void testJMXInstance() throws Exception {
- Instance i = EasyMock.createMock(Instance.class);
- EasyMock.expect(i.getPid()).andReturn(1712);
- EasyMock.expect(i.getName()).andReturn("MyInstance");
- EasyMock.expect(i.isRoot()).andReturn(false);
- EasyMock.expect(i.getPort()).andReturn(0);
- EasyMock.expect(i.getState()).andThrow(new Exception("gotcha"));
- EasyMock.expect(i.getLocation()).andReturn("somewhere");
- EasyMock.replay(i);
-
- JmxInstance ji = new JmxInstance(i);
- TabularData td = JmxInstance.tableFrom(Collections.singletonList(ji));
- Collection<?> keys = (Collection<?>) td.keySet().iterator().next();
- Assert.assertEquals("MyInstance", keys.iterator().next());
-
- CompositeData cd = td.get(keys.toArray());
- Assert.assertEquals(1712, cd.get("Pid"));
- Assert.assertEquals("MyInstance", cd.get("Name"));
- Assert.assertEquals(false, cd.get("Is Root"));
- Assert.assertEquals(0, cd.get("Port"));
- Assert.assertEquals("Error", cd.get("State"));
- Assert.assertEquals("somewhere", cd.get("Location"));
- }
-
- public void testJMXInstance2() throws Exception {
- Instance i = EasyMock.createMock(Instance.class);
- EasyMock.expect(i.getPid()).andReturn(1712);
- EasyMock.expect(i.getName()).andReturn("MyInstance");
- EasyMock.expect(i.isRoot()).andReturn(true);
- EasyMock.expect(i.getPort()).andReturn(0);
- EasyMock.expect(i.getState()).andReturn("Started");
- EasyMock.expect(i.getLocation()).andReturn(null);
- EasyMock.replay(i);
-
- JmxInstance ji = new JmxInstance(i);
- TabularData td = JmxInstance.tableFrom(Collections.singletonList(ji));
- Collection<?> keys = (Collection<?>) td.keySet().iterator().next();
- Assert.assertEquals("MyInstance", keys.iterator().next());
-
- CompositeData cd = td.get(keys.toArray());
- Assert.assertEquals(1712, cd.get("Pid"));
- Assert.assertEquals("MyInstance", cd.get("Name"));
- Assert.assertEquals(true, cd.get("Is Root"));
- Assert.assertEquals(0, cd.get("Port"));
- Assert.assertEquals("Started", cd.get("State"));
- Assert.assertNull(cd.get("Location"));
- }
-}
diff --git a/karaf/admin/management/src/test/java/org/apache/felix/karaf/admin/management/internal/AdminServiceMBeanImplTest.java b/karaf/admin/management/src/test/java/org/apache/felix/karaf/admin/management/internal/AdminServiceMBeanImplTest.java
deleted file mode 100644
index 11cb0c2..0000000
--- a/karaf/admin/management/src/test/java/org/apache/felix/karaf/admin/management/internal/AdminServiceMBeanImplTest.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.admin.management.internal;
-
-import java.util.Arrays;
-import java.util.Collections;
-
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.TabularData;
-
-import junit.framework.TestCase;
-import org.apache.felix.karaf.admin.AdminService;
-import org.apache.felix.karaf.admin.Instance;
-import org.apache.felix.karaf.admin.InstanceSettings;
-import org.easymock.EasyMock;
-import org.junit.Assert;
-
-public class AdminServiceMBeanImplTest extends TestCase {
- public void testCreateInstance() throws Exception {
- final InstanceSettings is = new InstanceSettings(123, "somewhere",
- Collections.<String>emptyList(), Arrays.asList("webconsole", "funfeat"));
-
- final Instance inst = EasyMock.createMock(Instance.class);
- EasyMock.expect(inst.getPid()).andReturn(42);
- EasyMock.replay(inst);
-
- AdminService as = EasyMock.createMock(AdminService.class);
- EasyMock.expect(as.createInstance("t1", is)).andReturn(inst);
- EasyMock.replay(as);
-
- AdminServiceMBeanImpl ab = new AdminServiceMBeanImpl();
- ab.setAdminService(as);
- Assert.assertSame(as, ab.getAdminService());
-
- assertEquals(42, ab.createInstance("t1", 123, "somewhere", " webconsole, funfeat", ""));
- }
-
- public void testCreateInstance2() throws Exception {
- final InstanceSettings is = new InstanceSettings(0, null,
- Collections.<String>emptyList(), Collections.<String>emptyList());
-
- AdminService as = EasyMock.createMock(AdminService.class);
- EasyMock.expect(as.createInstance("t1", is)).andReturn(null);
- EasyMock.replay(as);
-
- AdminServiceMBeanImpl ab = new AdminServiceMBeanImpl();
- ab.setAdminService(as);
- Assert.assertSame(as, ab.getAdminService());
-
- assertEquals(-1, ab.createInstance("t1", 0, "", "", ""));
- }
-
- public void testGetInstances() throws Exception {
- Instance i1 = EasyMock.createMock(Instance.class);
- EasyMock.expect(i1.getPid()).andReturn(1234);
- EasyMock.expect(i1.getPort()).andReturn(8818);
- EasyMock.expect(i1.getName()).andReturn("i1");
- EasyMock.expect(i1.isRoot()).andReturn(true);
- EasyMock.expect(i1.getLocation()).andReturn("somewhere");
- EasyMock.expect(i1.getState()).andReturn("Stopped");
- EasyMock.replay(i1);
- Instance i2 = EasyMock.createNiceMock(Instance.class);
- EasyMock.expect(i2.getName()).andReturn("i2");
- EasyMock.replay(i2);
-
- AdminService as = EasyMock.createMock(AdminService.class);
- EasyMock.expect(as.getInstances()).andReturn(new Instance [] {i1, i2});
- EasyMock.replay(as);
-
- AdminServiceMBeanImpl ab = new AdminServiceMBeanImpl();
- ab.setAdminService(as);
-
- TabularData td = ab.getInstances();
- Assert.assertEquals(2, td.size());
- CompositeData cd1 = td.get(new Object [] {"i1"});
- Assert.assertTrue(cd1.containsValue("i1"));
- Assert.assertTrue(cd1.containsValue(true));
- Assert.assertTrue(cd1.containsValue(1234));
- Assert.assertTrue(cd1.containsValue(8818));
- Assert.assertTrue(cd1.containsValue("somewhere"));
- Assert.assertTrue(cd1.containsValue("Stopped"));
-
- CompositeData cd2 = td.get(new Object [] {"i2"});
- Assert.assertTrue(cd2.containsValue("i2"));
- }
-
- public void testStartInstance() throws Exception {
- Instance inst = EasyMock.createMock(Instance.class);
- inst.start("-x -y -z");
- EasyMock.expectLastCall();
- EasyMock.replay(inst);
-
- AdminService as = EasyMock.createMock(AdminService.class);
- EasyMock.expect(as.getInstance("test instance")).andReturn(inst);
- EasyMock.replay(as);
-
- AdminServiceMBeanImpl ab = new AdminServiceMBeanImpl();
- ab.setAdminService(as);
- Assert.assertSame(as, ab.getAdminService());
-
- ab.startInstance("test instance", "-x -y -z");
- EasyMock.verify(as);
- EasyMock.verify(inst);
- }
-
- public void testStopInstance() throws Exception {
- Instance inst = EasyMock.createMock(Instance.class);
- inst.stop();
- EasyMock.expectLastCall();
- EasyMock.replay(inst);
-
- AdminService as = EasyMock.createMock(AdminService.class);
- EasyMock.expect(as.getInstance("test instance")).andReturn(inst);
- EasyMock.replay(as);
-
- AdminServiceMBeanImpl ab = new AdminServiceMBeanImpl();
- ab.setAdminService(as);
- Assert.assertSame(as, ab.getAdminService());
-
- ab.stopInstance("test instance");
- EasyMock.verify(as);
- EasyMock.verify(inst);
- }
-
- public void testDestroyInstance() throws Exception {
- Instance inst = EasyMock.createMock(Instance.class);
- inst.destroy();
- EasyMock.expectLastCall();
- EasyMock.replay(inst);
-
- AdminService as = EasyMock.createMock(AdminService.class);
- EasyMock.expect(as.getInstance("test instance")).andReturn(inst);
- EasyMock.replay(as);
-
- AdminServiceMBeanImpl ab = new AdminServiceMBeanImpl();
- ab.setAdminService(as);
- Assert.assertSame(as, ab.getAdminService());
-
- ab.destroyInstance("test instance");
- EasyMock.verify(as);
- EasyMock.verify(inst);
- }
-
- public void testChangePort() throws Exception {
- Instance inst = EasyMock.createMock(Instance.class);
- inst.changePort(7788);
- EasyMock.expectLastCall();
- EasyMock.replay(inst);
-
- AdminService as = EasyMock.createMock(AdminService.class);
- EasyMock.expect(as.getInstance("test instance")).andReturn(inst);
- EasyMock.replay(as);
-
- AdminServiceMBeanImpl ab = new AdminServiceMBeanImpl();
- ab.setAdminService(as);
- Assert.assertSame(as, ab.getAdminService());
-
- ab.changePort("test instance", 7788);
- EasyMock.verify(as);
- EasyMock.verify(inst);
- }
-}
diff --git a/karaf/admin/pom.xml b/karaf/admin/pom.xml
deleted file mode 100644
index 85bac79..0000000
--- a/karaf/admin/pom.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<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/maven-v4_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.felix.karaf</groupId>
- <artifactId>karaf</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.admin</groupId>
- <artifactId>admin</artifactId>
- <packaging>pom</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Admin</name>
-
- <modules>
- <module>core</module>
- <module>command</module>
- <module>management</module>
- </modules>
-
-</project>
diff --git a/karaf/assembly/NOTICE b/karaf/assembly/NOTICE
deleted file mode 100644
index b7a517d..0000000
--- a/karaf/assembly/NOTICE
+++ /dev/null
@@ -1,58 +0,0 @@
-Apache Felix Karaf :: Assembly
-Copyright 2010 The Apache Software Foundation
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-This product includes software developed at
-The Eclipse Foundation (http://www.eclipse.org/).
-Licensed under Eclipse Public License 1.0.
-
-This product includes software developed at
-OPS4J (http://www.ops4j.org/).
-Licensed under the Apache License 2.0.
-
-This products includes software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Licensed under the Apache License 2.0.
-
-This product includes software developed at
-FUSE Source (http://www.fusesource.org/).
-Licensed under the Apache License 2.0.
-
-This product includes software developed at
-JLine (http://jline.sourceforge.net).
-Licensed under the BSD License.
-
-This product includes software developed at
-SLF4J (http://www.slf4j.org/).
-Licensed under the MIT License.
-
-This product includes software from http://www.json.org.
-Copyright (c) 2002 JSON.org
-
-The PDF manual has been generated using http://www.princexml.com/
-and contains an attribution which should not be removed by
-licensee.
-
-II. Used Software
-
-This product uses software developed at
-SpringSource (http://www.springsource.org/).
-Licensed under the Apache License 2.0.
-
-This product uses software written by
-Antony Lesuisse.
-Licensed under Public Domain.
-
-
-III. License Summary
-- Apache License 2.0
-- Eclipse Public License 1.0
-- BSD License
-- MIT License
-
-
diff --git a/karaf/assembly/pom.xml b/karaf/assembly/pom.xml
deleted file mode 100644
index d43801b..0000000
--- a/karaf/assembly/pom.xml
+++ /dev/null
@@ -1,505 +0,0 @@
-<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/maven-v4_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.felix.karaf</groupId>
- <artifactId>karaf</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>apache-felix-karaf</artifactId>
- <packaging>pom</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Assembly</name>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>manual</artifactId>
- <type>pdf</type>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>manual</artifactId>
- <type>html</type>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>org.apache.felix.karaf.main</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>org.apache.felix.karaf.exception</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>org.apache.felix.karaf.client</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.deployer</groupId>
- <artifactId>org.apache.felix.karaf.deployer.spring</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.deployer</groupId>
- <artifactId>org.apache.felix.karaf.deployer.blueprint</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.deployer</groupId>
- <artifactId>org.apache.felix.karaf.deployer.features</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.deployer</groupId>
- <artifactId>org.apache.felix.karaf.deployer.war</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.features</groupId>
- <artifactId>org.apache.felix.karaf.features.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.features</groupId>
- <artifactId>org.apache.felix.karaf.features.command</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.features</groupId>
- <artifactId>org.apache.felix.karaf.features.management</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.admin</groupId>
- <artifactId>org.apache.felix.karaf.admin.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.admin</groupId>
- <artifactId>org.apache.felix.karaf.admin.command</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.admin</groupId>
- <artifactId>org.apache.felix.karaf.admin.management</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.obr</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.osgi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.log</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.config</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.packages</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.commands</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.ssh</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.dev</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.jaas</groupId>
- <artifactId>org.apache.felix.karaf.jaas.boot</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.jaas</groupId>
- <artifactId>org.apache.felix.karaf.jaas.config</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.jaas</groupId>
- <artifactId>org.apache.felix.karaf.jaas.modules</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>org.apache.felix.karaf.management</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-extender</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-io</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-annotation</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-aop</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.bundlerepository</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.fileinstall</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.mina</groupId>
- <artifactId>mina-core</artifactId>
- </dependency>
- <dependency>
- <groupId>jline</groupId>
- <artifactId>jline</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.configadmin</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.metatype</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.prefs</artifactId>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.logging</groupId>
- <artifactId>pax-logging-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.logging</groupId>
- <artifactId>pax-logging-service</artifactId>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.url</groupId>
- <artifactId>pax-url-mvn</artifactId>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.url</groupId>
- <artifactId>pax-url-wrap</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.sshd</groupId>
- <artifactId>sshd-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.eclipse</groupId>
- <artifactId>osgi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.framework</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.aries.blueprint</groupId>
- <artifactId>org.apache.aries.blueprint</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.aries.jmx</groupId>
- <artifactId>org.apache.aries.jmx</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.aries.jmx</groupId>
- <artifactId>org.apache.aries.jmx.blueprint</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-servlet_2.5_spec</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.jetty-bundle</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-api</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-spi</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-runtime</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-jetty</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-jsp</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-extender-war</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-extender-whiteboard</artifactId>
- <optional>true</optional>
- </dependency>
- </dependencies>
- <build>
- <resources>
- <resource>
- <directory>${project.basedir}/src/main/filtered-resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>filter</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>resources</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>org.apache.felix.karaf.main</artifactId>
- <outputDirectory>target/dependencies/lib</outputDirectory>
- <destFileName>karaf.jar</destFileName>
- </artifactItem>
- <artifactItem>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>org.apache.felix.karaf.client</artifactId>
- <outputDirectory>target/dependencies/lib</outputDirectory>
- <destFileName>karaf-client.jar</destFileName>
- </artifactItem>
- <artifactItem>
- <groupId>org.apache.felix.karaf.jaas</groupId>
- <artifactId>org.apache.felix.karaf.jaas.boot</artifactId>
- <outputDirectory>target/dependencies/lib</outputDirectory>
- <destFileName>karaf-jaas-boot.jar</destFileName>
- </artifactItem>
- <artifactItem>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>manual</artifactId>
- <type>pdf</type>
- <outputDirectory>target/dependencies</outputDirectory>
- <destFileName>karaf-manual-${project.version}.pdf</destFileName>
- </artifactItem>
- <artifactItem>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>manual</artifactId>
- <type>html</type>
- <outputDirectory>target/dependencies</outputDirectory>
- <destFileName>karaf-manual-${project.version}.html</destFileName>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-artifacts</id>
- <phase>package</phase>
- <goals>
- <goal>attach-artifact</goal>
- </goals>
- <configuration>
- <artifacts>
- <artifact>
- <file>target/classes/features.xml</file>
- <type>xml</type>
- <classifier>features</classifier>
- </artifact>
- </artifacts>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>none</phase>
- </execution>
- <execution>
- <id>unix-bin</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptors>
- <descriptor>src/main/descriptors/unix-bin.xml</descriptor>
- </descriptors>
- <finalName>${project.artifactId}-${project.version}</finalName>
- <tarLongFileMode>gnu</tarLongFileMode>
- </configuration>
- </execution>
- <execution>
- <id>windows-bin</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptors>
- <descriptor>src/main/descriptors/windows-bin.xml</descriptor>
- </descriptors>
- <finalName>${project.artifactId}-${project.version}</finalName>
- <appendAssemblyId>true</appendAssemblyId>
- <assemblyId />
- </configuration>
- </execution>
- <execution>
- <id>unix-src</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptors>
- <descriptor>src/main/descriptors/unix-src.xml</descriptor>
- </descriptors>
- <tarLongFileMode>gnu</tarLongFileMode>
- </configuration>
- </execution>
- <execution>
- <id>windows-src</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptors>
- <descriptor>src/main/descriptors/windows-src.xml</descriptor>
- </descriptors>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>assembly-src</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>unix-src</id>
- <phase>package</phase>
- <goals>
- <goal>attached</goal>
- </goals>
- <configuration>
- <descriptors>
- <descriptor>src/main/descriptors/unix-src.xml</descriptor>
- </descriptors>
- </configuration>
- </execution>
- <execution>
- <id>windows-src</id>
- <phase>package</phase>
- <goals>
- <goal>attached</goal>
- </goals>
- <configuration>
- <descriptors>
- <descriptor>src/main/descriptors/windows-src.xml</descriptor>
- </descriptors>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
diff --git a/karaf/assembly/src/main/descriptors/unix-bin.xml b/karaf/assembly/src/main/descriptors/unix-bin.xml
deleted file mode 100644
index fb3fead..0000000
--- a/karaf/assembly/src/main/descriptors/unix-bin.xml
+++ /dev/null
@@ -1,298 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<assembly>
- <id></id> <!-- intentionally left blank -> http://jira.codehaus.org/browse/MASSEMBLY-301 -->
- <formats>
- <format>tar.gz</format>
- </formats>
- <fileSets>
-
- <!-- Copy license and other files from root -->
- <fileSet>
- <directory>..</directory>
- <outputDirectory>/</outputDirectory>
- <includes>
- <include>README</include>
- <include>RELEASE*</include>
- </includes>
- <lineEnding>unix</lineEnding>
- </fileSet>
-
- <!-- Copy over everything that needs to get unix line endings -->
- <fileSet>
- <directory>src/main/distribution/text</directory>
- <outputDirectory>/</outputDirectory>
- <lineEnding>unix</lineEnding>
- </fileSet>
- <fileSet>
- <directory>src/main/distribution/unix-text</directory>
- <outputDirectory>/</outputDirectory>
- <lineEnding>unix</lineEnding>
- </fileSet>
- <fileSet>
- <directory>target/classes/bin</directory>
- <outputDirectory>/bin/</outputDirectory>
- <lineEnding>unix</lineEnding>
- <fileMode>0755</fileMode>
- <includes>
- <include>admin</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>target/classes/etc</directory>
- <outputDirectory>/etc/</outputDirectory>
- <lineEnding>unix</lineEnding>
- </fileSet>
-
- <!-- Copy over the examples -->
- <fileSet>
- <directory>target/classes/demos</directory>
- <outputDirectory>/demos/</outputDirectory>
- <lineEnding>unix</lineEnding>
- </fileSet>
- <fileSet>
- <directory>../demos</directory>
- <outputDirectory>/demos/</outputDirectory>
- <lineEnding>unix</lineEnding>
- <excludes>
- <exclude>**/target/**</exclude>
- </excludes>
- </fileSet>
-
- <!-- Copy over files that should not get the line endings converted -->
- <fileSet>
- <directory>src/main/distribution/binary</directory>
- <outputDirectory>/</outputDirectory>
- </fileSet>
-
- <!-- Copy over the files that should not get the line endings converted but need to be chmod to 755 -->
- <fileSet>
- <directory>src/main/distribution/unix-binary</directory>
- <outputDirectory>/</outputDirectory>
- <fileMode>0755</fileMode>
- </fileSet>
-
- <!-- Copy over the files that need unix line endings and also chmod to 755 -->
- <fileSet>
- <directory>src/main/distribution/unix-shell</directory>
- <outputDirectory>/</outputDirectory>
- <lineEnding>unix</lineEnding>
- <fileMode>0755</fileMode>
- </fileSet>
-
- <!-- Copy over jar files -->
- <fileSet>
- <directory>target/dependencies</directory>
- <outputDirectory>/</outputDirectory>
- </fileSet>
-
- </fileSets>
-
- <files>
- <file>
- <source>${basedir}/../LICENSE</source>
- <outputDirectory>/</outputDirectory>
- <destName>LICENSE</destName>
- <fileMode>0644</fileMode>
- <lineEnding>unix</lineEnding>
- </file>
- <file>
- <source>${basedir}/NOTICE</source>
- <outputDirectory>/</outputDirectory>
- <destName>NOTICE</destName>
- <fileMode>0644</fileMode>
- <lineEnding>unix</lineEnding>
- </file>
- <file>
- <source>${basedir}/target/classes/features.xml</source>
- <outputDirectory>/system/org/apache/felix/karaf/apache-felix-karaf/${project.version}</outputDirectory>
- <destName>apache-felix-karaf-${project.version}-features.xml</destName>
- <fileMode>0644</fileMode>
- <lineEnding>unix</lineEnding>
- </file>
- </files>
-
- <dependencySets>
- <dependencySet>
- <outputDirectory>/lib/endorsed</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <includes>
- <include>org.apache.felix.karaf:org.apache.felix.karaf.exception</include>
- </includes>
- </dependencySet>
-
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/felix/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.felix:org.apache.felix.configadmin</include>
- <include>org.apache.felix:org.apache.felix.prefs</include>
- <include>org.apache.felix:org.apache.felix.framework</include>
- <include>org.apache.felix:org.apache.felix.fileinstall</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/felix/gogo/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.felix.gogo:org.apache.felix.gogo.runtime</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/ops4j/pax/logging/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.ops4j.pax.logging:pax-logging-api</include>
- <include>org.ops4j.pax.logging:pax-logging-service</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/ops4j/pax/url/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.ops4j.pax.url:pax-url-mvn</include>
- <include>org.ops4j.pax.url:pax-url-wrap</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/felix/karaf/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.felix.karaf:org.apache.felix.karaf.management</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/felix/karaf/features/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.felix.karaf.features:org.apache.felix.karaf.features.core</include>
- <include>org.apache.felix.karaf.features:org.apache.felix.karaf.features.command</include>
- <include>org.apache.felix.karaf.features:org.apache.felix.karaf.features.management</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/felix/karaf/admin/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.felix.karaf.admin:org.apache.felix.karaf.admin.core</include>
- <include>org.apache.felix.karaf.admin:org.apache.felix.karaf.admin.command</include>
- <include>org.apache.felix.karaf.admin:org.apache.felix.karaf.admin.management</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/felix/karaf/deployer/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.felix.karaf.deployer:org.apache.felix.karaf.deployer.spring</include>
- <include>org.apache.felix.karaf.deployer:org.apache.felix.karaf.deployer.blueprint</include>
- <include>org.apache.felix.karaf.deployer:org.apache.felix.karaf.deployer.features</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/felix/karaf/shell/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.felix.karaf.shell:org.apache.felix.karaf.shell.console</include>
- <include>org.apache.felix.karaf.shell:org.apache.felix.karaf.shell.dev</include>
- <include>org.apache.felix.karaf.shell:org.apache.felix.karaf.shell.osgi</include>
- <include>org.apache.felix.karaf.shell:org.apache.felix.karaf.shell.log</include>
- <include>org.apache.felix.karaf.shell:org.apache.felix.karaf.shell.config</include>
- <include>org.apache.felix.karaf.shell:org.apache.felix.karaf.shell.packages</include>
- <include>org.apache.felix.karaf.shell:org.apache.felix.karaf.shell.ssh</include>
- <include>org.apache.felix.karaf.shell:org.apache.felix.karaf.shell.commands</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/felix/karaf/jaas/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.felix.karaf.jaas:org.apache.felix.karaf.jaas.config</include>
- <include>org.apache.felix.karaf.jaas:org.apache.felix.karaf.jaas.modules</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/sshd/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.sshd:sshd-core</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/mina/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.mina:mina-core</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/eclipse/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.eclipse:osgi</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/aries/blueprint/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.aries.blueprint:org.apache.aries.blueprint</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/aries/jmx/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.aries.jmx:org.apache.aries.jmx</include>
- <include>org.apache.aries.jmx:org.apache.aries.jmx.blueprint</include>
- </includes>
- </dependencySet>
-
- </dependencySets>
-
-</assembly>
diff --git a/karaf/assembly/src/main/descriptors/unix-src.xml b/karaf/assembly/src/main/descriptors/unix-src.xml
deleted file mode 100644
index 121e36a..0000000
--- a/karaf/assembly/src/main/descriptors/unix-src.xml
+++ /dev/null
@@ -1,109 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<assembly>
- <id>src</id>
- <formats>
- <format>tar.gz</format>
- </formats>
- <fileSets>
- <!-- Copy license and other files from root -->
- <fileSet>
- <directory>${basedir}/..</directory>
- <outputDirectory>/</outputDirectory>
- <includes>
- <include>BUILDING</include>
- <include>README</include>
- <include>NOTICE</include>
- <include>LICENSE</include>
- <include>RELEASE*</include>
- </includes>
- <lineEnding>unix</lineEnding>
- </fileSet>
-
- <!-- Binary Files -->
- <fileSet>
- <directory>${basedir}/..</directory>
- <outputDirectory>src</outputDirectory>
- <includes>
- <include>**/*.jpeg</include>
- <include>**/*.jpg</include>
- <include>**/*.gif</include>
- <include>**/*.png</include>
- <include>**/*.exe</include>
- <include>**/*.dll</include>
- <include>**/*.jar</include>
- <include>**/*.so</include>
- <include>**/*.ks</include>
- <include>**/*.ts</include>
- <include>**/*.keystore</include>
- <include>**/*.bin</include>
- <include>**/*.jnilib</include>
- <include>**/*.cert</include>
- <include>apache-felix-karaf/src/main/release/bin/*/wrapper</include>
- </includes>
- <excludes>
- <exclude>**/eclipse-classes/**</exclude>
- <exclude>**/target/**</exclude>
- </excludes>
- </fileSet>
-
- <!-- Text Files -->
- <fileSet>
- <directory>${basedir}/..</directory>
- <outputDirectory>src</outputDirectory>
- <includes>
- <include>**/*</include>
- </includes>
- <excludes>
- <exclude>**/*.jpeg</exclude>
- <exclude>**/*.jpg</exclude>
- <exclude>**/*.gif</exclude>
- <exclude>**/*.png</exclude>
- <exclude>**/*.exe</exclude>
- <exclude>**/*.dll</exclude>
- <exclude>**/*.jar</exclude>
- <exclude>**/*.so</exclude>
- <exclude>**/*.ks</exclude>
- <exclude>**/*.ts</exclude>
- <exclude>**/*.keystore</exclude>
- <exclude>**/*.bin</exclude>
- <exclude>**/*.jnilib</exclude>
- <exclude>**/*.cert</exclude>
- <exclude>apache-felix-karaf/src/main/release/bin/*/wrapper</exclude>
- <exclude>**/target/**</exclude>
- <exclude>**/build/**</exclude>
- <exclude>activemq-data/**</exclude>
- <exclude>*/activemq-data/**</exclude>
- <exclude>**/eclipse-classes/**</exclude>
- <exclude>**/.*</exclude>
- <exclude>**/.*/**</exclude>
-
- <exclude>**/surefire*</exclude>
- <exclude>**/svn-commit*</exclude>
-
- <exclude>**/*.iml</exclude>
- <exclude>**/*.ipr</exclude>
- <exclude>**/*.iws</exclude>
-
- <exclude>**/cobertura.ser</exclude>
-
- </excludes>
- <lineEnding>unix</lineEnding>
- </fileSet>
- </fileSets>
-</assembly>
diff --git a/karaf/assembly/src/main/descriptors/windows-bin.xml b/karaf/assembly/src/main/descriptors/windows-bin.xml
deleted file mode 100644
index 3b03a21..0000000
--- a/karaf/assembly/src/main/descriptors/windows-bin.xml
+++ /dev/null
@@ -1,290 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<assembly>
- <id></id> <!-- intentionally left blank -> http://jira.codehaus.org/browse/MASSEMBLY-301 -->
- <formats>
- <format>zip</format>
- </formats>
- <fileSets>
-
-
- <!-- Copy license and other files from root -->
- <fileSet>
- <directory>..</directory>
- <outputDirectory>/</outputDirectory>
- <includes>
- <include>README</include>
- <include>RELEASE*</include>
- </includes>
- <lineEnding>dos</lineEnding>
- </fileSet>
-
- <!-- Copy over everything that needs to get dos line endings -->
- <fileSet>
- <directory>src/main/distribution/text</directory>
- <outputDirectory>/</outputDirectory>
- <lineEnding>dos</lineEnding>
- </fileSet>
- <fileSet>
- <directory>src/main/distribution/windows-text</directory>
- <outputDirectory>/</outputDirectory>
- <lineEnding>dos</lineEnding>
- </fileSet>
- <fileSet>
- <directory>target/classes/bin</directory>
- <outputDirectory>/bin/</outputDirectory>
- <lineEnding>dos</lineEnding>
- <includes>
- <include>admin.bat</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>target/classes/etc</directory>
- <outputDirectory>/etc/</outputDirectory>
- <lineEnding>dos</lineEnding>
- </fileSet>
-
- <!-- Copy over the examples -->
- <fileSet>
- <directory>target/classes/demos</directory>
- <outputDirectory>/demos/</outputDirectory>
- <lineEnding>dos</lineEnding>
- </fileSet>
-
- <fileSet>
- <directory>../demos</directory>
- <outputDirectory>/demos/</outputDirectory>
- <lineEnding>dos</lineEnding>
- <excludes>
- <exclude>**/target/**</exclude>
- </excludes>
- </fileSet>
-
- <!-- Copy over files that should not get the line endings converted -->
- <fileSet>
- <directory>src/main/distribution/binary</directory>
- <outputDirectory>/</outputDirectory>
- </fileSet>
-
- <!-- Copy over the files that should not get the line endings converted but need to be chmod to 755 -->
- <fileSet>
- <directory>src/main/distribution/windows-binary</directory>
- <outputDirectory>/</outputDirectory>
- </fileSet>
-
- <!-- Copy over jar files -->
- <fileSet>
- <directory>target/dependencies</directory>
- <outputDirectory>/</outputDirectory>
- </fileSet>
-
- </fileSets>
-
- <files>
- <file>
- <source>${basedir}/../LICENSE</source>
- <outputDirectory>/</outputDirectory>
- <destName>LICENSE</destName>
- <fileMode>0644</fileMode>
- <lineEnding>dos</lineEnding>
- </file>
- <file>
- <source>${basedir}/NOTICE</source>
- <outputDirectory>/</outputDirectory>
- <destName>NOTICE</destName>
- <fileMode>0644</fileMode>
- <lineEnding>dos</lineEnding>
- </file>
- <file>
- <source>${basedir}/target/classes/features.xml</source>
- <outputDirectory>/system/org/apache/felix/karaf/apache-felix-karaf/${project.version}</outputDirectory>
- <destName>apache-felix-karaf-${project.version}-features.xml</destName>
- <fileMode>0644</fileMode>
- <lineEnding>dos</lineEnding>
- </file>
- </files>
-
- <dependencySets>
- <dependencySet>
- <outputDirectory>/lib/endorsed</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <includes>
- <include>org.apache.felix.karaf:org.apache.felix.karaf.exception</include>
- </includes>
- </dependencySet>
-
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/felix/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.felix:org.apache.felix.configadmin</include>
- <include>org.apache.felix:org.apache.felix.prefs</include>
- <include>org.apache.felix:org.apache.felix.framework</include>
- <include>org.apache.felix:org.apache.felix.fileinstall</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/felix/gogo/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.felix.gogo:org.apache.felix.gogo.runtime</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/ops4j/pax/logging/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.ops4j.pax.logging:pax-logging-api</include>
- <include>org.ops4j.pax.logging:pax-logging-service</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/ops4j/pax/url/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.ops4j.pax.url:pax-url-mvn</include>
- <include>org.ops4j.pax.url:pax-url-wrap</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/felix/karaf/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.felix.karaf:org.apache.felix.karaf.management</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/felix/karaf/features/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.felix.karaf.features:org.apache.felix.karaf.features.core</include>
- <include>org.apache.felix.karaf.features:org.apache.felix.karaf.features.command</include>
- <include>org.apache.felix.karaf.features:org.apache.felix.karaf.features.management</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/felix/karaf/admin/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.felix.karaf.admin:org.apache.felix.karaf.admin.core</include>
- <include>org.apache.felix.karaf.admin:org.apache.felix.karaf.admin.command</include>
- <include>org.apache.felix.karaf.admin:org.apache.felix.karaf.admin.management</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/felix/karaf/deployer/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.felix.karaf.deployer:org.apache.felix.karaf.deployer.spring</include>
- <include>org.apache.felix.karaf.deployer:org.apache.felix.karaf.deployer.blueprint</include>
- <include>org.apache.felix.karaf.deployer:org.apache.felix.karaf.deployer.features</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/felix/karaf/shell/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.felix.karaf.shell:org.apache.felix.karaf.shell.console</include>
- <include>org.apache.felix.karaf.shell:org.apache.felix.karaf.shell.dev</include>
- <include>org.apache.felix.karaf.shell:org.apache.felix.karaf.shell.osgi</include>
- <include>org.apache.felix.karaf.shell:org.apache.felix.karaf.shell.log</include>
- <include>org.apache.felix.karaf.shell:org.apache.felix.karaf.shell.config</include>
- <include>org.apache.felix.karaf.shell:org.apache.felix.karaf.shell.packages</include>
- <include>org.apache.felix.karaf.shell:org.apache.felix.karaf.shell.ssh</include>
- <include>org.apache.felix.karaf.shell:org.apache.felix.karaf.shell.commands</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/felix/karaf/jaas/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.felix.karaf.jaas:org.apache.felix.karaf.jaas.config</include>
- <include>org.apache.felix.karaf.jaas:org.apache.felix.karaf.jaas.modules</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/sshd/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.sshd:sshd-core</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/mina/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.mina:mina-core</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/eclipse/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.eclipse:osgi</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/aries/blueprint/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.aries.blueprint:org.apache.aries.blueprint</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/aries/jmx/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.aries.jmx:org.apache.aries.jmx</include>
- <include>org.apache.aries.jmx:org.apache.aries.jmx.blueprint</include>
- </includes>
- </dependencySet>
-
- </dependencySets>
-
-</assembly>
diff --git a/karaf/assembly/src/main/descriptors/windows-src.xml b/karaf/assembly/src/main/descriptors/windows-src.xml
deleted file mode 100644
index d038b9b..0000000
--- a/karaf/assembly/src/main/descriptors/windows-src.xml
+++ /dev/null
@@ -1,110 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<assembly>
- <id>src</id>
- <formats>
- <format>zip</format>
- </formats>
- <fileSets>
- <!-- Copy license and other files from root -->
- <fileSet>
- <directory>${basedir}/..</directory>
- <outputDirectory>/</outputDirectory>
- <includes>
- <include>BUILDING</include>
- <include>README</include>
- <include>NOTICE</include>
- <include>LICENSE</include>
- <include>RELEASE*</include>
- </includes>
- <lineEnding>dos</lineEnding>
- </fileSet>
-
- <!-- Binary Files -->
- <fileSet>
- <directory>${basedir}/..</directory>
- <outputDirectory>src</outputDirectory>
- <includes>
- <include>**/*.jpeg</include>
- <include>**/*.jpg</include>
- <include>**/*.gif</include>
- <include>**/*.png</include>
- <include>**/*.exe</include>
- <include>**/*.dll</include>
- <include>**/*.jar</include>
- <include>**/*.so</include>
- <include>**/*.ks</include>
- <include>**/*.ts</include>
- <include>**/*.keystore</include>
- <include>**/*.bin</include>
- <include>**/*.jnilib</include>
- <include>**/*.cert</include>
- <include>apache-felix-karaf/src/main/release/bin/*/wrapper</include>
- </includes>
- <excludes>
- <exclude>**/eclipse-classes/**</exclude>
- <exclude>**/target/**</exclude>
- </excludes>
- </fileSet>
-
- <!-- Text Files -->
- <fileSet>
- <directory>${basedir}/..</directory>
- <outputDirectory>src</outputDirectory>
- <includes>
- <include>**/*</include>
- </includes>
- <excludes>
- <exclude>**/*.jpeg</exclude>
- <exclude>**/*.jpg</exclude>
- <exclude>**/*.gif</exclude>
- <exclude>**/*.png</exclude>
- <exclude>**/*.exe</exclude>
- <exclude>**/*.dll</exclude>
- <exclude>**/*.jar</exclude>
- <exclude>**/*.so</exclude>
- <exclude>**/*.ks</exclude>
- <exclude>**/*.ts</exclude>
- <exclude>**/*.keystore</exclude>
- <exclude>**/*.bin</exclude>
- <exclude>**/*.jnilib</exclude>
- <exclude>**/*.cert</exclude>
- <exclude>apache-felix-karaf/src/main/release/bin/*/wrapper</exclude>
-
- <exclude>**/target/**</exclude>
- <exclude>**/build/**</exclude>
- <exclude>activemq-data/**</exclude>
- <exclude>*/activemq-data/**</exclude>
- <exclude>**/eclipse-classes/**</exclude>
- <exclude>**/.*</exclude>
- <exclude>**/.*/**</exclude>
-
- <exclude>**/surefire*</exclude>
- <exclude>**/svn-commit*</exclude>
-
- <exclude>**/*.iml</exclude>
- <exclude>**/*.ipr</exclude>
- <exclude>**/*.iws</exclude>
-
- <exclude>**/cobertura.ser</exclude>
-
- </excludes>
- <lineEnding>dos</lineEnding>
- </fileSet>
- </fileSets>
-</assembly>
diff --git a/karaf/assembly/src/main/distribution/text/deploy/README b/karaf/assembly/src/main/distribution/text/deploy/README
deleted file mode 100644
index 796bd5b..0000000
--- a/karaf/assembly/src/main/distribution/text/deploy/README
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-This folder can be used to deploy artifacts into the OSGi framework.
\ No newline at end of file
diff --git a/karaf/assembly/src/main/distribution/text/etc/java.util.logging.properties b/karaf/assembly/src/main/distribution/text/etc/java.util.logging.properties
deleted file mode 100644
index b7b50c5..0000000
--- a/karaf/assembly/src/main/distribution/text/etc/java.util.logging.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-# Empty java.util.logging.properties to prevent the log to stderr, so that
-# all logs will be delegated to pax logging JUL handler only
-
-
diff --git a/karaf/assembly/src/main/distribution/text/etc/org.apache.felix.fileinstall-deploy.cfg b/karaf/assembly/src/main/distribution/text/etc/org.apache.felix.fileinstall-deploy.cfg
deleted file mode 100644
index 62330b9..0000000
--- a/karaf/assembly/src/main/distribution/text/etc/org.apache.felix.fileinstall-deploy.cfg
+++ /dev/null
@@ -1,22 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-felix.fileinstall.dir = ${karaf.base}/deploy
-felix.fileinstall.tmpdir = ${karaf.base}/data/generated-bundles
-felix.fileinstall.poll = 1000
diff --git a/karaf/assembly/src/main/distribution/text/etc/org.apache.felix.karaf.log.cfg b/karaf/assembly/src/main/distribution/text/etc/org.apache.felix.karaf.log.cfg
deleted file mode 100644
index 39437d0..0000000
--- a/karaf/assembly/src/main/distribution/text/etc/org.apache.felix.karaf.log.cfg
+++ /dev/null
@@ -1,22 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-#
-size = 500
-pattern = %d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
diff --git a/karaf/assembly/src/main/distribution/text/etc/org.apache.felix.karaf.management.cfg b/karaf/assembly/src/main/distribution/text/etc/org.apache.felix.karaf.management.cfg
deleted file mode 100644
index a44e524..0000000
--- a/karaf/assembly/src/main/distribution/text/etc/org.apache.felix.karaf.management.cfg
+++ /dev/null
@@ -1,26 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-#
-rmiRegistryPort = 1099
-jmxRealm = karaf
-serviceUrl = service:jmx:rmi:///jndi/rmi://localhost:${rmiRegistryPort}/karaf-${karaf.name}
-daemon = true
-threaded = true
-objectName = connector:name=rmi
diff --git a/karaf/assembly/src/main/distribution/text/etc/org.apache.felix.karaf.shell.cfg b/karaf/assembly/src/main/distribution/text/etc/org.apache.felix.karaf.shell.cfg
deleted file mode 100644
index 555d451..0000000
--- a/karaf/assembly/src/main/distribution/text/etc/org.apache.felix.karaf.shell.cfg
+++ /dev/null
@@ -1,24 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-#
-sshPort=8101
-sshHost=0.0.0.0
-sshRealm=karaf
-hostKey=${karaf.base}/etc/host.key
diff --git a/karaf/assembly/src/main/distribution/text/etc/org.ops4j.pax.logging.cfg b/karaf/assembly/src/main/distribution/text/etc/org.ops4j.pax.logging.cfg
deleted file mode 100644
index 7c1f73d..0000000
--- a/karaf/assembly/src/main/distribution/text/etc/org.ops4j.pax.logging.cfg
+++ /dev/null
@@ -1,45 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-# Root logger
-log4j.rootLogger=INFO, out, osgi:VmLogAppender
-log4j.throwableRenderer=org.apache.log4j.OsgiThrowableRenderer
-
-# CONSOLE appender not used by default
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
-
-# File appender
-log4j.appender.out=org.apache.log4j.FileAppender
-log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
-log4j.appender.out.file=${karaf.base}/data/log/karaf.log
-log4j.appender.out.append=true
-
-# Sift appender
-log4j.appender.sift=org.apache.log4j.sift.MDCSiftingAppender
-log4j.appender.sift.key=bundle.name
-log4j.appender.sift.default=karaf
-log4j.appender.sift.appender=org.apache.log4j.FileAppender
-log4j.appender.sift.appender.layout=org.apache.log4j.PatternLayout
-log4j.appender.sift.appender.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
-log4j.appender.sift.appender.file=${karaf.base}/data/log/$\\{bundle.name\\}.log
-log4j.appender.sift.appender.append=true
-
diff --git a/karaf/assembly/src/main/distribution/text/etc/org.ops4j.pax.url.mvn.cfg b/karaf/assembly/src/main/distribution/text/etc/org.ops4j.pax.url.mvn.cfg
deleted file mode 100644
index 8e0e435..0000000
--- a/karaf/assembly/src/main/distribution/text/etc/org.ops4j.pax.url.mvn.cfg
+++ /dev/null
@@ -1,79 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-#
-# If set to true, the following property will not allow any certificate to be used
-# when accessing maven repositories through SSL
-#
-#org.ops4j.pax.url.mvn.certificateCheck=
-
-#
-# Path to the local maven settings file.
-# The repositories defined in this file will be automatically added to the list
-# of default repositories if the 'org.ops4j.pax.url.mvn.repositories' property
-# below is not set.
-# The following locations are checked for the existence of the settings.xml file
-# * 1. looks for the specified url
-# * 2. if not found looks for ${user.home}/.m2/settings.xml
-# * 3. if not found looks for ${maven.home}/conf/settings.xml
-# * 4. if not found looks for ${M2_HOME}/conf/settings.xml
-#
-#org.ops4j.pax.url.mvn.settings=
-
-#
-# Path to the local maven repository which is used to avoid downloading
-# artifacts when they already exist locally.
-# The value of this property will be extracted from the settings.xml file
-# above, or defaulted to:
-# System.getProperty( "user.home" ) + "/.m2/repository"
-#
-#org.ops4j.pax.url.mvn.localRepository=
-
-#
-# Comma separated list of repositories scanned when resolving an artifact.
-# Those repositories will be checked before iterating through the
-# below list of repositories and even before the local repository
-# A repository url can be appended with zero or more of the following flags:
-# @snapshots : the repository contains snaphots
-# @noreleases : the repository does not contain any released artifacts
-#
-# The following property value will add the system folder as a repo.
-#
-org.ops4j.pax.url.mvn.defaultRepositories=file:${karaf.home}/${karaf.default.repository}@snapshots
-
-#
-# Comma separated list of repositories scanned when resolving an artifact.
-# The default list includes the following repositories:
-# http://repo1.maven.org/maven2
-# http://repository.ops4j.org/maven2
-# To add repositories to the default ones, prepend '+' to the list of repositories
-# to add.
-# A repository url can be appended with zero or more of the following flags:
-# @snapshots : the repository contains snaphots
-# @noreleases : the repository does not contain any released artifacts
-#
-# The following property value will add the system folder as a repo.
-#
-org.ops4j.pax.url.mvn.repositories= \
- http://repo1.maven.org/maven2, \
- http://repository.apache.org/content/groups/snapshots-group@snapshots@noreleases, \
- http://repository.ops4j.org/maven2, \
- http://svn.apache.org/repos/asf/servicemix/m2-repo, \
- http://repository.springsource.com/maven/bundles/release, \
- http://repository.springsource.com/maven/bundles/external
diff --git a/karaf/assembly/src/main/distribution/text/etc/shell.init.script b/karaf/assembly/src/main/distribution/text/etc/shell.init.script
deleted file mode 100644
index b58d16d..0000000
--- a/karaf/assembly/src/main/distribution/text/etc/shell.init.script
+++ /dev/null
@@ -1,24 +0,0 @@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// This script is run each time a shell is created.
-// You can define here closures or variables that will be available
-// in each session.
-//
-ld = { log:display $args } ;
-lde = { log:display-exception $args } ;
diff --git a/karaf/assembly/src/main/distribution/text/etc/system.properties b/karaf/assembly/src/main/distribution/text/etc/system.properties
deleted file mode 100644
index 8c624a5..0000000
--- a/karaf/assembly/src/main/distribution/text/etc/system.properties
+++ /dev/null
@@ -1,61 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-#
-# The properties defined in this file will be made available through system
-# properties at the very beginning of the Karaf's boot process.
-#
-
-
-# Log level when the pax-logging service is not available
-# This level will only be used while the pax-logging service bundle
-# is not fully available.
-# To change log levels, please refer to the org.ops4j.pax.logging.cfg file
-# instead.
-org.ops4j.pax.logging.DefaultServiceLog.level=ERROR
-
-#
-# Name of this karaf instance.
-#
-karaf.name=root
-
-#
-# Default repository where bundles will be loaded from before using
-# other maven repositories. For the full maven configuration, see
-# the org.ops4j.pax.url.mvn.cfg file.
-#
-karaf.default.repository=system
-
-#
-# Location of a shell script that will be run when starting a shell
-# session. This script can be used to create aliases and define
-# additional commands.
-#
-karaf.shell.init.script=${karaf.home}/etc/shell.init.script
-
-#
-# Set this empty property to avoid errors when validating xml documents.
-#
-xml.catalog.files=
-
-#
-# Suppress the bell in the console when hitting backspace to many times
-# for example
-#
-jline.nobell=true
diff --git a/karaf/assembly/src/main/distribution/text/etc/users.properties b/karaf/assembly/src/main/distribution/text/etc/users.properties
deleted file mode 100644
index b91ac84..0000000
--- a/karaf/assembly/src/main/distribution/text/etc/users.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-#
-karaf=karaf,admin
diff --git a/karaf/assembly/src/main/distribution/text/lib/README b/karaf/assembly/src/main/distribution/text/lib/README
deleted file mode 100644
index ab4868d..0000000
--- a/karaf/assembly/src/main/distribution/text/lib/README
+++ /dev/null
@@ -1,27 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-This directory is the standard java classpath directory.
-Any jar in this folder will be part of the main classloader used to load Karaf.
-However, in OSGi, classes defined in this jar won't be available to other bundles
-unless one of the org.osgi.framework.system.packages.extra or
-org.osgi.framework.bootdelegation property in the etc/config.properties file
-is modified to export or delegate the packages.
-Please refer to the OSGi Core Specification for more informations on those
-properties and the OSGi classloading mechanism.
\ No newline at end of file
diff --git a/karaf/assembly/src/main/distribution/text/lib/endorsed/README b/karaf/assembly/src/main/distribution/text/lib/endorsed/README
deleted file mode 100644
index 81acbae1..0000000
--- a/karaf/assembly/src/main/distribution/text/lib/endorsed/README
+++ /dev/null
@@ -1,23 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-This directory is the java endorsed directory.
-Any jar in this folder will be used to override classes defined by the JVM.
-For more informations, see:
- http://java.sun.com/j2se/1.5.0/docs/guide/standards/
\ No newline at end of file
diff --git a/karaf/assembly/src/main/distribution/text/lib/ext/README b/karaf/assembly/src/main/distribution/text/lib/ext/README
deleted file mode 100644
index 26e2f3e..0000000
--- a/karaf/assembly/src/main/distribution/text/lib/ext/README
+++ /dev/null
@@ -1,23 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-This directory is the java extension directory.
-Any jar in this folder will be used as a JVM extension.
-For more informations, see
- http://java.sun.com/j2se/1.5.0/docs/guide/extensions/spec.html
\ No newline at end of file
diff --git a/karaf/assembly/src/main/distribution/unix-shell/bin/karaf b/karaf/assembly/src/main/distribution/unix-shell/bin/karaf
deleted file mode 100755
index f990e2e..0000000
--- a/karaf/assembly/src/main/distribution/unix-shell/bin/karaf
+++ /dev/null
@@ -1,326 +0,0 @@
-#!/bin/sh
-#
-# 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.
-#
-# $Id: karaf 979 2005-11-30 22:50:55Z bsnyder $
-#
-
-DIRNAME=`dirname $0`
-PROGNAME=`basename $0`
-
-#
-# Check/Set up some easily accessible MIN/MAX params for JVM mem usage
-#
-
-if [ "x$JAVA_MIN_MEM" = "x" ]; then
- JAVA_MIN_MEM=128M
- export JAVA_MIN_MEM
-fi
-
-if [ "x$JAVA_MAX_MEM" = "x" ]; then
- JAVA_MAX_MEM=512M
- export JAVA_MAX_MEM
-fi
-
-warn() {
- echo "${PROGNAME}: $*"
-}
-
-die() {
- warn "$*"
- exit 1
-}
-
-maybeSource() {
- file="$1"
- if [ -f "$file" ] ; then
- . $file
- fi
-}
-
-detectOS() {
- # OS specific support (must be 'true' or 'false').
- cygwin=false;
- darwin=false;
- aix=false;
- os400=false;
- case "`uname`" in
- CYGWIN*)
- cygwin=true
- ;;
- Darwin*)
- darwin=true
- ;;
- AIX*)
- aix=true
- ;;
- OS400*)
- os400=true
- ;;
- esac
- # For AIX, set an environment variable
- if $aix; then
- export LDR_CNTRL=MAXDATA=0xB0000000@DSA
- export IBM_JAVA_HEAPDUMP_TEXT=true
- echo $LDR_CNTRL
- fi
-}
-
-unlimitFD() {
- # Use the maximum available, or set MAX_FD != -1 to use that
- if [ "x$MAX_FD" = "x" ]; then
- MAX_FD="maximum"
- fi
-
- # Increase the maximum file descriptors if we can
- if [ "$os400" = "false" ] && [ "$cygwin" = "false" ]; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ "$MAX_FD_LIMIT" != 'unlimited' ]; then
- if [ $? -eq 0 ]; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then
- # use the system max
- MAX_FD="$MAX_FD_LIMIT"
- fi
-
- ulimit -n $MAX_FD > /dev/null
- # echo "ulimit -n" `ulimit -n`
- if [ $? -ne 0 ]; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query system maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
- fi
- fi
-}
-
-locateHome() {
- if [ "x$KARAF_HOME" != "x" ]; then
- warn "Ignoring predefined value for KARAF_HOME"
- fi
-
- # In POSIX shells, CDPATH may cause cd to write to stdout
- (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
- KARAF_HOME=`cd $DIRNAME/..; pwd`
- if [ ! -d "$KARAF_HOME" ]; then
- die "KARAF_HOME is not valid: $KARAF_HOME"
- fi
-}
-
-locateBase() {
- if [ "x$KARAF_BASE" != "x" ]; then
- if [ ! -d "$KARAF_BASE" ]; then
- die "KARAF_BASE is not valid: $KARAF_BASE"
- fi
- else
- KARAF_BASE=$KARAF_HOME
- fi
-}
-
-setupNativePath() {
- # Support for loading native libraries
- LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:$KARAF_BASE/lib:$KARAF_HOME/lib"
-
- # For Cygwin, set PATH from LD_LIBRARY_PATH
- if $cygwin; then
- LD_LIBRARY_PATH=`cygpath --path --windows "$LD_LIBRARY_PATH"`
- PATH="$PATH;$LD_LIBRARY_PATH"
- export PATH
- fi
- export LD_LIBRARY_PATH
-}
-
-pathCanonicalSimple() {
- local dst="${1}"
- cd -P -- "$(dirname -- "${dst}")" &> /dev/null && echo "$(pwd -P)/$(basename -- "${dst}")"
-}
-
-pathCanonical() {
- local dst=`pathCanonicalSimple "${1}"`
- while [ -h "${dst}" ]; do
- local linkDst="$(ls -l "${dst}" | sed -e 's/^.*[[:space:]]*->[[:space:]]*\(.*\)[[:space:]]*$/\1/g')"
- if [ -z "$(echo "${linkDst}" | grep -E '^/')" ]; then
- # relative link destination
- linkDst="$(dirname "${dst}")/${linkDst}"
- fi
- dst=`pathCanonicalSimple "${linkDst}"`
- done
- echo "${dst}"
-}
-
-locateJava() {
- # Setup the Java Virtual Machine
- if $cygwin ; then
- [ -n "$JAVA" ] && JAVA=`cygpath --unix "$JAVA"`
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
- fi
-
- if [ "x$JAVA_HOME" = "x" ] && [ "$darwin" = "true" ]; then
- JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
- fi
- if [ "x$JAVA" = "x" ]; then
- if [ "x$JAVA_HOME" != "x" ]; then
- if [ ! -d "$JAVA_HOME" ]; then
- die "JAVA_HOME is not valid: $JAVA_HOME"
- fi
- JAVA="$JAVA_HOME/bin/java"
- else
- warn "JAVA_HOME not set; results may vary"
- JAVA=`which java`
- if [ "x$JAVA" = "x" ]; then
- die "java command not found"
- fi
- fi
- fi
- if [ "x$JAVA_HOME" = "x" ]; then
- JAVA_HOME=$(dirname $(pathCanonical "$JAVA"))
- fi
-}
-
-detectJVM() {
- #echo "`$JAVA -version`"
- # This service should call `java -version`,
- # read stdout, and look for hints
- if $JAVA -version 2>&1 | grep "^IBM" ; then
- JVM_VENDOR="IBM"
- # on OS/400, java -version does not contain IBM explicitly
- elif $os400; then
- JVM_VENDOR="IBM"
- else
- JVM_VENDOR="SUN"
- fi
- # echo "JVM vendor is $JVM_VENDOR"
-}
-
-setupDebugOptions() {
- if [ "x$JAVA_OPTS" = "x" ]; then
- JAVA_OPTS="$DEFAULT_JAVA_OPTS"
- fi
- export JAVA_OPTS
-
- # Set Debug options if enabled
- if [ "x$KARAF_DEBUG" != "x" ]; then
- # Use the defaults if JAVA_DEBUG_OPTS was not set
- if [ "x$JAVA_DEBUG_OPTS" = "x" ]; then
- JAVA_DEBUG_OPTS="$DEFAULT_JAVA_DEBUG_OPTS"
- fi
-
- JAVA_OPTS="$JAVA_DEBUG_OPTS $JAVA_OPTS"
- warn "Enabling Java debug options: $JAVA_DEBUG_OPTS"
- fi
-}
-
-setupDefaults() {
- DEFAULT_JAVA_OPTS="-Xms$JAVA_MIN_MEM -Xmx$JAVA_MAX_MEM "
-
- #Set the JVM_VENDOR specific JVM flags
- if [ "$JVM_VENDOR" = "SUN" ]; then
- DEFAULT_JAVA_OPTS="-server $DEFAULT_JAVA_OPTS -Dcom.sun.management.jmxremote"
- elif [ "$JVM_VENDOR" = "IBM" ]; then
- if $os400; then
- DEFAULT_JAVA_OPTS="$DEFAULT_JAVA_OPTS"
- elif $aix; then
- DEFAULT_JAVA_OPTS="-Xverify:none -Xlp $DEFAULT_JAVA_OPTS"
- else
- DEFAULT_JAVA_OPTS="-Xverify:none $DEFAULT_JAVA_OPTS"
- fi
- fi
-
- # Add the jars in the lib dir
- for file in $KARAF_HOME/lib/*.jar
- do
- if [ -z "$CLASSPATH" ]; then
- CLASSPATH="$file"
- else
- CLASSPATH="$CLASSPATH:$file"
- fi
- done
- DEFAULT_JAVA_DEBUG_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"
-
- ##
- ## TODO: Move to conf/profiler/yourkit.{sh|cmd}
- ##
- # Uncomment to enable YourKit profiling
- #DEFAULT_JAVA_DEBUG_OPTS="-Xrunyjpagent"
-}
-
-init() {
- # Determine if there is special OS handling we must perform
- detectOS
-
- # Unlimit the number of file descriptors if possible
- unlimitFD
-
- # Locate the Karaf home directory
- locateHome
-
- # Locate the Karaf base directory
- locateBase
-
- # Setup the native library path
- setupNativePath
-
- # Locate the Java VM to execute
- locateJava
-
- # Determine the JVM vendor
- detectJVM
-
- # Setup default options
- setupDefaults
-
- # Install debug options
- setupDebugOptions
-
-}
-
-run() {
- OPTS="-Dkaraf.startLocalConsole=true -Dkaraf.startRemoteShell=true"
- MAIN=org.apache.felix.karaf.main.Main
- case "$1" in
- 'stop')
- MAIN=org.apache.felix.karaf.main.Stop
- shift
- ;;
- 'console')
- shift
- ;;
- 'server')
- OPTS="-Dkaraf.startLocalConsole=false -Dkaraf.startRemoteShell=true"
- shift
- ;;
- 'client')
- OPTS="-Dkaraf.startLocalConsole=true -Dkaraf.startRemoteShell=false"
- shift
- ;;
- esac
-
- if $cygwin; then
- KARAF_HOME=`cygpath --path --windows "$KARAF_HOME"`
- KARAF_BASE=`cygpath --path --windows "$KARAF_BASE"`
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
- fi
- cd $KARAF_BASE
- exec $JAVA $JAVA_OPTS -Djava.endorsed.dirs="${JAVA_HOME}/jre/lib/endorsed:${JAVA_HOME}/lib/endorsed:${KARAF_HOME}/lib/endorsed" -Djava.ext.dirs="${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext:${KARAF_HOME}/lib/ext" -Dstorage.location="${KARAF_HOME}/instances" -Dkaraf.home="$KARAF_HOME" -Dkaraf.base="$KARAF_BASE" -Djava.util.logging.config.file=$KARAF_BASE/etc/java.util.logging.properties $OPTS -classpath "$CLASSPATH" $MAIN "$@"
-}
-
-main() {
- init
- run "$@"
-}
-
-main "$@"
diff --git a/karaf/assembly/src/main/distribution/unix-shell/bin/start b/karaf/assembly/src/main/distribution/unix-shell/bin/start
deleted file mode 100755
index 474885e..0000000
--- a/karaf/assembly/src/main/distribution/unix-shell/bin/start
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/bin/sh
-#
-# 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.
-#
-# $Id: karaf 979 2005-11-30 22:50:55Z bsnyder $
-#
-
-DIRNAME=`dirname $0`
-PROGNAME=`basename $0`
-
-warn() {
- echo "${PROGNAME}: $*"
-}
-
-die() {
- warn "$*"
- exit 1
-}
-
-detectOS() {
- # OS specific support (must be 'true' or 'false').
- cygwin=false;
- darwin=false;
- aix=false;
- os400=false;
- case "`uname`" in
- CYGWIN*)
- cygwin=true
- ;;
- Darwin*)
- darwin=true
- ;;
- AIX*)
- aix=true
- ;;
- OS400*)
- os400=true
- ;;
- esac
- # For AIX, set an environment variable
- if $aix; then
- export LDR_CNTRL=MAXDATA=0xB0000000@DSA
- export IBM_JAVA_HEAPDUMP_TEXT=true
- echo $LDR_CNTRL
- fi
-}
-
-locateHome() {
- if [ "x$KARAF_HOME" != "x" ]; then
- warn "Ignoring predefined value for KARAF_HOME"
- fi
-
- # In POSIX shells, CDPATH may cause cd to write to stdout
- (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
- KARAF_HOME=`cd $DIRNAME/..; pwd`
- if [ ! -d "$KARAF_HOME" ]; then
- die "KARAF_HOME is not valid: $KARAF_HOME"
- fi
-}
-
-locateBase() {
- if [ "x$KARAF_BASE" != "x" ]; then
- if [ ! -d "$KARAF_BASE" ]; then
- die "KARAF_BASE is not valid: $KARAF_BASE"
- fi
- else
- KARAF_BASE=$KARAF_HOME
- fi
-}
-
-init() {
- # Determine if there is special OS handling we must perform
- detectOS
-
- # Locate the Karaf home directory
- locateHome
-
- # Locate the Karaf base directory
- locateBase
-}
-
-run() {
- if $cygwin; then
- KARAF_HOME=`cygpath --path --windows "$KARAF_HOME"`
- KARAF_BASE=`cygpath --path --windows "$KARAF_BASE"`
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
- fi
- # Ensure the log directory exists -- we need to have a place to redirect stdout/stderr
- if [ ! -d "$KARAF_HOME/data/log" ]; then
- mkdir -p "$KARAF_HOME/data/log"
- fi
- exec "$KARAF_HOME"/bin/karaf server "$@" >> "$KARAF_HOME/data/log/karaf.out" 2>&1 &
-}
-
-main() {
- init
- run "$@"
-}
-
-main "$@"
-
diff --git a/karaf/assembly/src/main/distribution/unix-shell/bin/stop b/karaf/assembly/src/main/distribution/unix-shell/bin/stop
deleted file mode 100755
index dd6dfc2..0000000
--- a/karaf/assembly/src/main/distribution/unix-shell/bin/stop
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/bin/sh
-#
-# 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.
-#
-# $Id: karaf 979 2005-11-30 22:50:55Z bsnyder $
-#
-
-DIRNAME=`dirname $0`
-PROGNAME=`basename $0`
-
-warn() {
- echo "${PROGNAME}: $*"
-}
-
-die() {
- warn "$*"
- exit 1
-}
-
-detectOS() {
- # OS specific support (must be 'true' or 'false').
- cygwin=false;
- darwin=false;
- aix=false;
- os400=false;
- case "`uname`" in
- CYGWIN*)
- cygwin=true
- ;;
- Darwin*)
- darwin=true
- ;;
- AIX*)
- aix=true
- ;;
- OS400*)
- os400=true
- ;;
- esac
- # For AIX, set an environment variable
- if $aix; then
- export LDR_CNTRL=MAXDATA=0xB0000000@DSA
- export IBM_JAVA_HEAPDUMP_TEXT=true
- echo $LDR_CNTRL
- fi
-}
-
-locateHome() {
- if [ "x$KARAF_HOME" != "x" ]; then
- warn "Ignoring predefined value for KARAF_HOME"
- fi
-
- # In POSIX shells, CDPATH may cause cd to write to stdout
- (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
- KARAF_HOME=`cd $DIRNAME/..; pwd`
- if [ ! -d "$KARAF_HOME" ]; then
- die "KARAF_HOME is not valid: $KARAF_HOME"
- fi
-}
-
-locateBase() {
- if [ "x$KARAF_BASE" != "x" ]; then
- if [ ! -d "$KARAF_BASE" ]; then
- die "KARAF_BASE is not valid: $KARAF_BASE"
- fi
- else
- KARAF_BASE=$KARAF_HOME
- fi
-}
-
-init() {
- # Determine if there is special OS handling we must perform
- detectOS
-
- # Locate the Karaf home directory
- locateHome
-
- # Locate the Karaf base directory
- locateBase
-}
-
-run() {
- if $cygwin; then
- KARAF_HOME=`cygpath --path --windows "$KARAF_HOME"`
- KARAF_BASE=`cygpath --path --windows "$KARAF_BASE"`
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
- fi
- # Ensure the log directory exists -- we need to have a place to redirect stdout/stderr
- if [ ! -d "$KARAF_HOME/data/log" ]; then
- mkdir -p "$KARAF_HOME/data/log"
- fi
- exec "$KARAF_HOME"/bin/karaf stop "$@"
-}
-
-main() {
- init
- run "$@"
-}
-
-main "$@"
-
diff --git a/karaf/assembly/src/main/distribution/windows-text/bin/karaf.bat b/karaf/assembly/src/main/distribution/windows-text/bin/karaf.bat
deleted file mode 100755
index 40ce239..0000000
--- a/karaf/assembly/src/main/distribution/windows-text/bin/karaf.bat
+++ /dev/null
@@ -1,242 +0,0 @@
-@echo off
-rem
-rem
-rem Licensed to the Apache Software Foundation (ASF) under one or more
-rem contributor license agreements. See the NOTICE file distributed with
-rem this work for additional information regarding copyright ownership.
-rem The ASF licenses this file to You under the Apache License, Version 2.0
-rem (the "License"); you may not use this file except in compliance with
-rem the License. You may obtain a copy of the License at
-rem
-rem http://www.apache.org/licenses/LICENSE-2.0
-rem
-rem Unless required by applicable law or agreed to in writing, software
-rem distributed under the License is distributed on an "AS IS" BASIS,
-rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-rem See the License for the specific language governing permissions and
-rem limitations under the License.
-rem
-rem
-rem $Id: karaf.bat 979 2005-11-30 22:50:55Z bsnyder $
-rem
-
-if not "%ECHO%" == "" echo %ECHO%
-
-setlocal
-set DIRNAME=%~dp0%
-set PROGNAME=%~nx0%
-set ARGS=%*
-
-title Karaf
-
-goto BEGIN
-
-:warn
- echo %PROGNAME%: %*
-goto :EOF
-
-:BEGIN
-
-rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
-
-if not "%KARAF_HOME%" == "" (
- call :warn Ignoring predefined value for KARAF_HOME
-)
-set KARAF_HOME=%DIRNAME%..
-if not exist "%KARAF_HOME%" (
- call :warn KARAF_HOME is not valid: %KARAF_HOME%
- goto END
-)
-
-if not "%KARAF_BASE%" == "" (
- if not exist "%KARAF_BASE%" (
- call :warn KARAF_BASE is not valid: %KARAF_BASE%
- goto END
- )
-)
-if "%KARAF_BASE%" == "" (
- set KARAF_BASE=%KARAF_HOME%
-)
-
-set LOCAL_CLASSPATH=%CLASSPATH%
-set DEFAULT_JAVA_OPTS=-server -Xmx512M -Dderby.system.home="%KARAF_BASE%\data\derby" -Dderby.storage.fileSyncTransactionLog=true -Dcom.sun.management.jmxremote
-set CLASSPATH=%LOCAL_CLASSPATH%;%KARAF_BASE%\conf
-set DEFAULT_JAVA_DEBUG_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
-
-if "%LOCAL_CLASSPATH%" == "" goto :KARAF_CLASSPATH_EMPTY
- set CLASSPATH=%LOCAL_CLASSPATH%;%KARAF_BASE%\conf
- goto :KARAF_CLASSPATH_END
-:KARAF_CLASSPATH_EMPTY
- set CLASSPATH=%KARAF_BASE%\conf
-:KARAF_CLASSPATH_END
-
-rem Setup Karaf Home
-if exist "%KARAF_HOME%\conf\karaf-rc.cmd" call %KARAF_HOME%\conf\karaf-rc.cmd
-if exist "%HOME%\karaf-rc.cmd" call %HOME%\karaf-rc.cmd
-
-rem Support for loading native libraries
-set PATH=%PATH%;%KARAF_BASE%\lib;%KARAF_HOME%\lib
-
-rem Setup the Java Virtual Machine
-if not "%JAVA%" == "" goto :Check_JAVA_END
- if not "%JAVA_HOME%" == "" goto :TryJDKEnd
- call :warn JAVA_HOME not set; results may vary
-:TryJRE
- start /w regedit /e __reg1.txt "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment"
- if not exist __reg1.txt goto :TryJDK
- type __reg1.txt | find "CurrentVersion" > __reg2.txt
- if errorlevel 1 goto :TryJDK
- for /f "tokens=2 delims==" %%x in (__reg2.txt) do set JavaTemp=%%~x
- if errorlevel 1 goto :TryJDK
- set JavaTemp=%JavaTemp%##
- set JavaTemp=%JavaTemp: ##=##%
- set JavaTemp=%JavaTemp: ##=##%
- set JavaTemp=%JavaTemp: ##=##%
- set JavaTemp=%JavaTemp: ##=##%
- set JavaTemp=%JavaTemp: ##=##%
- set JavaTemp=%JavaTemp:##=%
- del __reg1.txt
- del __reg2.txt
- start /w regedit /e __reg1.txt "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\%JavaTemp%"
- if not exist __reg1.txt goto :TryJDK
- type __reg1.txt | find "JavaHome" > __reg2.txt
- if errorlevel 1 goto :TryJDK
- for /f "tokens=2 delims==" %%x in (__reg2.txt) do set JAVA_HOME=%%~x
- if errorlevel 1 goto :TryJDK
- del __reg1.txt
- del __reg2.txt
- goto TryJDKEnd
-:TryJDK
- start /w regedit /e __reg1.txt "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit"
- if not exist __reg1.txt (
- call :warn Unable to retrieve JAVA_HOME
- goto END
- )
- type __reg1.txt | find "CurrentVersion" > __reg2.txt
- if errorlevel 1 (
- call :warn Unable to retrieve JAVA_HOME
- goto END
- )
- for /f "tokens=2 delims==" %%x in (__reg2.txt) do set JavaTemp=%%~x
- if errorlevel 1 (
- call :warn Unable to retrieve JAVA_HOME
- goto END
- )
- set JavaTemp=%JavaTemp%##
- set JavaTemp=%JavaTemp: ##=##%
- set JavaTemp=%JavaTemp: ##=##%
- set JavaTemp=%JavaTemp: ##=##%
- set JavaTemp=%JavaTemp: ##=##%
- set JavaTemp=%JavaTemp: ##=##%
- set JavaTemp=%JavaTemp:##=%
- del __reg1.txt
- del __reg2.txt
- start /w regedit /e __reg1.txt "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\%JavaTemp%"
- if not exist __reg1.txt (
- call :warn Unable to retrieve JAVA_HOME from JDK
- goto END
- )
- type __reg1.txt | find "JavaHome" > __reg2.txt
- if errorlevel 1 (
- call :warn Unable to retrieve JAVA_HOME
- goto END
- )
- for /f "tokens=2 delims==" %%x in (__reg2.txt) do set JAVA_HOME=%%~x
- if errorlevel 1 (
- call :warn Unable to retrieve JAVA_HOME
- goto END
- )
- del __reg1.txt
- del __reg2.txt
-:TryJDKEnd
- if not exist "%JAVA_HOME%" (
- call :warn JAVA_HOME is not valid: "%JAVA_HOME%"
- goto END
- )
- set JAVA=%JAVA_HOME%\bin\java
-:Check_JAVA_END
-
-if "%JAVA_OPTS%" == "" set JAVA_OPTS=%DEFAULT_JAVA_OPTS%
-
-if "%KARAF_DEBUG%" == "" goto :KARAF_DEBUG_END
- rem Use the defaults if JAVA_DEBUG_OPTS was not set
- if "%JAVA_DEBUG_OPTS%" == "" set JAVA_DEBUG_OPTS=%DEFAULT_JAVA_DEBUG_OPTS%
-
- set "JAVA_OPTS=%JAVA_DEBUG_OPTS% %JAVA_OPTS%"
- call :warn Enabling Java debug options: %JAVA_DEBUG_OPTS%
-:KARAF_DEBUG_END
-
-if "%KARAF_PROFILER%" == "" goto :KARAF_PROFILER_END
- set KARAF_PROFILER_SCRIPT=%KARAF_HOME%\conf\profiler\%KARAF_PROFILER%.cmd
-
- if exist "%KARAF_PROFILER_SCRIPT%" goto :KARAF_PROFILER_END
- call :warn Missing configuration for profiler '%KARAF_PROFILER%': %KARAF_PROFILER_SCRIPT%
- goto END
-:KARAF_PROFILER_END
-
-rem Setup the classpath
-pushd "%KARAF_HOME%\lib"
-for %%G in (*.*) do call:APPEND_TO_CLASSPATH %%G
-popd
-goto CLASSPATH_END
-
-: APPEND_TO_CLASSPATH
-set filename=%~1
-set suffix=%filename:~-4%
-if %suffix% equ .jar set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\lib\%filename%
-goto :EOF
-
-:CLASSPATH_END
-
-rem Execute the JVM or the load the profiler
-if "%KARAF_PROFILER%" == "" goto :RUN
- rem Execute the profiler if it has been configured
- call :warn Loading profiler script: %KARAF_PROFILER_SCRIPT%
- call %KARAF_PROFILER_SCRIPT%
-
-:RUN
- SET OPTS=-Dkaraf.startLocalConsole=true -Dkaraf.startRemoteShell=true
- SET MAIN=org.apache.felix.karaf.main.Main
- SET SHIFT=false
- if "%1" == "stop" goto :EXECUTE_STOP
- if "%1" == "console" goto :EXECUTE_CONSOLE
- if "%1" == "server" goto :EXECUTE_SERVER
- if "%1" == "client" goto :EXECUTE_CLIENT
- goto :EXECUTE
-
-:EXECUTE_STOP
- SET MAIN=org.apache.felix.karaf.main.Stop
- SET SHIFT=true
- goto :EXECUTE
-
-:EXECUTE_CONSOLE
- SET SHIFT=true
- goto :EXECUTE
-
-:EXECUTE_SERVER
- SET OPTS=-Dkaraf.startLocalConsole=false -Dkaraf.startRemoteShell=true
- SET SHIFT=true
- goto :EXECUTE
-
-:EXECUTE_CLIENT
- SET OPTS=-Dkaraf.startLocalConsole=true -Dkaraf.startRemoteShell=false
- SET SHIFT=true
- goto :EXECUTE
-
-:EXECUTE
- if "%SHIFT%" == "true" SET ARGS=%2 %3 %4 %5 %6 %7 %8
- if not "%SHIFT%" == "true" SET ARGS=%1 %2 %3 %4 %5 %6 %7 %8
- rem Execute the Java Virtual Machine
- cd %KARAF_BASE%
- "%JAVA%" %JAVA_OPTS% %OPTS% -classpath "%CLASSPATH%" -Djava.endorsed.dirs="%JAVA_HOME%\jre\lib\endorsed;%JAVA_HOME%\lib\endorsed;%KARAF_HOME%\lib\endorsed" -Djava.ext.dirs="%JAVA_HOME%\jre\lib\ext;%JAVA_HOME%\lib\ext;%KARAF_HOME%\lib\ext" -Dstorage.location="%KARAF_HOME%\instances" -Dkaraf.home="%KARAF_HOME%" -Dkaraf.base="%KARAF_BASE%" -Djava.util.logging.config.file="%KARAF_BASE%\etc\java.util.logging.properties" %MAIN% %ARGS%
-
-rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
-
-:END
-
-endlocal
-
-if not "%PAUSE%" == "" pause
-
-:END_NO_PAUSE
-
diff --git a/karaf/assembly/src/main/distribution/windows-text/bin/start.bat b/karaf/assembly/src/main/distribution/windows-text/bin/start.bat
deleted file mode 100755
index 1db948b..0000000
--- a/karaf/assembly/src/main/distribution/windows-text/bin/start.bat
+++ /dev/null
@@ -1,72 +0,0 @@
-@echo off
-rem
-rem
-rem Licensed to the Apache Software Foundation (ASF) under one or more
-rem contributor license agreements. See the NOTICE file distributed with
-rem this work for additional information regarding copyright ownership.
-rem The ASF licenses this file to You under the Apache License, Version 2.0
-rem (the "License"); you may not use this file except in compliance with
-rem the License. You may obtain a copy of the License at
-rem
-rem http://www.apache.org/licenses/LICENSE-2.0
-rem
-rem Unless required by applicable law or agreed to in writing, software
-rem distributed under the License is distributed on an "AS IS" BASIS,
-rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-rem See the License for the specific language governing permissions and
-rem limitations under the License.
-rem
-rem
-rem $Id: karaf.bat 979 2005-11-30 22:50:55Z bsnyder $
-rem
-
-if not "%ECHO%" == "" echo %ECHO%
-
-setlocal
-set DIRNAME=%~dp0%
-set PROGNAME=%~nx0%
-set ARGS=%*
-
-title Karaf
-
-goto BEGIN
-
-:warn
- echo %PROGNAME%: %*
-goto :EOF
-
-:BEGIN
-
-rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
-
-if not "%KARAF_HOME%" == "" (
- call :warn Ignoring predefined value for KARAF_HOME
-)
-set KARAF_HOME=%DIRNAME%..
-if not exist "%KARAF_HOME%" (
- call :warn KARAF_HOME is not valid: %KARAF_HOME%
- goto END
-)
-
-if not "%KARAF_BASE%" == "" (
- if not exist "%KARAF_BASE%" (
- call :warn KARAF_BASE is not valid: %KARAF_BASE%
- goto END
- )
-)
-if "%KARAF_BASE%" == "" (
- set KARAF_BASE=%KARAF_HOME%
-)
-
-:EXECUTE
- start "Karaf" /MIN "%KARAF_HOME%\bin\karaf.bat" server
-
-rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
-
-:END
-
-endlocal
-
-if not "%PAUSE%" == "" pause
-
-:END_NO_PAUSE
\ No newline at end of file
diff --git a/karaf/assembly/src/main/distribution/windows-text/bin/stop.bat b/karaf/assembly/src/main/distribution/windows-text/bin/stop.bat
deleted file mode 100755
index 3b875cd..0000000
--- a/karaf/assembly/src/main/distribution/windows-text/bin/stop.bat
+++ /dev/null
@@ -1,72 +0,0 @@
-@echo off
-rem
-rem
-rem Licensed to the Apache Software Foundation (ASF) under one or more
-rem contributor license agreements. See the NOTICE file distributed with
-rem this work for additional information regarding copyright ownership.
-rem The ASF licenses this file to You under the Apache License, Version 2.0
-rem (the "License"); you may not use this file except in compliance with
-rem the License. You may obtain a copy of the License at
-rem
-rem http://www.apache.org/licenses/LICENSE-2.0
-rem
-rem Unless required by applicable law or agreed to in writing, software
-rem distributed under the License is distributed on an "AS IS" BASIS,
-rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-rem See the License for the specific language governing permissions and
-rem limitations under the License.
-rem
-rem
-rem $Id: karaf.bat 979 2005-11-30 22:50:55Z bsnyder $
-rem
-
-if not "%ECHO%" == "" echo %ECHO%
-
-setlocal
-set DIRNAME=%~dp0%
-set PROGNAME=%~nx0%
-set ARGS=%*
-
-title Karaf
-
-goto BEGIN
-
-:warn
- echo %PROGNAME%: %*
-goto :EOF
-
-:BEGIN
-
-rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
-
-if not "%KARAF_HOME%" == "" (
- call :warn Ignoring predefined value for KARAF_HOME
-)
-set KARAF_HOME=%DIRNAME%..
-if not exist "%KARAF_HOME%" (
- call :warn KARAF_HOME is not valid: %KARAF_HOME%
- goto END
-)
-
-if not "%KARAF_BASE%" == "" (
- if not exist "%KARAF_BASE%" (
- call :warn KARAF_BASE is not valid: %KARAF_BASE%
- goto END
- )
-)
-if "%KARAF_BASE%" == "" (
- set KARAF_BASE=%KARAF_HOME%
-)
-
-:EXECUTE
- "%KARAF_HOME%\bin\karaf.bat" stop
-
-rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
-
-:END
-
-endlocal
-
-if not "%PAUSE%" == "" pause
-
-:END_NO_PAUSE
\ No newline at end of file
diff --git a/karaf/assembly/src/main/filtered-resources/bin/admin b/karaf/assembly/src/main/filtered-resources/bin/admin
deleted file mode 100644
index 96a6e0d..0000000
--- a/karaf/assembly/src/main/filtered-resources/bin/admin
+++ /dev/null
@@ -1,284 +0,0 @@
-#!/bin/sh
-#
-# 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.
-#
-#
-
-DIRNAME=`dirname $0`
-PROGNAME=`basename $0`
-
-#
-# Check/Set up some easily accessible MIN/MAX params for JVM mem usage
-#
-
-if [ "x$JAVA_MIN_MEM" = "x" ]; then
- JAVA_MIN_MEM=128M
- export JAVA_MIN_MEM
-fi
-
-if [ "x$JAVA_MAX_MEM" = "x" ]; then
- JAVA_MAX_MEM=512M
- export JAVA_MAX_MEM
-fi
-
-warn() {
- echo "${PROGNAME}: $*"
-}
-
-die() {
- warn "$*"
- exit 1
-}
-
-maybeSource() {
- file="$1"
- if [ -f "$file" ] ; then
- . $file
- fi
-}
-
-detectOS() {
- # OS specific support (must be 'true' or 'false').
- cygwin=false;
- darwin=false;
- aix=false;
- os400=false;
- case "`uname`" in
- CYGWIN*)
- cygwin=true
- ;;
- Darwin*)
- darwin=true
- ;;
- AIX*)
- aix=true
- ;;
- OS400*)
- os400=true
- ;;
- esac
- # For AIX, set an environment variable
- if $aix; then
- export LDR_CNTRL=MAXDATA=0xB0000000@DSA
- export IBM_JAVA_HEAPDUMP_TEXT=true
- echo $LDR_CNTRL
- fi
-}
-
-unlimitFD() {
- # Use the maximum available, or set MAX_FD != -1 to use that
- if [ "x$MAX_FD" = "x" ]; then
- MAX_FD="maximum"
- fi
-
- # Increase the maximum file descriptors if we can
- if [ "$os400" = "false" ] && [ "$cygwin" = "false" ]; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ "$MAX_FD_LIMIT" != 'unlimited' ]; then
- if [ $? -eq 0 ]; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then
- # use the system max
- MAX_FD="$MAX_FD_LIMIT"
- fi
-
- ulimit -n $MAX_FD > /dev/null
- # echo "ulimit -n" `ulimit -n`
- if [ $? -ne 0 ]; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query system maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
- fi
- fi
-}
-
-locateHome() {
- if [ "x$KARAF_HOME" != "x" ]; then
- warn "Ignoring predefined value for KARAF_HOME"
- fi
-
- # In POSIX shells, CDPATH may cause cd to write to stdout
- (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
- KARAF_HOME=`cd $DIRNAME/..; pwd`
- if [ ! -d "$KARAF_HOME" ]; then
- die "KARAF_HOME is not valid: $KARAF_HOME"
- fi
-}
-
-locateBase() {
- if [ "x$KARAF_BASE" != "x" ]; then
- if [ ! -d "$KARAF_BASE" ]; then
- die "KARAF_BASE is not valid: $KARAF_BASE"
- fi
- else
- KARAF_BASE=$KARAF_HOME
- fi
-}
-
-setupNativePath() {
- # Support for loading native libraries
- LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:$KARAF_BASE/lib:$KARAF_HOME/lib"
-
- # For Cygwin, set PATH from LD_LIBRARY_PATH
- if $cygwin; then
- LD_LIBRARY_PATH=`cygpath --path --windows "$LD_LIBRARY_PATH"`
- PATH="$PATH;$LD_LIBRARY_PATH"
- export PATH
- fi
- export LD_LIBRARY_PATH
-}
-
-locateJava() {
- # Setup the Java Virtual Machine
- if $cygwin ; then
- [ -n "$JAVA" ] && JAVA=`cygpath --unix "$JAVA"`
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
- fi
-
- if [ "x$JAVA" = "x" ]; then
- if [ "x$JAVA_HOME" = "x" ] && [ "$darwin" = "true" ]; then
- JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
- fi
- if [ "x$JAVA_HOME" != "x" ]; then
- if [ ! -d "$JAVA_HOME" ]; then
- die "JAVA_HOME is not valid: $JAVA_HOME"
- fi
- JAVA="$JAVA_HOME/bin/java"
- else
- warn "JAVA_HOME not set; results may vary"
- JAVA="java"
- fi
- fi
-}
-
-detectJVM() {
- #echo "`$JAVA -version`"
- # This service should call `java -version`,
- # read stdout, and look for hints
- if $JAVA -version 2>&1 | grep "^IBM" ; then
- JVM_VENDOR="IBM"
- # on OS/400, java -version does not contain IBM explicitly
- elif $os400; then
- JVM_VENDOR="IBM"
- else
- JVM_VENDOR="SUN"
- fi
- # echo "JVM vendor is $JVM_VENDOR"
-}
-
-setupDebugOptions() {
- if [ "x$JAVA_OPTS" = "x" ]; then
- JAVA_OPTS="$DEFAULT_JAVA_OPTS"
- fi
- export JAVA_OPTS
-
- # Set Debug options if enabled
- if [ "x$KARAF_DEBUG" != "x" ]; then
- # Use the defaults if JAVA_DEBUG_OPTS was not set
- if [ "x$JAVA_DEBUG_OPTS" = "x" ]; then
- JAVA_DEBUG_OPTS="$DEFAULT_JAVA_DEBUG_OPTS"
- fi
-
- JAVA_OPTS="$JAVA_DEBUG_OPTS $JAVA_OPTS"
- warn "Enabling Java debug options: $JAVA_DEBUG_OPTS"
- fi
-}
-
-setupDefaults() {
- DEFAULT_JAVA_OPTS="-Xms$JAVA_MIN_MEM -Xmx$JAVA_MAX_MEM "
-
- #Set the JVM_VENDOR specific JVM flags
- if [ "$JVM_VENDOR" = "SUN" ]; then
- DEFAULT_JAVA_OPTS="-server $DEFAULT_JAVA_OPTS -Dcom.sun.management.jmxremote"
- elif [ "$JVM_VENDOR" = "IBM" ]; then
- if $os400; then
- DEFAULT_JAVA_OPTS="$DEFAULT_JAVA_OPTS"
- elif $aix; then
- DEFAULT_JAVA_OPTS="-Xverify:none -Xlp $DEFAULT_JAVA_OPTS"
- else
- DEFAULT_JAVA_OPTS="-Xverify:none $DEFAULT_JAVA_OPTS"
- fi
- fi
-
- # Add the jars in the lib dir
- for file in $KARAF_HOME/lib/*.jar
- do
- if [ -z "$CLASSPATH" ]; then
- CLASSPATH="$file"
- else
- CLASSPATH="$CLASSPATH:$file"
- fi
- done
- DEFAULT_JAVA_DEBUG_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"
-
- ##
- ## TODO: Move to conf/profiler/yourkit.{sh|cmd}
- ##
- # Uncomment to enable YourKit profiling
- #DEFAULT_JAVA_DEBUG_OPTS="-Xrunyjpagent"
-}
-
-init() {
- # Determine if there is special OS handling we must perform
- detectOS
-
- # Unlimit the number of file descriptors if possible
- unlimitFD
-
- # Locate the Karaf home directory
- locateHome
-
- # Locate the Karaf base directory
- locateBase
-
- # Setup the native library path
- setupNativePath
-
- # Locate the Java VM to execute
- locateJava
-
- # Determine the JVM vendor
- detectJVM
-
- # Setup default options
- setupDefaults
-
- # Install debug options
- setupDebugOptions
-
-}
-
-run() {
-
- if $cygwin; then
- KARAF_HOME=`cygpath --path --windows "$KARAF_HOME"`
- KARAF_BASE=`cygpath --path --windows "$KARAF_BASE"`
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
- fi
-
- CLASSPATH=${KARAF_HOME}/system/org/apache/felix/karaf/admin/org.apache.felix.karaf.admin.command/${project.version}/org.apache.felix.karaf.admin.command-${project.version}.jar:${KARAF_HOME}/system/org/apache/felix/karaf/admin/org.apache.felix.karaf.admin.core/${project.version}/org.apache.felix.karaf.admin.core-${project.version}.jar:${KARAF_HOME}/system/org/apache/felix/karaf/shell/org.apache.felix.karaf.shell.console/${project.version}/org.apache.felix.karaf.shell.console-${project.version}.jar:${KARAF_HOME}/system/org/apache/felix/gogo/org.apache.felix.gogo.runtime/${felix.gogo.version}/org.apache.felix.gogo.runtime-${felix.gogo.version}.jar:${KARAF_HOME}/system/org/apache/aries/blueprint/org.apache.aries.blueprint/${aries.blueprint.version}/org.apache.aries.blueprint-${aries.blueprint.version}.jar:${KARAF_HOME}/system/org/ops4j/pax/logging/pax-logging-api/${pax.logging.version}/pax-logging-api-${pax.logging.version}.jar:${KARAF_HOME}/system/org/apache/felix/org.apache.felix.framework/${felix.framework.version}/org.apache.felix.framework-${felix.framework.version}.jar
-
- exec $JAVA $JAVA_OPTS -Dstorage.location="${KARAF_HOME}/instances" -Dkaraf.home="$KARAF_HOME" -Dkaraf.base="$KARAF_BASE" -Djava.util.logging.config.file=$KARAF_BASE/etc/java.util.logging.properties $OPTS -classpath "$CLASSPATH" org.apache.felix.karaf.admin.main.Execute "$@"
-}
-
-main() {
- init
- run "$@"
-}
-
-main "$@"
diff --git a/karaf/assembly/src/main/filtered-resources/bin/admin.bat b/karaf/assembly/src/main/filtered-resources/bin/admin.bat
deleted file mode 100644
index 32703f8..0000000
--- a/karaf/assembly/src/main/filtered-resources/bin/admin.bat
+++ /dev/null
@@ -1,97 +0,0 @@
-@echo off
-rem
-rem
-rem Licensed to the Apache Software Foundation (ASF) under one or more
-rem contributor license agreements. See the NOTICE file distributed with
-rem this work for additional information regarding copyright ownership.
-rem The ASF licenses this file to You under the Apache License, Version 2.0
-rem (the "License"); you may not use this file except in compliance with
-rem the License. You may obtain a copy of the License at
-rem
-rem http://www.apache.org/licenses/LICENSE-2.0
-rem
-rem Unless required by applicable law or agreed to in writing, software
-rem distributed under the License is distributed on an "AS IS" BASIS,
-rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-rem See the License for the specific language governing permissions and
-rem limitations under the License.
-rem
-rem
-
-if not "%ECHO%" == "" echo %ECHO%
-
-setlocal
-set DIRNAME=%~dp0%
-set PROGNAME=%~nx0%
-set ARGS=%*
-
-goto BEGIN
-
-:warn
- echo %PROGNAME%: %*
-goto :EOF
-
-:BEGIN
-
-rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
-
-if not "%KARAF_HOME%" == "" (
- call :warn Ignoring predefined value for KARAF_HOME
-)
-set KARAF_HOME=%DIRNAME%..
-if not exist "%KARAF_HOME%" (
- call :warn KARAF_HOME is not valid: %KARAF_HOME%
- goto END
-)
-
-if not "%KARAF_BASE%" == "" (
- if not exist "%KARAF_BASE%" (
- call :warn KARAF_BASE is not valid: %KARAF_BASE%
- goto END
- )
-)
-if "%KARAF_BASE%" == "" (
- set KARAF_BASE=%KARAF_HOME%
-)
-
-set DEFAULT_JAVA_OPTS=
-set DEFAULT_JAVA_DEBUG_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
-
-rem Support for loading native libraries
-set PATH=%PATH%;%KARAF_BASE%\lib;%KARAF_HOME%\lib
-
-rem Setup the Java Virtual Machine
-if not "%JAVA%" == "" goto :Check_JAVA_END
- set JAVA=java
- if "%JAVA_HOME%" == "" call :warn JAVA_HOME not set; results may vary
- if not "%JAVA_HOME%" == "" set JAVA=%JAVA_HOME%\bin\java
- if not exist "%JAVA_HOME%" (
- call :warn JAVA_HOME is not valid: "%JAVA_HOME%"
- goto END
- )
-:Check_JAVA_END
-
-if "%JAVA_OPTS%" == "" set JAVA_OPTS=%DEFAULT_JAVA_OPTS%
-
-if "%KARAF_DEBUG%" == "" goto :KARAF_DEBUG_END
- rem Use the defaults if JAVA_DEBUG_OPTS was not set
- if "%JAVA_DEBUG_OPTS%" == "" set JAVA_DEBUG_OPTS=%DEFAULT_JAVA_DEBUG_OPTS%
-
- set "JAVA_OPTS=%JAVA_DEBUG_OPTS% %JAVA_OPTS%"
- call :warn Enabling Java debug options: %JAVA_DEBUG_OPTS%
-:KARAF_DEBUG_END
-
-set CLASSPATH=%KARAF_HOME%\system\org\apache\felix\karaf\admin\org.apache.felix.karaf.admin.command\${project.version}\org.apache.felix.karaf.admin.command-${project.version}.jar;%KARAF_HOME%\system\org\apache\felix\karaf\admin\org.apache.felix.karaf.admin.core\${project.version}\org.apache.felix.karaf.admin.core-${project.version}.jar;%KARAF_HOME%\system\org\apache\felix\karaf\shell\org.apache.felix.karaf.shell.console\${project.version}\org.apache.felix.karaf.shell.console-${project.version}.jar;%KARAF_HOME%\system\org\apache\felix\gogo\org.apache.felix.gogo.runtime\${felix.gogo.version}\org.apache.felix.gogo.runtime-${felix.gogo.version}.jar;%KARAF_HOME%\system\org\apache\aries\blueprint\org.apache.aries.blueprint\${aries.blueprint.version}\org.apache.aries.blueprint-${aries.blueprint.version}.jar;%KARAF_HOME%\system\org\ops4j\pax\logging\pax-logging-api\${pax.logging.version}\pax-logging-api-${pax.logging.version}.jar;%KARAF_HOME%\system\org\apache\felix\org.apache.felix.framework\${felix.framework.version}\org.apache.felix.framework-${felix.framework.version}.jar
-
-:EXECUTE
- if "%SHIFT%" == "true" SET ARGS=%2 %3 %4 %5 %6 %7 %8
- if not "%SHIFT%" == "true" SET ARGS=%1 %2 %3 %4 %5 %6 %7 %8
- rem Execute the Java Virtual Machine
- "%JAVA%" %JAVA_OPTS% %OPTS% -classpath "%CLASSPATH%" -Dstorage.location="%KARAF_HOME%\instances" -Dkaraf.home="%KARAF_HOME%" -Dkaraf.base="%KARAF_BASE%" -Djava.util.logging.config.file="%KARAF_BASE%\etc\java.util.logging.properties" org.apache.felix.karaf.admin.main.Execute %ARGS%
-
-rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
-
-:END
-
-endlocal
-
diff --git a/karaf/assembly/src/main/filtered-resources/demos/web/README.txt b/karaf/assembly/src/main/filtered-resources/demos/web/README.txt
deleted file mode 100644
index 955f047..0000000
--- a/karaf/assembly/src/main/filtered-resources/demos/web/README.txt
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-EMBEDDING KARAF IN A WEB APPLICATION
-====================================
-
-Purpose
--------
-Embed Karaf in a web application.
-
-
-Prerequisites for Running the Example
--------------------------------------
-You must have the following installed on your machine:
-
- - JDK 1.5 or higher
-
- - Maven 2.0.9 or higher
-
-
-Building and Deploying
-----------------------
-You can build and deploy this example in two ways:
-
-- A. Using Jetty: Quick and Easy
- This option is useful if you want to see the example up and
- running quickly.
-
-- B. Using Your Favorite Web Container
- This option is useful if you want to see Karaf running
- as a web application inside your favorite web container.
-
-
-A. Using Jetty: Quick and Easy
-------------------------------
-To build the example and deploy to Jetty, complete the
-following steps:
-
-1. In a command prompt/shell, change to the directory
- that contains this README.txt file.
-
-2. Enter the following Maven command:
-
- mvn package jetty:run
-
-This Maven command builds the example web application, starts
-Jetty and deploys the web application to Jetty. Once complete,
-you should see the following printed to the console:
-
-[INFO] Started Jetty Server
-[INFO] Starting scanner at interval of 10 seconds.
-
-Running a Client
-----------------
-To test the example, you can use the Apache Felix Karaf client
-to connect to the server and issue a Karaf command. For example,
-try executing the "features:list" command as follows:
-
-1. In a command prompt/shell, change to your product
- installation directory.
-
-2. Run the following command:
-
- java -jar lib/karaf-client.jar features:list
-
-In this case, you should see output similar to the following:
-
-State Version Name Repository
-[uninstalled] [2.5.6.SEC01] spring karaf-${project.version}
-[uninstalled] [1.2.0 ] spring-dm karaf-${project.version}
-[uninstalled] [${pom.version}] wrapper karaf-${pom.version}
-[uninstalled] [${pom.version}] obr karaf-${pom.version}
-[uninstalled] [${pom.version}] http karaf-${pom.version}
-[uninstalled] [${pom.version}] webconsole karaf-${pom.version}
-[installed ] [${pom.version}] ssh karaf-${pom.version}
-[installed ] [${pom.version}] management karaf-${pom.version}
-
-
-B. Using Your Favorite Web Container
-------------------------------------
-You can deploy the web application to your favorite web
-container, by completing the following steps:
-
-1. In a command prompt/shell, change to the directory
- that contains this README.txt file.
-
-2. Enter the following command:
-
- mvn package
-
-Maven builds the web application, web-${project.version}.war, and
-saves it in the target directory of this example. Deploy this
-WAR file to your favorite web container. Once the application
-is running, you can test it using the Apache Felix Karaf client
-as described in the "Running a Client" section above.
diff --git a/karaf/assembly/src/main/filtered-resources/etc/config.properties b/karaf/assembly/src/main/filtered-resources/etc/config.properties
deleted file mode 100644
index 22d8f13..0000000
--- a/karaf/assembly/src/main/filtered-resources/etc/config.properties
+++ /dev/null
@@ -1,343 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-#
-# Framework selection properties
-#
-karaf.framework=felix
-
-#
-# Location of the OSGi frameworks
-#
-karaf.framework.equinox=${karaf.default.repository}/org/eclipse/osgi/${equinox.version}/osgi-${equinox.version}.jar
-karaf.framework.felix=${karaf.default.repository}/org/apache/felix/org.apache.felix.framework/${felix.framework.version}/org.apache.felix.framework-${felix.framework.version}.jar
-
-#
-# Framework config properties.
-#
-org.osgi.framework.system.packages=org.osgi.framework; version=1.5.0, \
- org.osgi.framework.launch; version=1.0.0, \
- org.osgi.framework.hooks.service; version=1.0.0, \
- org.osgi.service.packageadmin; version=1.2.0, \
- org.osgi.service.startlevel; version=1.1.0, \
- org.osgi.service.url; version=1.0.0, \
- org.osgi.util.tracker; version=1.4.0 \
- ${jre-${java.specification.version}}
-
-org.osgi.framework.system.packages.extra=\
- org.apache.felix.karaf.jaas.boot; version=${karaf.osgi.version}, \
- org.apache.felix.karaf.version; version=${karaf.osgi.version}
-
-# javax.transaction is needed to avoid class loader constraint violation when using javax.sql
-org.osgi.framework.bootdelegation=sun.*,com.sun.*,javax.transaction,javax.transaction.*
-
-# OSGi Execution Environment
-org.osgi.framework.executionenvironment=J2SE-1.5,J2SE-1.4,J2SE-1.3
-
-# To enable the use of the startup.properties file to control the start level:
-karaf.auto.start=startup.properties
-#felix.auto.start=all
-
-org.osgi.framework.startlevel.beginning=100
-karaf.startlevel.bundle=60
-
-karaf.shutdown.port.file=${karaf.base}/data/port
-
-#
-# FileMonitor properties
-#
-felix.fileinstall.dir = ${karaf.base}/etc
-felix.fileinstall.filter = .*\\.cfg
-felix.fileinstall.poll = 1000
-felix.fileinstall.noInitialDelay = true
-
-#
-# Delay for writing the framework state to disk in equinox
-# must be >= 1000 and <= 1800000
-#
-eclipse.stateSaveDelayInterval = 1000
-
-#
-# Java platform package export properties.
-#
-
-# Standard package set. Note that:
-# - javax.transaction* is exported with a mandatory attribute
-jre-1.5=, \
- javax.accessibility, \
- javax.activity, \
- javax.crypto, \
- javax.crypto.interfaces, \
- javax.crypto.spec, \
- javax.imageio, \
- javax.imageio.event, \
- javax.imageio.metadata, \
- javax.imageio.plugins.bmp, \
- javax.imageio.plugins.jpeg, \
- javax.imageio.spi, \
- javax.imageio.stream, \
- javax.management, \
- javax.management.loading, \
- javax.management.modelmbean, \
- javax.management.monitor, \
- javax.management.openmbean, \
- javax.management.relation, \
- javax.management.remote, \
- javax.management.remote.rmi, \
- javax.management.timer, \
- javax.naming, \
- javax.naming.directory, \
- javax.naming.event, \
- javax.naming.ldap, \
- javax.naming.spi, \
- javax.net, \
- javax.net.ssl, \
- javax.print, \
- javax.print.attribute, \
- javax.print.attribute.standard, \
- javax.print.event, \
- javax.rmi, \
- javax.rmi.CORBA, \
- javax.rmi.ssl, \
- javax.security.auth, \
- javax.security.auth.callback, \
- javax.security.auth.kerberos, \
- javax.security.auth.login, \
- javax.security.auth.spi, \
- javax.security.auth.x500, \
- javax.security.cert, \
- javax.security.sasl, \
- javax.sound.midi, \
- javax.sound.midi.spi, \
- javax.sound.sampled, \
- javax.sound.sampled.spi, \
- javax.sql, \
- javax.sql.rowset, \
- javax.sql.rowset.serial, \
- javax.sql.rowset.spi, \
- javax.swing, \
- javax.swing.border, \
- javax.swing.colorchooser, \
- javax.swing.event, \
- javax.swing.filechooser, \
- javax.swing.plaf, \
- javax.swing.plaf.basic, \
- javax.swing.plaf.metal, \
- javax.swing.plaf.multi, \
- javax.swing.plaf.synth, \
- javax.swing.table, \
- javax.swing.text, \
- javax.swing.text.html, \
- javax.swing.text.html.parser, \
- javax.swing.text.rtf, \
- javax.swing.tree, \
- javax.swing.undo, \
- javax.transaction; javax.transaction.xa; partial=true; mandatory:=partial, \
- javax.xml, \
- javax.xml.datatype, \
- javax.xml.namespace, \
- javax.xml.parsers, \
- javax.xml.transform, \
- javax.xml.transform.dom, \
- javax.xml.transform.sax, \
- javax.xml.transform.stream, \
- javax.xml.validation, \
- javax.xml.xpath, \
- org.ietf.jgss, \
- org.omg.CORBA, \
- org.omg.CORBA_2_3, \
- org.omg.CORBA_2_3.portable, \
- org.omg.CORBA.DynAnyPackage, \
- org.omg.CORBA.ORBPackage, \
- org.omg.CORBA.portable, \
- org.omg.CORBA.TypeCodePackage, \
- org.omg.CosNaming, \
- org.omg.CosNaming.NamingContextExtPackage, \
- org.omg.CosNaming.NamingContextPackage, \
- org.omg.Dynamic, \
- org.omg.DynamicAny, \
- org.omg.DynamicAny.DynAnyFactoryPackage, \
- org.omg.DynamicAny.DynAnyPackage, \
- org.omg.IOP, \
- org.omg.IOP.CodecFactoryPackage, \
- org.omg.IOP.CodecPackage, \
- org.omg.Messaging, \
- org.omg.PortableInterceptor, \
- org.omg.PortableInterceptor.ORBInitInfoPackage, \
- org.omg.PortableServer, \
- org.omg.PortableServer.CurrentPackage, \
- org.omg.PortableServer.POAManagerPackage, \
- org.omg.PortableServer.POAPackage, \
- org.omg.PortableServer.portable, \
- org.omg.PortableServer.ServantLocatorPackage, \
- org.omg.SendingContext, \
- org.omg.stub.java.rmi, \
- org.omg.stub.javax.management.remote.rmi, \
- org.w3c.dom, \
- org.w3c.dom.bootstrap, \
- org.w3c.dom.css, \
- org.w3c.dom.events, \
- org.w3c.dom.html, \
- org.w3c.dom.ls, \
- org.w3c.dom.ranges, \
- org.w3c.dom.stylesheets, \
- org.w3c.dom.traversal, \
- org.w3c.dom.views, \
- org.xml.sax, \
- org.xml.sax.ext, \
- org.xml.sax.helpers
-
-# Standard package set. Note that:
-# - javax.transaction* is exported with a mandatory attribute
-jre-1.6=, \
- javax.accessibility, \
- javax.activity, \
- javax.crypto, \
- javax.crypto.interfaces, \
- javax.crypto.spec, \
- javax.imageio, \
- javax.imageio.event, \
- javax.imageio.metadata, \
- javax.imageio.plugins.bmp, \
- javax.imageio.plugins.jpeg, \
- javax.imageio.spi, \
- javax.imageio.stream, \
- javax.lang.model, \
- javax.lang.model.element, \
- javax.lang.model.type, \
- javax.lang.model.util, \
- javax.management, \
- javax.management.loading, \
- javax.management.modelmbean, \
- javax.management.monitor, \
- javax.management.openmbean, \
- javax.management.relation, \
- javax.management.remote, \
- javax.management.remote.rmi, \
- javax.management.timer, \
- javax.naming, \
- javax.naming.directory, \
- javax.naming.event, \
- javax.naming.ldap, \
- javax.naming.spi, \
- javax.net, \
- javax.net.ssl, \
- javax.print, \
- javax.print.attribute, \
- javax.print.attribute.standard, \
- javax.print.event, \
- javax.rmi, \
- javax.rmi.CORBA, \
- javax.rmi.ssl, \
- javax.security.auth, \
- javax.security.auth.callback, \
- javax.security.auth.kerberos, \
- javax.security.auth.login, \
- javax.security.auth.spi, \
- javax.security.auth.x500, \
- javax.security.cert, \
- javax.security.sasl, \
- javax.sound.midi, \
- javax.sound.midi.spi, \
- javax.sound.sampled, \
- javax.sound.sampled.spi, \
- javax.sql, \
- javax.sql.rowset, \
- javax.sql.rowset.serial, \
- javax.sql.rowset.spi, \
- javax.swing, \
- javax.swing.border, \
- javax.swing.colorchooser, \
- javax.swing.event, \
- javax.swing.filechooser, \
- javax.swing.plaf, \
- javax.swing.plaf.basic, \
- javax.swing.plaf.metal, \
- javax.swing.plaf.multi, \
- javax.swing.plaf.synth, \
- javax.swing.table, \
- javax.swing.text, \
- javax.swing.text.html, \
- javax.swing.text.html.parser, \
- javax.swing.text.rtf, \
- javax.swing.tree, \
- javax.swing.undo, \
- javax.tools, \
- javax.transaction; javax.transaction.xa; partial=true; mandatory:=partial, \
- javax.xml, \
- javax.xml.crypto, \
- javax.xml.crypto.dom, \
- javax.xml.crypto.dsig, \
- javax.xml.crypto.dsig.dom, \
- javax.xml.crypto.dsig.keyinfo, \
- javax.xml.crypto.dsig.spec, \
- javax.xml.datatype, \
- javax.xml.namespace, \
- javax.xml.parsers, \
- javax.xml.transform, \
- javax.xml.transform.dom, \
- javax.xml.transform.sax, \
- javax.xml.transform.stax, \
- javax.xml.transform.stream, \
- javax.xml.validation, \
- javax.xml.xpath, \
- org.ietf.jgss, \
- org.omg.CORBA, \
- org.omg.CORBA_2_3, \
- org.omg.CORBA_2_3.portable, \
- org.omg.CORBA.DynAnyPackage, \
- org.omg.CORBA.ORBPackage, \
- org.omg.CORBA.portable, \
- org.omg.CORBA.TypeCodePackage, \
- org.omg.CosNaming, \
- org.omg.CosNaming.NamingContextExtPackage, \
- org.omg.CosNaming.NamingContextPackage, \
- org.omg.Dynamic, \
- org.omg.DynamicAny, \
- org.omg.DynamicAny.DynAnyFactoryPackage, \
- org.omg.DynamicAny.DynAnyPackage, \
- org.omg.IOP, \
- org.omg.IOP.CodecFactoryPackage, \
- org.omg.IOP.CodecPackage, \
- org.omg.Messaging, \
- org.omg.PortableInterceptor, \
- org.omg.PortableInterceptor.ORBInitInfoPackage, \
- org.omg.PortableServer, \
- org.omg.PortableServer.CurrentPackage, \
- org.omg.PortableServer.POAManagerPackage, \
- org.omg.PortableServer.POAPackage, \
- org.omg.PortableServer.portable, \
- org.omg.PortableServer.ServantLocatorPackage, \
- org.omg.SendingContext, \
- org.omg.stub.java.rmi, \
- org.omg.stub.javax.management.remote.rmi, \
- org.w3c.dom, \
- org.w3c.dom.bootstrap, \
- org.w3c.dom.css, \
- org.w3c.dom.events, \
- org.w3c.dom.html, \
- org.w3c.dom.ls, \
- org.w3c.dom.ranges, \
- org.w3c.dom.stylesheets, \
- org.w3c.dom.traversal, \
- org.w3c.dom.views, \
- org.w3c.dom.xpath, \
- org.xml.sax, \
- org.xml.sax.ext, \
- org.xml.sax.helpers
diff --git a/karaf/assembly/src/main/filtered-resources/etc/org.apache.felix.karaf.features.cfg b/karaf/assembly/src/main/filtered-resources/etc/org.apache.felix.karaf.features.cfg
deleted file mode 100644
index a3d4a82..0000000
--- a/karaf/assembly/src/main/filtered-resources/etc/org.apache.felix.karaf.features.cfg
+++ /dev/null
@@ -1,28 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-#
-# Comma separated list of features repositories to register by default
-#
-featuresRepositories=mvn:org.apache.felix.karaf/apache-felix-karaf/${project.version}/xml/features
-
-#
-# Comma separated list of features to install at startup
-#
-featuresBoot=ssh,management
diff --git a/karaf/assembly/src/main/filtered-resources/etc/startup.properties b/karaf/assembly/src/main/filtered-resources/etc/startup.properties
deleted file mode 100644
index 0ed8095..0000000
--- a/karaf/assembly/src/main/filtered-resources/etc/startup.properties
+++ /dev/null
@@ -1,65 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-# This file allows you to control the start level of each bundle.
-#
-
-#
-# Startup core services like logging
-#
-org/ops4j/pax/url/pax-url-mvn/${pax.url.version}/pax-url-mvn-${pax.url.version}.jar=5
-org/ops4j/pax/url/pax-url-wrap/${pax.url.version}/pax-url-wrap-${pax.url.version}.jar=5
-org/ops4j/pax/logging/pax-logging-api/${pax.logging.version}/pax-logging-api-${pax.logging.version}.jar=8
-org/ops4j/pax/logging/pax-logging-service/${pax.logging.version}/pax-logging-service-${pax.logging.version}.jar=8
-org/apache/felix/org.apache.felix.configadmin/${felix.configadmin.version}/org.apache.felix.configadmin-${felix.configadmin.version}.jar=10
-org/apache/felix/org.apache.felix.prefs/${felix.prefs.version}/org.apache.felix.prefs-${felix.prefs.version}.jar=10
-org/apache/felix/org.apache.felix.fileinstall/${felix.fileinstall.version}/org.apache.felix.fileinstall-${felix.fileinstall.version}.jar=11
-
-#
-# The rest of the services..
-#
-org/apache/aries/blueprint/org.apache.aries.blueprint/${aries.blueprint.version}/org.apache.aries.blueprint-${aries.blueprint.version}.jar=20
-
-org/apache/felix/gogo/org.apache.felix.gogo.runtime/${felix.gogo.version}/org.apache.felix.gogo.runtime-${felix.gogo.version}.jar=30
-org/apache/felix/karaf/shell/org.apache.felix.karaf.shell.console/${project.version}/org.apache.felix.karaf.shell.console-${project.version}.jar=30
-org/apache/felix/karaf/deployer/org.apache.felix.karaf.deployer.spring/${project.version}/org.apache.felix.karaf.deployer.spring-${project.version}.jar=30
-org/apache/felix/karaf/deployer/org.apache.felix.karaf.deployer.blueprint/${project.version}/org.apache.felix.karaf.deployer.blueprint-${project.version}.jar=30
-org/apache/felix/karaf/deployer/org.apache.felix.karaf.deployer.features/${project.version}/org.apache.felix.karaf.deployer.features-${project.version}.jar=30
-org/apache/felix/karaf/shell/org.apache.felix.karaf.shell.osgi/${project.version}/org.apache.felix.karaf.shell.osgi-${project.version}.jar=30
-org/apache/felix/karaf/shell/org.apache.felix.karaf.shell.log/${project.version}/org.apache.felix.karaf.shell.log-${project.version}.jar=30
-org/apache/felix/karaf/shell/org.apache.felix.karaf.shell.config/${project.version}/org.apache.felix.karaf.shell.config-${project.version}.jar=30
-org/apache/felix/karaf/shell/org.apache.felix.karaf.shell.packages/${project.version}/org.apache.felix.karaf.shell.packages-${project.version}.jar=30
-org/apache/felix/karaf/shell/org.apache.felix.karaf.shell.commands/${project.version}/org.apache.felix.karaf.shell.commands-${project.version}.jar=30
-org/apache/felix/karaf/shell/org.apache.felix.karaf.shell.dev/${project.version}/org.apache.felix.karaf.shell.dev-${project.version}.jar=30
-org/apache/felix/karaf/jaas/org.apache.felix.karaf.jaas.config/${project.version}/org.apache.felix.karaf.jaas.config-${project.version}.jar=30
-org/apache/felix/karaf/jaas/org.apache.felix.karaf.jaas.modules/${project.version}/org.apache.felix.karaf.jaas.modules-${project.version}.jar=30
-org/apache/felix/karaf/admin/org.apache.felix.karaf.admin.core/${project.version}/org.apache.felix.karaf.admin.core-${project.version}.jar=30
-org/apache/felix/karaf/admin/org.apache.felix.karaf.admin.command/${project.version}/org.apache.felix.karaf.admin.command-${project.version}.jar=30
-org/apache/felix/karaf/admin/org.apache.felix.karaf.admin.management/${project.version}/org.apache.felix.karaf.admin.management-${project.version}.jar=30
-org/apache/felix/karaf/features/org.apache.felix.karaf.features.core/${project.version}/org.apache.felix.karaf.features.core-${project.version}.jar=30
-org/apache/felix/karaf/features/org.apache.felix.karaf.features.command/${project.version}/org.apache.felix.karaf.features.command-${project.version}.jar=30
-org/apache/felix/karaf/features/org.apache.felix.karaf.features.management/${project.version}/org.apache.felix.karaf.features.management-${project.version}.jar=30
-
-org/apache/felix/karaf/org.apache.felix.karaf.management/${project.version}/org.apache.felix.karaf.management-${project.version}.jar=30
-org/apache/aries/jmx/org.apache.aries.jmx/${aries.jmx.version}/org.apache.aries.jmx-${aries.jmx.version}.jar=30
-org/apache/aries/jmx/org.apache.aries.jmx.blueprint/${aries.jmx.version}/org.apache.aries.jmx.blueprint-${aries.jmx.version}.jar=30
-
-org/apache/mina/mina-core/${mina.version}/mina-core-${mina.version}.jar=30
-org/apache/sshd/sshd-core/${sshd.version}/sshd-core-${sshd.version}.jar=30
-org/apache/felix/karaf/shell/org.apache.felix.karaf.shell.ssh/${project.version}/org.apache.felix.karaf.shell.ssh-${project.version}.jar=30
diff --git a/karaf/assembly/src/main/filtered-resources/features.xml b/karaf/assembly/src/main/filtered-resources/features.xml
deleted file mode 100644
index a8036e6..0000000
--- a/karaf/assembly/src/main/filtered-resources/features.xml
+++ /dev/null
@@ -1,90 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
--->
-<features name="karaf-${project.version}">
- <feature name="spring" version="${spring.version}">
- <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.aopalliance/${aopalliance.version}</bundle>
- <bundle>mvn:org.springframework/spring-core/${spring.version}</bundle>
- <bundle>mvn:org.springframework/spring-beans/${spring.version}</bundle>
- <bundle>mvn:org.springframework/spring-aop/${spring.version}</bundle>
- <bundle>mvn:org.springframework/spring-context/${spring.version}</bundle>
- <bundle>mvn:org.springframework/spring-context-support/${spring.version}</bundle>
- </feature>
- <feature name="spring-dm" version="${spring.osgi.version}">
- <feature version="${spring.version}">spring</feature>
- <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.cglib/${cglib.version}</bundle>
- <bundle>mvn:org.springframework.osgi/spring-osgi-io/${spring.osgi.version}</bundle>
- <bundle>mvn:org.springframework.osgi/spring-osgi-core/${spring.osgi.version}</bundle>
- <bundle>mvn:org.springframework.osgi/spring-osgi-extender/${spring.osgi.version}</bundle>
- <bundle>mvn:org.springframework.osgi/spring-osgi-annotation/${spring.osgi.version}</bundle>
- <bundle>mvn:org.apache.felix.karaf.deployer/org.apache.felix.karaf.deployer.spring/${project.version}</bundle>
- </feature>
- <feature name="wrapper" version="${project.version}">
- <bundle>mvn:org.apache.felix.karaf.shell/org.apache.felix.karaf.shell.wrapper/${project.version}</bundle>
- </feature>
- <feature name="obr" version="${project.version}">
- <bundle>mvn:org.apache.felix/org.apache.felix.bundlerepository/${felix.bundlerepository.version}</bundle>
- <bundle>mvn:org.apache.felix.karaf.shell/org.apache.felix.karaf.shell.obr/${project.version}</bundle>
- </feature>
- <feature name="http" version="${project.version}">
- <config name="org.ops4j.pax.web">
- org.osgi.service.http.port=8181
- </config>
- <bundle>mvn:org.apache.geronimo.specs/geronimo-servlet_2.5_spec/${geronimo.servlet.version}</bundle>
- <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jetty-bundle/${jetty.bundle.version}</bundle>
- <bundle>mvn:org.ops4j.pax.web/pax-web-api/${pax.web.version}</bundle>
- <bundle>mvn:org.ops4j.pax.web/pax-web-spi/${pax.web.version}</bundle>
- <bundle>mvn:org.ops4j.pax.web/pax-web-runtime/${pax.web.version}</bundle>
- <bundle>mvn:org.ops4j.pax.web/pax-web-jetty/${pax.web.version}</bundle>
- </feature>
- <feature name="war" version="${project.version}">
- <feature version="${project.version}">http</feature>
- <bundle>mvn:org.ops4j.pax.web/pax-web-jsp/${pax.web.version}</bundle>
- <bundle>mvn:org.ops4j.pax.web/pax-web-extender-war/${pax.web.version}</bundle>
- <bundle>mvn:org.ops4j.pax.web/pax-web-extender-whiteboard/${pax.web.version}</bundle>
- <bundle>mvn:org.ops4j.pax.url/pax-url-war/${pax.url.version}</bundle>
- <bundle>mvn:org.apache.felix.karaf.deployer/org.apache.felix.karaf.deployer.war/${project.version}</bundle>
- </feature>
- <feature name="webconsole" version="${project.version}">
- <feature version="${project.version}">http</feature>
- <config name="org.apache.felix.karaf.webconsole">
- realm=karaf
- </config>
- <bundle>mvn:org.apache.felix/org.apache.felix.metatype/${felix.metatype.version}</bundle>
- <bundle>mvn:org.apache.felix.karaf.webconsole/org.apache.felix.karaf.webconsole.branding/${project.version}</bundle>
- <bundle>mvn:org.apache.felix/org.apache.felix.webconsole/${felix.webconsole.version}</bundle>
- <bundle>mvn:org.apache.felix.karaf.webconsole/org.apache.felix.karaf.webconsole.admin/${project.version}</bundle>
- <bundle>mvn:org.apache.felix.karaf.webconsole/org.apache.felix.karaf.webconsole.features/${project.version}</bundle>
- <bundle>mvn:org.apache.felix.karaf.webconsole/org.apache.felix.karaf.webconsole.gogo/${project.version}</bundle>
- </feature>
- <feature name="ssh" version="${project.version}">
- <config name="org.apache.felix.karaf.shell.ssh">
- sshPort=8101
- sshHost=0.0.0.0
- sshRealm=karaf
- </config>
- <bundle>mvn:org.apache.mina/mina-core/${mina.version}</bundle>
- <bundle>mvn:org.apache.sshd/sshd-core/${sshd.version}</bundle>
- <bundle>mvn:org.apache.felix.karaf.shell/org.apache.felix.karaf.shell.ssh/${project.version}</bundle>
- </feature>
- <feature name="management" version="${project.version}">
- <bundle>mvn:org.apache.felix.karaf/org.apache.felix.karaf.management/${project.version}</bundle>
- <bundle>mvn:org.apache.aries.jmx/org.apache.aries.jmx/${aries.jmx.version}</bundle>
- <bundle>mvn:org.apache.aries.jmx/org.apache.aries.jmx.blueprint/${aries.jmx.version}</bundle>
- </feature>
-</features>
diff --git a/karaf/client/NOTICE b/karaf/client/NOTICE
deleted file mode 100644
index d0afbf7..0000000
--- a/karaf/client/NOTICE
+++ /dev/null
@@ -1,19 +0,0 @@
-Apache Felix Karaf :: Client
-Copyright 2007-2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-
-
-III. License Summary
-- Apache License 2.0
-
-
diff --git a/karaf/client/pom.xml b/karaf/client/pom.xml
deleted file mode 100644
index bcaacba..0000000
--- a/karaf/client/pom.xml
+++ /dev/null
@@ -1,135 +0,0 @@
-<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/maven-v4_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.felix.karaf</groupId>
- <artifactId>karaf</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>org.apache.felix.karaf.client</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Client</name>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.sshd</groupId>
- <artifactId>sshd-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <_donotcopy>(CVS|.svn|config.properties)</_donotcopy>
- <Main-Class>org.apache.felix.karaf.client.Main</Main-Class>
- <!-- Do not use \r\n in the Class-Path header because the maven-bundle-plugin remove those -->
- <Class-Path>
- ../system/org/apache/sshd/sshd-core/${sshd.version}/sshd-core-${sshd.version}.jar ../system/org/apache/mina/mina-core/${mina.version}/mina-core-${mina.version}.jar ../system/org/apache/felix/karaf/shell/org.apache.felix.karaf.shell.console/${project.version}/org.apache.felix.karaf.shell.console-${project.version}.jar
- </Class-Path>
- <Bundle-Name>Apache Felix Karaf Shell Client</Bundle-Name>
- <Bundle-Description>Shell client bundle for Apache Felix Karaf.</Bundle-Description>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Private-Package>
- org.apache.felix.karaf.client;-split-package:=merge-first,
- org.slf4j;-split-package:=merge-first,
- org.slf4j.spi;-split-package:=merge-first,
- org.slf4j.helpers;-split-package:=merge-first,
- org.slf4j.impl;-split-package:=merge-first,
- META-INF;-split-package:=merge-first
- </Private-Package>
- <Import-Package>!*</Import-Package>
- </instructions>
- <unpackBundle>true</unpackBundle>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <artifactSet>
- <includes>
- <include>${project.groupId}:${project.artifactId}</include>
- <include>org.slf4j:slf4j-api</include>
- <include>org.slf4j:slf4j-nop</include>
- </includes>
- </artifactSet>
- <filters>
- <filter>
- <artifact>org.slf4j:slf4j-api</artifact>
- <excludes>
- <exclude>org/slf4j/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.slf4j:slf4j-nop</artifact>
- <excludes>
- <exclude>org/slf4j/**</exclude>
- </excludes>
- </filter>
- </filters>
- <createSourcesJar>${createSourcesJar}</createSourcesJar>
- <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
- <createDependencyReducedPom>true</createDependencyReducedPom>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- </resource>
- </resources>
- </build>
-
-
-</project>
diff --git a/karaf/client/src/main/java/org/apache/felix/karaf/client/Main.java b/karaf/client/src/main/java/org/apache/felix/karaf/client/Main.java
deleted file mode 100644
index f010b2b..0000000
--- a/karaf/client/src/main/java/org/apache/felix/karaf/client/Main.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.client;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-
-import jline.Terminal;
-import org.apache.felix.karaf.shell.console.jline.TerminalFactory;
-import org.apache.sshd.ClientChannel;
-import org.apache.sshd.ClientSession;
-import org.apache.sshd.SshClient;
-import org.apache.sshd.client.channel.ChannelShell;
-import org.apache.sshd.client.future.ConnectFuture;
-import org.apache.sshd.common.RuntimeSshException;
-
-import org.fusesource.jansi.AnsiConsole;
-import org.slf4j.impl.SimpleLogger;
-
-/**
- * A very simple
- */
-public class Main {
-
- public static void main(String[] args) throws Exception {
- String host = "localhost";
- int port = 8101;
- String user = "karaf";
- String password = "karaf";
- StringBuilder sb = new StringBuilder();
- int level = 1;
- int retryAttempts = 0;
- int retryDelay = 2;
-
- for (int i = 0; i < args.length; i++) {
- if (args[i].charAt(0) == '-') {
- if (args[i].equals("-a")) {
- port = Integer.parseInt(args[++i]);
- } else if (args[i].equals("-h")) {
- host = args[++i];
- } else if (args[i].equals("-u")) {
- user = args[++i];
- } else if (args[i].equals("-p")) {
- password = args[++i];
- } else if (args[i].equals("-v")) {
- level++;
- } else if (args[i].equals("-r")) {
- retryAttempts = Integer.parseInt(args[++i]);
- } else if (args[i].equals("-d")) {
- retryDelay = Integer.parseInt(args[++i]);
- } else if (args[i].equals("--help")) {
- System.out.println("Apache Felix Karaf client");
- System.out.println(" -a [port] specify the port to connect to");
- System.out.println(" -h [host] specify the host to connect to");
- System.out.println(" -u [user] specify the user name");
- System.out.println(" -p [password] specify the password");
- System.out.println(" --help shows this help message");
- System.out.println(" -v raise verbosity");
- System.out.println(" -r [attempts] retry connection establishment (up to attempts times)");
- System.out.println(" -d [delay] intra-retry delay (defaults to 2 seconds)");
- System.out.println(" [commands] commands to run");
- System.out.println("If no commands are specified, the client will be put in an interactive mode");
- System.exit(0);
- } else {
- System.err.println("Unknown option: " + args[i]);
- System.err.println("Run with --help for usage");
- System.exit(1);
- }
- } else {
- sb.append(args[i]);
- sb.append(' ');
- }
- }
- SimpleLogger.setLevel(level);
-
- SshClient client = null;
- Terminal terminal = null;
- try {
- client = SshClient.setUpDefaultClient();
- client.start();
- int retries = 0;
- ClientSession session = null;
- do {
- ConnectFuture future = client.connect(host, port);
- future.await();
- try {
- session = future.getSession();
- } catch (RuntimeSshException ex) {
- if (retries++ < retryAttempts) {
- Thread.sleep(retryDelay * 1000);
- System.out.println("retrying (attempt " + retries + ") ...");
- } else {
- throw ex;
- }
- }
- } while (session == null);
- if (!session.authPassword(user, password).await().isSuccess()) {
- throw new Exception("Authentication failure");
- }
- ClientChannel channel;
- if (sb.length() > 0) {
- channel = session.createChannel("exec");
- channel.setIn(new ByteArrayInputStream(sb.append("\n").toString().getBytes()));
- } else {
- terminal = new TerminalFactory().getTerminal();
- channel = session.createChannel("shell");
- channel.setIn(System.in);
- ((ChannelShell) channel).setupSensibleDefaultPty();
- }
- channel.setOut(AnsiConsole.wrapOutputStream(System.out));
- channel.setErr(AnsiConsole.wrapOutputStream(System.err));
- channel.open();
- channel.waitFor(ClientChannel.CLOSED, 0);
- } catch (Throwable t) {
- if (level > 1) {
- t.printStackTrace();
- } else {
- System.err.println(t.getMessage());
- }
- System.exit(1);
- } finally {
- try {
- client.stop();
- } catch (Throwable t) { }
- try {
- if (terminal != null) {
- terminal.restoreTerminal();
- }
- } catch (Throwable t) { }
- }
- System.exit(0);
- }
-
-}
diff --git a/karaf/client/src/main/java/org/slf4j/impl/SimpleLogger.java b/karaf/client/src/main/java/org/slf4j/impl/SimpleLogger.java
deleted file mode 100644
index 1bf6e2d..0000000
--- a/karaf/client/src/main/java/org/slf4j/impl/SimpleLogger.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.slf4j.impl;
-
-import org.slf4j.helpers.MarkerIgnoringBase;
-import org.slf4j.helpers.MessageFormatter;
-
-/**
- * A simple logger that can be controlled from the ssh client
- */
-public class SimpleLogger extends MarkerIgnoringBase {
-
- public static final int ERROR = 0;
- public static final int WARN = 1;
- public static final int INFO = 2;
- public static final int DEBUG = 3;
- public static final int TRACE = 4;
-
- private static int level = 0;
- private static long startTime = System.currentTimeMillis();
- public static final String LINE_SEPARATOR = System.getProperty("line.separator");
-
- public static int getLevel() {
- return level;
- }
-
- public static void setLevel(int level) {
- SimpleLogger.level = level;
- }
-
- private String name;
-
- SimpleLogger(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public boolean isTraceEnabled() {
- return isLogEnabled(TRACE);
- }
-
- public void trace(String msg) {
- log(TRACE, msg);
- }
-
- public void trace(String format, Object arg) {
- log(TRACE, format, arg);
- }
-
- public void trace(String format, Object arg1, Object arg2) {
- log(TRACE, format, arg1, arg2);
- }
-
- public void trace(String format, Object[] argArray) {
- log(TRACE, format, argArray);
- }
-
- public void trace(String msg, Throwable t) {
- log(TRACE, msg, t);
- }
-
- public boolean isDebugEnabled() {
- return isLogEnabled(DEBUG);
- }
-
- public void debug(String msg) {
- log(DEBUG, msg);
- }
-
- public void debug(String format, Object arg) {
- log(DEBUG, format, arg);
- }
-
- public void debug(String format, Object arg1, Object arg2) {
- log(DEBUG, format, arg1, arg2);
- }
-
- public void debug(String format, Object[] argArray) {
- log(DEBUG, format, argArray, null);
- }
-
- public void debug(String msg, Throwable t) {
- log(DEBUG, msg, t);
- }
-
- public boolean isInfoEnabled() {
- return isLogEnabled(INFO);
- }
-
- public void info(String msg) {
- log(INFO, msg);
- }
-
- public void info(String format, Object arg) {
- log(INFO, format, arg);
- }
-
- public void info(String format, Object arg1, Object arg2) {
- log(INFO, format, arg1, arg2);
- }
-
- public void info(String format, Object[] argArray) {
- log(INFO, format, argArray);
- }
-
- public void info(String msg, Throwable t) {
- log(INFO, msg, t);
- }
-
- public boolean isWarnEnabled() {
- return isLogEnabled(WARN);
- }
-
- public void warn(String msg) {
- log(WARN, msg);
- }
-
- public void warn(String format, Object arg) {
- log(WARN, format, arg);
- }
-
- public void warn(String format, Object arg1, Object arg2) {
- log(WARN, format, arg1, arg2);
- }
-
- public void warn(String format, Object[] argArray) {
- log(WARN, format, argArray);
- }
-
- public void warn(String msg, Throwable t) {
- log(WARN, msg, t);
- }
-
- public boolean isErrorEnabled() {
- return isLogEnabled(ERROR);
- }
-
- public void error(String msg) {
- log(ERROR, msg);
- }
-
- public void error(String format, Object arg) {
- log(ERROR, format, arg);
- }
-
- public void error(String format, Object arg1, Object arg2) {
- log(ERROR, format, arg1, arg2);
- }
-
- public void error(String format, Object[] argArray) {
- log(ERROR, format, argArray);
- }
-
- public void error(String msg, Throwable t) {
- log(ERROR, msg, t);
- }
-
- protected boolean isLogEnabled(int level) {
- return SimpleLogger.level >= level;
- }
-
- protected void log(int level, String msg) {
- if (isLogEnabled(level)) {
- doLog(level, msg, null);
- }
- }
-
- protected void log(int level, String format, Object arg) {
- if (isLogEnabled(level)) {
- String msg = MessageFormatter.format(format, arg);
- doLog(level, msg, null);
- }
- }
-
- protected void log(int level, String format, Object arg1, Object arg2) {
- if (isLogEnabled(level)) {
- String msg = MessageFormatter.format(format, arg1, arg2);
- doLog(level, msg, null);
- }
- }
-
- protected void log(int level, String format, Object[] args) {
- if (isLogEnabled(level)) {
- String msg = MessageFormatter.format(format, args);
- doLog(level, msg, null);
- }
- }
-
- protected void log(int level, String msg, Throwable t) {
- if (isLogEnabled(level)) {
- doLog(level, msg, t);
- }
- }
-
- protected void doLog(int level, String msg, Throwable t) {
- StringBuffer buf = new StringBuffer();
- long millis = System.currentTimeMillis();
- buf.append(millis - startTime);
- buf.append(" [");
- buf.append(Thread.currentThread().getName());
- buf.append("] ");
- switch (level) {
- case TRACE:
- buf.append("TRACE"); break;
- case DEBUG:
- buf.append("DEBUG"); break;
- case INFO:
- buf.append("INFO"); break;
- case WARN:
- buf.append("WARN"); break;
- case ERROR:
- buf.append("ERROR"); break;
- }
- buf.append(" ");
- buf.append(name);
- buf.append(" - ");
- buf.append(msg);
- buf.append(LINE_SEPARATOR);
- System.err.print(buf.toString());
- if (t != null) {
- t.printStackTrace(System.err);
- }
- System.err.flush();
- }
-}
diff --git a/karaf/client/src/main/resources/client.login.conf b/karaf/client/src/main/resources/client.login.conf
deleted file mode 100644
index 1e190f1..0000000
--- a/karaf/client/src/main/resources/client.login.conf
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-//
-// $Rev: 580717 $ $Date: 2007-09-30 14:47:55 +0200 (Sun, 30 Sep 2007) $
-//
-
-RshClient {
- org.apache.geronimo.shell.remote.client.auth.RemoteLoginModule required;
-};
diff --git a/karaf/demos/pom.xml b/karaf/demos/pom.xml
deleted file mode 100644
index 62c85ba..0000000
--- a/karaf/demos/pom.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<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/maven-v4_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.felix.karaf</groupId>
- <artifactId>karaf</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.demos</groupId>
- <artifactId>demos</artifactId>
- <packaging>pom</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Demos</name>
-
- <modules>
- <module>web</module>
- </modules>
-
-</project>
diff --git a/karaf/demos/web/NOTICE b/karaf/demos/web/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/demos/web/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/demos/web/pom.xml b/karaf/demos/web/pom.xml
deleted file mode 100644
index b19223f..0000000
--- a/karaf/demos/web/pom.xml
+++ /dev/null
@@ -1,159 +0,0 @@
-<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/maven-v4_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.felix.karaf.demos</groupId>
- <artifactId>demos</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.demos</groupId>
- <artifactId>web</artifactId>
- <packaging>war</packaging>
- <name>Apache Felix Karaf :: Demos :: web</name>
-
- <properties>
- <jetty.port>8080</jetty.port>
- <jetty.version>6.1.12rc1</jetty.version>
- <geronimo.servlet.version>1.1.2</geronimo.servlet.version>
-
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>org.apache.felix.karaf.main</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.jaas</groupId>
- <artifactId>org.apache.felix.karaf.jaas.boot</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>apache-felix-karaf</artifactId>
- <type>zip</type>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-servlet_2.5_spec</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <version>2.1-beta-1</version>
- <configuration>
- <warSourceDirectory>src/main/webapp/</warSourceDirectory>
- <webResources>
- <resource>
- <directory>target/karaf</directory>
- </resource>
- </webResources>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-plugin</artifactId>
- <version>${jetty.version}</version>
- <configuration>
- <connectors>
- <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
- <port>${jetty.port}</port>
- <maxIdleTime>60000</maxIdleTime>
- </connector>
- </connectors>
- <systemProperties>
- <!-- enable easy connection to JConsole -->
- <systemProperty>
- <name>com.sun.management.jmxremote</name>
- <value />
- </systemProperty>
- </systemProperties>
- <scanIntervalSeconds>10</scanIntervalSeconds>
- <webAppSourceDirectory>${project.build.directory}/${project.build.finalName}</webAppSourceDirectory>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>2.0</version>
- <executions>
- <execution>
- <id>unpack-unix</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>unpack</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>apache-felix-karaf</artifactId>
- <type>zip</type>
- <overWrite>true</overWrite>
- <outputDirectory>${project.build.directory}/karaf/WEB-INF</outputDirectory>
- <excludes>**/lib/*,**/*.txt,**/bin/*,**/demos/**,**/lib,**/bin,**/demos</excludes>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-karaf</id>
- <phase>process-resources</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <move todir="${project.build.directory}/karaf/WEB-INF/karaf">
- <fileset dir="${project.build.directory}/karaf/WEB-INF/apache-felix-karaf-${project.version}" />
- </move>
- </tasks>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
diff --git a/karaf/demos/web/src/main/java/org/apache/felix/karaf/web/WebAppListener.java b/karaf/demos/web/src/main/java/org/apache/felix/karaf/web/WebAppListener.java
deleted file mode 100644
index e988278..0000000
--- a/karaf/demos/web/src/main/java/org/apache/felix/karaf/web/WebAppListener.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.web;
-
-import java.io.File;
-
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
-import org.apache.felix.karaf.main.Main;
-
-public class WebAppListener implements ServletContextListener {
-
- private Main main;
-
- public void contextInitialized(ServletContextEvent sce) {
- try {
- System.err.println("contextInitialized");
- String root = new File(sce.getServletContext().getRealPath("/") + "WEB-INF/karaf").getAbsolutePath();
- System.err.println("Root: " + root);
- System.setProperty("karaf.home", root);
- System.setProperty("karaf.base", root);
- System.setProperty("karaf.startLocalConsole", "false");
- System.setProperty("karaf.startRemoteShell", "true");
- main = new Main(new String[0]);
- main.launch();
- } catch (Exception e) {
- main = null;
- e.printStackTrace();
- }
- }
-
- public void contextDestroyed(ServletContextEvent sce) {
- try {
- System.err.println("contextDestroyed");
- if (main != null) {
- main.destroy(false);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
-}
diff --git a/karaf/demos/web/src/main/webapp/WEB-INF/web.xml b/karaf/demos/web/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index 4e2471b..0000000
--- a/karaf/demos/web/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-
-<web-app version="2.4"
- xmlns="http://java.sun.com/xml/ns/j2ee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
- http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
-
- <description>Karaf Embedded Example</description>
- <display-name>Karaf Embedded Example</display-name>
-
- <listener>
- <listener-class>org.apache.felix.karaf.web.WebAppListener</listener-class>
- </listener>
-
- <welcome-file-list>
- <welcome-file>index.jsp</welcome-file>
- </welcome-file-list>
-
-</web-app>
diff --git a/karaf/demos/web/src/main/webapp/index.jsp b/karaf/demos/web/src/main/webapp/index.jsp
deleted file mode 100644
index ab13f33..0000000
--- a/karaf/demos/web/src/main/webapp/index.jsp
+++ /dev/null
@@ -1,34 +0,0 @@
-<%--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
---%>
-<html>
-<head>
-<title>Apache Felix Karaf</title>
-</head>
-<body>
-
-<h2>Welcome!</h2>
-
-<p>
-Welcome to Apache Karaf web application demo
-</p>
-
-<p>
-You can find more information about Karaf on the <a href="http://felix.apache.org/site/apache-felix-karaf.html">Apache Karaf Site</a>
-</p>
-</body>
-</html>
-
diff --git a/karaf/deployer/blueprint/NOTICE b/karaf/deployer/blueprint/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/deployer/blueprint/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/deployer/blueprint/pom.xml b/karaf/deployer/blueprint/pom.xml
deleted file mode 100644
index d3bc534..0000000
--- a/karaf/deployer/blueprint/pom.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-<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/maven-v4_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.felix.karaf.deployer</groupId>
- <artifactId>deployer</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.deployer</groupId>
- <artifactId>org.apache.felix.karaf.deployer.blueprint</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Blueprint Deployer</name>
-
- <description>This deployer transforms a plain blueprint xml file to a deployable bundle</description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.fileinstall</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <!-- Set the blueprint.graceperiod flag to false to allow the bundle to start
- See the blueprint config file -->
- <Bundle-SymbolicName>${project.artifactId};blueprint.graceperiod:=false</Bundle-SymbolicName>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Import-Package>!${project.artifactId}*,*</Import-Package>
- <Private-Package>org.apache.felix.karaf.deployer.blueprint</Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git a/karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/BlueprintDeploymentListener.java b/karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/BlueprintDeploymentListener.java
deleted file mode 100644
index e11e958..0000000
--- a/karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/BlueprintDeploymentListener.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.deployer.blueprint;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.net.URL;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.felix.fileinstall.ArtifactTransformer;
-import org.apache.felix.fileinstall.ArtifactUrlTransformer;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.SAXException;
-
-/**
- * A deployment listener that listens for spring xml applications
- * and creates bundles for these.
- */
-public class BlueprintDeploymentListener implements ArtifactUrlTransformer {
-
-
- private static final Log LOGGER = LogFactory.getLog(BlueprintDeploymentListener.class);
-
- private DocumentBuilderFactory dbf;
-
- public boolean canHandle(File artifact) {
- try {
- if (artifact.isFile() && artifact.getName().endsWith(".xml")) {
- Document doc = parse(artifact);
- String name = doc.getDocumentElement().getLocalName();
- String uri = doc.getDocumentElement().getNamespaceURI();
- if ("blueprint".equals(name) && "http://www.osgi.org/xmlns/blueprint/v1.0.0".equals(uri)) {
- return true;
- }
- }
- } catch (Exception e) {
- LOGGER.error("Unable to parse deployed file " + artifact.getAbsolutePath(), e);
- }
- return false;
- }
-
- public URL transform(URL artifact) {
- try {
- return new URL("blueprint", null, artifact.toString());
- } catch (Exception e) {
- LOGGER.error("Unable to build blueprint application bundle", e);
- return null;
- }
- }
-
- protected Document parse(File artifact) throws Exception {
- if (dbf == null) {
- dbf = DocumentBuilderFactory.newInstance();
- dbf.setNamespaceAware(true);
- }
- DocumentBuilder db = dbf.newDocumentBuilder();
- db.setErrorHandler(new ErrorHandler() {
- public void warning(SAXParseException exception) throws SAXException {
- }
- public void error(SAXParseException exception) throws SAXException {
- }
- public void fatalError(SAXParseException exception) throws SAXException {
- throw exception;
- }
- });
- return db.parse(artifact);
- }
-
-}
diff --git a/karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/BlueprintTransformer.java b/karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/BlueprintTransformer.java
deleted file mode 100644
index 1c5c0ed..0000000
--- a/karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/BlueprintTransformer.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.deployer.blueprint;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.Properties;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.jar.JarFile;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.zip.ZipEntry;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import org.osgi.framework.Constants;
-
-public class BlueprintTransformer {
-
- static Transformer transformer;
- static DocumentBuilderFactory dbf;
- static TransformerFactory tf;
-
-
- public static void transform(URL url, OutputStream os) throws Exception {
- // Build dom document
- Document doc = parse(url);
- // Heuristicly retrieve name and version
- String name = url.getPath();
- int idx = name.lastIndexOf('/');
- if (idx >= 0) {
- name = name.substring(idx + 1);
- }
- String[] str = extractNameVersionType(name);
- // Create manifest
- Manifest m = new Manifest();
- m.getMainAttributes().putValue("Manifest-Version", "2");
- m.getMainAttributes().putValue(Constants.BUNDLE_MANIFESTVERSION, "2");
- m.getMainAttributes().putValue(Constants.BUNDLE_SYMBOLICNAME, str[0]);
- m.getMainAttributes().putValue(Constants.BUNDLE_VERSION, str[1]);
- String importPkgs = getImportPackages(analyze(new DOMSource(doc)));
- if (importPkgs != null && importPkgs.length() > 0) {
- m.getMainAttributes().putValue(Constants.IMPORT_PACKAGE, importPkgs);
- }
- m.getMainAttributes().putValue(Constants.DYNAMICIMPORT_PACKAGE, "*");
- // Extract manifest entries from the DOM
- NodeList l = doc.getElementsByTagName("manifest");
- if (l != null) {
- for (int i = 0; i < l.getLength(); i++) {
- Element e = (Element) l.item(i);
- String text = e.getTextContent();
- Properties props = new Properties();
- props.load(new ByteArrayInputStream(text.trim().getBytes()));
- Enumeration en = props.propertyNames();
- while (en.hasMoreElements()) {
- String k = (String) en.nextElement();
- String v = props.getProperty(k);
- m.getMainAttributes().putValue(k, v);
- }
- e.getParentNode().removeChild(e);
- }
- }
-
- JarOutputStream out = new JarOutputStream(os);
- ZipEntry e = new ZipEntry(JarFile.MANIFEST_NAME);
- out.putNextEntry(e);
- m.write(out);
- out.closeEntry();
- e = new ZipEntry("OSGI-INF/");
- out.putNextEntry(e);
- e = new ZipEntry("OSGI-INF/blueprint/");
- out.putNextEntry(e);
- out.closeEntry();
- e = new ZipEntry("OSGI-INF/blueprint/" + name);
- out.putNextEntry(e);
- // Copy the new DOM
- if (tf == null) {
- tf = TransformerFactory.newInstance();
- }
- tf.newTransformer().transform(new DOMSource(doc), new StreamResult(out));
- out.closeEntry();
- out.close();
- }
-
- private static final String DEFAULT_VERSION = "0.0.0";
-
- private static final Pattern ARTIFACT_MATCHER = Pattern.compile("(.+)(?:-(\\d+)(?:\\.(\\d+)(?:\\.(\\d+))?)?(?:[^a-zA-Z0-9](.*))?)(?:\\.([^\\.]+))", Pattern.DOTALL);
- private static final Pattern FUZZY_MODIFIDER = Pattern.compile("(?:\\d+[.-])*(.*)", Pattern.DOTALL);
-
- public static String[] extractNameVersionType(String url) {
- Matcher m = ARTIFACT_MATCHER.matcher(url);
- if (!m.matches()) {
- return new String[] { url, DEFAULT_VERSION };
- }
- else {
- //System.err.println(m.groupCount());
- //for (int i = 1; i <= m.groupCount(); i++) {
- // System.err.println("Group " + i + ": " + m.group(i));
- //}
-
- StringBuffer v = new StringBuffer();
- String d1 = m.group(1);
- String d2 = m.group(2);
- String d3 = m.group(3);
- String d4 = m.group(4);
- String d5 = m.group(5);
- String d6 = m.group(6);
- if (d2 != null) {
- v.append(d2);
- if (d3 != null) {
- v.append('.');
- v.append(d3);
- if (d4 != null) {
- v.append('.');
- v.append(d4);
- if (d5 != null) {
- v.append(".");
- cleanupModifier(v, d5);
- }
- } else if (d5 != null) {
- v.append(".0.");
- cleanupModifier(v, d5);
- }
- } else if (d5 != null) {
- v.append(".0.0.");
- cleanupModifier(v, d5);
- }
- }
- return new String[] { d1, v.toString(), d6 };
- }
- }
-
- private static void cleanupModifier(StringBuffer result, String modifier) {
- Matcher m = FUZZY_MODIFIDER.matcher(modifier);
- if (m.matches()) {
- modifier = m.group(1);
- }
- for (int i = 0; i < modifier.length(); i++) {
- char c = modifier.charAt(i);
- if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '-') {
- result.append(c);
- }
- }
- }
-
- public static Set<String> analyze(Source source) throws Exception {
- if (transformer == null) {
- if (tf == null) {
- tf = TransformerFactory.newInstance();
- }
- Source s = new StreamSource(BlueprintTransformer.class.getResourceAsStream("extract.xsl"));
- transformer = tf.newTransformer(s);
- }
-
- Set<String> refers = new TreeSet<String>();
-
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- Result r = new StreamResult(bout);
- transformer.transform(source, r);
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- bout.close();
-
- BufferedReader br = new BufferedReader(new InputStreamReader(bin));
-
- String line = br.readLine();
- while (line != null) {
- line = line.trim();
- if (line.length() > 0) {
- String parts[] = line.split("\\s*,\\s*");
- for (int i = 0; i < parts.length; i++) {
- int n = parts[i].lastIndexOf('.');
- if (n > 0) {
- String pkg = parts[i].substring(0, n);
- if (!pkg.startsWith("java.")) {
- refers.add(pkg);
- }
- }
- }
- }
- line = br.readLine();
- }
- br.close();
- return refers;
- }
-
- protected static String getImportPackages(Set<String> packages) {
- StringBuilder sb = new StringBuilder();
- for (String pkg : packages) {
- if (sb.length() > 0) {
- sb.append(",");
- }
- sb.append(pkg);
- }
- return sb.toString();
- }
-
- protected static Document parse(URL url) throws Exception {
- if (dbf == null) {
- dbf = DocumentBuilderFactory.newInstance();
- dbf.setNamespaceAware(true);
- }
- DocumentBuilder db = dbf.newDocumentBuilder();
- return db.parse(url.toString());
- }
-
- protected static void copyInputStream(InputStream in, OutputStream out) throws Exception {
- byte[] buffer = new byte[4096];
- int len = in.read(buffer);
- while (len >= 0) {
- out.write(buffer, 0, len);
- len = in.read(buffer);
- }
- }
-}
diff --git a/karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/BlueprintURLHandler.java b/karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/BlueprintURLHandler.java
deleted file mode 100644
index ca6d344..0000000
--- a/karaf/deployer/blueprint/src/main/java/org/apache/felix/karaf/deployer/blueprint/BlueprintURLHandler.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.deployer.blueprint;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.service.url.AbstractURLStreamHandlerService;
-
-/**
- * A URL handler that will transform a JBI artifact to an OSGi bundle
- * on the fly. Needs to be registered in the OSGi registry.
- */
-public class BlueprintURLHandler extends AbstractURLStreamHandlerService {
-
- private static Log logger = LogFactory.getLog(BlueprintURLHandler.class);
-
- private static String SYNTAX = "blueprint: bp-xml-uri";
-
- private URL blueprintXmlURL;
-
- /**
- * Open the connection for the given URL.
- *
- * @param url the url from which to open a connection.
- * @return a connection on the specified URL.
- * @throws IOException if an error occurs or if the URL is malformed.
- */
- @Override
- public URLConnection openConnection(URL url) throws IOException {
- if (url.getPath() == null || url.getPath().trim().length() == 0) {
- throw new MalformedURLException ("Path can not be null or empty. Syntax: " + SYNTAX );
- }
- blueprintXmlURL = new URL(url.getPath());
-
- logger.debug("Blueprint xml URL is: [" + blueprintXmlURL + "]");
- return new Connection(url);
- }
-
- public URL getBlueprintXmlURL() {
- return blueprintXmlURL;
- }
-
- public class Connection extends URLConnection {
-
- public Connection(URL url) {
- super(url);
- }
-
- @Override
- public void connect() throws IOException {
- }
-
- @Override
- public InputStream getInputStream() throws IOException {
- try {
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- BlueprintTransformer.transform(blueprintXmlURL, os);
- os.close();
- return new ByteArrayInputStream(os.toByteArray());
- } catch (Exception e) {
- logger.error("Error opening blueprint xml url", e);
- throw (IOException) new IOException("Error opening blueprint xml url").initCause(e);
- }
- }
- }
-
-}
diff --git a/karaf/deployer/blueprint/src/main/resources/OSGI-INF/blueprint/blueprint-deployer.xml b/karaf/deployer/blueprint/src/main/resources/OSGI-INF/blueprint/blueprint-deployer.xml
deleted file mode 100644
index bc55e2e..0000000
--- a/karaf/deployer/blueprint/src/main/resources/OSGI-INF/blueprint/blueprint-deployer.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <service id="blueprintUrlHandler" interface="org.osgi.service.url.URLStreamHandlerService">
- <service-properties>
- <entry key="url.handler.protocol" value="blueprint"/>
- </service-properties>
- <bean class="org.apache.felix.karaf.deployer.blueprint.BlueprintURLHandler"/>
- </service>
-
- <bean id="blueprintDeploymentListener" class="org.apache.felix.karaf.deployer.blueprint.BlueprintDeploymentListener"/>
-
- <!-- Force a reference to the url handler above from the osgi registry to (try to) make sure
- the url handler is registered inside the framework. Else we can run into timing issues
- where fileinstall will use the featureDeploymentListener before the url can be actually
- used. In order to not block the bundle, the blueprint.graceperiod=false flag must be
- set on the SymbolicName osgi header -->
- <reference id="blueprintUrlHandlerRef" interface="org.osgi.service.url.URLStreamHandlerService" filter="url.handler.protocol=blueprint" />
-
- <service ref="blueprintDeploymentListener" auto-export="interfaces" depends-on="blueprintDeploymentListener" />
-
-</blueprint>
diff --git a/karaf/deployer/blueprint/src/main/resources/org/apache/felix/karaf/deployer/blueprint/extract.xsl b/karaf/deployer/blueprint/src/main/resources/org/apache/felix/karaf/deployer/blueprint/extract.xsl
deleted file mode 100644
index eb44e25..0000000
--- a/karaf/deployer/blueprint/src/main/resources/org/apache/felix/karaf/deployer/blueprint/extract.xsl
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0">
- <xsl:output method="text" />
-
- <xsl:template match="/">
-
- <!-- Match all attributes that holds a class or a comma delimited
- list of classes and print them -->
-
- <xsl:for-each select="
- //bp:bean/@class
- | //bp:service/@interface
- | //bp:service/bp:interfaces/bp:value/text()
- | //bp:reference/@interface
- | //bp:reference-list/@interface
- ">
- <xsl:value-of select="." />
- <xsl:text>
- </xsl:text>
- </xsl:for-each>
-
- <xsl:for-each select="
- //bp:bean/bp:argument/@type
- | //bp:list/@value-type
- | //bp:set/@value-type
- | //bp:array/@value-type
- | //bp:map/@key-type
- | //bp:map/@value-type
- ">
- <xsl:choose>
- <xsl:when test="contains(., '[')"><xsl:value-of select="substring-before(., '[')"/></xsl:when>
- <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
- </xsl:choose>
- <xsl:text>
- </xsl:text>
- </xsl:for-each>
-
- </xsl:template>
-
-
-</xsl:stylesheet>
-
diff --git a/karaf/deployer/blueprint/src/test/java/org/apache/felix/karaf/deployer/blueprint/BlueprintDeploymentListenerTest.java b/karaf/deployer/blueprint/src/test/java/org/apache/felix/karaf/deployer/blueprint/BlueprintDeploymentListenerTest.java
deleted file mode 100644
index 2351a0b..0000000
--- a/karaf/deployer/blueprint/src/test/java/org/apache/felix/karaf/deployer/blueprint/BlueprintDeploymentListenerTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.deployer.blueprint;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.jar.JarInputStream;
-
-import javax.xml.transform.dom.DOMSource;
-
-import junit.framework.TestCase;
-
-public class BlueprintDeploymentListenerTest extends TestCase {
-
- public void testPackagesExtraction() throws Exception {
- BlueprintDeploymentListener l = new BlueprintDeploymentListener();
- File f = new File(getClass().getClassLoader().getResource("test.xml").toURI());
- Set<String> pkgs = BlueprintTransformer.analyze(new DOMSource(BlueprintTransformer.parse(f.toURL())));
- assertNotNull(pkgs);
- assertEquals(1, pkgs.size());
- Iterator<String> it = pkgs.iterator();
- assertEquals("org.apache.aries.blueprint.sample", it.next());
- }
-
- public void testCustomManifest() throws Exception {
- File f = File.createTempFile("smx", ".jar");
- try {
- OutputStream os = new FileOutputStream(f);
- BlueprintTransformer.transform(getClass().getClassLoader().getResource("test.xml"), os);
- os.close();
- InputStream is = new FileInputStream(f);
- JarInputStream jar = new JarInputStream(is);
- jar.getManifest().write(System.err);
- is.close();
- } finally {
- f.delete();
- }
- }
-
- public void testVersions() {
- assertVersion("org.apache.servicemix.bundles.ant-1.7.0-1.0-m3-SNAPSHOT.jar",
- "org.apache.servicemix.bundles.ant-1.7.0", "1.0.0.m3-SNAPSHOT", "jar");
- assertVersion("org.apache.activemq.core-1.0-SNAPSHOT.xml",
- "org.apache.activemq.core", "1.0.0.SNAPSHOT", "xml");
- assertVersion("org.apache.activemq.core-1.0.0-SNAPSHOT.xml",
- "org.apache.activemq.core", "1.0.0.SNAPSHOT", "xml");
- assertVersion("org.apache.activemq.core-1.0.0.xml",
- "org.apache.activemq.core", "1.0.0", "xml");
- assertVersion("geronimo-servlet_2.5_spec-1.1.2.jar",
- "geronimo-servlet_2.5_spec", "1.1.2", "jar");
- assertVersion("spring-aop-2.5.1.jar",
- "spring-aop", "2.5.1", "jar");
- }
-
- private void assertVersion(String s, String... expectedParts) {
- String[] parts = BlueprintTransformer.extractNameVersionType(s);
- assertEquals(expectedParts.length, parts.length);
- for (int i = 0; i < expectedParts.length; i++) {
- assertEquals(expectedParts[i], parts[i]);
- }
- }
-
-}
diff --git a/karaf/deployer/blueprint/src/test/resources/test.xml b/karaf/deployer/blueprint/src/test/resources/test.xml
deleted file mode 100644
index 158e125..0000000
--- a/karaf/deployer/blueprint/src/test/resources/test.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
- default-availability="optional">
-
- <type-converters>
- <bean id="converter1" class="org.apache.aries.blueprint.sample.DateTypeConverter">
- <property name="format" value="yyyy.MM.dd"/>
- </bean>
- <bean id="converter2" class="org.apache.aries.blueprint.sample.CurrencyTypeConverter"/>
-
- <cm:property-placeholder id="property-placeholder" persistent-id="blueprint-sample">
- <cm:default-properties>
- <cm:property name="key.b" value="-1"/>
- </cm:default-properties>
- </cm:property-placeholder>
- </type-converters>
-
- <bean id="foo" class="org.apache.aries.blueprint.sample.Foo" init-method="init" destroy-method="destroy">
- <property name="a" value="5" />
- <property name="b" value="${key.b}" />
- <property name="bar" ref="bar" />
- <property name="currency">
- <value>PLN</value>
- </property>
- <property name="date">
- <value>2009.04.17</value>
- </property>
- </bean>
-
- <bean id="bar" class="org.apache.aries.blueprint.sample.Bar">
- <property name="value"><value>Hello FooBar</value></property>
- <property name="context" ref="bundleContext"/>
- <property name="list">
- <list>
- <value>a list element</value>
- <value type = "java.lang.Integer">5</value>
- </list>
- </property>
- </bean>
-
- <service ref="foo" auto-export="all-classes">
- <service-properties>
- <entry key="key" value="value"/>
- </service-properties>
- <registration-listener ref="fooRegistrationListener"
- registration-method="serviceRegistered"
- unregistration-method="serviceUnregistered"/>
- </service>
-
- <bean id="fooRegistrationListener" class="org.apache.aries.blueprint.sample.FooRegistrationListener"/>
-
- <reference id="ref" interface="org.apache.aries.blueprint.sample.Foo">
- </reference>
-
- <reference id="ref2" interface="org.apache.aries.blueprint.sample.InterfaceA" timeout="100">
- <reference-listener bind-method="bind" unbind-method="unbind" ref="bindingListener" />
- </reference>
-
- <bean id="bindingListener" class="org.apache.aries.blueprint.sample.BindingListener"/>
-
- <reference-list id="ref-list" interface="org.apache.aries.blueprint.sample.InterfaceA">
- <reference-listener bind-method="bind" unbind-method="unbind" ref="listBindingListener" />
- </reference-list>
-
- <bean id="listBindingListener" class="org.apache.aries.blueprint.sample.BindingListener"/>
-
-</blueprint>
-
diff --git a/karaf/deployer/features/NOTICE b/karaf/deployer/features/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/deployer/features/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/deployer/features/pom.xml b/karaf/deployer/features/pom.xml
deleted file mode 100644
index dd1aad3..0000000
--- a/karaf/deployer/features/pom.xml
+++ /dev/null
@@ -1,89 +0,0 @@
-<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/maven-v4_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.felix.karaf.deployer</groupId>
- <artifactId>deployer</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.deployer</groupId>
- <artifactId>org.apache.felix.karaf.deployer.features</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Features Deployer</name>
-
- <description>This deployer can deploy features descriptor on the fly</description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.features</groupId>
- <artifactId>org.apache.felix.karaf.features.core</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.fileinstall</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <!-- Set the blueprint.graceperiod flag to false to allow the bundle to start
- See the blueprint config file -->
- <Bundle-SymbolicName>${project.artifactId};blueprint.graceperiod:=false</Bundle-SymbolicName>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Import-Package>!${project.artifactId}*,*</Import-Package>
- <Private-Package>org.apache.felix.karaf.deployer.features</Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git a/karaf/deployer/features/src/main/java/org/apache/felix/karaf/deployer/features/FeatureDeploymentListener.java b/karaf/deployer/features/src/main/java/org/apache/felix/karaf/deployer/features/FeatureDeploymentListener.java
deleted file mode 100644
index 53789fd..0000000
--- a/karaf/deployer/features/src/main/java/org/apache/felix/karaf/deployer/features/FeatureDeploymentListener.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.deployer.features;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.*;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.felix.fileinstall.ArtifactUrlTransformer;
-import org.apache.felix.karaf.features.Feature;
-import org.apache.felix.karaf.features.FeaturesService;
-import org.apache.felix.karaf.features.Repository;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleListener;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * A deployment listener able to hot deploy a feature descriptor
- */
-public class FeatureDeploymentListener implements ArtifactUrlTransformer, BundleListener {
-
- public static final String FEATURE_PATH = "org.apache.felix.karaf.shell.features";
-
- private static final Log LOGGER = LogFactory.getLog(FeatureDeploymentListener.class);
-
- private DocumentBuilderFactory dbf;
- private FeaturesService featuresService;
- private BundleContext bundleContext;
-
- public void setFeaturesService(FeaturesService featuresService) {
- this.featuresService = featuresService;
- }
-
- public FeaturesService getFeaturesService() {
- return featuresService;
- }
-
- public BundleContext getBundleContext() {
- return bundleContext;
- }
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- public void init() throws Exception {
- bundleContext.addBundleListener(this);
- for (Bundle bundle : bundleContext.getBundles()) {
- if (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.STARTING
- || bundle.getState() == Bundle.ACTIVE)
- bundleChanged(new BundleEvent(BundleEvent.RESOLVED, bundle));
- }
- }
-
- public void destroy() throws Exception {
- bundleContext.removeBundleListener(this);
- }
-
- public boolean canHandle(File artifact) {
- try {
- if (artifact.isFile() && artifact.getName().endsWith(".xml")) {
- Document doc = parse(artifact);
- String name = doc.getDocumentElement().getLocalName();
- String uri = doc.getDocumentElement().getNamespaceURI();
- if ("features".equals(name) && (uri == null || "".equals(uri))) {
- return true;
- }
- }
- } catch (Exception e) {
- LOGGER.error("Unable to parse deployed file " + artifact.getAbsolutePath(), e);
- }
- return false;
- }
-
- public URL transform(URL artifact) {
- // We can't really install the feature right now and just return nothing.
- // We would not be aware of the fact that the bundle has been uninstalled
- // and therefore require the feature to be uninstalled.
- // So instead, create a fake bundle with the file inside, which will be listened by
- // this deployer: installation / uninstallation of the feature will be done
- // while the bundle is installed / uninstalled.
- try {
- return new URL("feature", null, artifact.toString());
- } catch (Exception e) {
- LOGGER.error("Unable to build feature bundle", e);
- return null;
- }
- }
-
- public void bundleChanged(BundleEvent bundleEvent) {
- Bundle bundle = bundleEvent.getBundle();
- if (bundleEvent.getType() == BundleEvent.RESOLVED) {
- try {
- List<URL> urls = new ArrayList<URL>();
- Enumeration featuresUrlEnumeration = bundle.findEntries("/META-INF/" + FEATURE_PATH + "/", "*.xml", false);
- while (featuresUrlEnumeration != null && featuresUrlEnumeration.hasMoreElements()) {
- URL url = (URL) featuresUrlEnumeration.nextElement();
- try {
- featuresService.addRepository(url.toURI());
- for (Repository repo : featuresService.listRepositories()) {
- if (repo.getURI().equals(url.toURI())) {
- Set<Feature> features = new HashSet<Feature>(Arrays.asList(repo.getFeatures()));
- featuresService.installFeatures(features, EnumSet.noneOf(FeaturesService.Option.class));
- }
- }
- urls.add(url);
- } catch (Exception e) {
- LOGGER.error("Unable to install features", e);
- }
- }
- synchronized (this) {
- File file = bundleContext.getDataFile("FeatureDeploymentListener.cfg");
- if (file != null) {
- Properties props = new Properties();
- if (file.exists()) {
- InputStream input = new FileInputStream(file);
- try {
- props.load(input);
- } finally {
- input.close();
- }
- }
- String prefix = bundle.getSymbolicName() + "-" + bundle.getVersion();
- props.put(prefix + ".count", Integer.toString(urls.size()));
- for (int i = 0; i < urls.size(); i++) {
- props.put(prefix + ".url." + i, urls.get(i).toExternalForm());
- }
- OutputStream output = new FileOutputStream(file);
- try {
- props.store(output, null);
- } finally {
- output.close();
- }
- }
- }
- } catch (Exception e) {
- LOGGER.error("Unable to install deployed features for bundle: " + bundle.getSymbolicName() + " - " + bundle.getVersion(), e);
- }
- } else if (bundleEvent.getType() == BundleEvent.UNINSTALLED) {
- try {
- synchronized (this) {
- File file = bundleContext.getDataFile("FeatureDeploymentListener.cfg");
- if (file != null) {
- Properties props = new Properties();
- if (file.exists()) {
- InputStream input = new FileInputStream(file);
- try {
- props.load(input);
- } finally {
- input.close();
- }
- }
- String prefix = bundle.getSymbolicName() + "-" + bundle.getVersion();
- String countStr = (String) props.get(prefix + ".count");
- if (countStr != null) {
- int count = Integer.parseInt(countStr);
- for (int i = 0; i < count; i++) {
- URL url = new URL((String) props.get(prefix + ".url." + i));
- for (Repository repo : featuresService.listRepositories()) {
- try {
- if (repo.getURI().equals(url.toURI())) {
- for (Feature f : repo.getFeatures()) {
- try {
- featuresService.uninstallFeature(f.getName(), f.getVersion());
- } catch (Exception e) {
- LOGGER.error("Unable to uninstall feature: " + f.getName(), e);
- }
- }
- }
- } catch (Exception e) {
- LOGGER.error("Unable to uninstall features: " + url, e);
- }
- }
- try {
- featuresService.removeRepository(url.toURI());
- } catch (URISyntaxException e) {
- LOGGER.error("Unable to remove repository: " + url, e);
- }
- }
- }
- for (Iterator<Object> it = props.keySet().iterator(); it.hasNext();) {
- if (it.next().toString().startsWith(prefix + ".")) {
- it.remove();
- }
- }
- OutputStream output = new FileOutputStream(file);
- try {
- props.store(output, null);
- } finally {
- output.close();
- }
- }
- }
- } catch (Exception e) {
- LOGGER.error("Unable to uninstall deployed features for bundle: " + bundle.getSymbolicName() + " - " + bundle.getVersion(), e);
- }
- }
- }
-
- protected Document parse(File artifact) throws Exception {
- if (dbf == null) {
- dbf = DocumentBuilderFactory.newInstance();
- dbf.setNamespaceAware(true);
- }
- DocumentBuilder db = dbf.newDocumentBuilder();
- db.setErrorHandler(new ErrorHandler() {
- public void warning(SAXParseException exception) throws SAXException {
- }
- public void error(SAXParseException exception) throws SAXException {
- }
- public void fatalError(SAXParseException exception) throws SAXException {
- throw exception;
- }
- });
- return db.parse(artifact);
- }
-
-}
diff --git a/karaf/deployer/features/src/main/java/org/apache/felix/karaf/deployer/features/FeatureTransformer.java b/karaf/deployer/features/src/main/java/org/apache/felix/karaf/deployer/features/FeatureTransformer.java
deleted file mode 100644
index 050bec3..0000000
--- a/karaf/deployer/features/src/main/java/org/apache/felix/karaf/deployer/features/FeatureTransformer.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.deployer.features;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-import java.util.jar.JarFile;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.zip.ZipEntry;
-
-import org.osgi.framework.Constants;
-
-/**
- * Transform a feature descriptor into an osgi bundle
- */
-public class FeatureTransformer {
-
- public static void transform(URL url, OutputStream os) throws Exception {
- // Heuristicly retrieve name and version
- String name = url.getPath();
- int idx = name.lastIndexOf('/');
- if (idx >= 0) {
- name = name.substring(idx + 1);
- }
- String[] str = extractNameVersionType(name);
- // Create manifest
- Manifest m = new Manifest();
- m.getMainAttributes().putValue("Manifest-Version", "2");
- m.getMainAttributes().putValue(Constants.BUNDLE_MANIFESTVERSION, "2");
- m.getMainAttributes().putValue(Constants.BUNDLE_SYMBOLICNAME, str[0]);
- m.getMainAttributes().putValue(Constants.BUNDLE_VERSION, str[1]);
- // Put content
- JarOutputStream out = new JarOutputStream(os);
- ZipEntry e = new ZipEntry(JarFile.MANIFEST_NAME);
- out.putNextEntry(e);
- m.write(out);
- out.closeEntry();
- e = new ZipEntry("META-INF/");
- out.putNextEntry(e);
- e = new ZipEntry("META-INF/" + FeatureDeploymentListener.FEATURE_PATH + "/");
- out.putNextEntry(e);
- out.closeEntry();
- e = new ZipEntry("META-INF/" + FeatureDeploymentListener.FEATURE_PATH + "/" + name);
- out.putNextEntry(e);
- InputStream fis = url.openStream();
- try {
- copyInputStream(fis, out);
- } finally {
- fis.close();
- }
- out.closeEntry();
- out.close();
- os.close();
- }
-
- private static void copyInputStream(InputStream in, OutputStream out) throws IOException {
- byte[] buffer = new byte[8192];
- int len = in.read(buffer);
- while (len >= 0) {
- out.write(buffer, 0, len);
- len = in.read(buffer);
- }
- }
-
- private static final String DEFAULT_VERSION = "0.0.0";
-
- private static final Pattern ARTIFACT_MATCHER = Pattern.compile("(.+)(?:-(\\d+)(?:\\.(\\d+)(?:\\.(\\d+))?)?(?:[^a-zA-Z0-9](.*))?)(?:\\.([^\\.]+))", Pattern.DOTALL);
- private static final Pattern FUZZY_MODIFIDER = Pattern.compile("(?:\\d+[.-])*(.*)", Pattern.DOTALL);
-
- public static String[] extractNameVersionType(String url) {
- Matcher m = ARTIFACT_MATCHER.matcher(url);
- if (!m.matches()) {
- return new String[] { url, DEFAULT_VERSION };
- }
- else {
- //System.err.println(m.groupCount());
- //for (int i = 1; i <= m.groupCount(); i++) {
- // System.err.println("Group " + i + ": " + m.group(i));
- //}
-
- StringBuffer v = new StringBuffer();
- String d1 = m.group(1);
- String d2 = m.group(2);
- String d3 = m.group(3);
- String d4 = m.group(4);
- String d5 = m.group(5);
- String d6 = m.group(6);
- if (d2 != null) {
- v.append(d2);
- if (d3 != null) {
- v.append('.');
- v.append(d3);
- if (d4 != null) {
- v.append('.');
- v.append(d4);
- if (d5 != null) {
- v.append(".");
- cleanupModifier(v, d5);
- }
- } else if (d5 != null) {
- v.append(".0.");
- cleanupModifier(v, d5);
- }
- } else if (d5 != null) {
- v.append(".0.0.");
- cleanupModifier(v, d5);
- }
- }
- return new String[] { d1, v.toString(), d6 };
- }
- }
-
- private static void cleanupModifier(StringBuffer result, String modifier) {
- Matcher m = FUZZY_MODIFIDER.matcher(modifier);
- if (m.matches()) {
- modifier = m.group(1);
- }
- for (int i = 0; i < modifier.length(); i++) {
- char c = modifier.charAt(i);
- if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '-') {
- result.append(c);
- }
- }
- }
-
-}
diff --git a/karaf/deployer/features/src/main/java/org/apache/felix/karaf/deployer/features/FeatureURLHandler.java b/karaf/deployer/features/src/main/java/org/apache/felix/karaf/deployer/features/FeatureURLHandler.java
deleted file mode 100644
index f3dad87..0000000
--- a/karaf/deployer/features/src/main/java/org/apache/felix/karaf/deployer/features/FeatureURLHandler.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.deployer.features;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.service.url.AbstractURLStreamHandlerService;
-
-/**
- * URL handler for features
- */
-public class FeatureURLHandler extends AbstractURLStreamHandlerService {
-
- private static Log logger = LogFactory.getLog(FeatureURLHandler.class);
-
- private static String SYNTAX = "feature: xml-uri";
-
- private URL featureXmlURL;
-
- /**
- * Open the connection for the given URL.
- *
- * @param url the url from which to open a connection.
- * @return a connection on the specified URL.
- * @throws java.io.IOException if an error occurs or if the URL is malformed.
- */
- @Override
- public URLConnection openConnection(URL url) throws IOException {
- if (url.getPath() == null || url.getPath().trim().length() == 0) {
- throw new MalformedURLException("Path can not be null or empty. Syntax: " + SYNTAX );
- }
- featureXmlURL = new URL(url.getPath());
-
- logger.debug("Blueprint xml URL is: [" + featureXmlURL + "]");
- return new Connection(url);
- }
-
- public URL getFeatureXmlURL() {
- return featureXmlURL;
- }
-
- public class Connection extends URLConnection {
-
- public Connection(URL url) {
- super(url);
- }
-
- @Override
- public void connect() throws IOException {
- }
-
- @Override
- public InputStream getInputStream() throws IOException {
- try {
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- FeatureTransformer.transform(featureXmlURL, os);
- os.close();
- return new ByteArrayInputStream(os.toByteArray());
- } catch (Exception e) {
- logger.error("Error opening blueprint xml url", e);
- throw (IOException) new IOException("Error opening blueprint xml url").initCause(e);
- }
- }
- }
-
-
-}
diff --git a/karaf/deployer/features/src/main/resources/OSGI-INF/blueprint/features-deployer.xml b/karaf/deployer/features/src/main/resources/OSGI-INF/blueprint/features-deployer.xml
deleted file mode 100644
index 001f18e..0000000
--- a/karaf/deployer/features/src/main/resources/OSGI-INF/blueprint/features-deployer.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- default-activation="lazy">
-
- <service id="featureUrlHandler" interface="org.osgi.service.url.URLStreamHandlerService">
- <service-properties>
- <entry key="url.handler.protocol" value="feature"/>
- </service-properties>
- <bean class="org.apache.felix.karaf.deployer.features.FeatureURLHandler"/>
- </service>
-
- <bean id="featureDeploymentListener" class="org.apache.felix.karaf.deployer.features.FeatureDeploymentListener"
- init-method="init" destroy-method="destroy" activation="lazy">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- <property name="featuresService">
- <reference interface="org.apache.felix.karaf.features.FeaturesService"/>
- </property>
- </bean>
-
- <!-- Force a reference to the url handler above from the osgi registry to (try to) make sure
- the url handler is registered inside the framework. Else we can run into timing issues
- where fileinstall will use the featureDeploymentListener before the url can be actually
- used. In order to not block the bundle, the blueprint.graceperiod=false flag must be
- set on the SymbolicName osgi header -->
- <reference id="featureUrlHandlerRef" interface="org.osgi.service.url.URLStreamHandlerService" filter="url.handler.protocol=feature" />
-
- <service ref="featureDeploymentListener" auto-export="interfaces" depends-on="featureUrlHandlerRef"/>
-
-</blueprint>
diff --git a/karaf/deployer/pom.xml b/karaf/deployer/pom.xml
deleted file mode 100644
index ba03a2d..0000000
--- a/karaf/deployer/pom.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<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/maven-v4_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.felix.karaf</groupId>
- <artifactId>karaf</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.deployer</groupId>
- <artifactId>deployer</artifactId>
- <packaging>pom</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Deployer</name>
-
- <modules>
- <module>spring</module>
- <module>blueprint</module>
- <module>features</module>
- <module>war</module>
- </modules>
-
-</project>
diff --git a/karaf/deployer/spring/NOTICE b/karaf/deployer/spring/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/deployer/spring/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/deployer/spring/pom.xml b/karaf/deployer/spring/pom.xml
deleted file mode 100644
index 51c09d2..0000000
--- a/karaf/deployer/spring/pom.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-<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/maven-v4_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.felix.karaf.deployer</groupId>
- <artifactId>deployer</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.deployer</groupId>
- <artifactId>org.apache.felix.karaf.deployer.spring</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Spring Deployer</name>
-
- <description>This deployer transforms a plain spring xml file to a deployable bundle</description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.fileinstall</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <!-- Set the blueprint.graceperiod flag to false to allow the bundle to start
- See the blueprint config file -->
- <Bundle-SymbolicName>${project.artifactId};blueprint.graceperiod:=false</Bundle-SymbolicName>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Import-Package>!${project.artifactId}*,*</Import-Package>
- <Private-Package>org.apache.felix.karaf.deployer.spring</Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git a/karaf/deployer/spring/src/main/java/org/apache/felix/karaf/deployer/spring/SpringDeploymentListener.java b/karaf/deployer/spring/src/main/java/org/apache/felix/karaf/deployer/spring/SpringDeploymentListener.java
deleted file mode 100644
index 6cb15f2..0000000
--- a/karaf/deployer/spring/src/main/java/org/apache/felix/karaf/deployer/spring/SpringDeploymentListener.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.deployer.spring;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.net.URL;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.felix.fileinstall.ArtifactTransformer;
-import org.apache.felix.fileinstall.ArtifactUrlTransformer;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.SAXException;
-
-/**
- * A deployment listener that listens for spring xml applications
- * and creates bundles for these.
- */
-public class SpringDeploymentListener implements ArtifactUrlTransformer {
-
- private static final Log LOGGER = LogFactory.getLog(SpringDeploymentListener.class);
-
- private DocumentBuilderFactory dbf;
-
- public boolean canHandle(File artifact) {
- try {
- if (artifact.isFile() && artifact.getName().endsWith(".xml")) {
- Document doc = parse(artifact);
- String name = doc.getDocumentElement().getLocalName();
- String uri = doc.getDocumentElement().getNamespaceURI();
- if ("beans".equals(name) && "http://www.springframework.org/schema/beans".equals(uri)) {
- return true;
- }
- }
- } catch (Exception e) {
- LOGGER.error("Unable to parse deployed file " + artifact.getAbsolutePath(), e);
- }
- return false;
- }
-
- public URL transform(URL artifact) {
- try {
- return new URL("spring", null, artifact.toString());
- } catch (Exception e) {
- LOGGER.error("Unable to build spring application bundle", e);
- return null;
- }
- }
-
- protected Document parse(File artifact) throws Exception {
- if (dbf == null) {
- dbf = DocumentBuilderFactory.newInstance();
- dbf.setNamespaceAware(true);
- }
- DocumentBuilder db = dbf.newDocumentBuilder();
- db.setErrorHandler(new ErrorHandler() {
- public void warning(SAXParseException exception) throws SAXException {
- }
- public void error(SAXParseException exception) throws SAXException {
- }
- public void fatalError(SAXParseException exception) throws SAXException {
- throw exception;
- }
- });
- return db.parse(artifact);
- }
-
-}
diff --git a/karaf/deployer/spring/src/main/java/org/apache/felix/karaf/deployer/spring/SpringTransformer.java b/karaf/deployer/spring/src/main/java/org/apache/felix/karaf/deployer/spring/SpringTransformer.java
deleted file mode 100644
index 7564ab0..0000000
--- a/karaf/deployer/spring/src/main/java/org/apache/felix/karaf/deployer/spring/SpringTransformer.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.deployer.spring;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.Properties;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.jar.JarFile;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.zip.ZipEntry;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import org.osgi.framework.Constants;
-
-public class SpringTransformer {
-
- static Transformer transformer;
- static DocumentBuilderFactory dbf;
- static TransformerFactory tf;
-
-
- public static void transform(URL url, OutputStream os) throws Exception {
- // Build dom document
- Document doc = parse(url);
- // Heuristicly retrieve name and version
- String name = url.getPath();
- int idx = name.lastIndexOf('/');
- if (idx >= 0) {
- name = name.substring(idx + 1);
- }
- String[] str = extractNameVersionType(name);
- // Create manifest
- Manifest m = new Manifest();
- m.getMainAttributes().putValue("Manifest-Version", "2");
- m.getMainAttributes().putValue(Constants.BUNDLE_MANIFESTVERSION, "2");
- m.getMainAttributes().putValue(Constants.BUNDLE_SYMBOLICNAME, str[0]);
- m.getMainAttributes().putValue(Constants.BUNDLE_VERSION, str[1]);
- m.getMainAttributes().putValue("Spring-Context", "*;publish-context:=false;create-asynchronously:=true");
- String importPkgs = getImportPackages(analyze(new DOMSource(doc)));
- if (importPkgs != null && importPkgs.length() > 0) {
- m.getMainAttributes().putValue(Constants.IMPORT_PACKAGE, importPkgs);
- }
- m.getMainAttributes().putValue(Constants.DYNAMICIMPORT_PACKAGE, "*");
- // Extract manifest entries from the DOM
- NodeList l = doc.getElementsByTagName("manifest");
- if (l != null) {
- for (int i = 0; i < l.getLength(); i++) {
- Element e = (Element) l.item(i);
- String text = e.getTextContent();
- Properties props = new Properties();
- props.load(new ByteArrayInputStream(text.trim().getBytes()));
- Enumeration en = props.propertyNames();
- while (en.hasMoreElements()) {
- String k = (String) en.nextElement();
- String v = props.getProperty(k);
- m.getMainAttributes().putValue(k, v);
- }
- e.getParentNode().removeChild(e);
- }
- }
-
- JarOutputStream out = new JarOutputStream(os);
- ZipEntry e = new ZipEntry(JarFile.MANIFEST_NAME);
- out.putNextEntry(e);
- m.write(out);
- out.closeEntry();
- e = new ZipEntry("META-INF/");
- out.putNextEntry(e);
- e = new ZipEntry("META-INF/spring/");
- out.putNextEntry(e);
- out.closeEntry();
- e = new ZipEntry("META-INF/spring/" + name);
- out.putNextEntry(e);
- // Copy the new DOM
- if (tf == null) {
- tf = TransformerFactory.newInstance();
- }
- tf.newTransformer().transform(new DOMSource(doc), new StreamResult(out));
- out.closeEntry();
- out.close();
- }
-
- private static final String DEFAULT_VERSION = "0.0.0";
-
- private static final Pattern ARTIFACT_MATCHER = Pattern.compile("(.+)(?:-(\\d+)(?:\\.(\\d+)(?:\\.(\\d+))?)?(?:[^a-zA-Z0-9](.*))?)(?:\\.([^\\.]+))", Pattern.DOTALL);
- private static final Pattern FUZZY_MODIFIDER = Pattern.compile("(?:\\d+[.-])*(.*)", Pattern.DOTALL);
-
- public static String[] extractNameVersionType(String url) {
- Matcher m = ARTIFACT_MATCHER.matcher(url);
- if (!m.matches()) {
- return new String[] { url, DEFAULT_VERSION };
- }
- else {
- //System.err.println(m.groupCount());
- //for (int i = 1; i <= m.groupCount(); i++) {
- // System.err.println("Group " + i + ": " + m.group(i));
- //}
-
- StringBuffer v = new StringBuffer();
- String d1 = m.group(1);
- String d2 = m.group(2);
- String d3 = m.group(3);
- String d4 = m.group(4);
- String d5 = m.group(5);
- String d6 = m.group(6);
- if (d2 != null) {
- v.append(d2);
- if (d3 != null) {
- v.append('.');
- v.append(d3);
- if (d4 != null) {
- v.append('.');
- v.append(d4);
- if (d5 != null) {
- v.append(".");
- cleanupModifier(v, d5);
- }
- } else if (d5 != null) {
- v.append(".0.");
- cleanupModifier(v, d5);
- }
- } else if (d5 != null) {
- v.append(".0.0.");
- cleanupModifier(v, d5);
- }
- }
- return new String[] { d1, v.toString(), d6 };
- }
- }
-
- private static void cleanupModifier(StringBuffer result, String modifier) {
- Matcher m = FUZZY_MODIFIDER.matcher(modifier);
- if (m.matches()) {
- modifier = m.group(1);
- }
- for (int i = 0; i < modifier.length(); i++) {
- char c = modifier.charAt(i);
- if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '-') {
- result.append(c);
- }
- }
- }
-
- public static Set<String> analyze(Source source) throws Exception {
- if (transformer == null) {
- if (tf == null) {
- tf = TransformerFactory.newInstance();
- }
- Source s = new StreamSource(SpringTransformer.class.getResourceAsStream("extract.xsl"));
- transformer = tf.newTransformer(s);
- }
-
- Set<String> refers = new TreeSet<String>();
-
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- Result r = new StreamResult(bout);
- transformer.transform(source, r);
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- bout.close();
-
- BufferedReader br = new BufferedReader(new InputStreamReader(bin));
-
- String line = br.readLine();
- while (line != null) {
- line = line.trim();
- if (line.length() > 0) {
- String parts[] = line.split("\\s*,\\s*");
- for (int i = 0; i < parts.length; i++) {
- int n = parts[i].lastIndexOf('.');
- if (n > 0) {
- String pkg = parts[i].substring(0, n);
- if (!pkg.startsWith("java.")) {
- refers.add(parts[i].substring(0, n));
- }
- }
- }
- }
- line = br.readLine();
- }
- br.close();
- return refers;
- }
-
- protected static String getImportPackages(Set<String> packages) {
- StringBuilder sb = new StringBuilder();
- for (String pkg : packages) {
- if (sb.length() > 0) {
- sb.append(",");
- }
- sb.append(pkg);
- }
- return sb.toString();
- }
-
- protected static Document parse(URL url) throws Exception {
- if (dbf == null) {
- dbf = DocumentBuilderFactory.newInstance();
- dbf.setNamespaceAware(true);
- }
- DocumentBuilder db = dbf.newDocumentBuilder();
- return db.parse(url.toString());
- }
-
- protected static void copyInputStream(InputStream in, OutputStream out) throws Exception {
- byte[] buffer = new byte[4096];
- int len = in.read(buffer);
- while (len >= 0) {
- out.write(buffer, 0, len);
- len = in.read(buffer);
- }
- }
-}
diff --git a/karaf/deployer/spring/src/main/java/org/apache/felix/karaf/deployer/spring/SpringURLHandler.java b/karaf/deployer/spring/src/main/java/org/apache/felix/karaf/deployer/spring/SpringURLHandler.java
deleted file mode 100644
index 0124d38..0000000
--- a/karaf/deployer/spring/src/main/java/org/apache/felix/karaf/deployer/spring/SpringURLHandler.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.deployer.spring;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.service.url.AbstractURLStreamHandlerService;
-
-/**
- * A URL handler that will transform a JBI artifact to an OSGi bundle
- * on the fly. Needs to be registered in the OSGi registry.
- */
-public class SpringURLHandler extends AbstractURLStreamHandlerService {
-
- private static Log logger = LogFactory.getLog(SpringURLHandler.class);
-
- private static String SYNTAX = "spring: spring-xml-uri";
-
- private URL springXmlURL;
-
- /**
- * Open the connection for the given URL.
- *
- * @param url the url from which to open a connection.
- * @return a connection on the specified URL.
- * @throws IOException if an error occurs or if the URL is malformed.
- */
- @Override
- public URLConnection openConnection(URL url) throws IOException {
- if (url.getPath() == null || url.getPath().trim().length() == 0) {
- throw new MalformedURLException ("Path can not be null or empty. Syntax: " + SYNTAX );
- }
- springXmlURL = new URL(url.getPath());
-
- logger.debug("Spring xml URL is: [" + springXmlURL + "]");
- return new Connection(url);
- }
-
- public URL getSpringXmlURL() {
- return springXmlURL;
- }
-
- public class Connection extends URLConnection {
-
- public Connection(URL url) {
- super(url);
- }
-
- @Override
- public void connect() throws IOException {
- }
-
- @Override
- public InputStream getInputStream() throws IOException {
- try {
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- SpringTransformer.transform(springXmlURL, os);
- os.close();
- return new ByteArrayInputStream(os.toByteArray());
- } catch (Exception e) {
- logger.error("Error opening spring xml url", e);
- throw (IOException) new IOException("Error opening spring xml url").initCause(e);
- }
- }
- }
-
-}
diff --git a/karaf/deployer/spring/src/main/resources/OSGI-INF/blueprint/spring-deployer.xml b/karaf/deployer/spring/src/main/resources/OSGI-INF/blueprint/spring-deployer.xml
deleted file mode 100644
index 278584f..0000000
--- a/karaf/deployer/spring/src/main/resources/OSGI-INF/blueprint/spring-deployer.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <service id="springUrlHandler" interface="org.osgi.service.url.URLStreamHandlerService">
- <service-properties>
- <entry key="url.handler.protocol" value="spring"/>
- </service-properties>
- <bean class="org.apache.felix.karaf.deployer.spring.SpringURLHandler"/>
- </service>
-
- <bean id="springDeploymentListener" class="org.apache.felix.karaf.deployer.spring.SpringDeploymentListener"/>
-
- <!-- Force a reference to the url handler above from the osgi registry to (try to) make sure
- the url handler is registered inside the framework. Else we can run into timing issues
- where fileinstall will use the featureDeploymentListener before the url can be actually
- used. In order to not block the bundle, the blueprint.graceperiod=false flag must be
- set on the SymbolicName osgi header -->
- <reference id="springUrlHandlerRef" interface="org.osgi.service.url.URLStreamHandlerService" filter="url.handler.protocol=spring" />
-
- <service ref="springDeploymentListener" auto-export="interfaces" depends-on="springDeploymentListener" />
-
-</blueprint>
diff --git a/karaf/deployer/spring/src/main/resources/org/apache/felix/karaf/deployer/spring/extract.xsl b/karaf/deployer/spring/src/main/resources/org/apache/felix/karaf/deployer/spring/extract.xsl
deleted file mode 100644
index 4b06b69..0000000
--- a/karaf/deployer/spring/src/main/resources/org/apache/felix/karaf/deployer/spring/extract.xsl
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:beans="http://www.springframework.org/schema/beans"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:jee="http://www.springframework.org/schema/jee"
- xmlns:jms="http://www.springframework.org/schema/jms"
- xmlns:lang="http://www.springframework.org/schema/lang"
- xmlns:osgi-compendium="http://www.springframework.org/schema/osgi-compendium"
- xmlns:osgi="http://www.springframework.org/schema/osgi"
- xmlns:tool="http://www.springframework.org/schema/tool"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:util="http://www.springframework.org/schema/util"
- xmlns:webflow-config="http://www.springframework.org/schema/webflow-config">
-
- <xsl:output method="text" />
-
- <xsl:template match="/">
-
- <!-- Match all attributes that holds a class or a comma delimited
- list of classes and print them -->
-
- <xsl:for-each select="
- //beans:bean/@class
- | //beans:*/@value-type
- | //aop:*/@implement-interface
- | //aop:*/@default-impl
- | //context:load-time-weaver/@weaver-class
- | //jee:jndi-lookup/@expected-type
- | //jee:jndi-lookup/@proxy-interface
- | //jee:remote-slsb/@ejbType
- | //jee:*/@business-interface
- | //lang:*/@script-interfaces
- | //osgi:*/@interface
- | //util:list/@list-class
- | //util:set/@set-class
- | //util:map/@map-class
- | //webflow-config:*/@class
- ">
- <xsl:value-of select="." />
- <xsl:text>
- </xsl:text>
- </xsl:for-each>
-
- <!-- This seems some magic to get extra imports? -->
-
- <xsl:for-each select="//beans:bean[@class='org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean'
- or @class='org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean']">
- <xsl:for-each select="beans:property[@name='interfaces']">
- <xsl:value-of select="@value" />
- <xsl:text>
- </xsl:text>
- </xsl:for-each>
- </xsl:for-each>
-
- </xsl:template>
-
-
-</xsl:stylesheet>
-
diff --git a/karaf/deployer/spring/src/test/java/org/apache/felix/karaf/deployer/spring/SpringDeploymentListenerTest.java b/karaf/deployer/spring/src/test/java/org/apache/felix/karaf/deployer/spring/SpringDeploymentListenerTest.java
deleted file mode 100644
index d74e471..0000000
--- a/karaf/deployer/spring/src/test/java/org/apache/felix/karaf/deployer/spring/SpringDeploymentListenerTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.deployer.spring;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.jar.JarInputStream;
-
-import javax.xml.transform.dom.DOMSource;
-
-import junit.framework.TestCase;
-import org.apache.felix.karaf.deployer.spring.SpringDeploymentListener;
-import org.apache.felix.karaf.deployer.spring.SpringTransformer;
-
-public class SpringDeploymentListenerTest extends TestCase {
-
- public void testPackagesExtraction() throws Exception {
- SpringDeploymentListener l = new SpringDeploymentListener();
- File f = new File(getClass().getClassLoader().getResource("test.xml").toURI());
- Set<String> pkgs = SpringTransformer.analyze(new DOMSource(SpringTransformer.parse(f.toURL())));
- assertNotNull(pkgs);
- assertEquals(2, pkgs.size());
- Iterator<String> it = pkgs.iterator();
- assertEquals("org.apache.felix.karaf.deployer.spring", it.next());
- assertEquals("org.osgi.service.url", it.next());
- }
-
- public void testCustomManifest() throws Exception {
- File f = File.createTempFile("smx", ".jar");
- try {
- OutputStream os = new FileOutputStream(f);
- SpringTransformer.transform(getClass().getClassLoader().getResource("test.xml"), os);
- os.close();
- InputStream is = new FileInputStream(f);
- JarInputStream jar = new JarInputStream(is);
- jar.getManifest().write(System.err);
- is.close();
- } finally {
- f.delete();
- }
- }
-
- public void testVersions() {
- assertVersion("org.apache.servicemix.bundles.ant-1.7.0-1.0-m3-SNAPSHOT.jar",
- "org.apache.servicemix.bundles.ant-1.7.0", "1.0.0.m3-SNAPSHOT", "jar");
- assertVersion("org.apache.activemq.core-1.0-SNAPSHOT.xml",
- "org.apache.activemq.core", "1.0.0.SNAPSHOT", "xml");
- assertVersion("org.apache.activemq.core-1.0.0-SNAPSHOT.xml",
- "org.apache.activemq.core", "1.0.0.SNAPSHOT", "xml");
- assertVersion("org.apache.activemq.core-1.0.0.xml",
- "org.apache.activemq.core", "1.0.0", "xml");
- assertVersion("geronimo-servlet_2.5_spec-1.1.2.jar",
- "geronimo-servlet_2.5_spec", "1.1.2", "jar");
- assertVersion("spring-aop-2.5.1.jar",
- "spring-aop", "2.5.1", "jar");
- }
-
- private void assertVersion(String s, String... expectedParts) {
- String[] parts = SpringTransformer.extractNameVersionType(s);
- assertEquals(expectedParts.length, parts.length);
- for (int i = 0; i < expectedParts.length; i++) {
- assertEquals(expectedParts[i], parts[i]);
- }
- }
-
-}
diff --git a/karaf/deployer/spring/src/test/resources/test.xml b/karaf/deployer/spring/src/test/resources/test.xml
deleted file mode 100644
index 0b6ea23..0000000
--- a/karaf/deployer/spring/src/test/resources/test.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:osgi="http://www.springframework.org/schema/osgi"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd
- http://www.springframework.org/schema/osgi
- http://www.springframework.org/schema/osgi/spring-osgi.xsd">
-
- <manifest>
- RequireBundle=org.osgi
- Header=value
- </manifest>
-
- <bean id="springDeploymentListener" class="org.apache.felix.karaf.deployer.spring.SpringDeploymentListener">
-
- </bean>
-
- <osgi:service ref="springDeploymentListener">
- <osgi:interfaces>
- <value>org.apache.felix.karaf.deployer.filemonitor.DeploymentListener</value>
- </osgi:interfaces>
- </osgi:service>
-
- <bean id="springHandler" class="org.apache.felix.karaf.deployer.spring.SpringURLHandler" />
-
- <osgi:service ref="springHandler" interface="org.osgi.service.url.URLStreamHandlerService">
- <osgi:service-properties>
- <entry key="url.handler.protocol" value="spring"/>
- </osgi:service-properties>
- </osgi:service>
-
- <bean id="uri" class="java.net.URI">
- <constructor-arg value="urn:resource"/>
- </bean>
-
-</beans>
diff --git a/karaf/deployer/war/pom.xml b/karaf/deployer/war/pom.xml
deleted file mode 100644
index 2772469..0000000
--- a/karaf/deployer/war/pom.xml
+++ /dev/null
@@ -1,79 +0,0 @@
-<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/maven-v4_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.felix.karaf.deployer</groupId>
- <artifactId>deployer</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.deployer</groupId>
- <artifactId>org.apache.felix.karaf.deployer.war</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: WAR Deployer</name>
-
- <description>This deployer transforms a plain war file to a deployable bundle</description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.fileinstall</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Import-Package>!${project.artifactId}*,*</Import-Package>
- <Private-Package>org.apache.felix.karaf.deployer.war</Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git a/karaf/deployer/war/src/main/java/org/apache/felix/karaf/deployer/war/WarDeploymentListener.java b/karaf/deployer/war/src/main/java/org/apache/felix/karaf/deployer/war/WarDeploymentListener.java
deleted file mode 100644
index 855c49c..0000000
--- a/karaf/deployer/war/src/main/java/org/apache/felix/karaf/deployer/war/WarDeploymentListener.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.deployer.war;
-
-import java.io.File;
-import java.net.URL;
-import java.util.jar.Attributes;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.felix.fileinstall.ArtifactUrlTransformer;
-
-/**
- * A deployment listener that listens for war deployements.
- */
-public class WarDeploymentListener implements ArtifactUrlTransformer {
-
- private static final Log LOGGER = LogFactory.getLog(WarDeploymentListener.class);
-
- public boolean canHandle(File artifact) {
- try {
- JarFile jar = new JarFile(artifact);
- JarEntry entry = jar.getJarEntry("WEB-INF/web.xml");
- // Only handle WAR artifacts
- if (entry == null) {
- return false;
- }
- // Only handle non OSGi bundles
- Manifest m = jar.getManifest();
- if (m.getMainAttributes().getValue(new Attributes.Name("Bundle-SymbolicName")) != null &&
- m.getMainAttributes().getValue(new Attributes.Name("Bundle-Version")) != null) {
- return false;
- }
- return true;
- } catch (Exception e) {
- return false;
- }
- }
-
- public URL transform(URL artifact) throws Exception {
- try {
- return new URL("war", null, artifact.toString());
- } catch (Exception e) {
- LOGGER.error("Unable to build war bundle", e);
- return null;
- }
- }
-
-}
diff --git a/karaf/deployer/war/src/main/resources/OSGI-INF/blueprint/war-deployer.xml b/karaf/deployer/war/src/main/resources/OSGI-INF/blueprint/war-deployer.xml
deleted file mode 100644
index b1a2766..0000000
--- a/karaf/deployer/war/src/main/resources/OSGI-INF/blueprint/war-deployer.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <bean id="warDeploymentListener" class="org.apache.felix.karaf.deployer.war.WarDeploymentListener"/>
-
- <reference id="warUrlHandlerRef" interface="org.osgi.service.url.URLStreamHandlerService" filter="url.handler.protocol=war" />
-
- <service ref="warDeploymentListener" auto-export="interfaces" depends-on="warDeploymentListener" />
-
-</blueprint>
diff --git a/karaf/etc/appended-resources/supplemental-models.xml b/karaf/etc/appended-resources/supplemental-models.xml
deleted file mode 100644
index 2f96e29..0000000
--- a/karaf/etc/appended-resources/supplemental-models.xml
+++ /dev/null
@@ -1,1349 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<supplementalDataModels>
- <supplement>
- <project>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
- <name>Sun JAXB Reference Implementation Runtime</name>
- <organization>
- <name>Sun Microsystems</name>
- <url>http://www.sun.com/</url>
- </organization>
- <licenses>
- <license>
- <name>COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0</name>
- <url>http://www.sun.com/cddl/cddl.html</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-xjc</artifactId>
- <name>Sun JAXB Reference Implementation Tools</name>
- <organization>
- <name>Sun Microsystems</name>
- <url>http://www.sun.com/</url>
- </organization>
- <licenses>
- <license>
- <name>COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0</name>
- <url>http://www.sun.com/cddl/cddl.html</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>com.sun.xml.messaging.saaj</groupId>
- <artifactId>saaj-impl</artifactId>
- <name>Sun SAAJ Reference Implementation</name>
- <organization>
- <name>Sun Microsystems</name>
- <url>http://www.sun.com/</url>
- </organization>
- <licenses>
- <license>
- <name>COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0</name>
- <url>http://www.sun.com/cddl/cddl.html</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>javax.xml.soap</groupId>
- <artifactId>saaj-api</artifactId>
- <name>Sun SAAJ API</name>
- <organization>
- <name>Sun Microsystems</name>
- <url>http://www.sun.com/</url>
- </organization>
- <licenses>
- <license>
- <name>COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0</name>
- <url>http://www.sun.com/cddl/cddl.html</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.neethi</groupId>
- <artifactId>neethi</artifactId>
- <name>Neethi</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>javax.xml.ws</groupId>
- <artifactId>jaxws-api</artifactId>
- <name>Java API for XML-Based Web Services (JAX-WS API)</name>
- <organization>
- <name>Sun Microsystems</name>
- <url>http://www.sun.com/</url>
- </organization>
- <licenses>
- <license>
- <name>COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0</name>
- <url>http://www.sun.com/cddl/cddl.html</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
- <name>Java Architecture for XML Binding (JAXB API)</name>
- <organization>
- <name>Sun Microsystems</name>
- <url>http://www.sun.com/</url>
- </organization>
- <licenses>
- <license>
- <name>COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0</name>
- <url>http://www.sun.com/cddl/cddl.html</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>javax.xml</groupId>
- <artifactId>jaxb-api</artifactId>
- <name>Java Architecture for XML Binding (JAXB API)</name>
- <organization>
- <name>Sun Microsystems</name>
- <url>http://www.sun.com/</url>
- </organization>
- <licenses>
- <license>
- <name>COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0</name>
- <url>http://www.sun.com/cddl/cddl.html</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>xalan</groupId>
- <artifactId>xalan</artifactId>
- <name>Apache Xalan-Java</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>net.java.dev.stax-utils</groupId>
- <artifactId>stax-utils</artifactId>
- <name>StAX Utilities</name>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>wss4j</groupId>
- <artifactId>wss4j</artifactId>
- <name>Apache WSS4J</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>jdom</groupId>
- <artifactId>jdom</artifactId>
- <name>JDOM</name>
- <organization>
- <name>jdom.org</name>
- <url>http://www.jdom.org</url>
- </organization>
- <licenses>
- <license>
- <name>Modified Apache Software License</name>
- <url>licenses/jdom.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>xml-security</groupId>
- <artifactId>xmlsec</artifactId>
- <name>XML Security</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>xml-apis</groupId>
- <artifactId>xml-apis</artifactId>
- <name>XML APIs</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>bouncycastle</groupId>
- <artifactId>bcprov-jdk14</artifactId>
- <name>Bouncy Castle Crypto APIs for Java</name>
- <organization>
- <name>The Legion of the Bouncy Castle</name>
- <url>http://www.bouncycastle.org</url>
- </organization>
- <licenses>
- <license>
- <name>Bouncy Castle License</name>
- <url>http://www.bouncycastle.org/licence.html</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>ant</groupId>
- <artifactId>ant</artifactId>
- <name>Apache Ant</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>ant</groupId>
- <artifactId>ant-nodeps</artifactId>
- <name>Apache Ant (nodeps)</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.codehaus.jettison</groupId>
- <artifactId>jettison</artifactId>
- <name>Jettison</name>
- <organization>
- <name>Envoi Solutions LLC</name>
- <url>http://www.envoisolutions.com</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://jettison.codehaus.org/License</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.mina</groupId>
- <artifactId>mina-core</artifactId>
- <name>Apache MINA Core API</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.mina</groupId>
- <artifactId>mina-filter-ssl</artifactId>
- <name>Apache MINA SSL Filter</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <name>Apache Commons Codec</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <name>Apache Commons Collections</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>commons-dbcp</groupId>
- <artifactId>commons-dbcp</artifactId>
- <name>Apache Commons DBCP</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>commons-jexl</groupId>
- <artifactId>commons-jexl</artifactId>
- <name>Apache Commons JEXL</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <name>Apache Commons Logging</name>
- <url>http://commons.apache.org/logging</url>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging-api</artifactId>
- <name>Apache Commons Logging Api</name>
- <url>http://commons.apache.org/logging</url>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>commons-pool</groupId>
- <artifactId>commons-pool</artifactId>
- <name>Apache Commons Pool</name>
- <url>http://commons.apache.org/pool</url>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>commons-vfs</groupId>
- <artifactId>commons-vfs</artifactId>
- <name>Apache Commons VFS</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <name>Apache Commons Codec</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.aries.blueprint</groupId>
- <artifactId>org.apache.aries.blueprint</artifactId>
- <name>Apache Aries Blueprint</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-core</artifactId>
- <name>ActiveMQ :: Core</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- <name>Camel :: Core</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.xbean</groupId>
- <artifactId>xbean-classloader</artifactId>
- <name>XBean :: Classloader</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.xbean</groupId>
- <artifactId>xbean-finder</artifactId>
- <name>XBean :: Classpath Resource Finder</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.xbean</groupId>
- <artifactId>xbean-naming</artifactId>
- <name>XBean :: Naming</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.xbean</groupId>
- <artifactId>xbean-reflect</artifactId>
- <name>XBean :: Reflect</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.xbean</groupId>
- <artifactId>xbean-spring</artifactId>
- <name>XBean :: Spring</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <name>SLF4J API Module</name>
- <organization>
- <name>QOS.ch</name>
- <url>http://www.qos.ch</url>
- </organization>
- <licenses>
- <license>
- <name>MIT style</name>
- <url>http://www.slf4j.org/license.html</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- <name>SLF4J JDK14 Binding</name>
- <organization>
- <name>QOS.ch</name>
- <url>http://www.qos.ch</url>
- </organization>
- <licenses>
- <license>
- <name>MIT style</name>
- <url>http://www.slf4j.org/license.html</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <name>Log4j</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.geronimo.components</groupId>
- <artifactId>geronimo-connector</artifactId>
- <name>Apache Geronimo TxManager :: Connector</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.geronimo.components</groupId>
- <artifactId>geronimo-transaction</artifactId>
- <name>Apache Geronimo TxManager :: Transaction</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- <name>Spring OSGi Core</name>
- <url>http://www.springframework.org/osgi/</url>
- <organization>
- <name>Spring Framework</name>
- <url>http://www.springframework.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-extender</artifactId>
- <name>Spring OSGi Extender</name>
- <url>http://www.springframework.org/osgi/</url>
- <organization>
- <name>Spring Framework</name>
- <url>http://www.springframework.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-io</artifactId>
- <name>Spring OSGi IO</name>
- <url>http://www.springframework.org/osgi/</url>
- <organization>
- <name>Spring Framework</name>
- <url>http://www.springframework.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-annotation</artifactId>
- <name>Spring OSGi Annotations</name>
- <url>http://www.springframework.org/osgi/</url>
- <organization>
- <name>Spring Framework</name>
- <url>http://www.springframework.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.objectweb.howl</groupId>
- <artifactId>howl</artifactId>
- <name>Howl Logger</name>
- <url>http://howl.objectweb.org/</url>
- <organization>
- <name>ObjectWeb</name>
- <url>http://www.objectweb.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The BSD License</name>
- <url>http://howl.objectweb.org/license.html</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-classworlds</artifactId>
- <name>Plexus Classworlds</name>
- <url>http://plexus.codehaus.org/plexus-classworlds/</url>
- <organization>
- <name>Codehaus</name>
- <url>http://www.codehaus.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>com.thoughtworks.xstream</groupId>
- <artifactId>xstream</artifactId>
- <name>XStream Core</name>
- <url>http://xstream.codehaus.org/</url>
- <organization>
- <name>Codehaus</name>
- <url>http://www.codehaus.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The BSD License</name>
- <url>http://xstream.codehaus.com/license.html</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-activation_1.1_spec</artifactId>
- <name>Apache Geronimo Specs :: Activation 1.1</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
- <name>Apache Geronimo Specs :: J2EE Connector 1.5</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-j2ee-management_1.1_spec</artifactId>
- <name>Apache Geronimo Specs :: J2EE Management 1.1</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-javamail_1.4_spec</artifactId>
- <name>Apache Geronimo Specs :: JavaMail 1.4</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jms_1.1_spec</artifactId>
- <name>Apache Geronimo Specs :: JMS 1.1</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jta_1.1_spec</artifactId>
- <name>Apache Geronimo Specs :: JTA 1.1</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-saaj_1.3_spec</artifactId>
- <name>Apache Geronimo Specs :: SAAJ 1.3</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-servlet_2.5_spec</artifactId>
- <name>Apache Geronimo Specs :: Servlet 2.5</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-stax-api_1.0_spec</artifactId>
- <name>Apache Geronimo Specs :: Stax API 1.0</name>
- <organization>
- <name>The Apache Software Foundation</name>
- <url>http://www.apache.org/</url>
- </organization>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>jline</groupId>
- <artifactId>jline</artifactId>
- <name>JLine</name>
- <url>http://jline.sourceforge.net</url>
- <organization>
- <name>JLine</name>
- <url>http://jline.sourceforge.net</url>
- </organization>
- <licenses>
- <license>
- <name>The BSD License</name>
- <url>http://jline.sourceforge.net/license.html</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
- <name>Jetty Server</name>
- <url>http://jetty.mortbay.org/</url>
- <organization>
- <name>Mort Bay Consulting</name>
- <url>http://www.mortbay.com</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty-util</artifactId>
- <name>Jetty Utilities</name>
- <url>http://jetty.mortbay.org/</url>
- <organization>
- <name>Mort Bay Consulting</name>
- <url>http://www.mortbay.com</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.ops4j.base</groupId>
- <artifactId>ops4j-base-lang</artifactId>
- <name>OPS4J Base - Lang</name>
- <url>http://www.ops4j.org/projects/base/ops4j-base-lang</url>
- <organization>
- <name>OPS4J - Open Participation Software for Java</name>
- <url>http://www.ops4j.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.ops4j.base</groupId>
- <artifactId>ops4j-base-util-collections</artifactId>
- <name>OPS4J Base - Util - Collections</name>
- <url>http://www.ops4j.org/projects/base/ops4j-base-util-collections</url>
- <organization>
- <name>OPS4J - Open Participation Software for Java</name>
- <url>http://www.ops4j.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.ops4j.base</groupId>
- <artifactId>ops4j-base-util-xml</artifactId>
- <name>OPS4J Base - Util - XML</name>
- <url>http://www.ops4j.org/projects/base/ops4j-base-util-xml</url>
- <organization>
- <name>OPS4J - Open Participation Software for Java</name>
- <url>http://www.ops4j.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.ops4j.pax.logging</groupId>
- <artifactId>pax-logging-api</artifactId>
- <name>OPS4J - Pax Logging API</name>
- <url>http://www.ops4j.org/projects/pax/logging/pax-logging-api</url>
- <organization>
- <name>OPS4J - Open Participation Software for Java</name>
- <url>http://www.ops4j.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.ops4j.pax.logging</groupId>
- <artifactId>pax-logging-service</artifactId>
- <name>OPS4J - Pax Logging Service</name>
- <url>http://www.ops4j.org/projects/pax/logging/pax-logging-service</url>
- <organization>
- <name>OPS4J - Open Participation Software for Java</name>
- <url>http://www.ops4j.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.ops4j.pax.swissbox</groupId>
- <artifactId>pax-swissbox-core</artifactId>
- <name>OPS4J Pax Swissbox - OSGi Core</name>
- <url>http://www.ops4j.org/projects/pax/swissbox/pax-swissbox-core</url>
- <organization>
- <name>OPS4J - Open Participation Software for Java</name>
- <url>http://www.ops4j.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.ops4j.pax.swissbox</groupId>
- <artifactId>pax-swissbox-extender</artifactId>
- <name>OPS4J Pax Swissbox - Extender</name>
- <url>http://www.ops4j.org/projects/pax/swissbox/pax-swissbox-extender</url>
- <organization>
- <name>OPS4J - Open Participation Software for Java</name>
- <url>http://www.ops4j.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.ops4j.pax.swissbox</groupId>
- <artifactId>pax-swissbox-lifecycle</artifactId>
- <name>OPS4J Pax Swissbox - Lifecycle</name>
- <url>http://www.ops4j.org/projects/pax/swissbox/pax-swissbox-lifecycle</url>
- <organization>
- <name>OPS4J - Open Participation Software for Java</name>
- <url>http://www.ops4j.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.ops4j.pax.swissbox</groupId>
- <artifactId>pax-swissbox-optional-jcl</artifactId>
- <name>OPS4J Pax Swissbox - Optional JCL</name>
- <url>http://www.ops4j.org/projects/pax/swissbox/pax-swissbox-optional-jcl</url>
- <organization>
- <name>OPS4J - Open Participation Software for Java</name>
- <url>http://www.ops4j.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.ops4j.pax.swissbox</groupId>
- <artifactId>pax-swissbox-tracker</artifactId>
- <name>OPS4J Pax Swissbox - Tracker</name>
- <url>http://www.ops4j.org/projects/pax/swissbox/pax-swissbox-tracker</url>
- <organization>
- <name>OPS4J - Open Participation Software for Java</name>
- <url>http://www.ops4j.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.ops4j.pax.url</groupId>
- <artifactId>pax-url-mvn</artifactId>
- <name>OPS4J Pax Url - mvn:</name>
- <url>http://www.ops4j.org/projects/pax/url/pax-url-mvn</url>
- <organization>
- <name>OPS4J - Open Participation Software for Java</name>
- <url>http://www.ops4j.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.ops4j.pax.url</groupId>
- <artifactId>pax-url-war</artifactId>
- <name>OPS4J Pax Url - war:</name>
- <url>http://www.ops4j.org/projects/pax/url/pax-url-war</url>
- <organization>
- <name>OPS4J - Open Participation Software for Java</name>
- <url>http://www.ops4j.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-bundle</artifactId>
- <name>OPS4J Pax Web - Web Container</name>
- <url>http://www.ops4j.org/projects/pax/web/pax-web-bundle</url>
- <organization>
- <name>OPS4J - Open Participation Software for Java</name>
- <url>http://www.ops4j.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-jsp</artifactId>
- <name>OPS4J Pax Web - JSP</name>
- <url>http://www.ops4j.org/projects/pax/web/pax-web-jsp</url>
- <organization>
- <name>OPS4J - Open Participation Software for Java</name>
- <url>http://www.ops4j.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.ops4j.pax.web-extender</groupId>
- <artifactId>pax-web-ex-war</artifactId>
- <name>OPS4J Pax Web Extender - WAR</name>
- <url>http://www.ops4j.org/projects/pax/web-extender/pax-web-ex-war</url>
- <organization>
- <name>OPS4J - Open Participation Software for Java</name>
- <url>http://www.ops4j.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.ops4j.pax.web-extender</groupId>
- <artifactId>pax-web-ex-whiteboard</artifactId>
- <name>OPS4J Pax Web Extender - Whiteboard</name>
- <url>http://www.ops4j.org/projects/pax/web-extender/pax-web-ex-whiteboard</url>
- <organization>
- <name>OPS4J - Open Participation Software for Java</name>
- <url>http://www.ops4j.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.impl.bundle.jmx</artifactId>
- <name>JMX management for OSGi (RI snapshot)</name>
- <organization>
- <name>OSGi Alliance</name>
- <url>http://www.osgi.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.fusesource.jansi</groupId>
- <artifactId>jansi</artifactId>
- <name>jansi</name>
- <organization>
- <name>FUSE Source</name>
- <url>http://www.fusesource.org/</url>
- </organization>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>org.eclipse</groupId>
- <artifactId>osgi</artifactId>
- <name>Equinox Framework</name>
- <organization>
- <name>Eclipse Foundation</name>
- <url>http://www.eclipse.org/</url>
- </organization>
- <licenses>
- <license>
- <name>Eclipse Public License, Version 1.0</name>
- <url>http://www.eclipse.org/legal/epl-v10.html</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>xmlpull</groupId>
- <artifactId>xmlpull</artifactId>
- <name>XML Pull Parsing API</name>
- <organization>
- <name>Eclipse Foundation</name>
- <url>http://www.eclipse.org/</url>
- </organization>
- <licenses>
- <license>
- <name>Public Domain</name>
- <url>http://www.xmlpull.org/v1/download/unpacked/LICENSE.txt</url>
- </license>
- </licenses>
- </project>
- </supplement>
- <supplement>
- <project>
- <groupId>aopalliance</groupId>
- <artifactId>aopalliance</artifactId>
- <name>XML Pull Parsing API</name>
- <organization>
- <name>AOP Alliance</name>
- <url>http://aopalliance.sourceforge.net/</url>
- </organization>
- <licenses>
- <license>
- <name>Public Domain</name>
- </license>
- </licenses>
- </project>
- </supplement>
-</supplementalDataModels>
diff --git a/karaf/exception/pom.xml b/karaf/exception/pom.xml
deleted file mode 100644
index ab8e367..0000000
--- a/karaf/exception/pom.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<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/maven-v4_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.felix.karaf</groupId>
- <artifactId>karaf</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>org.apache.felix.karaf.exception</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Exception</name>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
-</project>
diff --git a/karaf/exception/src/main/java/java/lang/Exception.java b/karaf/exception/src/main/java/java/lang/Exception.java
deleted file mode 100644
index 1aff70e..0000000
--- a/karaf/exception/src/main/java/java/lang/Exception.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.lang;
-
-
-/**
- * {@code Exception} is the superclass of all classes that represent recoverable
- * exceptions. When exceptions are thrown, they may be caught by application
- * code.
- *
- * @see Throwable
- * @see Error
- * @see RuntimeException
- */
-public class Exception extends Throwable {
- private static final long serialVersionUID = -3387516993124229948L;
-
- private transient Class[] classContext = sm.getThrowableContext(this);
-
- /**
- * Constructs a new {@code Exception} that includes the current stack trace.
- */
- public Exception() {
- super();
- }
-
- /**
- * Constructs a new {@code Exception} with the current stack trace and the
- * specified detail message.
- *
- * @param detailMessage
- * the detail message for this exception.
- */
- public Exception(String detailMessage) {
- super(detailMessage);
- }
-
- /**
- * Constructs a new {@code Exception} with the current stack trace, the
- * specified detail message and the specified cause.
- *
- * @param detailMessage
- * the detail message for this exception.
- * @param throwable
- * the cause of this exception.
- */
- public Exception(String detailMessage, Throwable throwable) {
- super(detailMessage, throwable);
- }
-
- /**
- * Constructs a new {@code Exception} with the current stack trace and the
- * specified cause.
- *
- * @param throwable
- * the cause of this exception.
- */
- public Exception(Throwable throwable) {
- super(throwable);
- }
-
- public Class[] getClassContext() {
- return classContext;
- }
-
- private static final SecurityManagerEx sm = new SecurityManagerEx();
-
- static class SecurityManagerEx extends SecurityManager
- {
- public Class[] getClassContext()
- {
- return super.getClassContext();
- }
-
- public Class[] getThrowableContext(Throwable t) {
- try {
- Class[] context = getClassContext();
- int nb = 0;
- for (;;) {
- if (context[context.length - 1 - nb] == t.getClass()) {
- break;
- }
- nb++;
- }
- Class[] nc = new Class[nb];
- System.arraycopy(context, context.length - nb, nc, 0, nb);
- return nc;
- } catch (Exception e) {
- return null;
- }
- }
- }
-
-}
\ No newline at end of file
diff --git a/karaf/features/command/NOTICE b/karaf/features/command/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/features/command/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/features/command/pom.xml b/karaf/features/command/pom.xml
deleted file mode 100644
index 2eb726c..0000000
--- a/karaf/features/command/pom.xml
+++ /dev/null
@@ -1,119 +0,0 @@
-<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/maven-v4_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.felix.karaf.features</groupId>
- <artifactId>features</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.features</groupId>
- <artifactId>org.apache.felix.karaf.features.command</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Features Command</name>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix.karaf.features</groupId>
- <artifactId>org.apache.felix.karaf.features.core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.bundlerepository</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.obr</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Import-Package>
- !${project.artifactId}*,
- javax.management,
- javax.management.loading,
- org.osgi.service.command,
- org.apache.felix.gogo.commands,
- org.apache.felix.karaf.shell.console,
- *
- </Import-Package>
- <Private-Package>!*</Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/AddUrlCommand.java b/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/AddUrlCommand.java
deleted file mode 100644
index 237ac50..0000000
--- a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/AddUrlCommand.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.command;
-
-import java.net.URI;
-import java.util.List;
-
-import org.apache.felix.karaf.features.FeaturesService;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "features", name = "addUrl", description = "Adds a list of repository URLs to the features service.")
-public class AddUrlCommand extends FeaturesCommandSupport {
-
- @Argument(index = 0, name = "urls", description = "One or more repository URLs separated by whitespaces", required = true, multiValued = true)
- List<String> urls;
-
- protected void doExecute(FeaturesService admin) throws Exception {
- for (String url : urls) {
- try {
- admin.addRepository(new URI(url));
- } catch (Exception e) {
- System.out.println("Could not add Feature Repository:\n" + e );
- }
- }
- }
-}
diff --git a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/FeaturesCommandSupport.java b/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/FeaturesCommandSupport.java
deleted file mode 100644
index 1ba61ad..0000000
--- a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/FeaturesCommandSupport.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.command;
-
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.karaf.features.FeaturesService;
-import org.osgi.framework.ServiceReference;
-
-public abstract class FeaturesCommandSupport extends OsgiCommandSupport {
-
- protected Object doExecute() throws Exception {
- // Get repository admin service.
- ServiceReference ref = getBundleContext().getServiceReference(FeaturesService.class.getName());
- if (ref == null) {
- System.out.println("FeaturesService service is unavailable.");
- return null;
- }
- try {
- FeaturesService admin = (FeaturesService) getBundleContext().getService(ref);
- if (admin == null) {
- System.out.println("FeaturesService service is unavailable.");
- return null;
- }
-
- doExecute(admin);
- }
- finally {
- getBundleContext().ungetService(ref);
- }
- return null;
- }
-
- protected abstract void doExecute(FeaturesService admin) throws Exception;
-
-}
diff --git a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/InfoFeatureCommand.java b/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/InfoFeatureCommand.java
deleted file mode 100644
index 9418c75..0000000
--- a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/InfoFeatureCommand.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.command;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.karaf.features.Feature;
-import org.apache.felix.karaf.features.FeaturesService;
-
-/**
- * Utility command to display info about features.
- */
-@Command(scope = "features", name = "info", description = "Shows information about selected information.")
-public class InfoFeatureCommand extends FeaturesCommandSupport {
-
- @Argument(index = 0, name = "name", description = "The name of the feature", required = true, multiValued = false)
- private String name;
-
- @Argument(index = 1, name = "version", description = "The version of the feature", required = false, multiValued = false)
- private String version;
-
- @Option(name = "-c", aliases={"--configuration"}, description="Display configuration info", required = false, multiValued = false)
- private boolean config;
-
- @Option(name = "-d", aliases={"--dependency"}, description="Display dependencies info", required = false, multiValued = false)
- private boolean dependency;
-
- @Option(name = "-b", aliases={"--bundle"}, description="Display bundles info", required = false, multiValued = false)
- private boolean bundle;
-
- @Option(name = "-t", aliases={"--tree"}, description="Display feature tree", required = false, multiValued = false)
- private boolean tree;
-
- protected void doExecute(FeaturesService admin) throws Exception {
- Feature feature = null;
-
- if (version != null && version.length() > 0) {
- feature = admin.getFeature(name, version);
- } else {
- feature = admin.getFeature(name);
- }
-
- if (feature == null) {
- System.out.println("Feature not found");
- return;
- }
-
- // default behavior
- if (!config && !dependency && !bundle) {
- config = true;
- dependency = true;
- bundle = true;
- }
-
- System.out.println("Description of " + feature.getName() + " " + feature.getVersion() + " feature");
- System.out.println("----------------------------------------------------------------");
- if (config) {
- displayConfigInformation(feature);
- }
-
- if (dependency) {
- displayDependencyInformation(feature);
- }
-
- if (bundle) {
- displayBundleInformation(feature);
- }
-
- if (tree) {
- if (config || dependency || bundle) {
- System.out.println("\nFeature tree");
- }
-
- int unresolved = displayFeatureTree(admin, feature, 0, false);
- if (unresolved > 0) {
- System.out.println("Tree contains " + unresolved + " unresolved dependencies");
- System.out.println(" * means that node declares dependency but the dependant feature is not available.");
- }
- }
- }
-
- private void displayBundleInformation(Feature feature) {
- List<String> bundles = feature.getBundles();
- if (bundles.isEmpty()) {
- System.out.println("Feature has no bundles.");
- } else {
- System.out.println("Feature contains followed bundles:");
- for (String featureBundle : bundles) {
- System.out.println(" " + featureBundle);
- }
- }
- }
-
- private void displayDependencyInformation(Feature feature) {
- List<Feature> dependencies = feature.getDependencies();
- if (dependencies.isEmpty()) {
- System.out.println("Feature has no dependencies.");
- } else {
- System.out.println("Feature depends on:");
- for (Feature featureDependency : dependencies) {
- System.out.println(" " + featureDependency.getName() + " " + featureDependency.getVersion());
- }
- }
- }
-
- private void displayConfigInformation(Feature feature) {
- Map<String, Map<String, String>> configurations = feature.getConfigurations();
- if (configurations.isEmpty()) {
- System.out.println("Feature has no configuration");
- } else {
- System.out.println("Feature configuration:");
- for (String name : configurations.keySet()) {
- System.out.println(" " + name);
- }
- }
- }
-
-
- private int displayFeatureTree(FeaturesService admin, Feature feature, int level, boolean last) throws Exception {
- int unresolved = 0;
- String prefix = repeat(" ", level);
-
- Feature resolved = resolveFeature(admin, feature);
- if (resolved != null) {
- System.out.println(prefix + " " + resolved.getName() + " " + resolved.getVersion());
- } else {
- System.out.println(prefix + " " + feature.getName() + " " + feature.getVersion() + " *");
- unresolved++;
- }
-
- if (bundle) {
- List<String> bundles = resolved != null ? resolved.getBundles() : feature.getBundles();
- for (int i = 0, j = bundles.size(); i < j; i++) {
- System.out.println(prefix + " " + (i+1 == j ? "\\" : "+") + " " + bundles.get(i));
- }
- }
- List<Feature> dependencies = resolved != null ? resolved.getDependencies() : feature.getDependencies();
- for (int i = 0, j = dependencies.size(); i < j; i++) {
- Feature toDisplay = resolveFeature(admin, dependencies.get(i));
- if (toDisplay == null) {
- toDisplay = dependencies.get(i);
- }
- unresolved += displayFeatureTree(admin, toDisplay, level+1, i + 1 == j);
- }
-
- return unresolved;
- }
-
- private Feature resolveFeature(FeaturesService admin, Feature feature) throws Exception {
- return admin.getFeature(feature.getName(), feature.getVersion());
- }
-
- private static String repeat(String string, int times) {
- if (times <= 0) {
- return "";
- }
- else if (times % 2 == 0) {
- return repeat(string+string, times/2);
- }
- else {
- return string + repeat(string+string, times/2);
- }
- }
-}
diff --git a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/InstallFeatureCommand.java b/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/InstallFeatureCommand.java
deleted file mode 100644
index 45f7897..0000000
--- a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/InstallFeatureCommand.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.command;
-
-import java.util.EnumSet;
-
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.karaf.features.FeaturesService;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "features", name = "install", description = "Installs a feature with the specified name and version.")
-public class InstallFeatureCommand extends FeaturesCommandSupport {
-
- private static String DEFAULT_VERSION = "0.0.0";
-
- @Argument(index = 0, name = "name", description = "The name of the feature", required = true, multiValued = false)
- String name;
- @Argument(index = 1, name = "version", description = "The version of the feature", required = false, multiValued = false)
- String version;
- @Option(name = "-c", aliases = "--no-clean", description = "Do not uninstall bundles on failure", required = false, multiValued = false)
- boolean noClean;
- @Option(name = "-r", aliases = "--no-auto-refresh", description = "Do not automatically refresh bundles", required = false, multiValued = false)
- boolean noRefresh;
-
- protected void doExecute(FeaturesService admin) throws Exception {
- if (version == null || version.length() == 0) {
- version = DEFAULT_VERSION;
- }
- EnumSet<FeaturesService.Option> options = EnumSet.of(FeaturesService.Option.PrintBundlesToRefresh);
- if (noRefresh) {
- options.add(FeaturesService.Option.NoAutoRefreshBundles);
- }
- if (noClean) {
- options.add(FeaturesService.Option.NoCleanIfFailure);
- }
- admin.installFeature(name, version, options);
- }
-}
diff --git a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/ListFeaturesCommand.java b/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/ListFeaturesCommand.java
deleted file mode 100644
index ebdeb06..0000000
--- a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/ListFeaturesCommand.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.command;
-
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.felix.karaf.features.FeaturesService;
-import org.apache.felix.karaf.features.Feature;
-import org.apache.felix.karaf.features.Repository;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "features", name = "list", description = "Lists all existing features available from the defined repositories.")
-public class ListFeaturesCommand extends FeaturesCommandSupport {
-
- @Option(name = "-i", aliases={"--installed"}, description="Display a list of all installed features only", required = false, multiValued = false)
- boolean installed;
-
- private static final String STATE = "State";
- private static final String INSTALLED = "installed ";
- private static final String UNINSTALLED = "uninstalled";
-
- private static final String VERSION = "Version";
- private static final String NAME = "Name";
- private static final String REPOSITORY = "Repository";
-
- protected void doExecute(FeaturesService admin) throws Exception {
-
- // Get the feature data to print.
- List<Feature> features = new ArrayList<Feature>();
- List<Repository> repositories = new ArrayList<Repository>();
- for (Repository r : Arrays.asList(admin.listRepositories())) {
- for (Feature f : r.getFeatures()) {
- if (installed && !admin.isInstalled(f)) {
- continue;
- }
- features.add(f);
- repositories.add(r);
- }
- }
- if (features.size() == 0) {
- if (installed) {
- System.out.println("No features installed.");
- }
- else {
- System.out.println("No features available.");
- }
- return;
- }
-
- // Print column headers.
- int maxVersionSize = VERSION.length();
- for (Feature f : features) {
- maxVersionSize = Math.max(maxVersionSize, f.getVersion().length());
- }
- int maxNameSize = NAME.length();
- for (Feature f : features) {
- maxNameSize = Math.max(maxNameSize, f.getName().length());
- }
- StringBuilder sb = new StringBuilder();
- sb.append(STATE).append(" ").append(VERSION).append(" ");
- for (int i = VERSION.length(); i < maxVersionSize; i++) {
- sb.append(" ");
- }
- sb.append(NAME).append(" ");
- for (int i = NAME.length(); i < maxNameSize; i++) {
- sb.append(" ");
- }
- sb.append(REPOSITORY);
- System.out.println(sb.toString());
-
- // Print the feature data.
- boolean needsLegend = false;
- for (Feature f : features) {
-
- sb.setLength(0);
- sb.append("[");
- if (admin.isInstalled(f)) {
- sb.append(INSTALLED);
- } else {
- sb.append(UNINSTALLED);
- }
-
- sb.append("] [");
- String str = f.getVersion();
- sb.append(str);
- for (int i = str.length(); i < maxVersionSize; i++) {
- sb.append(" ");
- }
- sb.append("] ");
-
- str = f.getName();
- sb.append(str);
- for (int i = str.length(); i < maxNameSize; i++) {
- sb.append(" ");
- }
-
- sb.append(" ");
- String name = repositories.get(0).getName();
- sb.append(name);
- repositories.remove(0);
- System.out.println(sb.toString());
- if (name.charAt(name.length() - 1) == '*') {
- needsLegend = true;
- }
-
- }
-
- if (needsLegend) {
- System.out.println("* Installed via deploy directory");
- }
-
- }
-
-}
diff --git a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/ListUrlCommand.java b/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/ListUrlCommand.java
deleted file mode 100644
index 79b280b..0000000
--- a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/ListUrlCommand.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.command;
-
-import org.apache.felix.karaf.features.FeaturesService;
-import org.apache.felix.karaf.features.Repository;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "features", name = "listUrl", description = "Displays a list of all defined repository URLs.")
-public class ListUrlCommand extends FeaturesCommandSupport {
-
- protected void doExecute(FeaturesService admin) throws Exception {
- Repository[] repos = admin.listRepositories();
- if ((repos != null) && (repos.length > 0)) {
- for (int i = 0; i < repos.length; i++) {
- System.out.println(repos[i].getURI());
- }
- } else {
- System.out.println("No repository URLs are set.");
- }
- }
-}
diff --git a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/RefreshUrlCommand.java b/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/RefreshUrlCommand.java
deleted file mode 100644
index de67840..0000000
--- a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/RefreshUrlCommand.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.command;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.karaf.features.FeaturesService;
-import org.apache.felix.karaf.features.Repository;
-
-@Command(scope = "features", name = "refreshUrl", description = "Reloads the list of available features from the repositories.")
-public class RefreshUrlCommand extends FeaturesCommandSupport {
-
- @Argument(index = 0, name = "urls", description = "Repository URLs to reload (leave empty for all)", required = false, multiValued = true)
- List<String> urls;
-
- protected void doExecute(FeaturesService admin) throws Exception {
- if (urls == null || urls.isEmpty()) {
- urls = new ArrayList<String>();
- for (Repository repo : admin.listRepositories()) {
- urls.add(repo.getURI().toString());
- }
- }
- for (String strUri : urls) {
- try {
- URI uri = new URI(strUri);
- admin.removeRepository(uri);
- admin.addRepository(uri);
- } catch (Exception e) {
- System.out.println("Could not refresh Feature Repository:\n" + e.getMessage() );
- }
- }
- }
-}
diff --git a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/RemoveUrlCommand.java b/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/RemoveUrlCommand.java
deleted file mode 100644
index c5cfed1..0000000
--- a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/RemoveUrlCommand.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy 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.felix.karaf.features.command;
-
-import java.net.URI;
-import java.util.List;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.karaf.features.FeaturesService;
-
-@Command(scope = "features", name = "removeUrl", description = "Removes the given list of repository URLs from the features service.")
-public class RemoveUrlCommand extends FeaturesCommandSupport {
-
- @Argument(index = 0, name = "urls", description = "One or more repository URLs separated by whitespaces", required = true, multiValued = true)
- List<String> urls;
-
- protected void doExecute(FeaturesService admin) throws Exception {
- for (String url : urls) {
- admin.removeRepository(new URI(url));
- }
- }
-}
diff --git a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/UninstallFeatureCommand.java b/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/UninstallFeatureCommand.java
deleted file mode 100644
index 4906d78..0000000
--- a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/UninstallFeatureCommand.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.command;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.karaf.features.FeaturesService;
-
-@Command(scope = "features", name = "uninstall", description = "Uninstalls a feature with the specified name and version.")
-public class UninstallFeatureCommand extends FeaturesCommandSupport {
-
- @Argument(index = 0, name = "name", description = "The name of the feature", required = true, multiValued = false)
- String name;
-
- @Argument(index = 1, name = "version", description = "The version of the feature", required = false, multiValued = false)
- String version;
-
- protected void doExecute(FeaturesService admin) throws Exception {
- if (version != null && version.length() > 0) {
- admin.uninstallFeature(name, version);
- } else {
- admin.uninstallFeature(name );
- }
- }
-}
diff --git a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/completers/AllFeatureCompleter.java b/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/completers/AllFeatureCompleter.java
deleted file mode 100644
index 2b42bcc..0000000
--- a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/completers/AllFeatureCompleter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.command.completers;
-
-import org.apache.felix.karaf.features.Feature;
-
-/**
- * {@link jline.Completor} for available features.
- */
-public class AllFeatureCompleter extends FeatureCompleterSupport {
-
- @Override
- protected boolean acceptsFeature(Feature feature) {
- return true;
- }
-
-}
diff --git a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/completers/AvailableFeatureCompleter.java b/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/completers/AvailableFeatureCompleter.java
deleted file mode 100644
index ae0b9a6..0000000
--- a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/completers/AvailableFeatureCompleter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.command.completers;
-
-import org.apache.felix.karaf.features.Feature;
-
-/**
- * {@link jline.Completor} for features not installed yet.
- */
-public class AvailableFeatureCompleter extends FeatureCompleterSupport {
-
- @Override
- protected boolean acceptsFeature(Feature feature) {
- return !featuresService.isInstalled(feature);
- }
-
-}
diff --git a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/completers/FeatureCompleterSupport.java b/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/completers/FeatureCompleterSupport.java
deleted file mode 100644
index 430f8b1..0000000
--- a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/completers/FeatureCompleterSupport.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.command.completers;
-
-import java.util.List;
-
-import org.apache.felix.karaf.features.Feature;
-import org.apache.felix.karaf.features.FeaturesService;
-import org.apache.felix.karaf.shell.console.Completer;
-import org.apache.felix.karaf.shell.console.completer.StringsCompleter;
-
-/**
- * Base completer for feature commands.
- */
-public abstract class FeatureCompleterSupport implements Completer {
-
- /**
- * Feature service.
- */
- protected FeaturesService featuresService;
-
- public void setFeaturesService(FeaturesService featuresService) {
- this.featuresService = featuresService;
- }
-
- public int complete(final String buffer, final int cursor, final List candidates) {
- StringsCompleter delegate = new StringsCompleter();
- try {
- for (Feature feature : featuresService.listFeatures()) {
- if (acceptsFeature(feature)) {
- delegate.getStrings().add(feature.getName());
- }
- }
- } catch (Exception e) {
- // Ignore
- }
- return delegate.complete(buffer, cursor, candidates);
- }
-
- /**
- * Method for filtering features.
- *
- * @param feature The feature.
- * @return True if feature should be available in completer.
- */
- protected abstract boolean acceptsFeature(Feature feature);
-}
diff --git a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/completers/FeatureRepositoryCompleter.java b/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/completers/FeatureRepositoryCompleter.java
deleted file mode 100644
index a9b9d7b..0000000
--- a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/completers/FeatureRepositoryCompleter.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.command.completers;
-
-import java.util.List;
-
-import org.apache.felix.karaf.shell.console.completer.StringsCompleter;
-import org.apache.felix.karaf.shell.console.Completer;
-import org.apache.felix.karaf.features.FeaturesService;
-import org.apache.felix.karaf.features.Repository;
-
-/**
- * {@link jline.Completor} for Feature Repository URLs.
- *
- * Displays a list of currently installed Feature repositories.
- *
- */
-
-public class FeatureRepositoryCompleter implements Completer {
-
- private FeaturesService featuresService;
-
- public void setFeaturesService(FeaturesService featuresService) {
- this.featuresService = featuresService;
- }
-
- public int complete(final String buffer, final int cursor, final List candidates) {
- StringsCompleter delegate = new StringsCompleter();
- try {
- for (Repository repository : featuresService.listRepositories()) {
- delegate.getStrings().add(repository.getURI().toString());
- }
- } catch (Exception e) {
- // Ignore
- }
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/completers/InstalledFeatureCompleter.java b/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/completers/InstalledFeatureCompleter.java
deleted file mode 100644
index 07b7b73..0000000
--- a/karaf/features/command/src/main/java/org/apache/felix/karaf/features/command/completers/InstalledFeatureCompleter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.command.completers;
-
-import org.apache.felix.karaf.features.Feature;
-
-/**
- * {@link jline.Completor} for installed features.
- */
-public class InstalledFeatureCompleter extends FeatureCompleterSupport {
-
- @Override
- protected boolean acceptsFeature(Feature feature) {
- return featuresService.isInstalled(feature);
- }
-
-}
diff --git a/karaf/features/command/src/main/resources/OSGI-INF/blueprint/features-command.xml b/karaf/features/command/src/main/resources/OSGI-INF/blueprint/features-command.xml
deleted file mode 100644
index d9b3f8c..0000000
--- a/karaf/features/command/src/main/resources/OSGI-INF/blueprint/features-command.xml
+++ /dev/null
@@ -1,80 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
-
- <command-bundle xmlns="http://felix.apache.org/karaf/xmlns/shell/v1.0.0">
- <command name="features/addUrl">
- <action class="org.apache.felix.karaf.features.command.AddUrlCommand"/>
- </command>
- <command name="features/listUrl">
- <action class="org.apache.felix.karaf.features.command.ListUrlCommand"/>
- </command>
- <command name="features/removeUrl">
- <action class="org.apache.felix.karaf.features.command.RemoveUrlCommand"/>
- <completers>
- <ref component-id="removeUrlCompleter" />
- </completers>
- </command>
- <command name="features/refreshUrl">
- <action class="org.apache.felix.karaf.features.command.RefreshUrlCommand"/>
- </command>
- <command name="features/install">
- <action class="org.apache.felix.karaf.features.command.InstallFeatureCommand"/>
- <completers>
- <ref component-id="uninstalledFeatureCompleter" />
- </completers>
- </command>
- <command name="features/uninstall">
- <action class="org.apache.felix.karaf.features.command.UninstallFeatureCommand"/>
- <completers>
- <ref component-id="installedFeatureCompleter" />
- </completers>
- </command>
- <command name="features/list">
- <action class="org.apache.felix.karaf.features.command.ListFeaturesCommand"/>
- </command>
- <command name="features/info">
- <action class="org.apache.felix.karaf.features.command.InfoFeatureCommand"/>
- <completers>
- <ref component-id="allFeatureCompleter" />
- </completers>
- </command>
- </command-bundle>
-
- <reference id="featuresService" interface="org.apache.felix.karaf.features.FeaturesService" />
-
- <bean id="uninstalledFeatureCompleter" class="org.apache.felix.karaf.features.command.completers.AvailableFeatureCompleter">
- <property name="featuresService" ref="featuresService" />
- </bean>
-
- <bean id="installedFeatureCompleter" class="org.apache.felix.karaf.features.command.completers.InstalledFeatureCompleter">
- <property name="featuresService" ref="featuresService" />
- </bean>
-
- <bean id="allFeatureCompleter" class="org.apache.felix.karaf.features.command.completers.AllFeatureCompleter">
- <property name="featuresService" ref="featuresService" />
- </bean>
-
- <bean id="removeUrlCompleter" class="org.apache.felix.karaf.features.command.completers.FeatureRepositoryCompleter">
- <property name="featuresService" ref="featuresService" />
- </bean>
-
-</blueprint>
diff --git a/karaf/features/core/NOTICE b/karaf/features/core/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/features/core/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/features/core/pom.xml b/karaf/features/core/pom.xml
deleted file mode 100644
index c6fe665..0000000
--- a/karaf/features/core/pom.xml
+++ /dev/null
@@ -1,123 +0,0 @@
-<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/maven-v4_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.felix.karaf.features</groupId>
- <artifactId>features</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.features</groupId>
- <artifactId>org.apache.felix.karaf.features.core</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Features Core</name>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.utils</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.bundlerepository</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.obr</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>org.apache.felix.karaf.features;version=${project.version}</Export-Package>
- <Import-Package>
- !org.apache.felix.karaf.features,
- javax.management,
- javax.management.loading,
- org.osgi.service.command,
- org.apache.felix.gogo.commands,
- org.apache.felix.karaf.shell.console,
- *
- </Import-Package>
- <Private-Package>
- org.apache.felix.karaf.features.internal,
- org.apache.felix.utils.version,
- org.apache.felix.utils.manifest
- </Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/Feature.java b/karaf/features/core/src/main/java/org/apache/felix/karaf/features/Feature.java
deleted file mode 100644
index 6fc7f23..0000000
--- a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/Feature.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * A feature is a list of bundles associated identified by its name.
- */
-public interface Feature {
-
- String getId();
-
- String getName();
-
- String getVersion();
-
- List<Feature> getDependencies();
-
- List<String> getBundles();
-
- Map<String, Map<String, String>> getConfigurations();
-
-}
diff --git a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/FeatureEvent.java b/karaf/features/core/src/main/java/org/apache/felix/karaf/features/FeatureEvent.java
deleted file mode 100644
index f368ff8..0000000
--- a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/FeatureEvent.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features;
-
-import java.util.EventObject;
-
-public class FeatureEvent extends EventObject {
-
- public static enum EventType {
- FeatureInstalled,
- FeatureUninstalled
- }
-
- private final EventType type;
- private final Feature feature;
- private final boolean replay;
-
- public FeatureEvent(Feature feature, EventType type, boolean replay) {
- super(feature);
- this.type = type;
- this.feature = feature;
- this.replay = replay;
- }
-
- public EventType getType() {
- return type;
- }
-
- public Feature getFeature() {
- return feature;
- }
-
- public boolean isReplay() {
- return replay;
- }
-}
diff --git a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/FeaturesListener.java b/karaf/features/core/src/main/java/org/apache/felix/karaf/features/FeaturesListener.java
deleted file mode 100644
index 1b54ed9..0000000
--- a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/FeaturesListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features;
-
-public interface FeaturesListener {
-
- void featureEvent(FeatureEvent event);
-
- void repositoryEvent(RepositoryEvent event);
-
-}
diff --git a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/FeaturesService.java b/karaf/features/core/src/main/java/org/apache/felix/karaf/features/FeaturesService.java
deleted file mode 100644
index 1e248e7..0000000
--- a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/FeaturesService.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features;
-
-import java.net.URI;
-import java.util.EnumSet;
-import java.util.Set;
-
-/**
- * The service managing features repositories.
- */
-public interface FeaturesService {
-
- enum Option {
- NoCleanIfFailure,
- PrintBundlesToRefresh,
- NoAutoRefreshBundles,
- ContinueBatchOnFailure
- }
-
- void addRepository(URI url) throws Exception;
-
- void removeRepository(URI url);
-
- Repository[] listRepositories();
-
- void installFeature(String name) throws Exception;
-
- void installFeature(String name, String version) throws Exception;
-
- void installFeature(String name, String version, EnumSet<Option> options) throws Exception;
-
- void installFeature(Feature f, EnumSet<Option> options) throws Exception;
-
- void installFeatures(Set<Feature> features, EnumSet<Option> options) throws Exception;
-
- void uninstallFeature(String name) throws Exception;
-
- void uninstallFeature(String name, String version) throws Exception;
-
- Feature[] listFeatures() throws Exception;
-
- Feature[] listInstalledFeatures();
-
- boolean isInstalled(Feature f);
-
- Feature getFeature(String name, String version) throws Exception;
-
- Feature getFeature(String name) throws Exception;
-}
diff --git a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/Repository.java b/karaf/features/core/src/main/java/org/apache/felix/karaf/features/Repository.java
deleted file mode 100644
index a098825..0000000
--- a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/Repository.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features;
-
-import java.net.URI;
-
-/**
- * A repository of features.
- */
-public interface Repository {
-
- String getName();
-
- URI getURI();
-
- URI[] getRepositories() throws Exception;
-
- Feature[] getFeatures() throws Exception;
-
-}
diff --git a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/RepositoryEvent.java b/karaf/features/core/src/main/java/org/apache/felix/karaf/features/RepositoryEvent.java
deleted file mode 100644
index f62076a..0000000
--- a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/RepositoryEvent.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features;
-
-import java.util.EventObject;
-
-public class RepositoryEvent extends EventObject {
-
- public static enum EventType {
- RepositoryAdded,
- RepositoryRemoved,
- }
-
- private final EventType type;
- private final Repository repository;
- private final boolean replay;
-
- public RepositoryEvent(Repository repository, EventType type, boolean replay) {
- super(repository);
- this.type = type;
- this.repository = repository;
- this.replay = replay;
- }
-
- public EventType getType() {
- return type;
- }
-
- public Repository getRepository() {
- return repository;
- }
-
- public boolean isReplay() {
- return replay;
- }
-}
\ No newline at end of file
diff --git a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeatureImpl.java b/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeatureImpl.java
deleted file mode 100644
index 0ae7c6b..0000000
--- a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeatureImpl.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.internal;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.felix.karaf.features.Feature;
-
-/**
- * A feature
- */
-public class FeatureImpl implements Feature {
-
- private String id;
- private String name;
- private String version;
- private List<Feature> dependencies = new ArrayList<Feature>();
- private List<String> bundles = new ArrayList<String>();
- private Map<String, Map<String,String>> configs = new HashMap<String, Map<String,String>>();
- public static String SPLIT_FOR_NAME_AND_VERSION = "_split_for_name_and_version_";
- public static String DEFAULT_VERSION = "0.0.0";
-
- public FeatureImpl(String name) {
- this(name, DEFAULT_VERSION);
- }
-
- public FeatureImpl(String name, String version) {
- this.name = name;
- this.version = version;
- this.id = name + "-" + version;
- }
-
- public String getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public List<Feature> getDependencies() {
- return dependencies;
- }
-
- public List<String> getBundles() {
- return bundles;
- }
-
- public Map<String, Map<String, String>> getConfigurations() {
- return configs;
- }
-
- public void addDependency(Feature dependency) {
- dependencies.add(dependency);
- }
-
- public void addBundle(String bundle) {
- bundles.add(bundle);
- }
-
- public void addConfig(String name, Map<String,String> properties) {
- configs.put(name, properties);
- }
-
- public String toString() {
- String ret = getName() + SPLIT_FOR_NAME_AND_VERSION + getVersion();
- return ret;
- }
-
- public static Feature valueOf(String str) {
- if (str.indexOf(SPLIT_FOR_NAME_AND_VERSION) >= 0) {
- String strName = str.substring(0, str.indexOf(SPLIT_FOR_NAME_AND_VERSION));
- String strVersion = str.substring(str.indexOf(SPLIT_FOR_NAME_AND_VERSION)
- + SPLIT_FOR_NAME_AND_VERSION.length(), str.length());
- return new FeatureImpl(strName, strVersion);
- } else {
- return new FeatureImpl(str);
- }
-
-
- }
-
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- FeatureImpl feature = (FeatureImpl) o;
-
- if (!name.equals(feature.name)) return false;
- if (!version.equals(feature.version)) return false;
-
- return true;
- }
-
- public int hashCode() {
- int result = name.hashCode();
- result = 31 * result + version.hashCode();
- return result;
- }
-}
diff --git a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java b/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java
deleted file mode 100644
index df9b77c..0000000
--- a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java
+++ /dev/null
@@ -1,963 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.internal;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.*;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.jar.JarInputStream;
-import java.util.jar.Manifest;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.felix.karaf.features.Feature;
-import org.apache.felix.karaf.features.FeatureEvent;
-import org.apache.felix.karaf.features.FeaturesListener;
-import org.apache.felix.karaf.features.FeaturesService;
-import org.apache.felix.karaf.features.Repository;
-import org.apache.felix.karaf.features.RepositoryEvent;
-import org.apache.felix.utils.manifest.Clause;
-import org.apache.felix.utils.manifest.Parser;
-import org.apache.felix.utils.version.VersionRange;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.Version;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-import org.osgi.service.prefs.PreferencesService;
-import org.osgi.service.startlevel.StartLevel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.helpers.MessageFormatter;
-
-import static java.lang.String.format;
-
-/**
- * The Features service implementation.
- * Adding a repository url will load the features contained in this repository and
- * create dummy sub shells. When invoked, these commands will prompt the user for
- * installing the needed bundles.
- *
- */
-public class FeaturesServiceImpl implements FeaturesService {
-
- public static final String CONFIG_KEY = "org.apache.felix.karaf.features.configKey";
-
- private static final Logger LOGGER = LoggerFactory.getLogger(FeaturesServiceImpl.class);
-
- private BundleContext bundleContext;
- private ConfigurationAdmin configAdmin;
- private PackageAdmin packageAdmin;
- private StartLevel startLevel;
- private PreferencesService preferences;
- private Set<URI> uris;
- private Map<URI, RepositoryImpl> repositories = new HashMap<URI, RepositoryImpl>();
- private Map<String, Map<String, Feature>> features;
- private Map<Feature, Set<Long>> installed = new HashMap<Feature, Set<Long>>();
- private String boot;
- private boolean bootFeaturesInstalled;
- private List<FeaturesListener> listeners = new CopyOnWriteArrayList<FeaturesListener>();
-
- public BundleContext getBundleContext() {
- return bundleContext;
- }
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- public ConfigurationAdmin getConfigAdmin() {
- return configAdmin;
- }
-
- public void setConfigAdmin(ConfigurationAdmin configAdmin) {
- this.configAdmin = configAdmin;
- }
-
- public PackageAdmin getPackageAdmin() {
- return packageAdmin;
- }
-
- public void setPackageAdmin(PackageAdmin packageAdmin) {
- this.packageAdmin = packageAdmin;
- }
-
- public PreferencesService getPreferences() {
- return preferences;
- }
-
- public void setPreferences(PreferencesService preferences) {
- this.preferences = preferences;
- }
-
- public StartLevel getStartLevel() {
- return startLevel;
- }
-
- public void setStartLevel(StartLevel startLevel) {
- this.startLevel = startLevel;
- }
-
- public void registerListener(FeaturesListener listener) {
- listeners.add(listener);
- for (Repository repository : listRepositories()) {
- listener.repositoryEvent(new RepositoryEvent(repository, RepositoryEvent.EventType.RepositoryAdded, true));
- }
- for (Feature feature : listInstalledFeatures()) {
- listener.featureEvent(new FeatureEvent(feature, FeatureEvent.EventType.FeatureInstalled, true));
- }
- }
-
- public void unregisterListener(FeaturesListener listener) {
- listeners.remove(listener);
- }
-
- public void setUrls(String uris) throws URISyntaxException {
- String[] s = uris.split(",");
- this.uris = new HashSet<URI>();
- for (String value : s) {
- this.uris.add(new URI(value));
- }
- }
-
- public void setBoot(String boot) {
- this.boot = boot;
- }
-
- public void addRepository(URI uri) throws Exception {
- if (!repositories.containsKey(uri)) {
- internalAddRepository(uri);
- saveState();
- }
- }
-
- protected RepositoryImpl internalAddRepository(URI uri) throws Exception {
- RepositoryImpl repo = null;
- repo = new RepositoryImpl(uri);
- repo.load();
- repositories.put(uri, repo);
- callListeners(new RepositoryEvent(repo, RepositoryEvent.EventType.RepositoryAdded, false));
- features = null;
- return repo;
-
- }
-
- public void removeRepository(URI uri) {
- if (repositories.containsKey(uri)) {
- internalRemoveRepository(uri);
- saveState();
- }
- }
-
- public void internalRemoveRepository(URI uri) {
- Repository repo = repositories.remove(uri);
- callListeners(new RepositoryEvent(repo, RepositoryEvent.EventType.RepositoryRemoved, false));
- features = null;
- }
-
- public Repository[] listRepositories() {
- Collection<RepositoryImpl> repos = repositories.values();
- return repos.toArray(new Repository[repos.size()]);
- }
-
- public void installAllFeatures(URI uri) throws Exception {
- RepositoryImpl repo = internalAddRepository(uri);
- for (Feature f : repo.getFeatures()) {
- installFeature(f.getName(), f.getVersion());
- }
- internalRemoveRepository(uri);
- }
-
- public void uninstallAllFeatures(URI uri) throws Exception {
- RepositoryImpl repo = internalAddRepository(uri);
- for (Feature f : repo.getFeatures()) {
- uninstallFeature(f.getName(), f.getVersion());
- }
- internalRemoveRepository(uri);
- }
-
- public void installFeature(String name) throws Exception {
- installFeature(name, FeatureImpl.DEFAULT_VERSION);
- }
-
- public void installFeature(String name, String version) throws Exception {
- installFeature(name, version, EnumSet.noneOf(Option.class));
- }
-
- public void installFeature(String name, String version, EnumSet<Option> options) throws Exception {
- Feature f = getFeature(name, version);
- if (f == null) {
- throw new Exception("No feature named '" + name
- + "' with version '" + version + "' available");
- }
- installFeature(f, options);
- }
-
- public void installFeature(Feature f, EnumSet<Option> options) throws Exception {
- installFeatures(Collections.singleton(f), options);
- }
-
- public void installFeatures(Set<Feature> features, EnumSet<Option> options) throws Exception {
- InstallationState state = new InstallationState();
- InstallationState failure = new InstallationState();
- try {
- // Install everything
- for (Feature f : features) {
- InstallationState s = new InstallationState();
- try {
- doInstallFeature(s, f);
- state.bundles.addAll(s.bundles);
- state.features.putAll(s.features);
- state.installed.addAll(s.installed);
- } catch (Exception e) {
- failure.bundles.addAll(s.bundles);
- failure.features.putAll(s.features);
- failure.installed.addAll(s.installed);
- if (options.contains(Option.ContinueBatchOnFailure)) {
- LOGGER.info("Error when installing feature {}: {}", f.getName(), e);
- } else {
- throw e;
- }
- }
- }
- // Find bundles to refresh
- boolean print = options.contains(Option.PrintBundlesToRefresh);
- boolean refresh = !options.contains(Option.NoAutoRefreshBundles);
- if (print || refresh) {
- Set<Bundle> bundlesToRefresh = findBundlesToRefresh(state);
- StringBuilder sb = new StringBuilder();
- for (Bundle b : bundlesToRefresh) {
- if (sb.length() > 0) {
- sb.append(", ");
- }
- sb.append(b.getSymbolicName()).append(" (").append(b.getBundleId()).append(")");
- }
- LOGGER.info("Bundles to refresh: {}", sb.toString());
- if (!bundlesToRefresh.isEmpty()) {
- if (print) {
- if (refresh) {
- System.out.println("Refreshing bundles " + sb.toString());
- } else {
- System.out.println("The following bundles may need to be refreshed: " + sb.toString());
- }
- }
- if (refresh) {
- LOGGER.info("Refreshing bundles: {}", sb.toString());
- getPackageAdmin().refreshPackages(bundlesToRefresh.toArray(new Bundle[bundlesToRefresh.size()]));
- }
- }
- }
- // Start all bundles
- for (Bundle b : state.bundles) {
- // do not start fragment bundles
- Dictionary d = b.getHeaders();
- String fragmentHostHeader = (String) d.get(Constants.FRAGMENT_HOST);
- if (fragmentHostHeader == null || fragmentHostHeader.trim().length() == 0) {
- // do not start bundles that are persistently stopped
- if (state.installed.contains(b)
- || (b.getState() != Bundle.STARTING && b.getState() != Bundle.ACTIVE
- && getStartLevel().isBundlePersistentlyStarted(b))) {
- try {
- b.start();
- } catch (BundleException be) {
- String[] msgdata = new String[]{
- b.getLocation(),
- getFeaturesContainingBundleList(b),
- be.getMessage()
- };
- String msg = MessageFormatter.arrayFormat("Could not start bundle {} in feature(s) {}: {}", msgdata);
- throw new Exception(msg, be);
- }
- }
- }
- }
- // Clean up for batch
- if (!options.contains(Option.NoCleanIfFailure)) {
- failure.installed.removeAll(state.bundles);
- for (Bundle b : failure.installed) {
- try {
- b.uninstall();
- } catch (Exception e2) {
- // Ignore
- }
- }
- }
- } catch (Exception e) {
- // cleanup on error
- if (!options.contains(Option.NoCleanIfFailure)) {
- // Uninstall everything
- for (Bundle b : state.installed) {
- try {
- b.uninstall();
- } catch (Exception e2) {
- // Ignore
- }
- }
- for (Bundle b : failure.installed) {
- try {
- b.uninstall();
- } catch (Exception e2) {
- // Ignore
- }
- }
- } else {
- // Force start of bundles so that they are flagged as persistently started
- for (Bundle b : state.installed) {
- try {
- b.start();
- } catch (Exception e2) {
- // Ignore
- }
- }
- }
- // rethrow exception
- throw e;
- }
- for (Feature f : features) {
- callListeners(new FeatureEvent(f, FeatureEvent.EventType.FeatureInstalled, false));
- }
- for (Map.Entry<Feature, Set<Long>> e : state.features.entrySet()) {
- installed.put(e.getKey(), e.getValue());
- }
- saveState();
- }
-
- protected static class InstallationState {
- final Set<Bundle> installed = new HashSet<Bundle>();
- final List<Bundle> bundles = new ArrayList<Bundle>();
- final Map<Feature, Set<Long>> features = new HashMap<Feature, Set<Long>>();
- }
-
- protected void doInstallFeature(InstallationState state, Feature feature) throws Exception {
- for (Feature dependency : feature.getDependencies()) {
- Feature f = getFeature(dependency.getName(), dependency.getVersion());
- if (f == null) {
- throw new Exception("No feature named '" + dependency.getName()
- + "' with version '" + dependency.getVersion() + "' available");
- }
- doInstallFeature(state, f);
- }
- for (String config : feature.getConfigurations().keySet()) {
- Dictionary<String,String> props = new Hashtable<String, String>(feature.getConfigurations().get(config));
- String[] pid = parsePid(config);
- Configuration cfg = findExistingConfiguration(configAdmin, pid[0], pid[1]);
- if (cfg == null) {
- cfg = createConfiguration(configAdmin, pid[0], pid[1]);
- String key = (pid[1] == null ? pid[0] : pid[0] + "-" + pid[1]);
- props.put(CONFIG_KEY, key);
- if (cfg.getBundleLocation() != null) {
- cfg.setBundleLocation(null);
- }
- cfg.update(props);
- }
- }
- Set<Long> bundles = new TreeSet<Long>();
- for (String bundleLocation : feature.getBundles()) {
- Bundle b = installBundleIfNeeded(state, bundleLocation);
- bundles.add(b.getBundleId());
- }
- state.features.put(feature, bundles);
- }
-
- protected Set<Bundle> findBundlesToRefresh(InstallationState state) {
- Set<Bundle> bundles = new HashSet<Bundle>();
- bundles.addAll(findBundlesWithOptionalPackagesToRefresh(state));
- bundles.addAll(findBundlesWithFramentsToRefresh(state));
- return bundles;
- }
-
- protected Set<Bundle> findBundlesWithFramentsToRefresh(InstallationState state) {
- Set<Bundle> bundles = new HashSet<Bundle>();
- Set<Bundle> oldBundles = new HashSet<Bundle>(state.bundles);
- oldBundles.removeAll(state.installed);
- if (!oldBundles.isEmpty()) {
- for (Bundle b : state.installed) {
- String hostHeader = (String) b.getHeaders().get(Constants.FRAGMENT_HOST);
- if (hostHeader != null) {
- Clause[] clauses = Parser.parseHeader(hostHeader);
- if (clauses != null && clauses.length > 0) {
- Clause path = clauses[0];
- for (Bundle hostBundle : oldBundles) {
- if (hostBundle.getSymbolicName().equals(path.getName())) {
- String ver = path.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE);
- if (ver != null) {
- VersionRange v = VersionRange.parseVersionRange(ver);
- if (v.contains(hostBundle.getVersion())) {
- bundles.add(hostBundle);
- }
- } else {
- bundles.add(hostBundle);
- }
- }
- }
- }
- }
- }
- }
- return bundles;
- }
-
- protected Set<Bundle> findBundlesWithOptionalPackagesToRefresh(InstallationState state) {
- // First pass: include all bundles contained in these features
- Set<Bundle> bundles = new HashSet<Bundle>(state.bundles);
- bundles.removeAll(state.installed);
- if (bundles.isEmpty()) {
- return bundles;
- }
- // Second pass: for each bundle, check if there is any unresolved optional package that could be resolved
- Map<Bundle, List<Clause>> imports = new HashMap<Bundle, List<Clause>>();
- for (Iterator<Bundle> it = bundles.iterator(); it.hasNext();) {
- Bundle b = it.next();
- String importsStr = (String) b.getHeaders().get(Constants.IMPORT_PACKAGE);
- List<Clause> importsList = getOptionalImports(importsStr);
- if (importsList.isEmpty()) {
- it.remove();
- } else {
- imports.put(b, importsList);
- }
- }
- if (bundles.isEmpty()) {
- return bundles;
- }
- // Third pass: compute a list of packages that are exported by our bundles and see if
- // some exported packages can be wired to the optional imports
- List<Clause> exports = new ArrayList<Clause>();
- for (Bundle b : state.installed) {
- String exportsStr = (String) b.getHeaders().get(Constants.EXPORT_PACKAGE);
- if (exportsStr != null) {
- Clause[] exportsList = Parser.parseHeader(exportsStr);
- exports.addAll(Arrays.asList(exportsList));
- }
- }
- for (Iterator<Bundle> it = bundles.iterator(); it.hasNext();) {
- Bundle b = it.next();
- List<Clause> importsList = imports.get(b);
- for (Iterator<Clause> itpi = importsList.iterator(); itpi.hasNext();) {
- Clause pi = itpi.next();
- boolean matching = false;
- for (Clause pe : exports) {
- if (pi.getName().equals(pe.getName())) {
- String evStr = pe.getAttribute(Constants.VERSION_ATTRIBUTE);
- String ivStr = pi.getAttribute(Constants.VERSION_ATTRIBUTE);
- Version exported = evStr != null ? Version.parseVersion(evStr) : Version.emptyVersion;
- VersionRange imported = ivStr != null ? VersionRange.parseVersionRange(ivStr) : VersionRange.ANY_VERSION;
- if (imported.contains(exported)) {
- matching = true;
- break;
- }
- }
- }
- if (!matching) {
- itpi.remove();
- }
- }
- if (importsList.isEmpty()) {
- it.remove();
- } else {
- LOGGER.debug("Refeshing bundle {} ({}) to solve the following optional imports", b.getSymbolicName(), b.getBundleId());
- for (Clause p : importsList) {
- LOGGER.debug(" {}", p);
- }
-
- }
- }
- return bundles;
- }
-
- /*
- * Get the list of optional imports from an OSGi Import-Package string
- */
- protected List<Clause> getOptionalImports(String importsStr) {
- Clause[] imports = Parser.parseHeader(importsStr);
- List<Clause> result = new LinkedList<Clause>();
- for (int i = 0; i < imports.length; i++) {
- String resolution = imports[i].getDirective(Constants.RESOLUTION_DIRECTIVE);
- if (Constants.RESOLUTION_OPTIONAL.equals(resolution)) {
- result.add(imports[i]);
- }
- }
- return result;
- }
-
- protected Bundle installBundleIfNeeded(InstallationState state, String bundleLocation) throws IOException, BundleException {
- LOGGER.debug("Checking " + bundleLocation);
- InputStream is;
- try {
- is = new BufferedInputStream(new URL(bundleLocation).openStream());
- } catch (RuntimeException e) {
- LOGGER.error(e.getMessage());
- throw e;
- }
- try {
- is.mark(256 * 1024);
- JarInputStream jar = new JarInputStream(is);
- Manifest m = jar.getManifest();
- String sn = m.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
- String vStr = m.getMainAttributes().getValue(Constants.BUNDLE_VERSION);
- Version v = vStr == null ? Version.emptyVersion : Version.parseVersion(vStr);
- for (Bundle b : bundleContext.getBundles()) {
- if (b.getSymbolicName() != null && b.getSymbolicName().equals(sn)) {
- vStr = (String) b.getHeaders().get(Constants.BUNDLE_VERSION);
- Version bv = vStr == null ? Version.emptyVersion : Version.parseVersion(vStr);
- if (v.equals(bv)) {
- LOGGER.debug(" found installed bundle: " + b);
- state.bundles.add(b);
- return b;
- }
- }
- }
- try {
- is.reset();
- } catch (IOException e) {
- is.close();
- is = new BufferedInputStream(new URL(bundleLocation).openStream());
- }
- LOGGER.debug("Installing bundle " + bundleLocation);
- Bundle b = getBundleContext().installBundle(bundleLocation, is);
- state.bundles.add(b);
- state.installed.add(b);
- return b;
- } finally {
- is.close();
- }
- }
-
- public void uninstallFeature(String name) throws Exception {
- List<String> versions = new ArrayList<String>();
- for (Feature f : installed.keySet()) {
- if (name.equals(f.getName())) {
- versions.add(f.getVersion());
- }
- }
- if (versions.size() == 0) {
- throw new Exception("Feature named '" + name + "' is not installed");
- } else if (versions.size() > 1) {
- StringBuilder sb = new StringBuilder();
- sb.append("Feature named '").append(name).append("' has multiple versions installed (");
- for (int i = 0; i < versions.size(); i++) {
- if (i > 0) {
- sb.append(", ");
- }
- sb.append(versions.get(i));
- }
- sb.append("). Please specify the version to uninstall.");
- throw new Exception(sb.toString());
- }
- uninstallFeature(name, versions.get(0));
- }
-
- public void uninstallFeature(String name, String version) throws Exception {
- Feature feature = getFeature(name, version);
- if (feature == null || !installed.containsKey(feature)) {
- throw new Exception("Feature named '" + name
- + "' with version '" + version + "' is not installed");
- }
- // Grab all the bundles installed by this feature
- // and remove all those who will still be in use.
- // This gives this list of bundles to uninstall.
- Set<Long> bundles = installed.remove(feature);
- for (Set<Long> b : installed.values()) {
- bundles.removeAll(b);
- }
- for (long bundleId : bundles) {
- Bundle b = getBundleContext().getBundle(bundleId);
- if (b != null) {
- b.uninstall();
- }
- }
- if (getPackageAdmin() != null) {
- getPackageAdmin().refreshPackages(null);
- }
- callListeners(new FeatureEvent(feature, FeatureEvent.EventType.FeatureInstalled, false));
- saveState();
- }
-
- public Feature[] listFeatures() throws Exception {
- Collection<Feature> features = new ArrayList<Feature>();
- for (Map<String, Feature> featureWithDifferentVersion : getFeatures().values()) {
- for (Feature f : featureWithDifferentVersion.values()) {
- features.add(f);
- }
- }
- return features.toArray(new Feature[features.size()]);
- }
-
- public Feature[] listInstalledFeatures() {
- Set<Feature> result = installed.keySet();
- return result.toArray(new Feature[result.size()]);
- }
-
- public boolean isInstalled(Feature f) {
- return installed.containsKey(f);
- }
-
- public Feature getFeature(String name) throws Exception {
- return getFeature(name, FeatureImpl.DEFAULT_VERSION);
- }
-
- public Feature getFeature(String name, String version) throws Exception {
- if (version != null) {
- version = version.trim();
- }
- Map<String, Feature> versions = getFeatures().get(name);
- if (versions == null || versions.isEmpty()) {
- return null;
- } else {
- Feature feature = versions.get(version);
- if (feature == null && FeatureImpl.DEFAULT_VERSION.equals(version)) {
- Version latest = new Version(cleanupVersion(version));
- for (String available : versions.keySet()) {
- Version availableVersion = new Version(cleanupVersion(available));
- if (availableVersion.compareTo(latest) > 0) {
- feature = versions.get(available);
- latest = availableVersion;
- }
- }
- }
- return feature;
- }
- }
-
- protected Map<String, Map<String, Feature>> getFeatures() throws Exception {
- if (features == null) {
- //the outer map's key is feature name, the inner map's key is feature version
- Map<String, Map<String, Feature>> map = new HashMap<String, Map<String, Feature>>();
- // Two phase load:
- // * first load dependent repositories
- for (;;) {
- boolean newRepo = false;
- for (Repository repo : listRepositories()) {
- for (URI uri : repo.getRepositories()) {
- if (!repositories.containsKey(uri)) {
- internalAddRepository(uri);
- newRepo = true;
- }
- }
- }
- if (!newRepo) {
- break;
- }
- }
- // * then load all features
- for (Repository repo : repositories.values()) {
- for (Feature f : repo.getFeatures()) {
- if (map.get(f.getName()) == null) {
- Map<String, Feature> versionMap = new HashMap<String, Feature>();
- versionMap.put(f.getVersion(), f);
- map.put(f.getName(), versionMap);
- } else {
- map.get(f.getName()).put(f.getVersion(), f);
- }
- }
- }
- features = map;
- }
- return features;
- }
-
- public void start() throws Exception {
- if (!loadState()) {
- if (uris != null) {
- for (URI uri : uris) {
- try {
- internalAddRepository(uri);
- } catch (Exception e) {
- LOGGER.warn(format("Unable to add features repository %s at startup", uri), e);
- }
- }
- }
- saveState();
- }
- if (boot != null && !bootFeaturesInstalled) {
- new Thread() {
- public void run() {
- String[] list = boot.split(",");
- Set<Feature> features = new LinkedHashSet<Feature>();
- for (String f : list) {
- if (f.length() > 0) {
- try {
- Feature feature = getFeature(f, FeatureImpl.DEFAULT_VERSION);
- if (feature != null) {
- features.add(feature);
- } else {
- LOGGER.error("Error installing boot feature " + f + ": feature not found");
- }
- } catch (Exception e) {
- LOGGER.error("Error installing boot feature " + f, e);
- }
- }
- }
- try {
- installFeatures(features, EnumSet.of(Option.NoCleanIfFailure, Option.ContinueBatchOnFailure));
- } catch (Exception e) {
- LOGGER.error("Error installing boot features", e);
- }
- bootFeaturesInstalled = true;
- saveState();
- }
- }.start();
- }
- }
-
- public void stop() throws Exception {
- uris = new HashSet<URI>(repositories.keySet());
- while (!repositories.isEmpty()) {
- internalRemoveRepository(repositories.keySet().iterator().next());
- }
- }
-
- protected String[] parsePid(String pid) {
- int n = pid.indexOf('-');
- if (n > 0) {
- String factoryPid = pid.substring(n + 1);
- pid = pid.substring(0, n);
- return new String[]{pid, factoryPid};
- } else {
- return new String[]{pid, null};
- }
- }
-
- protected Configuration createConfiguration(ConfigurationAdmin configurationAdmin,
- String pid, String factoryPid) throws IOException, InvalidSyntaxException {
- if (factoryPid != null) {
- return configurationAdmin.createFactoryConfiguration(pid, null);
- } else {
- return configurationAdmin.getConfiguration(pid, null);
- }
- }
-
- protected Configuration findExistingConfiguration(ConfigurationAdmin configurationAdmin,
- String pid, String factoryPid) throws IOException, InvalidSyntaxException {
- String key = (factoryPid == null ? pid : pid + "-" + factoryPid);
- String filter;
- if (factoryPid == null) {
- filter = "(" + Constants.SERVICE_PID + "=" + pid + ")";
- } else {
- filter = "(" + ConfigurationAdmin.SERVICE_FACTORYPID + "=" + factoryPid + ")";
- }
- Configuration[] configurations = configurationAdmin.listConfigurations(filter);
- if (configurations != null && configurations.length > 0)
- {
- return configurations[0];
- }
- else
- {
- return null;
- }
- }
-
- protected void saveState() {
- try {
- Preferences prefs = preferences.getUserPreferences("FeaturesServiceState");
- saveSet(prefs.node("repositories"), repositories.keySet());
- saveMap(prefs.node("features"), installed);
- prefs.putBoolean("bootFeaturesInstalled", bootFeaturesInstalled);
- prefs.flush();
- } catch (Exception e) {
- LOGGER.error("Error persisting FeaturesService state", e);
- }
- }
-
- protected boolean loadState() {
- try {
- Preferences prefs = preferences.getUserPreferences("FeaturesServiceState");
- if (prefs.nodeExists("repositories")) {
- Set<URI> repositories = loadSet(prefs.node("repositories"));
- for (URI repo : repositories) {
- internalAddRepository(repo);
- }
- installed = loadMap(prefs.node("features"));
- for (Feature f : installed.keySet()) {
- callListeners(new FeatureEvent(f, FeatureEvent.EventType.FeatureInstalled, true));
- }
- bootFeaturesInstalled = prefs.getBoolean("bootFeaturesInstalled", false);
- return true;
- }
- } catch (Exception e) {
- LOGGER.error("Error loading FeaturesService state", e);
- }
- return false;
- }
-
- protected void saveSet(Preferences node, Set<URI> set) throws BackingStoreException {
- List<URI> l = new ArrayList<URI>(set);
- node.clear();
- node.putInt("count", l.size());
- for (int i = 0; i < l.size(); i++) {
- node.put("item." + i, l.get(i).toString());
- }
- }
-
- protected Set<URI> loadSet(Preferences node) {
- Set<URI> l = new HashSet<URI>();
- int count = node.getInt("count", 0);
- for (int i = 0; i < count; i++) {
- l.add(URI.create(node.get("item." + i, null)));
- }
- return l;
- }
-
- protected void saveMap(Preferences node, Map<Feature, Set<Long>> map) throws BackingStoreException {
- node.clear();
- for (Map.Entry<Feature, Set<Long>> entry : map.entrySet()) {
- Feature key = entry.getKey();
- String val = createValue(entry.getValue());
- node.put(key.toString(), val);
- }
- }
-
- protected Map<Feature, Set<Long>> loadMap(Preferences node) throws BackingStoreException {
- Map<Feature, Set<Long>> map = new HashMap<Feature, Set<Long>>();
- for (String key : node.keys()) {
- String val = node.get(key, null);
- Set<Long> set = readValue(val);
- map.put(FeatureImpl.valueOf(key), set);
- }
- return map;
- }
-
- protected String createValue(Set<Long> set) {
- StringBuilder sb = new StringBuilder();
- for (long i : set) {
- if (sb.length() > 0) {
- sb.append(",");
- }
- sb.append(i);
- }
- return sb.toString();
- }
-
- protected Set<Long> readValue(String val) {
- Set<Long> set = new HashSet<Long>();
- if (val != null && val.length() != 0) {
- for (String str : val.split(",")) {
- set.add(Long.parseLong(str));
- }
- }
- return set;
- }
-
- protected void callListeners(FeatureEvent event) {
- for (FeaturesListener listener : listeners) {
- listener.featureEvent(event);
- }
- }
-
- protected void callListeners(RepositoryEvent event) {
- for (FeaturesListener listener : listeners) {
- listener.repositoryEvent(event);
- }
- }
-
- static Pattern fuzzyVersion = Pattern.compile("(\\d+)(\\.(\\d+)(\\.(\\d+))?)?([^a-zA-Z0-9](.*))?",
- Pattern.DOTALL);
- static Pattern fuzzyModifier = Pattern.compile("(\\d+[.-])*(.*)",
- Pattern.DOTALL);
-
- /**
- * Clean up version parameters. Other builders use more fuzzy definitions of
- * the version syntax. This method cleans up such a version to match an OSGi
- * version.
- *
- * @param version
- * @return
- */
- static public String cleanupVersion(String version) {
- Matcher m = fuzzyVersion.matcher(version);
- if (m.matches()) {
- StringBuffer result = new StringBuffer();
- String d1 = m.group(1);
- String d2 = m.group(3);
- String d3 = m.group(5);
- String qualifier = m.group(7);
-
- if (d1 != null) {
- result.append(d1);
- if (d2 != null) {
- result.append(".");
- result.append(d2);
- if (d3 != null) {
- result.append(".");
- result.append(d3);
- if (qualifier != null) {
- result.append(".");
- cleanupModifier(result, qualifier);
- }
- } else if (qualifier != null) {
- result.append(".0.");
- cleanupModifier(result, qualifier);
- }
- } else if (qualifier != null) {
- result.append(".0.0.");
- cleanupModifier(result, qualifier);
- }
- return result.toString();
- }
- }
- return version;
- }
-
- static void cleanupModifier(StringBuffer result, String modifier) {
- Matcher m = fuzzyModifier.matcher(modifier);
- if (m.matches())
- modifier = m.group(2);
-
- for (int i = 0; i < modifier.length(); i++) {
- char c = modifier.charAt(i);
- if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')
- || (c >= 'A' && c <= 'Z') || c == '_' || c == '-')
- result.append(c);
- }
- }
-
- public Set<Feature> getFeaturesContainingBundle (Bundle bundle) throws Exception {
- Set<Feature> features = new HashSet<Feature>();
- for (Map<String, Feature> featureMap : this.getFeatures().values()) {
- for (Feature f : featureMap.values()) {
- if (f.getBundles().contains(bundle.getLocation())) {
- features.add(f);
- }
- }
- }
- return features;
- }
-
- private String getFeaturesContainingBundleList(Bundle bundle) throws Exception {
- Set<Feature> features = getFeaturesContainingBundle(bundle);
- StringBuilder buffer = new StringBuilder();
- Iterator<Feature> iter = features.iterator();
- while (iter.hasNext()) {
- Feature feature= iter.next();
- buffer.append(feature.getId());
- if (iter.hasNext()) {
- buffer.append(", ");
- }
- }
- return buffer.toString();
- }
-}
diff --git a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/RepositoryImpl.java b/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/RepositoryImpl.java
deleted file mode 100644
index 374f3cf..0000000
--- a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/RepositoryImpl.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.internal;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URLConnection;
-import java.rmi.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.apache.felix.karaf.features.Repository;
-import org.apache.felix.karaf.features.Feature;
-import org.xml.sax.SAXException;
-
-/**
- * The repository implementation.
- */
-public class RepositoryImpl implements Repository {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(RepositoryImpl.class);
- private int unnamedRepoId = 0;
- private String name;
- private URI uri;
- private List<Feature> features;
- private List<URI> repositories;
-
- public RepositoryImpl(URI uri) {
- this.uri = uri;
- }
-
- public String getName() {
- return name;
- }
-
- public URI getURI() {
- return uri;
- }
-
- public URI[] getRepositories() throws Exception {
- if (repositories == null) {
- load();
- }
- return repositories.toArray(new URI[repositories.size()]);
- }
-
- public Feature[] getFeatures() throws Exception {
- if (features == null) {
- load();
- }
- return features.toArray(new Feature[features.size()]);
- }
-
- public void load() throws IOException {
- try {
- repositories = new ArrayList<URI>();
- features = new ArrayList<Feature>();
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- URLConnection conn = uri.toURL().openConnection();
- conn.setDefaultUseCaches(false);
- Document doc = factory.newDocumentBuilder().parse(conn.getInputStream());
- String temp = doc.getDocumentElement().getAttribute( "name" );
- if ("".equals(temp)) {
- name = "repo-" + String.valueOf(unnamedRepoId++);
- }
- else {
- name = temp;
- }
- if ( uri.toString().startsWith( "bundle" ) ) {
- name += "*";
- }
-
- NodeList nodes = doc.getDocumentElement().getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
- if (!(node instanceof Element)) {
- continue;
- }
- if ("repository".equals(node.getNodeName())) {
- Element e = (Element) nodes.item(i);
- try {
- URI newrepo = new URI(e.getTextContent());
- repositories.add(newrepo);
- } catch (URISyntaxException ex) {
- LOGGER.error("Could not load feature repository: " + ex.getMessage() + " in feature repository " + uri);
- }
- } else if ("feature".equals(node.getNodeName())) {
- Element e = (Element) nodes.item(i);
- String name = e.getAttribute("name");
- String version = e.getAttribute("version");
- FeatureImpl f;
- if (version != null && version.length() > 0) {
- f = new FeatureImpl(name, version);
- } else {
- f = new FeatureImpl(name);
- }
-
- NodeList featureNodes = e.getElementsByTagName("feature");
- for (int j = 0; j < featureNodes.getLength(); j++) {
- Element b = (Element) featureNodes.item(j);
- String dependencyFeatureVersion = b.getAttribute("version");
- if (dependencyFeatureVersion != null && dependencyFeatureVersion.length() > 0) {
- f.addDependency(new FeatureImpl(b.getTextContent(), dependencyFeatureVersion));
- } else {
- f.addDependency(new FeatureImpl(b.getTextContent()));
- }
- }
- NodeList configNodes = e.getElementsByTagName("config");
- for (int j = 0; j < configNodes.getLength(); j++) {
- Element c = (Element) configNodes.item(j);
- String cfgName = c.getAttribute("name");
- String data = c.getTextContent();
- Properties properties = new Properties();
- properties.load(new ByteArrayInputStream(data.getBytes()));
- interpolation(properties);
- Map<String, String> hashtable = new Hashtable<String, String>();
- for (Object key : properties.keySet()) {
- String n = key.toString();
- hashtable.put(n, properties.getProperty(n));
- }
- f.addConfig(cfgName, hashtable);
- }
- NodeList bundleNodes = e.getElementsByTagName("bundle");
- for (int j = 0; j < bundleNodes.getLength(); j++) {
- Element b = (Element) bundleNodes.item(j);
- f.addBundle(b.getTextContent());
- }
- features.add(f);
- }
- }
- } catch (SAXException e) {
- throw (IOException) new IOException().initCause(e);
- } catch (ParserConfigurationException e) {
- throw (IOException) new IOException().initCause(e);
- } catch (IllegalArgumentException e) {
- throw (IOException) new IOException(e.getMessage() + " : " + uri).initCause(e);
- } catch (Exception e) {
- throw (IOException) new IOException(e.getMessage() + " : " + uri).initCause(e);
- }
- }
-
- protected void interpolation(Properties properties) {
- for (Enumeration e = properties.propertyNames(); e.hasMoreElements();) {
- String key = (String)e.nextElement();
- String val = properties.getProperty(key);
- Matcher matcher = Pattern.compile("\\$\\{([^}]+)\\}").matcher(val);
- while (matcher.find()) {
- String rep = System.getProperty(matcher.group(1));
- if (rep != null) {
- val = val.replace(matcher.group(0), rep);
- matcher.reset(val);
- }
- }
- properties.put(key, val);
- }
- }
-
-}
diff --git a/karaf/features/core/src/main/resources/OSGI-INF/blueprint/gshell-features.xml b/karaf/features/core/src/main/resources/OSGI-INF/blueprint/gshell-features.xml
deleted file mode 100644
index 24480f4..0000000
--- a/karaf/features/core/src/main/resources/OSGI-INF/blueprint/gshell-features.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
-
- <ext:property-placeholder placeholder-prefix="$(" placeholder-suffix=")"/>
-
- <ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]" ignore-missing-locations="true">
- <ext:default-properties>
- <ext:property name="featuresRepositories" value=""/>
- <ext:property name="featuresBoot" value=""/>
- </ext:default-properties>
- <ext:location>file:$(karaf.base)/etc/org.apache.felix.karaf.features.cfg</ext:location>
- </ext:property-placeholder>
-
- <bean id="featuresService" class="org.apache.felix.karaf.features.internal.FeaturesServiceImpl" init-method="start" destroy-method="stop">
- <property name="urls" value="$[featuresRepositories]" />
- <property name="boot" value="$[featuresBoot]" />
- <property name="configAdmin" ref="configAdmin" />
- <property name="packageAdmin" ref="packageAdmin" />
- <property name="preferences" ref="preferences" />
- <property name="startLevel" ref="startLevel" />
- <property name="bundleContext" ref="blueprintBundleContext" />
- </bean>
-
- <reference-list id="featuresListeners" interface="org.apache.felix.karaf.features.FeaturesListener" availability="optional">
- <reference-listener ref="featuresService"
- bind-method="registerListener"
- unbind-method="unregisterListener" />
- </reference-list>
-
- <reference id="configAdmin" interface="org.osgi.service.cm.ConfigurationAdmin" />
-
- <reference id="preferences" interface="org.osgi.service.prefs.PreferencesService" availability="optional"/>
-
- <reference id="packageAdmin" interface="org.osgi.service.packageadmin.PackageAdmin" />
-
- <reference id="startLevel" interface="org.osgi.service.startlevel.StartLevel" />
-
- <service ref="featuresService" interface="org.apache.felix.karaf.features.FeaturesService" />
-
-</blueprint>
diff --git a/karaf/features/core/src/test/java/org/apache/felix/karaf/features/FeatureTest.java b/karaf/features/core/src/test/java/org/apache/felix/karaf/features/FeatureTest.java
deleted file mode 100644
index bd88118..0000000
--- a/karaf/features/core/src/test/java/org/apache/felix/karaf/features/FeatureTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features;
-
-import junit.framework.TestCase;
-import org.apache.felix.karaf.features.internal.FeatureImpl;
-
-public class FeatureTest extends TestCase {
-
- public void testValueOf() {
- Feature feature = FeatureImpl.valueOf("name" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "version");
- assertEquals(feature.getName(), "name");
- assertEquals(feature.getVersion(), "version");
- feature = FeatureImpl.valueOf("name");
- assertEquals(feature.getName(), "name");
- assertEquals(feature.getVersion(), FeatureImpl.DEFAULT_VERSION);
- }
-
-}
diff --git a/karaf/features/core/src/test/java/org/apache/felix/karaf/features/FeaturesServiceTest.java b/karaf/features/core/src/test/java/org/apache/felix/karaf/features/FeaturesServiceTest.java
deleted file mode 100644
index 2cbaa54..0000000
--- a/karaf/features/core/src/test/java/org/apache/felix/karaf/features/FeaturesServiceTest.java
+++ /dev/null
@@ -1,1083 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.EnumSet;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CopyOnWriteArraySet;
-import java.util.jar.JarInputStream;
-
-import junit.framework.TestCase;
-import org.apache.felix.karaf.features.internal.FeatureImpl;
-import org.apache.felix.karaf.features.internal.FeaturesServiceImpl;
-import org.easymock.EasyMock;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.osgi.service.prefs.Preferences;
-import org.osgi.service.prefs.PreferencesService;
-
-import static org.easymock.EasyMock.*;
-
-public class FeaturesServiceTest extends TestCase {
-
- public void testInstallFeature() throws Exception {
-
- String name = getJarUrl(Bundle.class);
-
- File tmp = File.createTempFile("smx", ".feature");
- PrintWriter pw = new PrintWriter(new FileWriter(tmp));
- pw.println("<features>");
- pw.println(" <feature name=\"f1\">");
- pw.println(" <bundle>" + name + "</bundle>");
- pw.println(" </feature>");
- pw.println("</features>");
- pw.close();
-
- URI uri = tmp.toURI();
-
- Preferences prefs = EasyMock.createMock(Preferences.class);
- PreferencesService preferencesService = EasyMock.createMock(PreferencesService.class);
- Preferences repositoriesNode = EasyMock.createMock(Preferences.class);
- Preferences featuresNode = EasyMock.createMock(Preferences.class);
- BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
- Bundle installedBundle = EasyMock.createMock(Bundle.class);
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- replay(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle);
-
- FeaturesServiceImpl svc = new FeaturesServiceImpl();
- svc.setPreferences(preferencesService);
- svc.setBundleContext(bundleContext);
- svc.addRepository(uri);
-
- Repository[] repositories = svc.listRepositories();
- assertNotNull(repositories);
- assertEquals(1, repositories.length);
- assertNotNull(repositories[0]);
- Feature[] features = repositories[0].getFeatures();
- assertNotNull(features);
- assertEquals(1, features.length);
- assertNotNull(features[0]);
- assertEquals("f1", features[0].getName());
- assertNotNull(features[0].getDependencies());
- assertEquals(0, features[0].getDependencies().size());
- assertNotNull(features[0].getBundles());
- assertEquals(1, features[0].getBundles().size());
- assertEquals(name, features[0].getBundles().get(0));
-
- verify(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle);
-
- reset(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle);
-
- expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
- expect(bundleContext.installBundle(isA(String.class),
- isA(InputStream.class))).andReturn(installedBundle);
- expect(installedBundle.getBundleId()).andReturn(12345L);
- expect(bundleContext.getBundle(12345L)).andReturn(installedBundle);
- expect(installedBundle.getHeaders()).andReturn(new Hashtable());
- installedBundle.start();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- featuresNode.put("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + FeatureImpl.DEFAULT_VERSION, "12345");
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- replay(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle);
-
- svc.installFeature("f1", FeatureImpl.DEFAULT_VERSION, EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles));
-
- Feature[] installed = svc.listInstalledFeatures();
- assertEquals(1, installed.length);
- assertEquals("f1", installed[0].getName());
- }
-
- public void testUninstallFeature() throws Exception {
-
- String name = getJarUrl(Bundle.class);
-
- File tmp = File.createTempFile("smx", ".feature");
- PrintWriter pw = new PrintWriter(new FileWriter(tmp));
- pw.println("<features>");
- pw.println(" <feature name=\"f1\" version=\"0.1\">");
- pw.println(" <bundle>" + name + "</bundle>");
- pw.println(" </feature>");
- pw.println(" <feature name=\"f1\" version=\"0.2\">");
- pw.println(" <bundle>" + name + "</bundle>");
- pw.println(" </feature>");
- pw.println("</features>");
- pw.close();
-
- URI uri = tmp.toURI();
-
- Preferences prefs = EasyMock.createMock(Preferences.class);
- PreferencesService preferencesService = EasyMock.createMock(PreferencesService.class);
- Preferences repositoriesNode = EasyMock.createMock(Preferences.class);
- Preferences featuresNode = EasyMock.createMock(Preferences.class);
- BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
- Bundle installedBundle = EasyMock.createMock(Bundle.class);
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- replay(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle);
-
- FeaturesServiceImpl svc = new FeaturesServiceImpl();
- svc.setPreferences(preferencesService);
- svc.setBundleContext(bundleContext);
- svc.addRepository(uri);
-
- verify(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle);
-
- reset(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle);
-
- // Installs f1 and 0.1
- expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
- expect(bundleContext.installBundle(isA(String.class),
- isA(InputStream.class))).andReturn(installedBundle);
- expect(installedBundle.getBundleId()).andReturn(12345L);
- expect(bundleContext.getBundle(12345L)).andReturn(installedBundle);
- expect(installedBundle.getHeaders()).andReturn(new Hashtable());
- installedBundle.start();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- featuresNode.put("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.1", "12345");
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // Installs f1 and 0.2
- expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
- expect(bundleContext.installBundle(isA(String.class),
- isA(InputStream.class))).andReturn(installedBundle);
- expect(installedBundle.getBundleId()).andReturn(123456L);
- expect(bundleContext.getBundle(123456L)).andReturn(installedBundle);
- expect(installedBundle.getHeaders()).andReturn(new Hashtable());
- installedBundle.start();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- featuresNode.put("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.1", "12345");
- featuresNode.put("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.2", "123456");
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // UnInstalls f1 and 0.1
- expect(bundleContext.getBundle(12345)).andReturn(installedBundle);
- installedBundle.uninstall();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- featuresNode.put("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.2", "123456");
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // UnInstalls f1 and 0.2
- expect(bundleContext.getBundle(123456)).andReturn(installedBundle);
- installedBundle.uninstall();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- replay(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle);
-
- try {
- svc.uninstallFeature("f1");
- fail("Uninstall should have failed as feature is not installed");
- } catch (Exception e) {
- // ok
- }
-
- svc.installFeature("f1", "0.1", EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles));
- svc.installFeature("f1", "0.2", EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles));
-
- try {
- svc.uninstallFeature("f1");
- fail("Uninstall should have failed as feature is installed in multiple versions");
- } catch (Exception e) {
- // ok
- }
-
- svc.uninstallFeature("f1", "0.1");
- svc.uninstallFeature("f1");
- }
-
- // Tests Add and Remove Repository
- public void testAddAndRemoveRepository() throws Exception {
-
- String name = getJarUrl(Bundle.class);
-
- File tmp = File.createTempFile("smx", ".feature");
- PrintWriter pw = new PrintWriter(new FileWriter(tmp));
- pw.println("<features>");
- pw.println(" <feature name=\"f1\" version=\"0.1\">");
- pw.println(" <bundle>" + name + "</bundle>");
- pw.println(" </feature>");
- pw.println(" <feature name=\"f1\" version=\"0.2\">");
- pw.println(" <bundle>" + name + "</bundle>");
- pw.println(" </feature>");
- pw.println(" <feature name=\"f2\" version=\"0.2\">");
- pw.println(" <bundle>" + name + "</bundle>");
- pw.println(" </feature>");
- pw.println("</features>");
- pw.close();
-
- URI uri = tmp.toURI();
-
- // loads the state
- Preferences prefs = EasyMock.createMock(Preferences.class);
- PreferencesService preferencesService = EasyMock.createMock(PreferencesService.class);
- Preferences repositoriesNode = EasyMock.createMock(Preferences.class);
- Preferences featuresNode = EasyMock.createMock(Preferences.class);
- BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
- Bundle installedBundle = EasyMock.createMock(Bundle.class);
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // SaveState for addRepository
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // SaveState for removeRepository
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 0);
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
- replay(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle);
-
- FeaturesServiceImpl svc = new FeaturesServiceImpl();
- svc.setPreferences(preferencesService);
- svc.setBundleContext(bundleContext);
-
- // Adds Repository
- svc.addRepository(uri);
-
- // Removes Repository
- svc.removeRepository(uri);
- }
-
- // Tests installing all features in a repo and uninstalling
- // all features in a repo
- public void testInstallUninstallAllFeatures() throws Exception {
-
- String name = getJarUrl(Bundle.class);
-
- File tmp = File.createTempFile("smx", ".feature");
- PrintWriter pw = new PrintWriter(new FileWriter(tmp));
- pw.println("<features>");
- pw.println(" <feature name=\"f1\" version=\"0.1\">");
- pw.println(" <bundle>" + name + "</bundle>");
- pw.println(" </feature>");
- pw.println(" <feature name=\"f1\" version=\"0.2\">");
- pw.println(" <bundle>" + name + "</bundle>");
- pw.println(" </feature>");
- pw.println(" <feature name=\"f2\" version=\"0.2\">");
- pw.println(" <bundle>" + name + "</bundle>");
- pw.println(" </feature>");
- pw.println("</features>");
- pw.close();
-
- URI uri = tmp.toURI();
-
- // loads the state
- Preferences prefs = EasyMock.createMock(Preferences.class);
- PreferencesService preferencesService = EasyMock.createMock(PreferencesService.class);
- Preferences repositoriesNode = EasyMock.createMock(Preferences.class);
- Preferences featuresNode = EasyMock.createMock(Preferences.class);
- BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
- Bundle installedBundle = EasyMock.createMock(Bundle.class);
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // Installs first feature name = f1, version = 0.1
- expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
- expect(bundleContext.installBundle(isA(String.class),
- isA(InputStream.class))).andReturn(installedBundle);
- expect(installedBundle.getBundleId()).andReturn(12345L);
- expect(bundleContext.getBundle(12345L)).andReturn(installedBundle);
- expect(installedBundle.getHeaders()).andReturn(new Hashtable());
- expect(installedBundle.getSymbolicName()).andReturn("bundle");
-
- installedBundle.start();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- featuresNode.put("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.1", "12345");
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // Installs second feature name = f1, version = 0.2
- expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
- expect(bundleContext.installBundle(isA(String.class),
- isA(InputStream.class))).andReturn(installedBundle);
- expect(installedBundle.getBundleId()).andReturn(123456L);
- expect(bundleContext.getBundle(123456L)).andReturn(installedBundle);
- expect(installedBundle.getHeaders()).andReturn(new Hashtable());
- installedBundle.start();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- featuresNode.put("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.1", "12345");
- featuresNode.put("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.2", "123456");
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // Installs third feature name = f2, version = 0.2
- expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
- expect(bundleContext.installBundle(isA(String.class),
- isA(InputStream.class))).andReturn(installedBundle);
- expect(installedBundle.getBundleId()).andReturn(1234567L);
- expect(bundleContext.getBundle(1234567L)).andReturn(installedBundle);
- expect(installedBundle.getHeaders()).andReturn(new Hashtable());
- installedBundle.start();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- featuresNode.put("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.1", "12345");
- featuresNode.put("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.2", "123456");
- featuresNode.put("f2" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.2", "1234567");
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 0);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- featuresNode.put("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.1", "12345");
- featuresNode.put("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.2", "123456");
- featuresNode.put("f2" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.2", "1234567");
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- expect(installedBundle.getHeaders()).andReturn(new Hashtable()).anyTimes();
-
- // uninstallAllFeatures
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- featuresNode.put("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.1", "12345");
- featuresNode.put("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.2", "123456");
- featuresNode.put("f2" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.2", "1234567");
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // uninstalls first feature name = f1, version = 0.1
- expect(bundleContext.getBundle(12345)).andReturn(installedBundle);
- installedBundle.uninstall();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- featuresNode.put("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.2", "123456");
- featuresNode.put("f2" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.2", "1234567");
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // uninstalls third feature name = f2, version = 0.2
- expect(bundleContext.getBundle(1234567)).andReturn(installedBundle);
- installedBundle.uninstall();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- featuresNode.put("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.2", "123456");
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // uninstalls second feature name = f1, version = 0.2
- expect(bundleContext.getBundle(123456)).andReturn(installedBundle);
- installedBundle.uninstall();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 0);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- replay(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle);
-
- FeaturesServiceImpl svc = new FeaturesServiceImpl();
- svc.setPreferences(preferencesService);
- svc.setBundleContext(bundleContext);
- svc.installAllFeatures(uri);
-
- // Uninstalls features with versions.
- svc.uninstallAllFeatures(uri);
- }
-
-
- // Tests install of a Repository that includes a feature
- // with a feature dependency
- // The dependant feature is in the same repository
- // Tests uninstall of features
- public void testInstallFeatureWithDependantFeatures() throws Exception {
-
- String name = getJarUrl(Bundle.class);
-
- File tmp = File.createTempFile("smx", ".feature");
- PrintWriter pw = new PrintWriter(new FileWriter(tmp));
- pw.println("<features>");
- pw.println(" <feature name=\"f1\" version=\"0.1\">");
- pw.println(" <feature version=\"0.1\">f2</feature>");
- pw.println(" <bundle>" + name + "</bundle>");
- pw.println(" </feature>");
- pw.println(" <feature name=\"f2\" version=\"0.1\">");
- pw.println(" <bundle>" + name + "</bundle>");
- pw.println(" </feature>");
- pw.println("</features>");
- pw.close();
-
- URI uri = tmp.toURI();
-
- // loads the state
- Preferences prefs = EasyMock.createMock(Preferences.class);
- PreferencesService preferencesService = EasyMock.createMock(PreferencesService.class);
- Preferences repositoriesNode = EasyMock.createMock(Preferences.class);
- Preferences repositoriesAvailableNode = EasyMock.createMock(Preferences.class);
- Preferences featuresNode = EasyMock.createMock(Preferences.class);
- BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
- Bundle installedBundle = EasyMock.createMock(Bundle.class);
-
- // savestate from addRepository
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // Installs feature f1 with dependency on f2
- // so will install f2 first
- expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
- expect(bundleContext.installBundle(isA(String.class),
- isA(InputStream.class))).andReturn(installedBundle);
- expect(installedBundle.getBundleId()).andReturn(12345L);
- expect(bundleContext.getBundle(12345L)).andReturn(installedBundle);
- expect(installedBundle.getHeaders()).andReturn(new Hashtable());
- installedBundle.start();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- featuresNode.put("f2" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.1", "12345");
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // Then installs f1
- expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
- expect(bundleContext.installBundle(isA(String.class),
- isA(InputStream.class))).andReturn(installedBundle);
- expect(installedBundle.getBundleId()).andReturn(1234L);
- expect(bundleContext.getBundle(1234L)).andReturn(installedBundle);
- expect(installedBundle.getHeaders()).andReturn(new Hashtable()).anyTimes();
- installedBundle.start();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- featuresNode.put("f2" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.1", "12345");
- featuresNode.put("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.1", "1234");
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // uninstalls first feature name = f1, version = 0.1
- expect(bundleContext.getBundle(1234)).andReturn(installedBundle);
- installedBundle.uninstall();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- featuresNode.put("f2" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.1", "12345");
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // uninstalls first feature name = f2, version = 0.1
- expect(bundleContext.getBundle(12345)).andReturn(installedBundle);
- installedBundle.uninstall();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 0);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- replay(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle);
-
- FeaturesServiceImpl svc = new FeaturesServiceImpl();
- svc.setPreferences(preferencesService);
- svc.setBundleContext(bundleContext);
- svc.addRepository(uri);
-
- svc.installFeature("f1", "0.1");
-
- // Uninstall repository
- svc.uninstallFeature("f1", "0.1");
- svc.uninstallFeature("f2", "0.1");
-
- }
-
- public void testInstallBatchFeatureWithContinueOnFailureNoClean() throws Exception {
- String bundle1 = getJarUrl(Bundle.class);
- String bundle2 = getJarUrl(PreferencesService.class);
-
- File tmp = File.createTempFile("smx", ".feature");
- PrintWriter pw = new PrintWriter(new FileWriter(tmp));
- pw.println("<features>");
- pw.println(" <feature name='f1'>");
- pw.println(" <bundle>" + bundle1 + "</bundle>");
- pw.println(" <bundle>" + "zfs:unknown" + "</bundle>");
- pw.println(" </feature>");
- pw.println(" <feature name='f2'>");
- pw.println(" <bundle>" + bundle2 + "</bundle>");
- pw.println(" </feature>");
- pw.println("</features>");
- pw.close();
-
- URI uri = tmp.toURI();
-
- // loads the state
- Preferences prefs = EasyMock.createMock(Preferences.class);
- PreferencesService preferencesService = EasyMock.createMock(PreferencesService.class);
- Preferences repositoriesNode = EasyMock.createMock(Preferences.class);
- Preferences repositoriesAvailableNode = EasyMock.createMock(Preferences.class);
- Preferences featuresNode = EasyMock.createMock(Preferences.class);
- BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
- Bundle installedBundle1 = EasyMock.createMock(Bundle.class);
- Bundle installedBundle2 = EasyMock.createMock(Bundle.class);
-
- // savestate from addRepository
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // Installs feature f1 and f2
- expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
- expect(bundleContext.installBundle(eq(bundle1), isA(InputStream.class))).andReturn(installedBundle1);
- expect(installedBundle1.getBundleId()).andReturn(12345L);
-
- expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
- expect(bundleContext.installBundle(eq(bundle2), isA(InputStream.class))).andReturn(installedBundle2);
- expect(installedBundle2.getBundleId()).andReturn(54321L);
- expect(installedBundle2.getHeaders()).andReturn(new Hashtable()).anyTimes();
- installedBundle2.start();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- featuresNode.put("f2" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.0.0", "54321");
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- replay(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle1, installedBundle2);
-
- FeaturesServiceImpl svc = new FeaturesServiceImpl();
- svc.setPreferences(preferencesService);
- svc.setBundleContext(bundleContext);
- svc.addRepository(uri);
-
- svc.installFeatures(new CopyOnWriteArraySet<Feature>(Arrays.asList(svc.listFeatures())),
- EnumSet.of(FeaturesService.Option.ContinueBatchOnFailure, FeaturesService.Option.NoCleanIfFailure));
-
-// verify(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle1, installedBundle2);
- }
-
- public void testInstallBatchFeatureWithContinueOnFailureClean() throws Exception {
- String bundle1 = getJarUrl(Bundle.class);
- String bundle2 = getJarUrl(PreferencesService.class);
-
- File tmp = File.createTempFile("smx", ".feature");
- PrintWriter pw = new PrintWriter(new FileWriter(tmp));
- pw.println("<features>");
- pw.println(" <feature name='f1'>");
- pw.println(" <bundle>" + bundle1 + "</bundle>");
- pw.println(" <bundle>" + "zfs:unknown" + "</bundle>");
- pw.println(" </feature>");
- pw.println(" <feature name='f2'>");
- pw.println(" <bundle>" + bundle2 + "</bundle>");
- pw.println(" </feature>");
- pw.println("</features>");
- pw.close();
-
- URI uri = tmp.toURI();
-
- // loads the state
- Preferences prefs = EasyMock.createMock(Preferences.class);
- PreferencesService preferencesService = EasyMock.createMock(PreferencesService.class);
- Preferences repositoriesNode = EasyMock.createMock(Preferences.class);
- Preferences repositoriesAvailableNode = EasyMock.createMock(Preferences.class);
- Preferences featuresNode = EasyMock.createMock(Preferences.class);
- BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
- Bundle installedBundle1 = EasyMock.createMock(Bundle.class);
- Bundle installedBundle2 = EasyMock.createMock(Bundle.class);
-
- // savestate from addRepository
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // Installs feature f1 and f2
- expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
- expect(bundleContext.installBundle(eq(bundle1), isA(InputStream.class))).andReturn(installedBundle1);
- expect(installedBundle1.getBundleId()).andReturn(12345L);
- installedBundle1.uninstall();
-
- expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
- expect(bundleContext.installBundle(eq(bundle2), isA(InputStream.class))).andReturn(installedBundle2);
- expect(installedBundle2.getBundleId()).andReturn(54321L);
- expect(installedBundle2.getHeaders()).andReturn(new Hashtable()).anyTimes();
- installedBundle2.start();
-
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- featuresNode.put("f2" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + "0.0.0", "54321");
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- replay(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle1, installedBundle2);
-
- FeaturesServiceImpl svc = new FeaturesServiceImpl();
- svc.setPreferences(preferencesService);
- svc.setBundleContext(bundleContext);
- svc.addRepository(uri);
-
- svc.installFeatures(new CopyOnWriteArraySet<Feature>(Arrays.asList(svc.listFeatures())),
- EnumSet.of(FeaturesService.Option.ContinueBatchOnFailure));
-
-// verify(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle1, installedBundle2);
- }
-
- public void testInstallBatchFeatureWithoutContinueOnFailureNoClean() throws Exception {
- String bundle1 = getJarUrl(Bundle.class);
- String bundle2 = getJarUrl(PreferencesService.class);
-
- File tmp = File.createTempFile("smx", ".feature");
- PrintWriter pw = new PrintWriter(new FileWriter(tmp));
- pw.println("<features>");
- pw.println(" <feature name='f1'>");
- pw.println(" <bundle>" + bundle1 + "</bundle>");
- pw.println(" <bundle>" + "zfs:unknown" + "</bundle>");
- pw.println(" </feature>");
- pw.println(" <feature name='f2'>");
- pw.println(" <bundle>" + bundle2 + "</bundle>");
- pw.println(" </feature>");
- pw.println("</features>");
- pw.close();
-
- URI uri = tmp.toURI();
-
- // loads the state
- Preferences prefs = EasyMock.createMock(Preferences.class);
- PreferencesService preferencesService = EasyMock.createMock(PreferencesService.class);
- Preferences repositoriesNode = EasyMock.createMock(Preferences.class);
- Preferences repositoriesAvailableNode = EasyMock.createMock(Preferences.class);
- Preferences featuresNode = EasyMock.createMock(Preferences.class);
- BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
- Bundle installedBundle1 = EasyMock.createMock(Bundle.class);
- Bundle installedBundle2 = EasyMock.createMock(Bundle.class);
-
- // savestate from addRepository
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // Installs feature f1 and f2
- expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
- expect(bundleContext.installBundle(eq(bundle1), isA(InputStream.class))).andReturn(installedBundle1);
- expect(installedBundle1.getBundleId()).andReturn(12345L);
-
- expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
- expect(bundleContext.installBundle(eq(bundle2), isA(InputStream.class))).andReturn(installedBundle2);
- expect(installedBundle2.getBundleId()).andReturn(54321L);
- installedBundle2.start();
-
- replay(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle1, installedBundle2);
-
- FeaturesServiceImpl svc = new FeaturesServiceImpl();
- svc.setPreferences(preferencesService);
- svc.setBundleContext(bundleContext);
- svc.addRepository(uri);
-
- try {
- List<Feature> features = Arrays.asList(svc.listFeatures());
- Collections.reverse(features);
- svc.installFeatures(new CopyOnWriteArraySet<Feature>(features),
- EnumSet.of(FeaturesService.Option.NoCleanIfFailure));
- fail("Call should have thrown an exception");
- } catch (MalformedURLException e) {
- }
-
-// verify(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle1, installedBundle2);
- }
-
- public void testInstallBatchFeatureWithoutContinueOnFailureClean() throws Exception {
- String bundle1 = getJarUrl(Bundle.class);
- String bundle2 = getJarUrl(PreferencesService.class);
-
- File tmp = File.createTempFile("smx", ".feature");
- PrintWriter pw = new PrintWriter(new FileWriter(tmp));
- pw.println("<features>");
- pw.println(" <feature name='f1'>");
- pw.println(" <bundle>" + bundle1 + "</bundle>");
- pw.println(" <bundle>" + "zfs:unknown" + "</bundle>");
- pw.println(" </feature>");
- pw.println(" <feature name='f2'>");
- pw.println(" <bundle>" + bundle2 + "</bundle>");
- pw.println(" </feature>");
- pw.println("</features>");
- pw.close();
-
- URI uri = tmp.toURI();
-
- // loads the state
- Preferences prefs = EasyMock.createMock(Preferences.class);
- PreferencesService preferencesService = EasyMock.createMock(PreferencesService.class);
- Preferences repositoriesNode = EasyMock.createMock(Preferences.class);
- Preferences repositoriesAvailableNode = EasyMock.createMock(Preferences.class);
- Preferences featuresNode = EasyMock.createMock(Preferences.class);
- BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
- Bundle installedBundle1 = EasyMock.createMock(Bundle.class);
- Bundle installedBundle2 = EasyMock.createMock(Bundle.class);
-
- // savestate from addRepository
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // Installs feature f1 and f2
- expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
- expect(bundleContext.installBundle(eq(bundle1), isA(InputStream.class))).andReturn(installedBundle1);
- expect(installedBundle1.getBundleId()).andReturn(12345L);
- installedBundle1.uninstall();
-
- expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
- expect(bundleContext.installBundle(eq(bundle2), isA(InputStream.class))).andReturn(installedBundle2);
- expect(installedBundle2.getBundleId()).andReturn(54321L);
- installedBundle2.uninstall();
-
- replay(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle1, installedBundle2);
-
- FeaturesServiceImpl svc = new FeaturesServiceImpl();
- svc.setPreferences(preferencesService);
- svc.setBundleContext(bundleContext);
- svc.addRepository(uri);
-
- try {
- List<Feature> features = Arrays.asList(svc.listFeatures());
- Collections.reverse(features);
- svc.installFeatures(new CopyOnWriteArraySet<Feature>(features),
- EnumSet.noneOf(FeaturesService.Option.class));
- fail("Call should have thrown an exception");
- } catch (MalformedURLException e) {
- }
-
-// verify(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle1, installedBundle2);
- }
-
- public void testInstallFeatureWithHostToRefresh() throws Exception {
- String bundle1 = getJarUrl(PreferencesService.class);
- String bundle2 = getJarUrl(Bundle.class);
-
- File tmp = File.createTempFile("smx", ".feature");
- PrintWriter pw = new PrintWriter(new FileWriter(tmp));
- pw.println("<features>");
- pw.println(" <feature name='f1'>");
- pw.println(" <bundle>" + bundle1 + "</bundle>");
- pw.println(" <bundle>" + bundle2 + "</bundle>");
- pw.println(" </feature>");
- pw.println("</features>");
- pw.close();
-
- URI uri = tmp.toURI();
-
- JarInputStream j = new JarInputStream(new URL(bundle1).openStream());
- Dictionary<String,String> headers = new Hashtable();
- for (Map.Entry e : j.getManifest().getMainAttributes().entrySet()) {
- headers.put(e.getKey().toString(), e.getValue().toString());
- }
-
- // loads the state
- Preferences prefs = EasyMock.createMock(Preferences.class);
- PreferencesService preferencesService = EasyMock.createMock(PreferencesService.class);
- Preferences repositoriesNode = EasyMock.createMock(Preferences.class);
- Preferences repositoriesAvailableNode = EasyMock.createMock(Preferences.class);
- Preferences featuresNode = EasyMock.createMock(Preferences.class);
- PackageAdmin packageAdmin = EasyMock.createMock(PackageAdmin.class);
- BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
- Bundle installedBundle1 = EasyMock.createMock(Bundle.class);
- Bundle installedBundle2 = EasyMock.createMock(Bundle.class);
-
- // savestate from addRepository
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- // Installs feature f1
- expect(installedBundle1.getBundleId()).andReturn(12345L).anyTimes();
- expect(installedBundle1.getSymbolicName()).andReturn(headers.get(Constants.BUNDLE_SYMBOLICNAME)).anyTimes();
- expect(installedBundle1.getHeaders()).andReturn(headers).anyTimes();
- expect(bundleContext.getBundles()).andReturn(new Bundle[] { installedBundle1 });
-
- expect(bundleContext.installBundle(eq(bundle2), isA(InputStream.class))).andReturn(installedBundle2);
- expect(bundleContext.getBundles()).andReturn(new Bundle[] { installedBundle1, installedBundle2 });
- expect(installedBundle2.getBundleId()).andReturn(54321L);
- expect(installedBundle2.getSymbolicName()).andReturn("fragment").anyTimes();
- Dictionary d = new Hashtable();
- d.put(Constants.FRAGMENT_HOST, headers.get(Constants.BUNDLE_SYMBOLICNAME));
- expect(installedBundle2.getHeaders()).andReturn(d).anyTimes();
-
- expect(installedBundle1.getState()).andReturn(Bundle.ACTIVE);
- expect(installedBundle1.getState()).andReturn(Bundle.ACTIVE);
- expect(installedBundle2.getState()).andReturn(Bundle.INSTALLED);
- expect(installedBundle2.getState()).andReturn(Bundle.INSTALLED);
-
- //
- // This is the real test to make sure the host is actually refreshed
- //
- packageAdmin.refreshPackages(aryEq(new Bundle[] { installedBundle1 }));
-
- expect(prefs.node("repositories")).andReturn(repositoriesNode);
- repositoriesNode.clear();
- repositoriesNode.putInt("count", 1);
- repositoriesNode.put("item.0", uri.toString());
- expect(prefs.node("features")).andReturn(featuresNode);
- featuresNode.clear();
- featuresNode.put("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + FeatureImpl.DEFAULT_VERSION, "12345,54321");
- prefs.putBoolean("bootFeaturesInstalled", false);
- prefs.flush();
-
- replay(packageAdmin, preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle1, installedBundle2);
-
- FeaturesServiceImpl svc = new FeaturesServiceImpl();
- svc.setPackageAdmin(packageAdmin);
- svc.setPreferences(preferencesService);
- svc.setBundleContext(bundleContext);
- svc.addRepository(uri);
-
- List<Feature> features = Arrays.asList(svc.listFeatures());
- Collections.reverse(features);
- svc.installFeatures(new CopyOnWriteArraySet<Feature>(features),
- EnumSet.noneOf(FeaturesService.Option.class));
-
-// verify(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle1, installedBundle2);
- }
-
- private String getJarUrl(Class cl) {
- String name = cl.getName();
- name = name.replace(".", "/") + ".class";
- name = getClass().getClassLoader().getResource(name).toString();
- name = name.substring("jar:".length(), name.indexOf('!'));
- return name;
- }
-
-}
diff --git a/karaf/features/core/src/test/java/org/apache/felix/karaf/features/RepositoryTest.java b/karaf/features/core/src/test/java/org/apache/felix/karaf/features/RepositoryTest.java
deleted file mode 100644
index 9718e13..0000000
--- a/karaf/features/core/src/test/java/org/apache/felix/karaf/features/RepositoryTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features;
-
-import java.net.URI;
-
-import junit.framework.TestCase;
-import org.apache.felix.karaf.features.internal.RepositoryImpl;
-import org.apache.felix.karaf.features.internal.FeatureImpl;
-
-
-public class RepositoryTest extends TestCase {
-
- public void testLoad() throws Exception {
- RepositoryImpl r = new RepositoryImpl(getClass().getResource("repo1.xml").toURI());
- // Check repo
- URI[] repos = r.getRepositories();
- assertNotNull(repos);
- assertEquals(1, repos.length);
- assertEquals(URI.create("urn:r1"), repos[0]);
- // Check features
- Feature[] features = r.getFeatures();
- assertNotNull(features);
- assertEquals(2, features.length);
- assertNotNull(features[0]);
- assertEquals("f1", features[0].getName());
- assertNotNull(features[0].getConfigurations());
- assertEquals(1, features[0].getConfigurations().size());
- assertNotNull(features[0].getConfigurations().get("c1"));
- assertEquals(1, features[0].getConfigurations().get("c1").size());
- assertEquals("v", features[0].getConfigurations().get("c1").get("k"));
- assertNotNull(features[0].getDependencies());
- assertEquals(0, features[0].getDependencies().size());
- assertNotNull(features[0].getBundles());
- assertEquals(2, features[0].getBundles().size());
- assertEquals("b1", features[0].getBundles().get(0));
- assertEquals("b2", features[0].getBundles().get(1));
- assertNotNull(features[1]);
- assertEquals("f2", features[1].getName());
- assertNotNull(features[1].getConfigurations());
- assertEquals(0, features[1].getConfigurations().size());
- assertNotNull(features[1].getDependencies());
- assertEquals(1, features[1].getDependencies().size());
- assertEquals("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + FeatureImpl.DEFAULT_VERSION, features[1].getDependencies().get(0).toString());
- assertNotNull(features[1].getBundles());
- assertEquals(1, features[1].getBundles().size());
- assertEquals("b3", features[1].getBundles().get(0));
- }
-
- public void testShowWrongUriInException() throws Exception {
- String uri = "src/test/resources/org/apache/felix/karaf/shell/features/repo1.xml";
- RepositoryImpl r = new RepositoryImpl(new URI(uri));
- try {
- r.load();
- } catch (Exception e) {
- assertTrue(e.getMessage().contains(uri));
- }
- }
-}
diff --git a/karaf/features/core/src/test/java/org/apache/felix/karaf/features/internal/FeaturesServiceImplTest.java b/karaf/features/core/src/test/java/org/apache/felix/karaf/features/internal/FeaturesServiceImplTest.java
deleted file mode 100644
index 7775d3f..0000000
--- a/karaf/features/core/src/test/java/org/apache/felix/karaf/features/internal/FeaturesServiceImplTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.internal;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-import org.apache.felix.karaf.features.Feature;
-import org.apache.felix.utils.manifest.Clause;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-import org.osgi.service.prefs.PreferencesService;
-
-import static org.easymock.EasyMock.*;
-
-/**
- * Test cases for {@link FeaturesServiceImpl}
- */
-public class FeaturesServiceImplTest extends TestCase {
-
- public void testGetFeature() throws Exception {
- final Map<String, Map<String, Feature>> features = new HashMap<String, Map<String,Feature>>();
- Map<String, Feature> versions = new HashMap<String, Feature>();
- FeatureImpl feature = new FeatureImpl("transaction");
- versions.put("1.0.0", feature);
- features.put("transaction", versions);
- final FeaturesServiceImpl impl = new FeaturesServiceImpl() {
- protected Map<String,Map<String,Feature>> getFeatures() throws Exception {
- return features;
- };
- };
- assertNotNull(impl.getFeature("transaction", FeatureImpl.DEFAULT_VERSION));
- assertSame(feature, impl.getFeature("transaction", FeatureImpl.DEFAULT_VERSION));
- }
-
- public void testGetFeatureStripVersion() throws Exception {
- final Map<String, Map<String, Feature>> features = new HashMap<String, Map<String,Feature>>();
- Map<String, Feature> versions = new HashMap<String, Feature>();
- FeatureImpl feature = new FeatureImpl("transaction");
- versions.put("1.0.0", feature);
- features.put("transaction", versions);
- final FeaturesServiceImpl impl = new FeaturesServiceImpl() {
- protected Map<String,Map<String,Feature>> getFeatures() throws Exception {
- return features;
- };
- };
- assertNotNull(impl.getFeature("transaction", " 1.0.0 "));
- assertSame(feature, impl.getFeature("transaction", " 1.0.0 "));
- }
-
- public void testGetFeatureNotAvailable() throws Exception {
- final Map<String, Map<String, Feature>> features = new HashMap<String, Map<String,Feature>>();
- Map<String, Feature> versions = new HashMap<String, Feature>();
- versions.put("1.0.0", new FeatureImpl("transaction"));
- features.put("transaction", versions);
- final FeaturesServiceImpl impl = new FeaturesServiceImpl() {
- protected Map<String,Map<String,Feature>> getFeatures() throws Exception {
- return features;
- };
- };
- assertNull(impl.getFeature("activemq", FeatureImpl.DEFAULT_VERSION));
- }
-
- public void testGetFeatureHighestAvailable() throws Exception {
- final Map<String, Map<String, Feature>> features = new HashMap<String, Map<String,Feature>>();
- Map<String, Feature> versions = new HashMap<String, Feature>();
- versions.put("1.0.0", new FeatureImpl("transaction", "1.0.0"));
- versions.put("2.0.0", new FeatureImpl("transaction", "2.0.0"));
- features.put("transaction", versions);
- final FeaturesServiceImpl impl = new FeaturesServiceImpl() {
- protected Map<String,Map<String,Feature>> getFeatures() throws Exception {
- return features;
- };
- };
- assertNotNull(impl.getFeature("transaction", FeatureImpl.DEFAULT_VERSION));
- assertSame("2.0.0", impl.getFeature("transaction", FeatureImpl.DEFAULT_VERSION).getVersion());
- }
-
- public void testStartDoesNotFailWithOneInvalidUri() throws BackingStoreException {
- PreferencesService preferencesService = createNiceMock(PreferencesService.class);
- Preferences prefs = createNiceMock(Preferences.class);
- Preferences emptyPrefs = createNiceMock(Preferences.class);
- expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
- replay(preferencesService);
-
- expect(prefs.node("repositories")).andReturn(emptyPrefs);
- expect(prefs.node("features")).andReturn(emptyPrefs);
- replay(prefs);
-
- FeaturesServiceImpl service = new FeaturesServiceImpl();
- service.setPreferences(preferencesService);
-
- try {
- service.setUrls("mvn:inexistent/features/1.0/xml/features");
- service.start();
- } catch (Exception e) {
- fail(String.format("Service should not throw start-up exception but log the error instead: %s", e));
- }
- }
-
- public void testGetOptionalImportsOnly() {
- FeaturesServiceImpl service = new FeaturesServiceImpl();
-
- List<Clause> result = service.getOptionalImports("org.apache.felix.karaf,org.apache.felix.karaf.optional;resolution:=optional");
- assertEquals("One optional import expected", 1, result.size());
- assertEquals("org.apache.felix.karaf.optional", result.get(0).getName());
-
- result = service.getOptionalImports(null);
- assertNotNull(result);
- assertEquals("No optional imports expected", 0, result.size());
- }
-}
diff --git a/karaf/features/core/src/test/resources/org/apache/felix/karaf/features/repo1.xml b/karaf/features/core/src/test/resources/org/apache/felix/karaf/features/repo1.xml
deleted file mode 100644
index 3284661..0000000
--- a/karaf/features/core/src/test/resources/org/apache/felix/karaf/features/repo1.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<features>
- <repository>urn:r1</repository>
- <feature name="f1">
- <config name="c1">
- k=v
- </config>
- <bundle>b1</bundle>
- <bundle>b2</bundle>
- </feature>
- <feature name="f2">
- <feature>f1</feature>
- <bundle>b3</bundle>
- </feature>
-</features>
diff --git a/karaf/features/management/NOTICE b/karaf/features/management/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/features/management/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/features/management/pom.xml b/karaf/features/management/pom.xml
deleted file mode 100644
index 82da799..0000000
--- a/karaf/features/management/pom.xml
+++ /dev/null
@@ -1,126 +0,0 @@
-<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/maven-v4_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.felix.karaf.features</groupId>
- <artifactId>features</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.features</groupId>
- <artifactId>org.apache.felix.karaf.features.management</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Features Management</name>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix.karaf.features</groupId>
- <artifactId>org.apache.felix.karaf.features.core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.bundlerepository</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.obr</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>org.apache.felix.karaf.management</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>
- ${project.artifactId}*;version=${project.version}
- </Export-Package>
- <Import-Package>
- !${project.artifactId}*,
- javax.management,
- javax.management.loading,
- org.osgi.service.command,
- org.apache.felix.gogo.commands,
- org.apache.felix.karaf.shell.console,
- *
- </Import-Package>
- <Private-Package>org.apache.felix.karaf.features.management.internal</Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/FeaturesServiceMBean.java b/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/FeaturesServiceMBean.java
deleted file mode 100644
index 2683846..0000000
--- a/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/FeaturesServiceMBean.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.management;
-
-import javax.management.openmbean.TabularData;
-
-public interface FeaturesServiceMBean {
-
- TabularData getFeatures() throws Exception;
-
- TabularData getRepositories() throws Exception;
-
- void addRepository(String url) throws Exception;
-
- void removeRepositroy(String url) throws Exception;
-
- void installFeature(String name) throws Exception;
-
- void installFeature(String name, String version) throws Exception;
-
- void uninstallFeature(String name) throws Exception;
-
- void uninstallFeature(String name, String version) throws Exception;
-
- String FEATURE_NAME = "Name";
-
- String FEATURE_VERSION = "Version";
-
- String FEATURE_DEPENDENCIES = "Dependencies";
-
- String FEATURE_BUNDLES = "Bundles";
-
- String FEATURE_CONFIGURATIONS = "Configurations";
-
- String FEATURE_INSTALLED = "Installed";
-
- String FEATURE_CONFIG_PID = "Pid";
- String FEATURE_CONFIG_ELEMENTS = "Elements";
- String FEATURE_CONFIG_ELEMENT_KEY = "Key";
- String FEATURE_CONFIG_ELEMENT_VALUE = "Value";
-
- /**
- * The type of the event which is emitted for features events
- */
- String FEATURE_EVENT_TYPE = "org.apache.felix.karaf.features.featureEvent";
-
- String FEATURE_EVENT_EVENT_TYPE = "Type";
-
- String FEATURE_EVENT_EVENT_TYPE_INSTALLED = "Installed";
-
- String FEATURE_EVENT_EVENT_TYPE_UNINSTALLED = "Uninstalled";
-
- /**
- * The item names in the CompositeData representing a feature
- */
- String[] FEATURE = { FEATURE_NAME, FEATURE_VERSION, FEATURE_DEPENDENCIES, FEATURE_BUNDLES,
- FEATURE_CONFIGURATIONS, FEATURE_INSTALLED };
-
- String[] FEATURE_IDENTIFIER = { FEATURE_NAME, FEATURE_VERSION };
-
- String[] FEATURE_CONFIG = { FEATURE_CONFIG_PID, FEATURE_CONFIG_ELEMENTS };
-
- String[] FEATURE_CONFIG_ELEMENT = { FEATURE_CONFIG_ELEMENT_KEY, FEATURE_CONFIG_ELEMENT_VALUE };
-
- /**
- * The item names in the CompositeData representing the event raised for
- * feature events within the OSGi container by this bean
- */
- String[] FEATURE_EVENT = { FEATURE_NAME, FEATURE_VERSION, FEATURE_EVENT_EVENT_TYPE };
-
-
- String REPOSITORY_NAME = "Name";
-
- String REPOSITORY_URI = "Uri";
-
- String REPOSITORY_REPOSITORIES = "Repositories";
-
- String REPOSITORY_FEATURES = "Features";
-
- /**
- * The type of the event which is emitted for repositories events
- */
- String REPOSITORY_EVENT_TYPE = "org.apache.felix.karaf.features.repositoryEvent";
-
- String REPOSITORY_EVENT_EVENT_TYPE = "Type";
-
- String REPOSITORY_EVENT_EVENT_TYPE_ADDED = "Added";
-
- String REPOSITORY_EVENT_EVENT_TYPE_REMOVED = "Removed";
-
- /**
- * The item names in the CompositeData representing a feature
- */
- String[] REPOSITORY = { REPOSITORY_NAME, REPOSITORY_URI, REPOSITORY_REPOSITORIES, REPOSITORY_FEATURES };
-
- /**
- * The item names in the CompositeData representing the event raised for
- * feature events within the OSGi container by this bean
- */
- String[] REPOSITORY_EVENT = { REPOSITORY_NAME, REPOSITORY_URI, REPOSITORY_EVENT_EVENT_TYPE };
-
-}
diff --git a/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/codec/JmxFeature.java b/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/codec/JmxFeature.java
deleted file mode 100644
index f471282..0000000
--- a/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/codec/JmxFeature.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.management.codec;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import javax.management.openmbean.TabularData;
-import javax.management.openmbean.TabularType;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.SimpleType;
-import javax.management.openmbean.ArrayType;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.TabularDataSupport;
-
-import org.apache.felix.karaf.features.Feature;
-import org.apache.felix.karaf.features.management.FeaturesServiceMBean;
-
-public class JmxFeature {
-
- /**
- * The CompositeType which represents a single feature
- */
- public final static CompositeType FEATURE;
-
- /**
- * The TabularType which represents a list of features
- */
- public final static TabularType FEATURE_TABLE;
-
- public final static CompositeType FEATURE_IDENTIFIER;
-
- public final static TabularType FEATURE_IDENTIFIER_TABLE;
-
- public final static CompositeType FEATURE_CONFIG_ELEMENT;
-
- public final static TabularType FEATURE_CONFIG_ELEMENT_TABLE;
-
- public final static CompositeType FEATURE_CONFIG;
-
- public final static TabularType FEATURE_CONFIG_TABLE;
-
-
- private final CompositeData data;
-
- public JmxFeature(Feature feature, boolean installed) {
- try {
- String[] itemNames = FeaturesServiceMBean.FEATURE;
- Object[] itemValues = new Object[itemNames.length];
- itemValues[0] = feature.getName();
- itemValues[1] = feature.getVersion();
- itemValues[2] = getFeatureIdentifierTable(feature.getDependencies());
- itemValues[3] = feature.getBundles().toArray(new String[feature.getBundles().size()]);
- itemValues[4] = getConfigTable(feature.getConfigurations());
- itemValues[5] = installed;
- data = new CompositeDataSupport(FEATURE, itemNames, itemValues);
- } catch (OpenDataException e) {
- throw new IllegalStateException("Cannot form feature open data", e);
- }
- }
-
- public CompositeData asCompositeData() {
- return data;
- }
-
- public static TabularData tableFrom(Collection<JmxFeature> features) {
- TabularDataSupport table = new TabularDataSupport(FEATURE_TABLE);
- for (JmxFeature feature : features) {
- table.put(feature.asCompositeData());
- }
- return table;
- }
-
- static TabularData getFeatureIdentifierTable(List<Feature> features) throws OpenDataException {
- TabularDataSupport table = new TabularDataSupport(FEATURE_IDENTIFIER_TABLE);
- for (Feature feature : features) {
- String[] itemNames = new String[] { FeaturesServiceMBean.FEATURE_NAME, FeaturesServiceMBean.FEATURE_VERSION };
- Object[] itemValues = new Object[] { feature.getName(), feature.getVersion() };
- CompositeData ident = new CompositeDataSupport(FEATURE_IDENTIFIER, itemNames, itemValues);
- table.put(ident);
- }
- return table;
- }
-
- static TabularData getConfigTable(Map<String, Map<String, String>> configs) throws OpenDataException {
- TabularDataSupport table = new TabularDataSupport(FEATURE_CONFIG_TABLE);
- for (Map.Entry<String, Map<String, String>> entry : configs.entrySet()) {
- String[] itemNames = FeaturesServiceMBean.FEATURE_CONFIG;
- Object[] itemValues = new Object[2];
- itemValues[0] = entry.getKey();
- itemValues[1] = getConfigElementTable(entry.getValue());
- CompositeData config = new CompositeDataSupport(FEATURE_CONFIG, itemNames, itemValues);
- table.put(config);
- }
- return table;
- }
-
- static TabularData getConfigElementTable(Map<String, String> config) throws OpenDataException {
- TabularDataSupport table = new TabularDataSupport(FEATURE_CONFIG_ELEMENT_TABLE);
- for (Map.Entry<String, String> entry : config.entrySet()) {
- String[] itemNames = FeaturesServiceMBean.FEATURE_CONFIG_ELEMENT;
- Object[] itemValues = { entry.getKey(), entry.getValue() };
- CompositeData element = new CompositeDataSupport(FEATURE_CONFIG_ELEMENT, itemNames, itemValues);
- table.put(element);
- }
- return table;
- }
-
-
- static {
- FEATURE_IDENTIFIER = createFeatureIdentifierType();
- FEATURE_IDENTIFIER_TABLE = createFeatureIdentifierTableType();
- FEATURE_CONFIG_ELEMENT = createFeatureConfigElementType();
- FEATURE_CONFIG_ELEMENT_TABLE = createFeatureConfigElementTableType();
- FEATURE_CONFIG = createFeatureConfigType();
- FEATURE_CONFIG_TABLE = createFeatureConfigTableType();
- FEATURE = createFeatureType();
- FEATURE_TABLE = createFeatureTableType();
- }
-
- private static CompositeType createFeatureIdentifierType() {
- try {
- String description = "This type identify a Karaf features";
- String[] itemNames = FeaturesServiceMBean.FEATURE_IDENTIFIER;
- OpenType[] itemTypes = new OpenType[itemNames.length];
- String[] itemDescriptions = new String[itemNames.length];
- itemTypes[0] = SimpleType.STRING;
- itemTypes[1] = SimpleType.STRING;
-
- itemDescriptions[0] = "The id of the feature";
- itemDescriptions[1] = "The version of the feature";
-
- return new CompositeType("FeatureIdentifier", description, itemNames,
- itemDescriptions, itemTypes);
- } catch (OpenDataException e) {
- throw new IllegalStateException("Unable to build featureIdentifier type", e);
- }
- }
-
- private static TabularType createFeatureIdentifierTableType() {
- try {
- return new TabularType("Features", "The table of featureIdentifiers",
- FEATURE_IDENTIFIER, new String[] { FeaturesServiceMBean.FEATURE_NAME, FeaturesServiceMBean.FEATURE_VERSION });
- } catch (OpenDataException e) {
- throw new IllegalStateException("Unable to build featureIdentifier table type", e);
- }
- }
-
- private static CompositeType createFeatureConfigElementType() {
- try {
- String description = "This type encapsulates Karaf feature config element";
- String[] itemNames = FeaturesServiceMBean.FEATURE_CONFIG_ELEMENT;
- OpenType[] itemTypes = new OpenType[itemNames.length];
- String[] itemDescriptions = new String[itemNames.length];
- itemTypes[0] = SimpleType.STRING;
- itemTypes[1] = SimpleType.STRING;
-
- itemDescriptions[0] = "The key";
- itemDescriptions[1] = "The value";
-
- return new CompositeType("ConfigElement", description, itemNames,
- itemDescriptions, itemTypes);
- } catch (OpenDataException e) {
- throw new IllegalStateException("Unable to build configElement type", e);
- }
- }
-
- private static TabularType createFeatureConfigElementTableType() {
- try {
- return new TabularType("ConfigElement", "The table of configurations elements",
- FEATURE_CONFIG_ELEMENT, new String[] { FeaturesServiceMBean.FEATURE_CONFIG_ELEMENT_KEY});
- } catch (OpenDataException e) {
- throw new IllegalStateException("Unable to build feature table type", e);
- }
- }
-
- private static CompositeType createFeatureConfigType() {
- try {
- String description = "This type encapsulates Karaf feature config";
- String[] itemNames = FeaturesServiceMBean.FEATURE_CONFIG;
- OpenType[] itemTypes = new OpenType[itemNames.length];
- String[] itemDescriptions = new String[itemNames.length];
- itemTypes[0] = SimpleType.STRING;
- itemTypes[1] = FEATURE_CONFIG_ELEMENT_TABLE;
-
- itemDescriptions[0] = "The PID of the config";
- itemDescriptions[1] = "The configuration elements";
-
- return new CompositeType("Config", description, itemNames,
- itemDescriptions, itemTypes);
- } catch (OpenDataException e) {
- throw new IllegalStateException("Unable to build configElement type", e);
- }
- }
-
- private static TabularType createFeatureConfigTableType() {
- try {
- return new TabularType("Features", "The table of configurations",
- FEATURE_CONFIG, new String[] { FeaturesServiceMBean.FEATURE_CONFIG_PID});
- } catch (OpenDataException e) {
- throw new IllegalStateException("Unable to build feature table type", e);
- }
- }
-
- private static CompositeType createFeatureType() {
- try {
- String description = "This type encapsulates Karaf features";
- String[] itemNames = FeaturesServiceMBean.FEATURE;
- OpenType[] itemTypes = new OpenType[itemNames.length];
- String[] itemDescriptions = new String[itemNames.length];
- itemTypes[0] = SimpleType.STRING;
- itemTypes[1] = SimpleType.STRING;
- itemTypes[2] = FEATURE_IDENTIFIER_TABLE;
- itemTypes[3] = new ArrayType(1, SimpleType.STRING);
- itemTypes[4] = FEATURE_CONFIG_TABLE;
- itemTypes[5] = SimpleType.BOOLEAN;
-
- itemDescriptions[0] = "The name of the feature";
- itemDescriptions[1] = "The version of the feature";
- itemDescriptions[2] = "The feature dependencies";
- itemDescriptions[3] = "The feature bundles";
- itemDescriptions[4] = "The feature configurations";
- itemDescriptions[5] = "Whether the feature is installed";
-
- return new CompositeType("Feature", description, itemNames,
- itemDescriptions, itemTypes);
- } catch (OpenDataException e) {
- throw new IllegalStateException("Unable to build feature type", e);
- }
- }
-
- private static TabularType createFeatureTableType() {
- try {
- return new TabularType("Features", "The table of all features",
- FEATURE, new String[] { FeaturesServiceMBean.FEATURE_NAME, FeaturesServiceMBean.FEATURE_VERSION });
- } catch (OpenDataException e) {
- throw new IllegalStateException("Unable to build feature table type", e);
- }
- }
-
-}
diff --git a/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/codec/JmxFeatureEvent.java b/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/codec/JmxFeatureEvent.java
deleted file mode 100644
index 03f024a..0000000
--- a/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/codec/JmxFeatureEvent.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.management.codec;
-
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.SimpleType;
-
-import org.apache.felix.karaf.features.FeatureEvent;
-import org.apache.felix.karaf.features.management.FeaturesServiceMBean;
-
-public class JmxFeatureEvent {
-
- public static final CompositeType FEATURE_EVENT;
-
- private final CompositeData data;
-
- public JmxFeatureEvent(FeatureEvent event) {
- try {
- String[] itemNames = FeaturesServiceMBean.FEATURE_EVENT;
- Object[] itemValues = new Object[itemNames.length];
- itemValues[0] = event.getFeature().getName();
- itemValues[1] = event.getFeature().getVersion();
- switch (event.getType()) {
- case FeatureInstalled: itemValues[2] = FeaturesServiceMBean.FEATURE_EVENT_EVENT_TYPE_INSTALLED; break;
- case FeatureUninstalled: itemValues[2] = FeaturesServiceMBean.FEATURE_EVENT_EVENT_TYPE_UNINSTALLED; break;
- default: throw new IllegalStateException("Unsupported event type: " + event.getType());
- }
- data = new CompositeDataSupport(FEATURE_EVENT, itemNames, itemValues);
- } catch (OpenDataException e) {
- throw new IllegalStateException("Cannot form feature event open data", e);
- }
- }
-
- public CompositeData asCompositeData() {
- return data;
- }
-
- static {
- FEATURE_EVENT = createFeatureEventType();
- }
-
- private static CompositeType createFeatureEventType() {
- try {
- String description = "This type identify a Karaf feature event";
- String[] itemNames = FeaturesServiceMBean.FEATURE_EVENT;
- OpenType[] itemTypes = new OpenType[itemNames.length];
- String[] itemDescriptions = new String[itemNames.length];
- itemTypes[0] = SimpleType.STRING;
- itemTypes[1] = SimpleType.STRING;
- itemTypes[2] = SimpleType.STRING;
-
- itemDescriptions[0] = "The id of the feature";
- itemDescriptions[1] = "The version of the feature";
- itemDescriptions[2] = "The type of the event";
-
- return new CompositeType("FeatureEvent", description, itemNames,
- itemDescriptions, itemTypes);
- } catch (OpenDataException e) {
- throw new IllegalStateException("Unable to build featureEvent type", e);
- }
- }
-}
diff --git a/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/codec/JmxRepository.java b/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/codec/JmxRepository.java
deleted file mode 100644
index d2857f6..0000000
--- a/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/codec/JmxRepository.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.management.codec;
-
-import java.util.Collection;
-import java.util.Arrays;
-import java.net.URI;
-
-import javax.management.openmbean.TabularData;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.TabularType;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.SimpleType;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.ArrayType;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.TabularDataSupport;
-import javax.management.openmbean.CompositeDataSupport;
-
-import org.apache.felix.karaf.features.Repository;
-import org.apache.felix.karaf.features.management.FeaturesServiceMBean;
-
-public class JmxRepository {
-
- public final static CompositeType REPOSITORY;
-
- public final static TabularType REPOSITORY_TABLE;
-
- private final CompositeData data;
-
- public JmxRepository(Repository repository) {
- try {
- String[] itemNames = FeaturesServiceMBean.REPOSITORY;
- Object[] itemValues = new Object[itemNames.length];
- itemValues[0] = repository.getName();
- itemValues[1] = repository.getURI().toString();
- itemValues[2] = toStringArray(repository.getRepositories());
- itemValues[3] = JmxFeature.getFeatureIdentifierTable(Arrays.asList(repository.getFeatures()));
- data = new CompositeDataSupport(REPOSITORY, itemNames, itemValues);
- } catch (Exception e) {
- throw new IllegalStateException("Cannot form repository open data", e);
- }
- }
-
- public CompositeData asCompositeData() {
- return data;
- }
-
- public static TabularData tableFrom(Collection<JmxRepository> repositories) {
- TabularDataSupport table = new TabularDataSupport(REPOSITORY_TABLE);
- for (JmxRepository repository : repositories) {
- table.put(repository.asCompositeData());
- }
- return table;
- }
-
- private static String[] toStringArray(URI[] uris) {
- if (uris == null) {
- return null;
- }
- String[] res = new String[uris.length];
- for (int i = 0; i < res.length; i++) {
- res[i] = uris[i].toString();
- }
- return res;
- }
-
- static {
- REPOSITORY = createRepositoryType();
- REPOSITORY_TABLE = createRepositoryTableType();
- }
-
- private static CompositeType createRepositoryType() {
- try {
- String description = "This type identify a Karaf repository";
- String[] itemNames = FeaturesServiceMBean.REPOSITORY;
- OpenType[] itemTypes = new OpenType[itemNames.length];
- String[] itemDescriptions = new String[itemNames.length];
- itemTypes[0] = SimpleType.STRING;
- itemTypes[1] = SimpleType.STRING;
- itemTypes[2] = new ArrayType(1, SimpleType.STRING);
- itemTypes[3] = JmxFeature.FEATURE_IDENTIFIER_TABLE;
-
- itemDescriptions[0] = "The name of the repository";
- itemDescriptions[1] = "The uri of the repository";
- itemDescriptions[2] = "The dependent repositories";
- itemDescriptions[3] = "The list of included features";
-
- return new CompositeType("Repository", description, itemNames,
- itemDescriptions, itemTypes);
- } catch (OpenDataException e) {
- throw new IllegalStateException("Unable to build repository type", e);
- }
- }
-
- private static TabularType createRepositoryTableType() {
- try {
- return new TabularType("Features", "The table of repositories",
- REPOSITORY, new String[] { FeaturesServiceMBean.REPOSITORY_URI });
- } catch (OpenDataException e) {
- throw new IllegalStateException("Unable to build repository table type", e);
- }
- }
-
-}
diff --git a/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/codec/JmxRepositoryEvent.java b/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/codec/JmxRepositoryEvent.java
deleted file mode 100644
index 6e20032..0000000
--- a/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/codec/JmxRepositoryEvent.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.features.management.codec;
-
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.SimpleType;
-
-import org.apache.felix.karaf.features.RepositoryEvent;
-import org.apache.felix.karaf.features.management.FeaturesServiceMBean;
-
-public class JmxRepositoryEvent {
-
- public static final CompositeType REPOSITORY_EVENT;
-
- private final CompositeData data;
-
- public JmxRepositoryEvent(RepositoryEvent event) {
- try {
- String[] itemNames = FeaturesServiceMBean.REPOSITORY_EVENT;
- Object[] itemValues = new Object[itemNames.length];
- itemValues[0] = event.getRepository().getName();
- itemValues[1] = event.getRepository().getURI().toString();
- switch (event.getType()) {
- case RepositoryAdded: itemValues[2] = FeaturesServiceMBean.REPOSITORY_EVENT_EVENT_TYPE_ADDED; break;
- case RepositoryRemoved: itemValues[2] = FeaturesServiceMBean.REPOSITORY_EVENT_EVENT_TYPE_REMOVED; break;
- default: throw new IllegalStateException("Unsupported event type: " + event.getType());
- }
- data = new CompositeDataSupport(REPOSITORY_EVENT, itemNames, itemValues);
- } catch (OpenDataException e) {
- throw new IllegalStateException("Cannot form repository event open data", e);
- }
- }
-
- public CompositeData asCompositeData() {
- return data;
- }
-
- static {
- REPOSITORY_EVENT = createRepositoryEventType();
- }
-
- private static CompositeType createRepositoryEventType() {
- try {
- String description = "This type identify a Karaf repository event";
- String[] itemNames = FeaturesServiceMBean.REPOSITORY_EVENT;
- OpenType[] itemTypes = new OpenType[itemNames.length];
- String[] itemDescriptions = new String[itemNames.length];
- itemTypes[0] = SimpleType.STRING;
- itemTypes[1] = SimpleType.STRING;
- itemTypes[2] = SimpleType.STRING;
-
- itemDescriptions[0] = "The name of the repository";
- itemDescriptions[1] = "The uri of the repository";
- itemDescriptions[2] = "The type of event";
-
- return new CompositeType("RepositoryEvent", description, itemNames,
- itemDescriptions, itemTypes);
- } catch (OpenDataException e) {
- throw new IllegalStateException("Unable to build repositoryEvent type", e);
- }
- }
-}
\ No newline at end of file
diff --git a/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/internal/FeaturesServiceMBeanImpl.java b/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/internal/FeaturesServiceMBeanImpl.java
deleted file mode 100644
index 98358f0..0000000
--- a/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/internal/FeaturesServiceMBeanImpl.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Licensed 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.felix.karaf.features.management.internal;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Hashtable;
-import java.util.List;
-
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
-import javax.management.NotCompliantMBeanException;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.ObjectName;
-import javax.management.openmbean.TabularData;
-
-import org.apache.felix.karaf.features.Feature;
-import org.apache.felix.karaf.features.FeatureEvent;
-import org.apache.felix.karaf.features.FeaturesListener;
-import org.apache.felix.karaf.features.FeaturesService;
-import org.apache.felix.karaf.features.Repository;
-import org.apache.felix.karaf.features.RepositoryEvent;
-import org.apache.felix.karaf.features.management.FeaturesServiceMBean;
-import org.apache.felix.karaf.features.management.codec.JmxFeature;
-import org.apache.felix.karaf.features.management.codec.JmxFeatureEvent;
-import org.apache.felix.karaf.features.management.codec.JmxRepository;
-import org.apache.felix.karaf.features.management.codec.JmxRepositoryEvent;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * Implementation of {@link FeaturesServiceMBean}.
- */
-public class FeaturesServiceMBeanImpl extends StandardEmitterMBean implements
- MBeanRegistration, FeaturesServiceMBean {
-
- private ServiceRegistration registration;
-
- private BundleContext bundleContext;
-
- private ObjectName objectName;
-
- private volatile long sequenceNumber = 0;
-
- private MBeanServer server;
-
- private FeaturesService featuresService;
-
- public FeaturesServiceMBeanImpl() throws NotCompliantMBeanException {
- super(FeaturesServiceMBean.class, new NotificationBroadcasterSupport() {
- @Override
- public MBeanNotificationInfo[] getNotificationInfo() {
- return getBroadcastInfo();
- }
- });
- }
-
- public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
- objectName = name;
- this.server = server;
- return name;
- }
-
- public void postRegister(Boolean registrationDone) {
- registration = bundleContext.registerService(FeaturesListener.class.getName(),
- getFeaturesListener(), new Hashtable());
- }
-
- public void preDeregister() throws Exception {
- registration.unregister();
- }
-
- public void postDeregister() {
- }
-
- /**
- * {@inheritDoc}
- */
- public TabularData getFeatures() throws Exception {
- try {
- List<Feature> allFeatures = Arrays.asList(featuresService.listFeatures());
- List<Feature> insFeatures = Arrays.asList(featuresService.listInstalledFeatures());
- ArrayList<JmxFeature> features = new ArrayList<JmxFeature>();
- for (Feature feature : allFeatures) {
- features.add(new JmxFeature(feature, insFeatures.contains(feature)));
- }
- TabularData table = JmxFeature.tableFrom(features);
- return table;
- } catch (Throwable t) {
- t.printStackTrace();
- return null;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public TabularData getRepositories() throws Exception {
- try {
- List<Repository> allRepositories = Arrays.asList(featuresService.listRepositories());
- ArrayList<JmxRepository> repositories = new ArrayList<JmxRepository>();
- for (Repository repository : allRepositories) {
- repositories.add(new JmxRepository(repository));
- }
- TabularData table = JmxRepository.tableFrom(repositories);
- return table;
- } catch (Throwable t) {
- t.printStackTrace();
- return null;
- }
- }
-
- public void addRepository(String uri) throws Exception {
- featuresService.addRepository(new URI(uri));
- }
-
- public void removeRepositroy(String uri) throws Exception {
- featuresService.removeRepository(new URI(uri));
- }
-
- public void installFeature(String name) throws Exception {
- featuresService.installFeature(name);
- }
-
- public void installFeature(String name, String version) throws Exception {
- featuresService.installFeature(name, version);
- }
-
- public void uninstallFeature(String name) throws Exception {
- featuresService.uninstallFeature(name);
- }
-
- public void uninstallFeature(String name, String version) throws Exception {
- featuresService.uninstallFeature(name, version);
- }
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- public void setFeaturesService(FeaturesService featuresService) {
- this.featuresService = featuresService;
- }
-
- public FeaturesListener getFeaturesListener() {
- return new FeaturesListener() {
- public void featureEvent(FeatureEvent event) {
- if (!event.isReplay()) {
- Notification notification = new Notification(FEATURE_EVENT_TYPE, objectName, sequenceNumber++);
- notification.setUserData(new JmxFeatureEvent(event).asCompositeData());
- sendNotification(notification);
- }
- }
- public void repositoryEvent(RepositoryEvent event) {
- if (!event.isReplay()) {
- Notification notification = new Notification(REPOSITORY_EVENT_TYPE, objectName, sequenceNumber++);
- notification.setUserData(new JmxRepositoryEvent(event).asCompositeData());
- sendNotification(notification);
- }
- }
- };
- }
-
-
- private static MBeanNotificationInfo[] getBroadcastInfo() {
- String type = Notification.class.getCanonicalName();
- MBeanNotificationInfo info1 = new MBeanNotificationInfo(new String[] {FEATURE_EVENT_EVENT_TYPE},
- type, "Some features notification");
- MBeanNotificationInfo info2 = new MBeanNotificationInfo(new String[] {REPOSITORY_EVENT_EVENT_TYPE},
- type, "Some repository notification");
- return new MBeanNotificationInfo[] {info1, info2};
- }
-
-}
\ No newline at end of file
diff --git a/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/internal/StandardEmitterMBean.java b/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/internal/StandardEmitterMBean.java
deleted file mode 100644
index e999011..0000000
--- a/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/internal/StandardEmitterMBean.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed 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.felix.karaf.features.management.internal;
-
-import javax.management.*;
-
-public class StandardEmitterMBean extends StandardMBean implements NotificationEmitter {
-
- private NotificationBroadcasterSupport emitter;
-
- public StandardEmitterMBean(Class mbeanInterface, NotificationBroadcasterSupport emitter) throws NotCompliantMBeanException {
- super(mbeanInterface);
- this.emitter = emitter;
- }
-
- public void sendNotification(Notification notification) {
- emitter.sendNotification(notification);
- }
-
-
- public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException {
- emitter.removeNotificationListener(listener, filter, handback);
- }
-
- public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException {
- emitter.addNotificationListener(listener, filter, handback);
- }
-
- public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException {
- emitter.removeNotificationListener(listener);
- }
-
- public MBeanNotificationInfo[] getNotificationInfo() {
- return emitter.getNotificationInfo();
- }
-
- @Override
- public MBeanInfo getMBeanInfo() {
- MBeanInfo mbeanInfo = super.getMBeanInfo();
- if (mbeanInfo != null) {
- MBeanNotificationInfo[] notificationInfo = getNotificationInfo();
- mbeanInfo = new MBeanInfo(mbeanInfo.getClassName(), mbeanInfo.getDescription(), mbeanInfo.getAttributes(),
- mbeanInfo.getConstructors(), mbeanInfo.getOperations(), notificationInfo);
- }
- return mbeanInfo;
- }
-
-}
diff --git a/karaf/features/management/src/main/resources/OSGI-INF/blueprint/features-management.xml b/karaf/features/management/src/main/resources/OSGI-INF/blueprint/features-management.xml
deleted file mode 100644
index b8b221f..0000000
--- a/karaf/features/management/src/main/resources/OSGI-INF/blueprint/features-management.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
-
- <reference id="featuresService" interface="org.apache.felix.karaf.features.FeaturesService" />
-
- <reference id="mbeanServer" interface="javax.management.MBeanServer">
- <reference-listener ref="mbeanRegister" bind-method="registerMBeanServer" unbind-method="unregisterMBeanServer" />
- </reference>
-
- <bean id="mbeanImpl" class="org.apache.felix.karaf.features.management.internal.FeaturesServiceMBeanImpl">
- <property name="bundleContext" ref="blueprintBundleContext" />
- <property name="featuresService" ref="featuresService" />
- </bean>
-
- <bean id="mbeanRegister" class="org.apache.felix.karaf.management.MBeanRegistrer">
- <property name="mbeans">
- <map>
- <entry value="org.apache.felix.karaf:type=features,name=${karaf.name}"
- key-ref="mbeanImpl" />
- </map>
- </property>
- </bean>
-
-</blueprint>
diff --git a/karaf/features/pom.xml b/karaf/features/pom.xml
deleted file mode 100644
index 22046a8..0000000
--- a/karaf/features/pom.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<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/maven-v4_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.felix.karaf</groupId>
- <artifactId>karaf</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.features</groupId>
- <artifactId>features</artifactId>
- <packaging>pom</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Features</name>
-
- <modules>
- <module>core</module>
- <module>command</module>
- <module>management</module>
- </modules>
-
-</project>
diff --git a/karaf/itests/NOTICE b/karaf/itests/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/itests/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/itests/pom.xml b/karaf/itests/pom.xml
deleted file mode 100644
index 5f38cd5..0000000
--- a/karaf/itests/pom.xml
+++ /dev/null
@@ -1,108 +0,0 @@
-<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/maven-v4_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.felix.karaf</groupId>
- <artifactId>karaf</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>itests</artifactId>
- <packaging>jar</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: ITests</name>
-
- <description>
- Integration tests
- </description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <!-- This is required to be first so that pax-exam classloader is not messed up with a newer version of felix
- which would lead to java.lang.NoSuchMethodError: org.apache.felix.framework.Logger.<init>(I)V -->
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.framework</artifactId>
- <version>1.0.0</version>
- </dependency>
- <!-- This is required to be first so that pax-exam classloader is not messed up with a newer version of felix
- which would lead to java.lang.RuntimeException: Could not create [service.obr] -->
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.bundlerepository</artifactId>
- <version>1.2.1</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix.karaf.tooling</groupId>
- <artifactId>org.apache.felix.karaf.tooling.testing</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <!-- generate dependencies versions -->
- <plugin>
- <groupId>org.apache.servicemix.tooling</groupId>
- <artifactId>depends-maven-plugin</artifactId>
- <version>1.1</version>
- <executions>
- <execution>
- <id>generate-depends-file</id>
- <goals>
- <goal>generate-depends-file</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>ci-build-profile</id>
- <activation>
- <property>
- <name>maven.repo.local</name>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <!-- when the local repo location has been specified, we need to pass on this information to PAX mvn url -->
- <argLine>-Dorg.ops4j.pax.url.mvn.localRepository=${maven.repo.local}</argLine>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-</project>
diff --git a/karaf/itests/src/test/java/org/apache/felix/karaf/shell/itests/CoreTest.java b/karaf/itests/src/test/java/org/apache/felix/karaf/shell/itests/CoreTest.java
deleted file mode 100644
index 22875f9..0000000
--- a/karaf/itests/src/test/java/org/apache/felix/karaf/shell/itests/CoreTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.itests;
-
-import org.apache.felix.karaf.testing.AbstractIntegrationTest;
-import org.apache.felix.karaf.testing.Helper;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.framework.Bundle;
-import org.osgi.service.command.CommandProcessor;
-import org.osgi.service.command.CommandSession;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
-import static org.ops4j.pax.exam.OptionUtils.combine;
-
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.workingDirectory;
-
-@RunWith(JUnit4TestRunner.class)
-public class CoreTest extends AbstractIntegrationTest {
-
- @Test
- public void testHelp() throws Exception {
- Thread.sleep(10000);
-
- CommandProcessor cp = getOsgiService(CommandProcessor.class);
- CommandSession cs = cp.createSession(System.in, System.out, System.err);
- cs.execute("osgi:list --help");
- cs.close();
- }
-
- @Test
- public void testInstallCommand() throws Exception {
- Thread.sleep(12000);
-
- CommandProcessor cp = getOsgiService(CommandProcessor.class);
- CommandSession cs = cp.createSession(System.in, System.out, System.err);
-
- try {
- cs.execute("log:display");
- fail("command should not exist");
- } catch (IllegalArgumentException e) {
- assertTrue(e.getMessage().indexOf("Command not found") >= 0);
- }
-
- Bundle b = getInstalledBundle("org.apache.felix.karaf.shell.log");
- b.start();
-
- Thread.sleep(1000);
-
- cs.execute("log:display");
-
- b.stop();
-
- Thread.sleep(1000);
-
- try {
- cs.execute("log:display");
- fail("command should not exist");
- } catch (IllegalArgumentException e) {
- assertTrue(e.getMessage().indexOf("Command not found") >= 0);
- }
-
- cs.close();
- }
-
-// @Test
-// public void testCommandGroup() throws Exception {
-// Thread.sleep(5000);
-//
-// Shell shell = getOsgiService(Shell.class);
-// shell.execute("osgi");
-// shell.execute("help");
-// shell.execute("..");
-// }
-//
-// @Test
-// public void testCommandGroupAfterInstall() throws Exception {
-// Bundle b = getInstalledBundle("org.apache.felix.karaf.shell.log");
-// b.start();
-//
-// Thread.sleep(5000);
-//
-// Shell shell = getOsgiService(Shell.class);
-// shell.execute("log");
-// shell.execute("help");
-// shell.execute("..");
-// }
-//
- @Configuration
- public static Option[] configuration() throws Exception {
- Option[] options = combine(
- // Default karaf environment
- Helper.getDefaultOptions(
- // this is how you set the default log level when using pax logging (logProfile)
- systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG")),
-
- workingDirectory("target/paxrunner/core/"),
-
- waitForFrameworkStartup(),
-
- // Test on both equinox and felix
- equinox(), felix()
- );
- // Stop the shell log bundle
- Helper.findMaven(options, "org.apache.felix.karaf.shell", "org.apache.felix.karaf.shell.log").noStart();
- return options;
- }
-
-}
diff --git a/karaf/itests/src/test/java/org/apache/felix/karaf/shell/itests/FeaturesTest.java b/karaf/itests/src/test/java/org/apache/felix/karaf/shell/itests/FeaturesTest.java
deleted file mode 100644
index bdede08..0000000
--- a/karaf/itests/src/test/java/org/apache/felix/karaf/shell/itests/FeaturesTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.itests;
-
-import org.apache.felix.karaf.testing.AbstractIntegrationTest;
-import org.apache.felix.karaf.testing.Helper;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.service.blueprint.container.BlueprintContainer;
-import org.osgi.service.command.CommandProcessor;
-import org.osgi.service.command.CommandSession;
-
-import static org.junit.Assert.assertNotNull;
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.maven;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
-import static org.ops4j.pax.exam.OptionUtils.combine;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.scanFeatures;
-
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.workingDirectory;
-
-@RunWith(JUnit4TestRunner.class)
-public class FeaturesTest extends AbstractIntegrationTest {
-
- @Test
- public void testFeatures() throws Exception {
- // Make sure the command services are available
- assertNotNull(getOsgiService(BlueprintContainer.class, "osgi.blueprint.container.symbolicname=org.apache.felix.karaf.shell.obr", 20000));
- assertNotNull(getOsgiService(BlueprintContainer.class, "osgi.blueprint.container.symbolicname=org.apache.felix.karaf.shell.wrapper", 20000));
- // Run some commands to make sure they are installed properly
- CommandProcessor cp = getOsgiService(CommandProcessor.class);
- CommandSession cs = cp.createSession(System.in, System.out, System.err);
- cs.execute("obr:listUrl");
- cs.execute("wrapper:install --help");
- cs.close();
- }
-
- @Configuration
- public static Option[] configuration() throws Exception{
- return combine(
- // Default karaf environment
- Helper.getDefaultOptions(
- // this is how you set the default log level when using pax logging (logProfile)
- systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG")),
-
- // add two features
- scanFeatures(
- maven().groupId("org.apache.felix.karaf").artifactId("apache-felix-karaf").type("xml").classifier("features").versionAsInProject(),
- "obr", "wrapper"
- ),
-
- workingDirectory("target/paxrunner/features/"),
-
- waitForFrameworkStartup(),
-
- // Test on both equinox and felix
- equinox(), felix()
- );
- }
-
-}
diff --git a/karaf/itests/src/test/java/org/apache/felix/karaf/shell/itests/HeaderParser.java b/karaf/itests/src/test/java/org/apache/felix/karaf/shell/itests/HeaderParser.java
deleted file mode 100644
index a6b6387..0000000
--- a/karaf/itests/src/test/java/org/apache/felix/karaf/shell/itests/HeaderParser.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.itests;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Utility class to parse a standard OSGi header with paths.
- *
- * @author <a href="mailto:dev@geronimo.apache.org">Apache Geronimo Project</a>
- * @version $Rev: 786132 $, $Date: 2009-06-18 17:47:58 +0200 (Thu, 18 Jun 2009) $
- */
-public final class HeaderParser {
-
- // Private constructor for static final class
- private HeaderParser() {
- }
-
- /**
- * Parse a given OSGi header into a list of paths
- *
- * @param header the OSGi header to parse
- * @return the list of paths extracted from this header
- */
- public static List<PathElement> parseHeader(String header) {
- List<PathElement> elements = new ArrayList<PathElement>();
- if (header == null || header.trim().length() == 0) {
- return elements;
- }
- String[] clauses = parseDelimitedString(header, ",");
- for (String clause : clauses) {
- String[] tokens = clause.split(";");
- if (tokens.length < 1) {
- throw new IllegalArgumentException("Invalid header clause: " + clause);
- }
- PathElement elem = new PathElement(tokens[0].trim());
- elements.add(elem);
- for (int i = 1; i < tokens.length; i++) {
- int pos = tokens[i].indexOf('=');
- if (pos != -1) {
- if (pos > 0 && tokens[i].charAt(pos - 1) == ':') {
- String name = tokens[i].substring(0, pos - 1).trim();
- String value = tokens[i].substring(pos + 1).trim();
- if (value.startsWith("\"") && value.endsWith("\"")) {
- value = value.substring(1, value.length() - 1);
- }
- elem.addDirective(name, value);
- } else {
- String name = tokens[i].substring(0, pos).trim();
- String value = tokens[i].substring(pos + 1).trim();
- if (value.startsWith("\"") && value.endsWith("\"")) {
- value = value.substring(1, value.length() - 1);
- }
- elem.addAttribute(name, value);
- }
- } else {
- elem = new PathElement(tokens[i].trim());
- elements.add(elem);
- }
- }
- }
- return elements;
- }
-
- /**
- * Parses delimited string and returns an array containing the tokens. This
- * parser obeys quotes, so the delimiter character will be ignored if it is
- * inside of a quote. This method assumes that the quote character is not
- * included in the set of delimiter characters.
- * @param value the delimited string to parse.
- * @param delim the characters delimiting the tokens.
- * @return an array of string tokens or null if there were no tokens.
- **/
- public static String[] parseDelimitedString(String value, String delim)
- {
- if (value == null)
- {
- value = "";
- }
-
- List list = new ArrayList();
-
- int CHAR = 1;
- int DELIMITER = 2;
- int STARTQUOTE = 4;
- int ENDQUOTE = 8;
-
- StringBuffer sb = new StringBuffer();
-
- int expecting = (CHAR | DELIMITER | STARTQUOTE);
-
- for (int i = 0; i < value.length(); i++)
- {
- char c = value.charAt(i);
-
- boolean isDelimiter = (delim.indexOf(c) >= 0);
- boolean isQuote = (c == '"');
-
- if (isDelimiter && ((expecting & DELIMITER) > 0))
- {
- list.add(sb.toString().trim());
- sb.delete(0, sb.length());
- expecting = (CHAR | DELIMITER | STARTQUOTE);
- }
- else if (isQuote && ((expecting & STARTQUOTE) > 0))
- {
- sb.append(c);
- expecting = CHAR | ENDQUOTE;
- }
- else if (isQuote && ((expecting & ENDQUOTE) > 0))
- {
- sb.append(c);
- expecting = (CHAR | STARTQUOTE | DELIMITER);
- }
- else if ((expecting & CHAR) > 0)
- {
- sb.append(c);
- }
- else
- {
- throw new IllegalArgumentException("Invalid delimited string: " + value);
- }
- }
-
- if (sb.length() > 0)
- {
- list.add(sb.toString().trim());
- }
-
- return (String[]) list.toArray(new String[list.size()]);
- }
-
- public static class PathElement {
-
- private String path;
- private Map<String, String> attributes;
- private Map<String, String> directives;
-
- public PathElement(String path) {
- this.path = path;
- this.attributes = new HashMap<String, String>();
- this.directives = new HashMap<String, String>();
- }
-
- public String getName() {
- return this.path;
- }
-
- public Map<String, String> getAttributes() {
- return attributes;
- }
-
- public String getAttribute(String name) {
- return attributes.get(name);
- }
-
- public void addAttribute(String name, String value) {
- attributes.put(name, value);
- }
-
- public Map<String, String> getDirectives() {
- return directives;
- }
-
- public String getDirective(String name) {
- return directives.get(name);
- }
-
- public void addDirective(String name, String value) {
- directives.put(name, value);
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder(this.path);
- for (Map.Entry<String,String> directive : this.directives.entrySet()) {
- sb.append(";").append(directive.getKey()).append(":=").append(directive.getValue());
- }
- for (Map.Entry<String,String> attribute : this.attributes.entrySet()) {
- sb.append(";").append(attribute.getKey()).append("=").append(attribute.getValue());
- }
- return sb.toString();
- }
-
- }
-}
diff --git a/karaf/itests/src/test/resources/log4j.properties b/karaf/itests/src/test/resources/log4j.properties
deleted file mode 100644
index 0ca7b6a..0000000
--- a/karaf/itests/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,33 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-# Root logger
-log4j.rootLogger=INFO, stdout
-
-# CONSOLE appender not used by default
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
-
-# File appender
-log4j.appender.out=org.apache.log4j.FileAppender
-log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
-log4j.appender.out.file=${karaf.base}/data/log/karaf.log
-log4j.appender.out.append=true
diff --git a/karaf/jaas/boot/NOTICE b/karaf/jaas/boot/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/jaas/boot/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/jaas/boot/pom.xml b/karaf/jaas/boot/pom.xml
deleted file mode 100644
index e4aced2..0000000
--- a/karaf/jaas/boot/pom.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-<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/maven-v4_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.felix.karaf.jaas</groupId>
- <artifactId>jaas</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.jaas</groupId>
- <artifactId>org.apache.felix.karaf.jaas.boot</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: JAAS Boot</name>
-
- <description>
- Provides the JAAS Boot classes
- </description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Import-Package>!${project.artifactId}*,*</Import-Package>
- <Private-Package>!*</Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/karaf/jaas/boot/src/main/java/org/apache/felix/karaf/jaas/boot/ProxyLoginModule.java b/karaf/jaas/boot/src/main/java/org/apache/felix/karaf/jaas/boot/ProxyLoginModule.java
deleted file mode 100644
index b95641f..0000000
--- a/karaf/jaas/boot/src/main/java/org/apache/felix/karaf/jaas/boot/ProxyLoginModule.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.boot;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.security.auth.Subject;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.login.LoginException;
-import javax.security.auth.spi.LoginModule;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-
-/**
- * An OSGi proxy login module that should be used instead of a plain reference to
- * a given login module. Two properties must be set, the name of the login module
- * class and the bundle to be used to load it.
- * This class must be available from all modules, so it has to be either in a fragment
- * bundle attached to the system bundle or be made available through the boot delegation
- * class path.
- */
-public class ProxyLoginModule implements LoginModule {
-
- public static final String PROPERTY_MODULE = "org.apache.felix.karaf.jaas.module";
- public static final String PROPERTY_BUNDLE = "org.apache.felix.karaf.jaas.bundle";
-
- private static BundleContext bundleContext = null;
-
- private LoginModule target = null;
-
- public static void init(BundleContext context) {
- bundleContext = context;
- }
-
- /* (non-Javadoc)
- * @see javax.security.auth.spi.LoginModule#initialize(javax.security.auth.Subject, javax.security.auth.callback.CallbackHandler, java.util.Map, java.util.Map)
- */
- public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) {
- if (bundleContext == null) {
- throw new IllegalStateException("ProxyLoginModule not initialized. Init must be called prior any invocation.");
- }
- Map<String,?> newOptions = new HashMap<String,Object>(options);
- String module = (String) newOptions.remove(PROPERTY_MODULE);
- if (module == null) {
- throw new IllegalStateException("Option " + PROPERTY_MODULE + " must be set to the name of the factory service");
- }
- String bundleId = (String) newOptions.remove(PROPERTY_BUNDLE);
- if (bundleId == null) {
- throw new IllegalStateException("Option " + PROPERTY_BUNDLE + " must be set to the name of the factory service");
- }
- Bundle bundle = bundleContext.getBundle(Long.parseLong(bundleId));
- if (bundle == null) {
- throw new IllegalStateException("No bundle found for id " + bundleId);
- }
- try {
- target = (LoginModule) bundle.loadClass(module).newInstance();
- } catch (Exception e) {
- throw new IllegalStateException("Can not load or create login module " + module + " for bundle " + bundleId, e);
- }
- target.initialize(subject, callbackHandler, sharedState, newOptions);
- }
-
- /* (non-Javadoc)
- * @see javax.security.auth.spi.LoginModule#login()
- */
- public boolean login() throws LoginException {
- return target.login();
- }
-
- /* (non-Javadoc)
- * @see javax.security.auth.spi.LoginModule#commit()
- */
- public boolean commit() throws LoginException {
- return target.commit();
- }
-
- /* (non-Javadoc)
- * @see javax.security.auth.spi.LoginModule#abort()
- */
- public boolean abort() throws LoginException {
- return target.abort();
- }
-
- /* (non-Javadoc)
- * @see javax.security.auth.spi.LoginModule#logout()
- */
- public boolean logout() throws LoginException {
- return target.logout();
- }
-
-}
diff --git a/karaf/jaas/config/NOTICE b/karaf/jaas/config/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/jaas/config/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/jaas/config/pom.xml b/karaf/jaas/config/pom.xml
deleted file mode 100644
index 6fbfef0..0000000
--- a/karaf/jaas/config/pom.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-<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/maven-v4_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.felix.karaf.jaas</groupId>
- <artifactId>jaas</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.jaas</groupId>
- <artifactId>org.apache.felix.karaf.jaas.config</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: JAAS Config</name>
-
- <description>
- Provides the JAAS Config
- </description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix.karaf.jaas</groupId>
- <artifactId>org.apache.felix.karaf.jaas.boot</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.aries.blueprint</groupId>
- <artifactId>org.apache.aries.blueprint</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Import-Package>!${project.artifactId}*,*</Import-Package>
- <Private-Package>${project.artifactId}.impl</Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/JaasRealm.java b/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/JaasRealm.java
deleted file mode 100644
index d1a40f5..0000000
--- a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/JaasRealm.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.config;
-
-import javax.security.auth.login.AppConfigurationEntry;
-
-public interface JaasRealm {
-
- public String getName();
-
- public int getRank();
-
- public AppConfigurationEntry[] getEntries();
-}
diff --git a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/KeyIsLocked.java b/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/KeyIsLocked.java
deleted file mode 100644
index bfaaba2..0000000
--- a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/KeyIsLocked.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.config;
-
-import java.security.GeneralSecurityException;
-
-public class KeyIsLocked extends GeneralSecurityException {
-
- public KeyIsLocked() {
- super();
- }
-
- public KeyIsLocked(String message, Throwable cause) {
- super(message, cause);
- }
-
- public KeyIsLocked(String msg) {
- super(msg);
- }
-
- public KeyIsLocked(Throwable cause) {
- super(cause);
- }
-
-}
diff --git a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/KeystoreInstance.java b/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/KeystoreInstance.java
deleted file mode 100644
index 4f0890b..0000000
--- a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/KeystoreInstance.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.config;
-
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.PrivateKey;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.Certificate;
-
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.TrustManager;
-
-/**
- * Based on http://svn.apache.org/repos/asf/geronimo/trunk/modules/management/
- * src/java/org/apache/geronimo/management/geronimo/KeystoreInstance.java
- *
- * @version $Rev: $ $Date: $
- */
-public interface KeystoreInstance {
-
- String getName();
-
- int getRank();
-
- String[] listPrivateKeys();
-
- String[] listTrustCertificates();
-
- Certificate getCertificate(String alias);
-
- String getCertificateAlias(Certificate cert);
-
- Certificate[] getCertificateChain(String alias);
-
- PrivateKey getPrivateKey(String alias);
-
- boolean isKeystoreLocked();
-
- boolean isKeyLocked(String keyAlias);
-
- KeyManager[] getKeyManager(String algorithm, String keyAlias) throws NoSuchAlgorithmException,
- UnrecoverableKeyException, KeyStoreException, KeystoreIsLocked;
-
- TrustManager[] getTrustManager(String algorithm) throws KeyStoreException, NoSuchAlgorithmException, KeystoreIsLocked;
-
-}
diff --git a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/KeystoreIsLocked.java b/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/KeystoreIsLocked.java
deleted file mode 100644
index ae5efe6..0000000
--- a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/KeystoreIsLocked.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.config;
-
-import java.security.GeneralSecurityException;
-
-public class KeystoreIsLocked extends GeneralSecurityException {
-
- public KeystoreIsLocked() {
- super();
- }
-
- public KeystoreIsLocked(String message, Throwable cause) {
- super(message, cause);
- }
-
- public KeystoreIsLocked(String msg) {
- super(msg);
- }
-
- public KeystoreIsLocked(Throwable cause) {
- super(cause);
- }
-
-}
diff --git a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/KeystoreManager.java b/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/KeystoreManager.java
deleted file mode 100644
index afa2adf..0000000
--- a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/KeystoreManager.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.config;
-
-import java.security.GeneralSecurityException;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLServerSocketFactory;
-import javax.net.ssl.SSLSocketFactory;
-
-/**
- * Based on http://svn.apache.org/repos/asf/geronimo/trunk/modules/management/
- * src/java/org/apache/geronimo/management/geronimo/KeystoreManager.java
- *
- */
-public interface KeystoreManager {
-
- KeystoreInstance getKeystore(String name);
-
- /**
- * Gets a SSLContext using one Keystore to access the private key
- * and another to provide the list of trusted certificate authorities.
- * @param provider
- * @param protocol The SSL protocol to use
- * @param algorithm The SSL algorithm to use
- * @param keyStore The key keystore name as provided by listKeystores. The
- * KeystoreInstance for this keystore must be unlocked.
- * @param keyAlias The name of the private key in the keystore. The
- * KeystoreInstance for this keystore must have unlocked
- * this key.
- * @param trustStore The trust keystore name as provided by listKeystores.
- * The KeystoreInstance for this keystore must have
- * unlocked this key.
- *
- * @throws KeystoreIsLocked Occurs when the requested key keystore cannot
- * be used because it has not been unlocked.
- * @throws KeyIsLocked Occurs when the requested private key in the key
- * keystore cannot be used because it has not been
- * unlocked.
- */
- SSLContext createSSLContext(String provider, String protocol,
- String algorithm, String keyStore,
- String keyAlias, String trustStore) throws GeneralSecurityException;
-
- /**
- * Gets a ServerSocketFactory using one Keystore to access the private key
- * and another to provide the list of trusted certificate authorities.
- * @param provider
- * @param protocol The SSL protocol to use
- * @param algorithm The SSL algorithm to use
- * @param keyStore The key keystore name as provided by listKeystores. The
- * KeystoreInstance for this keystore must be unlocked.
- * @param keyAlias The name of the private key in the keystore. The
- * KeystoreInstance for this keystore must have unlocked
- * this key.
- * @param trustStore The trust keystore name as provided by listKeystores.
- * The KeystoreInstance for this keystore must have
- * unlocked this key.
- *
- * @throws KeystoreIsLocked Occurs when the requested key keystore cannot
- * be used because it has not been unlocked.
- * @throws KeyIsLocked Occurs when the requested private key in the key
- * keystore cannot be used because it has not been
- * unlocked.
- */
- SSLServerSocketFactory createSSLServerFactory(String provider, String protocol,
- String algorithm, String keyStore,
- String keyAlias, String trustStore) throws GeneralSecurityException;
-
- /**
- * Gets a SocketFactory using one Keystore to access the private key
- * and another to provide the list of trusted certificate authorities.
- * @param provider The SSL provider to use, or null for the default
- * @param protocol The SSL protocol to use
- * @param algorithm The SSL algorithm to use
- * @param keyStore The key keystore name as provided by listKeystores. The
- * KeystoreInstance for this keystore must be unlocked.
- * @param keyAlias The name of the private key in the keystore. The
- * KeystoreInstance for this keystore must have unlocked
- * this key.
- * @param trustStore The trust keystore name as provided by listKeystores.
- * The KeystoreInstance for this keystore must have
- * unlocked this key.
- *
- * @throws KeystoreIsLocked Occurs when the requested key keystore cannot
- * be used because it has not been unlocked.
- * @throws KeyIsLocked Occurs when the requested private key in the key
- * keystore cannot be used because it has not been
- * unlocked.
- * @throws GeneralSecurityException
- */
- SSLSocketFactory createSSLFactory(String provider, String protocol,
- String algorithm, String keyStore,
- String keyAlias, String trustStore) throws GeneralSecurityException;
-
-}
diff --git a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/Config.java b/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/Config.java
deleted file mode 100644
index c0e4e5c..0000000
--- a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/Config.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.config.impl;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.security.auth.login.AppConfigurationEntry;
-
-import org.apache.felix.karaf.jaas.boot.ProxyLoginModule;
-import org.apache.felix.karaf.jaas.config.JaasRealm;
-import org.osgi.framework.BundleContext;
-
-/**
- * An implementation of JaasRealm which is created
- * by the spring namespace handler.
- */
-public class Config implements JaasRealm {
-
- private String name;
- private int rank;
- private Module[] modules;
- private BundleContext bundleContext;
- private transient AppConfigurationEntry[] entries;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getRank() {
- return rank;
- }
-
- public void setRank(int rank) {
- this.rank = rank;
- }
-
- public Module[] getModules() {
- return modules;
- }
-
- public void setModules(Module[] modules) {
- this.modules = modules;
- this.entries = null;
- }
-
- public BundleContext getBundleContext() {
- return bundleContext;
- }
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- public AppConfigurationEntry[] getEntries() {
- if (this.entries == null && this.modules != null) {
- Module[] modules = this.modules;
- AppConfigurationEntry[] entries = new AppConfigurationEntry[modules.length];
- for (int i = 0; i < modules.length; i++) {
- Map<String,Object> options = new HashMap<String,Object>();
- if (modules[i].getOptions() != null) {
- for (Map.Entry e : modules[i].getOptions().entrySet()) {
- options.put(e.getKey().toString(), e.getValue());
- }
- }
- options.put(ProxyLoginModule.PROPERTY_MODULE, modules[i].getClassName());
- options.put(ProxyLoginModule.PROPERTY_BUNDLE, Long.toString(bundleContext.getBundle().getBundleId()));
- entries[i] = new AppConfigurationEntry(ProxyLoginModule.class.getName(),
- getControlFlag(modules[i].getFlags()),
- options);
- }
- this.entries = entries;
- }
- return this.entries;
- }
-
- private AppConfigurationEntry.LoginModuleControlFlag getControlFlag(String flags) {
- if ("required".equalsIgnoreCase(flags)) {
- return AppConfigurationEntry.LoginModuleControlFlag.REQUIRED;
- }
- if ("optional".equalsIgnoreCase(flags)) {
- return AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL;
- }
- if ("requisite".equalsIgnoreCase(flags)) {
- return AppConfigurationEntry.LoginModuleControlFlag.REQUISITE;
- }
- if ("sufficient".equalsIgnoreCase(flags)) {
- return AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT;
- }
- return null;
- }
-}
diff --git a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/Module.java b/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/Module.java
deleted file mode 100644
index ae74205..0000000
--- a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/Module.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.config.impl;
-
-import java.util.Properties;
-
-/**
- * POJO for a login module.
- * It contains the class name, flags and a map of options.
- */
-public class Module {
-
- private String className;
- private String flags;
- private Properties options;
-
- public String getClassName() {
- return className;
- }
-
- public void setClassName(String className) {
- this.className = className;
- }
-
- public String getFlags() {
- return flags;
- }
-
- public void setFlags(String flags) {
- this.flags = flags;
- }
-
- public Properties getOptions() {
- return options;
- }
-
- public void setOptions(Properties options) {
- this.options = options;
- }
-
-}
diff --git a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/NamespaceHandler.java b/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/NamespaceHandler.java
deleted file mode 100644
index 4c5e8d8..0000000
--- a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/NamespaceHandler.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.config.impl;
-
-import java.net.URL;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.CharacterData;
-import org.w3c.dom.Comment;
-import org.w3c.dom.EntityReference;
-
-import org.osgi.service.blueprint.container.ComponentDefinitionException;
-import org.osgi.service.blueprint.reflect.ComponentMetadata;
-import org.osgi.service.blueprint.reflect.ValueMetadata;
-import org.osgi.service.blueprint.reflect.RefMetadata;
-import org.osgi.service.blueprint.reflect.Metadata;
-import org.apache.felix.karaf.jaas.config.JaasRealm;
-import org.apache.felix.karaf.jaas.config.KeystoreInstance;
-import org.apache.felix.karaf.jaas.boot.ProxyLoginModule;
-import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
-import org.apache.aries.blueprint.mutable.MutableValueMetadata;
-import org.apache.aries.blueprint.mutable.MutableRefMetadata;
-import org.apache.aries.blueprint.mutable.MutableCollectionMetadata;
-import org.apache.aries.blueprint.mutable.MutableServiceMetadata;
-import org.apache.aries.blueprint.ParserContext;
-
-public class NamespaceHandler implements org.apache.aries.blueprint.NamespaceHandler {
-
- public URL getSchemaLocation(String namespace) {
- return getClass().getResource("/org/apache/felix/karaf/jaas/config/karaf-jaas.xsd");
- }
-
- public Set<Class> getManagedClasses() {
- return new HashSet<Class>(Arrays.asList(
- Config.class,
- ResourceKeystoreInstance.class
- ));
- }
-
- public Metadata parse(Element element, ParserContext context) {
- String name = element.getLocalName() != null ? element.getLocalName() : element.getNodeName();
- if ("config".equals(name)) {
- return parseConfig(element, context);
- } else if ("keystore".equals(name)) {
- return parseKeystore(element, context);
- }
- throw new ComponentDefinitionException("Bad xml syntax: unknown element '" + name + "'");
- }
-
- public ComponentMetadata decorate(Node node, ComponentMetadata component, ParserContext context) {
- throw new ComponentDefinitionException("Bad xml syntax: node decoration is not supported");
- }
-
- public ComponentMetadata parseConfig(Element element, ParserContext context) {
- MutableBeanMetadata bean = context.createMetadata(MutableBeanMetadata.class);
- bean.setRuntimeClass(Config.class);
- String name = element.getAttribute("name");
- bean.addProperty("bundleContext", createRef(context, "blueprintBundleContext"));
- bean.addProperty("name", createValue(context, name));
- String rank = element.getAttribute("rank");
- if (rank != null && rank.length() > 0) {
- bean.addProperty("rank", createValue(context, rank));
- }
- NodeList childElements = element.getElementsByTagNameNS("http://felix.apache.org/karaf/xmlns/jaas/v1.0.0", "module");
- if (childElements != null && childElements.getLength() > 0) {
- MutableCollectionMetadata children = context.createMetadata(MutableCollectionMetadata.class);
- for (int i = 0; i < childElements.getLength(); ++i) {
- Element childElement = (Element) childElements.item(i);
- MutableBeanMetadata md = context.createMetadata(MutableBeanMetadata.class);
- md.setRuntimeClass(Module.class);
- md.addProperty("className", createValue(context, childElement.getAttribute("className")));
- if (childElement.getAttribute("flags") != null) {
- md.addProperty("flags", createValue(context, childElement.getAttribute("flags")));
- }
- String options = getTextValue(childElement);
- if (options != null && options.length() > 0) {
- md.addProperty("options", createValue(context, options));
- }
- children.addValue(md);
- }
- bean.addProperty("modules", children);
- }
- // Publish Config
- MutableServiceMetadata service = context.createMetadata(MutableServiceMetadata.class);
- service.setId(name);
- service.setServiceComponent(bean);
- service.addInterface(JaasRealm.class.getName());
- service.addServiceProperty(createValue(context, ProxyLoginModule.PROPERTY_MODULE), createValue(context, name));
- return service;
- }
-
- public ComponentMetadata parseKeystore(Element element, ParserContext context) {
- MutableBeanMetadata bean = context.createMetadata(MutableBeanMetadata.class);
- bean.setRuntimeClass(ResourceKeystoreInstance.class);
- // Parse name
- String name = element.getAttribute("name");
- bean.addProperty("name", createValue(context, name));
- // Parse rank
- String rank = element.getAttribute("rank");
- if (rank != null && rank.length() > 0) {
- bean.addProperty("rank", createValue(context, rank));
- }
- // Parse path
- String path = element.getAttribute("path");
- if (path != null && path.length() > 0) {
- bean.addProperty("path", createValue(context, path));
- }
- // Parse keystorePassword
- String keystorePassword = element.getAttribute("keystorePassword");
- if (keystorePassword != null && keystorePassword.length() > 0) {
- bean.addProperty("keystorePassword", createValue(context, keystorePassword));
- }
- // Parse keyPasswords
- String keyPasswords = element.getAttribute("keyPasswords");
- if (keyPasswords != null && keyPasswords.length() > 0) {
- bean.addProperty("keyPasswords", createValue(context, keyPasswords));
- }
- // Publish Config
- MutableServiceMetadata service = context.createMetadata(MutableServiceMetadata.class);
- service.setId(name);
- service.setServiceComponent(bean);
- service.addInterface(KeystoreInstance.class.getName());
- return service;
- }
-
- private ValueMetadata createValue(ParserContext context, String value) {
- MutableValueMetadata v = context.createMetadata(MutableValueMetadata.class);
- v.setStringValue(value);
- return v;
- }
-
- private RefMetadata createRef(ParserContext context, String value) {
- MutableRefMetadata r = context.createMetadata(MutableRefMetadata.class);
- r.setComponentId(value);
- return r;
- }
-
- private static String getTextValue(Element element) {
- StringBuffer value = new StringBuffer();
- NodeList nl = element.getChildNodes();
- for (int i = 0; i < nl.getLength(); i++) {
- Node item = nl.item(i);
- if ((item instanceof CharacterData && !(item instanceof Comment)) || item instanceof EntityReference) {
- value.append(item.getNodeValue());
- }
- }
- return value.toString();
- }
-}
diff --git a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/OsgiConfiguration.java b/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/OsgiConfiguration.java
deleted file mode 100644
index 405161a..0000000
--- a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/OsgiConfiguration.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.config.impl;
-
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import javax.security.auth.login.AppConfigurationEntry;
-import javax.security.auth.login.Configuration;
-
-import org.apache.felix.karaf.jaas.config.JaasRealm;
-
-public class OsgiConfiguration extends Configuration {
-
- private final List<JaasRealm> realms = new CopyOnWriteArrayList<JaasRealm>();
-
- public void init() {
- Configuration.setConfiguration(this);
- }
-
- public void close() {
- realms.clear();
- Configuration.setConfiguration(null);
- }
-
- public void register(JaasRealm realm, Map<String,?> properties) {
- realms.add(realm);
- }
-
- public void unregister(JaasRealm realm, Map<String,?> properties) {
- realms.remove(realm);
- }
-
- public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
- JaasRealm realm = null;
- for (JaasRealm r : realms) {
- if (r.getName().equals(name)) {
- if (realm == null || r.getRank() > realm.getRank()) {
- realm = r;
- }
- }
- }
- if (realm != null) {
- return realm.getEntries();
- }
- return null;
- }
-
- public void refresh() {
- // Nothing to do, as we auto-update the configuration
- }
-}
diff --git a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/OsgiKeystoreManager.java b/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/OsgiKeystoreManager.java
deleted file mode 100644
index bb75dce..0000000
--- a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/OsgiKeystoreManager.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.config.impl;
-
-import java.security.GeneralSecurityException;
-import java.security.SecureRandom;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLServerSocketFactory;
-import javax.net.ssl.SSLSocketFactory;
-
-import org.apache.felix.karaf.jaas.config.KeystoreInstance;
-import org.apache.felix.karaf.jaas.config.KeystoreIsLocked;
-import org.apache.felix.karaf.jaas.config.KeystoreManager;
-
-/**
- * Implementation of KeystoreManager
- */
-public class OsgiKeystoreManager implements KeystoreManager {
-
- private List<KeystoreInstance> keystores = new CopyOnWriteArrayList<KeystoreInstance>();
-
- public void register(KeystoreInstance keystore, Map<String,?> properties) {
- keystores.add(keystore);
- }
-
- public void unregister(KeystoreInstance keystore, Map<String,?> properties) {
- keystores.remove(keystore);
- }
-
- public KeystoreInstance getKeystore(String name) {
- KeystoreInstance keystore = null;
- for (KeystoreInstance ks : keystores) {
- if (ks.getName().equals(name)) {
- if (keystore == null || keystore.getRank() < ks.getRank()) {
- keystore = ks;
- }
- }
- }
- return keystore;
- }
-
- public SSLContext createSSLContext(String provider, String protocol, String algorithm, String keyStore, String keyAlias, String trustStore) throws GeneralSecurityException {
- KeystoreInstance keyInstance = getKeystore(keyStore);
- if (keyInstance != null && keyInstance.isKeystoreLocked()) {
- throw new KeystoreIsLocked("Keystore '" + keyStore + "' is locked");
- }
- if (keyInstance != null && keyInstance.isKeyLocked(keyAlias)) {
- throw new KeystoreIsLocked("Key '" + keyAlias + "' in keystore '" + keyStore + "' is locked");
- }
- KeystoreInstance trustInstance = trustStore == null ? null : getKeystore(trustStore);
- if (trustInstance != null && trustInstance.isKeystoreLocked()) {
- throw new KeystoreIsLocked("Keystore '" + trustStore + "' is locked");
- }
- SSLContext context;
- if (provider == null) {
- context = SSLContext.getInstance(protocol);
- } else {
- context = SSLContext.getInstance(protocol, provider);
- }
- context.init(keyInstance == null ? null : keyInstance.getKeyManager(algorithm, keyAlias),
- trustInstance == null ? null : trustInstance.getTrustManager(algorithm), new SecureRandom());
- return context;
- }
-
- public SSLServerSocketFactory createSSLServerFactory(String provider, String protocol, String algorithm, String keyStore, String keyAlias, String trustStore) throws GeneralSecurityException {
- SSLContext context = createSSLContext(provider, protocol, algorithm, keyStore, keyAlias, trustStore);
- return context.getServerSocketFactory();
- }
-
- public SSLSocketFactory createSSLFactory(String provider, String protocol, String algorithm, String keyStore, String keyAlias, String trustStore) throws GeneralSecurityException {
- SSLContext context = createSSLContext(provider, protocol, algorithm, keyStore, keyAlias, trustStore);
- return context.getSocketFactory();
- }
-}
diff --git a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/ProxyLoginModuleInitializer.java b/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/ProxyLoginModuleInitializer.java
deleted file mode 100644
index d69cc90..0000000
--- a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/ProxyLoginModuleInitializer.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.config.impl;
-
-import org.apache.felix.karaf.jaas.boot.ProxyLoginModule;
-import org.osgi.framework.BundleContext;
-
-public class ProxyLoginModuleInitializer {
-
- private BundleContext bundleContext;
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- public void init() {
- BundleContext context = bundleContext.getBundle(0).getBundleContext();
- ProxyLoginModule.init(context);
- }
-}
diff --git a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/ResourceKeystoreInstance.java b/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/ResourceKeystoreInstance.java
deleted file mode 100644
index 4d7f792..0000000
--- a/karaf/jaas/config/src/main/java/org/apache/felix/karaf/jaas/config/impl/ResourceKeystoreInstance.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.config.impl;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.Key;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.PrivateKey;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.net.URL;
-import java.net.URI;
-
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.felix.karaf.jaas.config.KeystoreInstance;
-import org.apache.felix.karaf.jaas.config.KeystoreIsLocked;
-
-/**
- *
- */
-public class ResourceKeystoreInstance implements KeystoreInstance {
-
- private static final Log LOG = LogFactory.getLog(ResourceKeystoreInstance.class);
- private static final String JKS = "JKS";
-
- private String name;
- private int rank;
- private URL path;
- private String keystorePassword;
- private Map keyPasswords = new HashMap();
- private File keystoreFile; // Only valid after startup and if the resource points to a file
-
- // The following variables are the state of the keystore, which should be chucked if the file on disk changes
- private List privateKeys = new ArrayList();
- private List trustCerts = new ArrayList();
- private KeyStore keystore;
- private long keystoreReadDate = Long.MIN_VALUE;
-
- /**
- * @return the keystoreName
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param keystoreName the keystoreName to set
- */
- public void setName(String keystoreName) {
- this.name = keystoreName;
- }
-
- /**
- * @return the rank
- */
- public int getRank() {
- return rank;
- }
-
- /**
- * @param rank the rank to set
- */
- public void setRank(int rank) {
- this.rank = rank;
- }
-
- /**
- * @return the keystorePath
- */
- public URL getPath() {
- return path;
- }
-
- /**
- * @param keystorePath the keystorePath to set
- */
- public void setPath(URL keystorePath) throws IOException {
- this.path = keystorePath;
- if (keystorePath.getProtocol().equals("file")) {
- URI uri = URI.create(keystorePath.toString().replace(" ", "%20"));
- this.keystoreFile = new File(uri.getSchemeSpecificPart());
- }
- }
-
- /**
- * @param keystorePassword the keystorePassword to set
- */
- public void setKeystorePassword(String keystorePassword) {
- this.keystorePassword = keystorePassword;
- }
-
- /**
- * @param keyPasswords the keyPasswords to set
- */
- public void setKeyPasswords(String keyPasswords) {
- if (keyPasswords != null) {
- String[] keys = keyPasswords.split("\\]\\!\\[");
- for (int i = 0; i < keys.length; i++) {
- String key = keys[i];
- int pos = key.indexOf('=');
- this.keyPasswords.put(key.substring(0, pos), key.substring(pos + 1).toCharArray());
- }
- }
- }
-
- public Certificate getCertificate(String alias) {
- if (!loadKeystoreData()) {
- return null;
- }
- try {
- return keystore.getCertificate(alias);
- } catch (KeyStoreException e) {
- LOG.error("Unable to read certificate from keystore", e);
- }
- return null;
- }
-
- public String getCertificateAlias(Certificate cert) {
- if (!loadKeystoreData()) {
- return null;
- }
- try {
- return keystore.getCertificateAlias(cert);
- } catch (KeyStoreException e) {
- LOG.error("Unable to read retrieve alias for given certificate from keystore", e);
- }
- return null;
- }
-
- public Certificate[] getCertificateChain(String alias) {
- if (!loadKeystoreData()) {
- return null;
- }
- try {
- return keystore.getCertificateChain(alias);
- } catch (KeyStoreException e) {
- LOG.error("Unable to read certificate chain from keystore", e);
- }
- return null;
- }
-
- public KeyManager[] getKeyManager(String algorithm, String keyAlias) throws KeystoreIsLocked,
- NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException {
- if (isKeystoreLocked()) {
- throw new KeystoreIsLocked("Keystore '" + name + "' is locked.");
- }
- if (!loadKeystoreData()) {
- return null;
- }
- KeyManagerFactory keyFactory = KeyManagerFactory.getInstance(algorithm);
- keyFactory.init(keystore, (char[]) keyPasswords.get(keyAlias));
- return keyFactory.getKeyManagers();
- }
-
- public PrivateKey getPrivateKey(String alias) {
- if (!loadKeystoreData()) {
- return null;
- }
- try {
- if (isKeyLocked(alias)) {
- return null;
- }
- Key key = keystore.getKey(alias, (char[]) keyPasswords.get(alias));
- if (key instanceof PrivateKey) {
- return (PrivateKey) key;
- }
- } catch (KeyStoreException e) {
- LOG.error("Unable to read private key from keystore", e);
- } catch (NoSuchAlgorithmException e) {
- LOG.error("Unable to read private key from keystore", e);
- } catch (UnrecoverableKeyException e) {
- LOG.error("Unable to read private key from keystore", e);
- }
- return null;
- }
-
- public TrustManager[] getTrustManager(String algorithm) throws KeyStoreException,
- NoSuchAlgorithmException, KeystoreIsLocked {
- if (isKeystoreLocked()) {
- throw new KeystoreIsLocked("Keystore '" + name + "' is locked.");
- }
- if (!loadKeystoreData()) {
- return null;
- }
- TrustManagerFactory trustFactory = TrustManagerFactory.getInstance(algorithm);
- trustFactory.init(keystore);
- return trustFactory.getTrustManagers();
- }
-
- public boolean isKeyLocked(String keyAlias) {
- return keyPasswords.get(keyAlias) == null;
- }
-
- public boolean isKeystoreLocked() {
- return keystorePassword == null;
- }
-
- public String[] listPrivateKeys() {
- if (!loadKeystoreData()) {
- return null;
- }
- return (String[]) privateKeys.toArray(new String[privateKeys.size()]);
- }
-
- public String[] listTrustCertificates() {
- if (!loadKeystoreData()) {
- return null;
- }
- return (String[]) trustCerts.toArray(new String[trustCerts.size()]);
- }
-
- // ==================== Internals =====================
-
- private boolean loadKeystoreData() {
- // Check to reload the data if needed
- if (keystoreFile != null && keystoreReadDate >= keystoreFile.lastModified()) {
- return true;
- }
- // If not a file, just not reload the data if it has already been loaded
- if (keystoreFile == null && keystore != null) {
- return true;
- }
- // Check if the file is invalid
- if (keystoreFile != null && (!keystoreFile.exists() || !keystoreFile.canRead())) {
- throw new IllegalArgumentException("Invalid keystore file (" + path + " = " + keystoreFile.getAbsolutePath() + ")");
- }
- // Load the keystore data
- try {
- keystoreReadDate = System.currentTimeMillis();
- privateKeys.clear();
- trustCerts.clear();
- if (keystore == null) {
- keystore = KeyStore.getInstance(JKS);
- }
- InputStream in = new BufferedInputStream(path.openStream());
- keystore.load(in, keystorePassword == null ? new char[0] : keystorePassword.toCharArray());
- in.close();
- Enumeration aliases = keystore.aliases();
- while (aliases.hasMoreElements()) {
- String alias = (String) aliases.nextElement();
- if (keystore.isKeyEntry(alias)) {
- privateKeys.add(alias);
- } else if (keystore.isCertificateEntry(alias)) {
- trustCerts.add(alias);
- }
- }
- return true;
- } catch (KeyStoreException e) {
- LOG.error("Unable to open keystore with provided password", e);
- } catch (IOException e) {
- LOG.error("Unable to open keystore with provided password", e);
- } catch (NoSuchAlgorithmException e) {
- LOG.error("Unable to open keystore with provided password", e);
- } catch (CertificateException e) {
- LOG.error("Unable to open keystore with provided password", e);
- }
- return false;
- }
-
-}
diff --git a/karaf/jaas/config/src/main/resources/OSGI-INF/blueprint/karaf-jaas.xml b/karaf/jaas/config/src/main/resources/OSGI-INF/blueprint/karaf-jaas.xml
deleted file mode 100644
index b751552..0000000
--- a/karaf/jaas/config/src/main/resources/OSGI-INF/blueprint/karaf-jaas.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <bean id="config"
- class="org.apache.felix.karaf.jaas.config.impl.OsgiConfiguration"
- init-method="init"
- destroy-method="close"/>
-
- <reference-list id="realms"
- interface="org.apache.felix.karaf.jaas.config.JaasRealm"
- availability="optional">
- <reference-listener ref="config" bind-method="register" unbind-method="unregister" />
- </reference-list>
-
- <bean id="proxyLoginModuleInitializer" class="org.apache.felix.karaf.jaas.config.impl.ProxyLoginModuleInitializer" init-method="init">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </bean>
-
- <!-- Register the Straight-Through flow -->
- <bean id="keystoreManager" class="org.apache.felix.karaf.jaas.config.impl.OsgiKeystoreManager" />
- <service ref="keystoreManager" interface="org.apache.felix.karaf.jaas.config.KeystoreManager" />
-
- <reference-list id="keystores"
- interface="org.apache.felix.karaf.jaas.config.KeystoreInstance"
- availability="optional">
- <reference-listener ref="keystoreManager" bind-method="register" unbind-method="unregister" />
- </reference-list>
-
- <service interface="org.apache.aries.blueprint.NamespaceHandler">
- <service-properties>
- <entry key="osgi.service.blueprint.namespace" value="http://felix.apache.org/karaf/xmlns/jaas/v1.0.0"/>
- </service-properties>
- <bean class="org.apache.felix.karaf.jaas.config.impl.NamespaceHandler"/>
- </service>
-
-</blueprint>
diff --git a/karaf/jaas/config/src/main/resources/org/apache/felix/karaf/jaas/config/karaf-jaas.xsd b/karaf/jaas/config/src/main/resources/org/apache/felix/karaf/jaas/config/karaf-jaas.xsd
deleted file mode 100644
index 0a9f8d4..0000000
--- a/karaf/jaas/config/src/main/resources/org/apache/felix/karaf/jaas/config/karaf-jaas.xsd
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<xs:schema elementFormDefault='qualified'
- targetNamespace='http://felix.apache.org/karaf/xmlns/jaas/v1.0.0'
- xmlns:xs='http://www.w3.org/2001/XMLSchema'
- xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:tns='http://felix.apache.org/karaf/xmlns/jaas/v1.0.0'>
-
- <xs:import namespace="http://www.osgi.org/xmlns/blueprint/v1.0.0"/>
-
- <xs:element name="config">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="module" minOccurs="0" maxOccurs="unbounded">
- <xs:complexType mixed="true">
- <xs:attribute name="className" use="required" type="xs:string" />
- <xs:attribute name="flags" default="required">
- <xs:simpleType>
- <xs:restriction base="xs:NMTOKEN">
- <xs:enumeration value="required"/>
- <xs:enumeration value="requisite"/>
- <xs:enumeration value="sufficient"/>
- <xs:enumeration value="optional"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:attribute>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="name" use="required" type="xs:string" />
- <xs:attribute name="rank" use="optional" default="0" type="xs:int" />
- </xs:complexType>
- </xs:element>
-
- <xs:element name="keystore">
- <xs:complexType>
- <xs:attribute name="name" use="required" type="xs:string" />
- <xs:attribute name="rank" use="optional" default="0" type="xs:int" />
- <xs:attribute name="path" use="required" type="xs:string" />
- <xs:attribute name="keystorePassword" use="optional" type="xs:string" />
- <xs:attribute name="keyPasswords" use="optional" type="xs:string" />
- </xs:complexType>
- </xs:element>
-
-</xs:schema>
diff --git a/karaf/jaas/modules/NOTICE b/karaf/jaas/modules/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/jaas/modules/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/jaas/modules/pom.xml b/karaf/jaas/modules/pom.xml
deleted file mode 100644
index 4c73ea0..0000000
--- a/karaf/jaas/modules/pom.xml
+++ /dev/null
@@ -1,99 +0,0 @@
-<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/maven-v4_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.felix.karaf.jaas</groupId>
- <artifactId>jaas</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.jaas</groupId>
- <artifactId>org.apache.felix.karaf.jaas.modules</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: JAAS Modules</name>
-
- <description>
- Provides the JAAS Config
- </description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix.karaf.jaas</groupId>
- <artifactId>org.apache.felix.karaf.jaas.config</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.aries.blueprint</groupId>
- <artifactId>org.apache.aries.blueprint</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Import-Package>
- !${project.artifactId}*,
- org.apache.felix.karaf.jaas.config,
- org.apache.aries.blueprint.ext,
- *
- </Import-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git a/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/RolePrincipal.java b/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/RolePrincipal.java
deleted file mode 100644
index 1e70880..0000000
--- a/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/RolePrincipal.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.modules;
-
-import java.security.Principal;
-
-public class RolePrincipal implements Principal {
-
- private final String name;
-
- public RolePrincipal(String name) {
- assert name != null;
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof RolePrincipal)) return false;
-
- RolePrincipal that = (RolePrincipal) o;
-
- if (name != null ? !name.equals(that.name) : that.name != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return name != null ? name.hashCode() : 0;
- }
-
- @Override
- public String toString() {
- return "RolePrincipal[" + name + "]";
- }
-}
diff --git a/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/UserPrincipal.java b/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/UserPrincipal.java
deleted file mode 100644
index c791db9..0000000
--- a/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/UserPrincipal.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.modules;
-
-import java.security.Principal;
-
-public class UserPrincipal implements Principal {
-
- private final String name;
-
- public UserPrincipal(String name) {
- assert name != null;
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof UserPrincipal)) return false;
-
- UserPrincipal that = (UserPrincipal) o;
-
- if (name != null ? !name.equals(that.name) : that.name != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return name != null ? name.hashCode() : 0;
- }
-
- @Override
- public String toString() {
- return "UserPrincipal[" + name + "]";
- }
-}
diff --git a/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/osgi/ConfigAdminHolder.java b/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/osgi/ConfigAdminHolder.java
deleted file mode 100644
index cef50a7..0000000
--- a/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/osgi/ConfigAdminHolder.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.modules.osgi;
-
-import org.osgi.service.cm.ConfigurationAdmin;
-
-public class ConfigAdminHolder {
-
- private static ConfigurationAdmin configAdmin;
-
- public static ConfigurationAdmin getService() {
- return configAdmin;
- }
-
- public void setService(ConfigurationAdmin configAdmin) {
- ConfigAdminHolder.configAdmin = configAdmin;
- }
-
-}
diff --git a/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/osgi/OsgiConfigLoginModule.java b/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/osgi/OsgiConfigLoginModule.java
deleted file mode 100644
index 5e29485..0000000
--- a/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/osgi/OsgiConfigLoginModule.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.modules.osgi;
-
-import java.io.IOException;
-import java.security.Principal;
-import java.util.Dictionary;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.NameCallback;
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.auth.login.FailedLoginException;
-import javax.security.auth.login.LoginException;
-import javax.security.auth.spi.LoginModule;
-
-import org.apache.felix.karaf.jaas.modules.RolePrincipal;
-import org.apache.felix.karaf.jaas.modules.UserPrincipal;
-import org.osgi.service.cm.Configuration;
-
-public class OsgiConfigLoginModule implements LoginModule {
-
- public static final String PID = "pid";
- public static final String USER_PREFIX = "user.";
-
- private Subject subject;
- private CallbackHandler callbackHandler;
- private Map<String, ?> options;
-
- private Set<Principal> principals;
-
- public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) {
- this.subject = subject;
- this.callbackHandler = callbackHandler;
- this.options = options;
- }
-
- public boolean login() throws LoginException {
- try {
- String pid = (String) options.get(PID);
- Configuration config = ConfigAdminHolder.getService().getConfiguration(pid);
- Dictionary properties = config.getProperties();
-
- Callback[] callbacks = new Callback[2];
-
- callbacks[0] = new NameCallback("Username: ");
- callbacks[1] = new PasswordCallback("Password: ", false);
- try {
- callbackHandler.handle(callbacks);
- } catch (IOException ioe) {
- throw new LoginException(ioe.getMessage());
- } catch (UnsupportedCallbackException uce) {
- throw new LoginException(uce.getMessage() + " not available to obtain information from user");
- }
- String user = ((NameCallback) callbacks[0]).getName();
- char[] tmpPassword = ((PasswordCallback) callbacks[1]).getPassword();
- if (tmpPassword == null) {
- tmpPassword = new char[0];
- }
-
- String userInfos = (String) properties.get(USER_PREFIX + user);
- if (userInfos == null) {
- throw new FailedLoginException("User does not exist");
- }
- String[] infos = userInfos.split(",");
- if (!new String(tmpPassword).equals(infos[0])) {
- throw new FailedLoginException("Password does not match");
- }
-
- principals = new HashSet<Principal>();
- principals.add(new UserPrincipal(user));
- for (int i = 1; i < infos.length; i++) {
- principals.add(new RolePrincipal(infos[i]));
- }
-
- return true;
- } catch (LoginException e) {
- throw e;
- } catch (Exception e) {
- throw (LoginException) new LoginException("Unable to authenticate user").initCause(e);
- } finally {
- callbackHandler = null;
- options = null;
- }
- }
-
- public boolean commit() throws LoginException {
- subject.getPrincipals().addAll(principals);
- return true;
- }
-
- public boolean abort() throws LoginException {
- subject = null;
- principals = null;
- return true;
- }
-
- public boolean logout() throws LoginException {
- try {
- subject.getPrincipals().removeAll(principals);
- principals.clear();
- return true;
- } finally {
- subject = null;
- principals = null;
- }
- }
-
-}
diff --git a/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/properties/PropertiesConverter.java b/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/properties/PropertiesConverter.java
deleted file mode 100644
index b8dc6ee..0000000
--- a/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/properties/PropertiesConverter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.modules.properties;
-
-import org.osgi.service.blueprint.container.Converter;
-import org.osgi.service.blueprint.container.ReifiedType;
-
-import java.util.Properties;
-
-/**
- * Custom converter to transform a string into a Properties instance.
- * (to avoid removing \ from the values as is done by the default blueprint converter)
- */
-public class PropertiesConverter implements Converter {
-
- public boolean canConvert(Object from, ReifiedType type) {
- return String.class.isAssignableFrom(from.getClass())
- && Properties.class.equals(type.getRawClass());
- }
-
- public Object convert(Object from, ReifiedType type) throws Exception {
- Properties properties = new Properties();
-
- String text = (String) from;
- for (String line : text.split("[\\r\\n]+")) {
- int index = line.indexOf('=');
- if (index > 0) {
- String key = line.substring(0, index).trim();
- String value = line.substring(index + 1).trim();
- properties.put(key, value.replaceAll("\\\\", "/"));
- }
- }
-
- return properties;
- }
-}
diff --git a/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/properties/PropertiesLoginModule.java b/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/properties/PropertiesLoginModule.java
deleted file mode 100644
index 8219b4e..0000000
--- a/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/properties/PropertiesLoginModule.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.modules.properties;
-
-import java.io.File;
-import java.io.IOException;
-import java.security.Principal;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.NameCallback;
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.auth.login.FailedLoginException;
-import javax.security.auth.login.LoginException;
-import javax.security.auth.spi.LoginModule;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.felix.karaf.jaas.modules.RolePrincipal;
-import org.apache.felix.karaf.jaas.modules.UserPrincipal;
-
-/**
- * JAAS Login module for user / password, based on two properties files.
- *
- */
-public class PropertiesLoginModule implements LoginModule {
-
- private static final String USER_FILE = "users";
- private static final Log LOG = LogFactory.getLog(PropertiesLoginModule.class);
-
- private Subject subject;
- private CallbackHandler callbackHandler;
- private boolean debug;
- private String usersFile;
- private String user;
- private Set principals = new HashSet();
-
- public void initialize(Subject sub, CallbackHandler handler, Map sharedState, Map options) {
- this.subject = sub;
- this.callbackHandler = handler;
-
- debug = "true".equalsIgnoreCase((String) options.get("debug"));
- usersFile = (String) options.get(USER_FILE) + "";
-
- if (debug) {
- LOG.debug("Initialized debug=" + debug + " usersFile=" + usersFile);
- }
- }
-
- public boolean login() throws LoginException {
- Properties users = new Properties();
- File f = new File(usersFile);
- try {
- users.load(new java.io.FileInputStream(f));
- } catch (IOException ioe) {
- throw new LoginException("Unable to load user properties file " + f);
- }
-
- Callback[] callbacks = new Callback[2];
-
- callbacks[0] = new NameCallback("Username: ");
- callbacks[1] = new PasswordCallback("Password: ", false);
- try {
- callbackHandler.handle(callbacks);
- } catch (IOException ioe) {
- throw new LoginException(ioe.getMessage());
- } catch (UnsupportedCallbackException uce) {
- throw new LoginException(uce.getMessage() + " not available to obtain information from user");
- }
- user = ((NameCallback) callbacks[0]).getName();
- char[] tmpPassword = ((PasswordCallback) callbacks[1]).getPassword();
- if (tmpPassword == null) {
- tmpPassword = new char[0];
- }
-
- String userInfos = null;
-
- try {
- userInfos = (String) users.get(user);
- } catch (NullPointerException e) {
- //error handled in the next statement
- }
- if (userInfos == null) {
- throw new FailedLoginException("User " + user + " does not exist");
- }
- String[] infos = userInfos.split(",");
- if (!new String(tmpPassword).equals(infos[0])) {
- throw new FailedLoginException("Password for " + user + " does not match");
- }
-
- principals = new HashSet<Principal>();
- principals.add(new UserPrincipal(user));
- for (int i = 1; i < infos.length; i++) {
- principals.add(new RolePrincipal(infos[i]));
- }
-
- users.clear();
-
- if (debug) {
- LOG.debug("Successfully logged in " + user);
- }
- return true;
- }
-
- public boolean commit() throws LoginException {
- subject.getPrincipals().addAll(principals);
- clear();
- if (debug) {
- LOG.debug("commit");
- }
- return true;
- }
-
- public boolean abort() throws LoginException {
- clear();
- if (debug) {
- LOG.debug("abort");
- }
- return true;
- }
-
- public boolean logout() throws LoginException {
- subject.getPrincipals().removeAll(principals);
- principals.clear();
- if (debug) {
- LOG.debug("logout");
- }
- return true;
- }
-
- private void clear() {
- user = null;
- }
-}
diff --git a/karaf/jaas/modules/src/main/resources/OSGI-INF/blueprint/karaf-jaas-module.xml b/karaf/jaas/modules/src/main/resources/OSGI-INF/blueprint/karaf-jaas-module.xml
deleted file mode 100644
index 4abda4e..0000000
--- a/karaf/jaas/modules/src/main/resources/OSGI-INF/blueprint/karaf-jaas-module.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:jaas="http://felix.apache.org/karaf/xmlns/jaas/v1.0.0"
- xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
-
- <type-converters>
- <bean class="org.apache.felix.karaf.jaas.modules.properties.PropertiesConverter" />
- </type-converters>
-
- <!-- Bean to allow the $[karaf.base] property to be correctly resolved -->
- <ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"/>
-
- <jaas:config name="karaf">
- <jaas:module className="org.apache.felix.karaf.jaas.modules.properties.PropertiesLoginModule" flags="required">
- users = $[karaf.base]/etc/users.properties
- </jaas:module>
- </jaas:config>
-
-</blueprint>
diff --git a/karaf/jaas/modules/src/test/java/org/apache/felix/karaf/jaas/modules/properties/PropertiesConverterTest.java b/karaf/jaas/modules/src/test/java/org/apache/felix/karaf/jaas/modules/properties/PropertiesConverterTest.java
deleted file mode 100644
index d3cbed4..0000000
--- a/karaf/jaas/modules/src/test/java/org/apache/felix/karaf/jaas/modules/properties/PropertiesConverterTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.jaas.modules.properties;
-
-import junit.framework.TestCase;
-import org.osgi.service.blueprint.container.ReifiedType;
-
-import java.util.Properties;
-import java.util.List;
-
-/**
- * Test cases for {@link org.apache.felix.karaf.jaas.modules.properties.PropertiesConverter}
- */
-public class PropertiesConverterTest extends TestCase {
-
- private PropertiesConverter converter;
-
- public void setUp() {
- converter = new PropertiesConverter();
- }
-
- /*
- * Test the canConvert method
- */
- public void testCanConvert() {
- assertTrue(converter.canConvert("a string", new ReifiedType(Properties.class)));
- assertFalse(converter.canConvert(new Object(), new ReifiedType(Properties.class)));
- assertFalse(converter.canConvert("a string", new ReifiedType(List.class)));
- }
-
- /*
- * Test the convert method when dealing with unix paths (no \)
- */
- public void testConvertWithUnixPathNames() throws Exception {
- Properties properties =
- (Properties) converter.convert("users = /opt/karaf/etc/users.properties",
- new ReifiedType(Properties.class));
- assertNotNull(properties);
- assertEquals("/opt/karaf/etc/users.properties", properties.get("users"));
- }
-
- /*
- * Test the convert method when dealing with windows paths (avoid escaping \)
- */
- public void testConvertWithWindowsPathNames() throws Exception {
- Properties properties =
- (Properties) converter.convert("users = c:\\opt\\karaf/etc/users.properties",
- new ReifiedType(Properties.class));
- assertNotNull(properties);
- assertEquals("c:/opt/karaf/etc/users.properties", properties.get("users"));
- }
-}
diff --git a/karaf/jaas/pom.xml b/karaf/jaas/pom.xml
deleted file mode 100644
index 9de2c7b..0000000
--- a/karaf/jaas/pom.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<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/maven-v4_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.felix.karaf</groupId>
- <artifactId>karaf</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.jaas</groupId>
- <artifactId>jaas</artifactId>
- <packaging>pom</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: JAAS</name>
-
- <modules>
- <module>boot</module>
- <module>config</module>
- <module>modules</module>
- </modules>
-
-</project>
diff --git a/karaf/main/NOTICE b/karaf/main/NOTICE
deleted file mode 100644
index 7684a2a..0000000
--- a/karaf/main/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf :: Main
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/main/pom.xml b/karaf/main/pom.xml
deleted file mode 100644
index 0bbe38a..0000000
--- a/karaf/main/pom.xml
+++ /dev/null
@@ -1,210 +0,0 @@
-<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/maven-v4_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.felix.karaf</groupId>
- <artifactId>karaf</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>org.apache.felix.karaf.main</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Main</name>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.eclipse</groupId>
- <artifactId>osgi</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.framework</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <_donotcopy>(CVS|.svn|config.properties)</_donotcopy>
- <Main-Class>org.apache.felix.karaf.main.Main</Main-Class>
- <Bundle-Name>Apache Felix Karaf</Bundle-Name>
- <Bundle-Description>OSGi R4 framework.</Bundle-Description>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>org.apache.felix.karaf.main.spi.*;version=${project.version}</Export-Package>
- <!--
- <Private-Package>
- org.apache.felix.*;-split-package:=merge-first,
- org.eclipse.*;-split-package:=merge-first,
- org.osgi.*;-split-package:=merge-first,
- META-INF;-split-package:=merge-first
- </Private-Package>
- <Import-Package>!*</Import-Package>
- -->
- </instructions>
- <unpackBundle>true</unpackBundle>
- </configuration>
- </plugin>
- <!--
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <artifactSet>
- <includes>
- <include>org.eclipse:osgi</include>
- <include>org.apache.felix:org.apache.felix.framework</include>
- <include>${project.groupId}:${project.artifactId}</include>
- </includes>
- </artifactSet>
- <filters>
- <filter>
- <artifact>org.eclipse:osgi</artifact>
- <includes>
- <include>org/osgi/**</include>
- <include>org/eclipse/**</include>
- <include>hookconfigurators.properties</include>
- </includes>
- </filter>
- <filter>
- <artifact>org.apache.felix:org.apache.felix.framework</artifact>
- <includes>
- <include>org/apache/felix/**</include>
- </includes>
- </filter>
- </filters>
- <createSourcesJar>${createSourcesJar}</createSourcesJar>
- <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
- <createDependencyReducedPom>true</createDependencyReducedPom>
- </configuration>
- </execution>
- </executions>
- </plugin>
- -->
- </plugins>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- </resource>
- </resources>
- </build>
-
- <profiles>
- <profile>
- <id>deploy</id>
- <properties>
- <createSourcesJar>true</createSourcesJar>
- </properties>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>unpack-sources</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>unpack</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.eclipse</groupId>
- <artifactId>osgi</artifactId>
- <classifier>sources</classifier>
- </artifactItem>
- <artifactItem>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <classifier>sources</classifier>
- </artifactItem>
- <artifactItem>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.framework</artifactId>
- <classifier>sources</classifier>
- </artifactItem>
- </artifactItems>
- <outputDirectory>${project.build.directory}/sources</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <phase>process-classes</phase>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <executions>
- <execution>
- <id>package</id>
- <phase>package</phase>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <minmemory>128m</minmemory>
- <maxmemory>512m</maxmemory>
- <sourcepath>${project.build.directory}/sources</sourcepath>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-</project>
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/Bootstrap.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/Bootstrap.java
deleted file mode 100644
index c09b3f9..0000000
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/Bootstrap.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-/**
- * The Bootstrap class is used by the wrapper shell to bootstrap Karaf.
- * Given JSW is using introspection to launch the main method, it would cause
- * a CNFE on the OSGi related classes. Using an indirection solves this problem.
- */
-public class Bootstrap {
-
- public static void main(String[] args) throws Exception {
- Main.main(args);
- }
-}
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/BootstrapLogManager.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/BootstrapLogManager.java
deleted file mode 100644
index c31af9c..0000000
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/BootstrapLogManager.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Properties;
-import java.util.logging.Handler;
-import java.util.logging.LogRecord;
-import java.util.logging.StreamHandler;
-
-/**
- * Convenience class for configuring java.util.logging to append to
- * the configured log4j log. This could be used for bootstrap logging
- * prior to start of the framework.
- *
- */
-public class BootstrapLogManager {
- private static Handler handler;
- private static final String KARAF_BOOTSTRAP_LOG = "karaf.bootstrap.log";
-
- private static Properties configProps;
-
- public static Handler getDefaultHandler () {
- String filename;
- File log;
- Properties props = new Properties();
- filename = configProps.getProperty(KARAF_BOOTSTRAP_LOG);
-
- if (filename != null) {
- log = new File(filename);
- } else {
- // Make a best effort to log to the default file appender configured for log4j
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(System.getProperty("karaf.base") + "/etc/org.ops4j.pax.logging.cfg");
- props.load(fis);
- } catch (IOException e) {
- props.setProperty("log4j.appender.out.file", "${karaf.base}/data/log/karaf.log");
- } finally {
- if (fis != null) {
- try {
- fis.close();
- } catch (IOException ioe) {
- ioe.printStackTrace();
- }
- }
- }
- filename = Main.substVars(props.getProperty("log4j.appender.out.file"),"log4j.appender.out.file", null, null);
- log = new File(filename);
- }
-
-
- try {
- handler = new BootstrapLogManager.SimpleFileHandler(log);
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- return handler;
- }
-
- public static void setProperties(Properties configProps) {
- BootstrapLogManager.configProps = configProps;
- }
-
-
- /**
- * Implementation of java.util.logging.Handler that does simple appending
- * to a named file. Should be able to use this for bootstrap logging
- * via java.util.logging prior to startup of pax logging.
- */
- public static class SimpleFileHandler extends StreamHandler {
-
- public SimpleFileHandler (File file) throws IOException {
- open(file, true);
- }
-
- private void open (File logfile, boolean append) throws IOException {
- if (!logfile.getParentFile().exists()) {
- try {
- logfile.getParentFile().mkdirs();
- } catch (SecurityException se) {
- throw new IOException(se.getMessage());
- }
- }
- FileOutputStream fout = new FileOutputStream(logfile, append);
- BufferedOutputStream out = new BufferedOutputStream(fout);
- setOutputStream(out);
- }
-
- public synchronized void publish (LogRecord record) {
- if (!isLoggable(record)) {
- return;
- }
- super.publish(record);
- flush();
- }
- }
-
-
-}
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/DefaultJDBCLock.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/DefaultJDBCLock.java
deleted file mode 100644
index a331e1a..0000000
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/DefaultJDBCLock.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Properties;
-import java.util.logging.Logger;
-
-/**
- * Represents an exclusive lock on a database,
- * used to avoid multiple Karaf instances attempting
- * to become master.
- *
- * @version $Revision: $
- */
-public class DefaultJDBCLock implements Lock {
-
- final Logger LOG = Logger.getLogger(this.getClass().getName());
-
- private static final String PROPERTY_LOCK_URL = "karaf.lock.jdbc.url";
- private static final String PROPERTY_LOCK_JDBC_DRIVER = "karaf.lock.jdbc.driver";
- private static final String PROPERTY_LOCK_JDBC_USER = "karaf.lock.jdbc.user";
- private static final String PROPERTY_LOCK_JDBC_PASSWORD = "karaf.lock.jdbc.password";
- private static final String PROPERTY_LOCK_JDBC_TABLE = "karaf.lock.jdbc.table";
- private static final String PROPERTY_LOCK_JDBC_CLUSTERNAME = "karaf.lock.jdbc.clustername";
- private static final String PROPERTY_LOCK_JDBC_TIMEOUT = "karaf.lock.jdbc.timeout";
-
- private static final String DEFAULT_PASSWORD = "";
- private static final String DEFAULT_USER = "";
- private static final String DEFAULT_TABLE = "KARAF_LOCK";
- private static final String DEFAULT_CLUSTERNAME = "karaf";
- private static final String DEFAULT_TIMEOUT = "10"; // in seconds
-
- final Statements statements;
- Connection lockConnection;
- String url;
- String driver;
- String user;
- String password;
- String table;
- String clusterName;
- int timeout;
-
- public DefaultJDBCLock(Properties props) {
- LOG.addHandler(BootstrapLogManager.getDefaultHandler());
-
- this.url = props.getProperty(PROPERTY_LOCK_URL);
- this.driver = props.getProperty(PROPERTY_LOCK_JDBC_DRIVER);
- this.user = props.getProperty(PROPERTY_LOCK_JDBC_USER, DEFAULT_USER);
- this.password = props.getProperty(PROPERTY_LOCK_JDBC_PASSWORD, DEFAULT_PASSWORD);
- this.table = props.getProperty(PROPERTY_LOCK_JDBC_TABLE, DEFAULT_TABLE);
- this.clusterName = props.getProperty(PROPERTY_LOCK_JDBC_CLUSTERNAME, DEFAULT_CLUSTERNAME);
- this.timeout = Integer.parseInt(props.getProperty(PROPERTY_LOCK_JDBC_TIMEOUT, DEFAULT_TIMEOUT));
-
- this.statements = createStatements();
-
- init();
- }
-
- Statements createStatements() {
- Statements statements = new Statements();
- statements.setTableName(table);
- statements.setNodeName(clusterName);
- return statements;
- }
-
- void init() {
- try {
- createDatabase();
- createSchema();
- } catch (Exception e) {
- LOG.severe("Error occured while attempting to obtain connection: " + e);
- }
- }
-
- void createDatabase() {
- // do nothing in the default implementation
- }
-
- void createSchema() {
- if (schemaExists()) {
- return;
- }
-
- String[] createStatments = this.statements.getLockCreateSchemaStatements(getCurrentTimeMillis());
- Statement statement = null;
-
- try {
- statement = getConnection().createStatement();
-
- for (String stmt : createStatments) {
- statement.execute(stmt);
- }
-
- getConnection().commit();
- } catch (Exception e) {
- LOG.severe("Could not create schema: " + e );
- } finally {
- closeSafely(statement);
- }
- }
-
- boolean schemaExists() {
- ResultSet rs = null;
- boolean schemaExists = false;
-
- try {
- rs = getConnection().getMetaData().getTables(null, null, statements.getFullLockTableName(), new String[] {"TABLE"});
- schemaExists = rs.next();
- } catch (Exception ignore) {
- LOG.severe("Error testing for db table: " + ignore);
- } finally {
- closeSafely(rs);
- }
-
- return schemaExists;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.felix.karaf.main.Lock#lock()
- */
- public boolean lock() {
- boolean result = aquireLock();
-
- if (result) {
- result = updateLock();
- }
-
- return result;
- }
-
- boolean aquireLock() {
- String lockCreateStatement = statements.getLockCreateStatement();
- PreparedStatement preparedStatement = null;
- boolean lockAquired = false;
-
- try {
- preparedStatement = getConnection().prepareStatement(lockCreateStatement);
- preparedStatement.setQueryTimeout(timeout);
- lockAquired = preparedStatement.execute();
- } catch (Exception e) {
- LOG.warning("Failed to acquire database lock: " + e);
- }finally {
- closeSafely(preparedStatement);
- }
-
- return lockAquired;
- }
-
- boolean updateLock() {
- String lockUpdateStatement = statements.getLockUpdateStatement(getCurrentTimeMillis());
- PreparedStatement preparedStatement = null;
- boolean lockUpdated = false;
-
- try {
- preparedStatement = getConnection().prepareStatement(lockUpdateStatement);
- preparedStatement.setQueryTimeout(timeout);
- int rows = preparedStatement.executeUpdate();
- lockUpdated = (rows == 1);
- } catch (Exception e) {
- LOG.warning("Failed to update database lock: " + e);
- }finally {
- closeSafely(preparedStatement);
- }
-
- return lockUpdated;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.felix.karaf.main.Lock#release()
- */
- public void release() throws Exception {
- if (isConnected()) {
- try {
- getConnection().rollback();
- } catch (SQLException e) {
- LOG.severe("Exception while rollbacking the connection on release: " + e);
- } finally {
- try {
- getConnection().close();
- } catch (SQLException ignored) {
- LOG.fine("Exception while closing connection on release: " + ignored);
- }
- }
- }
-
- lockConnection = null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.felix.karaf.main.Lock#isAlive()
- */
- public boolean isAlive() throws Exception {
- if (!isConnected()) {
- LOG.severe("Lost lock!");
- return false;
- }
-
- return updateLock();
- }
-
- boolean isConnected() throws SQLException {
- return lockConnection != null && !lockConnection.isClosed();
- }
-
- void closeSafely(Statement preparedStatement) {
- if (preparedStatement != null) {
- try {
- preparedStatement.close();
- } catch (SQLException e) {
- LOG.severe("Failed to close statement: " + e);
- }
- }
- }
-
- void closeSafely(ResultSet rs) {
- if (rs != null) {
- try {
- rs.close();
- } catch (SQLException e) {
- LOG.severe("Error occured while releasing ResultSet: " + e);
- }
- }
- }
-
- Connection getConnection() throws Exception {
- if (!isConnected()) {
- lockConnection = createConnection(driver, url, user, password);
- lockConnection.setAutoCommit(false);
- }
-
- return lockConnection;
- }
-
- /**
- * Create a new jdbc connection.
- *
- * @param driver
- * @param url
- * @param username
- * @param password
- * @return a new jdbc connection
- * @throws Exception
- */
- Connection createConnection(String driver, String url, String username, String password) throws Exception {
- if (url.toLowerCase().startsWith("jdbc:derby")) {
- url = (url.toLowerCase().contains("create=true")) ? url : url + ";create=true";
- }
-
- try {
- return doCreateConnection(driver, url, username, password);
- } catch (Exception e) {
- LOG.severe("Error occured while setting up JDBC connection: " + e);
- throw e;
- }
- }
-
- /**
- * This method could be used to inject a mock jdbc connection for testing purposes.
- *
- * @param driver
- * @param url
- * @param username
- * @param password
- * @return
- * @throws ClassNotFoundException
- * @throws SQLException
- */
- Connection doCreateConnection(String driver, String url, String username, String password) throws ClassNotFoundException, SQLException {
- Class.forName(driver);
- // results in a closed connection in Derby if the update lock table request timed out
- // DriverManager.setLoginTimeout(timeout);
- return DriverManager.getConnection(url, username, password);
- }
-
- long getCurrentTimeMillis() {
- return System.currentTimeMillis();
- }
-}
\ No newline at end of file
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/DerbyJDBCLock.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/DerbyJDBCLock.java
deleted file mode 100644
index 9d8f662..0000000
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/DerbyJDBCLock.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import java.sql.Connection;
-import java.util.Properties;
-
-/**
- * Represents an exclusive lock on a database,
- * used to avoid multiple Karaf instances attempting
- * to become master.
- *
- * @version $Revision: $
- */
-public class DerbyJDBCLock extends DefaultJDBCLock {
-
- public DerbyJDBCLock(Properties props) {
- super(props);
- }
-
- @Override
- Connection createConnection(String driver, String url, String username, String password) throws Exception {
- url = (url.toLowerCase().contains("create=true")) ? url : url + ";create=true";
-
- return super.createConnection(driver, url, username, password);
- }
-}
\ No newline at end of file
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/Lock.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/Lock.java
deleted file mode 100644
index 7750fe7..0000000
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/Lock.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-public interface Lock {
-
- /**
- * A KeepAlive function to maintain the lock.
- * Indicates whether or not the lock could be aquired.
- *
- * @return true if connection lock retained, false otherwise.
- * @throws Exception
- */
- boolean lock() throws Exception;
-
- /**
- * Terminate the lock connection safely.
- *
- * @throws Exception
- */
- void release() throws Exception;
-
- /**
- * Indicates whether or not the lock still exists.
- *
- * @return true, if the lock still exists, otherwise false.
- * @throws Exception
- */
- boolean isAlive() throws Exception;
-}
\ No newline at end of file
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/Main.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/Main.java
deleted file mode 100644
index f6df843..0000000
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/Main.java
+++ /dev/null
@@ -1,1231 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import java.io.*;
-import java.lang.management.ManagementFactory;
-import java.lang.management.RuntimeMXBean;
-import java.net.InetAddress;
-import java.net.MalformedURLException;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.security.AccessControlException;
-import java.security.Provider;
-import java.security.Security;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.lang.reflect.Method;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.felix.karaf.main.Utils;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.launch.Framework;
-import org.osgi.framework.launch.FrameworkFactory;
-import org.osgi.service.startlevel.StartLevel;
-
-/**
- * <p>
- * This class is the default way to instantiate and execute the framework. It is not
- * intended to be the only way to instantiate and execute the framework; rather, it is
- * one example of how to do so. When embedding the framework in a host application,
- * this class can serve as a simple guide of how to do so. It may even be
- * worthwhile to reuse some of its property handling capabilities. This class
- * is completely static and is only intended to start a single instance of
- * the framework.
- * </p>
- */
-public class Main {
- /**
- * The default name used for the system properties file.
- */
- public static final String SYSTEM_PROPERTIES_FILE_NAME = "system.properties";
- /**
- * The default name used for the configuration properties file.
- */
- public static final String CONFIG_PROPERTIES_FILE_NAME = "config.properties";
- /**
- * The default name used for the startup properties file.
- */
- public static final String STARTUP_PROPERTIES_FILE_NAME = "startup.properties";
- /**
- * The property name prefix for the launcher's auto-install property.
- */
- public static final String PROPERTY_AUTO_INSTALL = "karaf.auto.install";
- /**
- * The property for auto-discovering the bundles
- */
- public static final String PROPERTY_AUTO_START = "karaf.auto.start";
- /**
- * The system property for specifying the Karaf home directory. The home directory
- * hold the binary install of Karaf.
- */
- public static final String PROP_KARAF_HOME = "karaf.home";
- /**
- * The environment variable for specifying the Karaf home directory. The home directory
- * hold the binary install of Karaf.
- */
- public static final String ENV_KARAF_HOME = "KARAF_HOME";
- /**
- * The system property for specifying the Karaf base directory. The base directory
- * holds the configuration and data for a Karaf instance.
- */
- public static final String PROP_KARAF_BASE = "karaf.base";
- /**
- * The environment variable for specifying the Karaf base directory. The base directory
- * holds the configuration and data for a Karaf instance.
- */
- public static final String ENV_KARAF_BASE = "KARAF_BASE";
-
- /**
- * Config property which identifies directories which contain bundles to be loaded by SMX
- */
- public static final String BUNDLE_LOCATIONS = "bundle.locations";
-
- /**
- * Config property that indicates we want to convert bundles locations to maven style urls
- */
- public static final String PROPERTY_CONVERT_TO_MAVEN_URL = "karaf.maven.convert";
-
- /**
- * If a lock should be used before starting the runtime
- */
- public static final String PROPERTY_USE_LOCK = "karaf.lock";
-
- /**
- * The lock implementation
- */
- public static final String PROPERTY_LOCK_CLASS = "karaf.lock.class";
-
- public static final String PROPERTY_LOCK_DELAY = "karaf.lock.delay";
-
- public static final String PROPERTY_LOCK_LEVEL = "karaf.lock.level";
-
- public static final String DEFAULT_REPO = "karaf.default.repository";
-
- public static final String KARAF_FRAMEWORK = "karaf.framework";
-
- public static final String KARAF_SHUTDOWN_PORT = "karaf.shutdown.port";
-
- public static final String KARAF_SHUTDOWN_HOST = "karaf.shutdown.host";
-
- public static final String KARAF_SHUTDOWN_PORT_FILE = "karaf.shutdown.port.file";
-
- public static final String KARAF_SHUTDOWN_COMMAND = "karaf.shutdown.command";
-
- public static final String KARAF_SHUTDOWN_PID_FILE = "karaf.shutdown.pid.file";
-
- public static final String DEFAULT_SHUTDOWN_COMMAND = "SHUTDOWN";
-
- public static final String PROPERTY_LOCK_CLASS_DEFAULT = SimpleFileLock.class.getName();
-
- Logger LOG = Logger.getLogger(this.getClass().getName());
-
- private File karafHome;
- private File karafBase;
- private Properties configProps = null;
- private Framework framework = null;
- private final String[] args;
- private int exitCode;
- private Lock lock;
- private int defaultStartLevel = 100;
- private int lockStartLevel = 1;
- private int lockDelay = 1000;
- private boolean exiting = false;
- private boolean cmProcessed;
-
- public Main(String[] args) {
- this.args = args;
- }
-
- public void launch() throws Exception {
- karafHome = Utils.getKarafHome();
- karafBase = Utils.getKarafBase(karafHome);
-
- //System.out.println("Karaf Home: "+main.karafHome.getPath());
- //System.out.println("Karaf Base: "+main.karafBase.getPath());
-
- System.setProperty(PROP_KARAF_HOME, karafHome.getPath());
- System.setProperty(PROP_KARAF_BASE, karafBase.getPath());
-
- // Load system properties.
- loadSystemProperties(karafBase);
-
- updateInstancePid();
-
- // Read configuration properties.
- configProps = loadConfigProperties();
- BootstrapLogManager.setProperties(configProps);
- LOG.addHandler(BootstrapLogManager.getDefaultHandler());
-
- // Copy framework properties from the system properties.
- Main.copySystemProperties(configProps);
-
- updateClassLoader(configProps);
-
- processSecurityProperties(configProps);
-
- if (configProps.getProperty(Constants.FRAMEWORK_STORAGE) == null) {
- File storage = new File(karafBase.getPath(), "data/cache");
- try {
- storage.mkdirs();
- } catch (SecurityException se) {
- throw new Exception(se.getMessage());
- }
- configProps.setProperty(Constants.FRAMEWORK_STORAGE, storage.getAbsolutePath());
- }
-
- defaultStartLevel = Integer.parseInt(configProps.getProperty(Constants.FRAMEWORK_BEGINNING_STARTLEVEL));
- lockStartLevel = Integer.parseInt(configProps.getProperty(PROPERTY_LOCK_LEVEL, Integer.toString(lockStartLevel)));
- lockDelay = Integer.parseInt(configProps.getProperty(PROPERTY_LOCK_DELAY, Integer.toString(lockDelay)));
- configProps.setProperty(Constants.FRAMEWORK_BEGINNING_STARTLEVEL, Integer.toString(lockStartLevel));
- // Start up the OSGI framework
-
- InputStream is = getClass().getResourceAsStream("/META-INF/services/" + FrameworkFactory.class.getName());
- BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
- String factoryClass = br.readLine();
- br.close();
- FrameworkFactory factory = (FrameworkFactory) getClass().getClassLoader().loadClass(factoryClass).newInstance();
- framework = factory.newFramework(new StringMap(configProps, false));
- framework.start();
- processAutoProperties(framework.getBundleContext());
- // Start lock monitor
- new Thread() {
- public void run() {
- lock(configProps);
- }
- }.start();
- }
-
- public void destroy(boolean await) throws Exception {
- if (framework == null) {
- return;
- }
- try {
- if (await) {
- while (true) {
- FrameworkEvent event = framework.waitForStop(0);
- if (event.getType() != FrameworkEvent.STOPPED_UPDATE) {
- break;
- }
- }
- }
- exiting = true;
- if (framework.getState() == Bundle.ACTIVE) {
- framework.stop();
- }
- } finally {
- unlock();
- }
- }
-
- /**
- * <p>
- * This method performs the main task of constructing an framework instance
- * and starting its execution. The following functions are performed
- * when invoked:
- * </p>
- * <ol>
- * <li><i><b>Read the system properties file.<b></i> This is a file
- * containing properties to be pushed into <tt>System.setProperty()</tt>
- * before starting the framework. This mechanism is mainly shorthand
- * for people starting the framework from the command line to avoid having
- * to specify a bunch of <tt>-D</tt> system property definitions.
- * The only properties defined in this file that will impact the framework's
- * behavior are the those concerning setting HTTP proxies, such as
- * <tt>http.proxyHost</tt>, <tt>http.proxyPort</tt>, and
- * <tt>http.proxyAuth</tt>.
- * </li>
- * <li><i><b>Perform system property variable substitution on system
- * properties.</b></i> Any system properties in the system property
- * file whose value adheres to <tt>${<system-prop-name>}</tt>
- * syntax will have their value substituted with the appropriate
- * system property value.
- * </li>
- * <li><i><b>Read the framework's configuration property file.</b></i> This is
- * a file containing properties used to configure the framework
- * instance and to pass configuration information into
- * bundles installed into the framework instance. The configuration
- * property file is called <tt>config.properties</tt> by default
- * and is located in the <tt>conf/</tt> directory of the Felix
- * installation directory, which is the parent directory of the
- * directory containing the <tt>felix.jar</tt> file. It is possible
- * to use a different location for the property file by specifying
- * the desired URL using the <tt>felix.config.properties</tt>
- * system property; this should be set using the <tt>-D</tt> syntax
- * when executing the JVM. Refer to the
- * <a href="Felix.html#Felix(java.util.Map, java.util.List)">
- * <tt>Felix</tt></a> constructor documentation for more
- * information on the framework configuration options.
- * </li>
- * <li><i><b>Perform system property variable substitution on configuration
- * properties.</b></i> Any configuration properties whose value adheres to
- * <tt>${<system-prop-name>}</tt> syntax will have their value
- * substituted with the appropriate system property value.
- * </li>
- * <li><i><b>Ensure the default bundle cache has sufficient information to
- * initialize.</b></i> The default implementation of the bundle cache
- * requires either a profile name or a profile directory in order to
- * start. The configuration properties are checked for at least one
- * of the <tt>felix.cache.profile</tt> or <tt>felix.cache.profiledir</tt>
- * properties. If neither is found, the user is asked to supply a profile
- * name that is added to the configuration property set. See the
- * <a href="cache/DefaultBundleCache.html"><tt>DefaultBundleCache</tt></a>
- * documentation for more details its configuration options.
- * </li>
- * <li><i><b>Creates and starts a framework instance.</b></i> A
- * case insensitive
- * <a href="util/StringMap.html"><tt>StringMap</tt></a>
- * is created for the configuration property file and is passed
- * into the framework.
- * </li>
- * </ol>
- * <p>
- * It should be noted that simply starting an instance of the framework is not enough
- * to create an interactive session with it. It is necessary to install
- * and start bundles that provide an interactive impl; this is generally
- * done by specifying an "auto-start" property in the framework configuration
- * property file. If no interactive impl bundles are installed or if
- * the configuration property file cannot be found, the framework will appear to
- * be hung or deadlocked. This is not the case, it is executing correctly,
- * there is just no way to interact with it. Refer to the
- * <a href="Felix.html#Felix(java.util.Map, java.util.List)">
- * <tt>Felix</tt></a> constructor documentation for more information on
- * framework configuration options.
- * </p>
- * @param args An array of arguments, all of which are ignored.
- * @throws Exception If an error occurs.
- **/
- public static void main(String[] args) throws Exception {
- final Main main = new Main(args);
- try {
- main.launch();
- } catch (Throwable ex) {
- main.setExitCode(-1);
- System.err.println("Could not create framework: " + ex);
- ex.printStackTrace();
- }
- try {
- main.destroy(true);
- } catch (Throwable ex) {
- main.setExitCode(-2);
- System.err.println("Error occured shutting down framework: " + ex);
- ex.printStackTrace();
- } finally {
- System.exit(main.getExitCode());
- }
- }
-
- private static void processSecurityProperties(Properties m_configProps) {
- String prop = m_configProps.getProperty("org.apache.felix.karaf.security.providers");
- if (prop != null) {
- String[] providers = prop.split(",");
- for (String provider : providers) {
- try {
- Security.addProvider((Provider) Class.forName(provider).newInstance());
- } catch (Throwable t) {
- System.err.println("Unable to register security provider: " + t);
- }
- }
- }
- }
-
- private void updateInstancePid() {
- try {
- String instanceName = System.getProperty("karaf.name");
- String pid = ManagementFactory.getRuntimeMXBean().getName();
- if (pid.indexOf('@') > 0) {
- pid = pid.substring(0, pid.indexOf('@'));
- }
-
- boolean isRoot = karafHome.equals(karafBase);
-
- if (instanceName != null) {
- String storage = System.getProperty("storage.location");
- if (storage == null) {
- throw new Exception("System property 'storage.location' is not set. \n" +
- "This property needs to be set to the full path of the instance.properties file.");
- }
- File storageFile = new File(storage);
- File propertiesFile = new File(storageFile, "instance.properties");
- Properties props = new Properties();
- if (propertiesFile.exists()) {
- FileInputStream fis = new FileInputStream(propertiesFile);
- props.load(fis);
- int count = Integer.parseInt(props.getProperty("count"));
- for (int i = 0; i < count; i++) {
- String name = props.getProperty("item." + i + ".name");
- if (name.equals(instanceName)) {
- props.setProperty("item." + i + ".pid", pid);
- FileOutputStream fos = new FileOutputStream(propertiesFile);
- props.store(fos, null);
- fis.close();
- fos.close();
- return;
- }
- }
- fis.close();
- if (!isRoot) {
- throw new Exception("Instance " + instanceName + " not found");
- }
- } else if (isRoot) {
- if (!propertiesFile.getParentFile().exists()) {
- try {
- propertiesFile.getParentFile().mkdirs();
- } catch (SecurityException se) {
- throw new Exception(se.getMessage());
- }
- }
- props.setProperty("count", "1");
- props.setProperty("item.0.name", instanceName);
- props.setProperty("item.0.loc", karafHome.getAbsolutePath());
- props.setProperty("item.0.pid", pid);
- props.setProperty("item.0.root", "true");
- FileOutputStream fos = new FileOutputStream(propertiesFile);
- props.store(fos, null);
- fos.close();
- }
- }
- } catch (Exception e) {
- System.err.println("Unable to update instance pid: " + e.getMessage());
- }
- }
-
- /**
- * <p/>
- * Processes the auto-install and auto-start properties from the
- * specified configuration properties.
- */
- private void processAutoProperties(BundleContext context) {
- // Check if we want to convert URLs to maven style
- boolean convertToMavenUrls = Boolean.parseBoolean(configProps.getProperty(PROPERTY_CONVERT_TO_MAVEN_URL, "true"));
-
- // Retrieve the Start Level service, since it will be needed
- // to set the start level of the installed bundles.
- StartLevel sl = (StartLevel) context.getService(
- context.getServiceReference(org.osgi.service.startlevel.StartLevel.class.getName()));
-
- // Set the default bundle start level
- int ibsl = 60;
- try {
- String str = configProps.getProperty("karaf.startlevel.bundle");
- if (str != null) {
- ibsl = Integer.parseInt(str);
- }
- } catch (Throwable t) {
- }
- sl.setInitialBundleStartLevel(ibsl);
-
- // The auto-install property specifies a space-delimited list of
- // bundle URLs to be automatically installed into each new profile;
- // the start level to which the bundles are assigned is specified by
- // appending a ".n" to the auto-install property name, where "n" is
- // the desired start level for the list of bundles.
- autoInstall(PROPERTY_AUTO_INSTALL, context, sl, convertToMavenUrls);
-
- // The auto-start property specifies a space-delimited list of
- // bundle URLs to be automatically installed and started into each
- // new profile; the start level to which the bundles are assigned
- // is specified by appending a ".n" to the auto-start property name,
- // where "n" is the desired start level for the list of bundles.
- // The following code starts bundles in two passes, first it installs
- // them, then it starts them.
- List<Bundle> bundlesToStart = autoInstall(PROPERTY_AUTO_START, context, sl, convertToMavenUrls);
- // Now loop through and start the installed bundles.
- for (Bundle b : bundlesToStart) {
- try {
- b.start();
- }
- catch (Exception ex) {
- System.err.println("Auto-properties start: " + ex);
- }
- }
- }
-
- private List<Bundle> autoInstall(String propertyPrefix, BundleContext context, StartLevel sl, boolean convertToMavenUrls) {
- Map<Integer, String> autoStart = new TreeMap<Integer, String>();
- List<Bundle> bundles = new ArrayList<Bundle>();
- for (Iterator i = configProps.keySet().iterator(); i.hasNext();) {
- String key = (String) i.next();
- // Ignore all keys that are not the auto-start property.
- if (!key.startsWith(propertyPrefix)) {
- continue;
- }
- // If the auto-start property does not have a start level,
- // then assume it is the default bundle start level, otherwise
- // parse the specified start level.
- int startLevel = sl.getInitialBundleStartLevel();
- if (!key.equals(propertyPrefix)) {
- try {
- startLevel = Integer.parseInt(key.substring(key.lastIndexOf('.') + 1));
- }
- catch (NumberFormatException ex) {
- System.err.println("Invalid property: " + key);
- }
- }
- autoStart.put(startLevel, configProps.getProperty(key));
- }
- for (Integer startLevel : autoStart.keySet()) {
- StringTokenizer st = new StringTokenizer(autoStart.get(startLevel), "\" ", true);
- if (st.countTokens() > 0) {
- String location = null;
- do {
- location = nextLocation(st);
- if (location != null) {
- try {
- String[] parts = convertToMavenUrlsIfNeeded(location, convertToMavenUrls);
- Bundle b = context.installBundle(parts[0], new URL(parts[1]).openStream());
- sl.setBundleStartLevel(b, startLevel);
- bundles.add(b);
- }
- catch (Exception ex) {
- System.err.println("Auto-properties install:" + ex);
- }
- }
- }
- while (location != null);
- }
- }
- return bundles;
- }
-
- private static String[] convertToMavenUrlsIfNeeded(String location, boolean convertToMavenUrls) {
- String[] parts = location.split("\\|");
- if (convertToMavenUrls) {
- String[] p = parts[1].split("/");
- if (p.length >= 4 && p[p.length-1].startsWith(p[p.length-3] + "-" + p[p.length-2])) {
- String groupId = null;
- String artifactId = p[p.length-3];
- String version = p[p.length-2];
- String classifier;
- String type;
- String artifactIdVersion = artifactId + "-" + version;
- StringBuffer sb = new StringBuffer();
- if (p[p.length-1].charAt(artifactIdVersion.length()) == '-') {
- classifier = p[p.length-1].substring(artifactIdVersion.length() + 1, p[p.length-1].lastIndexOf('.'));
- } else {
- classifier = null;
- }
- type = p[p.length-1].substring(p[p.length-1].lastIndexOf('.') + 1);
- sb.append("mvn:");
- for (int j = 0; j < p.length - 3; j++) {
- if (j > 0) {
- sb.append('.');
- }
- sb.append(p[j]);
- }
- sb.append('/').append(artifactId).append('/').append(version);
- if (!"jar".equals(type) || classifier != null) {
- sb.append('/');
- if (!"jar".equals(type)) {
- sb.append(type);
- }
- if (classifier != null) {
- sb.append('/').append(classifier);
- }
- }
- parts[1] = parts[0];
- parts[0] = sb.toString();
- } else {
- parts[1] = parts[0];
- }
- } else {
- parts[1] = parts[0];
- }
- return parts;
- }
-
- private static String nextLocation(StringTokenizer st) {
- String retVal = null;
-
- if (st.countTokens() > 0) {
- String tokenList = "\" ";
- StringBuffer tokBuf = new StringBuffer(10);
- String tok = null;
- boolean inQuote = false;
- boolean tokStarted = false;
- boolean exit = false;
- while ((st.hasMoreTokens()) && (!exit)) {
- tok = st.nextToken(tokenList);
- if (tok.equals("\"")) {
- inQuote = !inQuote;
- if (inQuote) {
- tokenList = "\"";
- } else {
- tokenList = "\" ";
- }
-
- } else if (tok.equals(" ")) {
- if (tokStarted) {
- retVal = tokBuf.toString();
- tokStarted = false;
- tokBuf = new StringBuffer(10);
- exit = true;
- }
- } else {
- tokStarted = true;
- tokBuf.append(tok.trim());
- }
- }
-
- // Handle case where end of token stream and
- // still got data
- if ((!exit) && (tokStarted)) {
- retVal = tokBuf.toString();
- }
- }
-
- return retVal;
- }
-
- /**
- * <p>
- * Loads the properties in the system property file associated with the
- * framework installation into <tt>System.setProperty()</tt>. These properties
- * are not directly used by the framework in anyway. By default, the system
- * property file is located in the <tt>conf/</tt> directory of the Felix
- * installation directory and is called "<tt>system.properties</tt>". The
- * installation directory of Felix is assumed to be the parent directory of
- * the <tt>felix.jar</tt> file as found on the system class path property.
- * The precise file from which to load system properties can be set by
- * initializing the "<tt>felix.system.properties</tt>" system property to an
- * arbitrary URL.
- * </p>
- */
- protected static void loadSystemProperties(File karafBase) {
- // The system properties file is either specified by a system
- // property or it is in the same directory as the Felix JAR file.
- // Try to load it from one of these places.
-
- // See if the property URL was specified as a property.
- URL propURL = null;
- try {
- File file = new File(new File(karafBase, "etc"), SYSTEM_PROPERTIES_FILE_NAME);
- propURL = file.toURL();
- }
- catch (MalformedURLException ex) {
- System.err.print("Main: " + ex);
- return;
- }
-
- // Read the properties file.
- Properties props = new Properties();
- InputStream is = null;
- try {
- is = propURL.openConnection().getInputStream();
- props.load(is);
- is.close();
- }
- catch (FileNotFoundException ex) {
- // Ignore file not found.
- }
- catch (Exception ex) {
- System.err.println(
- "Main: Error loading system properties from " + propURL);
- System.err.println("Main: " + ex);
- try {
- if (is != null) is.close();
- }
- catch (IOException ex2) {
- // Nothing we can do.
- }
- return;
- }
-
- // Perform variable substitution on specified properties.
- for (Enumeration e = props.propertyNames(); e.hasMoreElements();) {
- String name = (String) e.nextElement();
- String value = System.getProperty(name, props.getProperty(name));
- System.setProperty(name, substVars(value, name, null, null));
- }
- }
-
- /**
- * <p>
- * Loads the configuration properties in the configuration property file
- * associated with the framework installation; these properties
- * are accessible to the framework and to bundles and are intended
- * for configuration purposes. By default, the configuration property
- * file is located in the <tt>conf/</tt> directory of the Felix
- * installation directory and is called "<tt>config.properties</tt>".
- * The installation directory of Felix is assumed to be the parent
- * directory of the <tt>felix.jar</tt> file as found on the system class
- * path property. The precise file from which to load configuration
- * properties can be set by initializing the "<tt>felix.config.properties</tt>"
- * system property to an arbitrary URL.
- * </p>
- *
- * @return A <tt>Properties</tt> instance or <tt>null</tt> if there was an error.
- * @throws Exception
- */
- private Properties loadConfigProperties() throws Exception {
- // The config properties file is either specified by a system
- // property or it is in the conf/ directory of the Felix
- // installation directory. Try to load it from one of these
- // places.
-
- ArrayList<File> bundleDirs = new ArrayList<File>();
-
- // See if the property URL was specified as a property.
- URL configPropURL = null;
- URL startupPropURL = null;
-
- try {
- File file = new File(new File(karafBase, "etc"), CONFIG_PROPERTIES_FILE_NAME);
- configPropURL = file.toURI().toURL();
-
- file = new File(new File(karafBase, "etc"), STARTUP_PROPERTIES_FILE_NAME);
- startupPropURL = file.toURI().toURL();
-
- }
- catch (MalformedURLException ex) {
- System.err.print("Main: " + ex);
- return null;
- }
-
-
- Properties configProps = loadPropertiesFile(configPropURL);
- Properties startupProps = loadPropertiesFile(startupPropURL);
-
- String defaultRepo = System.getProperty(DEFAULT_REPO, "system");
-
- if (karafBase.equals(karafHome)) {
- bundleDirs.add(new File(karafHome, defaultRepo));
- } else {
- bundleDirs.add(new File(karafBase, defaultRepo));
- bundleDirs.add(new File(karafHome, defaultRepo));
- }
-
- String locations = configProps.getProperty(BUNDLE_LOCATIONS);
-
- if (locations != null) {
- StringTokenizer st = new StringTokenizer(locations, "\" ", true);
- if (st.countTokens() > 0) {
- String location = null;
- do {
- location = nextLocation(st);
- if (location != null) {
- File f = new File(location);
- if (f.exists() && f.isDirectory()) {
- bundleDirs.add(f);
- } else {
- System.err.println("Bundle location " + location
- + " does not exist or is not a directory.");
- }
- }
- }
-
- while (location != null);
- }
- }
-
- // Perform variable substitution for system properties.
- for (Enumeration e = configProps.propertyNames(); e.hasMoreElements();) {
- String name = (String) e.nextElement();
- configProps.setProperty(name,
- substVars(configProps.getProperty(name), name, null, configProps));
- }
-
- // Mutate properties
- Main.processConfigurationProperties(configProps, startupProps, bundleDirs);
-
- return configProps;
- }
-
- protected static Properties loadPropertiesFile(URL configPropURL) throws Exception {
- // Read the properties file.
- Properties configProps = new Properties();
- InputStream is = null;
- try {
- is = configPropURL.openConnection().getInputStream();
- configProps.load(is);
- is.close();
- }
- catch (FileNotFoundException ex) {
- if (configPropURL.getFile().lastIndexOf(STARTUP_PROPERTIES_FILE_NAME) != -1) {
- throw ex;
- }
- }
- catch (Exception ex) {
- System.err.println(
- "Error loading config properties from " + configPropURL);
- System.err.println("Main: " + ex);
- try {
- if (is != null) is.close();
- }
- catch (IOException ex2) {
- // Nothing we can do.
- }
- return null;
- }
- return configProps;
- }
-
- protected static void copySystemProperties(Properties configProps) {
- for (Enumeration e = System.getProperties().propertyNames();
- e.hasMoreElements();) {
- String key = (String) e.nextElement();
- if (key.startsWith("felix.") ||
- key.startsWith("karaf.") ||
- key.startsWith("org.osgi.framework.")) {
- configProps.setProperty(key, System.getProperty(key));
- }
- }
- }
-
- private void updateClassLoader(Properties configProps) throws Exception {
- String framework = configProps.getProperty(KARAF_FRAMEWORK);
- if (framework == null) {
- throw new IllegalArgumentException("Property " + KARAF_FRAMEWORK + " must be set in the etc/" + CONFIG_PROPERTIES_FILE_NAME + " configuration file");
- }
- String bundle = configProps.getProperty(KARAF_FRAMEWORK + "." + framework);
- if (bundle == null) {
- throw new IllegalArgumentException("Property " + KARAF_FRAMEWORK + "." + framework + " must be set in the etc/" + CONFIG_PROPERTIES_FILE_NAME + " configuration file");
- }
- File bundleFile = new File(karafBase, bundle);
- if (!bundleFile.exists()) {
- bundleFile = new File(karafHome, bundle);
- }
- if (!bundleFile.exists()) {
- throw new FileNotFoundException(bundleFile.getAbsolutePath());
- }
-
- URLClassLoader classLoader = (URLClassLoader) Main.class.getClassLoader();
- Method mth = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
- mth.setAccessible(true);
- mth.invoke(classLoader, bundleFile.toURL());
-
- }
-
- /**
- * Process properties to customize default felix behavior
- *
- * @param startupProps
- */
- private static void processConfigurationProperties(Properties props, Properties startupProps, ArrayList<File> bundleDirs) {
- if (bundleDirs == null) {
- return;
- }
- if ("all".equals(props.getProperty(PROPERTY_AUTO_START, "").trim())) {
- props.remove(PROPERTY_AUTO_START);
- ArrayList<File> jars = new ArrayList<File>();
-
- // We should start all the bundles in the system dir.
- for (File bundleDir : bundleDirs) {
- findJars(bundleDir, jars);
- }
-
- StringBuffer sb = new StringBuffer();
-
- for (File jar : jars) {
- try {
- sb.append("\"").append(jar.toURL().toString()).append("\" ");
- } catch (MalformedURLException e) {
- System.err.print("Ignoring " + jar.toString() + " (" + e + ")");
- }
- }
-
- props.setProperty(PROPERTY_AUTO_START, sb.toString());
-
- } else if (STARTUP_PROPERTIES_FILE_NAME.equals(props.getProperty(PROPERTY_AUTO_START, "").trim())) {
- props.remove(PROPERTY_AUTO_START);
- // We should start the bundles in the startup.properties file.
- HashMap<Integer, StringBuffer> levels = new HashMap<Integer, StringBuffer>();
- for (Iterator iterator = startupProps.keySet().iterator(); iterator.hasNext();) {
- String name = (String) iterator.next();
- File file = findFile(bundleDirs, name);
-
- if (file != null) {
- Integer level;
- try {
- level = new Integer(startupProps.getProperty(name).trim());
- } catch (NumberFormatException e1) {
- System.err.print("Ignoring " + file.toString() + " (run level must be an integer)");
- continue;
- }
- StringBuffer sb = levels.get(level);
- if (sb == null) {
- sb = new StringBuffer(256);
- levels.put(level, sb);
- }
- try {
- sb.append("\"").append(file.toURL().toString()).append("|").append(name).append("\" ");
- } catch (MalformedURLException e) {
- System.err.print("Ignoring " + file.toString() + " (" + e + ")");
- }
- } else {
- System.err.println("Bundle listed in " + STARTUP_PROPERTIES_FILE_NAME + " configuration not found: " + name);
- }
- }
-
- for (Map.Entry<Integer, StringBuffer> entry : levels.entrySet()) {
- props.setProperty(PROPERTY_AUTO_START + "." + entry.getKey(), entry.getValue().toString());
- }
- }
-
- }
-
- private static File findFile(ArrayList<File> bundleDirs, String name) {
- for (File bundleDir : bundleDirs) {
- File file = findFile(bundleDir, name);
- if (file != null) {
- return file;
- }
- }
- return null;
- }
-
- private static File findFile(File dir, String name) {
- File theFile = new File(dir, name);
-
- if (theFile.exists() && !theFile.isDirectory()) {
- return theFile;
- }
-
- for (File file : dir.listFiles()) {
- if (file.isDirectory()) {
- return findFile(file, name);
- }
- }
-
- return null;
- }
-
- private static void findJars(File dir, ArrayList<File> jars) {
- for (File file : dir.listFiles()) {
- if (file.isDirectory()) {
- findJars(file, jars);
- } else {
- if (file.toString().endsWith(".jar")) {
- jars.add(file);
- }
- }
- }
- }
-
- private static final String DELIM_START = "${";
- private static final String DELIM_STOP = "}";
-
- /**
- * <p>
- * This method performs property variable substitution on the
- * specified value. If the specified value contains the syntax
- * <tt>${<prop-name>}</tt>, where <tt><prop-name></tt>
- * refers to either a configuration property or a system property,
- * then the corresponding property value is substituted for the variable
- * placeholder. Multiple variable placeholders may exist in the
- * specified value as well as nested variable placeholders, which
- * are substituted from inner most to outer most. Configuration
- * properties override system properties.
- * </p>
- *
- * @param val The string on which to perform property substitution.
- * @param currentKey The key of the property being evaluated used to
- * detect cycles.
- * @param cycleMap Map of variable references used to detect nested cycles.
- * @param configProps Set of configuration properties.
- * @return The value of the specified string after system property substitution.
- * @throws IllegalArgumentException If there was a syntax error in the
- * property placeholder syntax or a recursive variable reference.
- */
- public static String substVars(String val, String currentKey,
- Map<String, String> cycleMap, Properties configProps)
- throws IllegalArgumentException {
- // If there is currently no cycle map, then create
- // one for detecting cycles for this invocation.
- if (cycleMap == null) {
- cycleMap = new HashMap<String, String>();
- }
-
- // Put the current key in the cycle map.
- cycleMap.put(currentKey, currentKey);
-
- // Assume we have a value that is something like:
- // "leading ${foo.${bar}} middle ${baz} trailing"
-
- // Find the first ending '}' variable delimiter, which
- // will correspond to the first deepest nested variable
- // placeholder.
- int stopDelim = val.indexOf(DELIM_STOP);
-
- // Find the matching starting "${" variable delimiter
- // by looping until we find a start delimiter that is
- // greater than the stop delimiter we have found.
- int startDelim = val.indexOf(DELIM_START);
- while (stopDelim >= 0) {
- int idx = val.indexOf(DELIM_START, startDelim + DELIM_START.length());
- if ((idx < 0) || (idx > stopDelim)) {
- break;
- } else if (idx < stopDelim) {
- startDelim = idx;
- }
- }
-
- // If we do not have a start or stop delimiter, then just
- // return the existing value.
- if ((startDelim < 0) && (stopDelim < 0)) {
- return val;
- }
- // At this point, we found a stop delimiter without a start,
- // so throw an exception.
- else if (((startDelim < 0) || (startDelim > stopDelim))
- && (stopDelim >= 0)) {
- throw new IllegalArgumentException(
- "stop delimiter with no start delimiter: "
- + val);
- }
-
- // At this point, we have found a variable placeholder so
- // we must perform a variable substitution on it.
- // Using the start and stop delimiter indices, extract
- // the first, deepest nested variable placeholder.
- String variable =
- val.substring(startDelim + DELIM_START.length(), stopDelim);
-
- // Verify that this is not a recursive variable reference.
- if (cycleMap.get(variable) != null) {
- throw new IllegalArgumentException(
- "recursive variable reference: " + variable);
- }
-
- // Get the value of the deepest nested variable placeholder.
- // Try to configuration properties first.
- String substValue = (configProps != null)
- ? configProps.getProperty(variable, null)
- : null;
- if (substValue == null) {
- // Ignore unknown property values.
- substValue = System.getProperty(variable, "");
- }
-
- // Remove the found variable from the cycle map, since
- // it may appear more than once in the value and we don't
- // want such situations to appear as a recursive reference.
- cycleMap.remove(variable);
-
- // Append the leading characters, the substituted value of
- // the variable, and the trailing characters to get the new
- // value.
- val = val.substring(0, startDelim)
- + substValue
- + val.substring(stopDelim + DELIM_STOP.length(), val.length());
-
- // Now perform substitution again, since there could still
- // be substitutions to make.
- val = substVars(val, currentKey, cycleMap, configProps);
-
- // Return the value.
- return val;
- }
-
- /* (non-Javadoc)
- * @see org.apache.felix.karaf.main.MainService#getArgs()
- */
- public String[] getArgs() {
- return args;
- }
-
- public int getExitCode() {
- return exitCode;
- }
-
- public void setExitCode(int exitCode) {
- this.exitCode = exitCode;
- }
-
- public Framework getFramework() {
- return framework;
- }
-
- public void lock(Properties props) {
- try {
- if (Boolean.parseBoolean(props.getProperty(PROPERTY_USE_LOCK, "true"))) {
- String clz = props.getProperty(PROPERTY_LOCK_CLASS, PROPERTY_LOCK_CLASS_DEFAULT);
- lock = (Lock) Class.forName(clz).getConstructor(Properties.class).newInstance(props);
- boolean lockLogged = false;
- setStartLevel(lockStartLevel);
- for (;;) {
- if (lock.lock()) {
- if (lockLogged) {
- LOG.info("Lock acquired.");
- }
- setupShutdown(props);
- setStartLevel(defaultStartLevel);
- for (;;) {
- if (!lock.isAlive()) {
- break;
- }
- Thread.sleep(lockDelay);
- }
- if (framework.getState() == Bundle.ACTIVE && !exiting) {
- LOG.info("Lost the lock, stopping this instance ...");
- setStartLevel(lockStartLevel);
- }
- } else if (!lockLogged) {
- LOG.info("Waiting for the lock ...");
- lockLogged = true;
- }
- Thread.sleep(lockDelay);
- }
- } else {
- setStartLevel(defaultStartLevel);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public void unlock() throws Exception {
- if (lock != null) {
- lock.release();
- }
- }
-
- protected void setStartLevel(int level) throws Exception {
- BundleContext ctx = framework.getBundleContext();
- ServiceReference[] refs = ctx.getServiceReferences(StartLevel.class.getName(), null);
- StartLevel sl = (StartLevel) ctx.getService(refs[0]);
- sl.setStartLevel(level);
- }
-
-
- private Random random = null;
- private ServerSocket shutdownSocket;
-
- protected void setupShutdown(Properties props) {
- try {
- String pidFile = props.getProperty(KARAF_SHUTDOWN_PID_FILE);
- if (pidFile != null) {
- RuntimeMXBean rtb = ManagementFactory.getRuntimeMXBean();
- String processName = rtb.getName();
- Pattern pattern = Pattern.compile("^([0-9]+)@.+$", Pattern.CASE_INSENSITIVE);
- Matcher matcher = pattern.matcher(processName);
- if (matcher.matches()) {
- int pid = Integer.parseInt(matcher.group(1));
- Writer w = new OutputStreamWriter(new FileOutputStream(pidFile));
- w.write(Integer.toString(pid));
- w.close();
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- try {
- int port = Integer.parseInt(props.getProperty(KARAF_SHUTDOWN_PORT, "0"));
- String host = props.getProperty(KARAF_SHUTDOWN_HOST, "localhost");
- String portFile = props.getProperty(KARAF_SHUTDOWN_PORT_FILE);
- final String shutdown = props.getProperty(KARAF_SHUTDOWN_COMMAND, DEFAULT_SHUTDOWN_COMMAND);
- if (port >= 0) {
- shutdownSocket = new ServerSocket(port, 1, InetAddress.getByName(host));
- if (port == 0) {
- port = shutdownSocket.getLocalPort();
- }
- if (portFile != null) {
- Writer w = new OutputStreamWriter(new FileOutputStream(portFile));
- w.write(Integer.toString(port));
- w.close();
- }
- Thread thread = new Thread() {
- public void run() {
- try {
- while (true) {
- // Wait for the next connection
- Socket socket = null;
- InputStream stream = null;
- try {
- socket = shutdownSocket.accept();
- socket.setSoTimeout(10 * 1000); // Ten seconds
- stream = socket.getInputStream();
- } catch (AccessControlException ace) {
- LOG.log(Level.WARNING, "Karaf shutdown socket: security exception: "
- + ace.getMessage(), ace);
- continue;
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Karaf shutdown socket: accept: ", e);
- System.exit(1);
- }
-
- // Read a set of characters from the socket
- StringBuilder command = new StringBuilder();
- int expected = 1024; // Cut off to avoid DoS attack
- while (expected < shutdown.length()) {
- if (random == null) {
- random = new Random();
- }
- expected += (random.nextInt() % 1024);
- }
- while (expected > 0) {
- int ch = -1;
- try {
- ch = stream.read();
- } catch (IOException e) {
- LOG.log(Level.WARNING, "Karaf shutdown socket: read: ", e);
- ch = -1;
- }
- if (ch < 32) { // Control character or EOF terminates loop
- break;
- }
- command.append((char) ch);
- expected--;
- }
-
- // Close the socket now that we are done with it
- try {
- socket.close();
- } catch (IOException e) {
- // Ignore
- }
-
- // Match against our command string
- boolean match = command.toString().equals(shutdown);
- if (match) {
- LOG.log(Level.INFO, "Karaf shutdown socket: received shutdown command. Stopping framework...");
- framework.stop();
- break;
- } else {
- LOG.log(Level.WARNING, "Karaf shutdown socket: Invalid command '" +
- command.toString() + "' received");
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- try {
- shutdownSocket.close();
- } catch (IOException e) {
- }
- }
- }
- };
- thread.setDaemon(true);
- thread.start();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
-}
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/MySQLJDBCLock.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/MySQLJDBCLock.java
deleted file mode 100644
index 86cc83f..0000000
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/MySQLJDBCLock.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import java.sql.Connection;
-import java.util.Properties;
-
-/**
- * Represents an exclusive lock on a database,
- * used to avoid multiple Karaf instances attempting
- * to become master.
- *
- * @version $Revision: $
- */
-public class MySQLJDBCLock extends DefaultJDBCLock {
-
- public MySQLJDBCLock(Properties props) {
- super(props);
- }
-
- Statements createStatements() {
- Statements statements = new Statements();
- statements.setTableName(table);
- statements.setNodeName(clusterName);
- String[] lockCreateSchemaStatements = statements.getLockCreateSchemaStatements(getCurrentTimeMillis());
- for (int index = 0; index < lockCreateSchemaStatements.length; index++) {
- if (lockCreateSchemaStatements[index].toUpperCase().startsWith("CREATE TABLE")) {
- lockCreateSchemaStatements[index] = lockCreateSchemaStatements[index] + " ENGINE=INNODB";
- }
- }
- return statements;
- }
-
- @Override
- Connection createConnection(String driver, String url, String username, String password) throws Exception {
- url = (url.toLowerCase().contains("createDatabaseIfNotExist=true")) ?
- url :
- ((url.contains("?")) ?
- url + "&createDatabaseIfNotExist=true" :
- url + "?createDatabaseIfNotExist=true");
-
- return super.createConnection(driver, url, username, password);
- }
-}
\ No newline at end of file
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/OracleJDBCLock.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/OracleJDBCLock.java
deleted file mode 100644
index bcf72f7..0000000
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/OracleJDBCLock.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import java.util.Properties;
-
-/**
- * Represents an exclusive lock on a database,
- * used to avoid multiple Karaf instances attempting
- * to become master.
- *
- * @version $Revision: $
- */
-public class OracleJDBCLock extends DefaultJDBCLock {
-
- private static final String MOMENT_COLUMN_DATA_TYPE = "NUMBER(20)";
-
- public OracleJDBCLock(Properties props) {
- super(props);
- }
-
- @Override
- Statements createStatements() {
- Statements statements = new Statements();
- statements.setTableName(table);
- statements.setNodeName(clusterName);
- statements.setMomentColumnDataType(MOMENT_COLUMN_DATA_TYPE);
- return statements;
- }
-
- /**
- * When we perform an update on a long lived locked table, Oracle will save
- * a copy of the transaction in it's UNDO table space. Eventually this can
- * cause the UNDO table to become full, disrupting all locks in the DB instance.
- * A select query just touches the table, ensuring we can still read the DB but
- * doesn't add to the UNDO.
- */
- @Override
- public boolean lock() {
- return aquireLock();
- }
-
- /**
- * When we perform an update on a long lived locked table, Oracle will save
- * a copy of the transaction in it's UNDO table space. Eventually this can
- * cause the UNDO table to become full, disrupting all locks in the DB instance.
- * A select query just touches the table, ensuring we can still read the DB but
- * doesn't add to the UNDO.
- */
- @Override
- boolean updateLock() {
- return aquireLock();
- }
-}
\ No newline at end of file
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/SimpleFileLock.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/SimpleFileLock.java
deleted file mode 100644
index c6fd1fa..0000000
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/SimpleFileLock.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.nio.channels.FileLock;
-import java.util.Properties;
-import java.util.logging.Logger;
-
-public class SimpleFileLock implements Lock {
-
- private static final Logger LOG = Logger.getLogger(SimpleFileLock.class.getName());
- private static final String PROPERTY_LOCK_DIR = "karaf.lock.dir";
- private static final String PROP_KARAF_BASE = "karaf.base";
- private RandomAccessFile lockFile;
- private FileLock lock;
-
- public SimpleFileLock(Properties props) {
- try {
-
- LOG.addHandler( BootstrapLogManager.getDefaultHandler() );
- String lock = props.getProperty(PROPERTY_LOCK_DIR);
-
- if (lock != null) {
- File karafLock = getKarafLock(new File(lock), props);
- props.setProperty(PROPERTY_LOCK_DIR, karafLock.getPath());
- } else {
- props.setProperty(PROPERTY_LOCK_DIR, System.getProperty(PROP_KARAF_BASE));
- }
-
- File base = new File(props.getProperty(PROPERTY_LOCK_DIR));
- lockFile = new RandomAccessFile(new File(base, "lock"), "rw");
- } catch (IOException e) {
- throw new RuntimeException("Could not create file lock", e);
- }
- }
-
- public boolean lock() throws Exception {
- LOG.info("locking");
- if (lock == null) {
- lock = lockFile.getChannel().tryLock();
- }
- return lock != null;
- }
-
- public void release() throws Exception {
- LOG.info("releasing");
- if (lock != null && lock.isValid()) {
- lock.release();
- lock.channel().close();
- }
- lock = null;
- }
-
- public boolean isAlive() throws Exception {
- return lock != null;
- }
-
- private static File getKarafLock(File lock,Properties props) {
- File rc = null;
-
- String path = lock.getPath();
- if (path != null) {
- rc = validateDirectoryExists(path, "Invalid " + PROPERTY_LOCK_DIR + " system property");
- }
-
- if (rc == null) {
- path = props.getProperty(PROP_KARAF_BASE);
- if (path != null) {
- rc = validateDirectoryExists(path, "Invalid " + PROP_KARAF_BASE + " property");
- }
- }
-
- if (rc == null) {
- rc = lock;
- }
- return rc;
- }
-
- private static File validateDirectoryExists(String path, String errPrefix) {
- File rc;
- try {
- rc = new File(path).getCanonicalFile();
- } catch (IOException e) {
- throw new IllegalArgumentException(errPrefix + " '" + path + "' : " + e.getMessage());
- }
- if (!rc.exists()) {
- throw new IllegalArgumentException(errPrefix + " '" + path + "' : does not exist");
- }
- if (!rc.isDirectory()) {
- throw new IllegalArgumentException(errPrefix + " '" + path + "' : is not a directory");
- }
- return rc;
- }
-
-}
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/Statements.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/Statements.java
deleted file mode 100644
index 251d6c4..0000000
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/Statements.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-
-public class Statements {
-
- protected String tablePrefix = "";
- protected String tableName = "KARAF_LOCK";
- protected String nodeName = "karaf";
- protected String momentColumnDataType = "BIGINT";
- protected String nodeColumnDataType = "VARCHAR(20)";
-
- private String[] lockCreateSchemaStatements;
- private String lockCreateStatement;
- private String lockUpdateStatement;
-
- public String[] getLockCreateSchemaStatements(long moment) {
- if (lockCreateSchemaStatements == null) {
- lockCreateSchemaStatements = new String[] {
- "CREATE TABLE " + getFullLockTableName() + " (MOMENT " + getMomentColumnDataType() + ", NODE " + getNodeColumnDataType() + ")",
- "INSERT INTO " + getFullLockTableName() + " (MOMENT, NODE) VALUES (" + moment + ", '" + getNodeName() + "')",
- };
- }
- return lockCreateSchemaStatements;
- }
-
- public void setLockCreateSchemaStatements(String[] lockCreateSchemaStatements) {
- this.lockCreateSchemaStatements = lockCreateSchemaStatements;
- }
-
- public String getLockCreateStatement() {
- if (lockCreateStatement == null) {
- lockCreateStatement = "SELECT * FROM " + getFullLockTableName() + " FOR UPDATE";
- }
- return lockCreateStatement;
- }
-
- public void setLockCreateStatement(String lockCreateStatement) {
- this.lockCreateStatement = lockCreateStatement;
- }
-
- public String getLockUpdateStatement(long moment) {
- if (lockUpdateStatement == null) {
- lockUpdateStatement = "UPDATE " + getFullLockTableName() + " SET MOMENT = " + moment;
- }
- return lockUpdateStatement;
- }
-
- public void setLockUpdateStatement(String lockUpdateStatement) {
- this.lockUpdateStatement = lockUpdateStatement;
- }
-
- long getCurrentTimeMillis() {
- return System.currentTimeMillis();
- }
-
- public String getFullLockTableName() {
- return getTablePrefix() + getTableName();
- }
-
- public void setMomentColumnDataType(String momentColumnDataType) {
- this.momentColumnDataType = momentColumnDataType;
- }
-
- public String getMomentColumnDataType() {
- return momentColumnDataType;
- }
-
- public String getNodeName() {
- return nodeName;
- }
-
- public void setNodeName(String nodeName) {
- this.nodeName = nodeName;
- }
-
- public String getNodeColumnDataType() {
- return nodeColumnDataType;
- }
-
- public void setNodeColumnDataType(String nodeColumnDataType) {
- this.nodeColumnDataType = nodeColumnDataType;
- }
-
- public String getTablePrefix() {
- return tablePrefix;
- }
-
- public void setTablePrefix(String tablePrefix) {
- this.tablePrefix = tablePrefix;
- }
-
- public String getTableName() {
- return tableName;
- }
-
- public void setTableName(String tableName) {
- this.tableName = tableName;
- }
-}
\ No newline at end of file
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/Stop.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/Stop.java
deleted file mode 100644
index b3c9b2c..0000000
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/Stop.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.net.Socket;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.Properties;
-
-/**
- * Main class used to stop the root Karaf instance
- */
-public class Stop {
-
- public static void main(String[] args) throws Exception {
- File karafHome = Utils.getKarafHome();
- File karafBase = Utils.getKarafBase(karafHome);
-
- System.setProperty(Main.PROP_KARAF_HOME, karafHome.getPath());
- System.setProperty(Main.PROP_KARAF_BASE, karafBase.getPath());
-
- // Load system properties.
- Main.loadSystemProperties(karafBase);
-
- File file = new File(new File(karafBase, "etc"), Main.CONFIG_PROPERTIES_FILE_NAME);
- URL configPropURL = file.toURI().toURL();
- Properties props = Main.loadPropertiesFile(configPropURL);
- Main.copySystemProperties(props);
-
- // Perform variable substitution for system properties.
- for (Enumeration e = props.propertyNames(); e.hasMoreElements();) {
- String name = (String) e.nextElement();
- props.setProperty(name,
- Main.substVars(props.getProperty(name), name, null, props));
- }
-
- int port = Integer.parseInt(props.getProperty(Main.KARAF_SHUTDOWN_PORT, "0"));
- String host = props.getProperty(Main.KARAF_SHUTDOWN_HOST, "localhost");
- String portFile = props.getProperty(Main.KARAF_SHUTDOWN_PORT_FILE);
- String shutdown = props.getProperty(Main.KARAF_SHUTDOWN_COMMAND, Main.DEFAULT_SHUTDOWN_COMMAND);
- if (port == 0 && portFile != null) {
- BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(portFile)));
- String portStr = r.readLine();
- port = Integer.parseInt(portStr);
- r.close();
- }
- if (port > 0) {
- Socket s = new Socket(host, port);
- s.getOutputStream().write(shutdown.getBytes());
- s.close();
- } else {
- System.err.println("Unable to find port...");
- }
-
- }
-}
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/StringMap.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/StringMap.java
deleted file mode 100644
index 4ef648f..0000000
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/StringMap.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import java.util.Comparator;
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- * Simple utility class that creates a map for string-based keys by
- * extending <tt>TreeMap</tt>. This map can be set to use case-sensitive
- * or case-insensitive comparison when searching for the key.
- * Any keys put into this map will be converted to
- * a <tt>String</tt> using the <tt>toString()</tt> method,
- * since it is only intended to compare strings.
-**/
-public class StringMap extends TreeMap
-{
- public StringMap()
- {
- this(true);
- }
-
- public StringMap(boolean caseSensitive)
- {
- super(new StringComparator(caseSensitive));
- }
-
- public StringMap(Map map, boolean caseSensitive)
- {
- this(caseSensitive);
- putAll(map);
- }
-
- public Object put(Object key, Object value)
- {
- return super.put(key.toString(), value);
- }
-
- public boolean isCaseSensitive()
- {
- return ((StringComparator) comparator()).isCaseSensitive();
- }
-
- public void setCaseSensitive(boolean b)
- {
- ((StringComparator) comparator()).setCaseSensitive(b);
- }
-
- private static class StringComparator implements Comparator
- {
- private boolean m_isCaseSensitive = true;
-
- public StringComparator(boolean b)
- {
- m_isCaseSensitive = b;
- }
-
- public int compare(Object o1, Object o2)
- {
- if (m_isCaseSensitive)
- {
- return o1.toString().compareTo(o2.toString());
- }
- else
- {
- return o1.toString().compareToIgnoreCase(o2.toString());
- }
- }
-
- public boolean isCaseSensitive()
- {
- return m_isCaseSensitive;
- }
-
- public void setCaseSensitive(boolean b)
- {
- m_isCaseSensitive = b;
- }
- }
-}
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/Utils.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/Utils.java
deleted file mode 100644
index 61c03ee..0000000
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/Utils.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.net.JarURLConnection;
-import java.net.URI;
-
-import org.apache.felix.karaf.main.Main;
-
-public class Utils {
-
- public static File getKarafHome() throws IOException {
- File rc = null;
-
- // Use the system property if specified.
- String path = System.getProperty(Main.PROP_KARAF_HOME);
- if (path != null) {
- rc = validateDirectoryExists(path, "Invalid " + Main.PROP_KARAF_HOME + " system property");
- }
-
- if (rc == null) {
- path = System.getenv(Main.ENV_KARAF_HOME);
- if (path != null) {
- rc = validateDirectoryExists(path, "Invalid " + Main.ENV_KARAF_HOME + " environment variable");
- }
- }
-
- // Try to figure it out using the jar file this class was loaded from.
- if (rc == null) {
- // guess the home from the location of the jar
- URL url = Main.class.getClassLoader().getResource(Main.class.getName().replace(".", "/") + ".class");
- if (url != null) {
- try {
- JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
- url = jarConnection.getJarFileURL();
- rc = new File(new URI(url.toString())).getCanonicalFile().getParentFile().getParentFile();
- } catch (Exception ignored) {
- }
- }
- }
-
- if (rc == null) {
- // Dig into the classpath to guess the location of the jar
- String classpath = System.getProperty("java.class.path");
- int index = classpath.toLowerCase().indexOf("karaf.jar");
- int start = classpath.lastIndexOf(File.pathSeparator, index) + 1;
- if (index >= start) {
- String jarLocation = classpath.substring(start, index);
- rc = new File(jarLocation).getCanonicalFile().getParentFile();
- }
- }
- if (rc == null) {
- throw new IOException("The Karaf install directory could not be determined. Please set the " + Main.PROP_KARAF_HOME + " system property or the " + Main.ENV_KARAF_HOME + " environment variable.");
- }
-
- return rc;
- }
-
- public static File validateDirectoryExists(String path, String errPrefix) {
- File rc;
- try {
- rc = new File(path).getCanonicalFile();
- } catch (IOException e) {
- throw new IllegalArgumentException(errPrefix + " '" + path + "' : " + e.getMessage());
- }
- if (!rc.exists()) {
- throw new IllegalArgumentException(errPrefix + " '" + path + "' : does not exist");
- }
- if (!rc.isDirectory()) {
- throw new IllegalArgumentException(errPrefix + " '" + path + "' : is not a directory");
- }
- return rc;
- }
-
- public static File getKarafBase(File defaultValue) {
- File rc = null;
-
- String path = System.getProperty(Main.PROP_KARAF_BASE);
- if (path != null) {
- rc = validateDirectoryExists(path, "Invalid " + Main.PROP_KARAF_BASE + " system property");
- }
-
- if (rc == null) {
- path = System.getenv(Main.ENV_KARAF_BASE);
- if (path != null) {
- rc = validateDirectoryExists(path, "Invalid " + Main.ENV_KARAF_BASE + " environment variable");
- }
- }
-
- if (rc == null) {
- rc = defaultValue;
- }
- return rc;
- }
-}
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/spi/MainService.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/spi/MainService.java
deleted file mode 100644
index f72c207..0000000
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/spi/MainService.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main.spi;
-
-public interface MainService {
-
- public abstract String[] getArgs();
- public int getExitCode();
- public void setExitCode(int exitCode);
-
-}
diff --git a/karaf/main/src/main/resources/config.properties b/karaf/main/src/main/resources/config.properties
deleted file mode 100644
index 6fe20f9..0000000
--- a/karaf/main/src/main/resources/config.properties
+++ /dev/null
@@ -1,529 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-#
-# Framework config properties.
-#
-org.osgi.framework.system.packages=org.osgi.framework; version=1.4.0, \
- org.osgi.service.packageadmin; version=1.2.0, \
- org.osgi.service.startlevel; version=1.1.0, \
- org.osgi.service.url; version=1.0.0, \
- org.osgi.util.tracker; version=1.3.2 \
- ${jre-${java.specification.version}}
-
-#org.osgi.framework.bootdelegation=sun.*,com.sun.*
-#felix.cache.profile=foo
-felix.auto.start.1= \
- file:bundle/org.apache.felix.shell-1.0.0.jar \
- file:bundle/org.apache.felix.shell.tui-1.0.0.jar \
- file:bundle/org.apache.felix.bundlerepository-1.0.0.jar
-felix.log.level=4
-felix.startlevel.framework=1
-felix.startlevel.bundle=1
-#framework.service.urlhandlers=false
-
-#
-# Bundle config properties.
-#
-org.osgi.service.http.port=8080
-osgi.shell.telnet=on
-#obr.repository.url=http://bundles.osgi.org/obr/browse?_xml=1&cmd=repository
-
-karaf.default.repository=system
-#list of directories containing bundles to be loaded by SMX
-#bundle.locations=
-
-#
-# Java platform package export properties.
-#
-jre-1.3=, \
- javax.accessibility; \
- javax.accessibility.resources; \
- javax.naming; \
- javax.naming.directory; \
- javax.naming.event; \
- javax.naming.ldap; \
- javax.naming.spi; \
- javax.rmi; \
- javax.rmi.CORBA; \
- javax.sound.midi; \
- javax.sound.midi.spi; \
- javax.sound.sampled; \
- javax.sound.sampled.spi; \
- javax.swing; \
- javax.swing.border; \
- javax.swing.colorchooser; \
- javax.swing.event; \
- javax.swing.filechooser; \
- javax.swing.plaf; \
- javax.swing.plaf.basic; \
- javax.swing.plaf.basic.resources; \
- javax.swing.plaf.metal; \
- javax.swing.plaf.metal.resources; \
- javax.swing.plaf.multi; \
- javax.swing.table; \
- javax.swing.text; \
- javax.swing.text.html; \
- javax.swing.text.html.parser; \
- javax.swing.text.rtf; \
- javax.swing.tree; \
- javax.swing.undo; \
- javax.transaction; \
- org.omg.CORBA; \
- org.omg.CORBA_2_3; \
- org.omg.CORBA_2_3.portable; \
- org.omg.CORBA.DynAnyPackage; \
- org.omg.CORBA.ORBPackage; \
- org.omg.CORBA.portable; \
- org.omg.CORBA.TypeCodePackage; \
- org.omg.CosNaming; \
- org.omg.CosNaming.NamingContextPackage; \
- org.omg.SendingContext; \
- org.omg.stub.java.rmi; \
- version="1.3.0"
-
-jre-1.4=, \
- javax.accessibility; \
- javax.imageio; \
- javax.imageio.event; \
- javax.imageio.metadata; \
- javax.imageio.plugins.jpeg; \
- javax.imageio.spi; \
- javax.imageio.stream; \
- javax.naming; \
- javax.naming.directory; \
- javax.naming.event; \
- javax.naming.ldap; \
- javax.naming.spi; \
- javax.net; \
- javax.net.ssl; \
- javax.print; \
- javax.print.attribute; \
- javax.print.attribute.standard; \
- javax.print.event; \
- javax.rmi; \
- javax.rmi.CORBA; \
- javax.security.auth; \
- javax.security.auth.callback; \
- javax.security.auth.kerberos; \
- javax.security.auth.login; \
- javax.security.auth.spi; \
- javax.security.auth.x500; \
- javax.sound.midi; \
- javax.sound.midi.spi; \
- javax.sound.sampled; \
- javax.sound.sampled.spi; \
- javax.sql; \
- javax.swing; \
- javax.swing.border; \
- javax.swing.colorchooser; \
- javax.swing.event; \
- javax.swing.filechooser; \
- javax.swing.plaf; \
- javax.swing.plaf.basic; \
- javax.swing.plaf.metal; \
- javax.swing.plaf.multi; \
- javax.swing.table; \
- javax.swing.text; \
- javax.swing.text.html; \
- javax.swing.text.html.parser; \
- javax.swing.text.rtf; \
- javax.swing.tree; \
- javax.swing.undo; \
- javax.transaction; \
- javax.transaction.xa; \
- javax.xml.parsers; \
- javax.xml.transform; \
- javax.xml.transform.dom; \
- javax.xml.transform.sax; \
- javax.xml.transform.stream; \
- org.ietf.jgss; \
- org.omg.CORBA; \
- org.omg.CORBA_2_3; \
- org.omg.CORBA_2_3.portable; \
- org.omg.CORBA.DynAnyPackage; \
- org.omg.CORBA.ORBPackage; \
- org.omg.CORBA.portable; \
- org.omg.CORBA.TypeCodePackage; \
- org.omg.CosNaming; \
- org.omg.CosNaming.NamingContextExtPackage; \
- org.omg.CosNaming.NamingContextPackage; \
- org.omg.Dynamic; \
- org.omg.DynamicAny; \
- org.omg.DynamicAny.DynAnyFactoryPackage; \
- org.omg.DynamicAny.DynAnyPackage; \
- org.omg.IOP; \
- org.omg.IOP.CodecFactoryPackage; \
- org.omg.IOP.CodecPackage; \
- org.omg.Messaging; \
- org.omg.PortableInterceptor; \
- org.omg.PortableInterceptor.ORBInitInfoPackage; \
- org.omg.PortableServer; \
- org.omg.PortableServer.CurrentPackage; \
- org.omg.PortableServer.POAManagerPackage; \
- org.omg.PortableServer.POAPackage; \
- org.omg.PortableServer.portable; \
- org.omg.PortableServer.ServantLocatorPackage; \
- org.omg.SendingContext; \
- org.omg.stub.java.rmi; \
- org.w3c.dom; \
- org.w3c.dom.css; \
- org.w3c.dom.events; \
- org.w3c.dom.html; \
- org.w3c.dom.stylesheets; \
- org.w3c.dom.traversal; \
- org.w3c.dom.views; \
- org.xml.sax; \
- org.xml.sax.ext; \
- org.xml.sax.helpers; \
- version="1.4.0"
-
-jre-1.5=, \
- javax.accessibility; \
- javax.activity; \
- javax.imageio; \
- javax.imageio.event; \
- javax.imageio.metadata; \
- javax.imageio.plugins.bmp; \
- javax.imageio.plugins.jpeg; \
- javax.imageio.spi; \
- javax.imageio.stream; \
- javax.management; \
- javax.management.loading; \
- javax.management.modelmbean; \
- javax.management.monitor; \
- javax.management.openmbean; \
- javax.management.relation; \
- javax.management.remote; \
- javax.management.remote.rmi; \
- javax.management.timer; \
- javax.naming; \
- javax.naming.directory; \
- javax.naming.event; \
- javax.naming.ldap; \
- javax.naming.spi; \
- javax.net; \
- javax.net.ssl; \
- javax.print; \
- javax.print.attribute; \
- javax.print.attribute.standard; \
- javax.print.event; \
- javax.rmi; \
- javax.rmi.CORBA; \
- javax.rmi.ssl; \
- javax.security.auth; \
- javax.security.auth.callback; \
- javax.security.auth.kerberos; \
- javax.security.auth.login; \
- javax.security.auth.spi; \
- javax.security.auth.x500; \
- javax.security.sasl; \
- javax.sound.midi; \
- javax.sound.midi.spi; \
- javax.sound.sampled; \
- javax.sound.sampled.spi; \
- javax.sql; \
- javax.sql.rowset; \
- javax.sql.rowset.serial; \
- javax.sql.rowset.spi; \
- javax.swing; \
- javax.swing.border; \
- javax.swing.colorchooser; \
- javax.swing.event; \
- javax.swing.filechooser; \
- javax.swing.plaf; \
- javax.swing.plaf.basic; \
- javax.swing.plaf.metal; \
- javax.swing.plaf.multi; \
- javax.swing.plaf.synth; \
- javax.swing.table; \
- javax.swing.text; \
- javax.swing.text.html; \
- javax.swing.text.html.parser; \
- javax.swing.text.rtf; \
- javax.swing.tree; \
- javax.swing.undo; \
- javax.transaction; \
- javax.transaction.xa; \
- javax.xml; \
- javax.xml.datatype; \
- javax.xml.namespace; \
- javax.xml.parsers; \
- javax.xml.transform; \
- javax.xml.transform.dom; \
- javax.xml.transform.sax; \
- javax.xml.transform.stream; \
- javax.xml.validation; \
- javax.xml.xpath; \
- org.ietf.jgss; \
- org.omg.CORBA; \
- org.omg.CORBA_2_3; \
- org.omg.CORBA_2_3.portable; \
- org.omg.CORBA.DynAnyPackage; \
- org.omg.CORBA.ORBPackage; \
- org.omg.CORBA.portable; \
- org.omg.CORBA.TypeCodePackage; \
- org.omg.CosNaming; \
- org.omg.CosNaming.NamingContextExtPackage; \
- org.omg.CosNaming.NamingContextPackage; \
- org.omg.Dynamic; \
- org.omg.DynamicAny; \
- org.omg.DynamicAny.DynAnyFactoryPackage; \
- org.omg.DynamicAny.DynAnyPackage; \
- org.omg.IOP; \
- org.omg.IOP.CodecFactoryPackage; \
- org.omg.IOP.CodecPackage; \
- org.omg.Messaging; \
- org.omg.PortableInterceptor; \
- org.omg.PortableInterceptor.ORBInitInfoPackage; \
- org.omg.PortableServer; \
- org.omg.PortableServer.CurrentPackage; \
- org.omg.PortableServer.POAManagerPackage; \
- org.omg.PortableServer.POAPackage; \
- org.omg.PortableServer.portable; \
- org.omg.PortableServer.ServantLocatorPackage; \
- org.omg.SendingContext; \
- org.omg.stub.java.rmi; \
- org.omg.stub.javax.management.remote.rmi; \
- org.w3c.dom; \
- org.w3c.dom.bootstrap; \
- org.w3c.dom.css; \
- org.w3c.dom.events; \
- org.w3c.dom.html; \
- org.w3c.dom.ls; \
- org.w3c.dom.ranges; \
- org.w3c.dom.stylesheets; \
- org.w3c.dom.traversal; \
- org.w3c.dom.views; \
- org.xml.sax; \
- org.xml.sax.ext; \
- org.xml.sax.helpers; \
- version="1.5.0"
-
-jre-1.6=, \
- java.applet; \
- java.awt; \
- java.awt.color; \
- java.awt.datatransfer; \
- java.awt.dnd; \
- java.awt.dnd.peer; \
- java.awt.event; \
- java.awt.font; \
- java.awt.geom; \
- java.awt.im; \
- java.awt.image; \
- java.awt.image.renderable; \
- java.awt.im.spi; \
- java.awt.peer; \
- java.awt.print; \
- java.beans; \
- java.beans.beancontext; \
- java.io; \
- java.lang; \
- java.lang.annotation; \
- java.lang.instrument; \
- java.lang.management; \
- java.lang.ref; \
- java.lang.reflect; \
- java.math; \
- java.net; \
- java.nio; \
- java.nio.channels; \
- java.nio.channels.spi; \
- java.nio.charset; \
- java.nio.charset.spi; \
- java.rmi; \
- java.rmi.activation; \
- java.rmi.dgc; \
- java.rmi.registry; \
- java.rmi.server; \
- java.security; \
- java.security.acl; \
- java.security.cert; \
- java.security.interfaces; \
- java.security.spec; \
- java.sql; \
- java.text; \
- java.text.spi; \
- java.util; \
- java.util.concurrent; \
- java.util.concurrent.atomic; \
- java.util.concurrent.locks; \
- java.util.jar; \
- java.util.logging; \
- java.util.prefs; \
- java.util.regex; \
- java.util.spi; \
- java.util.zip; \
- javax.accessibility; \
- javax.activation; \
- javax.activity; \
- javax.annotation; \
- javax.annotation.processing; \
- javax.imageio; \
- javax.imageio.event; \
- javax.imageio.metadata; \
- javax.imageio.plugins.bmp; \
- javax.imageio.plugins.jpeg; \
- javax.imageio.spi; \
- javax.imageio.stream; \
- javax.jws; \
- javax.jws.soap; \
- javax.lang.model; \
- javax.lang.model.element; \
- javax.lang.model.type; \
- javax.lang.model.util; \
- javax.management; \
- javax.management.loading; \
- javax.management.modelmbean; \
- javax.management.monitor; \
- javax.management.openmbean; \
- javax.management.relation; \
- javax.management.remote; \
- javax.management.remote.rmi; \
- javax.management.timer; \
- javax.naming; \
- javax.naming.directory; \
- javax.naming.event; \
- javax.naming.ldap; \
- javax.naming.spi; \
- javax.net; \
- javax.net.ssl; \
- javax.print; \
- javax.print.attribute; \
- javax.print.attribute.standard; \
- javax.print.event; \
- javax.rmi; \
- javax.rmi.CORBA; \
- javax.rmi.ssl; \
- javax.script; \
- javax.security.auth; \
- javax.security.auth.callback; \
- javax.security.auth.kerberos; \
- javax.security.auth.login; \
- javax.security.auth.spi; \
- javax.security.auth.x500; \
- javax.security.sasl; \
- javax.smartcardio; \
- javax.sound.midi; \
- javax.sound.midi.spi; \
- javax.sound.sampled; \
- javax.sound.sampled.spi; \
- javax.sql; \
- javax.sql.rowset; \
- javax.sql.rowset.serial; \
- javax.sql.rowset.spi; \
- javax.swing; \
- javax.swing.border; \
- javax.swing.colorchooser; \
- javax.swing.event; \
- javax.swing.filechooser; \
- javax.swing.plaf; \
- javax.swing.plaf.basic; \
- javax.swing.plaf.metal; \
- javax.swing.plaf.multi; \
- javax.swing.plaf.synth; \
- javax.swing.table; \
- javax.swing.text; \
- javax.swing.text.html; \
- javax.swing.text.html.parser; \
- javax.swing.text.rtf; \
- javax.swing.tree; \
- javax.swing.undo; \
- javax.tools; \
- javax.transaction; \
- javax.transaction.xa; \
- javax.xml; \
- javax.xml.bind; \
- javax.xml.bind.annotation; \
- javax.xml.bind.annotation.adapters; \
- javax.xml.bind.attachment; \
- javax.xml.bind.helpers; \
- javax.xml.bind.util; \
- javax.xml.crypto; \
- javax.xml.crypto.dom; \
- javax.xml.crypto.dsig; \
- javax.xml.crypto.dsig.dom; \
- javax.xml.crypto.dsig.keyinfo; \
- javax.xml.crypto.dsig.spec; \
- javax.xml.datatype; \
- javax.xml.namespace; \
- javax.xml.parsers; \
- javax.xml.soap; \
- javax.xml.stream; \
- javax.xml.stream.events; \
- javax.xml.stream.util; \
- javax.xml.transform; \
- javax.xml.transform.dom; \
- javax.xml.transform.sax; \
- javax.xml.transform.stax; \
- javax.xml.transform.stream; \
- javax.xml.validation; \
- javax.xml.ws; \
- javax.xml.ws.handler; \
- javax.xml.ws.handler.soap; \
- javax.xml.ws.http; \
- javax.xml.ws.soap; \
- javax.xml.ws.spi; \
- javax.xml.xpath; \
- org.ietf.jgss; \
- org.jcp.xml.dsig.internal; \
- org.jcp.xml.dsig.internal.dom; \
- org.omg.CORBA; \
- org.omg.CORBA_2_3; \
- org.omg.CORBA_2_3.portable; \
- org.omg.CORBA.DynAnyPackage; \
- org.omg.CORBA.ORBPackage; \
- org.omg.CORBA.portable; \
- org.omg.CORBA.TypeCodePackage; \
- org.omg.CosNaming; \
- org.omg.CosNaming.NamingContextExtPackage; \
- org.omg.CosNaming.NamingContextPackage; \
- org.omg.Dynamic; \
- org.omg.DynamicAny; \
- org.omg.DynamicAny.DynAnyFactoryPackage; \
- org.omg.DynamicAny.DynAnyPackage; \
- org.omg.IOP; \
- org.omg.IOP.CodecFactoryPackage; \
- org.omg.IOP.CodecPackage; \
- org.omg.Messaging; \
- org.omg.PortableInterceptor; \
- org.omg.PortableInterceptor.ORBInitInfoPackage; \
- org.omg.PortableServer; \
- org.omg.PortableServer.CurrentPackage; \
- org.omg.PortableServer.POAManagerPackage; \
- org.omg.PortableServer.POAPackage; \
- org.omg.PortableServer.portable; \
- org.omg.PortableServer.ServantLocatorPackage; \
- org.omg.SendingContext; \
- org.omg.stub.java.rmi; \
- org.omg.stub.javax.management.remote.rmi; \
- org.w3c.dom; \
- org.w3c.dom.bootstrap; \
- org.w3c.dom.css; \
- org.w3c.dom.events; \
- org.w3c.dom.html; \
- org.w3c.dom.ls; \
- org.w3c.dom.ranges; \
- org.w3c.dom.stylesheets; \
- org.w3c.dom.traversal; \
- org.w3c.dom.views; \
- org.w3c.dom.xpath; \
- org.xml.sax; \
- org.xml.sax.ext; \
- org.xml.sax.helpers; \
- version=\"1.6.0\"
diff --git a/karaf/main/src/test/java/org/apache/felix/karaf/main/BaseJDBCLockIntegrationTest.java b/karaf/main/src/test/java/org/apache/felix/karaf/main/BaseJDBCLockIntegrationTest.java
deleted file mode 100644
index eae8d19..0000000
--- a/karaf/main/src/test/java/org/apache/felix/karaf/main/BaseJDBCLockIntegrationTest.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Properties;
-import java.util.logging.Logger;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public abstract class BaseJDBCLockIntegrationTest {
-
- private final Logger LOG = Logger.getLogger(this.getClass().getName());
-
- DefaultJDBCLock lock;
- Properties props;
- String user = "root";
- String password = "";
- String driver;
- String url;
- String tableName = "LOCK_TABLE";
- String clustername = "karaf_cluster";
- int timeout = 10;
- String momentDatatype = "BIGINT";
- String nodeDatatype = "VARCHAR(20)";
-
- abstract DefaultJDBCLock createLock(Properties props);
-
- @BeforeClass
- public static void setUpTestSuite() {
- Properties properties = new Properties();
- properties.put("karaf.bootstrap.log", "target/karaf.log");
- BootstrapLogManager.setProperties(properties);
- }
-
- @Before
- public void setUp() throws Exception {
- props = new Properties();
- props.put("karaf.lock.jdbc.url", url);
- props.put("karaf.lock.jdbc.driver", driver);
- props.put("karaf.lock.jdbc.user", user);
- props.put("karaf.lock.jdbc.password", password);
- props.put("karaf.lock.jdbc.table", tableName);
- props.put("karaf.lock.jdbc.clustername", clustername);
- props.put("karaf.lock.jdbc.timeout", String.valueOf(timeout));
-
- try {
- executeStatement("DROP TABLE " + tableName);
- } catch (Exception e) {
- // expected if the table dosn't exist
- }
- }
-
- @After
- public void tearDown() throws Exception {
- if (lock != null) {
- lock.release();
- }
- }
-
- @Test
- @Ignore
- public void lockShouldRestoreTheLockAfterADbFailure() throws Exception {
- Lock lock1 = createLock(props);
- assertTrue(lock1.lock());
- assertTrue(lock1.isAlive());
-
- // shut down the database
-
- assertFalse(lock1.isAlive());
-
- // start the database
-
- assertTrue(lock1.lock());
- assertTrue(lock1.isAlive());
- }
-
- @Test
- public void initShouldCreateTheSchemaIfItNotExists() throws Exception {
- long start = System.currentTimeMillis();
- lock = createLock(props);
- long end = System.currentTimeMillis();
-
- long moment = queryDatabaseSingleResult("SELECT MOMENT FROM " + tableName);
-
- assertTrue(moment >= start);
- assertTrue(moment <= end);
- }
-
- @Test
- public void initShouldNotCreateTheSchemaIfItAlreadyExists() throws Exception {
- executeStatement("CREATE TABLE " + tableName + " (MOMENT " + momentDatatype + ", NODE " + nodeDatatype + ")");
- executeStatement("INSERT INTO " + tableName + " (MOMENT, NODE) VALUES (1, '" + clustername + "')");
-
- lock = createLock(props);
-
- long moment = queryDatabaseSingleResult("SELECT MOMENT FROM " + tableName);
-
- assertEquals(1, moment);
- }
-
- @Test
- public void lockShouldReturnTrueItTheTableIsNotLocked() throws Exception {
- lock = createLock(props);
-
- assertTrue(lock.lock());
- assertTableIsLocked();
- }
-
- @Test
- public void lockShouldReturnFalseIfAnotherRowIsLocked() throws Exception {
- Connection connection = null;
- try {
- lock = createLock(props);
-
- executeStatement("INSERT INTO " + tableName + " (MOMENT, NODE) VALUES (1, '" + clustername + "_2')");
- connection = lock(tableName, clustername + "_2");
-
- // we can't lock only one row for the cluster
- assertFalse(lock.lock());
- } finally {
- close(connection);
- }
- }
-
- @Test
- public void lockShouldReturnFalseIfTheRowIsAlreadyLocked() throws Exception {
- Connection connection = null;
- try {
- lock = createLock(props);
- connection = lock(tableName, clustername);
-
- assertFalse(lock.lock());
- } finally {
- close(connection);
- }
- }
-
- @Test
- public void release() throws Exception {
- lock = createLock(props);
-
- assertTrue(lock.lock());
-
- lock.release();
-
- assertNull(lock.lockConnection);
- assertTableIsUnlocked();
- }
-
- @Test
- public void releaseShouldSucceedForAnAlreadyClosedConnection() throws Exception {
- lock = createLock(props);
-
- assertTrue(lock.lock());
-
- lock.lockConnection.rollback(); // release the lock
- lock.lockConnection.close();
- lock.release();
-
- assertTableIsUnlocked();
- }
-
- @Test
- public void releaseShouldSucceedForANullConnectionReference() throws Exception {
- lock = createLock(props);
-
- assertTrue(lock.lock());
-
- lock.lockConnection.rollback(); // release the lock
- lock.lockConnection.close();
- lock.lockConnection = null;
- lock.release();
-
- assertTableIsUnlocked();
- }
-
- @Test
- public void isAliveShouldReturnTrueIfItHoldsTheLock() throws Exception {
- lock = createLock(props);
-
- assertTrue(lock.lock());
- assertTrue(lock.isAlive());
- }
-
- @Test
- public void isAliveShouldReturnFalseIfTheConnectionIsClosed() throws Exception {
- lock = createLock(props);
-
- assertTrue(lock.lock());
-
- lock.lockConnection.rollback(); // release the lock
- lock.lockConnection.close();
-
- assertFalse(lock.isAlive());
- }
-
- @Test
- public void isAliveShouldReturnFalseIfTheConnectionIsNull() throws Exception {
- lock = createLock(props);
-
- assertTrue(lock.lock());
-
- lock.lockConnection.rollback(); // release the lock
- lock.lockConnection.close();
- lock.lockConnection = null;
-
- assertFalse(lock.isAlive());
- }
-
- @Test
- public void isAliveShouldReturnFalseIfItNotHoldsTheLock() throws Exception {
- Connection connection = null;
- try {
- lock = createLock(props);
-
- assertTrue(lock.lock());
-
- lock.lockConnection.rollback(); // release the lock
- connection = lock(tableName, clustername); // another connection locks the table
-
- assertFalse(lock.isAlive());
- } finally {
- close(connection);
- }
- }
-
- Connection getConnection(String url, String user, String password) throws ClassNotFoundException, SQLException {
- Class.forName(driver);
- Connection connection = DriverManager.getConnection(url, user, password);
- connection.setAutoCommit(false);
- return connection;
- }
-
- void executeStatement(String stmt) throws SQLException, ClassNotFoundException {
- Connection connection = null;
- Statement statement = null;
-
- try {
- connection = getConnection(url, user, password);
- statement = connection.createStatement();
- statement.setQueryTimeout(timeout);
- statement.execute(stmt);
- connection.commit();
- } finally {
- close(statement);
- close(connection);
- }
- }
-
- Long queryDatabaseSingleResult(String query) throws ClassNotFoundException, SQLException {
- Connection connection = null;
- Statement statement = null;
- ResultSet rs = null;
-
- try {
- connection = getConnection(url, user, password);
- statement = connection.createStatement();
- rs = statement.executeQuery(query);
- rs.next();
- return rs.getLong(1);
- } finally {
- close(rs);
- close(statement);
- close(connection);
- }
- }
-
- void assertTableIsLocked() throws ClassNotFoundException, SQLException {
- try {
- executeStatement("UPDATE " + tableName + " SET MOMENT = " + System.currentTimeMillis());
- fail("SQLException for timeout expected because the table should be already locked");
- } catch (SQLException sqle) {
- // expected
- }
- }
-
- void assertTableIsUnlocked() throws ClassNotFoundException, SQLException {
- executeStatement("UPDATE " + tableName + " SET MOMENT = " + System.currentTimeMillis());
- }
-
- Connection lock(String table, String node) throws ClassNotFoundException, SQLException {
- Connection connection = null;
- Statement statement = null;
-
- try {
- connection = getConnection(url, user, password);
- statement = connection.createStatement();
- //statement.execute("SELECT * FROM " + table + " WHERE NODE = '" + node + "' FOR UPDATE");
- //statement.execute("UPDATE " + table + " SET MOMENT = " + System.currentTimeMillis() + " WHERE NODE = '" + node + "'");
- statement.execute("SELECT * FROM " + table + " FOR UPDATE");
- statement.execute("UPDATE " + table + " SET MOMENT = " + System.currentTimeMillis());
- } finally {
- close(statement);
- // connection must not be closed!
- }
-
- return connection;
- }
-
- void close(ResultSet rs) throws SQLException {
- if (rs != null) {
- try {
- rs.close();
- } catch (Exception e) {
- }
- }
- }
-
- void close(Statement statement) throws SQLException {
- if (statement != null) {
- try {
- statement.close();
- } catch (Exception e) {
- LOG.severe("Can't close the statement: " + e);
- }
- }
- }
-
- void close(Connection connection) throws SQLException {
- if (connection != null) {
- try {
- connection.rollback();
- } catch (Exception e) {
- LOG.severe("Can't rollback the connection: " + e);
- }
- try {
- connection.close();
- } catch (Exception e) {
- LOG.severe("Can't close the connection: " + e);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/karaf/main/src/test/java/org/apache/felix/karaf/main/BaseJDBCLockTest.java b/karaf/main/src/test/java/org/apache/felix/karaf/main/BaseJDBCLockTest.java
deleted file mode 100644
index 8f9de04..0000000
--- a/karaf/main/src/test/java/org/apache/felix/karaf/main/BaseJDBCLockTest.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Properties;
-
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public abstract class BaseJDBCLockTest {
-
- DefaultJDBCLock lock;
- Properties props;
- String user = "root";
- String password = "";
- String driver;
- String url;
- String tableName = "LOCK_TABLE";
- String clustername = "karaf_cluster";
- int timeout = 10;
- String momentDatatype = "BIGINT";
- String nodeDatatype = "VARCHAR(20)";
- String createTableStmtSuffix = "";
-
- Connection connection;
- DatabaseMetaData metaData;
- ResultSet resultSet;
- PreparedStatement preparedStatement;
- Statement statement;
-
- abstract DefaultJDBCLock createLock(Properties props);
-
- @BeforeClass
- public static void setUpTestSuite() {
- Properties properties = new Properties();
- properties.put("karaf.bootstrap.log", "target/karaf.log");
- BootstrapLogManager.setProperties(properties);
- }
-
- @Before
- public void setUp() throws Exception {
- connection = EasyMock.createMock(Connection.class);
- metaData = EasyMock.createMock(DatabaseMetaData.class);
- resultSet = EasyMock.createMock(ResultSet.class);
- preparedStatement = EasyMock.createMock(PreparedStatement.class);
- statement = EasyMock.createMock(Statement.class);
-
- props = new Properties();
- props.put("karaf.lock.jdbc.url", url);
- props.put("karaf.lock.jdbc.driver", driver);
- props.put("karaf.lock.jdbc.user", user);
- props.put("karaf.lock.jdbc.password", password);
- props.put("karaf.lock.jdbc.table", tableName);
- props.put("karaf.lock.jdbc.clustername", clustername);
- props.put("karaf.lock.jdbc.timeout", timeout);
- }
-
- @Test
- public void initShouldCreateTheSchemaIfItNotExists() throws Exception {
- expect(connection.isClosed()).andReturn(false);
- connection.setAutoCommit(false);
- expect(connection.getMetaData()).andReturn(metaData);
- expect(metaData.getTables((String) isNull(), (String) isNull(), eq("LOCK_TABLE"), aryEq(new String[] {"TABLE"}))).andReturn(resultSet);
- expect(resultSet.next()).andReturn(false);
- resultSet.close();
- expect(connection.isClosed()).andReturn(false);
- expect(connection.createStatement()).andReturn(statement);
- expect(statement.execute("CREATE TABLE " + tableName + " (MOMENT " + momentDatatype + ", NODE " + nodeDatatype + ")" + createTableStmtSuffix)).andReturn(false);
- expect(statement.execute("INSERT INTO " + tableName + " (MOMENT, NODE) VALUES (1, '" + clustername + "')")).andReturn(false);
- statement.close();
- connection.commit();
-
- replay(connection, metaData, statement, preparedStatement, resultSet);
-
- lock = createLock(props);
-
- verify(connection, metaData, statement, preparedStatement, resultSet);
- }
-
- @Test
- public void initShouldNotCreateTheSchemaIfItAlreadyExists() throws Exception {
- connection.setAutoCommit(false);
- expect(connection.getMetaData()).andReturn(metaData);
- expect(metaData.getTables((String) isNull(), (String) isNull(), eq("LOCK_TABLE"), aryEq(new String[] {"TABLE"}))).andReturn(resultSet);
- expect(resultSet.next()).andReturn(true);
- resultSet.close();
-
- replay(connection, metaData, statement, preparedStatement, resultSet);
-
- lock = createLock(props);
-
- verify(connection, metaData, statement, preparedStatement, resultSet);
- }
-
- @Test
- public void lockShouldReturnTrueItTheTableIsNotLocked() throws Exception {
- initShouldNotCreateTheSchemaIfItAlreadyExists();
- reset(connection, metaData, statement, preparedStatement, resultSet);
-
- expect(connection.isClosed()).andReturn(false);
- expect(connection.prepareStatement("SELECT * FROM " + tableName + " FOR UPDATE")).andReturn(preparedStatement);
- preparedStatement.setQueryTimeout(10);
- expect(preparedStatement.execute()).andReturn(true);
- preparedStatement.close();
- expect(connection.isClosed()).andReturn(false);
- expect(connection.prepareStatement("UPDATE " + tableName + " SET MOMENT = 1")).andReturn(preparedStatement);
- preparedStatement.setQueryTimeout(10);
- expect(preparedStatement.executeUpdate()).andReturn(1);
- preparedStatement.close();
-
- replay(connection, metaData, statement, preparedStatement, resultSet);
-
- boolean lockAquired = lock.lock();
-
- verify(connection, metaData, statement, preparedStatement, resultSet);
- assertTrue(lockAquired);
- }
-
- @Test
- public void lockShouldReturnFalseIfAnotherRowIsLocked() throws Exception {
- initShouldNotCreateTheSchemaIfItAlreadyExists();
- reset(connection, metaData, statement, preparedStatement, resultSet);
-
- expect(connection.isClosed()).andReturn(false);
- expect(connection.prepareStatement("SELECT * FROM " + tableName + " FOR UPDATE")).andReturn(preparedStatement);
- preparedStatement.setQueryTimeout(10);
- expect(preparedStatement.execute()).andReturn(true);
- preparedStatement.close();
- expect(connection.isClosed()).andReturn(false);
- expect(connection.prepareStatement("UPDATE " + tableName + " SET MOMENT = 1")).andReturn(preparedStatement);
- preparedStatement.setQueryTimeout(10);
- expect(preparedStatement.executeUpdate()).andThrow(new SQLException());
- preparedStatement.close();
-
- replay(connection, metaData, statement, preparedStatement, resultSet);
-
- boolean lockAquired = lock.lock();
-
- verify(connection, metaData, statement, preparedStatement, resultSet);
- assertFalse(lockAquired);
- }
-
- @Test
- public void lockShouldReturnFalseIfTheRowIsAlreadyLocked() throws Exception {
- initShouldNotCreateTheSchemaIfItAlreadyExists();
- reset(connection, metaData, statement, preparedStatement, resultSet);
-
- expect(connection.isClosed()).andReturn(false);
- expect(connection.prepareStatement("SELECT * FROM " + tableName + " FOR UPDATE")).andReturn(preparedStatement);
- preparedStatement.setQueryTimeout(10);
- expect(preparedStatement.execute()).andReturn(true);
- preparedStatement.close();
- expect(connection.isClosed()).andReturn(false);
- expect(connection.prepareStatement("UPDATE " + tableName + " SET MOMENT = 1")).andReturn(preparedStatement);
- preparedStatement.setQueryTimeout(10);
- expect(preparedStatement.executeUpdate()).andThrow(new SQLException());
- preparedStatement.close();
-
- replay(connection, metaData, statement, preparedStatement, resultSet);
-
- boolean lockAquired = lock.lock();
-
- verify(connection, metaData, statement, preparedStatement, resultSet);
- assertFalse(lockAquired);
- }
-
- @Test
- public void release() throws Exception {
- initShouldNotCreateTheSchemaIfItAlreadyExists();
- reset(connection, metaData, statement, preparedStatement, resultSet);
-
- expect(connection.isClosed()).andReturn(false);
- expect(connection.isClosed()).andReturn(false);
- expect(connection.isClosed()).andReturn(false);
- connection.rollback();
- connection.close();
-
- replay(connection, metaData, statement, preparedStatement, resultSet);
-
- lock.release();
-
- verify(connection, metaData, statement, preparedStatement, resultSet);
- }
-
- @Test
- public void releaseShouldSucceedForAnAlreadyClosedConnection() throws Exception {
- initShouldNotCreateTheSchemaIfItAlreadyExists();
- reset(connection, metaData, statement, preparedStatement, resultSet);
-
- expect(connection.isClosed()).andReturn(true);
-
- replay(connection, metaData, statement, preparedStatement, resultSet);
-
- lock.release();
-
- verify(connection, metaData, statement, preparedStatement, resultSet);
- }
-
- @Test
- public void releaseShouldSucceedForANullConnectionReference() throws Exception {
- initShouldNotCreateTheSchemaIfItAlreadyExists();
- reset(connection, metaData, statement, preparedStatement, resultSet);
-
- lock.lockConnection = null;
-
- replay(connection, metaData, statement, preparedStatement, resultSet);
-
- lock.release();
-
- verify(connection, metaData, statement, preparedStatement, resultSet);
- }
-
- @Test
- public void isAliveShouldReturnTrueIfItHoldsTheLock() throws Exception {
- initShouldNotCreateTheSchemaIfItAlreadyExists();
- reset(connection, metaData, statement, preparedStatement, resultSet);
-
- expect(connection.isClosed()).andReturn(false);
- expect(connection.isClosed()).andReturn(false);
- expect(connection.prepareStatement("UPDATE " + tableName + " SET MOMENT = 1")).andReturn(preparedStatement);
- preparedStatement.setQueryTimeout(10);
- expect(preparedStatement.executeUpdate()).andReturn(1);
- preparedStatement.close();
-
- replay(connection, metaData, statement, preparedStatement, resultSet);
-
- boolean alive = lock.isAlive();
-
- verify(connection, metaData, statement, preparedStatement, resultSet);
- assertTrue(alive);
- }
-
- @Test
- public void isAliveShouldReturnFalseIfTheConnectionIsClosed() throws Exception {
- initShouldNotCreateTheSchemaIfItAlreadyExists();
- reset(connection, metaData, statement, preparedStatement, resultSet);
-
- expect(connection.isClosed()).andReturn(true);
-
- replay(connection, metaData, statement, preparedStatement, resultSet);
-
- boolean alive = lock.isAlive();
-
- verify(connection, metaData, statement, preparedStatement, resultSet);
- assertFalse(alive);
- }
-
- @Test
- public void isAliveShouldReturnFalseIfTheConnectionIsNull() throws Exception {
- initShouldNotCreateTheSchemaIfItAlreadyExists();
- reset(connection, metaData, statement, preparedStatement, resultSet);
-
- lock.lockConnection = null;
-
- replay(connection, metaData, statement, preparedStatement, resultSet);
-
- boolean alive = lock.isAlive();
-
- verify(connection, metaData, statement, preparedStatement, resultSet);
- assertFalse(alive);
- }
-
- @Test
- public void isAliveShouldReturnFalseIfItNotHoldsTheLock() throws Exception {
- initShouldNotCreateTheSchemaIfItAlreadyExists();
- reset(connection, metaData, statement, preparedStatement, resultSet);
-
- expect(connection.isClosed()).andReturn(false);
- expect(connection.isClosed()).andReturn(false);
- expect(connection.prepareStatement("UPDATE " + tableName + " SET MOMENT = 1")).andReturn(preparedStatement);
- preparedStatement.setQueryTimeout(10);
- expect(preparedStatement.executeUpdate()).andThrow(new SQLException());
- preparedStatement.close();
-
- replay(connection, metaData, statement, preparedStatement, resultSet);
-
- boolean alive = lock.isAlive();
-
- verify(connection, metaData, statement, preparedStatement, resultSet);
- assertFalse(alive);
- }
-}
\ No newline at end of file
diff --git a/karaf/main/src/test/java/org/apache/felix/karaf/main/DefaultJDBCLockIntegrationTest.java b/karaf/main/src/test/java/org/apache/felix/karaf/main/DefaultJDBCLockIntegrationTest.java
deleted file mode 100644
index c2d586d..0000000
--- a/karaf/main/src/test/java/org/apache/felix/karaf/main/DefaultJDBCLockIntegrationTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.Properties;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-
-@Ignore
-public class DefaultJDBCLockIntegrationTest extends BaseJDBCLockIntegrationTest {
-
- @Before
- @Override
- public void setUp() throws Exception {
- password = "root";
- driver = "org.apache.derby.jdbc.ClientDriver";
- url = "jdbc:derby://127.0.0.1:1527/test";
-
- super.setUp();
- }
-
- @Override
- DefaultJDBCLock createLock(Properties props) {
- return new DefaultJDBCLock(props);
- }
-
- @Test
- public void initShouldCreateTheDatabaseIfItNotExists() throws Exception {
- String database = "test" + System.currentTimeMillis();
- url = "jdbc:derby://127.0.0.1:1527/" + database;
- props.put("karaf.lock.jdbc.url", url);
- lock = createLock(props);
- lock.lock();
-
- assertTrue(lock.lockConnection.getMetaData().getURL().contains(database));
- }
-}
\ No newline at end of file
diff --git a/karaf/main/src/test/java/org/apache/felix/karaf/main/DefaultJDBCLockTest.java b/karaf/main/src/test/java/org/apache/felix/karaf/main/DefaultJDBCLockTest.java
deleted file mode 100644
index 101aa20..0000000
--- a/karaf/main/src/test/java/org/apache/felix/karaf/main/DefaultJDBCLockTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import static org.junit.Assert.assertEquals;
-
-import java.sql.Connection;
-import java.util.Properties;
-
-import org.junit.Before;
-import org.junit.Test;
-
-
-public class DefaultJDBCLockTest extends BaseJDBCLockTest {
-
- @Before
- @Override
- public void setUp() throws Exception {
- password = "root";
- driver = "org.apache.derby.jdbc.ClientDriver";
- url = "jdbc:derby://127.0.0.1:1527/test";
-
- super.setUp();
- }
-
- DefaultJDBCLock createLock(Properties props) {
- return new DefaultJDBCLock(props) {
- @Override
- Connection doCreateConnection(String driver, String url, String username, String password) {
- assertEquals(this.driver, driver);
- assertEquals(this.url + ";create=true", url);
- assertEquals(this.user, username);
- assertEquals(this.password, password);
- return connection;
- }
-
- @Override
- long getCurrentTimeMillis() {
- return 1;
- }
- };
- }
-
- @Test
- public void createConnectionShouldConcatinateOptionsCorrect() {
- props.put("karaf.lock.jdbc.url", this.url + ";dataEncryption=false");
-
- lock = new DefaultJDBCLock(props) {
- @Override
- Connection doCreateConnection(String driver, String url, String username, String password) {
- assertEquals(this.driver, driver);
- assertEquals(this.url + ";create=true", url);
- assertEquals(this.user, username);
- assertEquals(this.password, password);
- return connection;
- }
-
- @Override
- long getCurrentTimeMillis() {
- return 1;
- }
- };
- }
-}
\ No newline at end of file
diff --git a/karaf/main/src/test/java/org/apache/felix/karaf/main/DerbyJDBCLockIntegrationTest.java b/karaf/main/src/test/java/org/apache/felix/karaf/main/DerbyJDBCLockIntegrationTest.java
deleted file mode 100644
index d176edc..0000000
--- a/karaf/main/src/test/java/org/apache/felix/karaf/main/DerbyJDBCLockIntegrationTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.Properties;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-
-@Ignore
-public class DerbyJDBCLockIntegrationTest extends BaseJDBCLockIntegrationTest {
-
- @Before
- @Override
- public void setUp() throws Exception {
- password = "root";
- driver = "org.apache.derby.jdbc.ClientDriver";
- url = "jdbc:derby://127.0.0.1:1527/test";
-
- super.setUp();
- }
-
- @Override
- DefaultJDBCLock createLock(Properties props) {
- return new DerbyJDBCLock(props);
- }
-
- @Test
- public void initShouldCreateTheDatabaseIfItNotExists() throws Exception {
- String database = "test" + System.currentTimeMillis();
- url = "jdbc:derby://127.0.0.1:1527/" + database;
- props.put("karaf.lock.jdbc.url", url);
- lock = createLock(props);
- lock.lock();
-
- assertTrue(lock.lockConnection.getMetaData().getURL().contains(database));
- }
-}
\ No newline at end of file
diff --git a/karaf/main/src/test/java/org/apache/felix/karaf/main/DerbyJDBCLockTest.java b/karaf/main/src/test/java/org/apache/felix/karaf/main/DerbyJDBCLockTest.java
deleted file mode 100644
index 548937f..0000000
--- a/karaf/main/src/test/java/org/apache/felix/karaf/main/DerbyJDBCLockTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import static org.junit.Assert.assertEquals;
-
-import java.sql.Connection;
-import java.util.Properties;
-
-import org.junit.Before;
-import org.junit.Test;
-
-
-public class DerbyJDBCLockTest extends BaseJDBCLockTest {
-
- @Before
- @Override
- public void setUp() throws Exception {
- password = "root";
- driver = "org.apache.derby.jdbc.ClientDriver";
- url = "jdbc:derby://127.0.0.1:1527/test";
-
- super.setUp();
- }
-
- DerbyJDBCLock createLock(Properties props) {
- return new DerbyJDBCLock(props) {
- @Override
- Connection doCreateConnection(String driver, String url, String username, String password) {
- assertEquals(this.driver, driver);
- assertEquals(this.url + ";create=true", url);
- assertEquals(this.user, username);
- assertEquals(this.password, password);
- return connection;
- }
-
- @Override
- long getCurrentTimeMillis() {
- return 1;
- }
- };
- }
-
- @Test
- public void createConnectionShouldConcatinateOptionsCorrect() {
- props.put("karaf.lock.jdbc.url", this.url + ";dataEncryption=false");
-
- lock = new DerbyJDBCLock(props) {
- @Override
- Connection doCreateConnection(String driver, String url, String username, String password) {
- assertEquals(this.driver, driver);
- assertEquals(this.url + ";create=true", url);
- assertEquals(this.user, username);
- assertEquals(this.password, password);
- return connection;
- }
-
- @Override
- long getCurrentTimeMillis() {
- return 1;
- }
- };
- }
-}
\ No newline at end of file
diff --git a/karaf/main/src/test/java/org/apache/felix/karaf/main/MySQLJDBCLockIntegrationTest.java b/karaf/main/src/test/java/org/apache/felix/karaf/main/MySQLJDBCLockIntegrationTest.java
deleted file mode 100644
index 4b5f7ca..0000000
--- a/karaf/main/src/test/java/org/apache/felix/karaf/main/MySQLJDBCLockIntegrationTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-
-import static org.junit.Assert.assertFalse;
-
-import java.sql.Connection;
-import java.util.Properties;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-
-@Ignore
-public class MySQLJDBCLockIntegrationTest extends BaseJDBCLockIntegrationTest {
-
- @Before
- public void setUp() throws Exception {
- driver = "com.mysql.jdbc.Driver";
- url = "jdbc:mysql://127.0.0.1:3306/test";
-
- super.setUp();
- }
-
- @Override
- MySQLJDBCLock createLock(Properties props) {
- return new MySQLJDBCLock(props);
- }
-
- @Test
- public void initShouldCreateTheDatabaseIfItNotExists() throws Exception {
- String database = "test" + System.currentTimeMillis();
-
- try {
- executeStatement("DROP DATABASE " + database);
- } catch (Exception e) {
- // expected if table dosn't exist
- }
-
- url = "jdbc:mysql://127.0.0.1:3306/" + database;
- props.put("karaf.lock.jdbc.url", url);
- lock = createLock(props);
-
-
- // should throw an exeption, if the database doesn't exists
- Connection connection = getConnection("jdbc:mysql://127.0.0.1:3306/" + database, user, password);
- assertFalse(connection.isClosed());
-
- executeStatement("DROP DATABASE " + database);
- close(connection);
- }
-}
\ No newline at end of file
diff --git a/karaf/main/src/test/java/org/apache/felix/karaf/main/MySQLJDBCLockTest.java b/karaf/main/src/test/java/org/apache/felix/karaf/main/MySQLJDBCLockTest.java
deleted file mode 100644
index 112701a..0000000
--- a/karaf/main/src/test/java/org/apache/felix/karaf/main/MySQLJDBCLockTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import static org.junit.Assert.assertEquals;
-
-import java.sql.Connection;
-import java.util.Properties;
-
-import org.junit.Before;
-import org.junit.Test;
-
-
-public class MySQLJDBCLockTest extends BaseJDBCLockTest {
-
- @Before
- @Override
- public void setUp() throws Exception {
- driver = "com.mysql.jdbc.Driver";
- url = "jdbc:mysql://127.0.0.1:3306/test";
- createTableStmtSuffix = " ENGINE=INNODB";
-
- super.setUp();
- }
-
- MySQLJDBCLock createLock(Properties props) {
- return new MySQLJDBCLock(props) {
- @Override
- Connection doCreateConnection(String driver, String url, String username, String password) {
- assertEquals(this.driver, driver);
- assertEquals(this.url + "?createDatabaseIfNotExist=true", url);
- assertEquals(this.user, username);
- assertEquals(this.password, password);
- return connection;
- }
-
- @Override
- long getCurrentTimeMillis() {
- return 1;
- }
- };
- }
-
- @Test
- public void createConnectionShouldConcatinateOptionsCorrect() {
- props.put("karaf.lock.jdbc.url", this.url + "?connectTimeout=10000");
-
- lock = new MySQLJDBCLock(props) {
- @Override
- Connection doCreateConnection(String driver, String url, String username, String password) {
- assertEquals(this.driver, driver);
- assertEquals(this.url + "&createDatabaseIfNotExist=true", url);
- assertEquals(this.user, username);
- assertEquals(this.password, password);
- return connection;
- }
-
- @Override
- long getCurrentTimeMillis() {
- return 1;
- }
- };
- }
-}
\ No newline at end of file
diff --git a/karaf/main/src/test/java/org/apache/felix/karaf/main/OracleJDBCLockIntegrationTest.java b/karaf/main/src/test/java/org/apache/felix/karaf/main/OracleJDBCLockIntegrationTest.java
deleted file mode 100644
index 08bacc2..0000000
--- a/karaf/main/src/test/java/org/apache/felix/karaf/main/OracleJDBCLockIntegrationTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Properties;
-
-import org.junit.Before;
-import org.junit.Ignore;
-
-
-@Ignore
-public class OracleJDBCLockIntegrationTest extends BaseJDBCLockIntegrationTest {
-
- @Before
- @Override
- public void setUp() throws Exception {
- password = "root";
- driver = "oracle.jdbc.driver.OracleDriver";
- url = "jdbc:oracle:thin:@172.16.16.133:1521:XE";
- momentDatatype = "NuMBER(20)";
-
- super.setUp();
- }
-
- OracleJDBCLock createLock(Properties props) {
- return new OracleJDBCLock(props);
- }
-
- @Override
- Connection lock(String table, String node) throws ClassNotFoundException, SQLException {
- Connection connection = null;
- Statement statement = null;
-
- try {
- connection = getConnection(url, user, password);
- statement = connection.createStatement();
- statement.execute("SELECT * FROM " + table + " FOR UPDATE");
- } finally {
- close(statement);
- // connection must not be closed!
- }
-
- return connection;
- }
-}
\ No newline at end of file
diff --git a/karaf/main/src/test/java/org/apache/felix/karaf/main/OracleJDBCLockTest.java b/karaf/main/src/test/java/org/apache/felix/karaf/main/OracleJDBCLockTest.java
deleted file mode 100644
index c4c96d8..0000000
--- a/karaf/main/src/test/java/org/apache/felix/karaf/main/OracleJDBCLockTest.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.*;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Properties;
-
-import org.junit.Before;
-import org.junit.Test;
-
-
-public class OracleJDBCLockTest extends BaseJDBCLockTest {
-
- @Before
- @Override
- public void setUp() throws Exception {
- password = "root";
- driver = "oracle.jdbc.driver.OracleDriver";
- url = "jdbc:oracle:thin:@172.16.16.132:1521:XE";
- momentDatatype = "NUMBER(20)";
-
- super.setUp();
- }
-
- OracleJDBCLock createLock(Properties props) {
- return new OracleJDBCLock(props) {
- @Override
- Connection doCreateConnection(String driver, String url, String username, String password) {
- assertEquals(this.driver, driver);
- assertEquals(this.url, url);
- assertEquals(this.user, username);
- assertEquals(this.password, password);
- return connection;
- }
-
- @Override
- long getCurrentTimeMillis() {
- return 1;
- }
- };
- }
-
- @Test
- @Override
- public void lockShouldReturnTrueItTheTableIsNotLocked() throws Exception {
- initShouldNotCreateTheSchemaIfItAlreadyExists();
- reset(connection, metaData, statement, preparedStatement, resultSet);
-
- expect(connection.isClosed()).andReturn(false);
- expect(connection.prepareStatement("SELECT * FROM " + tableName + " FOR UPDATE")).andReturn(preparedStatement);
- preparedStatement.setQueryTimeout(10);
- expect(preparedStatement.execute()).andReturn(true);
- preparedStatement.close();
-
- replay(connection, metaData, statement, preparedStatement, resultSet);
-
- boolean lockAquired = lock.lock();
-
- verify(connection, metaData, statement, preparedStatement, resultSet);
- assertTrue(lockAquired);
- }
-
- @Test
- @Override
- public void lockShouldReturnFalseIfAnotherRowIsLocked() throws Exception {
- initShouldNotCreateTheSchemaIfItAlreadyExists();
- reset(connection, metaData, statement, preparedStatement, resultSet);
-
- expect(connection.isClosed()).andReturn(false);
- expect(connection.prepareStatement("SELECT * FROM " + tableName + " FOR UPDATE")).andReturn(preparedStatement);
- preparedStatement.setQueryTimeout(10);
- expect(preparedStatement.execute()).andThrow(new SQLException());
- preparedStatement.close();
-
- replay(connection, metaData, statement, preparedStatement, resultSet);
-
- boolean lockAquired = lock.lock();
-
- verify(connection, metaData, statement, preparedStatement, resultSet);
- assertFalse(lockAquired);
- }
-
- @Test
- @Override
- public void lockShouldReturnFalseIfTheRowIsAlreadyLocked() throws Exception {
- initShouldNotCreateTheSchemaIfItAlreadyExists();
- reset(connection, metaData, statement, preparedStatement, resultSet);
-
- expect(connection.isClosed()).andReturn(false);
- expect(connection.prepareStatement("SELECT * FROM " + tableName + " FOR UPDATE")).andReturn(preparedStatement);
- preparedStatement.setQueryTimeout(10);
- expect(preparedStatement.execute()).andThrow(new SQLException());
- preparedStatement.close();
-
- replay(connection, metaData, statement, preparedStatement, resultSet);
-
- boolean lockAquired = lock.lock();
-
- verify(connection, metaData, statement, preparedStatement, resultSet);
- assertFalse(lockAquired);
- }
-
- @Test
- public void isAliveShouldReturnTrueIfItHoldsTheLock() throws Exception {
- initShouldNotCreateTheSchemaIfItAlreadyExists();
- reset(connection, metaData, statement, preparedStatement, resultSet);
-
- expect(connection.isClosed()).andReturn(false);
- expect(connection.isClosed()).andReturn(false);
- expect(connection.prepareStatement("SELECT * FROM " + tableName + " FOR UPDATE")).andReturn(preparedStatement);
- preparedStatement.setQueryTimeout(10);
- expect(preparedStatement.execute()).andReturn(true);
- preparedStatement.close();
-
- replay(connection, metaData, statement, preparedStatement, resultSet);
-
- boolean alive = lock.isAlive();
-
- verify(connection, metaData, statement, preparedStatement, resultSet);
- assertTrue(alive);
- }
-
- @Test
- public void isAliveShouldReturnFalseIfItNotHoldsTheLock() throws Exception {
- initShouldNotCreateTheSchemaIfItAlreadyExists();
- reset(connection, metaData, statement, preparedStatement, resultSet);
-
- expect(connection.isClosed()).andReturn(false);
- expect(connection.isClosed()).andReturn(false);
- expect(connection.prepareStatement("SELECT * FROM " + tableName + " FOR UPDATE")).andReturn(preparedStatement);
- preparedStatement.setQueryTimeout(10);
- expect(preparedStatement.execute()).andThrow(new SQLException());
- preparedStatement.close();
-
- replay(connection, metaData, statement, preparedStatement, resultSet);
-
- boolean alive = lock.isAlive();
-
- verify(connection, metaData, statement, preparedStatement, resultSet);
- assertFalse(alive);
- }
-}
\ No newline at end of file
diff --git a/karaf/main/src/test/java/org/apache/felix/karaf/main/StatementsTest.java b/karaf/main/src/test/java/org/apache/felix/karaf/main/StatementsTest.java
deleted file mode 100644
index 87e31a8..0000000
--- a/karaf/main/src/test/java/org/apache/felix/karaf/main/StatementsTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import static org.junit.Assert.*;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class StatementsTest {
-
- private static final String DEFAULT_CREATE_TABLE_STMT = "CREATE TABLE KARAF_LOCK (MOMENT BIGINT, NODE VARCHAR(20))";
- private static final String DEFAULT_POPULATE_TABLE_STMT = "INSERT INTO KARAF_LOCK (MOMENT, NODE) VALUES (1, 'karaf')";
-
- private Statements statements;
-
- @Before
- public void setUp() {
- statements = new Statements();
- }
-
- @Test
- public void getDefaultLockCreateSchemaStatements() {
- assertArrayEquals(new String[] {DEFAULT_CREATE_TABLE_STMT, DEFAULT_POPULATE_TABLE_STMT}, statements.getLockCreateSchemaStatements(1));
- }
-
- @Test
- public void getCustomLockCreateSchemaStatements() {
- customizeStatements();
- String[] expectedCreateSchemaStmts = new String[] {
- "CREATE TABLE test.LOCK_TABLE (MOMENT NUMBER(20), NODE VARCHAR2(30))",
- "INSERT INTO test.LOCK_TABLE (MOMENT, NODE) VALUES (2, 'node_1')"};
-
- assertArrayEquals(expectedCreateSchemaStmts, statements.getLockCreateSchemaStatements(2));
- }
-
- @Test
- public void getDefaultLockCreateStatement() {
- assertEquals("SELECT * FROM KARAF_LOCK FOR UPDATE", statements.getLockCreateStatement());
- }
-
- @Test
- public void getCustomLockCreateStatement() {
- customizeStatements();
-
- assertEquals("SELECT * FROM test.LOCK_TABLE FOR UPDATE", statements.getLockCreateStatement());
- }
-
- @Test
- public void getDefaultLockUpdateStatement() {
- assertEquals("UPDATE KARAF_LOCK SET MOMENT = 1", statements.getLockUpdateStatement(1));
- }
-
- @Test
- public void getCustomLockUpdateStatement() {
- customizeStatements();
-
- assertEquals("UPDATE test.LOCK_TABLE SET MOMENT = 2", statements.getLockUpdateStatement(2));
- }
-
- private void customizeStatements() {
- statements.setTablePrefix("test.");
- statements.setTableName("LOCK_TABLE");
- statements.setNodeName("node_1");
- statements.setMomentColumnDataType("NUMBER(20)");
- statements.setNodeColumnDataType("VARCHAR2(30)");
- }
-}
\ No newline at end of file
diff --git a/karaf/main/src/test/java/org/apache/felix/karaf/main/StringMapTest.java b/karaf/main/src/test/java/org/apache/felix/karaf/main/StringMapTest.java
deleted file mode 100644
index 9ce6389..0000000
--- a/karaf/main/src/test/java/org/apache/felix/karaf/main/StringMapTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.main;
-
-import junit.framework.TestCase;
-
-/**
- * Test cased for {@link org.apache.felix.karaf.main.StringMap}
- */
-public class StringMapTest extends TestCase {
-
- public void testPut() throws Exception {
- StringMap sm = new StringMap();
- Object key = new String("key");
- Object value = new String("value");
- sm.put(key, value);
- Object result = sm.get(key);
- assertFalse(result == null);
- assertTrue(result.equals(value));
- }
-
-}
diff --git a/karaf/management/NOTICE b/karaf/management/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/management/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/management/pom.xml b/karaf/management/pom.xml
deleted file mode 100644
index 5c62e99..0000000
--- a/karaf/management/pom.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-<?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/maven-v4_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.felix.karaf</groupId>
- <artifactId>karaf</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>org.apache.felix.karaf.management</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Management</name>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymockclassextension</artifactId>
- <version>${easymock.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Import-Package>
- !${project.artifactId}*,
- javax.management,
- *
- </Import-Package>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-
-</project>
diff --git a/karaf/management/src/main/java/org/apache/felix/karaf/management/ConnectorServerFactory.java b/karaf/management/src/main/java/org/apache/felix/karaf/management/ConnectorServerFactory.java
deleted file mode 100644
index 4ab9f39..0000000
--- a/karaf/management/src/main/java/org/apache/felix/karaf/management/ConnectorServerFactory.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.management;
-
-import java.io.IOException;
-import java.util.Map;
-
-import javax.management.JMException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-public class ConnectorServerFactory {
-
- private MBeanServer server;
- private String serviceUrl;
- private Map environment;
- private ObjectName objectName;
- private boolean threaded = false;
- private boolean daemon = false;
- private JMXConnectorServer connectorServer;
-
- public MBeanServer getServer() {
- return server;
- }
-
- public void setServer(MBeanServer server) {
- this.server = server;
- }
-
- public String getServiceUrl() {
- return serviceUrl;
- }
-
- public void setServiceUrl(String serviceUrl) {
- this.serviceUrl = serviceUrl;
- }
-
- public Map getEnvironment() {
- return environment;
- }
-
- public void setEnvironment(Map environment) {
- this.environment = environment;
- }
-
- public ObjectName getObjectName() {
- return objectName;
- }
-
- public void setObjectName(ObjectName objectName) {
- this.objectName = objectName;
- }
-
- public boolean isThreaded() {
- return threaded;
- }
-
- public void setThreaded(boolean threaded) {
- this.threaded = threaded;
- }
-
- public boolean isDaemon() {
- return daemon;
- }
-
- public void setDaemon(boolean daemon) {
- this.daemon = daemon;
- }
-
- public void init() throws Exception {
- if (this.server == null) {
- throw new IllegalArgumentException("server must be set");
- }
- JMXServiceURL url = new JMXServiceURL(this.serviceUrl);
- this.connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, this.environment, this.server);
- if (this.objectName != null) {
- this.server.registerMBean(this.connectorServer, this.objectName);
- }
- try {
- if (this.threaded) {
- Thread connectorThread = new Thread() {
- public void run() {
- try {
- connectorServer.start();
- } catch (IOException ex) {
- throw new RuntimeException("Could not start JMX connector server", ex);
- }
- }
- };
- connectorThread.setName("JMX Connector Thread [" + this.serviceUrl + "]");
- connectorThread.setDaemon(this.daemon);
- connectorThread.start();
- }
- else {
- this.connectorServer.start();
- }
- } catch (Exception ex) {
- doUnregister(this.objectName);
- throw ex;
- }
- }
-
- public void destroy() throws Exception {
- try {
- this.connectorServer.stop();
- } finally {
- doUnregister(this.objectName);
- }
- }
-
- protected void doUnregister(ObjectName objectName) {
- try {
- if (this.objectName != null && this.server.isRegistered(objectName)) {
- this.server.unregisterMBean(objectName);
- }
- }
- catch (JMException ex) {
- // Ignore
- }
- }
-}
diff --git a/karaf/management/src/main/java/org/apache/felix/karaf/management/JaasAuthenticator.java b/karaf/management/src/main/java/org/apache/felix/karaf/management/JaasAuthenticator.java
deleted file mode 100644
index a3897ed..0000000
--- a/karaf/management/src/main/java/org/apache/felix/karaf/management/JaasAuthenticator.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.management;
-
-import java.io.IOException;
-
-import javax.management.remote.JMXAuthenticator;
-import javax.security.auth.Subject;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.NameCallback;
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-
-public class JaasAuthenticator implements JMXAuthenticator {
-
- private String realm;
-
- public String getRealm() {
- return realm;
- }
-
- public void setRealm(String realm) {
- this.realm = realm;
- }
-
- public Subject authenticate(Object credentials) throws SecurityException {
- if (!(credentials instanceof String[])) {
- throw new IllegalArgumentException("Expected String[2], got "
- + (credentials != null ? credentials.getClass().getName() : null));
- }
- final String[] params = (String[]) credentials;
- if (params.length != 2) {
- throw new IllegalArgumentException("Expected String[2] but length was " + params.length);
- }
- try {
- LoginContext loginContext = new LoginContext(realm, new CallbackHandler() {
- public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
- for (int i = 0; i < callbacks.length; i++) {
- if (callbacks[i] instanceof NameCallback) {
- ((NameCallback) callbacks[i]).setName(params[0]);
- } else if (callbacks[i] instanceof PasswordCallback) {
- ((PasswordCallback) callbacks[i]).setPassword((params[1].toCharArray()));
- } else {
- throw new UnsupportedCallbackException(callbacks[i]);
- }
- }
- }
- });
- loginContext.login();
- return loginContext.getSubject();
- } catch (LoginException e) {
- throw new SecurityException("Authentication failed", e);
- }
- }
-}
diff --git a/karaf/management/src/main/java/org/apache/felix/karaf/management/MBeanRegistrer.java b/karaf/management/src/main/java/org/apache/felix/karaf/management/MBeanRegistrer.java
deleted file mode 100644
index 10645c6..0000000
--- a/karaf/management/src/main/java/org/apache/felix/karaf/management/MBeanRegistrer.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.management;
-
-import java.util.Map;
-
-import javax.management.JMException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-public class MBeanRegistrer {
-
- private MBeanServer mbeanServer;
-
- private Map<Object, String> mbeans;
-
- public void setMbeans(Map<Object, String> mbeans) {
- this.mbeans = mbeans;
- }
-
- public void registerMBeanServer(MBeanServer mbeanServer) throws JMException {
- if (this.mbeanServer != mbeanServer) {
- unregisterMBeans();
- }
- this.mbeanServer = mbeanServer;
- registerMBeans();
- }
-
- public void unregisterMBeanServer(MBeanServer mbeanServer) throws JMException {
- unregisterMBeans();
- this.mbeanServer = null;
- }
-
- public void init() throws Exception {
- registerMBeans();
- }
-
- protected void registerMBeans() throws JMException {
- if (mbeanServer != null && mbeans != null) {
- for (Map.Entry<Object, String> entry : mbeans.entrySet()) {
- String value = parseProperty(entry.getValue());
- mbeanServer.registerMBean(entry.getKey(), new ObjectName(value));
- }
- }
- }
-
- protected void unregisterMBeans() throws JMException {
- if (mbeanServer != null && mbeans != null) {
- for (Map.Entry<Object, String> entry : mbeans.entrySet()) {
- String value = parseProperty(entry.getValue());
- mbeanServer.unregisterMBean(new ObjectName(value));
- }
- }
- }
-
- protected String parseProperty(String raw) {
- if (raw.indexOf("${") > -1 && raw.indexOf("}", raw.indexOf("${")) > -1) {
- String var = raw.substring(raw.indexOf("${") + 2, raw.indexOf("}"));
- String val = System.getProperty(var);
- if (val != null) {
- raw = raw.replace("${" + var + "}", val);
- }
- }
- return raw;
- }
-}
diff --git a/karaf/management/src/main/java/org/apache/felix/karaf/management/MBeanServerFactory.java b/karaf/management/src/main/java/org/apache/felix/karaf/management/MBeanServerFactory.java
deleted file mode 100644
index 6bbc780..0000000
--- a/karaf/management/src/main/java/org/apache/felix/karaf/management/MBeanServerFactory.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.management;
-
-import java.lang.management.ManagementFactory;
-import java.util.List;
-
-import javax.management.MBeanServer;
-
-public class MBeanServerFactory {
-
- private boolean locateExistingServerIfPossible = false;
- private String agentId;
- private String defaultDomain;
- private boolean registerWithFactory = true;
- private MBeanServer server;
- private boolean newlyRegistered = false;
-
- public boolean isLocateExistingServerIfPossible() {
- return locateExistingServerIfPossible;
- }
-
- public void setLocateExistingServerIfPossible(boolean locateExistingServerIfPossible) {
- this.locateExistingServerIfPossible = locateExistingServerIfPossible;
- }
-
- public String getAgentId() {
- return agentId;
- }
-
- public void setAgentId(String agentId) {
- this.agentId = agentId;
- }
-
- public String getDefaultDomain() {
- return defaultDomain;
- }
-
- public void setDefaultDomain(String defaultDomain) {
- this.defaultDomain = defaultDomain;
- }
-
- public boolean isRegisterWithFactory() {
- return registerWithFactory;
- }
-
- public void setRegisterWithFactory(boolean registerWithFactory) {
- this.registerWithFactory = registerWithFactory;
- }
-
- public boolean isNewlyRegistered() {
- return newlyRegistered;
- }
-
- public void setNewlyRegistered(boolean newlyRegistered) {
- this.newlyRegistered = newlyRegistered;
- }
-
- public MBeanServer getServer() throws Exception {
- if (this.server == null) {
- init();
- }
- return server;
- }
-
- public void init() throws Exception {
- if (this.locateExistingServerIfPossible || this.agentId != null) {
- try {
- List servers = javax.management.MBeanServerFactory.findMBeanServer(agentId);
- MBeanServer server = null;
- if (servers != null && servers.size() > 0) {
- this.server = (MBeanServer) servers.get(0);
- }
- if (server == null && agentId == null) {
- this.server = ManagementFactory.getPlatformMBeanServer();
- }
- if (this.server == null) {
- throw new Exception("Unable to locate MBeanServer");
- }
- } catch (Exception ex) {
- if (this.agentId != null) {
- throw ex;
- }
- }
- }
- if (this.server == null) {
- if (this.registerWithFactory) {
- this.server = javax.management.MBeanServerFactory.createMBeanServer(this.defaultDomain);
- } else {
- this.server = javax.management.MBeanServerFactory.newMBeanServer(this.defaultDomain);
- }
- this.newlyRegistered = this.registerWithFactory;
- }
- }
-
- public void destroy() throws Exception {
- if (this.newlyRegistered) {
- javax.management.MBeanServerFactory.releaseMBeanServer(this.server);
- }
- }
-
-}
diff --git a/karaf/management/src/main/java/org/apache/felix/karaf/management/RmiRegistryFactory.java b/karaf/management/src/main/java/org/apache/felix/karaf/management/RmiRegistryFactory.java
deleted file mode 100644
index 640789a..0000000
--- a/karaf/management/src/main/java/org/apache/felix/karaf/management/RmiRegistryFactory.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.management;
-
-import java.rmi.RemoteException;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
-import java.rmi.server.UnicastRemoteObject;
-
-/**
- *
- * @author gnodet
- */
-public class RmiRegistryFactory {
-
- private int port = Registry.REGISTRY_PORT;
- private Registry registry;
- private boolean locate;
- private boolean create = true;
- private boolean locallyCreated;
-
- /**
- * @return the create
- */
- public boolean isCreate() {
- return create;
- }
-
- /**
- * @param create the create to set
- */
- public void setCreate(boolean create) {
- this.create = create;
- }
-
- /**
- * @return the locate
- */
- public boolean isLocate() {
- return locate;
- }
-
- /**
- * @param locate the locate to set
- */
- public void setLocate(boolean locate) {
- this.locate = locate;
- }
-
- /**
- * @return the port
- */
- public int getPort() {
- return port;
- }
-
- /**
- * @param port the port to set
- */
- public void setPort(int port) {
- this.port = port;
- }
-
- public Object getObject() throws Exception {
- return registry;
- }
-
- public void init() throws RemoteException {
- if (registry == null && locate) {
- try {
- Registry reg = LocateRegistry.getRegistry(getPort());
- reg.list();
- registry = reg;
- } catch (RemoteException e) {
- // ignore
- }
- }
- if (registry == null && create) {
- registry = LocateRegistry.createRegistry(getPort());
- locallyCreated = true;
- }
- }
-
- public void destroy() throws RemoteException {
- if (registry != null && locallyCreated) {
- Registry reg = registry;
- registry = null;
- UnicastRemoteObject.unexportObject(reg, true);
- }
- }
-
-}
diff --git a/karaf/management/src/main/resources/OSGI-INF/blueprint/karaf-management.xml b/karaf/management/src/main/resources/OSGI-INF/blueprint/karaf-management.xml
deleted file mode 100644
index 49294b9..0000000
--- a/karaf/management/src/main/resources/OSGI-INF/blueprint/karaf-management.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
- xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
-
- <!-- Allow the use of system properties -->
- <ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"/>
-
- <!-- Property place holder -->
- <cm:property-placeholder persistent-id="org.apache.felix.karaf.management">
- <cm:default-properties>
- <cm:property name="rmiRegistryPort" value="1099"/>
- <cm:property name="jmxRealm" value="karaf"/>
- <cm:property name="serviceUrl" value="service:jmx:rmi:///jndi/rmi://localhost:1099/karaf-$[karaf.name]"/>
- <cm:property name="daemon" value="true"/>
- <cm:property name="threaded" value="true"/>
- <cm:property name="objectName" value="connector:name=rmi"/>
- </cm:default-properties>
- </cm:property-placeholder>
-
- <!-- MBeanServer bean -->
- <bean id="mbeanServerFactory" class="org.apache.felix.karaf.management.MBeanServerFactory" init-method="init"
- destroy-method="destroy" depends-on="rmiRegistryFactory">
- <property name="locateExistingServerIfPossible" value="true"/>
- </bean>
- <bean id="mbeanServer" factory-ref="mbeanServerFactory" factory-method="getServer"/>
-
- <!-- Export the MBeanServer as an OSGi service -->
- <service ref="mbeanServer" interface="javax.management.MBeanServer"/>
-
- <!-- Create a RMI registry -->
- <bean id="rmiRegistryFactory" class="org.apache.felix.karaf.management.RmiRegistryFactory" init-method="init"
- destroy-method="destroy">
- <property name="create" value="true"/>
- <property name="locate" value="true"/>
- <property name="port" value="${rmiRegistryPort}"/>
- </bean>
-
- <!-- Create a JMX connector ServiceFactory -->
- <bean id="connectorFactory" class="org.apache.felix.karaf.management.ConnectorServerFactory" init-method="init"
- destroy-method="destroy">
- <property name="server" ref="mbeanServer"/>
- <property name="serviceUrl" value="${serviceUrl}"/>
- <property name="daemon" value="${daemon}"/>
- <property name="threaded" value="${threaded}"/>
- <property name="objectName" value="${objectName}"/>
- <property name="environment">
- <map>
- <entry key="jmx.remote.authenticator" value-ref="jaasAuthenticator"/>
- </map>
- </property>
- </bean>
-
- <!-- JAAS authenticator -->
- <bean id="jaasAuthenticator" class="org.apache.felix.karaf.management.JaasAuthenticator">
- <property name="realm" value="${jmxRealm}"/>
- </bean>
-
-</blueprint>
-
diff --git a/karaf/management/src/main/resources/OSGI-INF/metatype/metatype.properties b/karaf/management/src/main/resources/OSGI-INF/metatype/metatype.properties
deleted file mode 100644
index 2869f52..0000000
--- a/karaf/management/src/main/resources/OSGI-INF/metatype/metatype.properties
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-#
-# This file contains localization strings for configuration labels and
-# descriptions as used in the metatype.xml descriptor
-
-management.name = Apache Felix Karaf JMX Management
-management.description = Configuration of Apache Felix Karaf JMX Management
-
-rmiRegistryPort.name = RMI Port
-rmiRegistryPort.description = port of the registry for the exported RMI service
-
-jmxRealm.name = Realm
-jmxRealm.description = name of the JAAS realm used for authentication
-
-serviceUrl.name = Service Url
-serviceUrl.description = the service URL for the JMXConnectorServer
-
-daemon.name = Daemon
-daemon.description = whether any threads started for the JMXConnectorServer should be started as daemon threads
-
-threaded.name = Threaded
-threaded.description = whether the JMXConnectorServer should be started in a separate thread
-
-objectName.name = ObjectName
-objectName.description = the ObjectName used to register the JMXConnectorServer
-
diff --git a/karaf/management/src/main/resources/OSGI-INF/metatype/metatype.xml b/karaf/management/src/main/resources/OSGI-INF/metatype/metatype.xml
deleted file mode 100644
index e8d4bbd..0000000
--- a/karaf/management/src/main/resources/OSGI-INF/metatype/metatype.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0" localization="OSGI-INF/metatype/metatype">
- <OCD id="org.apache.felix.karaf.management" name="%management.name" description="%management.description">
- <AD id="rmiRegistryPort" type="Integer" default="1099" name="%rmiRegistryPort.name"
- description="%rmiRegistryPort.description"/>
- <AD id="jmxRealm" type="String" default="karaf" name="%jmxRealm.name"
- description="%jmxRealm.description"/>
- <AD id="serviceUrl" type="String" default="service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi" name="%serviceUrl.name"
- description="%serviceUrl.description"/>
- <AD id="daemon" type="Boolean" default="true" name="%daemon.name" description="%daemon.description"/>
- <AD id="threaded" type="Boolean" default="true" name="%threaded.name" description="%threaded.description"/>
- <AD id="objectName" type="String" default="connector:name=rmi" name="%objectName.name" description="%objectName.description"/>
- </OCD>
- <Designate pid="org.apache.felix.karaf.management">
- <Object ocdref="org.apache.felix.karaf.management"/>
- </Designate>
-</metatype:MetaData>
diff --git a/karaf/management/src/test/configs/factories/management.properties b/karaf/management/src/test/configs/factories/management.properties
deleted file mode 100644
index 3887ba8..0000000
--- a/karaf/management/src/test/configs/factories/management.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-service.pid=org.apache.felix.karaf.management.JmxConnectorServiceFactory
-instances=1
-keys=objectName,serviceUrl,threaded,daemon,
-objectName.1=connector:name=rmi
-serviceUrl.1=service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
-threaded.1=true
-daemon.1=true
diff --git a/karaf/management/src/test/configs/services/org.ops4j.pax.logging.properties b/karaf/management/src/test/configs/services/org.ops4j.pax.logging.properties
deleted file mode 100644
index d1f34a6..0000000
--- a/karaf/management/src/test/configs/services/org.ops4j.pax.logging.properties
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-# implied.
-#
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-#
-log4j.rootLogger=DEBUG, out
-
-log4j.logger.org.springframework=DEBUG
-
-# CONSOLE appender not used by default
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
-
-# File appender
-log4j.appender.out=org.apache.log4j.FileAppender
-log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
-log4j.appender.out.file=target/shell.log
-log4j.appender.out.append=true
diff --git a/karaf/management/src/test/java/org/apache/felix/karaf/management/MBeanRegistererTest.java b/karaf/management/src/test/java/org/apache/felix/karaf/management/MBeanRegistererTest.java
deleted file mode 100644
index dc95bdc..0000000
--- a/karaf/management/src/test/java/org/apache/felix/karaf/management/MBeanRegistererTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.management;
-
-import java.util.Map;
-import java.util.HashMap;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import static org.easymock.classextension.EasyMock.*;
-import org.easymock.classextension.IMocksControl;
-
-import junit.framework.TestCase;
-import org.junit.Assert;
-
-public class MBeanRegistererTest extends TestCase {
- public void testRegistration() throws Exception {
- IMocksControl control = createNiceControl();
- MBeanServer mbeanServer = control.createMock(MBeanServer.class);
- String rawName = "org.apache.felix.karaf:type=admin,name=${karaf.name}";
- AdminServiceMBean mbean = control.createMock(AdminServiceMBean.class);
- ObjectName name = new ObjectName("org.apache.felix.karaf:type=admin,name=foobar");
- expect(mbeanServer.registerMBean(isA(AdminServiceMBean.class), eq(name))).andReturn(null);
- mbeanServer.unregisterMBean(eq(name));
- expectLastCall();
- control.replay();
-
- String old = System.getProperty("karaf.name");
- System.setProperty("karaf.name", "foobar");
- MBeanRegistrer registerer = new MBeanRegistrer();
- Map<Object, String> mbeans = new HashMap<Object, String>();
- mbeans.put(mbean, rawName);
- registerer.setMbeans(mbeans);
- registerer.registerMBeanServer(mbeanServer);
- registerer.unregisterMBeanServer(mbeanServer);
-
- restoreProperties(old);
- control.verify();
- }
-
- private void restoreProperties(String old) {
- if (old != null) {
- System.setProperty("karaf.name", old);
- } else {
- System.getProperties().remove("karaf.name");
- }
- }
-
- public static interface AdminServiceMBean {
- int createInstance(String name) throws Exception;
- }
-}
diff --git a/karaf/manual/NOTICE b/karaf/manual/NOTICE
deleted file mode 100644
index b8bf7cd..0000000
--- a/karaf/manual/NOTICE
+++ /dev/null
@@ -1,28 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-The PDF manual has been generated using http://www.princexml.com/
-and contains an attribution which should not be removed by
-licensee.
-
-This product includes software written by
-Hakon Wium Lie and Bert Bos.
-Licensed under the MIT License.
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-III. License Summary
-- Apache License 2.0
-- MIT License
diff --git a/karaf/manual/pom.xml b/karaf/manual/pom.xml
deleted file mode 100644
index 5299a30..0000000
--- a/karaf/manual/pom.xml
+++ /dev/null
@@ -1,145 +0,0 @@
-<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/maven-v4_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.
--->
-
- <parent>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>karaf</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>manual</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- <packaging>pom</packaging>
- <name>Apache Felix Karaf :: Manual</name>
- <description>The Karaf Manual which generates a HTML and PDF representation of the manual.</description>
-
- <properties>
- <must-succeed>false</must-succeed>
-
- <manual.dir>${project.build.directory}/manual</manual.dir>
- <manual>${manual.dir}/manual-${project.version}</manual>
- <svn.root>${project.scm.connection}</svn.root>
- </properties>
-
- <build>
- <plugins>
-
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.2</version>
- <executions>
- <execution>
- <id>preprocess</id>
- <configuration>
- <tasks>
- <taskdef name="if" classname="net.sf.antcontrib.logic.IfTask" classpathref="maven.plugin.classpath" />
- <taskdef name="for" classname="net.sf.antcontrib.logic.ForTask" classpathref="maven.plugin.classpath" />
- <taskdef name="trycatch" classname="net.sf.antcontrib.logic.TryCatchTask" classpathref="maven.plugin.classpath" />
- <property name="ant.regexp.regexpimpl" value="org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp" />
- <mkdir dir="${manual.dir}" />
- <trycatch property="error">
- <try>
- <get src="https://cwiki.apache.org/confluence/display/FELIX/Karaf+Users'+Guide+in+one+page" dest="${manual}.temp" />
- <for list="1,2,3,4,5,6,7,8,9,10" param="letter">
- <sequential>
- <replaceregexp file="${manual}.temp" flags="g" match=""/confluence/display/FELIX/([^"]*)\+([^"+]*)"" replace=""/confluence/display/FELIX/\1\2"" />
- </sequential>
- </for>
- <replaceregexp file="${manual}.temp" flags="g" match=""/confluence/display/FELIX/([^"]*)"" replace=""#KarafUsers%27Guideinonepage-\1"" />
- <replaceregexp file="${manual}.temp" flags="g" match=""/confluence/([^"]*)"" replace=""http://cwiki.apache.org/confluence/\1"" />
- <replaceregexp file="${manual}.temp" flags="g" match=">top</a>" replace="></a>" />
- <java classname="org.ccil.cowan.tagsoup.CommandLine" classpathref="maven.plugin.classpath" fork="true" output="${manual}.temp2" logError="true">
- <arg value="${manual}.temp" />
- </java>
- <xslt in="${manual}.temp2" out="${manual}.html" style="${basedir}/src/xslt/extract.xsl">
- <param name="stylesheet" expression="${basedir}/src/styles/print.css" />
- </xslt>
- <exec executable="prince">
- <arg value="${manual}.html" />
- <arg value="${manual}.pdf" />
- </exec>
- <replace file="${manual}.html" token="${basedir}/src/styles/print.css" value="${svn.root}/src/styles/print.css" />
- <replace file="${manual}.html" token="scm:svn:" value="" />
- </try>
- <catch>
- <if>
- <equals arg1="${must-succeed}" arg2="true" />
- <then>
- <echo>ERROR: ${error}</echo>
- <fail>${error}</fail>
- </then>
- <else>
- <echo>ERROR: ${error}</echo>
- <echo>Falling back to dummy manuals</echo>
- <copy file="src/fallback/manual.html" tofile="${manual}.html" />
- <copy file="src/fallback/manual.pdf" tofile="${manual}.pdf" />
- </else>
- </if>
- </catch>
- </trycatch>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- <phase>generate-resources</phase>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-artifacts</id>
- <phase>package</phase>
- <goals>
- <goal>attach-artifact</goal>
- </goals>
- <configuration>
- <artifacts>
- <artifact>
- <file>${manual}.html</file>
- <type>html</type>
- </artifact>
- <artifact>
- <file>${manual}.pdf</file>
- <type>pdf</type>
- </artifact>
- </artifacts>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>release</id>
- <properties>
- <must-succeed>true</must-succeed>
- </properties>
- </profile>
- </profiles>
-
-</project>
\ No newline at end of file
diff --git a/karaf/manual/src/fallback/manual.html b/karaf/manual/src/fallback/manual.html
deleted file mode 100644
index 4aa3dbd..0000000
--- a/karaf/manual/src/fallback/manual.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<div class="wiki-content">
- Unable to generate manual.
-</div>
\ No newline at end of file
diff --git a/karaf/manual/src/fallback/manual.pdf b/karaf/manual/src/fallback/manual.pdf
deleted file mode 100644
index 72f3d80..0000000
--- a/karaf/manual/src/fallback/manual.pdf
+++ /dev/null
Binary files differ
diff --git a/karaf/manual/src/styles/chapter-rounded-bottom.png b/karaf/manual/src/styles/chapter-rounded-bottom.png
deleted file mode 100644
index 7b1d53d..0000000
--- a/karaf/manual/src/styles/chapter-rounded-bottom.png
+++ /dev/null
Binary files differ
diff --git a/karaf/manual/src/styles/print.css b/karaf/manual/src/styles/print.css
deleted file mode 100644
index b6f85af..0000000
--- a/karaf/manual/src/styles/print.css
+++ /dev/null
@@ -1,644 +0,0 @@
-/*
-
-Copyright (c) 2005 Hakon Wium Lie and Bert Bos
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
-*/
-html {
- margin: 0; padding: 0;
- font: 10pt/1.26 "Gill Sans", sans-serif;
-}
-
-h1, h2, h3, h4, h5, h6 {
- font-family: "Gill Sans", sans-serif;
- margin: 2em 0 0.5em 0;
- page-break-after: avoid;
-}
-
-h1 {
- font-size: 2.0em;
- font-weight: 900;
-
- margin: 0;
- margin-left:-2cm;
- margin-top:-1cm;
- margin-bottom:1.5cm;
- top: 0cm;
- left: 0cm;
- padding: 2cm;
- padding-top: 0cm;
- padding-bottom: 1cm;
- background: #888;
- border-bottom-right-radius: 2cm;
- page-break-before: always;
- page-break-inside: avoid;
-}
-
-@media screen, handheld {
-h1 {
- margin-top:1cm;
- background-image: url("chapter-rounded-bottom.png");
- background-repeat: no-repeat;
- background-position: bottom right;
-}
-div.page-reset > h1 {
- margin-top:0cm;
-}
-}
-
-
-h2 {
- font-size: 1.2em;
- text-transform: uppercase;
- font-weight: bold;
-}
-
-h3 {
- font-size: 1em;
- font-weight: bold;
-}
-
-q::before {
- content: "\201C";
-}
-
-q::after {
- content: "\201D";
-}
-
-p { margin: 0 }
-p + p { text-indent: 1.3em ; margin-top: 0.2em; }
-p.sidenote + p, p.caption, p.art { text-indent: 0 }
-
-p.author {
- margin-top: 2em;
- text-indent: 0;
- text-align: right;
-}
-
-a { text-decoration: none; color: black }
-
-/* cross-references */
-
-a.pageref::after { content: " on page " target-counter(attr(href), page); }
-a.chapref::before { content: " Chapter " target-counter(attr(href), chapter) ", "; }
-a.figref { content: " Figure " target-counter(attr(href), figure); }
-a.tableref { content: " Table " target-counter(attr(href), figure); }
-a.listingref { content: " Listing " target-counter(attr(href), listing); }
-
-/* sidenotes */
-
-.sidenote {
- float: left;
- clear: left;
- margin: 0 0 1em -41%;
- width: 37%;
- font-size: 0.9em;
- font-style: normal;
- text-indent: 0;
- text-align: right;
- page-break-inside: avoid;
-}
-
-/* sidebars */
-
-div.sidebar {
- float: top-next;
- margin: 1.2em 0 1.2em 0;
- border: thin solid;
- background: #CCC;
- padding: 0.5em 1em;
- page-break-inside: avoid;
- column-count: 2;
- column-gap: 1.5em;
-}
-
-div.sidebar h2 {
- margin-top: 0;
-}
-
-/* frontpage */
-
-.title p{
- font-size:22pt;
- font-family: "Gill Sans", sans-serif;
- text-align: center;
-}
-
-.copyright-section {
- text-align: center;
- font-size: 9pt;
- page-break-after: always;
- margin-top: 50pt;
- margin-bottom: 20pt;
-}
-
-.toc-title {
- font-size:18pt;
- font-family: "Gill Sans", sans-serif;
- text-align: left;
- margin-left:20pt;
- margin-bottom: 40pt;
-
-}
-
-/* figures, tables, and listings */
-
-div.confluenceTableSmall th.confluenceTh {
- font-size: 11px;
-}
-
-div.confluenceTableSmall td.confluenceTd {
- font-size: 7px;
-}
-
-div.figure {
- margin: 1em 0;
- counter-increment: figure;
-}
-
-div.figure .caption, div.table .caption {
- font-size: 0.9em;
- font-style: italic;
-}
-
-div.figure .caption::before {
- content: "Figure " counter(figure) ". ";
- font-weight: bold;
- font-style: normal;
-}
-
-div.table .caption::before {
- content: "Table " counter(table) ". ";
- font-weight: bold;
- font-style: normal;
-}
-
-div.table {
- margin: 1em 0;
- counter-increment: table;
-}
-
-div.table th {
- text-align: left;
-}
-
-table th, table td {
- text-align: left;
- padding-right: 1em;
- page-break-inside: avoid;
-}
-
-table th {
- border-top: thin solid;
- border-bottom: thin solid;
- padding-top: 0.2em;
- padding-bottom: 0.2em;
-}
-table td {
- border-top: none;
- border-bottom: thin dotted;
- padding-top: 0.2em;
- padding-bottom: 0.2em;
-}
-
-div.Scrollbar {
- display: none;
-}
-
-
-/* Weird div.codeHeader a b::before would be a better selection
- but prince does not properly match it.. Firefox does. */
-div.codeHeader::before {
- content: "Listing " counter(listing) ". ";
- font-weight: bold;
- font-style: normal;
-}
-div.codeHeader a b {
- font-style: italic;
- font-weight: normal;
-}
-div.codeHeader {
- font-size: 0.9em;
- counter-increment: listing;
-}
-div.code {
- border: 1px dashed #c0c0c0;
- font-size: 12px;
- font-family: Courier;
- margin: 5px;
- line-height: 13px;
- padding: 3px;
- background-color: #f8f8f8;
-
-}
-
-
-@page {
- margin: 2cm;
- size: 7in 9.25in;
-
- @footnotes {
- border-top: thin solid black;
- padding-top: 0.3em;
- margin-top: 0.6em;
- }
-}
-
-
-/* define default page and names pages: cover, blank, frontmatter */
-div.page-reset {
- counter-reset: page 1;
-}
-
-@page :left {
- @top-left-corner {
- font-weight: 900; font: 9pt "Gill Sans", serif;
- content: counter(page);
- text-align: left;
- margin-left: 1cm;
- visibility: hidden;
- }
- @top-left {
- font-weight: 900;
- font: 9pt "Gill Sans", serif; white-space: pre; text-transform: uppercase; letter-spacing: 0.1em;
- content: string(header, first);
- visibility: hidden;
- }
- @bottom-left-corner {
- font-weight: 900; font: 9pt "Gill Sans", serif;
- content: counter(page);
- text-align: left;
- margin-left: 1cm;
- }
- @bottom-left {
- font-weight: 900;
- font: 9pt "Gill Sans", serif; white-space: pre; text-transform: uppercase; letter-spacing: 0.1em;
- content: string(header, first);
- }
-}
-
-@page :right {
- @top-right-corner {
- font-weight: 900; font: 9pt "Gill Sans", serif;
- content: counter(page);
- text-align: left;
- margin-left: 1cm;
- visibility: hidden;
- }
- @top-right {
- font-weight: 900;
- font: 9pt "Gill Sans", serif; white-space: pre; text-transform: uppercase; letter-spacing: 0.1em;
- content: string(header, first)
- visibility: hidden;
- }
- @bottom-right-corner {
- font-weight: 900; font: 9pt "Gill Sans", serif;
- content: counter(page);
- text-align: right;
- margin-right: 1cm;
- }
- @bottom-right {
- font-weight: 900; font: 9pt "Gill Sans", serif;
- white-space: pre; text-transform: uppercase; letter-spacing: 0.1em;
- content: string(header, first)
- }
-}
-
-/*
- In theory we should be able to use the :first selector so taht
- we can put the page numbering on the bottom of the first page of the chapter
- but have the rest of the pages number at the top. But this does not seem
- to work. See http://www.princexml.com/doc/6.0/page-selectors/
-
- So for now just always number at the bottom :(
-*/
-/*
-div.chapter { page: bottom-number; }
-@page bottom-number :first {
- @top-left {
- visibility: hidden;
- }
- @bottom-left {
- visibility: visible;
- }
- @top-right {
- visibility: hidden;
- }
- @bottom-right {
- visibility: visible;
- }
-}
-*/
-
-@page cover { margin: 0; }
-
-@page frontmatter :left {
- @bottom-left-corner {
- content: counter(page, lower-roman);
- }
- @bottom-left-corner {
- content: counter(page, lower-roman);
- }
-}
-
-@page frontmatter :right {
- @bottom-right-corner {
- content: counter(page, lower-roman);
- }
- @bottom-right-corner {
- content: counter(page, lower-roman);
- }
-}
-
-@page blank :left {
- @top-left { visibility: hidden; }
- @bottom-left { visibility: hidden; }
- @top-left-corner { visibility: hidden; }
- @bottom-left-corner { visibility: hidden; }
-}
-
-@page blank :right {
- @top-right { visibility: hidden; }
- @bottom-right { visibility: hidden; }
- @top-right-corner { visibility: hidden; }
- @bottom-right-corner { visibility: hidden; }
-}
-
-/* footnotes */
-.footnote {
- display: none; /* default rule */
-
- display: prince-footnote; /* prince-specific rules */
- position: footnote;
- footnote-style-position: inside;
-
- counter-increment: footnote;
- margin-left: 1.4em;
- font-size: 90%;
- line-height: 1.4;
-}
-
-.footnote::footnote-call {
- vertical-align: super;
- font-size: 80%;
-}
-
-.footnote::footnote-marker {
- vertical-align: super;
- color: green;
- padding-right: 0.4em;
-}
-
-/* Confluence contents to hide */
-#labels-section {
- display: none;
-}
-#comments-section {
- display: none;
-}
-#footer {
- display: none;
-}
-.hidden {
- display: none;
-}
-
-/*
- A book consists of different types of sections. We propose to use
- DIV elements with these class names:
-
- frontcover
- halftitlepage: contains the title of the book
- titlepage: contains the title of the book, name of author(s) and publisher
- imprint: left page with copyright, publisher, library printing information
- dedication: right page with short dedication
- foreword: written by someone other than the author(s)
- toc: table of contents
- preface: preface, including acknowledgements
- chapter: each chapter is given its own DIV element
- references: contains list of references
- appendix: each appendix is given its own
- bibliography
- glossary
- index
- colophon: describes how the book was produced
- backcover
-
- A book will use several of the types listed above, but few books
- will use all of them.
-*/
-
-/* which section uses which named page */
-
-div.halftitlepage, div.titlepage, div.imprint, div.dedication { page: blank }
-div.foreword, div.toc, div.preface { page: frontmatter }
-
-
-/* page breaks */
-div.frontcover, div.halftitlepage, div.titlepage { page-break-before: right }
-div.imprint { page-break-before: always; }
-div.chapter { page-break-before: always; }
-div.dedication, div.foreword, div.toc, div.preface, div.reference,
-div.appendix, div.bibliography, div.glossary, div.index, div.colophon {
- page-break-before: always
-}
-div.backcover { page-break-before: left }
-
-/* titlepage, halftitlepage */
-
-div.titlepage h1, div.halftitlepage h1 { margin-bottom: 2em; }
-div.titlepage h2, div.halftitlepage h2 { font-size: 1.2em; margin-bottom: 3em; }
-div.titlepage h3, div.halftitlepage h3 { font-size: 1em; margin-bottom: 3em; }
-div.titlepage p, div.halftitlepage p {
- font-size: 1.4em;
- font-weight: bold;
- margin: 0; padding: 0;
-}
-
-
-/* TOC */
-
-ul.toc, ul.toc ul {
- list-style-type: none;
- margin: 0; padding: 0;
- margin-left: 3cm;
-}
-ul.toc ul {
- margin-left: 1em;
- font-weight: normal;
-}
-ul.toc > li {
- font-weight: bold;
- margin-bottom: 0.5em;
-}
-ul.toc a::after {
- content: leader('.') target-counter(attr(href), page);
- font-style: normal;
-}
-ul.toc > li.frontmatter a::after {
- content: leader('.') target-counter(attr(href), page, lower-roman);
- font-style: normal;
-}
-ul.toc > li.endmatter a::after {
- content: leader('.') target-counter(attr(href), page);
- font-style: normal;
-}
-ul.toc > li.chapter::before {
- content: "Chapter " counter(toc-chapter, decimal);
- display: block;
- margin: 1em 0 0.1em -2.5cm;
- font-weight: normal;
- counter-increment: toc-chapter;
- page-break-after: avoid;
-}
-
-/* chapter numbers */
-
-div.chapter { counter-increment: chapter; }
-div.chapter h1::before {
- text-transform: uppercase;
- letter-spacing: 0.15em;
- content: "Chapter " counter(chapter) " \A\B0 \B0 \B0 \B0\A";
- white-space: pre;
- font-size: 50%;
-}
-
-div.frontcover h1::before, div.titlepage h1::before, div.halftitlepage h1::before {
- content: normal; /* that is, none */
-}
-
-h1 { string-set: header content();}
-div.chapter h1 { string-set: header "Chapter " counter(chapter) " - " content(); }
-
-/* index */
-
-ul.index {
- list-style-type: none;
- margin: 0; padding: 0;
- column-count: 2;
- column-gap: 1em;
-}
-
-ul.index a::after { content: ", " target-counter(attr(href), page); }
-
-
-span.element, span.attribute {
- text-transform: uppercase;
- font-weight: bold;
- font-size: 80%;
-}
-span.property { font-weight: bold }
-code, span.css, span.value, span.declaration {
- font: 90% "Lucida Console", "Lucida Sans Typewriter", monospace;
-}
-
-
-@media screen, handheld {
- html {font: 14px "Gill Sans", sans-serif; }
- h1 { margin-bottom: 0.5em }
- div.frontcover, div.halftitlepage, div.titlepage, div.imprint,
- div.dedication, div.foreword, div.toc, div.index { display: none }
- body {
- margin: 0cm;
- margin-left: 2cm;
- margin-right: 2cm;
- }
-}
-
-/*
- * Enhancements to the take advantage of some of the style markup that
- * Confluence generates
- */
-a sup img { visibility: hidden; position: absolute;}
-
-img {
- prince-image-resolution:150dpi;
-}
-
-table {
- font: "Lucida Console", "Lucida Sans Typewriter", monospace;
-}
-
-table td {
- font-size: 10pt;
-}
-
-pre {
- white-space: pre-wrap;
-}
-
-.codeContent {
- font-size: 80%;
-}
-.code {
-}
-.code-keyword {
- color: #000091;
- background-color: inherit;
-}
-
-.code-object {
- color: #910091;
- background-color: inherit;
-}
-
-.code-quote {
- color: #009100;
- background-color: inherit;
-}
-
-.code-comment {
- color: #808080;
- background-color: inherit;
-}
-
-
-.code-xml .code-keyword {
- color: inherit;
- font-weight: bold;
-}
-
-.code-tag {
- color: #000091;
- background-color: inherit;
-}
-
-.noteMacro { border-color: #F0C000; background-color: #FFFFCE;}
-.warningMacro { border-color: #CC0000; background-color: #FFCCCC }
-.infoMacro { border-color: #3c78b5; background-color: #D8E4F1; }
-.tipMacro { border-color: #090; background-color: #dfd;}
-.noteMacro, .warningMacro, .infoMacro, .tipMacro, .informationMacroPadding {
- border: thin solid;
- float: top-next;
- margin: 1em 0 1.2em 0;
- padding: 0.5em;
- column-count: 2;
- column-gap: 1.5em;
- width: 100%;
-}
-table.infoMacro td, table.warningMacro td, table.tipMacro td, table.noteMacro td, table.sectionMacro td {
- border: none;
-}
-table.infoMacro p, table.warningMacro p, table.tipMacro p, table.noteMacro p, table.sectionMacro p {
- font-size:x-small;
- margin-top: 1em;
-}
-
diff --git a/karaf/manual/src/xslt/extract.xsl b/karaf/manual/src/xslt/extract.xsl
deleted file mode 100644
index d6f20dd..0000000
--- a/karaf/manual/src/xslt/extract.xsl
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:html="http://www.w3.org/1999/xhtml"
- version="1.0">
- <xsl:param name="stylesheet"/>
- <xsl:template match="/">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <link rel="stylesheet" type="text/css">
- <xsl:attribute name="href"><xsl:value-of select="$stylesheet"/></xsl:attribute>
- </link>
- <style type="text/css">
- @page :left {
- @top-left {
- content: "Apache Felix Karaf ${project.version} User's Manual";
- }
- }
- </style>
- </head>
- <body>
- <xsl:apply-templates select=".//html:div[@class='wiki-content']" />
- </body>
- </html>
- </xsl:template>
- <xsl:template match="@*|node()">
- <xsl:copy>
- <xsl:apply-templates select="@*|node()"/>
- </xsl:copy>
- </xsl:template>
-</xsl:stylesheet>
diff --git a/karaf/pom.xml b/karaf/pom.xml
deleted file mode 100644
index ca29478..0000000
--- a/karaf/pom.xml
+++ /dev/null
@@ -1,1120 +0,0 @@
-<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/maven-v4_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.felix</groupId>
- <artifactId>felix-parent</artifactId>
- <version>1.2.1</version>
- <relativePath>../pom/pom.xml</relativePath>
- </parent>
-
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>karaf</artifactId>
- <packaging>pom</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf</name>
- <inceptionYear>2007</inceptionYear>
-
- <modules>
- <module>main</module>
- <module>features</module>
- <module>admin</module>
- <module>deployer</module>
- <module>shell</module>
- <module>jaas</module>
- <module>client</module>
- <module>management</module>
- <module>webconsole</module>
- <module>manual</module>
- <module>exception</module>
- <module>assembly</module>
- <module>demos</module>
- <module>itests</module>
- <module>tooling</module>
- </modules>
-
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/felix/trunk/karaf</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/felix/trunk/karaf</developerConnection>
- <url>http://svn.apache.org/viewvc/felix/trunk/karaf/</url>
- </scm>
-
- <issueManagement>
- <system>jira</system>
- <url>https://issues.apache.org/jira/browse/FELIX/component/12312824</url>
- </issueManagement>
-
- <prerequisites>
- <maven>2.0.7</maven>
- </prerequisites>
-
- <properties>
- <aopalliance.version>1.0_3</aopalliance.version>
- <cglib.version>2.1_3_4</cglib.version>
- <commons.logging.version>1.1.1</commons.logging.version>
- <depends.maven.plugin.version>1.0</depends.maven.plugin.version>
- <easymock.version>2.4</easymock.version>
- <equinox.version>3.5.1.v20090827</equinox.version>
- <felix.bundlerepository.version>1.6.4</felix.bundlerepository.version>
- <felix.compendium.version>1.2.0</felix.compendium.version>
- <felix.configadmin.version>1.2.4</felix.configadmin.version>
- <felix.fileinstall.version>3.0.0</felix.fileinstall.version>
- <felix.framework.version>2.0.5</felix.framework.version>
- <felix.gogo.version>0.4.0</felix.gogo.version>
- <felix.osgi.version>1.4.0</felix.osgi.version>
- <felix.plugin.version>2.1.0</felix.plugin.version>
- <felix.prefs.version>1.0.4</felix.prefs.version>
- <felix.utils.version>1.0.0</felix.utils.version>
- <felix.webconsole.version>3.1.0</felix.webconsole.version>
- <felix.metatype.version>1.0.2</felix.metatype.version>
- <aries.blueprint.version>0.1-incubating</aries.blueprint.version>
- <aries.jmx.version>0.1-incubating</aries.jmx.version>
- <geronimo.servlet.version>1.1.2</geronimo.servlet.version>
- <jansi.version>1.2</jansi.version>
- <jetty.bundle.version>6.1.22_1</jetty.bundle.version>
- <junit.version>4.7_1</junit.version>
- <jline.version>0.9.95.20100209</jline.version>
- <log4j.version>1.2.16</log4j.version>
- <maven.version>2.0.9</maven.version>
- <mina.version>2.0.0-RC1</mina.version>
- <pax.exam.version>1.2.0</pax.exam.version>
- <pax.logging.version>1.5.2</pax.logging.version>
- <pax.runner.version>1.4.0</pax.runner.version>
- <pax.url.version>1.1.2</pax.url.version>
- <pax.web.version>0.7.2</pax.web.version>
- <servlet.api.version>2.5</servlet.api.version>
- <spring.osgi.version>1.2.0</spring.osgi.version>
- <spring.version>2.5.6.SEC01</spring.version>
- <sshd.version>0.4.0</sshd.version>
- <xbean.version>3.7</xbean.version>
-
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <appendedResourcesDirectory>${basedir}/etc/appended-resources</appendedResourcesDirectory>
- <bnd.version.policy>[$(version;==;$(@)),$(version;+;$(@)))</bnd.version.policy>
- </properties>
-
- <repositories>
- <!-- Apache snapshots -->
- <repository>
- <id>apache-snapshots</id>
- <name>Apache Snapshots Repository</name>
- <url>http://repository.apache.org/content/groups/snapshots-group</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- <!-- ServiceMix repo -->
- <repository>
- <id>servicemix</id>
- <name>Apache ServiceMix Repository</name>
- <url>http://svn.apache.org/repos/asf/servicemix/m2-repo</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>jansi.release.m2</id>
- <name>jansi Release Repository</name>
- <url>http://jansi.fusesource.org/repo/release</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- </releases>
- </repository>
- </repositories>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>manual</artifactId>
- <type>pdf</type>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>manual</artifactId>
- <type>html</type>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>org.apache.felix.karaf.main</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>org.apache.felix.karaf.exception</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>org.apache.felix.karaf.client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.deployer</groupId>
- <artifactId>org.apache.felix.karaf.deployer.spring</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.deployer</groupId>
- <artifactId>org.apache.felix.karaf.deployer.blueprint</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.deployer</groupId>
- <artifactId>org.apache.felix.karaf.deployer.features</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.deployer</groupId>
- <artifactId>org.apache.felix.karaf.deployer.war</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>org.apache.felix.karaf.management</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.demos</groupId>
- <artifactId>demos</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.features</groupId>
- <artifactId>org.apache.felix.karaf.features.core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.features</groupId>
- <artifactId>org.apache.felix.karaf.features.command</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.features</groupId>
- <artifactId>org.apache.felix.karaf.features.management</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.admin</groupId>
- <artifactId>org.apache.felix.karaf.admin.core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.admin</groupId>
- <artifactId>org.apache.felix.karaf.admin.command</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.admin</groupId>
- <artifactId>org.apache.felix.karaf.admin.management</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.obr</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.osgi</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.log</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.config</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.packages</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.ssh</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.commands</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.dev</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.wrapper</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.jaas</groupId>
- <artifactId>org.apache.felix.karaf.jaas.boot</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.jaas</groupId>
- <artifactId>org.apache.felix.karaf.jaas.config</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.jaas</groupId>
- <artifactId>org.apache.felix.karaf.jaas.modules</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.demos</groupId>
- <artifactId>web</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>apache-felix-karaf</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>apache-felix-karaf</artifactId>
- <type>zip</type>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>apache-felix-karaf</artifactId>
- <classifier>features</classifier>
- <type>xml</type>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.tooling</groupId>
- <artifactId>org.apache.felix.karaf.tooling.testing</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.framework</artifactId>
- <version>${felix.framework.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>${felix.compendium.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.foundation</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.felix</groupId>
- <artifactId>javax.servlet</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>${felix.osgi.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.configadmin</artifactId>
- <version>${felix.configadmin.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.prefs</artifactId>
- <version>${felix.prefs.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.bundlerepository</artifactId>
- <version>${felix.bundlerepository.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.service.obr</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.shell</artifactId>
- </exclusion>
- <exclusion>
- <groupId>net.sf.kxml</groupId>
- <artifactId>kxml2</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.metatype</artifactId>
- <version>${felix.metatype.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.utils</artifactId>
- <version>${felix.utils.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.webconsole</artifactId>
- <version>${felix.webconsole.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.fileinstall</artifactId>
- <version>${felix.fileinstall.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>${felix.plugin.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>${maven.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- <version>${maven.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-aop</artifactId>
- <version>${spring.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.aopalliance</groupId>
- <artifactId>com.springsource.org.aopalliance</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- <version>${spring.osgi.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.springframework</groupId>
- <artifactId>org.springframework.aop</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.springframework</groupId>
- <artifactId>org.springframework.beans</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.springframework</groupId>
- <artifactId>org.springframework.context</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.springframework</groupId>
- <artifactId>org.springframework.core</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-io</artifactId>
- <version>${spring.osgi.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-extender</artifactId>
- <version>${spring.osgi.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-annotation</artifactId>
- <version>${spring.osgi.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-test</artifactId>
- <version>${spring.osgi.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>asm.osgi</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.junit</groupId>
- <artifactId>com.springsource.junit</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.objectweb.asm</groupId>
- <artifactId>com.springsource.org.objectweb.asm</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.junit</artifactId>
- <version>${junit.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.jetty-bundle</artifactId>
- <version>${jetty.bundle.version}</version>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>${log4j.version}</version>
- </dependency>
- <dependency>
- <groupId>jline</groupId>
- <artifactId>jline</artifactId>
- <version>${jline.version}</version>
- </dependency>
- <dependency>
- <groupId>org.fusesource.jansi</groupId>
- <artifactId>jansi</artifactId>
- <version>${jansi.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>${commons.logging.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.artifact</groupId>
- <artifactId>maven-artifact</artifactId>
- <version>3.0-alpha-1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.mina</groupId>
- <artifactId>mina-core</artifactId>
- <version>${mina.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.easymock</groupId>
- <artifactId>easymockclassextension</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.4.3</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- <version>1.4.3</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-nop</artifactId>
- <version>1.4.3</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <version>1.4.3</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.logging</groupId>
- <artifactId>pax-logging-api</artifactId>
- <version>${pax.logging.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.logging</groupId>
- <artifactId>pax-logging-service</artifactId>
- <version>${pax.logging.version}</version>
- <exclusions>
- <exclusion>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.url</groupId>
- <artifactId>pax-url-mvn</artifactId>
- <version>${pax.url.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.url</groupId>
- <artifactId>pax-url-wrap</artifactId>
- <version>${pax.url.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.url</groupId>
- <artifactId>pax-url-war</artifactId>
- <version>${pax.url.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-servlet_2.5_spec</artifactId>
- <version>${geronimo.servlet.version}</version>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <version>${easymock.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sshd</groupId>
- <artifactId>sshd-core</artifactId>
- <version>${sshd.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam</artifactId>
- <version>${pax.exam.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit</artifactId>
- <version>${pax.exam.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-container-default</artifactId>
- <version>${pax.exam.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit-extender-impl</artifactId>
- <version>${pax.exam.version}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse</groupId>
- <artifactId>osgi</artifactId>
- <version>${equinox.version}</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>${servlet.api.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.aries.blueprint</groupId>
- <artifactId>org.apache.aries.blueprint</artifactId>
- <version>${aries.blueprint.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.felix</groupId>
- <artifactId>javax.servlet</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.aries.jmx</groupId>
- <artifactId>org.apache.aries.jmx</artifactId>
- <version>${aries.jmx.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.aries.jmx</groupId>
- <artifactId>org.apache.aries.jmx.blueprint</artifactId>
- <version>${aries.jmx.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.gogo</groupId>
- <artifactId>org.apache.felix.gogo.runtime</artifactId>
- <version>${felix.gogo.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.gogo</groupId>
- <artifactId>org.apache.felix.gogo.commands</artifactId>
- <version>${felix.gogo.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.runner</groupId>
- <artifactId>pax-runner-no-jcl</artifactId>
- <version>${pax.runner.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-api</artifactId>
- <version>${pax.web.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-spi</artifactId>
- <version>${pax.web.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-runtime</artifactId>
- <version>${pax.web.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-jetty</artifactId>
- <version>${pax.web.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-jsp</artifactId>
- <version>${pax.web.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-extender-war</artifactId>
- <version>${pax.web.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-extender-whiteboard</artifactId>
- <version>${pax.web.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.xbean</groupId>
- <artifactId>xbean-finder-shaded</artifactId>
- <version>${xbean.version}</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <build>
- <defaultGoal>install</defaultGoal>
-
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-eclipse-plugin</artifactId>
- <version>2.4</version>
- <configuration>
- <outputDirectory>${basedir}/eclipse-classes</outputDirectory>
- <downloadSources>true</downloadSources>
- <downloadJavadocs>true</downloadJavadocs>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-release-plugin</artifactId>
- <version>2.0</version>
- <configuration>
- <useReleaseProfile>false</useReleaseProfile>
- <preparationGoals>clean install</preparationGoals>
- <goals>deploy</goals>
- <arguments>-Prelease,deploy</arguments>
- <autoVersionSubmodules>true</autoVersionSubmodules>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>${felix.plugin.version}</version>
- <extensions>true</extensions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-idea-plugin</artifactId>
- <version>2.1</version>
- <configuration>
- <downloadSources>true</downloadSources>
- <downloadJavadocs>true</downloadJavadocs>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.3.1</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>1.2</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <version>2.3</version>
- </plugin>
- <plugin>
- <groupId>org.apache.servicemix.tooling</groupId>
- <artifactId>depends-maven-plugin</artifactId>
- <version>${depends.maven.plugin.version}</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>2.0.4</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.2-beta-3</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.2</version>
- <dependencies>
- <dependency>
- <groupId>ant-contrib</groupId>
- <artifactId>ant-contrib</artifactId>
- <version>1.0b3</version>
- </dependency>
- <dependency>
- <groupId>ant</groupId>
- <artifactId>ant-optional</artifactId>
- <version>1.5.3-1</version>
- </dependency>
- <dependency>
- <groupId>org.ccil.cowan.tagsoup</groupId>
- <artifactId>tagsoup</artifactId>
- <version>1.2</version>
- </dependency>
- </dependencies>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.1.1</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>2.1</version>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0.2</version>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- <maxmem>256M</maxmem>
- <fork>${compiler.fork}</fork>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-remote-resources-plugin</artifactId>
- <version>1.1</version>
- <executions>
- <execution>
- <goals>
- <goal>process</goal>
- </goals>
- <configuration>
- <appendedResourcesDirectory>${appendedResourcesDirectory}</appendedResourcesDirectory>
- <resourceBundles>
- <resourceBundle>org.apache:apache-jar-resource-bundle:1.4</resourceBundle>
- </resourceBundles>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-notice</id>
- <phase>generate-resources</phase>
- <configuration>
- <tasks>
- <copy file="NOTICE" todir="target/maven-shared-archive-resources/META-INF" failonerror="false" overwrite="true" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <inherited>true</inherited>
- <executions>
- <execution>
- <id>cleanVersions</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>cleanVersions</goal>
- </goals>
- <configuration>
- <versions>
- <karaf.osgi.version>${project.version}</karaf.osgi.version>
- </versions>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.3</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jxr-plugin</artifactId>
- <version>2.0</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <version>2.1</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-report-plugin</artifactId>
- <version>2.5</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <version>2.1.2</version>
- </plugin>
- </plugins>
- </reporting>
-
- <profiles>
- <profile>
- <id>fastinstall</id>
- <properties>
- <maven.test.skip>true</maven.test.skip>
- </properties>
- </profile>
- <profile>
- <id>rat</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <version>0.6</version>
- <executions>
- <execution>
- <phase>verify</phase>
- <goals>
- <goal>check</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <reportFile>${project.build.directory}/${project.build.finalName}.rat</reportFile>
- <excludeSubProjects>false</excludeSubProjects>
- <excludes>
- <exclude>**/target/**/*</exclude>
- <!-- IDEA files -->
- <exclude>**/*.iml</exclude>
- <exclude>**/*.ipr</exclude>
- <exclude>**/*.iws</exclude>
- <!-- Eclipse files -->
- <exclude>**/.*</exclude>
- <exclude>**/eclipse-classes/**/*</exclude>
- <exclude>**/dependency-reduced-pom.xml</exclude>
- <!--RAT doesn't seem to recognize MIT style licenses-->
- <exclude>manual/src/styles/print.css</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>release</id>
- <build>
- <plugins>
- <!-- We want to deploy the artifact to a staging location for perusal -->
- <plugin>
- <inherited>true</inherited>
- <artifactId>maven-deploy-plugin</artifactId>
- <version>2.3</version>
- <configuration>
- <altDeploymentRepository>${deploy.altRepository}</altDeploymentRepository>
- <updateReleaseInfo>true</updateReleaseInfo>
- </configuration>
- </plugin>
- <!-- We want to sign the artifact, the POM, and all attached artifacts -->
- <plugin>
- <artifactId>maven-gpg-plugin</artifactId>
- <version>1.0-alpha-4</version>
- <executions>
- <execution>
- <id>sign-artifacts</id>
- <phase>verify</phase>
- <goals>
- <goal>sign</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-assemblies</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>setup.eclipse</id>
- <modules>
- <module>assembly</module>
- </modules>
- <properties>
- <eclipse.workspace.dir>${basedir}/../workspace</eclipse.workspace.dir>
- </properties>
- <build>
- <defaultGoal>eclipse:eclipse</defaultGoal>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-eclipse-plugin</artifactId>
- <inherited>false</inherited>
- <executions>
- <execution>
- <id>setup.eclipse.workspace</id>
- <phase>process-test-sources</phase>
- <goals>
- <goal>add-maven-repo</goal>
- </goals>
- <configuration>
- <workspace>${eclipse.workspace.dir}</workspace>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>deploy</id>
- <properties>
- <createSourcesJar>true</createSourcesJar>
- </properties>
- <build>
- <defaultGoal>deploy</defaultGoal>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>2.0.4</version>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.4</version>
- <configuration>
- <source>1.5</source>
- </configuration>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-</project>
diff --git a/karaf/shell/commands/NOTICE b/karaf/shell/commands/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/shell/commands/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/shell/commands/pom.xml b/karaf/shell/commands/pom.xml
deleted file mode 100644
index fa02b72..0000000
--- a/karaf/shell/commands/pom.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<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/maven-v4_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.felix.karaf.shell</groupId>
- <artifactId>shell</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.commands</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Shell Various Commands</name>
-
- <description>
- Provides SSH support to the console
- </description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.gogo</groupId>
- <artifactId>org.apache.felix.gogo.runtime</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <resources>
- <resource>
- <directory>${project.basedir}/src/main/resources</directory>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Import-Package>
- !${project.artifactId}*,
- org.osgi.service.command,
- org.apache.felix.gogo.commands,
- org.apache.felix.karaf.shell.console,
- *
- </Import-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/CatAction.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/CatAction.java
deleted file mode 100644
index 6767955..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/CatAction.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-import java.io.IOException;
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.FileReader;
-import java.io.File;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.net.URI;
-import java.net.MalformedURLException;
-import java.util.List;
-
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Command;
-
-/**
- * Concatenate and print files and/or URLs.
- *
- * @version $Rev: 593392 $ $Date: 2007-11-09 03:14:15 +0100 (Fri, 09 Nov 2007) $
- */
-@Command(scope = "shell", name = "cat", description = "Displays the content of a file or url")
-public class CatAction extends OsgiCommandSupport {
-
- @Option(name = "-n", aliases = {}, description = "The number the output lines, starting at 1.", required = false, multiValued = false)
- private boolean displayLineNumbers;
-
- @Argument(index = 0, name = "paths or urls", description = "A list of file paths or urls to display separated by whitespaces (use - for STDIN)", required = true, multiValued = true)
- private List<String> paths;
-
- protected Object doExecute() throws Exception {
- //
- // Support "-" if length is one, and read from io.in
- // This will help test command pipelines.
- //
- if (paths.size() == 1 && "-".equals(paths.get(0))) {
- log.info("Printing STDIN");
- cat(new BufferedReader(new InputStreamReader(System.in)));
- }
- else {
- for (String filename : paths) {
- BufferedReader reader;
-
- // First try a URL
- try {
- URL url = new URL(filename);
- log.info("Printing URL: " + url);
- reader = new BufferedReader(new InputStreamReader(url.openStream()));
- }
- catch (MalformedURLException ignore) {
- // They try a file
- File file = new File(filename);
- log.info("Printing file: " + file);
- reader = new BufferedReader(new FileReader(file));
- }
-
- try {
- cat(reader);
- }
- finally {
- try {
- reader.close();
- } catch (IOException e) {
- // Ignore
- }
- }
- }
- }
-
- return null;
- }
-
- private void cat(final BufferedReader reader) throws IOException
- {
- String line;
- int lineno = 1;
-
- while ((line = reader.readLine()) != null) {
- if (displayLineNumbers) {
- System.out.print(String.format("%6d ", lineno++));
- }
- System.out.println(line);
- }
- }
-}
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/ClearAction.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/ClearAction.java
deleted file mode 100644
index 829f861..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/ClearAction.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-
-/**
- * A command to clear the console buffer
- */
-@Command(scope = "shell", name = "clear", description = "Clears the console buffer")
-public class ClearAction extends OsgiCommandSupport {
-
- protected Object doExecute() throws Exception {
- System.out.print("\33[2J");
- System.out.flush();
- System.out.print("\33[1;1H");
- System.out.flush();
- return null;
- }
-
-}
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/EachAction.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/EachAction.java
deleted file mode 100644
index eec57fa..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/EachAction.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-import java.util.Collection;
-import java.util.Collections;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.osgi.service.command.Function;
-
-/**
- * Execute a closure on a list of arguments.
- */
-@Command(scope = "shell", name = "each", description = "Execute a closure on a list of arguments.")
-public class EachAction extends OsgiCommandSupport {
-
- @Argument(name = "values", index = 0, multiValued = false, required = true, description = "The collection of arguments to iterate on")
- Collection<Object> values;
-
- @Argument(name = "function", index = 1, multiValued = false, required = true, description = "The function to execute")
- Function function;
-
- @Override
- protected Object doExecute() throws Exception {
- for (Object v : values) {
- function.execute(session, Collections.singletonList(v));
- }
- return null;
- }
-}
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/EchoAction.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/EchoAction.java
deleted file mode 100644
index a5fa17c..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/EchoAction.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-import java.util.List;
-
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-
-@Command(scope = "shell", name = "echo", description="Echoes or prints arguments to STDOUT")
-public class EchoAction extends OsgiCommandSupport
-{
- @Option(name = "-n", aliases = {}, description = "Do not print the trailing newline character", required = false, multiValued = false)
- private boolean noTrailingNewline = false;
-
- @Argument(index = 0, name = "arguments", description="Arguments to display separated by whitespaces", required = false, multiValued = true)
- private List<String> args;
-
- protected Object doExecute() throws Exception {
- if (args != null) {
- boolean first = true;
- for (String arg : args) {
- if (first) {
- first = false;
- } else {
- System.out.print(" ");
- }
- System.out.print(arg);
- }
- }
-
- if (!noTrailingNewline) {
- System.out.println();
- }
-
- return null;
- }
-}
\ No newline at end of file
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/ExecuteAction.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/ExecuteAction.java
deleted file mode 100644
index 3cd0d60..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/ExecuteAction.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-import java.util.List;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.karaf.shell.commands.utils.PumpStreamHandler;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-
-/**
- * Execute system processes.
- *
- * @version $Rev: 593392 $ $Date: 2007-11-09 03:14:15 +0100 (Fri, 09 Nov 2007) $
- */
-@Command(scope = "shell", name = "exec", description = "Executes system processes")
-public class ExecuteAction extends OsgiCommandSupport {
-
- @Argument(index = 0, name = "command", description = "Execution command with arguments", required = true, multiValued = true)
- private List<String> args;
-
- protected Object doExecute() throws Exception {
- ProcessBuilder builder = new ProcessBuilder(args);
-
- PumpStreamHandler handler = new PumpStreamHandler(System.in, System.out, System.err);
-
- log.info("Executing: {}", builder.command());
- Process p = builder.start();
-
- handler.attach(p);
- handler.start();
-
- log.debug("Waiting for process to exit...");
-
- int status = p.waitFor();
-
-
- log.info("Process exited w/status: {}", status);
-
- handler.stop();
-
- return null;
- }
-
-}
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/GrepAction.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/GrepAction.java
deleted file mode 100644
index 2635eb6..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/GrepAction.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Command;
-import org.fusesource.jansi.Ansi;
-
-
-@Command(scope = "shell", name="grep", description="Prints lines matching the given pattern")
-public class GrepAction extends OsgiCommandSupport {
-
- public static enum ColorOption {
- never,
- always,
- auto
- }
-
- @Argument(index = 0, name = "pattern", description = "Regular expression", required = true, multiValued = false)
- private String regex;
-
- @Option(name = "-n", aliases = { "--line-number" }, description = "Prefixes each line of output with the line number within its input file.", required = false, multiValued = false)
- private boolean lineNumber;
-
- @Option(name = "-v", aliases = { "--invert-match" }, description = "Inverts the sense of matching, to select non-matching lines.", required = false, multiValued = false)
- private boolean invertMatch;
-
- @Option(name = "-w", aliases = { "--word-regexp" }, description = "Selects only those lines containing matches that form whole " +
- "words. The test is that the matching substring must either be " +
- "at the beginning of the line, or preceded by a non-word constituent " +
- "character. Similarly, it must be either at the end of " +
- "the line or followed by a non-word constituent character. " +
- "Word-constituent characters are letters, digits, and the underscore.", required = false, multiValued = false)
- private boolean wordRegexp;
-
- @Option(name = "-x", aliases = { "--line-regexp" }, description = "Selects only those matches that exactly match the whole line.", required = false, multiValued = false)
- private boolean lineRegexp;
-
- @Option(name = "-i", aliases = { "--ignore-case" }, description = "Ignores case distinctions in both the PATTERN and the input files.", required = false, multiValued = false)
- private boolean ignoreCase;
-
- @Option(name = "-c", aliases = { "--count" }, description = "only print a count of matching lines per FILE", required = false, multiValued = false)
- private boolean count;
-
- @Option(name = "--color", aliases = { "--colour" }, description = "use markers to distinguish the matching string. WHEN may be `always', `never' or `auto'", required = false, multiValued = false)
- private ColorOption color = ColorOption.auto;
-
- @Option(name = "-B", aliases = { "--before-context" }, description = "Print NUM lines of leading context before matching lines. Places a line containing -- between contiguous groups of matches.", required = false, multiValued = false)
- private int before = -1;
-
- @Option(name = "-A", aliases = { "--after-context" }, description = "Print NUM lines of trailing context after matching lines. Places a line containing -- between contiguous groups of matches.", required = false, multiValued = false)
- private int after = -1;
-
- @Option(name = "-C", aliases = { "--context" }, description = "Print NUM lines of output context. Places a line containing -- between contiguous groups of matches.", required = false, multiValued = false)
- private int context = 0;
-
-
- protected Object doExecute() throws Exception {
- if (after < 0) {
- after = context;
- }
- if (before < 0) {
- before = context;
- }
- List<String> lines = new ArrayList<String>();
-
- String regexp = regex;
- if (wordRegexp) {
- regexp = "\\b" + regexp + "\\b";
- }
- if (lineRegexp) {
- regexp = "^" + regexp + "$";
- } else {
- regexp = ".*" + regexp + ".*";
- }
- Pattern p;
- Pattern p2;
- if (ignoreCase) {
- p = Pattern.compile(regexp, Pattern.CASE_INSENSITIVE);
- p2 = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
- } else {
- p = Pattern.compile(regexp);
- p2 = Pattern.compile(regex);
- }
- try {
- boolean firstPrint = true;
- int nb = 0;
- int lineno = 1;
- String line;
- int lineMatch = 0;
- BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
- while ((line = r.readLine()) != null) {
- if (line.length() == 1 && line.charAt(0) == '\n') {
- break;
- }
- if (p.matcher(line).matches() ^ invertMatch) {
-
- Matcher matcher2 = p2.matcher(line);
- StringBuffer sb = new StringBuffer();
- while (matcher2.find()) {
- if (!invertMatch && color != ColorOption.never) {
- matcher2.appendReplacement(sb, Ansi.ansi()
- .bg(Ansi.Color.YELLOW)
- .fg(Ansi.Color.BLACK)
- .a(matcher2.group())
- .reset().toString());
- } else {
- matcher2.appendReplacement(sb, matcher2.group());
- }
- nb++;
- }
- matcher2.appendTail(sb);
- if (!count && lineNumber) {
- lines.add(String.format("%6d ", lineno) + sb.toString());
- } else {
- lines.add(sb.toString());
- }
- lineMatch = lines.size();
- } else {
- if (lineMatch != 0 & lineMatch + after + before <= lines.size()) {
- if (!count) {
- if (!firstPrint && before + after > 0) {
- System.out.println("--");
- } else {
- firstPrint = false;
- }
- for (int i = 0; i < lineMatch + after; i++) {
- System.out.println(lines.get(i));
- }
- }
- while (lines.size() > before) {
- lines.remove(0);
- }
- lineMatch = 0;
- }
- lines.add(line);
- while (lineMatch == 0 && lines.size() > before) {
- lines.remove(0);
- }
- }
- lineno++;
- }
- if (!count && lineMatch > 0) {
- if (!firstPrint && before + after > 0) {
- System.out.println("--");
- } else {
- firstPrint = false;
- }
- for (int i = 0; i < lineMatch + after && i < lines.size(); i++) {
- System.out.println(lines.get(i));
- }
- }
- if (count) {
- System.out.println(nb);
- }
- } catch (IOException e) {
- }
- return null;
- }
-
-}
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/HistoryAction.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/HistoryAction.java
deleted file mode 100644
index ee5884b..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/HistoryAction.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-import java.util.List;
-
-import jline.History;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.fusesource.jansi.Ansi;
-
-/**
- * History command
- */
-@Command(scope = "shell", name="history", description="Prints command history")
-public class HistoryAction extends OsgiCommandSupport {
-
- @Override
- protected Object doExecute() throws Exception {
- History history = (History) session.get(".jline.history");
- List<String> elements = history.getHistoryList();
-
- int i = 0;
- for (String element : elements) {
- System.out.println(
- Ansi.ansi()
- .a(" ")
- .a(Ansi.Attribute.INTENSITY_BOLD).render("%3d", i).a(Ansi.Attribute.INTENSITY_BOLD_OFF)
- .a(" ")
- .a(element)
- .toString());
- i++;
- }
- return null;
- }
-}
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/IfAction.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/IfAction.java
deleted file mode 100644
index d331ad0..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/IfAction.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.osgi.service.command.Function;
-
-/**
- * Execute a closure on a list of arguments.
- */
-@Command(scope = "shell", name = "if", description = "If/Then/Else block.")
-public class IfAction extends OsgiCommandSupport {
-
- @Argument(name = "condition", index = 0, multiValued = false, required = true, description = "The condition")
- Function condition;
-
- @Argument(name = "ifTrue", index = 1, multiValued = false, required = true, description = "The function to execute if the condition is true")
- Function ifTrue;
-
- @Argument(name = "ifFalse", index = 2, multiValued = false, required = false, description = "The function to execute if the condition is false")
- Function ifFalse;
-
- @Override
- protected Object doExecute() throws Exception {
- Object result = condition.execute(session, null);
- if (isTrue(result)) {
- return ifTrue.execute(session, null);
- } else {
- if (ifFalse != null) {
- return ifFalse.execute(session, null);
- }
- }
- return null;
- }
-
- private boolean isTrue(Object result) {
- if (result == null) {
- return false;
- }
- if (result instanceof String && ((String) result).equals("")) {
- return false;
- }
- if (result instanceof Boolean) {
- return ((Boolean) result).booleanValue();
- }
- return true;
- }
-
-}
\ No newline at end of file
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/InfoAction.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/InfoAction.java
deleted file mode 100644
index c415ea0..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/InfoAction.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-import java.util.Locale;
-import java.text.DecimalFormatSymbols;
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-import java.lang.management.OperatingSystemMXBean;
-import java.lang.management.ManagementFactory;
-import java.lang.management.ClassLoadingMXBean;
-import java.lang.management.MemoryMXBean;
-import java.lang.management.ThreadMXBean;
-import java.lang.management.RuntimeMXBean;
-import java.lang.management.GarbageCollectorMXBean;
-import java.lang.reflect.Method;
-
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Command;
-import org.fusesource.jansi.Ansi;
-
-@Command(scope = "shell", name = "info", description = "Prints system informations")
-public class InfoAction extends OsgiCommandSupport {
-
- private NumberFormat fmtI = new DecimalFormat("###,###", new DecimalFormatSymbols(Locale.ENGLISH));
- private NumberFormat fmtD = new DecimalFormat("###,##0.000", new DecimalFormatSymbols(Locale.ENGLISH));
-
- protected Object doExecute() throws Exception {
- int maxNameLen;
-
- RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
- OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
- ThreadMXBean threads = ManagementFactory.getThreadMXBean();
- MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
- ClassLoadingMXBean cl = ManagementFactory.getClassLoadingMXBean();
-
- //
- // print Karaf informations
- //
- maxNameLen = 25;
- System.out.println("Karaf");
- printValue("Karaf home", maxNameLen, System.getProperty("karaf.home"));
- printValue("Karaf base", maxNameLen, System.getProperty("karaf.base"));
- printValue("OSGi Framework", maxNameLen, bundleContext.getBundle(0).getSymbolicName() + " - " +
- bundleContext.getBundle(0).getVersion());
- System.out.println();
-
- System.out.println("JVM");
- printValue("Java Virtual Machine", maxNameLen, runtime.getVmName() + " version " + runtime.getVmVersion());
- printValue("Version", maxNameLen, System.getProperty("java.version"));
- printValue("Vendor", maxNameLen, runtime.getVmVendor());
- printValue("Uptime", maxNameLen, printDuration(runtime.getUptime()));
- try {
- printValue("Process CPU time", maxNameLen, printDuration(getSunOsValueAsLong(os, "getProcessCpuTime") / 1000000));
- } catch (Throwable t) {}
- printValue("Total compile time", maxNameLen, printDuration(ManagementFactory.getCompilationMXBean().getTotalCompilationTime()));
-
- System.out.println("Threads");
- printValue("Live threads", maxNameLen, Integer.toString(threads.getThreadCount()));
- printValue("Daemon threads", maxNameLen, Integer.toString(threads.getDaemonThreadCount()));
- printValue("Peak", maxNameLen, Integer.toString(threads.getPeakThreadCount()));
- printValue("Total started", maxNameLen, Long.toString(threads.getTotalStartedThreadCount()));
-
- System.out.println("Memory");
- printValue("Current heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getUsed()));
- printValue("Maximum heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getMax()));
- printValue("Committed heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getCommitted()));
- printValue("Pending objects", maxNameLen, Integer.toString(mem.getObjectPendingFinalizationCount()));
- for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {
- String val = "Name = '" + gc.getName() + "', Collections = " + gc.getCollectionCount() + ", Time = " + printDuration(gc.getCollectionTime());
- printValue("Garbage collector", maxNameLen, val);
- }
-
- System.out.println("Classes");
- printValue("Current classes loaded", maxNameLen, printLong(cl.getLoadedClassCount()));
- printValue("Total classes loaded", maxNameLen, printLong(cl.getTotalLoadedClassCount()));
- printValue("Total classes unloaded", maxNameLen, printLong(cl.getUnloadedClassCount()));
-
- System.out.println("Operating system");
- printValue("Name", maxNameLen, os.getName() + " version " + os.getVersion());
- printValue("Architecture", maxNameLen, os.getArch());
- printValue("Processors", maxNameLen, Integer.toString(os.getAvailableProcessors()));
- try {
- printValue("Total physical memory", maxNameLen, printSizeInKb(getSunOsValueAsLong(os, "getTotalPhysicalMemorySize")));
- printValue("Free physical memory", maxNameLen, printSizeInKb(getSunOsValueAsLong(os, "getFreePhysicalMemorySize")));
- printValue("Committed virtual memory", maxNameLen, printSizeInKb(getSunOsValueAsLong(os, "getCommittedVirtualMemorySize")));
- printValue("Total swap space", maxNameLen, printSizeInKb(getSunOsValueAsLong(os, "getTotalSwapSpaceSize")));
- printValue("Free swap space", maxNameLen, printSizeInKb(getSunOsValueAsLong(os, "getFreeSwapSpaceSize")));
- } catch (Throwable t) {}
-
- return null;
- }
-
- private long getSunOsValueAsLong(OperatingSystemMXBean os, String name) throws Exception {
- Method mth = os.getClass().getMethod(name);
- return (Long) mth.invoke(os);
- }
-
- private String printLong(long i) {
- return fmtI.format(i);
- }
-
- private String printSizeInKb(double size) {
- return fmtI.format((long) (size / 1024)) + " kbytes";
- }
-
- private String printDuration(double uptime) {
- uptime /= 1000;
- if (uptime < 60) {
- return fmtD.format(uptime) + " seconds";
- }
- uptime /= 60;
- if (uptime < 60) {
- long minutes = (long) uptime;
- String s = fmtI.format(minutes) + (minutes > 1 ? " minutes" : " minute");
- return s;
- }
- uptime /= 60;
- if (uptime < 24) {
- long hours = (long) uptime;
- long minutes = (long) ((uptime - hours) * 60);
- String s = fmtI.format(hours) + (hours > 1 ? " hours" : " hour");
- if (minutes != 0) {
- s += " " + fmtI.format(minutes) + (minutes > 1 ? " minutes" : "minute");
- }
- return s;
- }
- uptime /= 24;
- long days = (long) uptime;
- long hours = (long) ((uptime - days) * 60);
- String s = fmtI.format(days) + (days > 1 ? " days" : " day");
- if (hours != 0) {
- s += " " + fmtI.format(hours) + (hours > 1 ? " hours" : "hour");
- }
- return s;
- }
-
- void printSysValue(String prop, int pad) {
- printValue(prop, pad, System.getProperty(prop));
- }
-
- void printValue(String name, int pad, String value) {
- System.out.println(Ansi.ansi().a(" ")
- .a(Ansi.Attribute.INTENSITY_BOLD).a(name).a(spaces(pad - name.length())).a(Ansi.Attribute.RESET)
- .a(" ").a(value).toString());
- }
-
- String spaces(int nb) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < nb; i++) {
- sb.append(' ');
- }
- return sb.toString();
- }
-
-}
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/JavaAction.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/JavaAction.java
deleted file mode 100644
index 47f81c6..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/JavaAction.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-import java.lang.reflect.Method;
-import java.util.List;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-
-/**
- * Execute a Java standard application.
- *
- * <p>By default looks for static main(String[]) to execute, but
- * you can specify a different static method that takes a String[]
- * to execute instead.
- *
- * @version $Rev: 593392 $ $Date: 2007-11-09 03:14:15 +0100 (Fri, 09 Nov 2007) $
- */
-@Command(scope = "shell", name = "java", description = "Execute a Java standard application")
-public class JavaAction extends OsgiCommandSupport {
-
- @Option(name = "-m", aliases = {"--method"}, description = "Invoke a named method", required = false, multiValued = false)
- private String methodName = "main";
-
- @Argument(index = 0, name = "className", description="The name of the class to invoke", required = true, multiValued = false)
- private String className;
-
- @Argument(index = 1, name = "arguments", description="Arguments to pass to the method of the given class", required = false, multiValued = false)
- private List<String> args;
-
- protected Object doExecute() throws Exception {
- boolean info = log.isInfoEnabled();
-
- Class type = Thread.currentThread().getContextClassLoader().loadClass(className);
- if (info) {
- log.info("Using type: " + type);
- }
-
- Method method = type.getMethod(methodName, String[].class);
- if (info) {
- log.info("Using method: " + method);
- }
-
- if (info) {
- log.info("Invoking w/arguments: {}", args);
- }
-
- Object result = method.invoke(null, args);
-
- if (info) {
- log.info("Result: " + result);
- }
-
- return null;
- }
-
-}
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/LogoutAction.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/LogoutAction.java
deleted file mode 100644
index 420f6e5..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/LogoutAction.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.karaf.shell.console.CloseShellException;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Command(scope = "shell", name = "logout", description = "Disconnect shell from current session")
-public class LogoutAction extends OsgiCommandSupport {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- protected Object doExecute() throws Exception {
- log.info("Disconnecting from current session...");
- throw new CloseShellException();
- }
-
-}
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/MoreAction.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/MoreAction.java
deleted file mode 100644
index 567ba93..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/MoreAction.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "shell", name = "more", description = "")
-public class MoreAction {
-}
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/NewAction.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/NewAction.java
deleted file mode 100644
index 04d9a93..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/NewAction.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.karaf.shell.console.commands.GenericType;
-import org.osgi.service.blueprint.container.ComponentDefinitionException;
-import org.osgi.service.blueprint.container.Converter;
-import org.osgi.service.blueprint.container.ReifiedType;
-
-/**
- * Execute a closure on a list of arguments.
- */
-@Command(scope = "shell", name = "new", description = "Creates a new java object.")
-public class NewAction extends OsgiCommandSupport {
-
- @Argument(name = "class", index = 0, multiValued = false, required = true, description = "The object class")
- Class clazz;
-
- @Argument(name = "args", index = 1, multiValued = true, required = false, description = "Constructor arguments")
- List<Object> args;
-
- boolean reorderArguments;
-
- protected Converter blueprintConverter;
-
- public void setBlueprintConverter(Converter blueprintConverter) {
- this.blueprintConverter = blueprintConverter;
- }
-
- @Override
- protected Object doExecute() throws Exception {
- // Map of matching constructors
- Map<Constructor, List<Object>> matches = findMatchingConstructors(clazz, args, Arrays.asList(new ReifiedType[args.size()]));
- if (matches.size() == 1) {
- try {
- Map.Entry<Constructor, List<Object>> match = matches.entrySet().iterator().next();
- return newInstance(match.getKey(), match.getValue().toArray());
- } catch (Throwable e) {
- throw new ComponentDefinitionException("Error when instanciating object of class " + clazz.getName(), getRealCause(e));
- }
- } else if (matches.size() == 0) {
- throw new ComponentDefinitionException("Unable to find a matching constructor on class " + clazz.getName() + " for arguments " + args + " when instanciating object.");
- } else {
- throw new ComponentDefinitionException("Multiple matching constructors found on class " + clazz.getName() + " for arguments " + args + " when instanciating object: " + matches.keySet());
- }
- }
-
-
- //
- // Code below comes from Aries blueprint implementation. Given this code is not available
- // from a public API it has been copied here.
- //
-
- private Object newInstance(Constructor constructor, Object... args) throws Exception {
- return constructor.newInstance(args);
- }
-
- private Map<Constructor, List<Object>> findMatchingConstructors(Class type, List<Object> args, List<ReifiedType> types) {
- Map<Constructor, List<Object>> matches = new HashMap<Constructor, List<Object>>();
- // Get constructors
- List<Constructor> constructors = new ArrayList<Constructor>(Arrays.asList(type.getConstructors()));
- // Discard any signature with wrong cardinality
- for (Iterator<Constructor> it = constructors.iterator(); it.hasNext();) {
- if (it.next().getParameterTypes().length != args.size()) {
- it.remove();
- }
- }
- // Find a direct match with assignment
- if (matches.size() != 1) {
- Map<Constructor, List<Object>> nmatches = new HashMap<Constructor, List<Object>>();
- for (Constructor cns : constructors) {
- boolean found = true;
- List<Object> match = new ArrayList<Object>();
- for (int i = 0; i < args.size(); i++) {
- ReifiedType argType = new GenericType(cns.getGenericParameterTypes()[i]);
- if (types.get(i) != null && !argType.getRawClass().equals(types.get(i).getRawClass())) {
- found = false;
- break;
- }
- if (!isAssignable(args.get(i), argType)) {
- found = false;
- break;
- }
- try {
- match.add(convert(args.get(i), cns.getGenericParameterTypes()[i]));
- } catch (Throwable t) {
- found = false;
- break;
- }
- }
- if (found) {
- nmatches.put(cns, match);
- }
- }
- if (nmatches.size() > 0) {
- matches = nmatches;
- }
- }
- // Find a direct match with conversion
- if (matches.size() != 1) {
- Map<Constructor, List<Object>> nmatches = new HashMap<Constructor, List<Object>>();
- for (Constructor cns : constructors) {
- boolean found = true;
- List<Object> match = new ArrayList<Object>();
- for (int i = 0; i < args.size(); i++) {
- ReifiedType argType = new GenericType(cns.getGenericParameterTypes()[i]);
- if (types.get(i) != null && !argType.getRawClass().equals(types.get(i).getRawClass())) {
- found = false;
- break;
- }
- try {
- Object val = convert(args.get(i), argType);
- match.add(val);
- } catch (Throwable t) {
- found = false;
- break;
- }
- }
- if (found) {
- nmatches.put(cns, match);
- }
- }
- if (nmatches.size() > 0) {
- matches = nmatches;
- }
- }
- // Start reordering with assignment
- if (matches.size() != 1 && reorderArguments && args.size() > 1) {
- Map<Constructor, List<Object>> nmatches = new HashMap<Constructor, List<Object>>();
- for (Constructor cns : constructors) {
- ArgumentMatcher matcher = new ArgumentMatcher(cns.getGenericParameterTypes(), false);
- List<Object> match = matcher.match(args, types);
- if (match != null) {
- nmatches.put(cns, match);
- }
- }
- if (nmatches.size() > 0) {
- matches = nmatches;
- }
- }
- // Start reordering with conversion
- if (matches.size() != 1 && reorderArguments && args.size() > 1) {
- Map<Constructor, List<Object>> nmatches = new HashMap<Constructor, List<Object>>();
- for (Constructor cns : constructors) {
- ArgumentMatcher matcher = new ArgumentMatcher(cns.getGenericParameterTypes(), true);
- List<Object> match = matcher.match(args, types);
- if (match != null) {
- nmatches.put(cns, match);
- }
- }
- if (nmatches.size() > 0) {
- matches = nmatches;
- }
- }
- return matches;
- }
-
- protected Object convert(Object obj, Type type) throws Exception {
- return blueprintConverter.convert(obj, new GenericType(type));
- }
-
- protected Object convert(Object obj, ReifiedType type) throws Exception {
- return blueprintConverter.convert(obj, type);
- }
-
- public static boolean isAssignable(Object source, ReifiedType target) {
- return source == null
- || (target.size() == 0
- && unwrap(target.getRawClass()).isAssignableFrom(unwrap(source.getClass())));
- }
-
- private static Class unwrap(Class c) {
- Class u = primitives.get(c);
- return u != null ? u : c;
- }
-
- private static final Map<Class, Class> primitives;
- static {
- primitives = new HashMap<Class, Class>();
- primitives.put(byte.class, Byte.class);
- primitives.put(short.class, Short.class);
- primitives.put(char.class, Character.class);
- primitives.put(int.class, Integer.class);
- primitives.put(long.class, Long.class);
- primitives.put(float.class, Float.class);
- primitives.put(double.class, Double.class);
- primitives.put(boolean.class, Boolean.class);
- }
-
-
- private static Object UNMATCHED = new Object();
-
- private class ArgumentMatcher {
-
- private List<TypeEntry> entries;
- private boolean convert;
-
- public ArgumentMatcher(Type[] types, boolean convert) {
- entries = new ArrayList<TypeEntry>();
- for (Type type : types) {
- entries.add(new TypeEntry(new GenericType(type)));
- }
- this.convert = convert;
- }
-
- public List<Object> match(List<Object> arguments, List<ReifiedType> forcedTypes) {
- if (find(arguments, forcedTypes)) {
- return getArguments();
- }
- return null;
- }
-
- private List<Object> getArguments() {
- List<Object> list = new ArrayList<Object>();
- for (TypeEntry entry : entries) {
- if (entry.argument == UNMATCHED) {
- throw new RuntimeException("There are unmatched types");
- } else {
- list.add(entry.argument);
- }
- }
- return list;
- }
-
- private boolean find(List<Object> arguments, List<ReifiedType> forcedTypes) {
- if (entries.size() == arguments.size()) {
- boolean matched = true;
- for (int i = 0; i < arguments.size() && matched; i++) {
- matched = find(arguments.get(i), forcedTypes.get(i));
- }
- return matched;
- }
- return false;
- }
-
- private boolean find(Object arg, ReifiedType forcedType) {
- for (TypeEntry entry : entries) {
- Object val = arg;
- if (entry.argument != UNMATCHED) {
- continue;
- }
- if (forcedType != null) {
- if (!forcedType.equals(entry.type)) {
- continue;
- }
- } else if (arg != null) {
- if (convert) {
- try {
- // TODO: call canConvert instead of convert()
- val = convert(arg, entry.type);
- } catch (Throwable t) {
- continue;
- }
- } else {
- if (!isAssignable(arg, entry.type)) {
- continue;
- }
- }
- }
- entry.argument = val;
- return true;
- }
- return false;
- }
-
- }
-
- private static class TypeEntry {
-
- private final ReifiedType type;
- private Object argument;
-
- public TypeEntry(ReifiedType type) {
- this.type = type;
- this.argument = UNMATCHED;
- }
-
- }
-
- public static Throwable getRealCause(Throwable t) {
- if (t instanceof InvocationTargetException && t.getCause() != null) {
- return t.getCause();
- }
- return t;
- }
-}
\ No newline at end of file
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/PrintfAction.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/PrintfAction.java
deleted file mode 100644
index 5bd4219..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/PrintfAction.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-import java.util.Collection;
-
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "shell", name = "printf", description = "Format and print arguments")
-public class PrintfAction extends OsgiCommandSupport {
-
- @Argument(index = 0, name = "format", description = "The format pattern to use", required = true, multiValued = false)
- private String format;
-
- @Argument(index = 1, name = "arguments", description = "The arguments for the given format pattern", required = true, multiValued = true)
- private Collection<Object> arguments = null;
-
- protected Object doExecute() throws Exception {
- System.out.printf(format, arguments.toArray());
- return null;
- }
-}
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/SleepAction.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/SleepAction.java
deleted file mode 100644
index facadd4..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/SleepAction.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "shell", name = "sleep", description = "Sleeps for a bit then wakes up")
-public class SleepAction extends OsgiCommandSupport {
-
- @Argument(index = 0, name = "duration", description = "The amount of millis to sleep", required = true, multiValued = false)
- private long time = -1;
-
- protected Object doExecute() throws Exception {
- log.info("Sleeping for {}", time);
-
- try {
- Thread.sleep(time);
- }
- catch (InterruptedException ignore) {
- log.debug("Sleep was interrupted... :-(");
- }
-
- log.info("Awake now");
- return null;
- }
-}
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/SortAction.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/SortAction.java
deleted file mode 100644
index 9f375ba..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/SortAction.java
+++ /dev/null
@@ -1,401 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-
-/**
- * Sort lines of text
- *
- * @version $Rev: 722776 $ $Date: 2008-12-03 05:59:59 +0100 (Wed, 03 Dec 2008) $
- */
-@Command(scope = "shell", name = "sort", description = "Write sorted concatenation of all files to standard output.")
-public class SortAction extends OsgiCommandSupport {
-
- @Option(name = "-f", aliases = { "-ignore-case" }, description = "fold lower case to upper case characters", required = false, multiValued = false)
- private boolean caseInsensitive;
-
- @Option(name = "-r", aliases = { "--reverse" }, description = "reverse the result of comparisons", required = false, multiValued = false)
- private boolean reverse;
-
- @Option(name = "-u", aliases = { "--unique" }, description = "output only the first of an equal run", required = false, multiValued = false)
- private boolean unique;
-
- @Option(name = "-t", aliases = { "--field-separator" }, description = "use SEP instead of non-blank to blank transition", required = false, multiValued = false)
- private String separator;
-
- @Option(name = "-b", aliases = { "--ignore-leading-blanks" }, description = "ignore leading blanks", required = false, multiValued = false)
- private boolean ignoreBlanks;
-
- @Option(name = "-k", aliases = { "--key" }, description = "Fields to use for sorting separated by whitespaces", required = false, multiValued = true)
- private List<String> sortFields;
-
- @Option(name = "-n", aliases = { "--numeric-sort" }, description = "compare according to string numerical value", required = false, multiValued = false)
- private boolean numeric;
-
- @Argument(index = 0, name = "files", description = "A list of files separated by whitespaces", required = false, multiValued = true)
- private List<String> paths;
-
-
- public Object doExecute() throws Exception {
- if (paths != null && paths.size() > 0) {
- List<String> lines = new ArrayList<String>();
- for (String filename : paths) {
- BufferedReader reader;
-
- // First try a URL
- try {
- URL url = new URL(filename);
- log.info("Printing URL: " + url);
- reader = new BufferedReader(new InputStreamReader(url.openStream()));
- }
- catch (MalformedURLException ignore) {
- // They try a file
- File file = new File(filename);
- log.info("Printing file: " + file);
- reader = new BufferedReader(new FileReader(file));
- }
-
- try {
- read(reader, lines);
- }
- finally {
- try {
- reader.close();
- } catch (IOException e) {
- // Ignore
- }
- }
- }
- sort(lines, System.out);
- }
- else {
- sort(System.in, System.out);
- }
- return null;
- }
-
- protected void read(BufferedReader r, List<String> lines) throws Exception {
- for (String s = r.readLine(); s != null; s = r.readLine()) {
- lines.add(s);
- }
- }
-
- protected void sort(InputStream input, PrintStream out) throws Exception {
- List<String> strings = new ArrayList<String>();
- BufferedReader r = new BufferedReader(new InputStreamReader(input));
- read(r, strings);
- sort(strings, out);
- }
-
- protected void sort(List<String> strings, PrintStream out) throws Exception {
- char sep = (separator == null || separator.length() == 0) ? '\0' : separator.charAt(0);
- Collections.sort(strings, new SortComparator(caseInsensitive, reverse, ignoreBlanks, numeric, sep, sortFields));
- String last = null;
- for (String s : strings) {
- if (last == null) {
- last = s;
- } else if (!unique || !s.equals(last)) {
- out.println(s);
- }
- }
- }
-
- public static class SortComparator implements Comparator<String> {
-
- private boolean caseInsensitive;
- private boolean reverse;
- private boolean ignoreBlanks;
- private boolean numeric;
- private char separator;
- private List<Key> sortKeys;
-
- private static Pattern fpPattern;
- static {
- final String Digits = "(\\p{Digit}+)";
- final String HexDigits = "(\\p{XDigit}+)";
- final String Exp = "[eE][+-]?" + Digits;
- final String fpRegex = "([\\x00-\\x20]*[+-]?(NaN|Infinity|(((" + Digits + "(\\.)?(" + Digits + "?)(" + Exp + ")?)|(\\.(" + Digits + ")(" + Exp + ")?)|(((0[xX]" + HexDigits + "(\\.)?)|(0[xX]" + HexDigits + "?(\\.)" + HexDigits + "))[pP][+-]?" + Digits + "))" + "[fFdD]?))[\\x00-\\x20]*)(.*)";
- fpPattern = Pattern.compile(fpRegex);
- }
-
- public SortComparator(boolean caseInsensitive,
- boolean reverse,
- boolean ignoreBlanks,
- boolean numeric,
- char separator,
- List<String> sortFields) {
- this.caseInsensitive = caseInsensitive;
- this.reverse = reverse;
- this.separator = separator;
- this.ignoreBlanks = ignoreBlanks;
- this.numeric = numeric;
- if (sortFields == null || sortFields.size() == 0) {
- sortFields = new ArrayList<String>();
- sortFields.add("1");
- }
- sortKeys = new ArrayList<Key>();
- for (String f : sortFields) {
- sortKeys.add(new Key(f));
- }
- }
-
- public int compare(String o1, String o2) {
- int res = 0;
-
- List<Integer> fi1 = getFieldIndexes(o1);
- List<Integer> fi2 = getFieldIndexes(o2);
- for (Key key : sortKeys) {
- int[] k1 = getSortKey(o1, fi1, key);
- int[] k2 = getSortKey(o2, fi2, key);
- if (key.numeric) {
- Double d1 = getDouble(o1, k1[0], k1[1]);
- Double d2 = getDouble(o2, k2[0], k2[1]);
- res = d1.compareTo(d2);
- } else {
- res = compareRegion(o1, k1[0], k1[1], o2, k2[0], k2[1], key.caseInsensitive);
- }
- if (res != 0) {
- if (key.reverse) {
- res = - res;
- }
- break;
- }
- }
- return res;
- }
-
- protected Double getDouble(String s, int start, int end) {
- Matcher m = fpPattern.matcher(s.substring(start, end));
- m.find();
- return new Double(s.substring(0, m.end(1)));
- }
-
- protected int compareRegion(String s1, int start1, int end1, String s2, int start2, int end2, boolean caseInsensitive) {
- int n1 = end1, n2 = end2;
- for (int i1 = start1, i2 = start2; i1 < end1 && i2 < n2; i1++, i2++) {
- char c1 = s1.charAt(i1);
- char c2 = s2.charAt(i2);
- if (c1 != c2) {
- if (caseInsensitive) {
- c1 = Character.toUpperCase(c1);
- c2 = Character.toUpperCase(c2);
- if (c1 != c2) {
- c1 = Character.toLowerCase(c1);
- c2 = Character.toLowerCase(c2);
- if (c1 != c2) {
- return c1 - c2;
- }
- }
- } else {
- return c1 - c2;
- }
- }
- }
- return n1 - n2;
- }
-
- protected int[] getSortKey(String str, List<Integer> fields, Key key) {
- int start;
- int end;
- if (key.startField * 2 < fields.size()) {
- start = fields.get((key.startField - 1) * 2);
- if (key.ignoreBlanksStart) {
- while (start < fields.get((key.startField - 1) * 2 + 1) && Character.isWhitespace(str.charAt(start))) {
- start++;
- }
- }
- if (key.startChar > 0) {
- start = Math.min(start + key.startChar - 1, fields.get((key.startField - 1) * 2 + 1));
- }
- } else {
- start = 0;
- }
- if (key.endField > 0 && key.endField * 2 < fields.size()) {
- end = fields.get((key.endField - 1) * 2);
- if (key.ignoreBlanksEnd) {
- while (end < fields.get((key.endField - 1) * 2 + 1) && Character.isWhitespace(str.charAt(end))) {
- end++;
- }
- }
- if (key.endChar > 0) {
- end = Math.min(end + key.endChar - 1, fields.get((key.endField - 1) * 2 + 1));
- }
- } else {
- end = str.length();
- }
- return new int[] { start, end };
- }
-
- protected List<Integer> getFieldIndexes(String o) {
- List<Integer> fields = new ArrayList<Integer>();
- if (o.length() > 0) {
- if (separator == '\0') {
- int i = 0;
- fields.add(0);
- for (int idx = 1; idx < o.length(); idx++) {
- if (Character.isWhitespace(o.charAt(idx)) && !Character.isWhitespace(o.charAt(idx - 1))) {
- fields.add(idx - 1);
- fields.add(idx);
- }
- }
- fields.add(o.length() - 1);
- } else {
- int last = -1;
- for (int idx = o.indexOf(separator); idx >= 0; idx = o.indexOf(separator, idx + 1)) {
- if (last >= 0) {
- fields.add(last);
- fields.add(idx - 1);
- } else if (idx > 0) {
- fields.add(0);
- fields.add(idx - 1);
- }
- last = idx + 1;
- }
- if (last < o.length()) {
- fields.add(last < 0 ? 0 : last);
- fields.add(o.length() - 1);
- }
- }
- }
- return fields;
- }
-
- public class Key {
- int startField;
- int startChar;
- int endField;
- int endChar;
- boolean ignoreBlanksStart;
- boolean ignoreBlanksEnd;
- boolean caseInsensitive;
- boolean reverse;
- boolean numeric;
-
- public Key(String str) {
- boolean modifiers = false;
- boolean startPart = true;
- boolean inField = true;
- boolean inChar = false;
- for (char c : str.toCharArray()) {
- switch (c) {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (!inField && !inChar) {
- throw new IllegalArgumentException("Bad field syntax: " + str);
- }
- if (startPart) {
- if (inChar) {
- startChar = startChar * 10 + (c - '0');
- } else {
- startField = startField * 10 + (c - '0');
- }
- } else {
- if (inChar) {
- endChar = endChar * 10 + (c - '0');
- } else {
- endField = endField * 10 + (c - '0');
- }
- }
- break;
- case '.':
- if (!inField) {
- throw new IllegalArgumentException("Bad field syntax: " + str);
- }
- inField = false;
- inChar = true;
- break;
- case 'n':
- inField = false;
- inChar = false;
- modifiers = true;
- numeric = true;
- break;
- case 'f':
- inField = false;
- inChar = false;
- modifiers = true;
- caseInsensitive = true;
- break;
- case 'r':
- inField = false;
- inChar = false;
- modifiers = true;
- reverse = true;
- break;
- case 'b':
- inField = false;
- inChar = false;
- modifiers = true;
- if (startPart) {
- ignoreBlanksStart = true;
- } else {
- ignoreBlanksEnd = true;
- }
- break;
- case ',':
- inField = true;
- inChar = false;
- startPart = false;
- break;
- default:
- throw new IllegalArgumentException("Bad field syntax: " + str);
- }
- }
- if (!modifiers) {
- ignoreBlanksStart = ignoreBlanksEnd = SortComparator.this.ignoreBlanks;
- reverse = SortComparator.this.reverse;
- caseInsensitive = SortComparator.this.caseInsensitive;
- numeric = SortComparator.this.numeric;
- }
- if (startField < 1) {
- throw new IllegalArgumentException("Bad field syntax: " + str);
- }
- }
- }
- }
-
-}
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/SourceAction.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/SourceAction.java
deleted file mode 100644
index 82b482d..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/SourceAction.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-/**
- * TODO
- */
-public class SourceAction {
-}
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/TacAction.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/TacAction.java
deleted file mode 100644
index 376fcb4..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/TacAction.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-import java.io.StringWriter;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.File;
-import java.io.OutputStream;
-import java.io.BufferedWriter;
-import java.io.BufferedOutputStream;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.Option;
-
-/**
- * Grab the text from the standard input and return it as a string.
- * Also write this text to a file if specified
- *
- * @version $Rev: 593392 $ $Date: 2007-11-09 03:14:15 +0100 (Fri, 09 Nov 2007) $
- */
-@Command(scope = "shell", name = "tac", description = "Captures the STDIN and returns it as a string. Optionally writes the content to a file")
-public class TacAction extends OsgiCommandSupport {
-
- @Option(name = "-f", aliases = {}, description = "Outputs the content to the given file", required = false, multiValued = false)
- private File file;
-
- protected Object doExecute() throws Exception {
- StringWriter sw = new StringWriter();
- Writer[] writers;
- if (file != null) {
- writers = new Writer[] { sw, new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file))) };
- } else {
- writers = new Writer[] { sw };
- }
- BufferedReader rdr = new BufferedReader(new InputStreamReader(System.in));
- String s = rdr.readLine();
- boolean first = true;
- while (s != null)
- {
- for (Writer w : writers) {
- if (!first) {
- w.write("\n");
- }
- w.write(s);
- }
- first = false;
- s = rdr.readLine();
- }
- for (Writer w : writers) {
- w.close();
- }
- return sw.toString();
- }
-}
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/utils/PumpStreamHandler.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/utils/PumpStreamHandler.java
deleted file mode 100644
index ba0d839..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/utils/PumpStreamHandler.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.karaf.shell.commands.utils;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-
-//
-// Based on Apache Ant 1.6.5
-//
-
-/**
- * Copies standard output and error of children streams to standard output and error of the parent.
- *
- * @version $Rev: 705608 $ $Date: 2008-10-17 15:28:45 +0200 (Fri, 17 Oct 2008) $
- */
-public class PumpStreamHandler
-{
- private InputStream in;
-
- private OutputStream out;
-
- private OutputStream err;
-
- private Thread outputThread;
-
- private Thread errorThread;
-
- private StreamPumper inputPump;
-
- //
- // NOTE: May want to use a ThreadPool here, 3 threads per/pair seems kinda expensive :-(
- //
-
- public PumpStreamHandler(final InputStream in, final OutputStream out, final OutputStream err) {
- assert in != null;
- assert out != null;
- assert err != null;
-
- this.in = in;
- this.out = out;
- this.err = err;
- }
-
- public PumpStreamHandler(final OutputStream out, final OutputStream err) {
- this(null, out, err);
- }
-
- public PumpStreamHandler(final OutputStream outAndErr) {
- this(outAndErr, outAndErr);
- }
-
- /**
- * Set the input stream from which to read the standard output of the child.
- */
- public void setChildOutputStream(final InputStream in) {
- assert in != null;
-
- createChildOutputPump(in, out);
- }
-
- /**
- * Set the input stream from which to read the standard error of the child.
- */
- public void setChildErrorStream(final InputStream in) {
- assert in != null;
-
- if (err != null) {
- createChildErrorPump(in, err);
- }
- }
-
- /**
- * Set the output stream by means of which input can be sent to the child.
- */
- public void setChildInputStream(final OutputStream out) {
- assert out != null;
-
- if (in != null) {
- inputPump = createInputPump(in, out, true);
- }
- else {
- try {
- out.close();
- } catch (IOException e) { }
- }
- }
-
- /**
- * Attach to a child streams from the given process.
- *
- * @param p The process to attach to.
- */
- public void attach(final Process p) {
- assert p != null;
-
- setChildInputStream(p.getOutputStream());
- setChildOutputStream(p.getInputStream());
- setChildErrorStream(p.getErrorStream());
- }
- /**
- * Start pumping the streams.
- */
- public void start() {
- if (outputThread != null) {
- outputThread.start();
- }
-
- if (errorThread != null) {
- errorThread.start();
- }
-
- if (inputPump != null) {
- Thread inputThread = new Thread(inputPump);
- inputThread.setDaemon(true);
- inputThread.start();
- }
- }
-
- /**
- * Stop pumping the streams.
- */
- public void stop() {
- if (outputThread != null) {
- try {
- outputThread.join();
- }
- catch (InterruptedException e) {
- // ignore
- }
- }
-
- if (errorThread != null) {
- try {
- errorThread.join();
- }
- catch (InterruptedException e) {
- // ignore
- }
- }
-
- if (inputPump != null) {
- inputPump.stop();
- }
-
- try {
- err.flush();
- } catch (IOException e) { }
- try {
- out.flush();
- } catch (IOException e) { }
- }
-
- /**
- * Create the pump to handle child output.
- */
- protected void createChildOutputPump(final InputStream in, final OutputStream out) {
- assert in != null;
- assert out != null;
-
- outputThread = createPump(in, out);
- }
-
- /**
- * Create the pump to handle error output.
- */
- protected void createChildErrorPump(final InputStream in, final OutputStream out) {
- assert in != null;
- assert out != null;
-
- errorThread = createPump(in, out);
- }
-
- /**
- * Creates a stream pumper to copy the given input stream to the given output stream.
- */
- protected Thread createPump(final InputStream in, final OutputStream out) {
- assert in != null;
- assert out != null;
-
- return createPump(in, out, false);
- }
-
- /**
- * Creates a stream pumper to copy the given input stream to the
- * given output stream.
- *
- * @param in The input stream to copy from.
- * @param out The output stream to copy to.
- * @param closeWhenExhausted If true close the inputstream.
- * @return A thread object that does the pumping.
- */
- protected Thread createPump(final InputStream in, final OutputStream out, final boolean closeWhenExhausted) {
- assert in != null;
- assert out != null;
-
- final Thread result = new Thread(new StreamPumper(in, out, closeWhenExhausted));
- result.setDaemon(true);
- return result;
- }
-
- /**
- * Creates a stream pumper to copy the given input stream to the
- * given output stream. Used for standard input.
- */
- protected StreamPumper createInputPump(final InputStream in, final OutputStream out, final boolean closeWhenExhausted) {
- assert in != null;
- assert out != null;
-
- StreamPumper pumper = new StreamPumper(in, out, closeWhenExhausted);
- pumper.setAutoflush(true);
- return pumper;
- }
-}
\ No newline at end of file
diff --git a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/utils/StreamPumper.java b/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/utils/StreamPumper.java
deleted file mode 100644
index 9d15286..0000000
--- a/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/utils/StreamPumper.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.karaf.shell.commands.utils;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-
-//
-// Based on Apache Ant 1.6.5
-//
-
-/**
- * Copies all data from an input stream to an output stream.
- *
- * @version $Rev: 705608 $ $Date: 2008-10-17 15:28:45 +0200 (Fri, 17 Oct 2008) $
- */
-public class StreamPumper
- implements Runnable
-{
- private InputStream in;
-
- private OutputStream out;
-
- private volatile boolean finish;
-
- private volatile boolean finished;
-
- private boolean closeWhenExhausted;
-
- private boolean autoflush;
-
- private Exception exception;
-
- private int bufferSize = 128;
-
- private boolean started;
-
- /**
- * Create a new stream pumper.
- *
- * @param in Input stream to read data from
- * @param out Output stream to write data to.
- * @param closeWhenExhausted If true, the output stream will be closed when
- * the input is exhausted.
- */
- public StreamPumper(final InputStream in, final OutputStream out, final boolean closeWhenExhausted) {
- assert in != null;
- assert out != null;
-
- this.in = in;
- this.out = out;
- this.closeWhenExhausted = closeWhenExhausted;
- }
-
- /**
- * Create a new stream pumper.
- *
- * @param in Input stream to read data from
- * @param out Output stream to write data to.
- */
- public StreamPumper(final InputStream in, final OutputStream out) {
- this(in, out, false);
- }
-
- /**
- * Set whether data should be flushed through to the output stream.
- *
- * @param autoflush If true, push through data; if false, let it be buffered
- */
- public void setAutoflush(boolean autoflush) {
- this.autoflush = autoflush;
- }
-
- /**
- * Copies data from the input stream to the output stream.
- *
- * Terminates as soon as the input stream is closed or an error occurs.
- */
- public void run() {
- synchronized (this) {
- started = true;
- }
- finished = false;
- finish = false;
-
- final byte[] buf = new byte[bufferSize];
-
- int length;
- try {
- do {
- while (in.available() > 0 && !finish) {
- length = in.read(buf);
- if (length < 1 ) {
- break;
- }
- out.write(buf, 0, length);
- if (autoflush) {
- out.flush();
- }
- }
- out.flush();
- Thread.sleep(200); // Pause to avoid tight loop if external proc is slow
- } while (!finish && closeWhenExhausted);
- }
- catch (Exception e) {
- synchronized (this) {
- exception = e;
- }
- }
- finally {
- if (closeWhenExhausted) {
- try {
- out.close();
- } catch (IOException e) { }
- }
- finished = true;
-
- synchronized (this) {
- notifyAll();
- }
- }
- }
-
- /**
- * Tells whether the end of the stream has been reached.
- *
- * @return true If the stream has been exhausted.
- */
- public boolean isFinished() {
- return finished;
- }
-
- /**
- * This method blocks until the stream pumper finishes.
- *
- * @see #isFinished()
- */
- public synchronized void waitFor() throws InterruptedException {
- while (!isFinished()) {
- wait();
- }
- }
-
- /**
- * Set the size in bytes of the read buffer.
- *
- * @param bufferSize the buffer size to use.
- * @throws IllegalStateException if the StreamPumper is already running.
- */
- public synchronized void setBufferSize(final int bufferSize) {
- if (started) {
- throw new IllegalStateException("Cannot set buffer size on a running StreamPumper");
- }
-
- this.bufferSize = bufferSize;
- }
-
- /**
- * Get the size in bytes of the read buffer.
- *
- * @return The size of the read buffer.
- */
- public synchronized int getBufferSize() {
- return bufferSize;
- }
-
- /**
- * Get the exception encountered, if any.
- *
- * @return The Exception encountered; or null if there was none.
- */
- public synchronized Exception getException() {
- return exception;
- }
-
- /**
- * Stop the pumper as soon as possible.
- *
- * Note that it may continue to block on the input stream
- * but it will really stop the thread as soon as it gets EOF
- * or any byte, and it will be marked as finished.
- */
- public synchronized void stop() {
- finish = true;
-
- notifyAll();
- }
-}
\ No newline at end of file
diff --git a/karaf/shell/commands/src/main/resources/OSGI-INF/blueprint/shell-commands.xml b/karaf/shell/commands/src/main/resources/OSGI-INF/blueprint/shell-commands.xml
deleted file mode 100644
index ec7e7c1..0000000
--- a/karaf/shell/commands/src/main/resources/OSGI-INF/blueprint/shell-commands.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <command-bundle xmlns="http://felix.apache.org/karaf/xmlns/shell/v1.0.0">
- <command name="shell/cat">
- <action class="org.apache.felix.karaf.shell.commands.CatAction"/>
- </command>
- <command name="shell/each">
- <action class="org.apache.felix.karaf.shell.commands.EachAction"/>
- </command>
- <command name="shell/echo">
- <action class="org.apache.felix.karaf.shell.commands.EchoAction"/>
- </command>
- <command name="shell/exec">
- <action class="org.apache.felix.karaf.shell.commands.ExecuteAction"/>
- </command>
- <command name="shell/grep">
- <action class="org.apache.felix.karaf.shell.commands.GrepAction"/>
- </command>
- <command name="shell/history">
- <action class="org.apache.felix.karaf.shell.commands.HistoryAction"/>
- </command>
- <command name="shell/if">
- <action class="org.apache.felix.karaf.shell.commands.IfAction"/>
- </command>
- <command name="shell/info">
- <action class="org.apache.felix.karaf.shell.commands.InfoAction"/>
- </command>
- <command name="shell/clear">
- <action class="org.apache.felix.karaf.shell.commands.ClearAction"/>
- </command>
- <command name="shell/java">
- <action class="org.apache.felix.karaf.shell.commands.JavaAction"/>
- </command>
- <!--
- <command name="shell/more">
- <action class="org.apache.felix.karaf.shell.commands.MoreAction"/>
- </command>
- -->
- <command name="shell/new">
- <action class="org.apache.felix.karaf.shell.commands.NewAction">
- <property name="blueprintConverter" ref="blueprintConverter"/>
- </action>
- </command>
- <command name="shell/logout">
- <action class="org.apache.felix.karaf.shell.commands.LogoutAction"/>
- </command>
- <command name="shell/printf">
- <action class="org.apache.felix.karaf.shell.commands.PrintfAction"/>
- </command>
- <command name="shell/sleep">
- <action class="org.apache.felix.karaf.shell.commands.SleepAction"/>
- </command>
- <command name="shell/sort">
- <action class="org.apache.felix.karaf.shell.commands.SortAction"/>
- </command>
- <!--
- <command name="shell/source">
- <action class="org.apache.felix.karaf.shell.commands.SourceAction"/>
- </command>
- -->
- <command name="shell/tac">
- <action class="org.apache.felix.karaf.shell.commands.TacAction"/>
- </command>
- </command-bundle>
-
-</blueprint>
diff --git a/karaf/shell/commands/src/test/java/org/apache/felix/karaf/shell/commands/GrepTest.java b/karaf/shell/commands/src/test/java/org/apache/felix/karaf/shell/commands/GrepTest.java
deleted file mode 100644
index 0469d64..0000000
--- a/karaf/shell/commands/src/test/java/org/apache/felix/karaf/shell/commands/GrepTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-import org.apache.felix.gogo.commands.basic.DefaultActionPreparator;
-
-public class GrepTest extends TestCase {
-
- public void testGrep() throws Exception {
- InputStream input = System.in;
- try {
- ByteArrayInputStream bais = new ByteArrayInputStream("1\n2\n3\n4\n5\n6\n7\n8\n9\n".getBytes());
- System.setIn(bais);
-
- GrepAction grep = new GrepAction();
- DefaultActionPreparator preparator = new DefaultActionPreparator();
- preparator.prepare(grep, null, Arrays.<Object>asList("-C", "100", "2"));
- grep.doExecute();
- } finally {
- System.setIn(input);
- }
- }
-}
diff --git a/karaf/shell/commands/src/test/java/org/apache/felix/karaf/shell/commands/SortTest.java b/karaf/shell/commands/src/test/java/org/apache/felix/karaf/shell/commands/SortTest.java
deleted file mode 100644
index 8e9d72f..0000000
--- a/karaf/shell/commands/src/test/java/org/apache/felix/karaf/shell/commands/SortTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.commands;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Collections;
-
-import junit.framework.TestCase;
-
-public class SortTest extends TestCase {
-
- public void testFieldIndexesDefaultSep() {
- SortAction.SortComparator comparator = new SortAction.SortComparator(false, false, false, false, '\0', null);
- List<Integer> indexes = comparator.getFieldIndexes(" ad re t ");
- assertTrue(Arrays.asList(0, 2, 3, 6, 7, 9, 10, 10).equals(indexes));
- }
-
- public void testFieldIndexesWithSep() {
- SortAction.SortComparator comparator = new SortAction.SortComparator(false, false, false, false, '[', null);
- List<Integer> indexes = comparator.getFieldIndexes("[ 10] [Active ] [ ] [ 8] OPS4J Pax Logging - Service (1.3.0)");
- assertTrue(Arrays.asList(1, 6, 8, 20, 22, 30, 32, 73 ).equals(indexes));
-
- indexes = comparator.getFieldIndexes(" ad re t ");
- assertTrue(Arrays.asList(0, 10).equals(indexes));
- }
-
- public void testSort() {
- String s0 = "0321 abcd ddcba a";
- String s1 = " 57t bcad ddacb b";
- String s2 = " 128 cab ddbac c";
- List<String> strings = Arrays.asList(s0, s1, s2);
-
- Collections.sort(strings, new SortAction.SortComparator(false, false, false, false, '\0', Arrays.asList("2")));
- assertTrue(Arrays.asList(s0, s1, s2).equals(strings));
-
- Collections.sort(strings, new SortAction.SortComparator(false, false, false, false, '\0', Arrays.asList("2.2b")));
- assertTrue(Arrays.asList(s2, s0, s1).equals(strings));
-
- Collections.sort(strings, new SortAction.SortComparator(false, false, false, true, '\0', null));
- assertTrue(Arrays.asList(s1, s2, s0).equals(strings));
- }
-
-}
diff --git a/karaf/shell/config/NOTICE b/karaf/shell/config/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/shell/config/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/shell/config/pom.xml b/karaf/shell/config/pom.xml
deleted file mode 100644
index ec086e6..0000000
--- a/karaf/shell/config/pom.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-<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/maven-v4_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.felix.karaf.shell</groupId>
- <artifactId>shell</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.config</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Shell ConfigAdmin Commands</name>
-
- <description>
- Provides the ConfigAdmin Shell commands
- </description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Import-Package>
- !${project.artifactId}*,
- org.osgi.service.command,
- org.apache.felix.gogo.commands,
- org.apache.felix.karaf.shell.console,
- *
- </Import-Package>
- <Private-Package>!*</Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/CancelCommand.java b/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/CancelCommand.java
deleted file mode 100644
index 15e31ca..0000000
--- a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/CancelCommand.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.config;
-
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "config", name = "cancel", description = "Cancel the changes to the configuration being edited.")
-public class CancelCommand extends ConfigCommandSupport {
-
- protected void doExecute(ConfigurationAdmin admin) throws Exception {
- session.put(PROPERTY_CONFIG_PID, null);
- session.put(PROPERTY_CONFIG_PROPS, null);
- }
-
-}
diff --git a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/ConfigCommandSupport.java b/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/ConfigCommandSupport.java
deleted file mode 100644
index 9d945b7..0000000
--- a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/ConfigCommandSupport.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.config;
-
-import java.util.Dictionary;
-
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ConfigurationAdmin;
-
-/**
- * Abstract class from which all commands related to the ConfigurationAdmin
- * service should derive.
- * This command retrieves a reference to the ConfigurationAdmin service before
- * calling another method to actually process the command.
- */
-public abstract class ConfigCommandSupport extends OsgiCommandSupport {
-
- public static final String PROPERTY_CONFIG_PID = "ConfigCommand.PID";
- public static final String PROPERTY_CONFIG_PROPS = "ConfigCommand.Props";
-
- protected Object doExecute() throws Exception {
- // Get config admin service.
- ServiceReference ref = getBundleContext().getServiceReference(ConfigurationAdmin.class.getName());
- if (ref == null) {
- System.out.println("ConfigurationAdmin service is unavailable.");
- return null;
- }
- try {
- ConfigurationAdmin admin = (ConfigurationAdmin) getBundleContext().getService(ref);
- if (admin == null) {
- System.out.println("ConfigAdmin service is unavailable.");
- return null;
- }
-
- doExecute(admin);
- }
- finally {
- getBundleContext().ungetService(ref);
- }
- return null;
- }
-
- protected Dictionary getEditedProps() throws Exception {
- return (Dictionary) this.session.get(PROPERTY_CONFIG_PROPS);
- }
-
- protected abstract void doExecute(ConfigurationAdmin admin) throws Exception;
-
-}
diff --git a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/EditCommand.java b/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/EditCommand.java
deleted file mode 100644
index ea807f4..0000000
--- a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/EditCommand.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.config;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Command;
-import org.osgi.service.cm.ConfigurationAdmin;
-
-@Command(scope = "config", name = "edit", description = "Create or edit a configuration.")
-public class EditCommand extends ConfigCommandSupport {
-
- @Argument(index = 0, name = "pid", description = "PID of the configuration", required = true, multiValued = false)
- String pid;
-
- @Option(name = "--force", aliases = {}, description = "Force the edition of this config, even if another one was under edition", required = false, multiValued = false)
- boolean force;
-
- protected void doExecute(ConfigurationAdmin admin) throws Exception {
- String oldPid = (String) this.session.get(PROPERTY_CONFIG_PID);
- if (oldPid != null && !oldPid.equals(pid) && !force) {
- System.err.println("Another config is being edited. Cancel / update first, or use the --force option");
- return;
- }
- Dictionary props = admin.getConfiguration(pid).getProperties();
- if (props == null) {
- props = new Properties();
- }
- this.session.put(PROPERTY_CONFIG_PID, pid);
- this.session.put(PROPERTY_CONFIG_PROPS, props);
- }
-}
diff --git a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/ListCommand.java b/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/ListCommand.java
deleted file mode 100644
index b0a0eb5..0000000
--- a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/ListCommand.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.config;
-
-import java.util.Dictionary;
-import java.util.Enumeration;
-
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "config", name = "list", description = "Lists existing configurations.")
-public class ListCommand extends ConfigCommandSupport {
-
- @Argument(index = 0, name = "query", description = "Specify a LDAP query", required = false, multiValued = false)
- String query;
-
- protected void doExecute(ConfigurationAdmin admin) throws Exception {
- Configuration[] configs = admin.listConfigurations(query);
- for (Configuration config : configs) {
- System.out.println("----------------------------------------------------------------");
- System.out.println("Pid: " + config.getPid());
- if (config.getFactoryPid() != null) {
- System.out.println("FactoryPid: " + config.getFactoryPid());
- }
- System.out.println("BundleLocation: " + config.getBundleLocation());
- if (config.getProperties() != null) {
- System.out.println("Properties:");
- Dictionary props = config.getProperties();
- for (Enumeration e = props.keys(); e.hasMoreElements();) {
- Object key = e.nextElement();
- System.out.println(" " + key + " = " + props.get(key));
- }
- }
- }
- }
-}
diff --git a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/PropAppendCommand.java b/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/PropAppendCommand.java
deleted file mode 100644
index a6a441d..0000000
--- a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/PropAppendCommand.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.config;
-
-import java.util.Dictionary;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.osgi.service.cm.ConfigurationAdmin;
-
-/**
- * Appends a value to the current property value.
- */
-@Command(scope = "config", name = "propappend", description = "Appends the given value to an existing property or creates the property with the specified name and value.")
-public class PropAppendCommand extends ConfigCommandSupport {
-
- @Argument(index = 0, name = "name", description = "The name of the property", required = true, multiValued = false)
- String prop;
-
- @Argument(index = 1, name = "value", description = "The value to append to the property", required = true, multiValued = false)
- String value;
-
- @Override
- protected void doExecute(ConfigurationAdmin admin) throws Exception {
- Dictionary props = getEditedProps();
- if (props == null) {
- System.err.println("No configuration is being edited. Run the edit command first");
- } else {
- final Object currentValue = props.get(prop);
- if (currentValue == null) {
- props.put(prop, value);
- } else if (currentValue instanceof String) {
- props.put(prop, currentValue + value);
- } else {
- System.err.println("Append Failed: current value is not a String.");
- }
- }
- }
-
-}
diff --git a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/PropDelCommand.java b/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/PropDelCommand.java
deleted file mode 100644
index d6959eb..0000000
--- a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/PropDelCommand.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.config;
-
-import java.util.Dictionary;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.osgi.service.cm.ConfigurationAdmin;
-
-@Command(scope = "config", name = "propdel", description = "Deletes a property from the edited configuration.")
-public class PropDelCommand extends ConfigCommandSupport {
-
- @Argument(index = 0, name = "property", description = "The name of the property to delete", required = true, multiValued = false)
- String prop;
-
- protected void doExecute(ConfigurationAdmin admin) throws Exception {
- Dictionary props = getEditedProps();
- if (props == null) {
- System.err.println("No configuration is being edited. Run the edit command first");
- } else {
- props.remove(prop);
- }
- }
-
-}
diff --git a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/PropListCommand.java b/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/PropListCommand.java
deleted file mode 100644
index 905b664..0000000
--- a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/PropListCommand.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.config;
-
-import java.util.Dictionary;
-import java.util.Enumeration;
-
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "config", name = "proplist", description = "Lists properties from the currently edited configuration.")
-public class PropListCommand extends ConfigCommandSupport {
-
- protected void doExecute(ConfigurationAdmin admin) throws Exception {
- Dictionary props = getEditedProps();
- if (props == null) {
- System.err.println("No configuration is being edited. Run the edit command first");
- } else {
- for (Enumeration e = props.keys(); e.hasMoreElements();) {
- Object key = e.nextElement();
- System.out.println(" " + key + " = " + props.get(key));
- }
- }
- }
-
-}
diff --git a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/PropSetCommand.java b/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/PropSetCommand.java
deleted file mode 100644
index d8a12ea..0000000
--- a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/PropSetCommand.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.config;
-
-import java.util.Dictionary;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.osgi.service.cm.ConfigurationAdmin;
-
-@Command(scope = "config", name = "propset", description = "Sets a property in the currently edited configuration.")
-public class PropSetCommand extends ConfigCommandSupport {
-
- @Argument(index = 0, name = "property", description = "The name of the property to set", required = true, multiValued = false)
- String prop;
-
- @Argument(index = 1, name = "value", description = "The value of the property", required = true, multiValued = false)
- String value;
-
- protected void doExecute(ConfigurationAdmin admin) throws Exception {
- Dictionary props = getEditedProps();
- if (props == null) {
- System.err.println("No configuration is being edited. Run the edit command first");
- } else {
- props.put(prop, value);
- }
- }
-
-}
diff --git a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/UpdateCommand.java b/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/UpdateCommand.java
deleted file mode 100644
index 9da60a2..0000000
--- a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/UpdateCommand.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.config;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Properties;
-
-import org.apache.felix.gogo.commands.Option;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "config", name = "update", description = "Save and propagate changes from the configuration being edited.")
-public class UpdateCommand extends ConfigCommandSupport {
-
- @Option(name = "-b", aliases = { "--bypass-storage" }, multiValued = false, required = false, description = "Do not store the configuration in a properties file, but feed it directly to ConfigAdmin")
- private boolean bypassStorage;
-
- private File storage;
-
- public File getStorage() {
- return storage;
- }
-
- public void setStorage(File storage) {
- this.storage = storage;
- }
-
- protected void doExecute(ConfigurationAdmin admin) throws Exception {
- Dictionary props = getEditedProps();
- if (props == null) {
- System.err.println("No configuration is being edited. Run the edit command first");
- } else if (!bypassStorage && storage != null) {
- Properties p = new Properties();
- for (Enumeration keys = props.keys(); keys.hasMoreElements();) {
- Object key = keys.nextElement();
- if (!"service.pid".equals(key) && !"felix.fileinstall.filename".equals(key)) {
- p.put(key, props.get(key));
- }
- }
- storage.mkdirs();
- String pid = (String) this.session.get(PROPERTY_CONFIG_PID);
- FileOutputStream os = new FileOutputStream(new File(storage, pid + ".cfg"));
- try {
- p.store(os, null);
- } finally {
- os.close();
- }
- this.session.put(PROPERTY_CONFIG_PID, null);
- this.session.put(PROPERTY_CONFIG_PROPS, null);
- } else {
- String pid = (String) this.session.get(PROPERTY_CONFIG_PID);
- Configuration cfg = admin.getConfiguration(pid, null);
- cfg.update(props);
- this.session.put(PROPERTY_CONFIG_PID, null);
- this.session.put(PROPERTY_CONFIG_PROPS, null);
- }
- }
-}
diff --git a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/completers/ConfigurationCompleter.java b/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/completers/ConfigurationCompleter.java
deleted file mode 100644
index c366f1e..0000000
--- a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/completers/ConfigurationCompleter.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.karaf.shell.config.completers;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.felix.karaf.shell.console.completer.StringsCompleter;
-import org.apache.felix.karaf.shell.console.Completer;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.cm.ConfigurationEvent;
-import org.osgi.service.cm.ConfigurationListener;
-
-/**
- * {@link jline.Completor} for Configuration Admin configurations.
- *
- * Displays a list of existing config admin configurations for completion.
- *
- */
-public class ConfigurationCompleter implements Completer, ConfigurationListener {
-
- private final StringsCompleter delegate = new StringsCompleter();
-
- private ConfigurationAdmin admin;
-
- public void setAdmin(ConfigurationAdmin admin) {
- this.admin = admin;
- }
-
- public void init() {
- Configuration[] configs;
- try {
- configs = admin.listConfigurations(null);
- if (configs == null) {
- return;
- }
- } catch (Exception e) {
- return;
- }
-
- Collection<String> pids = new ArrayList<String>();
-
- for (Configuration config : configs) {
- if (config.getFactoryPid() != null) {
- pids.add(config.getFactoryPid());
- } else {
- pids.add(config.getPid());
- }
- }
-
- delegate.getStrings().addAll(pids);
-
- }
-
- public int complete(final String buffer, final int cursor, final List candidates) {
- return delegate.complete(buffer, cursor, candidates);
- }
-
- public void configurationEvent(ConfigurationEvent configurationEvent) {
- String pid = configurationEvent.getFactoryPid()!=null ? configurationEvent.getFactoryPid() : configurationEvent.getPid();
- if (configurationEvent.getType() == ConfigurationEvent.CM_DELETED) {
- delegate.getStrings().remove(pid);
- } else if (configurationEvent.getType() == ConfigurationEvent.CM_UPDATED) {
- delegate.getStrings().add(pid);
- }
- }
-}
diff --git a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/completers/ConfigurationPropertyCompleter.java b/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/completers/ConfigurationPropertyCompleter.java
deleted file mode 100644
index d74b524..0000000
--- a/karaf/shell/config/src/main/java/org/apache/felix/karaf/shell/config/completers/ConfigurationPropertyCompleter.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.karaf.shell.config.completers;
-
-import java.util.List;
-
-import org.apache.felix.karaf.shell.console.Completer;
-
-/**
- * {@link jline.Completor} for Configuration Admin properties.
- *
- * Displays a list of existing properties based on the current configuration being edited.
- *
- */
-public class ConfigurationPropertyCompleter implements Completer {
-
- public int complete(final String buffer, final int cursor, final List candidates) {
- // TODO: currently we have no way to access the session which is being run in this thread
- return -1;
-
-// if (vars.get(ConfigCommandSupport.PROPERTY_CONFIG_PID) == null) {
-// return -1;
-// }
-//
-// Dictionary props = (Dictionary) vars.get(ConfigCommandSupport.PROPERTY_CONFIG_PROPS);
-// StringsCompleter delegate = new StringsCompleter();
-//
-// for (Enumeration e = props.keys(); e.hasMoreElements();) {
-// String key = (String) e.nextElement();
-// delegate.getStrings().add(key);
-// }
-//
-// return delegate.complete(buffer, cursor, candidates);
- }
-}
diff --git a/karaf/shell/config/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/karaf/shell/config/src/main/resources/OSGI-INF/blueprint/shell-config.xml
deleted file mode 100644
index 342fcc1..0000000
--- a/karaf/shell/config/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
- xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
- default-activation="lazy">
-
- <command-bundle xmlns="http://felix.apache.org/karaf/xmlns/shell/v1.0.0">
- <command name="config/cancel">
- <action class="org.apache.felix.karaf.shell.config.CancelCommand"/>
- </command>
- <command name="config/edit">
- <action class="org.apache.felix.karaf.shell.config.EditCommand"/>
- <completers>
- <ref component-id="configCompleter" />
- <null/>
- </completers>
- </command>
- <command name="config/list">
- <action class="org.apache.felix.karaf.shell.config.ListCommand"/>
- </command>
- <command name="config/propdel">
- <action class="org.apache.felix.karaf.shell.config.PropDelCommand"/>
- <completers>
- <ref component-id="configPropertyCompleter" />
- <null/>
- </completers>
- </command>
- <command name="config/proplist">
- <action class="org.apache.felix.karaf.shell.config.PropListCommand"/>
- </command>
- <command name="config/propset">
- <action class="org.apache.felix.karaf.shell.config.PropSetCommand"/>
- <completers>
- <ref component-id="configPropertyCompleter" />
- <null/>
- </completers>
- </command>
- <command name="config/propappend">
- <action class="org.apache.felix.karaf.shell.config.PropAppendCommand"/>
- <completers>
- <ref component-id="configPropertyCompleter" />
- <null/>
- </completers>
- </command>
- <command name="config/update">
- <action class="org.apache.felix.karaf.shell.config.UpdateCommand">
- <property name="storage" value="${storage}" />
- </action>
- </command>
- </command-bundle>
-
- <bean id="configCompleter" class="org.apache.felix.karaf.shell.config.completers.ConfigurationCompleter" init-method="init">
- <property name="admin" ref="configAdmin"/>
- </bean>
- <service ref="configCompleter" interface="org.osgi.service.cm.ConfigurationListener" />
-
- <bean id="configPropertyCompleter" class="org.apache.felix.karaf.shell.config.completers.ConfigurationPropertyCompleter" />
-
- <reference id="configAdmin" interface="org.osgi.service.cm.ConfigurationAdmin" />
-
- <ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]" />
-
- <cm:property-placeholder persistent-id="org.apache.felix.karaf.shell.config">
- <cm:default-properties>
- <cm:property name="storage" value="$[karaf.base]/etc/"/>
- </cm:default-properties>
- </cm:property-placeholder>
-
-</blueprint>
diff --git a/karaf/shell/config/src/main/resources/OSGI-INF/metatype/metatype.properties b/karaf/shell/config/src/main/resources/OSGI-INF/metatype/metatype.properties
deleted file mode 100644
index 206b662..0000000
--- a/karaf/shell/config/src/main/resources/OSGI-INF/metatype/metatype.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-#
-# This file contains localization strings for configuration labels and
-# descriptions as used in the metatype.xml descriptor
-
-config.name = Apache Felix Karaf Shell Config
-config.description = Configuration of Apache Felix Karaf Shell Config
-
-storage.name = Storage directory
-storage.description = the directory used as a storage for configurations
diff --git a/karaf/shell/config/src/main/resources/OSGI-INF/metatype/metatype.xml b/karaf/shell/config/src/main/resources/OSGI-INF/metatype/metatype.xml
deleted file mode 100644
index 8fe7363..0000000
--- a/karaf/shell/config/src/main/resources/OSGI-INF/metatype/metatype.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0" localization="OSGI-INF/metatype/metatype">
- <OCD id="org.apache.felix.karaf.shell.config" name="%config.name" description="%config.description">
- <AD id="storage" type="String" default="${karaf.base}/etc/"
- name="%storage.name" description="%storage.description"/>
- </OCD>
- <Designate pid="org.apache.felix.karaf.shell.config">
- <Object ocdref="org.apache.felix.karaf.shell.config"/>
- </Designate>
-</metatype:MetaData>
diff --git a/karaf/shell/config/src/test/java/org/apache/felix/karaf/shell/config/EditCommandTest.java b/karaf/shell/config/src/test/java/org/apache/felix/karaf/shell/config/EditCommandTest.java
deleted file mode 100644
index f4787c1..0000000
--- a/karaf/shell/config/src/test/java/org/apache/felix/karaf/shell/config/EditCommandTest.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.config;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-
-import java.io.InputStream;
-import java.io.PrintStream;
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.command.CommandSession;
-
-/**
- * Test cases for {@link EditCommand}
- */
-public class EditCommandTest extends TestCase {
-
- private static final String PID = "my.test.persistent.id";
-
- private EditCommand command;
- private BundleContext context;
- private ConfigurationAdmin admin;
- private CommandSession session;
-
- @Override
- protected void setUp() throws Exception {
- command = new EditCommand();
-
- context = EasyMock.createMock(BundleContext.class);
- command.setBundleContext(context);
-
- ServiceReference reference = createMock(ServiceReference.class);
- expect(context.getServiceReference(ConfigurationAdmin.class.getName())).andReturn(reference);
-
- admin = createMock(ConfigurationAdmin.class);
- expect(context.getService(reference)).andReturn(admin);
- expect(context.ungetService(reference)).andReturn(Boolean.TRUE);
-
- replay(context);
-
- session = new MockCommandSession();
- }
-
- public void testExecuteOnExistingPid() throws Exception {
- Configuration config = createMock(Configuration.class);
- expect(admin.getConfiguration(PID)).andReturn(config);
- replay(admin);
-
- // the ConfigAdmin service returns a Dictionary for an existing PID
- Properties props = new Properties();
- expect(config.getProperties()).andReturn(props);
- replay(config);
-
- command.pid = PID;
- command.execute(session);
-
- // the PID and Dictionary should have been set on the session
- assertEquals("The PID should be set on the session",
- PID, session.get(ConfigCommandSupport.PROPERTY_CONFIG_PID));
- assertSame("The Dictionary returned by the ConfigAdmin service should be set on the session",
- props, session.get(ConfigCommandSupport.PROPERTY_CONFIG_PROPS));
- }
-
- @SuppressWarnings("unchecked")
- public void testExecuteOnNewPid() throws Exception {
- Configuration config = createMock(Configuration.class);
- expect(admin.getConfiguration(PID)).andReturn(config);
- replay(admin);
-
- // the ConfigAdmin service does not return a Dictionary for a new PID
- expect(config.getProperties()).andReturn(null);
- replay(config);
-
- command.pid = PID;
- command.execute(session);
-
- // the PID and an empty Dictionary should have been set on the session
- assertEquals("The PID should be set on the session",
- PID, session.get(ConfigCommandSupport.PROPERTY_CONFIG_PID));
- Dictionary props = (Dictionary) session.get(ConfigCommandSupport.PROPERTY_CONFIG_PROPS);
- assertNotNull("Should have a Dictionary on the session", props);
- assertTrue("Should have an empty Dictionary on the session", props.isEmpty());
- }
-
- /*
- * A mock CommandSession implementation that only cares about the properties set on the session
- */
- private class MockCommandSession implements CommandSession {
-
- private Map<String, Object> properties = new HashMap<String, Object>();
-
- public void close() {
- // not implemented
- }
-
- public Object convert(Class<?> type, Object instance) {
- // not implemented
- return null;
- }
-
- public Object execute(CharSequence commandline) throws Exception {
- // not implemented
- return null;
- }
-
- public CharSequence format(Object target, int level) {
- // not implemented
- return null;
- }
-
- public Object get(String name) {
- return properties.get(name);
- }
-
- public PrintStream getConsole() {
- // not implemented
- return null;
- }
-
- public InputStream getKeyboard() {
- // not implemented
- return null;
- }
-
- public void put(String name, Object value) {
- properties.put(name, value);
- }
- }
-}
diff --git a/karaf/shell/console/NOTICE b/karaf/shell/console/NOTICE
deleted file mode 100644
index e6bc1e8..0000000
--- a/karaf/shell/console/NOTICE
+++ /dev/null
@@ -1,29 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-This product includes software developed at
-FUSE Source (http://www.fusesource.org/).
-Licensed under the Apache License 2.0.
-
-This product includes software developed at
-JLine (http://jline.sourceforge.net).
-Licensed under the BSD License.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/shell/console/pom.xml b/karaf/shell/console/pom.xml
deleted file mode 100644
index 60bb571..0000000
--- a/karaf/shell/console/pom.xml
+++ /dev/null
@@ -1,136 +0,0 @@
-<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/maven-v4_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.felix.karaf.shell</groupId>
- <artifactId>shell</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Shell Console</name>
-
- <description>
- Provides the OSGi Shell integration
- </description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>jline</groupId>
- <artifactId>jline</artifactId>
- </dependency>
- <dependency>
- <groupId>org.fusesource.jansi</groupId>
- <artifactId>jansi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.aries.blueprint</groupId>
- <artifactId>org.apache.aries.blueprint</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.gogo</groupId>
- <artifactId>org.apache.felix.gogo.runtime</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <resources>
- <resource>
- <directory>${project.basedir}/src/main/resources</directory>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- <resource>
- <directory>${project.basedir}/src/main/filtered-resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <configuration>
- <mainClass>Main</mainClass>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Import-Package>
- !org.apache.felix.karaf.shell.console*,
- !org.apache.felix.gogo.commands*,
- !org.fusesource.jansi*,
- !javax.swing,
- !jline,
- com.sun.jna*;resolution:=optional,
- org.apache.felix.karaf.branding;resolution:=optional,
- *
- </Import-Package>
- <Export-Package>
- org.apache.felix.gogo.commands*;version=${felix.gogo.version},
- org.apache.felix.karaf.shell.console*;version=${project.version},
- org.fusesource.jansi;version=${jansi.version},
- jline;version=${jline.version}
- </Export-Package>
- <Private-Package>
- org.fusesource.jansi.internal
- </Private-Package>
- <Bundle-NativeCode>jline/jline32.dll;
- osname=Win32;
- processor=x86,
- jline/jline64.dll;
- osname=Win32;
- processor=x86-64,
- *
- </Bundle-NativeCode>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- <unpackBundle>true</unpackBundle>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/karaf/shell/console/src/main/filtered-resources/org/apache/felix/karaf/shell/console/branding.properties b/karaf/shell/console/src/main/filtered-resources/org/apache/felix/karaf/shell/console/branding.properties
deleted file mode 100644
index 5b62a4f..0000000
--- a/karaf/shell/console/src/main/filtered-resources/org/apache/felix/karaf/shell/console/branding.properties
+++ /dev/null
@@ -1,33 +0,0 @@
-##
-## Licensed to the Apache Software Foundation (ASF) under one
-## or more contributor license agreements. See the NOTICE file
-## distributed with this work for additional information
-## regarding copyright ownership. The ASF licenses this file
-## to you under the Apache License, Version 2.0 (the
-## "License"); you may not use this file except in compliance
-## with the License. You may obtain a copy of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing,
-## software distributed under the License is distributed on an
-## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-## KIND, either express or implied. See the License for the
-## specific language governing permissions and limitations
-## under the License.
-##
-
-welcome = \
-\u001B[36m __ __ ____ \u001B[0m\r\n\
-\u001B[36m / //_/____ __________ _/ __/ \u001B[0m\r\n\
-\u001B[36m / ,< / __ `/ ___/ __ `/ /_ \u001B[0m\r\n\
-\u001B[36m / /| |/ /_/ / / / /_/ / __/ \u001B[0m\r\n\
-\u001B[36m /_/ |_|\\__,_/_/ \\__,_/_/ \u001B[0m\r\n\
-\r\n\
-\u001B[1m Apache Felix Karaf\u001B[0m (${project.version})\r\n\
-\r\n\
-Hit '\u001B[1m<tab>\u001B[0m' for a list of available commands\r\n\
- and '\u001B[1m[cmd] --help\u001B[0m' for help on a specific command.\r\n\
-Hit '\u001B[1m<ctrl-d>\u001B[0m' or '\u001B[1mosgi:shutdown\u001B[0m' to shutdown Karaf.\r\n
-
-
diff --git a/karaf/shell/console/src/main/java/jline/AnsiWindowsTerminal.java b/karaf/shell/console/src/main/java/jline/AnsiWindowsTerminal.java
deleted file mode 100644
index 077ee72..0000000
--- a/karaf/shell/console/src/main/java/jline/AnsiWindowsTerminal.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package jline;
-
-import org.fusesource.jansi.AnsiConsole;
-import org.fusesource.jansi.WindowsAnsiOutputStream;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-public class AnsiWindowsTerminal extends WindowsTerminal {
-
- private boolean ansisupported = checkAnsiSupport();
-
- @Override
- public boolean isANSISupported() {
- return ansisupported;
- }
-
- @Override
- public int readCharacter(InputStream in) throws IOException {
- return in.read();
- }
-
- public int readDirectChar(InputStream in) throws IOException {
- return super.readCharacter(in);
- }
-
- public static boolean checkAnsiSupport() {
- OutputStream dummy = new ByteArrayOutputStream();
- OutputStream ansiout = AnsiConsole.wrapOutputStream(dummy);
- try {
- dummy.close();
- ansiout.close();
- } catch (IOException ignore) {
- }
-
- return (ansiout instanceof WindowsAnsiOutputStream);
-
- }
-
-}
diff --git a/karaf/shell/console/src/main/java/jline/NoInterruptUnixTerminal.java b/karaf/shell/console/src/main/java/jline/NoInterruptUnixTerminal.java
deleted file mode 100644
index 9093a40..0000000
--- a/karaf/shell/console/src/main/java/jline/NoInterruptUnixTerminal.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy 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 jline;
-
-import java.io.IOException;
-
-public class NoInterruptUnixTerminal extends UnixTerminal {
-
- @Override
- public void initializeTerminal() throws IOException, InterruptedException {
- super.initializeTerminal();
- stty("intr undef");
- }
-
- @Override
- public void restoreTerminal() throws Exception {
- stty("intr ^C");
- super.restoreTerminal();
- }
-
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/Action.java b/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/Action.java
deleted file mode 100644
index 7979a41..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/Action.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.gogo.commands;
-
-import org.osgi.service.command.CommandSession;
-
-public interface Action
-{
-
- Object execute(CommandSession session) throws Exception;
-
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/Argument.java b/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/Argument.java
deleted file mode 100644
index e1b8f7f..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/Argument.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.gogo.commands;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.FIELD})
-public @interface Argument
-{
- String name() default "VAL";
-
- String description() default "";
-
- boolean required() default false;
-
- int index() default 0;
-
- boolean multiValued() default false;
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/Command.java b/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/Command.java
deleted file mode 100644
index 9f94e1f..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/Command.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.gogo.commands;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE})
-public @interface Command
-{
- String scope();
-
- String name();
-
- String description() default "";
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/Option.java b/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/Option.java
deleted file mode 100644
index 0197ff5..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/Option.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.gogo.commands;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.FIELD})
-public @interface Option
-{
- String name();
-
- String[] aliases() default {};
-
- String description() default "";
-
- boolean required() default false;
-
- boolean multiValued() default false;
-
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/basic/AbstractCommand.java b/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/basic/AbstractCommand.java
deleted file mode 100644
index 1cf3a72..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/basic/AbstractCommand.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.gogo.commands.basic;
-
-import java.util.List;
-
-import org.apache.felix.gogo.commands.basic.DefaultActionPreparator;
-import org.apache.felix.gogo.commands.basic.ActionPreparator;
-import org.apache.felix.gogo.commands.Action;
-import org.osgi.service.command.CommandSession;
-import org.osgi.service.command.Function;
-
-public abstract class AbstractCommand implements Function {
-
- public Object execute(CommandSession session, List<Object> arguments) throws Exception {
- Action action = createNewAction();
- try {
- if (getPreparator().prepare(action, session, arguments)) {
- return action.execute(session);
- } else {
- return null;
- }
- } finally {
- releaseAction(action);
- }
- }
-
- protected abstract Action createNewAction() throws Exception;
-
- /**
- * Release the used Action.
- * This method has to be overridden for pool based Actions.
- * @param action Action that was executed
- * @throws Exception if something went wrong during the Action release
- */
- protected void releaseAction(Action action) throws Exception {
- // Do nothing by default (stateful)
- }
-
- protected ActionPreparator getPreparator() throws Exception {
- return new DefaultActionPreparator();
- }
-
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/basic/ActionPreparator.java b/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/basic/ActionPreparator.java
deleted file mode 100644
index ef289e8..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/basic/ActionPreparator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.gogo.commands.basic;
-
-import java.util.List;
-
-import org.osgi.service.command.CommandSession;
-import org.apache.felix.gogo.commands.Action;
-
-public interface ActionPreparator {
-
- boolean prepare(Action action, CommandSession session, List<Object> arguments) throws Exception;
-
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/basic/DefaultActionPreparator.java b/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/basic/DefaultActionPreparator.java
deleted file mode 100644
index b124691..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/basic/DefaultActionPreparator.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.gogo.commands.basic;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.reflect.Type;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Arrays;
-import java.util.Set;
-import java.util.HashSet;
-import java.io.PrintStream;
-
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Action;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.basic.ActionPreparator;
-import org.apache.felix.gogo.commands.converter.DefaultConverter;
-import org.osgi.service.command.CommandSession;
-
-public class DefaultActionPreparator implements ActionPreparator {
-
- protected static final Option HELP = new Option() {
- public String name()
- {
- return "--help";
- }
-
- public String[] aliases()
- {
- return new String[] { };
- }
-
- public String description()
- {
- return "Display this help message";
- }
-
- public boolean required()
- {
- return false;
- }
-
- public boolean multiValued()
- {
- return false;
- }
-
- public Class<? extends Annotation> annotationType()
- {
- return Option.class;
- }
- };
-
- public boolean prepare(Action action, CommandSession session, List<Object> params) throws Exception
- {
- Map<Option, Field> options = new HashMap<Option, Field>();
- Map<Argument, Field> arguments = new HashMap<Argument, Field>();
- List<Argument> orderedArguments = new ArrayList<Argument>();
- // Introspect
- for (Class type = action.getClass(); type != null; type = type.getSuperclass()) {
- for (Field field : type.getDeclaredFields()) {
- Option option = field.getAnnotation(Option.class);
- if (option != null) {
- options.put(option, field);
- }
- Argument argument = field.getAnnotation(Argument.class);
- if (argument != null) {
- arguments.put(argument, field);
- int index = argument.index();
- while (orderedArguments.size() <= index) {
- orderedArguments.add(null);
- }
- if (orderedArguments.get(index) != null) {
- throw new IllegalArgumentException("Duplicate argument index: " + index);
- }
- orderedArguments.set(index, argument);
- }
- }
- }
- // Check indexes are correct
- for (int i = 0; i < orderedArguments.size(); i++) {
- if (orderedArguments.get(i) == null) {
- throw new IllegalArgumentException("Missing argument for index: " + i);
- }
- }
- // Populate
- Map<Option, Object> optionValues = new HashMap<Option, Object>();
- Map<Argument, Object> argumentValues = new HashMap<Argument, Object>();
- boolean processOptions = true;
- int argIndex = 0;
- for (Iterator<Object> it = params.iterator(); it.hasNext();) {
- Object param = it.next();
- // Check for help
- if (HELP.name().equals(param) || Arrays.asList(HELP.aliases()).contains(param)) {
- printUsage(session, action.getClass().getAnnotation(Command.class), options.keySet(), arguments.keySet(), System.out);
- return false;
- }
- if (processOptions && param instanceof String && ((String) param).startsWith("-")) {
- boolean isKeyValuePair = ((String) param).indexOf('=') != -1;
- String name;
- Object value = null;
- if (isKeyValuePair) {
- name = ((String) param).substring(0, ((String) param).indexOf('='));
- value = ((String) param).substring(((String) param).indexOf('=') + 1);
- } else {
- name = (String) param;
- }
- Option option = null;
- for (Option opt : options.keySet()) {
- if (name.equals(opt.name()) || Arrays.binarySearch(opt.aliases(), name) >= 0) {
- option = opt;
- break;
- }
- }
- if (option == null) {
- throw new IllegalArgumentException("Undefined option: " + param);
- }
- Field field = options.get(option);
- if (value == null && (field.getType() == boolean.class || field.getType() == Boolean.class)) {
- value = Boolean.TRUE;
- }
- if (value == null && it.hasNext()) {
- value = it.next();
- }
- if (value == null) {
- throw new IllegalArgumentException("Missing value for option " + param);
- }
- if (option.multiValued()) {
- List<Object> l = (List<Object>) optionValues.get(option);
- if (l == null) {
- l = new ArrayList<Object>();
- optionValues.put(option, l);
- }
- l.add(value);
- } else {
- optionValues.put(option, value);
- }
- } else {
- processOptions = false;
- if (argIndex >= orderedArguments.size()) {
- throw new IllegalArgumentException("Too many arguments specified");
- }
- Argument argument = orderedArguments.get(argIndex);
- if (!argument.multiValued()) {
- argIndex++;
- }
- if (argument.multiValued()) {
- List<Object> l = (List<Object>) argumentValues.get(argument);
- if (l == null) {
- l = new ArrayList<Object>();
- argumentValues.put(argument, l);
- }
- l.add(param);
- } else {
- argumentValues.put(argument, param);
- }
- }
- }
- // Check required arguments / options
- for (Option option : options.keySet()) {
- if (option.required() && optionValues.get(option) == null) {
- throw new IllegalArgumentException("Option " + option.name() + " is required");
- }
- }
- for (Argument argument : arguments.keySet()) {
- if (argument.required() && argumentValues.get(argument) == null) {
- throw new IllegalArgumentException("Argument " + argument.name() + " is required");
- }
- }
- // Convert and inject values
- for (Map.Entry<Option, Object> entry : optionValues.entrySet()) {
- Field field = options.get(entry.getKey());
- Object value = convert(action, session, entry.getValue(), field.getGenericType());
- field.setAccessible(true);
- field.set(action, value);
- }
- for (Map.Entry<Argument, Object> entry : argumentValues.entrySet()) {
- Field field = arguments.get(entry.getKey());
- Object value = convert(action, session, entry.getValue(), field.getGenericType());
- field.setAccessible(true);
- field.set(action, value);
- }
- return true;
- }
-
- protected void printUsage(CommandSession session, Command command, Set<Option> options, Set<Argument> arguments, PrintStream out)
- {
- options = new HashSet<Option>(options);
- options.add(HELP);
- if (command != null && command.description() != null && command.description().length() > 0)
- {
- out.println(command.description());
- out.println();
- }
- String syntax = "syntax: ";
- if (command != null)
- {
- syntax += command.scope() + ":" + command.name();
- }
- if (options.size() > 0)
- {
- syntax += " [options]";
- }
- if (arguments.size() > 0)
- {
- syntax += " [arguments]";
- }
- out.println(syntax);
- out.println();
- if (arguments.size() > 0)
- {
- out.println("arguments:");
- for (Argument argument : arguments)
- {
- out.print(" ");
- out.print(argument.name());
- out.print(" ");
- out.print(argument.description());
- out.println();
- }
- out.println();
- }
- if (options.size() > 0)
- {
- out.println("options:");
- for (Option option : options)
- {
- out.print(" ");
- out.print(option.name());
- out.print(" ");
- if (option.aliases().length > 0)
- {
- out.print("(");
- out.print(Arrays.toString(option.aliases()));
- out.print(") ");
- }
- out.print(option.description());
- out.println();
- }
- out.println();
- }
- }
-
- protected Object convert(Action action, CommandSession session, Object value, Type toType) throws Exception
- {
- return new DefaultConverter(action.getClass().getClassLoader()).convert(value, toType);
- }
-
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/basic/SimpleCommand.java b/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/basic/SimpleCommand.java
deleted file mode 100644
index 175281e..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/basic/SimpleCommand.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.gogo.commands.basic;
-
-import java.util.Hashtable;
-
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.command.Function;
-import org.apache.felix.gogo.commands.basic.AbstractCommand;
-import org.apache.felix.gogo.commands.Action;
-import org.apache.felix.gogo.commands.Command;
-
-public class SimpleCommand extends AbstractCommand {
-
- private Class<? extends Action> actionClass;
-
- public SimpleCommand()
- {
- }
-
- public SimpleCommand(Class<? extends Action> actionClass)
- {
- this.actionClass = actionClass;
- }
-
- public Class<? extends Action> getActionClass()
- {
- return actionClass;
- }
-
- public void setActionClass(Class<? extends Action> actionClass)
- {
- this.actionClass = actionClass;
- }
-
- protected Action createNewAction() throws Exception {
- return actionClass.newInstance();
- }
-
-
- public static ServiceRegistration export(BundleContext context, Class<? extends Action> actionClass)
- {
- Command cmd = actionClass.getAnnotation(Command.class);
- if (cmd == null)
- {
- throw new IllegalArgumentException("Action class is not annotated with @Command");
- }
- Hashtable props = new Hashtable();
- props.put("osgi.command.scope", cmd.scope());
- props.put("osgi.command.function", cmd.name());
- SimpleCommand command = new SimpleCommand(actionClass);
- return context.registerService(Function.class.getName(), command, props);
- }
-
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/converter/DefaultConverter.java b/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/converter/DefaultConverter.java
deleted file mode 100644
index df20321..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/converter/DefaultConverter.java
+++ /dev/null
@@ -1,403 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.gogo.commands.converter;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Dictionary;
-import java.util.Locale;
-import java.util.Properties;
-import java.util.Hashtable;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.SortedMap;
-import java.util.TreeMap;
-import java.util.LinkedHashMap;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.Set;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Queue;
-import java.util.LinkedList;
-import java.util.regex.Pattern;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ConcurrentHashMap;
-import java.math.BigInteger;
-import java.math.BigDecimal;
-import java.io.ByteArrayInputStream;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Array;
-import java.lang.reflect.Type;
-import java.lang.reflect.InvocationTargetException;
-
-import org.apache.felix.gogo.commands.converter.ReifiedType;
-
-public class DefaultConverter
-{
-
- private Object loader;
-
- public DefaultConverter(Object loader) {
- this.loader = loader;
- }
-
- public Object convert(Object source, Type target) throws Exception {
- return convert( source, new GenericType(target));
- }
-
- public Object convert(Object fromValue, ReifiedType type) throws Exception {
- // Discard null values
- if (fromValue == null) {
- return null;
- }
- // If the object is an instance of the type, just return it
- if (isAssignable(fromValue, type)) {
- return fromValue;
- }
- Object value = convertWithConverters(fromValue, type);
- if (value == null) {
- if (fromValue instanceof Number && Number.class.isAssignableFrom(unwrap(toClass(type)))) {
- return convertToNumber((Number) fromValue, toClass(type));
- } else if (fromValue instanceof String) {
- return convertFromString((String) fromValue, toClass(type), loader);
- } else if (toClass(type).isArray() && (fromValue instanceof Collection || fromValue.getClass().isArray())) {
- return convertToArray(fromValue, type);
- } else if (Map.class.isAssignableFrom(toClass(type)) && (fromValue instanceof Map || fromValue instanceof Dictionary)) {
- return convertToMap(fromValue, type);
- } else if (Dictionary.class.isAssignableFrom(toClass(type)) && (fromValue instanceof Map || fromValue instanceof Dictionary)) {
- return convertToDictionary(fromValue, type);
- } else if (Collection.class.isAssignableFrom(toClass(type)) && (fromValue instanceof Collection || fromValue.getClass().isArray())) {
- return convertToCollection(fromValue, type);
- } else {
- throw new Exception("Unable to convert value " + fromValue + " to type " + type);
- }
- }
- return value;
- }
-
- private Object convertWithConverters(Object source, ReifiedType type) throws Exception {
- Object value = null;
-// for (Converter converter : converters) {
-// if (converter.canConvert(source, type)) {
-// value = converter.convert(source, type);
-// if (value != null) {
-// return value;
-// }
-// }
-// }
- return value;
- }
-
- public Object convertToNumber(Number value, Class toType) throws Exception {
- toType = unwrap(toType);
- if (AtomicInteger.class == toType) {
- return new AtomicInteger((Integer) convertToNumber(value, Integer.class));
- } else if (AtomicLong.class == toType) {
- return new AtomicLong((Long) convertToNumber(value, Long.class));
- } else if (Integer.class == toType) {
- return value.intValue();
- } else if (Short.class == toType) {
- return value.shortValue();
- } else if (Long.class == toType) {
- return value.longValue();
- } else if (Float.class == toType) {
- return value.floatValue();
- } else if (Double.class == toType) {
- return value.doubleValue();
- } else if (Byte.class == toType) {
- return value.byteValue();
- } else if (BigInteger.class == toType) {
- return new BigInteger(value.toString());
- } else if (BigDecimal.class == toType) {
- return new BigDecimal(value.toString());
- } else {
- throw new Exception("Unable to convert number " + value + " to " + toType);
- }
- }
-
- public Object convertFromString(String value, Class toType, Object loader) throws Exception {
- toType = unwrap(toType);
- if (ReifiedType.class == toType) {
- try {
- return GenericType.parse(value, loader);
- } catch (ClassNotFoundException e) {
- throw new Exception("Unable to convert", e);
- }
- } else if (Class.class == toType) {
- try {
- return GenericType.parse(value, loader).getRawClass();
- } catch (ClassNotFoundException e) {
- throw new Exception("Unable to convert", e);
- }
- } else if (Locale.class == toType) {
- String[] tokens = value.split("_");
- if (tokens.length == 1) {
- return new Locale(tokens[0]);
- } else if (tokens.length == 2) {
- return new Locale(tokens[0], tokens[1]);
- } else if (tokens.length == 3) {
- return new Locale(tokens[0], tokens[1], tokens[2]);
- } else {
- throw new Exception("Invalid locale string:" + value);
- }
- } else if (Pattern.class == toType) {
- return Pattern.compile(value);
- } else if (Properties.class == toType) {
- Properties props = new Properties();
- ByteArrayInputStream in = new ByteArrayInputStream(value.getBytes("UTF8"));
- props.load(in);
- return props;
- } else if (Boolean.class == toType) {
- if ("yes".equalsIgnoreCase(value) || "true".equalsIgnoreCase(value) || "on".equalsIgnoreCase(value)) {
- return Boolean.TRUE;
- } else if ("no".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value) || "off".equalsIgnoreCase(value)) {
- return Boolean.FALSE;
- } else {
- throw new RuntimeException("Invalid boolean value: " + value);
- }
- } else if (Integer.class == toType) {
- return Integer.valueOf(value);
- } else if (Short.class == toType) {
- return Short.valueOf(value);
- } else if (Long.class == toType) {
- return Long.valueOf(value);
- } else if (Float.class == toType) {
- return Float.valueOf(value);
- } else if (Double.class == toType) {
- return Double.valueOf(value);
- } else if (Character.class == toType) {
- if (value.length() == 6 && value.startsWith("\\u")) {
- int code = Integer.parseInt(value.substring(2), 16);
- return (char)code;
- } else if (value.length() == 1) {
- return value.charAt(0);
- } else {
- throw new Exception("Invalid value for character type: " + value);
- }
- } else if (Byte.class == toType) {
- return Byte.valueOf(value);
- } else if (Enum.class.isAssignableFrom(toType)) {
- return Enum.valueOf((Class<Enum>) toType, value);
- } else {
- return createObject(value, toType);
- }
- }
-
- private static Object createObject(String value, Class type) throws Exception {
- if (type.isInterface() || Modifier.isAbstract(type.getModifiers())) {
- throw new Exception("Unable to convert value " + value + " to type " + type + ". Type " + type + " is an interface or an abstract class");
- }
- Constructor constructor = null;
- try {
- constructor = type.getConstructor(String.class);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException("Unable to convert to " + type);
- }
- try {
- return constructor.newInstance(value);
- } catch (Exception e) {
- throw new Exception("Unable to convert ", getRealCause(e));
- }
- }
-
- private static Throwable getRealCause(Throwable t) {
- if (t instanceof InvocationTargetException && t.getCause() != null) {
- return t.getCause();
- }
- return t;
- }
-
- private Object convertToCollection(Object obj, ReifiedType type) throws Exception {
- ReifiedType valueType = type.getActualTypeArgument(0);
- Collection newCol = (Collection) getCollection(toClass(type)).newInstance();
- if (obj.getClass().isArray()) {
- for (int i = 0; i < Array.getLength(obj); i++) {
- try {
- newCol.add(convert(Array.get(obj, i), valueType));
- } catch (Exception t) {
- throw new Exception("Unable to convert from " + obj + " to " + type + "(error converting array element)", t);
- }
- }
- } else {
- for (Object item : (Collection) obj) {
- try {
- newCol.add(convert(item, valueType));
- } catch (Exception t) {
- throw new Exception("Unable to convert from " + obj + " to " + type + "(error converting collection entry)", t);
- }
- }
- }
- return newCol;
- }
-
- private Object convertToDictionary(Object obj, ReifiedType type) throws Exception {
- ReifiedType keyType = type.getActualTypeArgument(0);
- ReifiedType valueType = type.getActualTypeArgument(1);
- Dictionary newDic = new Hashtable();
- if (obj instanceof Dictionary) {
- Dictionary dic = (Dictionary) obj;
- for (Enumeration keyEnum = dic.keys(); keyEnum.hasMoreElements();) {
- Object key = keyEnum.nextElement();
- try {
- newDic.put(convert(key, keyType), convert(dic.get(key), valueType));
- } catch (Exception t) {
- throw new Exception("Unable to convert from " + obj + " to " + type + "(error converting map entry)", t);
- }
- }
- } else {
- for (Map.Entry e : ((Map<Object,Object>) obj).entrySet()) {
- try {
- newDic.put(convert(e.getKey(), keyType), convert(e.getValue(), valueType));
- } catch (Exception t) {
- throw new Exception("Unable to convert from " + obj + " to " + type + "(error converting map entry)", t);
- }
- }
- }
- return newDic;
- }
-
- private Object convertToMap(Object obj, ReifiedType type) throws Exception {
- ReifiedType keyType = type.getActualTypeArgument(0);
- ReifiedType valueType = type.getActualTypeArgument(1);
- Map newMap = (Map) getMap(toClass(type)).newInstance();
- if (obj instanceof Dictionary) {
- Dictionary dic = (Dictionary) obj;
- for (Enumeration keyEnum = dic.keys(); keyEnum.hasMoreElements();) {
- Object key = keyEnum.nextElement();
- try {
- newMap.put(convert(key, keyType), convert(dic.get(key), valueType));
- } catch (Exception t) {
- throw new Exception("Unable to convert from " + obj + " to " + type + "(error converting map entry)", t);
- }
- }
- } else {
- for (Map.Entry e : ((Map<Object,Object>) obj).entrySet()) {
- try {
- newMap.put(convert(e.getKey(), keyType), convert(e.getValue(), valueType));
- } catch (Exception t) {
- throw new Exception("Unable to convert from " + obj + " to " + type + "(error converting map entry)", t);
- }
- }
- }
- return newMap;
- }
-
- private Object convertToArray(Object obj, ReifiedType type) throws Exception {
- if (obj instanceof Collection) {
- obj = ((Collection) obj).toArray();
- }
- if (!obj.getClass().isArray()) {
- throw new Exception("Unable to convert from " + obj + " to " + type);
- }
- ReifiedType componentType;
- if (type.size() > 0) {
- componentType = type.getActualTypeArgument(0);
- } else {
- componentType = new GenericType(type.getRawClass().getComponentType());
- }
- Object array = Array.newInstance(toClass(componentType), Array.getLength(obj));
- for (int i = 0; i < Array.getLength(obj); i++) {
- try {
- Array.set(array, i, convert(Array.get(obj, i), componentType));
- } catch (Exception t) {
- throw new Exception("Unable to convert from " + obj + " to " + type + "(error converting array element)", t);
- }
- }
- return array;
- }
-
- public static boolean isAssignable(Object source, ReifiedType target) {
- return source == null
- || (target.size() == 0
- && unwrap(target.getRawClass()).isAssignableFrom(unwrap(source.getClass())));
- }
-
- private static Class unwrap(Class c) {
- Class u = primitives.get(c);
- return u != null ? u : c;
- }
-
- private static Class getMap(Class type) {
- if (hasDefaultConstructor(type)) {
- return type;
- } else if (SortedMap.class.isAssignableFrom(type)) {
- return TreeMap.class;
- } else if (ConcurrentMap.class.isAssignableFrom(type)) {
- return ConcurrentHashMap.class;
- } else {
- return LinkedHashMap.class;
- }
- }
-
- private static Class getCollection(Class type) {
- if (hasDefaultConstructor(type)) {
- return type;
- } else if (SortedSet.class.isAssignableFrom(type)) {
- return TreeSet.class;
- } else if (Set.class.isAssignableFrom(type)) {
- return LinkedHashSet.class;
- } else if (List.class.isAssignableFrom(type)) {
- return ArrayList.class;
- } else if (Queue.class.isAssignableFrom(type)) {
- return LinkedList.class;
- } else {
- return ArrayList.class;
- }
- }
-
- private static boolean hasDefaultConstructor(Class type) {
- if (!Modifier.isPublic(type.getModifiers())) {
- return false;
- }
- if (Modifier.isAbstract(type.getModifiers())) {
- return false;
- }
- Constructor[] constructors = type.getConstructors();
- for (Constructor constructor : constructors) {
- if (Modifier.isPublic(constructor.getModifiers()) &&
- constructor.getParameterTypes().length == 0) {
- return true;
- }
- }
- return false;
- }
-
- private static final Map<Class, Class> primitives;
- static {
- primitives = new HashMap<Class, Class>();
- primitives.put(byte.class, Byte.class);
- primitives.put(short.class, Short.class);
- primitives.put(char.class, Character.class);
- primitives.put(int.class, Integer.class);
- primitives.put(long.class, Long.class);
- primitives.put(float.class, Float.class);
- primitives.put(double.class, Double.class);
- primitives.put(boolean.class, Boolean.class);
- }
-
- private Class toClass(ReifiedType type) {
- return type.getRawClass();
- }
-
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/converter/GenericType.java b/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/converter/GenericType.java
deleted file mode 100644
index 43f5f91..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/converter/GenericType.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.gogo.commands.converter;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.lang.reflect.WildcardType;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.osgi.framework.Bundle;
-import org.apache.felix.gogo.commands.converter.ReifiedType;
-
-public class GenericType extends ReifiedType {
-
- private static final GenericType[] EMPTY = new GenericType[0];
-
- private static final Map<String, Class> primitiveClasses = new HashMap<String, Class>();
-
- static {
- primitiveClasses.put("int", int.class);
- primitiveClasses.put("short", short.class);
- primitiveClasses.put("long", long.class);
- primitiveClasses.put("byte", byte.class);
- primitiveClasses.put("char", char.class);
- primitiveClasses.put("float", float.class);
- primitiveClasses.put("double", double.class);
- primitiveClasses.put("boolean", boolean.class);
- }
-
- private GenericType[] parameters;
-
- public GenericType(Type type) {
- this(getConcreteClass(type), parametersOf(type));
- }
-
- public GenericType(Class clazz, GenericType... parameters) {
- super(clazz);
- this.parameters = parameters;
- }
-
- public static GenericType parse(String type, Object loader) throws ClassNotFoundException, IllegalArgumentException {
- type = type.trim();
- // Check if this is an array
- if (type.endsWith("[]")) {
- GenericType t = parse(type.substring(0, type.length() - 2), loader);
- return new GenericType(Array.newInstance(t.getRawClass(), 0).getClass(), t);
- }
- // Check if this is a generic
- int genericIndex = type.indexOf('<');
- if (genericIndex > 0) {
- if (!type.endsWith(">")) {
- throw new IllegalArgumentException("Can not load type: " + type);
- }
- GenericType base = parse(type.substring(0, genericIndex), loader);
- String[] params = type.substring(genericIndex + 1, type.length() - 1).split(",");
- GenericType[] types = new GenericType[params.length];
- for (int i = 0; i < params.length; i++) {
- types[i] = parse(params[i], loader);
- }
- return new GenericType(base.getRawClass(), types);
- }
- // Primitive
- if (primitiveClasses.containsKey(type)) {
- return new GenericType(primitiveClasses.get(type));
- }
- // Class
- if (loader instanceof ClassLoader) {
- return new GenericType(((ClassLoader) loader).loadClass(type));
- } else if (loader instanceof Bundle) {
- return new GenericType(((Bundle) loader).loadClass(type));
- } else {
- throw new IllegalArgumentException("Unsupported loader: " + loader);
- }
- }
-
- @Override
- public ReifiedType getActualTypeArgument(int i) {
- if (parameters.length == 0) {
- return super.getActualTypeArgument(i);
- }
- return parameters[i];
- }
-
- @Override
- public int size() {
- return parameters.length;
- }
-
- @Override
- public String toString() {
- Class cl = getRawClass();
- if (cl.isArray()) {
- if (parameters.length > 0) {
- return parameters[0].toString() + "[]";
- } else {
- return cl.getComponentType().getName() + "[]";
- }
- }
- if (parameters.length > 0) {
- StringBuilder sb = new StringBuilder();
- sb.append(cl.getName());
- sb.append("<");
- for (int i = 0; i < parameters.length; i++) {
- if (i > 0) {
- sb.append(",");
- }
- sb.append(parameters[i].toString());
- }
- sb.append(">");
- return sb.toString();
- }
- return cl.getName();
- }
-
- static GenericType[] parametersOf(Type type ) {
- if ( type instanceof Class ) {
- Class clazz = (Class) type;
- if (clazz.isArray()) {
- GenericType t = new GenericType(clazz.getComponentType());
- if (t.size() > 0) {
- return new GenericType[] { t };
- } else {
- return EMPTY;
- }
- } else {
- return EMPTY;
- }
- }
- if ( type instanceof ParameterizedType ) {
- ParameterizedType pt = (ParameterizedType) type;
- Type [] parameters = pt.getActualTypeArguments();
- GenericType[] gts = new GenericType[parameters.length];
- for ( int i =0; i<gts.length; i++) {
- gts[i] = new GenericType(parameters[i]);
- }
- return gts;
- }
- if ( type instanceof GenericArrayType ) {
- return new GenericType[] { new GenericType(((GenericArrayType) type).getGenericComponentType()) };
- }
- throw new IllegalStateException();
- }
-
- static Class<?> getConcreteClass(Type type) {
- Type ntype = collapse(type);
- if ( ntype instanceof Class )
- return (Class<?>) ntype;
-
- if ( ntype instanceof ParameterizedType )
- return getConcreteClass(collapse(((ParameterizedType)ntype).getRawType()));
-
- throw new RuntimeException("Unknown type " + type );
- }
-
- static Type collapse(Type target) {
- if (target instanceof Class || target instanceof ParameterizedType ) {
- return target;
- } else if (target instanceof TypeVariable) {
- return collapse(((TypeVariable<?>) target).getBounds()[0]);
- } else if (target instanceof GenericArrayType) {
- Type t = collapse(((GenericArrayType) target)
- .getGenericComponentType());
- while ( t instanceof ParameterizedType )
- t = collapse(((ParameterizedType)t).getRawType());
- return Array.newInstance((Class<?>)t, 0).getClass();
- } else if (target instanceof WildcardType) {
- WildcardType wct = (WildcardType) target;
- if (wct.getLowerBounds().length == 0)
- return collapse(wct.getUpperBounds()[0]);
- else
- return collapse(wct.getLowerBounds()[0]);
- }
- throw new RuntimeException("Huh? " + target);
- }
-
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/converter/ReifiedType.java b/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/converter/ReifiedType.java
deleted file mode 100644
index 239616e..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/gogo/commands/converter/ReifiedType.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
- *
- * Licensed 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.felix.gogo.commands.converter;
-
-/**
- * Provides access to a concrete type and its optional generic type arguments.
- *
- * Java 5 and later support generic types. These types consist of a raw class
- * with type arguments. This class models such a <code>Type</code> class but
- * ensures that the type is <em>reified</em>. Reification means that the Type
- * graph associated with a Java 5 <code>Type</code> instance is traversed
- * until the type becomes a concrete class. In Java 1.4 a class has no
- * arguments. This concrete class implements the Reified Type for Java 1.4.
- *
- * In Java 1.4, this class works with non-generic types. In that cases, a
- * Reified Type provides access to the class and has zero type arguments, though
- * a subclass that provide type arguments should be respected. Blueprint
- * extender implementations can subclass this class and provide access to the
- * generics type graph if used in a conversion. Such a subclass must
- * <em>reify<em> the different Java 5 <code>Type</code> instances into the
- * reified form. That is, a form where the raw Class is available with its optional type arguments as Reified Types.
- *
- * @Immutable
- */
-public class ReifiedType {
- final static ReifiedType ALL = new ReifiedType(Object.class);
-
- private final Class clazz;
-
- /**
- * Create a Reified Type for a raw Java class without any generic arguments.
- * Subclasses can provide the optional generic argument information. Without
- * subclassing, this instance has no type arguments.
- *
- * @param clazz
- * The raw class of the Reified Type.
- */
- public ReifiedType(Class clazz) {
- this.clazz = clazz;
- }
-
- /**
- * Access to the raw class.
- *
- * The raw class represents the concrete class that is associated with a
- * type declaration. This class could have been deduced from the generics
- * type graph of the declaration. For example, in the following example:
- *
- * <pre>
- * Map<String, Object> map;
- * </pre>
- *
- * The raw class is the Map class.
- *
- * @return the collapsed raw class that represents this type.
- */
- public Class getRawClass() {
- return clazz;
- }
-
- /**
- * Access to a type argument.
- *
- * The type argument refers to a argument in a generic type declaration
- * given by index <code>i</code>. This method returns a Reified Type that
- * has Object as class when no generic type information is available. Any
- * object is assignable to Object and therefore no conversion is then
- * necessary, this is compatible with older Javas than 5. For this reason,
- * the implementation in this class always returns the
- * <code>Object<code> class, regardless of the given index.
- *
- * This method should be overridden by a subclass that provides access to
- * the generic information.
- *
- * For example, in the following example:
- *
- * <pre>
- * Map<String, Object> map;
- * </pre>
- *
- * The type argument 0 is <code>String</code>, and type argument 1 is
- * <code>Object</code>.
- *
- * @param i
- * The index of the type argument
- * @return <code>ReifiedType(Object.class)<code>, subclasses must override this and return the generic argument at index <code>i</code>
- */
- public ReifiedType getActualTypeArgument(int i) {
- return ALL;
- }
-
- /**
- * Return the number of type arguments.
- *
- * This method should be overridden by a subclass to support Java 5 types.
- *
- * @return 0, subclasses must override this and return the number of generic
- * arguments
- */
- public int size() {
- return 0;
- }
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/BlueprintContainerAware.java b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/BlueprintContainerAware.java
deleted file mode 100644
index 11b1b68..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/BlueprintContainerAware.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.console;
-
-import org.osgi.service.blueprint.container.BlueprintContainer;
-
-public interface BlueprintContainerAware {
-
- void setBlueprintContainer(BlueprintContainer blueprintContainer);
-
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/BundleContextAware.java b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/BundleContextAware.java
deleted file mode 100644
index c5fbe40..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/BundleContextAware.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.console;
-
-import org.osgi.framework.BundleContext;
-
-public interface BundleContextAware {
-
- void setBundleContext(BundleContext bundleContext);
-
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/CloseShellException.java b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/CloseShellException.java
deleted file mode 100644
index 2753112..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/CloseShellException.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.console;
-
-/**
- * Exception thrown to indicate the console to close.
- */
-public class CloseShellException extends Exception {
-
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/CompletableFunction.java b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/CompletableFunction.java
deleted file mode 100644
index 486474b..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/CompletableFunction.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.console;
-
-import java.util.List;
-
-import org.osgi.service.command.Function;
-
-public interface CompletableFunction extends Function {
-
- List<Completer> getCompleters();
-
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/Completer.java b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/Completer.java
deleted file mode 100644
index b72ba4b..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/Completer.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.console;
-
-import java.util.List;
-
-public interface Completer {
-
- int complete(String buffer, int cursor, List<String> candidates);
-
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/OsgiCommandSupport.java b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/OsgiCommandSupport.java
deleted file mode 100644
index a992893..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/OsgiCommandSupport.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.console;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.felix.gogo.commands.Action;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.command.CommandSession;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class OsgiCommandSupport implements Action, BundleContextAware {
-
- protected final Logger log = LoggerFactory.getLogger(getClass());
- protected BundleContext bundleContext;
- protected CommandSession session;
- protected List<ServiceReference> usedReferences;
-
- public Object execute(CommandSession session) throws Exception {
- this.session = session;
- try {
- return doExecute();
- } finally {
- ungetServices();
- }
- }
-
- protected abstract Object doExecute() throws Exception;
-
- public BundleContext getBundleContext() {
- return bundleContext;
- }
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- protected <T> List<T> getAllServices(Class<T> clazz, String filter) throws Exception {
- ServiceReference[] references = getBundleContext().getAllServiceReferences(clazz.getName(), filter);
- if (references == null) {
- return null;
- }
- List<T> services = new ArrayList<T>();
- for (ServiceReference ref : references) {
- T t = getService(clazz, ref);
- services.add(t);
- }
- return services;
- }
-
- protected <T> T getService(Class<T> clazz, ServiceReference reference) {
- T t = (T) getBundleContext().getService(reference);
- if (t != null) {
- if (usedReferences == null) {
- usedReferences = new ArrayList<ServiceReference>();
- }
- usedReferences.add(reference);
- }
- return t;
- }
-
- protected void ungetServices() {
- if (usedReferences != null) {
- for (ServiceReference ref : usedReferences) {
- getBundleContext().ungetService(ref);
- }
- }
- }
-
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/commands/BlueprintCommand.java b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/commands/BlueprintCommand.java
deleted file mode 100644
index dcb3eb4..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/commands/BlueprintCommand.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.console.commands;
-
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Arrays;
-import java.io.PrintStream;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import jline.Terminal;
-import org.apache.felix.gogo.commands.Action;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.basic.AbstractCommand;
-import org.apache.felix.gogo.commands.basic.ActionPreparator;
-import org.apache.felix.gogo.commands.basic.DefaultActionPreparator;
-import org.apache.felix.karaf.shell.console.BlueprintContainerAware;
-import org.apache.felix.karaf.shell.console.BundleContextAware;
-import org.apache.felix.karaf.shell.console.CompletableFunction;
-import org.apache.felix.karaf.shell.console.Completer;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.blueprint.container.BlueprintContainer;
-import org.osgi.service.blueprint.container.Converter;
-import org.osgi.service.command.CommandSession;
-import org.fusesource.jansi.Ansi;
-
-public class BlueprintCommand extends AbstractCommand implements CompletableFunction
-{
-
- protected BlueprintContainer blueprintContainer;
- protected Converter blueprintConverter;
- protected String actionId;
- protected List<Completer> completers;
-
- public void setBlueprintContainer(BlueprintContainer blueprintContainer) {
- this.blueprintContainer = blueprintContainer;
- }
-
- public void setBlueprintConverter(Converter blueprintConverter) {
- this.blueprintConverter = blueprintConverter;
- }
-
- public void setActionId(String actionId) {
- this.actionId = actionId;
- }
-
- public List<Completer> getCompleters() {
- return completers;
- }
-
- public void setCompleters(List<Completer> completers) {
- this.completers = completers;
- }
-
- @Override
- protected ActionPreparator getPreparator() throws Exception {
- return new BlueprintActionPreparator();
- }
-
- protected class BlueprintActionPreparator extends DefaultActionPreparator {
-
- @Override
- protected Object convert(Action action, CommandSession commandSession, Object o, Type type) throws Exception {
- return blueprintConverter.convert(o, new GenericType(type));
- }
-
- @Override
- protected void printUsage(CommandSession session, Command command, Set<Option> options, Set<Argument> args, PrintStream out)
- {
- Terminal term = (Terminal) session.get(".jline.terminal");
- List<Argument> arguments = new ArrayList<Argument>(args);
- Collections.sort(arguments, new Comparator<Argument>() {
- public int compare(Argument o1, Argument o2) {
- return Integer.valueOf(o1.index()).compareTo(Integer.valueOf(o2.index()));
- }
- });
- options = new HashSet<Option>(options);
- options.add(HELP);
- if (command != null && (command.description() != null || command.name() != null))
- {
- out.println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a("DESCRIPTION").a(Ansi.Attribute.RESET));
- out.print(" ");
- if (command.name() != null) {
- out.println(Ansi.ansi().a(command.scope()).a(":").a(Ansi.Attribute.INTENSITY_BOLD).a(command.name()).a(Ansi.Attribute.RESET));
- out.println();
- }
- out.print("\t");
- out.println(command.description());
- out.println();
- }
- StringBuffer syntax = new StringBuffer();
- if (command != null)
- {
- syntax.append(String.format("%s:%s", command.scope(), command.name()));
- }
- if (options.size() > 0)
- {
- syntax.append(" [options]");
- }
- if (arguments.size() > 0)
- {
- syntax.append(' ');
- for (Argument argument : arguments)
- {
- if (!argument.required())
- {
- syntax.append(String.format("[%s] ", argument.name()));
- }
- else
- {
- syntax.append(String.format("%s ", argument.name()));
- }
- }
- }
-
- out.println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a("SYNTAX").a(Ansi.Attribute.RESET));
- out.print(" ");
- out.println(syntax.toString());
- out.println();
- if (arguments.size() > 0)
- {
- out.println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a("ARGUMENTS").a(Ansi.Attribute.RESET));
- for (Argument argument : arguments)
- {
- out.print(" ");
- out.println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a(argument.name()).a(Ansi.Attribute.RESET));
- printFormatted(" ", argument.description(), term != null ? term.getTerminalWidth() : 80, out);
- }
- out.println();
- }
- if (options.size() > 0)
- {
- out.println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a("OPTIONS").a(Ansi.Attribute.RESET));
- for (Option option : options)
- {
- String opt = option.name();
- for (String alias : option.aliases())
- {
- opt += ", " + alias;
- }
- out.print(" ");
- out.println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a(opt).a(Ansi.Attribute.RESET));
- printFormatted(" ", option.description(), term != null ? term.getTerminalWidth() : 80, out);
- }
- out.println();
- }
- }
-
- protected void printFormatted(String prefix, String str, int termWidth, PrintStream out) {
- int pfxLen = length(prefix);
- int maxwidth = termWidth - pfxLen;
- Pattern wrap = Pattern.compile("(\\S\\S{" + maxwidth + ",}|.{1," + maxwidth + "})(\\s+|$)");
- Matcher m = wrap.matcher(str);
- while (m.find()) {
- out.print(prefix);
- out.println(m.group());
- }
- }
-
- protected int length(String str) {
- return str.length();
- }
-
- }
-
- protected Action createNewAction() throws Exception {
- Action action = (Action) blueprintContainer.getComponentInstance(actionId);
- if (action instanceof BlueprintContainerAware) {
- ((BlueprintContainerAware) action).setBlueprintContainer(blueprintContainer);
- }
- if (action instanceof BundleContextAware) {
- BundleContext context = (BundleContext) blueprintContainer.getComponentInstance("blueprintBundleContext");
- ((BundleContextAware) action).setBundleContext(context);
- }
- return action;
- }
-
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/commands/GenericType.java b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/commands/GenericType.java
deleted file mode 100644
index c417b86..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/commands/GenericType.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.console.commands;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.lang.reflect.WildcardType;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.osgi.framework.Bundle;
-import org.osgi.service.blueprint.container.ReifiedType;
-
-public class GenericType extends ReifiedType {
-
- private static final GenericType[] EMPTY = new GenericType[0];
-
- private static final Map<String, Class> primitiveClasses = new HashMap<String, Class>();
-
- static {
- primitiveClasses.put("int", int.class);
- primitiveClasses.put("short", short.class);
- primitiveClasses.put("long", long.class);
- primitiveClasses.put("byte", byte.class);
- primitiveClasses.put("char", char.class);
- primitiveClasses.put("float", float.class);
- primitiveClasses.put("double", double.class);
- primitiveClasses.put("boolean", boolean.class);
- }
-
- private GenericType[] parameters;
-
- public GenericType(Type type) {
- this(getConcreteClass(type), parametersOf(type));
- }
-
- public GenericType(Class clazz, GenericType... parameters) {
- super(clazz);
- this.parameters = parameters;
- }
-
- public static GenericType parse(String type, Object loader) throws ClassNotFoundException, IllegalArgumentException {
- type = type.trim();
- // Check if this is an array
- if (type.endsWith("[]")) {
- GenericType t = parse(type.substring(0, type.length() - 2), loader);
- return new GenericType(Array.newInstance(t.getRawClass(), 0).getClass(), t);
- }
- // Check if this is a generic
- int genericIndex = type.indexOf('<');
- if (genericIndex > 0) {
- if (!type.endsWith(">")) {
- throw new IllegalArgumentException("Can not load type: " + type);
- }
- GenericType base = parse(type.substring(0, genericIndex), loader);
- String[] params = type.substring(genericIndex + 1, type.length() - 1).split(",");
- GenericType[] types = new GenericType[params.length];
- for (int i = 0; i < params.length; i++) {
- types[i] = parse(params[i], loader);
- }
- return new GenericType(base.getRawClass(), types);
- }
- // Primitive
- if (primitiveClasses.containsKey(type)) {
- return new GenericType(primitiveClasses.get(type));
- }
- // Class
- if (loader instanceof ClassLoader) {
- return new GenericType(((ClassLoader) loader).loadClass(type));
- } else if (loader instanceof Bundle) {
- return new GenericType(((Bundle) loader).loadClass(type));
- } else {
- throw new IllegalArgumentException("Unsupported loader: " + loader);
- }
- }
-
- @Override
- public ReifiedType getActualTypeArgument(int i) {
- if (parameters.length == 0) {
- return super.getActualTypeArgument(i);
- }
- return parameters[i];
- }
-
- @Override
- public int size() {
- return parameters.length;
- }
-
- @Override
- public String toString() {
- Class cl = getRawClass();
- if (cl.isArray()) {
- if (parameters.length > 0) {
- return parameters[0].toString() + "[]";
- } else {
- return cl.getComponentType().getName() + "[]";
- }
- }
- if (parameters.length > 0) {
- StringBuilder sb = new StringBuilder();
- sb.append(cl.getName());
- sb.append("<");
- for (int i = 0; i < parameters.length; i++) {
- if (i > 0) {
- sb.append(",");
- }
- sb.append(parameters[i].toString());
- }
- sb.append(">");
- return sb.toString();
- }
- return cl.getName();
- }
-
- static GenericType[] parametersOf(Type type ) {
- if ( type instanceof Class ) {
- Class clazz = (Class) type;
- if (clazz.isArray()) {
- GenericType t = new GenericType(clazz.getComponentType());
- if (t.size() > 0) {
- return new GenericType[] { t };
- } else {
- return EMPTY;
- }
- } else {
- return EMPTY;
- }
- }
- if ( type instanceof ParameterizedType ) {
- ParameterizedType pt = (ParameterizedType) type;
- Type [] parameters = pt.getActualTypeArguments();
- GenericType[] gts = new GenericType[parameters.length];
- for ( int i =0; i<gts.length; i++) {
- gts[i] = new GenericType(parameters[i]);
- }
- return gts;
- }
- if ( type instanceof GenericArrayType ) {
- return new GenericType[] { new GenericType(((GenericArrayType) type).getGenericComponentType()) };
- }
- throw new IllegalStateException();
- }
-
- static Class<?> getConcreteClass(Type type) {
- Type ntype = collapse(type);
- if ( ntype instanceof Class )
- return (Class<?>) ntype;
-
- if ( ntype instanceof ParameterizedType )
- return getConcreteClass(collapse(((ParameterizedType)ntype).getRawType()));
-
- throw new RuntimeException("Unknown type " + type );
- }
-
- static Type collapse(Type target) {
- if (target instanceof Class || target instanceof ParameterizedType ) {
- return target;
- } else if (target instanceof TypeVariable) {
- return collapse(((TypeVariable<?>) target).getBounds()[0]);
- } else if (target instanceof GenericArrayType) {
- Type t = collapse(((GenericArrayType) target)
- .getGenericComponentType());
- while ( t instanceof ParameterizedType )
- t = collapse(((ParameterizedType)t).getRawType());
- return Array.newInstance((Class<?>)t, 0).getClass();
- } else if (target instanceof WildcardType) {
- WildcardType wct = (WildcardType) target;
- if (wct.getLowerBounds().length == 0)
- return collapse(wct.getUpperBounds()[0]);
- else
- return collapse(wct.getLowerBounds()[0]);
- }
- throw new RuntimeException("Huh? " + target);
- }
-
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/commands/NamespaceHandler.java b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/commands/NamespaceHandler.java
deleted file mode 100644
index 566b586..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/commands/NamespaceHandler.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.console.commands;
-
-import java.net.URL;
-import java.util.Arrays;
-import java.util.List;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.apache.aries.blueprint.ParserContext;
-import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
-import org.apache.aries.blueprint.mutable.MutableIdRefMetadata;
-import org.apache.aries.blueprint.mutable.MutableServiceMetadata;
-import org.apache.aries.blueprint.mutable.MutableValueMetadata;
-import org.apache.aries.blueprint.mutable.MutableRefMetadata;
-import org.apache.aries.blueprint.mutable.MutableCollectionMetadata;
-import org.apache.felix.karaf.shell.console.CompletableFunction;
-import org.osgi.service.blueprint.reflect.BeanArgument;
-import org.osgi.service.blueprint.reflect.BeanProperty;
-import org.osgi.service.blueprint.reflect.ComponentMetadata;
-import org.osgi.service.blueprint.reflect.IdRefMetadata;
-import org.osgi.service.blueprint.reflect.Metadata;
-import org.osgi.service.blueprint.reflect.ValueMetadata;
-import org.osgi.service.blueprint.reflect.RefMetadata;
-import org.osgi.service.blueprint.reflect.NullMetadata;
-import org.osgi.service.blueprint.reflect.BeanMetadata;
-import org.osgi.service.blueprint.container.ComponentDefinitionException;
-import org.osgi.service.command.Function;
-
-
-public class NamespaceHandler implements org.apache.aries.blueprint.NamespaceHandler {
-
- public static final String ID = "id";
- public static final String DESCRIPTION = "description";
- public static final String PLUGIN_TEMPLATE = "pluginTemplate";
- public static final String ACTION = "action";
- public static final String ACTION_ID = "actionId";
- public static final String COMMAND_TEMPLATE_SUFFIX = "CommandTemplate";
- public static final String COMMAND_BUNDLE = "command-bundle";
- public static final String NAME = "name";
- public static final String LOCATION = "location";
- public static final String COMMANDS = "commands";
- public static final String COMMAND = "command";
- public static final String DOCUMENTER = "documenter";
- public static final String COMPLETER = "completer";
- public static final String COMPLETERS = "completers";
- public static final String BEAN = "bean";
- public static final String REF = "ref";
- public static final String NULL = "null";
- public static final String MESSAGE_SOURCE = "message-source";
- public static final String MESSAGES = "messages";
- public static final String PROTOTYPE = "prototype";
- public static final String ALIAS = "alias";
- public static final String ALIASES = "aliases";
- public static final String LINK = "link";
- public static final String LINKS = "links";
- public static final String TARGET = "target";
- public static final String BLUEPRINT_CONTAINER = "blueprintContainer";
- public static final String BLUEPRINT_CONVERTER = "blueprintConverter";
-
- private int nameCounter = 0;
-
- public URL getSchemaLocation(String namespace) {
- return getClass().getResource("karaf-shell.xsd");
- }
-
- public Set<Class> getManagedClasses() {
- return new HashSet<Class>(Arrays.asList(
- BlueprintCommand.class
- ));
- }
-
- public ComponentMetadata decorate(Node node, ComponentMetadata component, ParserContext context) {
- throw new ComponentDefinitionException("Bad xml syntax: node decoration is not supported");
- }
-
- public Metadata parse(Element element, ParserContext context) {
- if (nodeNameEquals(element, COMMAND_BUNDLE)) {
- NodeList children = element.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child instanceof Element) {
- Element childElement = (Element) child;
- parseChildElement(childElement, context);
- }
- }
- return null;
- } else {
- throw new IllegalStateException("Unexpected element " + element.getNodeName());
- }
- }
-
- private void parseChildElement(Element element, ParserContext context) {
- if (nodeNameEquals(element, COMMAND)) {
- parseCommand(element, context);
- } else if (nodeNameEquals(element, LINK)) {
-// parseLink(element, context);
- } else if (nodeNameEquals(element, ALIAS)) {
-// parseAlias(element, context);
- }
- }
-
- private void parseCommand(Element element, ParserContext context) {
- MutableBeanMetadata command = context.createMetadata(MutableBeanMetadata.class);
- command.setRuntimeClass(BlueprintCommand.class);
- command.addProperty(BLUEPRINT_CONTAINER, createRef(context, BLUEPRINT_CONTAINER));
- command.addProperty(BLUEPRINT_CONVERTER, createRef(context, BLUEPRINT_CONVERTER));
-// MutableBeanMetadata documenter = context.createMetadata(MutableBeanMetadata.class);
-// documenter.setRuntimeClass(MessageSourceCommandDocumenter.class);
-// command.addProperty(DOCUMENTER, documenter);
-// MutableBeanMetadata messages = context.createMetadata(MutableBeanMetadata.class);
-// messages.setRuntimeClass(CommandMessageSource.class);
-// command.addProperty(MESSAGES, messages);
-// MutableBeanMetadata location = context.createMetadata(MutableBeanMetadata.class);
-// location.setRuntimeClass(CommandLocationImpl.class);
-// location.addArgument(createStringValue(context, element.getAttribute(NAME)), String.class.getName(), 0);
-// command.addProperty(LOCATION, location);
-
- String location = element.getAttribute(NAME);
- location = location.replace('/', ':');
- String scope;
- String function;
- if (location.lastIndexOf(':') >= 0) {
- scope = location.substring(0, location.lastIndexOf(':'));
- function = location.substring(location.lastIndexOf(':') + 1);
- } else {
- scope = "";
- function = location;
- }
-
- NodeList children = element.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child instanceof Element) {
- Element childElement = (Element) child;
- if (nodeNameEquals(childElement, ACTION)) {
- MutableBeanMetadata action = parseAction(context, command, childElement);
- action.setId(getName());
- context.getComponentDefinitionRegistry().registerComponentDefinition(action);
- command.addProperty(ACTION_ID, createIdRef(context, action.getId()));
- } else if (nodeNameEquals(childElement, COMPLETERS)) {
- command.addProperty(COMPLETERS, parseCompleters(context, command, childElement));
- } else {
- throw new ComponentDefinitionException("Bad xml syntax: unknown element '" + childElement.getNodeName() + "'");
- }
- }
- }
-
- MutableServiceMetadata commandService = context.createMetadata(MutableServiceMetadata.class);
- commandService.setActivation(MutableServiceMetadata.ACTIVATION_LAZY);
- commandService.setId(getName());
- commandService.addInterface(Function.class.getName());
- commandService.addInterface(CompletableFunction.class.getName());
- commandService.setServiceComponent(command);
- commandService.addServiceProperty(createStringValue(context, "osgi.command.scope"),
- createStringValue(context, scope));
- commandService.addServiceProperty(createStringValue(context, "osgi.command.function"),
- createStringValue(context, function));
- context.getComponentDefinitionRegistry().registerComponentDefinition(commandService);
- }
-
- private MutableBeanMetadata parseAction(ParserContext context, ComponentMetadata enclosingComponent, Element element) {
- MutableBeanMetadata action = context.createMetadata(MutableBeanMetadata.class);
- action.setActivation(MutableBeanMetadata.ACTIVATION_LAZY);
- action.setScope(MutableBeanMetadata.SCOPE_PROTOTYPE);
- action.setClassName(element.getAttribute("class"));
- NodeList children = element.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child instanceof Element) {
- Element childElement = (Element) child;
- if (nodeNameEquals(childElement, "argument")) {
- action.addArgument(context.parseElement(BeanArgument.class, enclosingComponent, childElement));
- } else if (nodeNameEquals(childElement, "property")) {
- action.addProperty(context.parseElement(BeanProperty.class, enclosingComponent, childElement));
- }
- }
- }
- return action;
- }
-
- private Metadata parseCompleters(ParserContext context, ComponentMetadata enclosingComponent, Element element) {
- MutableCollectionMetadata collection = context.createMetadata(MutableCollectionMetadata.class);
- collection.setCollectionClass(List.class);
- NodeList children = element.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child instanceof Element) {
- Metadata metadata;
- if (nodeNameEquals(child, REF)) {
- metadata = context.parseElement(RefMetadata.class, context.getEnclosingComponent(), (Element) child);
- } else if (nodeNameEquals(child, NULL)) {
- metadata = context.parseElement(NullMetadata.class, context.getEnclosingComponent(), (Element) child);
- } else if (nodeNameEquals(child, BEAN)) {
- metadata = context.parseElement(BeanMetadata.class, enclosingComponent, (Element) child);
- } else {
- throw new IllegalStateException("Unexpected element " + child.getNodeName());
- }
- collection.addValue(metadata);
- }
- }
- return collection;
- }
-
-// private void parseLink(Element element, ParserContext context) {
-// MutableBeanMetadata link = context.createMetadata(MutableBeanMetadata.class);
-// link.setRuntimeClass(LinkImpl.class);
-// link.addArgument(createStringValue(context, element.getAttribute(NAME)), String.class.getName(), 0);
-// link.addArgument(createStringValue(context, element.getAttribute(TARGET)), String.class.getName(), 0);
-//
-// MutableServiceMetadata linkService = context.createMetadata(MutableServiceMetadata.class);
-// linkService.setId(getName());
-// linkService.addInterface(Link.class.getName());
-// linkService.setServiceComponent(link);
-// context.getComponentDefinitionRegistry().registerComponentDefinition(linkService);
-// }
-//
-// private void parseAlias(Element element, ParserContext context) {
-// MutableBeanMetadata alias = context.createMetadata(MutableBeanMetadata.class);
-// alias.setRuntimeClass(AliasImpl.class);
-// alias.addArgument(createStringValue(context, element.getAttribute(NAME)), String.class.getName(), 0);
-// alias.addArgument(createStringValue(context, element.getAttribute(ALIAS)), String.class.getName(), 0);
-//
-// MutableServiceMetadata aliasService = context.createMetadata(MutableServiceMetadata.class);
-// aliasService.setId(getName());
-// aliasService.addInterface(Alias.class.getName());
-// aliasService.setServiceComponent(alias);
-// context.getComponentDefinitionRegistry().registerComponentDefinition(aliasService);
-// }
-//
- private ValueMetadata createStringValue(ParserContext context, String str) {
- MutableValueMetadata value = context.createMetadata(MutableValueMetadata.class);
- value.setStringValue(str);
- return value;
- }
-
- private RefMetadata createRef(ParserContext context, String id) {
- MutableRefMetadata idref = context.createMetadata(MutableRefMetadata.class);
- idref.setComponentId(id);
- return idref;
- }
-
- private IdRefMetadata createIdRef(ParserContext context, String id) {
- MutableIdRefMetadata idref = context.createMetadata(MutableIdRefMetadata.class);
- idref.setComponentId(id);
- return idref;
- }
-
- public synchronized String getName() {
- return "shell-" + ++nameCounter;
- }
-
- private static boolean nodeNameEquals(Node node, String name) {
- return (name.equals(node.getNodeName()) || name.equals(node.getLocalName()));
- }
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/completer/AggregateCompleter.java b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/completer/AggregateCompleter.java
deleted file mode 100644
index d858ca2..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/completer/AggregateCompleter.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.karaf.shell.console.completer;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Collection;
-
-import org.apache.felix.karaf.shell.console.Completer;
-
-/**
- * Completer which contains multipule completers and aggregates them together.
- *
- * @version $Rev: 699733 $ $Date: 2008-09-27 22:55:23 +0200 (Sat, 27 Sep 2008) $
- */
-public class AggregateCompleter implements Completer
-{
- private final Collection<Completer> completers;
-
- public AggregateCompleter(final Collection<Completer> completers) {
- assert completers != null;
- this.completers = completers;
- }
-
- public int complete(final String buffer, final int cursor, final List candidates) {
- // buffer could be null
- assert candidates != null;
-
- List<Completion> completions = new ArrayList<Completion>(completers.size());
-
- // Run each completer, saving its completion results
- int max = -1;
- for (Completer completer : completers) {
- Completion completion = new Completion(candidates);
- completion.complete(completer, buffer, cursor);
-
- // Compute the max cursor position
- max = Math.max(max, completion.cursor);
-
- completions.add(completion);
- }
-
- // Append candiates from completions which have the same cursor position as max
- for (Completion completion : completions) {
- if (completion.cursor == max) {
- // noinspection unchecked
- candidates.addAll(completion.candidates);
- }
- }
-
- return max;
- }
-
- private class Completion
- {
- public final List<String> candidates;
-
- public int cursor;
-
- public Completion(final List candidates) {
- assert candidates != null;
-
- // noinspection unchecked
- this.candidates = new LinkedList<String>(candidates);
- }
-
- public void complete(final Completer completer, final String buffer, final int cursor) {
- assert completer != null;
-
- this.cursor = completer.complete(buffer, cursor, candidates);
- }
- }
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/completer/ArgumentCompleter.java b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/completer/ArgumentCompleter.java
deleted file mode 100644
index d49ac74..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/completer/ArgumentCompleter.java
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/*
- * Copyright (c) 2002-2007, Marc Prud'hommeaux. All rights reserved.
- *
- * This software is distributable under the BSD license. See the terms of the
- * BSD license in the documentation provided with this software.
- */
-package org.apache.felix.karaf.shell.console.completer;
-
-import java.util.*;
-
-import org.apache.felix.karaf.shell.console.Completer;
-
-public class ArgumentCompleter implements Completer {
- final Completer[] completers;
- final ArgumentDelimiter delim;
- boolean strict = true;
-
- /**
- * Constuctor: create a new completor with the default
- * argument separator of " ".
- *
- * @param completer the embedded completer
- */
- public ArgumentCompleter(final Completer completer) {
- this(new Completer[] {
- completer
- });
- }
-
- /**
- * Constuctor: create a new completor with the default
- * argument separator of " ".
- *
- * @param completers the List of completors to use
- */
- public ArgumentCompleter(final List<Completer> completers) {
- this(completers.toArray(new Completer[completers.size()]));
- }
-
- /**
- * Constuctor: create a new completor with the default
- * argument separator of " ".
- *
- * @param completers the embedded argument completers
- */
- public ArgumentCompleter(final Completer[] completers) {
- this(completers, new WhitespaceArgumentDelimiter());
- }
-
- /**
- * Constuctor: create a new completor with the specified
- * argument delimiter.
- *
- * @param completer the embedded completer
- * @param delim the delimiter for parsing arguments
- */
- public ArgumentCompleter(final Completer completer,
- final ArgumentDelimiter delim) {
- this(new Completer[] {
- completer
- }, delim);
- }
-
- /**
- * Constuctor: create a new completor with the specified
- * argument delimiter.
- *
- * @param completers the embedded completers
- * @param delim the delimiter for parsing arguments
- */
- public ArgumentCompleter(final Completer[] completers,
- final ArgumentDelimiter delim) {
- this.completers = completers;
- this.delim = delim;
- }
-
- /**
- * If true, a completion at argument index N will only succeed
- * if all the completions from 0-(N-1) also succeed.
- */
- public void setStrict(final boolean strict) {
- this.strict = strict;
- }
-
- /**
- * Returns whether a completion at argument index N will succees
- * if all the completions from arguments 0-(N-1) also succeed.
- */
- public boolean getStrict() {
- return this.strict;
- }
-
- public int complete(final String buffer, final int cursor,
- final List<String> candidates) {
- ArgumentList list = delim.delimit(buffer, cursor);
- int argpos = list.getArgumentPosition();
- int argIndex = list.getCursorArgumentIndex();
-
- if (argIndex < 0) {
- return -1;
- }
-
- final Completer comp;
-
- // if we are beyond the end of the completors, just use the last one
- if (argIndex >= completers.length) {
- comp = completers[completers.length - 1];
- } else {
- comp = completers[argIndex];
- }
-
- // ensure that all the previous completors are successful before
- // allowing this completor to pass (only if strict is true).
- for (int i = 0; getStrict() && (i < argIndex); i++) {
- Completer sub = completers[(i >= completers.length) ? (completers.length - 1) : i];
- String[] args = list.getArguments();
- String arg = ((args == null) || (i >= args.length)) ? "" : args[i];
-
- List<String> subCandidates = new LinkedList<String>();
-
- if (sub.complete(arg, arg.length(), subCandidates) == -1) {
- return -1;
- }
-
- if (subCandidates.size() == 0) {
- return -1;
- }
- }
-
- int ret = comp.complete(list.getCursorArgument(), argpos, candidates);
-
- if (ret == -1) {
- return -1;
- }
-
- int pos = ret + (list.getBufferPosition() - argpos);
-
- /**
- * Special case: when completing in the middle of a line, and the
- * area under the cursor is a delimiter, then trim any delimiters
- * from the candidates, since we do not need to have an extra
- * delimiter.
- *
- * E.g., if we have a completion for "foo", and we
- * enter "f bar" into the buffer, and move to after the "f"
- * and hit TAB, we want "foo bar" instead of "foo bar".
- */
- if ((cursor != buffer.length()) && delim.isDelimiter(buffer, cursor)) {
- for (int i = 0; i < candidates.size(); i++) {
- String val = candidates.get(i);
-
- while ((val.length() > 0)
- && delim.isDelimiter(val, val.length() - 1)) {
- val = val.substring(0, val.length() - 1);
- }
-
- candidates.set(i, val);
- }
- }
-
- return pos;
- }
-
- /**
- * The {@link ArgumentCompleter.ArgumentDelimiter} allows custom
- * breaking up of a {@link String} into individual arguments in
- * order to dispatch the arguments to the nested {@link Completer}.
- *
- * @author <a href="mailto:mwp1@cornell.edu">Marc Prud'hommeaux</a>
- */
- public static interface ArgumentDelimiter {
- /**
- * Break the specified buffer into individual tokens
- * that can be completed on their own.
- *
- * @param buffer the buffer to split
- * @param argumentPosition the current position of the
- * cursor in the buffer
- * @return the tokens
- */
- ArgumentList delimit(String buffer, int argumentPosition);
-
- /**
- * Returns true if the specified character is a whitespace
- * parameter.
- *
- * @param buffer the complete command buffer
- * @param pos the index of the character in the buffer
- * @return true if the character should be a delimiter
- */
- boolean isDelimiter(String buffer, int pos);
- }
-
- /**
- * Abstract implementation of a delimiter that uses the
- * {@link #isDelimiter} method to determine if a particular
- * character should be used as a delimiter.
- *
- * @author <a href="mailto:mwp1@cornell.edu">Marc Prud'hommeaux</a>
- */
- public abstract static class AbstractArgumentDelimiter
- implements ArgumentDelimiter {
- private char[] quoteChars = new char[] { '\'', '"' };
- private char[] escapeChars = new char[] { '\\' };
-
- public void setQuoteChars(final char[] quoteChars) {
- this.quoteChars = quoteChars;
- }
-
- public char[] getQuoteChars() {
- return this.quoteChars;
- }
-
- public void setEscapeChars(final char[] escapeChars) {
- this.escapeChars = escapeChars;
- }
-
- public char[] getEscapeChars() {
- return this.escapeChars;
- }
-
- public ArgumentList delimit(final String buffer, final int cursor) {
- List<String> args = new LinkedList<String>();
- StringBuffer arg = new StringBuffer();
- int argpos = -1;
- int bindex = -1;
-
- for (int i = 0; (buffer != null) && (i <= buffer.length()); i++) {
- // once we reach the cursor, set the
- // position of the selected index
- if (i == cursor) {
- bindex = args.size();
- // the position in the current argument is just the
- // length of the current argument
- argpos = arg.length();
- }
-
- if ((i == buffer.length()) || isDelimiter(buffer, i)) {
- if (arg.length() > 0) {
- args.add(arg.toString());
- arg.setLength(0); // reset the arg
- }
- } else {
- arg.append(buffer.charAt(i));
- }
- }
-
- return new ArgumentList(args.
- toArray(new String[args.size()]), bindex, argpos, cursor);
- }
-
- /**
- * Returns true if the specified character is a whitespace
- * parameter. Check to ensure that the character is not
- * escaped by any of
- * {@link #getQuoteChars}, and is not escaped by ant of the
- * {@link #getEscapeChars}, and returns true from
- * {@link #isDelimiterChar}.
- *
- * @param buffer the complete command buffer
- * @param pos the index of the character in the buffer
- * @return true if the character should be a delimiter
- */
- public boolean isDelimiter(final String buffer, final int pos) {
- if (isQuoted(buffer, pos)) {
- return false;
- }
-
- if (isEscaped(buffer, pos)) {
- return false;
- }
-
- return isDelimiterChar(buffer, pos);
- }
-
- public boolean isQuoted(final String buffer, final int pos) {
- return false;
- }
-
- public boolean isEscaped(final String buffer, final int pos) {
- if (pos <= 0) {
- return false;
- }
-
- for (int i = 0; (escapeChars != null) && (i < escapeChars.length);
- i++) {
- if (buffer.charAt(pos) == escapeChars[i]) {
- return !isEscaped(buffer, pos - 1); // escape escape
- }
- }
-
- return false;
- }
-
- /**
- * Returns true if the character at the specified position
- * if a delimiter. This method will only be called if the
- * character is not enclosed in any of the
- * {@link #getQuoteChars}, and is not escaped by ant of the
- * {@link #getEscapeChars}. To perform escaping manually,
- * override {@link #isDelimiter} instead.
- */
- public abstract boolean isDelimiterChar(String buffer, int pos);
- }
-
- /**
- * {@link ArgumentCompleter.ArgumentDelimiter}
- * implementation that counts all
- * whitespace (as reported by {@link Character#isWhitespace})
- * as being a delimiter.
- *
- * @author <a href="mailto:mwp1@cornell.edu">Marc Prud'hommeaux</a>
- */
- public static class WhitespaceArgumentDelimiter
- extends AbstractArgumentDelimiter {
- /**
- * The character is a delimiter if it is whitespace, and the
- * preceeding character is not an escape character.
- */
- public boolean isDelimiterChar(String buffer, int pos) {
- return Character.isWhitespace(buffer.charAt(pos));
- }
- }
-
- /**
- * The result of a delimited buffer.
- *
- * @author <a href="mailto:mwp1@cornell.edu">Marc Prud'hommeaux</a>
- */
- public static class ArgumentList {
- private String[] arguments;
- private int cursorArgumentIndex;
- private int argumentPosition;
- private int bufferPosition;
-
- /**
- * @param arguments the array of tokens
- * @param cursorArgumentIndex the token index of the cursor
- * @param argumentPosition the position of the cursor in the
- * current token
- * @param bufferPosition the position of the cursor in
- * the whole buffer
- */
- public ArgumentList(String[] arguments, int cursorArgumentIndex,
- int argumentPosition, int bufferPosition) {
- this.arguments = arguments;
- this.cursorArgumentIndex = cursorArgumentIndex;
- this.argumentPosition = argumentPosition;
- this.bufferPosition = bufferPosition;
- }
-
- public void setCursorArgumentIndex(int cursorArgumentIndex) {
- this.cursorArgumentIndex = cursorArgumentIndex;
- }
-
- public int getCursorArgumentIndex() {
- return this.cursorArgumentIndex;
- }
-
- public String getCursorArgument() {
- if ((cursorArgumentIndex < 0)
- || (cursorArgumentIndex >= arguments.length)) {
- return null;
- }
-
- return arguments[cursorArgumentIndex];
- }
-
- public void setArgumentPosition(int argumentPosition) {
- this.argumentPosition = argumentPosition;
- }
-
- public int getArgumentPosition() {
- return this.argumentPosition;
- }
-
- public void setArguments(String[] arguments) {
- this.arguments = arguments;
- }
-
- public String[] getArguments() {
- return this.arguments;
- }
-
- public void setBufferPosition(int bufferPosition) {
- this.bufferPosition = bufferPosition;
- }
-
- public int getBufferPosition() {
- return this.bufferPosition;
- }
- }
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/completer/CommandsCompleter.java b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/completer/CommandsCompleter.java
deleted file mode 100644
index e52a23c..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/completer/CommandsCompleter.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.console.completer;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.felix.karaf.shell.console.Completer;
-import org.apache.felix.karaf.shell.console.CompletableFunction;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.command.CommandProcessor;
-
-public class CommandsCompleter implements Completer {
-
- private final Map<ServiceReference, Completer> completers = new ConcurrentHashMap<ServiceReference, Completer>();
-
- private BundleContext bundleContext;
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- public void register(ServiceReference reference) {
- Set<String> functions = getNames(reference);
- if (functions != null) {
- List<Completer> cl = new ArrayList<Completer>();
- cl.add(new StringsCompleter(functions));
- try {
- Object function = bundleContext.getService(reference);
- if (function instanceof CompletableFunction) {
- List<Completer> fcl = ((CompletableFunction) function).getCompleters();
- if (fcl != null) {
- for (Completer c : fcl) {
- cl.add(c == null ? NullCompleter.INSTANCE : c);
- }
- } else {
- cl.add(NullCompleter.INSTANCE);
- }
- } else {
- cl.add(NullCompleter.INSTANCE);
- }
- } finally {
- bundleContext.ungetService(reference);
- }
- ArgumentCompleter c = new ArgumentCompleter(cl);
- completers.put(reference, c);
- }
- }
-
- public void unregister(ServiceReference reference) {
- if (reference != null) {
- completers.remove(reference);
- }
- }
-
- private Set<String> getNames(ServiceReference reference) {
- Set<String> names = new HashSet<String>();
- Object scope = reference.getProperty(CommandProcessor.COMMAND_SCOPE);
- Object function = reference.getProperty(CommandProcessor.COMMAND_FUNCTION);
- if(scope != null && function != null)
- {
- if (function.getClass().isArray())
- {
- for (Object f : ((Object[]) function))
- {
- names.add(scope + ":" + f.toString());
- }
- }
- else
- {
- names.add(scope + ":" + function.toString());
- }
- return names;
- }
- return null;
- }
-
- public int complete(String buffer, int cursor, List<String> candidates) {
- int res = new AggregateCompleter(completers.values()).complete(buffer, cursor, candidates);
- Collections.sort(candidates);
- return res;
- }
-}
-
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/completer/NullCompleter.java b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/completer/NullCompleter.java
deleted file mode 100644
index c1390bd..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/completer/NullCompleter.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.console.completer;
-
-import java.util.List;
-
-import org.apache.felix.karaf.shell.console.Completer;
-
-public class NullCompleter implements Completer {
-
- public static final NullCompleter INSTANCE = new NullCompleter();
-
- public int complete(String buffer, int cursor, List<String> candidates) {
- return -1;
- }
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/completer/SessionScopeCompleter.java b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/completer/SessionScopeCompleter.java
deleted file mode 100644
index dd99f38..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/completer/SessionScopeCompleter.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.console.completer;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import org.apache.felix.karaf.shell.console.Completer;
-import org.osgi.service.command.CommandSession;
-
-/**
- * Completer which uses the session scopes automatically appended in front of buffer.
- *
- * @version $Rev: $ $Date: $
- */
-public class SessionScopeCompleter implements Completer
-{
-
- private final CommandSession session;
- private final Completer completer;
-
- public SessionScopeCompleter( final CommandSession session,
- final Completer completer )
- {
- this.session = session;
- this.completer = completer;
- }
-
- public int complete( String buffer, int cursor, List<String> candidates )
- {
- // buffer could be null
- assert candidates != null;
-
- try
- {
- final List<Completion> completions = new ArrayList<Completion>();
-
- final String scope = (String) session.get( "SCOPE" );
- if( scope != null )
- {
- final String[] segments = scope.split( ":" );
-
- // Run completer for each segment, saving its completion results
- int max = -1;
- for( String segment : segments )
- {
- Completion completion = new Completion( segment, candidates );
- completion.complete( completer, buffer, cursor );
-
- // Compute the max cursor position
- max = Math.max( max, completion.cursor );
-
- completions.add( completion );
- }
-
- // Append candidates from completions which have the same cursor position as max
- for( Completion completion : completions )
- {
- if( completion.cursor == max )
- {
- // noinspection unchecked
- candidates.addAll( completion.candidates );
- }
- }
-
- return max;
- }
- }
- catch( Exception ignore )
- {
- }
- return -1;
- }
-
- private class Completion
- {
-
- public final String scope;
-
- public final List<String> candidates;
-
- public int cursor;
-
- public Completion( final String scope, final List candidates )
- {
- assert scope != null;
- assert candidates != null;
-
- this.scope = scope;
- // noinspection unchecked
- this.candidates = new LinkedList<String>( candidates );
- }
-
- public void complete( Completer completer, String buffer, int cursor )
- {
- assert completer != null;
-
- buffer = scope + ":" + buffer;
- cursor += (scope + ":").length();
-
- this.cursor = completer.complete( buffer, cursor, candidates );
-
- cursor -= (scope + ":").length();
- for (int i = 0; i < candidates.size(); i++) {
- String s = candidates.get(i);
- s = s.substring((scope + ":").length());
- candidates.set(i, s);
- }
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/completer/StringsCompleter.java b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/completer/StringsCompleter.java
deleted file mode 100644
index 6c9629e..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/completer/StringsCompleter.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.console.completer;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import org.apache.felix.karaf.shell.console.Completer;
-
-/**
- * Completer for a set of strings.
- *
- * @version $Rev: 722797 $ $Date: 2008-12-03 08:18:16 +0100 (Wed, 03 Dec 2008) $
- */
-public class StringsCompleter
- implements Completer
-{
- private final SortedSet<String> strings = new TreeSet<String>();
-
- public StringsCompleter() {}
-
- public StringsCompleter(final Collection<String> strings) {
- assert strings != null;
-
- getStrings().addAll(strings);
- }
-
- public StringsCompleter(final String[] strings) {
- this(Arrays.asList(strings));
- }
-
- public Collection<String> getStrings() {
- return strings;
- }
-
- public int complete(String buffer, final int cursor, final List candidates) {
- // buffer could be null
- assert candidates != null;
-
- if (buffer == null) {
- buffer = "";
- }
-
- SortedSet<String> matches = strings.tailSet(buffer);
-
- for (String match : matches) {
- if (!match.startsWith(buffer)) {
- break;
- }
-
- // noinspection unchecked
- candidates.add(match);
- }
-
- if (candidates.size() == 1) {
- // noinspection unchecked
- candidates.set(0, candidates.get(0) + " ");
- }
-
- return candidates.isEmpty() ? -1 : 0;
- }
-}
\ No newline at end of file
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/jline/CompleterAsCompletor.java b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/jline/CompleterAsCompletor.java
deleted file mode 100644
index 28aca00..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/jline/CompleterAsCompletor.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy 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.felix.karaf.shell.console.jline;
-
-import java.util.List;
-
-import jline.Completor;
-import org.apache.felix.karaf.shell.console.Completer;
-
-public class CompleterAsCompletor implements Completor {
-
- private final Completer completer;
-
- public CompleterAsCompletor(Completer completer) {
- this.completer = completer;
- }
-
- public int complete(String buffer, int cursor, List candidates) {
- return completer.complete(buffer, cursor, candidates);
- }
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/jline/Console.java b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/jline/Console.java
deleted file mode 100644
index 029733d..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/jline/Console.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.console.jline;
-
-import java.io.CharArrayWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.InterruptedIOException;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import jline.AnsiWindowsTerminal;
-import jline.ConsoleReader;
-import jline.Terminal;
-import jline.UnsupportedTerminal;
-import org.apache.felix.karaf.shell.console.CloseShellException;
-import org.apache.felix.karaf.shell.console.Completer;
-import org.apache.felix.karaf.shell.console.completer.AggregateCompleter;
-import org.apache.felix.karaf.shell.console.completer.SessionScopeCompleter;
-import org.fusesource.jansi.Ansi;
-import org.osgi.service.command.CommandProcessor;
-import org.osgi.service.command.CommandSession;
-import org.osgi.service.command.Converter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class Console implements Runnable
-{
-
- public static final String SHELL_INIT_SCRIPT = "karaf.shell.init.script";
- public static final String PROMPT = "PROMPT";
- public static final String DEFAULT_PROMPT = "\u001B[1m${USER}\u001B[0m@${APPLICATION}> ";
- public static final String PRINT_STACK_TRACES = "karaf.printStackTraces";
- public static final String LAST_EXCEPTION = "karaf.lastException";
-
- private static final Logger LOGGER = LoggerFactory.getLogger(Console.class);
-
- private CommandSession session;
- private ConsoleReader reader;
- private BlockingQueue<Integer> queue;
- private boolean interrupt;
- private Thread pipe;
- private boolean running;
- private Runnable closeCallback;
- private Terminal terminal;
- private InputStream consoleInput;
- private InputStream in;
- private PrintStream out;
- private PrintStream err;
- private Thread thread;
-
- public Console(CommandProcessor processor,
- InputStream in,
- PrintStream out,
- PrintStream err,
- Terminal term,
- Completer completer,
- Runnable closeCallback) throws Exception
- {
- this.in = in;
- this.out = out;
- this.err = err;
- this.queue = new ArrayBlockingQueue<Integer>(1024);
- this.terminal = term == null ? new UnsupportedTerminal() : term;
- this.consoleInput = new ConsoleInputStream();
- this.session = processor.createSession(this.consoleInput, this.out, this.err);
- this.session.put("SCOPE", "shell:osgi:*");
- this.closeCallback = closeCallback;
-
- reader = new ConsoleReader(this.consoleInput,
- new PrintWriter(this.out),
- getClass().getResourceAsStream("keybinding.properties"),
- this.terminal);
-
- File file = new File(System.getProperty("user.home"), ".karaf/karaf.history");
- file.getParentFile().mkdirs();
- reader.getHistory().setHistoryFile(file);
- session.put(".jline.history", reader.getHistory());
- if (completer != null) {
- reader.addCompletor(
- new CompleterAsCompletor(
- new AggregateCompleter(
- Arrays.asList(
- completer,
- new SessionScopeCompleter( session, completer )
- )
- )
- )
- );
- }
- if (Boolean.getBoolean("jline.nobell")) {
- reader.setBellEnabled(false);
- }
- pipe = new Thread(new Pipe());
- pipe.setName("gogo shell pipe thread");
- pipe.setDaemon(true);
- }
-
- public CommandSession getSession() {
- return session;
- }
-
- public void close() {
- //System.err.println("Closing");
- running = false;
- pipe.interrupt();
- Thread.interrupted();
- }
-
- public void run()
- {
- thread = Thread.currentThread();
- running = true;
- pipe.start();
- Properties props = loadBrandingProperties();
- welcome(props);
- setSessionProperties(props);
- String scriptFileName = System.getProperty(SHELL_INIT_SCRIPT);
- if (scriptFileName != null) {
- Reader r = null;
- try {
- File scriptFile = new File(scriptFileName);
- r = new InputStreamReader(new FileInputStream(scriptFile));
- CharArrayWriter w = new CharArrayWriter();
- int n;
- char[] buf = new char[8192];
- while ((n = r.read(buf)) > 0) {
- w.write(buf, 0, n);
- }
- session.execute(new String(w.toCharArray()));
- } catch (Exception e) {
- LOGGER.debug("Error in initialization script", e);
- System.err.println("Error in initialization script: " + e.getMessage());
- } finally {
- if (r != null) {
- try {
- r.close();
- } catch (IOException e) {
- // Ignore
- }
- }
- }
- }
- while (running) {
- try {
- checkInterrupt();
- String line = reader.readLine(getPrompt());
- if (line == null)
- {
- break;
- }
- //session.getConsole().println("Executing: " + line);
- Object result = session.execute(line);
- if (result != null)
- {
- session.getConsole().println(session.format(result, Converter.INSPECT));
- }
- }
- catch (InterruptedIOException e)
- {
- //System.err.println("^C");
- // TODO: interrupt current thread
- }
- catch (CloseShellException e)
- {
- break;
- }
- catch (Throwable t)
- {
- try {
- LOGGER.info("Exception caught while executing command", t);
- session.put(LAST_EXCEPTION, t);
- session.getConsole().print(Ansi.ansi().fg(Ansi.Color.RED).toString());
- if ( isPrintStackTraces()) {
- t.printStackTrace(session.getConsole());
- }
- else {
- session.getConsole().println("Error executing command: "
- + (t.getMessage() != null ? t.getMessage() : t.getClass().getName()));
- }
- session.getConsole().print(Ansi.ansi().fg(Ansi.Color.DEFAULT).toString());
- } catch (Exception ignore) {
- // ignore
- }
- }
- }
- //System.err.println("Exiting console...");
- if (closeCallback != null)
- {
- closeCallback.run();
- }
- }
-
- protected boolean isPrintStackTraces() {
- Object s = session.get(PRINT_STACK_TRACES);
- if (s == null) {
- s = System.getProperty(PRINT_STACK_TRACES);
- }
- if (s == null) {
- return false;
- }
- if (s instanceof Boolean) {
- return (Boolean) s;
- }
- return Boolean.parseBoolean(s.toString());
- }
-
- protected void welcome(Properties props) {
- String welcome = props.getProperty("welcome");
- if (welcome != null && welcome.length() > 0) {
- session.getConsole().println(welcome);
- }
- }
-
- private void setSessionProperties(Properties props) {
- for (Map.Entry<Object, Object> entry : props.entrySet()) {
- String key = (String) entry.getKey();
- if (key.startsWith("session.")) {
- session.put(key.substring("session.".length()), entry.getValue());
- }
- }
- }
-
- private Properties loadBrandingProperties() {
- Properties props = new Properties();
- loadProps(props, "org/apache/felix/karaf/shell/console/branding.properties");
- loadProps(props, "org/apache/felix/karaf/branding/branding.properties");
- return props;
- }
-
- private void loadProps(Properties props, String resource) {
- InputStream is = null;
- try {
- is = getClass().getClassLoader().getResourceAsStream(resource);
- if (is != null) {
- props.load(is);
- }
- } catch (IOException e) {
- // ignore
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException e) {
- // Ignore
- }
- }
- }
- }
-
- protected String getPrompt() {
- try {
- String prompt;
- try {
- Object p = session.get(PROMPT);
- prompt = p != null ? p.toString() : DEFAULT_PROMPT;
- } catch (Throwable t) {
- prompt = DEFAULT_PROMPT;
- }
- Matcher matcher = Pattern.compile("\\$\\{([^}]+)\\}").matcher(prompt);
- while (matcher.find()) {
- Object rep = session.get(matcher.group(1));
- if (rep != null) {
- prompt = prompt.replace(matcher.group(0), rep.toString());
- matcher.reset(prompt);
- }
- }
- return prompt;
- } catch (Throwable t) {
- return "$ ";
- }
- }
-
- private void checkInterrupt() throws IOException {
- if (Thread.interrupted() || interrupt) {
- interrupt = false;
- throw new InterruptedIOException("Keyboard interruption");
- }
- }
-
- private void interrupt() {
- interrupt = true;
- thread.interrupt();
- }
-
- private class ConsoleInputStream extends InputStream
- {
- private int read(boolean wait) throws IOException
- {
- if (!running) {
- return -1;
- }
- checkInterrupt();
- Integer i;
- if (wait) {
- try {
- i = queue.take();
- } catch (InterruptedException e) {
- throw new InterruptedIOException();
- }
- checkInterrupt();
- } else {
- i = queue.poll();
- }
- if (i == null) {
- return -1;
- }
- return i;
- }
-
- @Override
- public int read() throws IOException
- {
- return read(true);
- }
-
- @Override
- public int read(byte b[], int off, int len) throws IOException
- {
- if (b == null) {
- throw new NullPointerException();
- } else if (off < 0 || len < 0 || len > b.length - off) {
- throw new IndexOutOfBoundsException();
- } else if (len == 0) {
- return 0;
- }
-
- int nb = 1;
- int i = read(true);
- if (i < 0) {
- return -1;
- }
- b[off++] = (byte) i;
- while (nb < len) {
- i = read(false);
- if (i < 0) {
- return nb;
- }
- b[off++] = (byte) i;
- nb++;
- }
- return nb;
- }
- }
-
- private class Pipe implements Runnable
- {
- public void run()
- {
- try {
- while (running)
- {
- try
- {
- int c;
- if (terminal instanceof AnsiWindowsTerminal) {
- c = ((AnsiWindowsTerminal) terminal).readDirectChar(in);
- } else {
- c = terminal.readCharacter(in);
- }
- if (c == -1)
- {
- queue.put(c);
- return;
- }
- else if (c == 4)
- {
- err.println("^D");
- }
- else if (c == 3)
- {
- err.println("^C");
- reader.getCursorBuffer().clearBuffer();
- interrupt();
- }
- queue.put(c);
- }
- catch (Throwable t) {
- return;
- }
- }
- }
- finally
- {
- close();
- }
- }
- }
-
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/jline/ConsoleFactory.java b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/jline/ConsoleFactory.java
deleted file mode 100644
index 8dde072..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/jline/ConsoleFactory.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.console.jline;
-
-import java.io.InputStream;
-import java.io.PrintStream;
-import java.io.OutputStream;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.concurrent.Callable;
-
-import org.apache.felix.karaf.shell.console.Completer;
-import org.apache.felix.karaf.shell.console.completer.AggregateCompleter;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.command.CommandProcessor;
-import org.osgi.service.command.CommandSession;
-import org.fusesource.jansi.AnsiConsole;
-import jline.Terminal;
-
-public class ConsoleFactory {
-
- private BundleContext bundleContext;
- private CommandProcessor commandProcessor;
- private List<Completer> completers;
- private TerminalFactory terminalFactory;
- private Console console;
- private boolean start;
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- public synchronized void registerCommandProcessor(CommandProcessor commandProcessor) throws Exception {
- this.commandProcessor = commandProcessor;
- start();
- }
-
- public synchronized void unregisterCommandProcessor(CommandProcessor commandProcessor) throws Exception {
- this.commandProcessor = null;
- stop();
- }
-
- public void setCompleters(List<Completer> completers) {
- this.completers = completers;
- }
-
- public void setTerminalFactory(TerminalFactory terminalFactory) {
- this.terminalFactory = terminalFactory;
- }
-
- public void setStart(boolean start) {
- this.start = start;
- }
-
- protected void start() throws Exception {
- if (start) {
- InputStream in = unwrap(System.in);
- PrintStream out = unwrap(System.out);
- PrintStream err = unwrap(System.err);
- Runnable callback = new Runnable() {
- public void run() {
- try {
- bundleContext.getBundle(0).stop();
- } catch (Exception e) {
- // Ignore
- }
- }
- };
- Terminal terminal = terminalFactory.getTerminal();
- this.console = new Console(commandProcessor,
- in,
- wrap(out),
- wrap(err),
- terminal,
- new AggregateCompleter(completers),
- callback);
- CommandSession session = console.getSession();
- session.put("USER", "karaf");
- session.put("APPLICATION", System.getProperty("karaf.name", "root"));
- session.put("LINES", Integer.toString(terminal.getTerminalHeight()));
- session.put("COLUMNS", Integer.toString(terminal.getTerminalWidth()));
- session.put(".jline.terminal", terminal);
- new Thread(console, "Karaf Shell Console Thread").start();
- }
- }
-
- protected void stop() throws Exception {
- if (console != null) {
- console.close();
- }
- }
-
- private static PrintStream wrap(PrintStream stream) {
- OutputStream o = AnsiConsole.wrapOutputStream(stream);
- if (o instanceof PrintStream) {
- return ((PrintStream) o);
- } else {
- return new PrintStream(o);
- }
- }
-
- private static <T> T unwrap(T stream) {
- try {
- Method mth = stream.getClass().getMethod("getRoot");
- return (T) mth.invoke(stream);
- } catch (Throwable t) {
- return stream;
- }
- }
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/jline/TerminalFactory.java b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/jline/TerminalFactory.java
deleted file mode 100644
index 585ca4d..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/jline/TerminalFactory.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.console.jline;
-
-import jline.Terminal;
-import jline.UnsupportedTerminal;
-import jline.AnsiWindowsTerminal;
-import jline.NoInterruptUnixTerminal;
-
-public class TerminalFactory {
-
- private Terminal term;
-
- public synchronized Terminal getTerminal() throws Exception {
- if (term == null) {
- init();
- }
- return term;
- }
-
- public void init() throws Exception {
- if ("jline.UnsupportedTerminal".equals(System.getProperty("jline.terminal"))) {
- term = new UnsupportedTerminal();
- return;
- }
-
- boolean windows = System.getProperty("os.name").toLowerCase().contains("windows");
- try {
- if (windows) {
- AnsiWindowsTerminal t = new AnsiWindowsTerminal();
- t.setDirectConsole(true);
- t.initializeTerminal();
- term = t;
- } else {
- NoInterruptUnixTerminal t = new NoInterruptUnixTerminal();
- t.initializeTerminal();
- term = t;
- }
- } catch (Throwable e) {
- System.out.println("Using an unsupported terminal: " + e.toString());
- term = new UnsupportedTerminal();
- }
- }
-
- public synchronized void destroy() throws Exception {
- if (term != null) {
- term.restoreTerminal();
- term = null;
- }
- }
-
-}
diff --git a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/jline/keybindings.properties b/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/jline/keybindings.properties
deleted file mode 100644
index 93057c2..0000000
--- a/karaf/shell/console/src/main/java/org/apache/felix/karaf/shell/console/jline/keybindings.properties
+++ /dev/null
@@ -1,81 +0,0 @@
-##
-## Licensed to the Apache Software Foundation (ASF) under one
-## or more contributor license agreements. See the NOTICE file
-## distributed with this work for additional information
-## regarding copyright ownership. The ASF licenses this file
-## to you under the Apache License, Version 2.0 (the
-## "License"); you may not use this file except in compliance
-## with the License. You may obtain a copy of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing,
-## software distributed under the License is distributed on an
-## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-## KIND, either express or implied. See the License for the
-## specific language governing permissions and limitations
-## under the License.
-##
-
-# Keybinding mapping for JLine. The format is:
-# [key code]: [logical operation]
-
-# CTRL-B: move to the previous character
-2: PREV_CHAR
-
-# CTRL-G: move to the previous word
-7: PREV_WORD
-
-# CTRL-F: move to the next character
-6: NEXT_CHAR
-
-# CTRL-A: move to the beginning of the line
-1: MOVE_TO_BEG
-
-# CTRL-D: close out the input stream
-4: EXIT
-
-# CTRL-E: move the cursor to the end of the line
-5: MOVE_TO_END
-
-# BACKSPACE, CTRL-H: delete the previous character
-# 8 is the ASCII code for backspace and therefor
-# deleting the previous character
-8: DELETE_PREV_CHAR
-
-# TAB, CTRL-I: signal that console completion should be attempted
-9: COMPLETE
-
-# CTRL-J, CTRL-M: newline
-10: NEWLINE
-
-# CTRL-K: erase the current line
-11: KILL_LINE
-
-# ENTER: newline
-13: NEWLINE
-
-# CTRL-L: clear screen
-12: CLEAR_SCREEN
-
-# CTRL-N: scroll to the next element in the history buffer
-14: NEXT_HISTORY
-
-# CTRL-P: scroll to the previous element in the history buffer
-16: PREV_HISTORY
-
-# CTRL-R: redraw the current line
-18: REDISPLAY
-
-# CTRL-U: delete all the characters before the cursor position
-21: KILL_LINE_PREV
-
-# CTRL-V: paste the contents of the clipboard (useful for Windows terminal)
-22: PASTE
-
-# CTRL-W: delete the word directly before the cursor
-23: DELETE_PREV_WORD
-
-# DELETE, CTRL-?: delete the previous character
-# 127 is the ASCII code for delete
-127: DELETE_PREV_CHAR
diff --git a/karaf/shell/console/src/main/resources/OSGI-INF/blueprint/karaf-console.xml b/karaf/shell/console/src/main/resources/OSGI-INF/blueprint/karaf-console.xml
deleted file mode 100644
index f0a7ee7..0000000
--- a/karaf/shell/console/src/main/resources/OSGI-INF/blueprint/karaf-console.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
-
- <ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"/>
-
- <reference id="commandProcessor" interface="org.osgi.service.command.CommandProcessor">
- <reference-listener ref="consoleFactory"
- bind-method="registerCommandProcessor"
- unbind-method="unregisterCommandProcessor"/>
- </reference>
-
- <reference-list id="functions" filter="(&(osgi.command.scope=*)(osgi.command.function=*))"
- availability="optional">
- <reference-listener ref="commandCompleter"
- bind-method="register"
- unbind-method="unregister"/>
- </reference-list>
-
- <bean id="commandCompleter" class="org.apache.felix.karaf.shell.console.completer.CommandsCompleter">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </bean>
-
- <bean id="consoleFactory" class="org.apache.felix.karaf.shell.console.jline.ConsoleFactory">
- <property name="start" value="$[karaf.startLocalConsole]"/>
- <property name="bundleContext" ref="blueprintBundleContext"/>
- <property name="completers">
- <list>
- <ref component-id="commandCompleter"/>
- </list>
- </property>
- <property name="terminalFactory" ref="terminalFactory"/>
- </bean>
-
- <bean id="terminalFactory" class="org.apache.felix.karaf.shell.console.jline.TerminalFactory"
- destroy-method="destroy"/>
-
-
-</blueprint>
diff --git a/karaf/shell/console/src/main/resources/OSGI-INF/blueprint/shell-namespacehandler.xml b/karaf/shell/console/src/main/resources/OSGI-INF/blueprint/shell-namespacehandler.xml
deleted file mode 100644
index 870df38..0000000
--- a/karaf/shell/console/src/main/resources/OSGI-INF/blueprint/shell-namespacehandler.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <service interface="org.apache.aries.blueprint.NamespaceHandler">
- <service-properties>
- <entry key="osgi.service.blueprint.namespace" value="http://felix.apache.org/karaf/xmlns/shell/v1.0.0"/>
- </service-properties>
- <bean class="org.apache.felix.karaf.shell.console.commands.NamespaceHandler"/>
- </service>
-
-</blueprint>
diff --git a/karaf/shell/console/src/main/resources/org/apache/felix/karaf/shell/console/commands/karaf-shell.xsd b/karaf/shell/console/src/main/resources/org/apache/felix/karaf/shell/console/commands/karaf-shell.xsd
deleted file mode 100644
index 7230804..0000000
--- a/karaf/shell/console/src/main/resources/org/apache/felix/karaf/shell/console/commands/karaf-shell.xsd
+++ /dev/null
@@ -1,217 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-
-<!-- $Rev: 699828 $ $Date: 2008-09-28 16:35:27 +0200 (Sun, 28 Sep 2008) $ -->
-
-<xsd:schema xmlns="http://felix.apache.org/karaf/xmlns/shell/v1.0.0"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- targetNamespace="http://felix.apache.org/karaf/xmlns/shell/v1.0.0"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified">
-
- <xsd:import namespace="http://www.osgi.org/xmlns/blueprint/v1.0.0"/>
-
- <xsd:annotation>
- <xsd:documentation>
- Defines the configuration elements for Apache Felix Karaf commands support.
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:element name="command-bundle">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
- Defines a command bundle.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice minOccurs="0" maxOccurs="unbounded">
- <xsd:element ref="command"/>
- <xsd:element ref="alias"/>
- <xsd:element ref="link"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="command">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
- Defines a command.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <!--
- NOTE: Not using an xsd:choice here, as I can't seem to figure out how to get it to properly
- validate the min/max of the containted elements. W/o the xsd:choice the validation
- works, though have to define elements in order :-(
- -->
- <xsd:element ref="action" minOccurs="1" maxOccurs="1"/>
- <xsd:element ref="documenter" minOccurs="0" maxOccurs="1"/>
- <xsd:choice minOccurs="0" maxOccurs="1">
- <xsd:element ref="completer"/>
- <xsd:element ref="completers"/>
- </xsd:choice>
- <xsd:element ref="message-source" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="link">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
- Defines a link command.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target" type="xsd:string" use="required"/>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:group name="commandComponentElements">
- <xsd:annotation>
- <xsd:documentation>
- Defines the valid elements for command components. This is based on beans:beanElements,
- stripping off the bits which are not valid in the command component context.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice minOccurs="0" maxOccurs="unbounded">
- <xsd:element name="argument" type="bp:Targument"/>
- <xsd:element name="property" type="bp:Tproperty"/>
- <!--
- NOTE: This seems to cause schema validation problems... not really sure why
- <xsd:any namespace="##other" processContents="strict" minOccurs="0" maxOccurs="unbounded"/>
- -->
- </xsd:choice>
- </xsd:sequence>
- </xsd:group>
-
- <xsd:attributeGroup name="commandComponentAttributes">
- <xsd:annotation>
- <xsd:documentation>
- Defines the valid attributes for command components. This is based on beans:beanAttributes,
- stripping off the bits which are not valid in the command component context.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string"/>
- <xsd:attribute name="depends-on" type="xsd:string"/>
- <xsd:attribute name="init-method" type="xsd:string"/>
- <xsd:attribute name="factory-method" type="xsd:string"/>
- <xsd:attribute name="factory-bean" type="xsd:string"/>
- <xsd:anyAttribute namespace="##other" processContents="lax"/>
- </xsd:attributeGroup>
-
- <xsd:complexType name="commandComponent" abstract="true">
- <xsd:annotation>
- <xsd:documentation>
- Support for command component elements, which are all basically just beans.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:group ref="commandComponentElements"/>
- <xsd:attributeGroup ref="commandComponentAttributes"/>
- </xsd:complexType>
-
- <xsd:element name="action">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
- Defines a command action.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="commandComponent"/>
- </xsd:complexContent>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="documenter">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
- Defines a command documenter.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="commandComponent"/>
- </xsd:complexContent>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="completer">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
- Defines a command completer.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="commandComponent"/>
- </xsd:complexContent>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="completers">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
- Defines a configurable command completer with a set of completers.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice minOccurs="1" maxOccurs="unbounded">
- <xsd:element name="bean" type="bp:Tbean"/>
- <xsd:element name="ref" type="bp:Tref"/>
- <xsd:element name="null" type="bp:Tnull"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="message-source">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
- Defines a command message source.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="commandComponent"/>
- </xsd:complexContent>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="alias">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
- Defines a command alias.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="alias" type="xsd:string" use="required"/>
- </xsd:complexType>
- </xsd:element>
-
-</xsd:schema>
diff --git a/karaf/shell/console/src/test/java/org/apache/felix/gogo/commands/Context.java b/karaf/shell/console/src/test/java/org/apache/felix/gogo/commands/Context.java
deleted file mode 100644
index 1e266da..0000000
--- a/karaf/shell/console/src/test/java/org/apache/felix/gogo/commands/Context.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.gogo.commands;
-
-import org.apache.felix.gogo.runtime.threadio.ThreadIOImpl;
-import org.apache.felix.gogo.runtime.shell.CommandShellImpl;
-import org.apache.felix.gogo.runtime.shell.CommandSessionImpl;
-
-public class Context extends CommandShellImpl
-{
- public static final String EMPTY = "";
- CommandSessionImpl session = (CommandSessionImpl) createSession(System.in, System.out, System.err);
- static ThreadIOImpl threadio;
-
- static
- {
- threadio = new ThreadIOImpl();
- threadio.start();
-
- }
-
- public Context()
- {
- setThreadio(threadio);
- }
-
- public Object execute(CharSequence source) throws Exception
- {
- return session.execute(source);
- }
-
- public void addCommand(String name, Object target)
- {
- put("test:" + name, target);
- }
-
- public void set(String name, Object value)
- {
- session.put(name, value);
- }
-
-
-}
\ No newline at end of file
diff --git a/karaf/shell/console/src/test/java/org/apache/felix/gogo/commands/TestCommands.java b/karaf/shell/console/src/test/java/org/apache/felix/gogo/commands/TestCommands.java
deleted file mode 100644
index 72256e0..0000000
--- a/karaf/shell/console/src/test/java/org/apache/felix/gogo/commands/TestCommands.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.gogo.commands;
-
-import java.util.List;
-import java.util.Arrays;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-
-import junit.framework.TestCase;
-import org.osgi.service.command.CommandSession;
-import org.apache.felix.gogo.commands.basic.SimpleCommand;
-
-public class TestCommands extends TestCase {
-
-
- public void testPrompt() throws Exception {
- Context c = new Context();
- c.addCommand("echo", this);
- c.set("USER", "gnodet");
- c.set("APPLICATION", "karaf");
- //c.set("SCOPE", "");
- Object p = c.execute("echo \"@|bold ${USER}|@${APPLICATION}:@|bold ${SCOPE}|> \"");
- System.out.println("Prompt: " + p);
- }
-
- public void testCommand() throws Exception {
- Context c= new Context();
- c.addCommand("capture", this);
- c.addCommand("my-action", new SimpleCommand(MyAction.class));
-
- // Test help
- Object help = c.execute("my-action --help | capture");
- assertTrue(help instanceof String);
- assertTrue(((String) help).indexOf("My Action") >= 0);
- assertTrue(((String) help).indexOf("First option") >= 0);
- assertTrue(((String) help).indexOf("Bundle ids") >= 0);
-
-
- // Test required argument
- try
- {
- c.execute("my-action");
- fail("Action should have thrown an exception because of a missing argument");
- }
- catch (IllegalArgumentException e)
- {
- }
-
- // Test required argument
- assertEquals(Arrays.asList(3), c.execute("my-action 3"));
-
- // Test required argument
- assertEquals(Arrays.asList(3), c.execute("my-action 3"));
-
- // Test required argument
- assertEquals(Arrays.asList(3, 5), c.execute("my-action 3 5"));
-
- // Test option
- assertEquals(Arrays.asList(4), c.execute("my-action -i 3"));
-
- // Test option alias
- assertEquals(Arrays.asList(4), c.execute("my-action --increment 3"));
- }
-
- public String capture() throws IOException
- {
- StringWriter sw = new StringWriter();
- BufferedReader rdr = new BufferedReader(new InputStreamReader(System.in));
- String s = rdr.readLine();
- while (s != null)
- {
- sw.write(s);
- s = rdr.readLine();
- }
- return sw.toString();
- }
-
- public CharSequence echo(Object args[])
- {
- if (args == null)
- {
- return "";
- }
-
- StringBuilder sb = new StringBuilder();
- String del = "";
- for (Object arg : args)
- {
- sb.append(del);
- if (arg != null)
- {
- sb.append(arg);
- del = " ";
- }
- }
- return sb;
- }
-
- @Command(scope = "test", name = "my-action", description = "My Action")
- public static class MyAction implements Action
- {
-
- @Option(name = "-i", aliases = { "--increment" }, description = "First option")
- private boolean increment;
-
- @Argument(name = "ids", description = "Bundle ids", required = true, multiValued = true)
- private List<Integer> ids;
-
- public Object execute(CommandSession session) throws Exception {
- if (increment)
- {
- for (int i = 0; i < ids.size(); i++)
- {
- ids.set(i, ids.get(i) + 1);
- }
- }
- return ids;
- }
- }
-}
\ No newline at end of file
diff --git a/karaf/shell/dev/pom.xml b/karaf/shell/dev/pom.xml
deleted file mode 100644
index 15a4ca2..0000000
--- a/karaf/shell/dev/pom.xml
+++ /dev/null
@@ -1,90 +0,0 @@
-<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.
- -->
-
- <parent>
- <artifactId>shell</artifactId>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>org.apache.felix.karaf.shell.dev</artifactId>
- <packaging>bundle</packaging>
- <name>Apache Felix Karaf :: Shell Development Commands</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.ops4j.pax.url</groupId>
- <artifactId>pax-url-wrap</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.utils</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Import-Package>
- !${project.artifactId}*,
- org.osgi.service.command,
- org.apache.felix.gogo.commands,
- org.apache.felix.karaf.shell.console,
- *
- </Import-Package>
- <Private-Package>
- org.apache.felix.utils.version,
- !*
- </Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
diff --git a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/AbstractBundleCommand.java b/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/AbstractBundleCommand.java
deleted file mode 100644
index bc4f7b8..0000000
--- a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/AbstractBundleCommand.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.dev;
-
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.ExportedPackage;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/**
- * Base class for a dev: command that takes a bundle id as an argument
- *
- * It also provides convient access to the PackageAdmin service
- */
-public abstract class AbstractBundleCommand extends OsgiCommandSupport {
-
- @Argument(index = 0, name = "id", description = "The bundle ID", required = true)
- Long id;
-
- private PackageAdmin admin;
-
- @Override
- protected Object doExecute() throws Exception {
- // Get package admin service.
- ServiceReference ref = getBundleContext().getServiceReference(PackageAdmin.class.getName());
- if (ref == null) {
- System.out.println("PackageAdmin service is unavailable.");
- return null;
- }
-
- // using the getService call ensures that the reference will be released at the end
- admin = getService(PackageAdmin.class, ref);
-
- Bundle bundle = getBundleContext().getBundle(id);
- if (bundle == null) {
- System.err.println("Bundle ID" + id + " is invalid");
- return null;
- }
-
- doExecute(bundle);
-
- return null;
- }
-
- protected abstract void doExecute(Bundle bundle) throws Exception;
-
- /*
- * Get the list of bundles from which the given bundle imports packages
- */
- protected Map<String, Bundle> getWiredBundles(Bundle bundle) {
- // the set of bundles from which the bundle imports packages
- Map<String, Bundle> exporters = new HashMap<String, Bundle>();
-
- for (ExportedPackage pkg : getPackageAdmin().getExportedPackages((Bundle) null)) {
- Bundle[] bundles = pkg.getImportingBundles();
- if (bundles != null) {
- for (Bundle importingBundle : bundles) {
- if (bundle.equals(importingBundle)
- && !(pkg.getExportingBundle().getBundleId() == 0)
- && !(pkg.getExportingBundle().equals(bundle))) {
- exporters.put(pkg.getName(), pkg.getExportingBundle());
- }
- }
- }
- }
- return exporters;
- }
-
- protected PackageAdmin getPackageAdmin() {
- return admin;
- }
-}
diff --git a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/DynamicImport.java b/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/DynamicImport.java
deleted file mode 100644
index 228db5f..0000000
--- a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/DynamicImport.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.dev;
-
-import java.io.IOException;
-import static java.lang.String.format;
-import java.net.URL;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.ops4j.pax.url.wrap.Handler;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.ExportedPackage;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/**
- * Command for enabling/disabling debug logging on a bundle and calculating the difference in
- * wired imports.
- */
-@Command(scope = "dev", name = "dynamic-import",
- description = "Enable/disable dynamic-import for a given bundle")
-public class DynamicImport extends AbstractBundleCommand {
-
- private static final Log LOG = LogFactory.getLog(DynamicImport.class);
-
- /**
- * The header key where we store the active wires when we enable DynamicImport=*
- */
- protected static final String ORIGINAL_WIRES = "Original-Wires";
-
- @Override
- protected void doExecute(Bundle bundle) throws Exception {
- if (bundle.getHeaders().get(ORIGINAL_WIRES) == null) {
- enableDynamicImports(bundle);
- } else {
- disableDynamicImports(bundle);
- }
- }
-
- /*
- * Enable DynamicImport=* on the bundle
- */
- private void enableDynamicImports(Bundle bundle) throws IOException, BundleException {
- System.out.printf("Enabling dynamic imports on bundle %s%n", bundle);
-
- String location =
- String.format("wrap:%s$" +
- "Bundle-UpdateLocation=%s&" +
- "DynamicImport-Package=*&" +
- "%s=%s&" +
- "overwrite=merge",
- bundle.getLocation(),
- bundle.getLocation(),
- ORIGINAL_WIRES,
- explode(getWiredBundles(bundle).keySet()));
- LOG.debug(format("Updating %s with URL %s", bundle, location));
-
- URL url = new URL(location);
- bundle.update(url.openStream());
- getPackageAdmin().refreshPackages(new Bundle[] {bundle});
- }
-
- /*
- * Disable DynamicImport=* on the bundle
- *
- * At this time, we will also calculate the difference in package wiring for the bundle compared to
- * when we enabled the DynamicImport
- */
- private void disableDynamicImports(Bundle bundle) throws BundleException {
- System.out.printf("Disabling dynamic imports on bundle %s%n", bundle);
-
- Set<String> current = getWiredBundles(bundle).keySet();
- for (String original : bundle.getHeaders().get(ORIGINAL_WIRES).toString().split(",")) {
- current.remove(original);
- }
-
- if (current.isEmpty()) {
- System.out.println("(no additional packages have been wired since dynamic import was enabled)");
- } else {
- System.out.printf("%nAdditional packages wired since dynamic import was enabled:%n");
- for (String pkg : current) {
- System.out.printf("- %s%n", pkg);
- }
- }
-
- bundle.update();
- }
-
- /*
- * Explode a set of string values in to a ,-delimited string
- */
- private String explode(Set<String> set) {
- StringBuffer result = new StringBuffer();
- Iterator<String> it = set.iterator();
- while (it.hasNext()) {
- result.append(it.next());
- if (it.hasNext()) {
- result.append(",");
- }
- }
- return result.toString();
- }
-}
diff --git a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/FrameworkDebug.java b/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/FrameworkDebug.java
deleted file mode 100644
index 7413c91..0000000
--- a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/FrameworkDebug.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.dev;
-
-import java.io.File;
-
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.karaf.shell.dev.framework.Equinox;
-import org.apache.felix.karaf.shell.dev.framework.Felix;
-import org.apache.felix.karaf.shell.dev.framework.Framework;
-
-/**
- * Command for enabling/disabling debug logging on the OSGi framework
- */
-@Command(scope = "dev", name = "framework",
- description = "Enable/disable debugging for the OSGi Framework")
-public class FrameworkDebug extends OsgiCommandSupport {
-
- private static final String KARAF_BASE = System.getProperty("karaf.base");
-
- @Option(name = "-debug", aliases={"--enable-debug"}, description="Enable debug for the OSGi framework", required = false, multiValued = false)
- boolean debug;
-
- @Option(name = "-nodebug", aliases={"--disable-debug"}, description="Disable debug for the OSGi framework", required = false, multiValued = false)
- boolean nodebug;
-
- @Override
- protected Object doExecute() throws Exception {
- Framework framework = getFramework();
-
- if (!debug^nodebug) {
- System.err.printf("Required option missing: use -debug or -nodebug%n");
- return null;
- }
- if (debug) {
- System.out.printf("Enabling debug for OSGi framework (%s)%n", framework.getName());
- framework.enableDebug(new File(KARAF_BASE));
- }
- if (nodebug) {
- System.out.printf("Disabling debug for OSGi framework (%s)%n", framework.getName());
- framework.disableDebug(new File(KARAF_BASE));
- }
-
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
-
- public Framework getFramework() {
- if (bundleContext.getBundle(0).getSymbolicName().contains("felix")) {
- return new Felix(new File(KARAF_BASE));
- } else {
- return new Equinox(new File(KARAF_BASE));
- }
- }
-}
diff --git a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/PrintStackTraces.java b/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/PrintStackTraces.java
deleted file mode 100644
index a34c03d..0000000
--- a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/PrintStackTraces.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.dev;
-
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.karaf.shell.console.jline.Console;
-import org.osgi.framework.Bundle;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static java.lang.String.format;
-
-/**
- * Command for showing the full tree of bundles that have been used to resolve
- * a given bundle.
- */
-@Command(scope = "dev", name = "print-stack-traces",
- description = "Print the full stack trace in the console when the execution of a command throws an exception")
-public class PrintStackTraces extends OsgiCommandSupport {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(PrintStackTraces.class);
-
- @Argument(name = "print", description="Print stack traces or not", required = false, multiValued = false)
- boolean print = true;
-
- protected Object doExecute() throws Exception {
- session.put(Console.PRINT_STACK_TRACES, Boolean.valueOf(print));
- return null;
- }
-
-}
\ No newline at end of file
diff --git a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/ShowBundleTree.java b/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/ShowBundleTree.java
deleted file mode 100644
index 5c2cbea..0000000
--- a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/ShowBundleTree.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.dev;
-
-import static java.lang.String.format;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.karaf.shell.dev.util.Bundles;
-import org.apache.felix.karaf.shell.dev.util.Import;
-import org.apache.felix.karaf.shell.dev.util.Node;
-import org.apache.felix.karaf.shell.dev.util.Tree;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.ExportedPackage;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Command for showing the full tree of bundles that have been used to resolve
- * a given bundle.
- */
-@Command(scope = "dev", name = "show-tree",
- description = "Show the tree of bundles based on the wiring information")
-public class ShowBundleTree extends AbstractBundleCommand {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ShowBundleTree.class);
-
- private Tree<Bundle> tree;
-
- @Override
- protected void doExecute(Bundle bundle) throws Exception {
- long start = System.currentTimeMillis();
- // let's do the real work here
- printHeader(bundle);
- tree = new Tree<Bundle>(bundle);
- createTree(bundle);
- printTree(tree);
- printDuplicatePackages(tree);
- LOGGER.debug(format("Dependency tree calculated in %d ms",
- System.currentTimeMillis() - start));
- }
-
- /*
- * Print the header
- */
- private void printHeader(Bundle bundle) {
- System.out.printf("Bundle %s [%s] is currently %s%n",
- bundle.getSymbolicName(),
- bundle.getBundleId(),
- Bundles.toString(bundle.getState()));
- }
-
- /*
- * Print the dependency tree
- */
- private void printTree(Tree<Bundle> tree) {
- System.out.printf("%n");
- tree.write(System.out, new Tree.Converter<Bundle>() {
-
- public String toString(Node<Bundle> node) {
- return String.format("%s [%s]",
- node.getValue().getSymbolicName(),
- node.getValue().getBundleId());
- }
- });
- }
-
- /*
- * Check for bundles in the tree exporting the same package
- * as a possible cause for 'Unresolved constraint...' on a uses-conflict
- */
- private void printDuplicatePackages(Tree<Bundle> tree) {
- Set<Bundle> bundles = tree.flatten();
- Map<String, Set<Bundle>> exports = new HashMap<String, Set<Bundle>>();
-
- for (Bundle bundle : bundles) {
- ExportedPackage[] packages = getPackageAdmin().getExportedPackages(bundle);
- if (packages != null) {
- for (ExportedPackage p : packages) {
- if (exports.get(p.getName()) == null) {
- exports.put(p.getName(), new HashSet<Bundle>());
- }
- exports.get(p.getName()).add(bundle);
- }
- }
- }
-
- for (String pkg : exports.keySet()) {
- if (exports.get(pkg).size() > 1) {
- System.out.printf("%n");
- System.out.printf("WARNING: multiple bundles are exporting package %s%n", pkg);
- for (Bundle bundle : exports.get(pkg)) {
- System.out.printf("- %s%n", bundle);
- }
- }
- }
- }
-
- /*
- * Creates the bundle tree
- */
- protected void createTree(Bundle bundle) {
- if (bundle.getState() >= Bundle.RESOLVED) {
- createNode(tree);
- } else {
- createNodesForImports(tree, bundle);
- }
- }
-
- /*
- * Creates nodes for the imports of the bundle (instead of reporting wiring information
- */
- private void createNodesForImports(Node node, Bundle bundle) {
- for (Import i : Import.parse(String.valueOf(bundle.getHeaders().get("Import-Package")),
- String.valueOf(bundle.getHeaders().get("Export-Package")))) {
- createNodeForImport(node, bundle, i);
- }
- }
-
- /*
- * Create a child node for a given import (by finding a matching export in the currently installed bundles)
- */
- private void createNodeForImport(Node node, Bundle bundle, Import i) {
- ExportedPackage[] exporters = getPackageAdmin().getExportedPackages(i.getPackage());
- boolean foundMatch = false;
- if (exporters != null) {
- for (ExportedPackage ep : exporters) {
- if (i.getVersion().contains(ep.getVersion())) {
- if (bundle.equals(ep.getExportingBundle())) {
- foundMatch = true;
- } else {
- Node child = node.addChild(ep.getExportingBundle());
- System.out.printf("- import %s: resolved using %s%n", i, ep.getExportingBundle());
- foundMatch = true;
- createNode(child);
- }
- }
- }
- }
- if (!foundMatch) {
- System.out.printf("- import %s: WARNING - unable to find matching export%n", i);
- }
- }
-
- /*
- * Creates a node in the bundle tree
- */
- private void createNode(Node<Bundle> node) {
- Bundle bundle = node.getValue();
- Collection<Bundle> exporters = new HashSet<Bundle>();
- exporters.addAll(getWiredBundles(bundle).values());
-
- for (Bundle exporter : exporters) {
- if (node.hasAncestor(exporter)) {
- LOGGER.debug(format("Skipping %s (already exists in the current branch)", exporter));
- } else {
- boolean existing = tree.flatten().contains(exporter);
- LOGGER.debug(format("Adding %s as a dependency for %s", exporter, bundle));
- Node child = node.addChild(exporter);
- if (existing) {
- LOGGER.debug(format("Skipping children of %s (already exists in another branch)", exporter));
- } else {
- createNode(child);
- }
- }
- }
- }
-}
diff --git a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/framework/Equinox.java b/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/framework/Equinox.java
deleted file mode 100644
index 288697b..0000000
--- a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/framework/Equinox.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.dev.framework;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.felix.karaf.shell.dev.util.IO;
-
-/**
- * Represents Eclipse's Equinox as the underlying OSGi framework
- */
-public class Equinox extends Framework {
-
- /**
- * Create a new instance
- *
- * @param base
- */
- public Equinox(File base) {
- super(base);
- }
-
- public String getName() {
- return "Equinox";
- }
-
- public void enableDebug(File directory) throws IOException {
- setConfigProperty("osgi.debug", "etc/equinox-debug.properties");
- saveConfigProperties();
-
- System.out.printf("- set osgi.debug=etc/equinox-debug.properties in etc/config.properties%n");
-
- File debug = new File(directory, "etc/equinox-debug.properties");
- if (!debug.exists()) {
- IO.copyTextToFile(
- Equinox.class.getResourceAsStream("equinox-debug.properties"),
- debug);
- System.out.printf("- created etc/equinox-debug.properties to configure Equinox debugging options%n");
- }
-
- System.out.printf("%nEnable specific debug options in etc/equinox-debug.properties%n");
- System.out.printf("and restart Karaf now to enable Equinox debug logging%n");
- }
-
- @Override
- public void disableDebug(File directory) throws IOException {
- removeConfigProperty("osgi.debug");
- saveConfigProperties();
-
- System.out.printf("- removed osgi.debug from etc/config.properties%n%n");
- System.out.printf("Restart Karaf now to disable Equinox debug logging%n");
-
- }
-}
diff --git a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/framework/Felix.java b/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/framework/Felix.java
deleted file mode 100644
index ff5c6a9..0000000
--- a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/framework/Felix.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.dev.framework;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Represents Apache Felix as the underlying OSGi platform
- */
-public class Felix extends Framework {
-
- /**
- * Create a instance of Karaf running with Felix in the given base directory
- *
- * @param base the base directory
- */
- public Felix(File base) {
- super(base);
- }
-
- public String getName() {
- return "Felix";
- }
-
- public void enableDebug(File directory) throws IOException {
- setConfigProperty("felix.log.level", "4");
- saveConfigProperties();
-
- System.out.printf("- set felix.log.level=4 in etc/config.properties%n%n");
- System.out.printf("Restart Karaf now to enable Felix debug logging%n");
- }
-
- public void disableDebug(File directory) throws IOException {
- removeConfigProperty("felix.log.level");
- saveConfigProperties();
-
- System.out.printf("- removed felix.log.level from etc/config.properties%n%n");
- System.out.printf("Restart Karaf now to disable Felix debug logging%n");
- }
-}
diff --git a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/framework/Framework.java b/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/framework/Framework.java
deleted file mode 100644
index e930549..0000000
--- a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/framework/Framework.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.dev.framework;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Class to represent the underlying OSGi framework
- */
-public abstract class Framework {
-
- /*
- * The Karaf base directory
- */
- private File base;
-
- /*
- * The contents of the etc/config.properties file
- */
- private List<String> config;
-
- /**
- * Create a instance of this framework in the given base directory
- *
- * @param base the base directory
- */
- public Framework(File base) {
- super();
- this.base = base;
- }
-
- /**
- * Get the underlying OSGi framework name
- */
- public abstract String getName();
-
- /**
- * Enable the OSGi framework's debug logging
- *
- * @param directory the directory containing the Karaf installation
- * @throws IOException when a problem occurs configuring debug settings
- */
- public abstract void enableDebug(File directory) throws IOException;
-
- /**
- * Disable the OSGI framework's debug logging
- *
- * @param directory the Karaf base installation directory
- * @throws IOException when a problem occurs removing debug configuration settings
- */
- public abstract void disableDebug(File directory) throws IOException;
-
- /*
- * Save the etc/config.properties file
- */
- protected void saveConfigProperties() throws IOException {
- PrintWriter writer = null;
- try {
- writer = new PrintWriter(new File(base, "etc/config.properties"));
- for (String line : getConfig()) {
- writer.printf("%s%n", line);
- }
- writer.flush();
- writer.close();
- } finally {
- if (writer != null) {
- writer.close();
- }
- }
- }
-
- protected List<String> readPropertyFile(File config) throws IOException {
- List<String> result = new LinkedList<String>();
- BufferedReader reader = new BufferedReader(new FileReader(config));
- String line = reader.readLine();
- while (line != null) {
- result.add(line);
- line = reader.readLine();
- }
- return result;
- }
-
- /**
- * Set a new key and value in the etc/config.properties - if the given key
- * already exists, the existing value will be overwritten
- *
- * @param key property key
- * @param value property value
- * @throws IOException if the etc/config.properties file can not be read
- */
- protected void setConfigProperty(String key, String value) throws IOException {
- boolean done = false;
-
- for (int i = 0 ; i < getConfig().size() ; i++) {
- if (getConfig().get(i).startsWith(key)) {
- getConfig().set(i, java.lang.String.format("%s=%s", key, value));
- done = true;
- }
- }
-
- if (!done) {
- getConfig().add("");
- getConfig().add(java.lang.String.format("%s=%s", key, value, new Date()));
- }
- }
-
- /**
- * Remove an existing key from the etc/config.properties file
- *
- * @param key the key
- * @throws IOException if the etc/config.properties file can not be read
- */
- protected void removeConfigProperty(String key) throws IOException {
- for (int i = 0 ; i < getConfig().size() ; i++) {
- if (getConfig().get(i).startsWith(key)) {
- getConfig().remove(i);
- }
- }
- }
-
- /**
- * Access the contents of the etc/config.properties file
- *
- * @return the contents of the file
- * @throws IOException if the etc/config.properties file can not be read
- */
- public List<String> getConfig() throws IOException {
- if (config == null) {
- config = readPropertyFile(new File(base, "etc/config.properties"));
- }
- return config;
- }
-}
diff --git a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/util/Bundles.java b/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/util/Bundles.java
deleted file mode 100644
index acf70eb..0000000
--- a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/util/Bundles.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.dev.util;
-
-import org.osgi.framework.Bundle;
-
-/**
- * A set of utility methods for working with {@link org.osgi.framework.Bundle}s
- */
-public class Bundles {
-
- /**
- * Return a String representation of a bundle state
- */
- public static String toString(int state) {
- switch (state) {
- case Bundle.UNINSTALLED : return "UNINSTALLED";
- case Bundle.INSTALLED : return "INSTALLED";
- case Bundle.RESOLVED: return "RESOLVED";
- case Bundle.STARTING : return "STARTING";
- case Bundle.STOPPING : return "STOPPING";
- case Bundle.ACTIVE : return "ACTIVE";
- default : return "UNKNOWN";
- }
- }
-}
diff --git a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/util/IO.java b/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/util/IO.java
deleted file mode 100644
index 15f5f45..0000000
--- a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/util/IO.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.dev.util;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.util.Scanner;
-
-/**
- * Helper class for I/O operations
- */
-public class IO {
-
- /**
- * Write text from an InputStream to a file
- */
- public static void copyTextToFile(InputStream stream, File file) throws IOException {
- PrintWriter writer = null;
- Scanner scanner = null;
-
- try {
- scanner = new Scanner(stream);
- writer = new PrintWriter(file);
-
- while (scanner.hasNextLine()) {
- writer.printf("%s%n", scanner.nextLine());
- }
-
- writer.flush();
- } finally {
- if (scanner != null) {
- scanner.close();
- }
- if (writer != null) {
- writer.close();
- }
- }
- }
-}
diff --git a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/util/Import.java b/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/util/Import.java
deleted file mode 100644
index 66ee9c4..0000000
--- a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/util/Import.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.dev.util;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.felix.utils.version.VersionRange;
-
-/**
- * Simple class to model an OSGi Import-Package
- */
-public class Import {
-
- private final String packageName;
- private final VersionRange version;
- private final String value;
-
- /**
- * Create a new import based on the string value found in MANIFEST.MF
- *
- * @param value the MANIFEST.MF value
- */
- protected Import(String value) {
- super();
- this.value = value;
- this.packageName = extractPackageName(value);
- if (value.contains("version=")) {
- this.version = extractVersion(value);
- } else {
- this.version = VersionRange.ANY_VERSION;
- }
- }
-
- /*
- * Extract the version from the string
- */
- private VersionRange extractVersion(String value) {
- int begin = value.indexOf("version=") + 8;
- int end = value.indexOf(";", begin);
- if (end < 0) {
- return VersionRange.parseVersionRange(unquote(value.substring(begin)));
- } else {
- return VersionRange.parseVersionRange(unquote(value.substring(begin, end)));
- }
- }
-
- /*
- * Remove leading/trailing quotes
- */
- private String unquote(String string) {
- return string.replace("\"", "");
- }
-
- public String getPackage() {
- return packageName;
- }
-
- public VersionRange getVersion() {
- return version;
- }
-
- @Override
- public String toString() {
- return value;
- }
-
- /**
- * Parse the value of an Import-Package META-INF header and return
- * a list of Import instances
- */
- public static List<Import> parse(String value) {
- LinkedList<Import> imports = new LinkedList<Import>();
- for (String imp : split(value)) {
- imports.add(new Import(imp));
- }
- return imports;
- }
-
- /**
- * Parse the value of an Import-Package META-INF header and return
- * a list of Import instances, filtering out packages that are in the
- * Export-Package META-INF header
- *
- * @param importValue the value of the Import-Package header
- * @param exportValue the value of the Export-Package header
- */
- public static List<Import> parse(String importValue, String exportValue) {
- LinkedList<String> exports = new LinkedList<String>();
- for (String exp : split(exportValue)) {
- exports.add(extractPackageName(exp));
- }
- LinkedList<Import> imports = new LinkedList<Import>();
- for (Import imp : parse(importValue)) {
- if (!exports.contains(imp.getPackage())) {
- imports.add(imp);
- }
- }
- return imports;
- }
-
- /*
- * Extract the package name from the value
- * e.g. org.apache.felix.karaf;version="1.x" -> org.apache.felix.karaf
- */
- private static String extractPackageName(String value) {
- if (value.contains(";")) {
- return value.split(";")[0];
- } else {
- return value;
- }
- }
-
- /*
- * Counts the number of quotes in a String value
- */
- private static int quotes(String value) {
- return value.replaceAll("[^\"]", "").length();
- }
-
- /*
- * Split the OSGi headers on the , symbol
- */
- private static List<String> split(String value) {
- List<String> result = new LinkedList<String>();
- String[] elements = value.split(",");
- for (int i = 0; i < elements.length ; i++) {
- if (quotes(elements[i]) % 2 == 1) {
- // we probably split a version range, so joining it again with the next element
- result.add(elements[i] + "," + elements[++i]);
- } else {
- result.add(elements[i]);
- }
- }
- return result;
- }
-}
diff --git a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/util/Node.java b/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/util/Node.java
deleted file mode 100644
index b266fe4..0000000
--- a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/util/Node.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.dev.util;
-
-import java.io.PrintWriter;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Represents a node in a {@link org.apache.felix.karaf.shell.dev.util.Tree}
- */
-public class Node<T> {
-
- private final T value;
- private Node<T> parent;
- private List<Node<T>> children = new LinkedList<Node<T>>();
-
- /**
- * Creates a new node. Only meant for internal use,
- * new nodes should be added using the {@link #addChild(Object)} method
- *
- * @param value the node value
- */
- protected Node(T value) {
- super();
- this.value = value;
- }
-
- /**
- * Creates a new node. Only meant for internal use,
- * new nodes should be added using the {@link #addChild(Object)} method
- *
- * @param value the node value
- */
- protected Node(T value, Node<T> parent) {
- this(value);
- this.parent = parent;
- }
-
- /**
- * Access the node's value
- */
- public T getValue() {
- return value;
- }
-
- /**
- * Access the node's child nodes
- */
- public List<Node<T>> getChildren() {
- return children;
- }
-
- /**
- * Adds a child to this node
- *
- * @param value the child's value
- * @return the child node
- */
- public Node addChild(T value) {
- Node node = new Node(value, this);
- children.add(node);
- return node;
- }
-
- /**
- * Give a set of values in the tree.
- *
- * @return
- */
- public Set<T> flatten() {
- Set<T> result = new HashSet<T>();
- result.add(getValue());
- for (Node<T> child : getChildren()) {
- result.addAll(child.flatten());
- }
- return result;
- }
-
- /**
- * Check if the node has an ancestor that represents the given value
- *
- * @param value the node value
- * @return <code>true</code> it there's an ancestor that represents the value
- */
- public boolean hasAncestor(T value) {
- if (parent == null) {
- return false;
- } else {
- return value.equals(parent.value) || parent.hasAncestor(value);
- }
- }
-
- /*
- * Write this node to the PrintWriter. It should be indented one step
- * further for every element in the indents array. If an element in the
- * array is <code>true</code>, there should be a | to connect to the next
- * sibling.
- */
- protected void write(PrintWriter writer, Tree.Converter<T> converter, boolean... indents) {
- for (boolean indent : indents) {
- writer.printf("%-3s", indent ? "|" : "");
- }
- writer.printf("+- %s%n", converter.toString(this));
- for (Node<T> child : getChildren()) {
- child.write(writer, converter, concat(indents, hasNextSibling()));
- }
- }
-
- /*
- * Is this node the last child node for its parent
- * or is there a next sibling?
- */
- private boolean hasNextSibling() {
- if (parent == null) {
- return false;
- } else {
- return parent.getChildren().size() > 1
- && parent.getChildren().indexOf(this) < parent.getChildren().size() - 1;
- }
- }
-
- /*
- * Add an element to the end of the array
- */
- private boolean[] concat(boolean[] array, boolean element) {
- boolean[] result = new boolean[array.length + 1];
- for (int i = 0 ; i < array.length ; i++) {
- result[i] = array[i];
- }
- result[array.length] = element;
- return result;
- }
-}
diff --git a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/util/Tree.java b/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/util/Tree.java
deleted file mode 100644
index a625780..0000000
--- a/karaf/shell/dev/src/main/java/org/apache/felix/karaf/shell/dev/util/Tree.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.dev.util;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Represents a tree that can be written to the console.
- *
- * The output will look like this:
- * <pre>
- * root
- * +- child1
- * | +- grandchild
- * +- child2
- * </pre>
- */
-public class Tree<T> extends Node<T> {
-
- /**
- * Creates a new tree with the given root node
- *
- * @param root the root node
- */
- public Tree(T root) {
- super(root);
- }
-
- /**
- * Write the tree to a PrintStream, using the default toString() method to output the node values
- *
- * @param stream
- */
- public void write(PrintStream stream) {
- write(new PrintWriter(stream));
- }
-
- /**
- * Write the tree to a PrintStream, using the provided converter to output the node values
- *
- * @param stream
- * @param converter
- */
- public void write(PrintStream stream, Converter<T> converter) {
- write(new PrintWriter(stream), converter);
- }
-
- /**
- * Write the tree to a PrintWriter, using the default toString() method to output the node values
- *
- * @param writer
- */
- public void write(PrintWriter writer) {
- write(writer, new Converter() {
- public String toString(Node node) {
- return node.getValue().toString();
- }
- });
- }
-
- /**
- * Write the tree to a PrintWriter, using the provided converter to output the node values
- *
- * @param writer
- * @param converter
- */
- public void write(PrintWriter writer, Converter<T> converter) {
- writer.printf("%s%n", converter.toString(this));
- for (Node<T> child : getChildren()) {
- child.write(writer, converter);
- }
- writer.flush();
- }
-
- /**
- * Interface to convert node values to string
- *
- * @param <T> the object type for the node value
- */
- public static interface Converter<T> {
-
- public String toString(Node<T> node);
-
- }
-}
diff --git a/karaf/shell/dev/src/main/resources/OSGI-INF/blueprint/shell-dev.xml b/karaf/shell/dev/src/main/resources/OSGI-INF/blueprint/shell-dev.xml
deleted file mode 100644
index d19064f..0000000
--- a/karaf/shell/dev/src/main/resources/OSGI-INF/blueprint/shell-dev.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <command-bundle xmlns="http://felix.apache.org/karaf/xmlns/shell/v1.0.0">
- <command name="dev/show-tree">
- <action class="org.apache.felix.karaf.shell.dev.ShowBundleTree"/>
- </command>
- <command name="dev/framework">
- <action class="org.apache.felix.karaf.shell.dev.FrameworkDebug" />
- </command>
- <command name="dev/dynamic-import">
- <action class="org.apache.felix.karaf.shell.dev.DynamicImport" />
- </command>
- <command name="dev/print-stack-traces">
- <action class="org.apache.felix.karaf.shell.dev.PrintStackTraces" />
- </command>
- </command-bundle>
-
-</blueprint>
diff --git a/karaf/shell/dev/src/main/resources/org/apache/felix/karaf/shell/dev/framework/equinox-debug.properties b/karaf/shell/dev/src/main/resources/org/apache/felix/karaf/shell/dev/framework/equinox-debug.properties
deleted file mode 100644
index b842875..0000000
--- a/karaf/shell/dev/src/main/resources/org/apache/felix/karaf/shell/dev/framework/equinox-debug.properties
+++ /dev/null
@@ -1,111 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-
-# http://www.apache.org/licenses/LICENSE-2.0
-
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-#### Debugging options for org.eclipse.osgi
-
-# Turn on general debugging for org.eclipse.osgi
-org.eclipse.osgi/debug=false
-# Prints out class loading debug information
-org.eclipse.osgi/debug/loader=false
-# Prints out event (FrameworkEvent/BundleEvent/ServiceEvent) and listener debug information
-org.eclipse.osgi/debug/events=false
-# Prints out OSGi service debug information (registration/getting/ungetting etc.)
-org.eclipse.osgi/debug/services=false
-# Prints out bundle manifest parsing debug information
-org.eclipse.osgi/debug/manifest=false
-# Prints out LDAP filter debug information
-org.eclipse.osgi/debug/filter=false
-# Prints out security (PermissionAdmin service) debug information
-org.eclipse.osgi/debug/security=false
-# Prints out start level service debug information
-org.eclipse.osgi/debug/startlevel=false
-# Prints out package admin service debug information
-org.eclipse.osgi/debug/packageadmin=false
-# Prints out timing information for bundle activation
-org.eclipse.osgi/debug/bundleTime=false
-# Debug the loading of message bundles
-org.eclipse.osgi/debug/messageBundles=false
-
-# Eclipse adaptor options
-org.eclipse.osgi/eclipseadaptor/debug = false
-org.eclipse.osgi/eclipseadaptor/debug/location = false
-org.eclipse.osgi/eclipseadaptor/debug/platformadmin=false
-org.eclipse.osgi/eclipseadaptor/debug/platformadmin/resolver=false
-org.eclipse.osgi/eclipseadaptor/converter/debug = false
-
-### OSGi resolver options
-# Turns on debugging for the resolver
-org.eclipse.osgi/resolver/debug = false
-# Prints out wiring information after the resolver has completed the resolve process
-org.eclipse.osgi/resolver/wiring = false
-# Prints out Import-Package information
-org.eclipse.osgi/resolver/imports = false
-# Prints out Require-Bundle information
-org.eclipse.osgi/resolver/requires = false
-# Prints out package grouping information form the "uses" clause
-org.eclipse.osgi/resolver/grouping = false
-# Prints out cycle information
-org.eclipse.osgi/resolver/cycles = false
-# Prints out Eclipse-GenericRequire information
-org.eclipse.osgi/resolver/generics = false
-
-#### Profile settings
-org.eclipse.osgi/profile/startup = false
-org.eclipse.osgi/profile/benchmark = false
-org.eclipse.osgi/profile/debug = false
-
-# Override the default implemenation
-org.eclipse.osgi/profile/impl = org.eclipse.osgi.internal.profile.DefaultProfileLogger
-
-# Append all profile messages to the filename specified
-org.eclipse.osgi/defaultprofile/logfilename =
-
-# Output all profile log messages synchronously to the jvm console.
-# By default, all log messages are cached until the log buffer is
-# requested.
-org.eclipse.osgi/defaultprofile/logsynchronously = false
-
-# Specify the size of the default profile implementation log buffer.
-org.eclipse.osgi/defaultprofile/buffersize = 256
-
-#### Monitoring settings
-# monitor class loading
-org.eclipse.osgi/monitor/classes=false
-
-# monitor bundle activation
-org.eclipse.osgi/monitor/activation=false
-
-# monitor resource bundle (*.properties) loading
-org.eclipse.osgi/monitor/resources=false
-
-
-#### Trace settings
-# trace class loading - snapshot the execution stack when a class is loaded
-org.eclipse.osgi/trace/classLoading=false
-
-# trace location - file in which execution traces are written
-org.eclipse.osgi/trace/filename=runtime.traces
-
-# trace filters - Java properties file defining which classes should
-# be traced (if trace/classLoading is true)
-# File format:
-# plugins=<comma separated list of plugins whose classes to trace>
-# packages=<comma separated list of package prefixes of classes to trace>
-# Note that there may be many 'plugins' and 'packages' lines in one file.
-org.eclipse.osgi/trace/filters=trace.properties
-
-# trace bundle activation - snapshot the execution stack when a bundle is activated
-org.eclipse.osgi/trace/activation=false
diff --git a/karaf/shell/dev/src/test/java/org/apache/felix/karaf/shell/dev/framework/EquinoxTest.java b/karaf/shell/dev/src/test/java/org/apache/felix/karaf/shell/dev/framework/EquinoxTest.java
deleted file mode 100644
index 85ea42c..0000000
--- a/karaf/shell/dev/src/test/java/org/apache/felix/karaf/shell/dev/framework/EquinoxTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.dev.framework;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Properties;
-
-import org.apache.felix.karaf.shell.dev.util.IO;
-import static org.junit.Assert.*;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test cases for {@link org.apache.felix.karaf.shell.dev.framework.Equinox}
- */
-public class EquinoxTest {
-
- private File base;
- private File etc;
-
- private Equinox equinox;
-
- @Before
- public void setUp() {
- // creating a dummy karaf instance folder
- base = new File("target/instances/" + System.currentTimeMillis());
- base.mkdirs();
-
- // make sure the etc directory exists
- etc = new File(base, "etc");
- etc.mkdirs();
-
- equinox = new Equinox(base);
- }
-
- @Test
- public void enableDebug() throws IOException {
- IO.copyTextToFile(
- EquinoxTest.class.getResourceAsStream("config.properties"),
- new File(etc, "config.properties"));
-
- equinox.enableDebug(base);
-
- Properties properties = new Properties();
- properties.load(new FileInputStream(new File(base, "etc/config.properties")));
- assertNotNull(properties.get("osgi.debug"));
- assertEquals("etc/equinox-debug.properties", properties.get("osgi.debug"));
-
- assertTrue("Should have created the default Equinox debug config file",
- new File(etc, "equinox-debug.properties").exists());
- }
-
- @Test
- public void testDisableDebug() throws IOException {
- IO.copyTextToFile(
- EquinoxTest.class.getResourceAsStream("enabled-config.properties"),
- new File(etc, "config.properties"));
-
- equinox.disableDebug(base);
-
- Properties properties = new Properties();
- properties.load(new FileInputStream(new File(etc, "config.properties")));
- assertFalse("osgi.debug property should have been removed from the file",
- properties.containsKey("osgi.debug"));
- }
-}
diff --git a/karaf/shell/dev/src/test/java/org/apache/felix/karaf/shell/dev/framework/FelixTest.java b/karaf/shell/dev/src/test/java/org/apache/felix/karaf/shell/dev/framework/FelixTest.java
deleted file mode 100644
index 399777b..0000000
--- a/karaf/shell/dev/src/test/java/org/apache/felix/karaf/shell/dev/framework/FelixTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.dev.framework;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Properties;
-
-import org.apache.felix.karaf.shell.dev.util.IO;
-import static org.junit.Assert.*;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test cases for {@link org.apache.felix.karaf.shell.dev.framework.Felix}
- */
-public class FelixTest {
-
- private File base;
- private File etc;
-
- private Felix felix;
-
- @Before
- public void setUp() {
- // creating a dummy karaf instance folder
- base = new File("target/instances/" + System.currentTimeMillis());
- base.mkdirs();
-
- // make sure the etc directory exists
- etc = new File(base, "etc");
- etc.mkdirs();
-
- felix = new Felix(base);
- }
-
- @Test
- public void enableDebug() throws IOException {
- IO.copyTextToFile(
- FelixTest.class.getResourceAsStream("config.properties"),
- new File(etc, "config.properties"));
-
- felix.enableDebug(base);
-
- Properties properties = new Properties();
- properties.load(new FileInputStream(new File(etc, "config.properties")));
- assertNotNull(properties.get("felix.log.level"));
- assertEquals("4", properties.get("felix.log.level"));
- }
-
- @Test
- public void testDisableDebug() throws IOException {
- IO.copyTextToFile(
- FelixTest.class.getResourceAsStream("enabled-config.properties"),
- new File(etc, "config.properties"));
-
- felix.disableDebug(base);
-
- Properties properties = new Properties();
- properties.load(new FileInputStream(new File(etc, "config.properties")));
- assertFalse(properties.containsKey("felix.log.level"));
- }
-}
diff --git a/karaf/shell/dev/src/test/java/org/apache/felix/karaf/shell/dev/util/BundlesTest.java b/karaf/shell/dev/src/test/java/org/apache/felix/karaf/shell/dev/util/BundlesTest.java
deleted file mode 100644
index 94c28a6..0000000
--- a/karaf/shell/dev/src/test/java/org/apache/felix/karaf/shell/dev/util/BundlesTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy 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.felix.karaf.shell.dev.util;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-
-/**
- * Test cases for {@link org.apache.felix.karaf.shell.dev.util.Bundles}
- */
-public class BundlesTest {
-
- @Test
- public void testToString() {
- assertEquals("UNINSTALLED", Bundles.toString(Bundle.UNINSTALLED));
- assertEquals("INSTALLED", Bundles.toString(Bundle.INSTALLED));
- assertEquals("RESOLVED", Bundles.toString(Bundle.RESOLVED));
- assertEquals("STARTING", Bundles.toString(Bundle.STARTING));
- assertEquals("STOPPING", Bundles.toString(Bundle.STOPPING));
- assertEquals("ACTIVE", Bundles.toString(Bundle.ACTIVE));
- }
-}
diff --git a/karaf/shell/dev/src/test/java/org/apache/felix/karaf/shell/dev/util/ImportTest.java b/karaf/shell/dev/src/test/java/org/apache/felix/karaf/shell/dev/util/ImportTest.java
deleted file mode 100644
index f8edd13..0000000
--- a/karaf/shell/dev/src/test/java/org/apache/felix/karaf/shell/dev/util/ImportTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.dev.util;
-
-import java.util.List;
-
-import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.apache.felix.utils.version.VersionRange;
-import org.junit.Test;
-
-/**
- * Test cases for {@link org.apache.felix.karaf.shell.dev.util.Import}
- */
-public class ImportTest {
-
- @Test
- public void createWithPackageName() {
- Import i = new Import("org.wip.foo");
- assertEquals("org.wip.foo", i.getPackage());
- }
-
- @Test
- public void createWithPackageNameAndVersion() {
- Import i = new Import("org.wip.bar;version=\"2.0.0\"");
- assertEquals("org.wip.bar", i.getPackage());
- assertEquals(VersionRange.parseVersionRange("2.0.0"), i.getVersion());
- }
-
- @Test
- public void createListOfImports() {
- List<Import> imports = Import.parse("org.wip.bar;version=\"2.0.0\",org.wip.foo");
- assertNotNull(imports);
- assertEquals(2, imports.size());
- assertEquals("org.wip.bar", imports.get(0).getPackage());
- assertEquals("org.wip.foo", imports.get(1).getPackage());
- }
-
- @Test
- public void createListOfImportsWithVersionRanges() {
- List<Import> imports =
- Import.parse("javax.activation;version=\"[0.0,2)\",javax.annotation;version=\"[0.0,2)\"");
- assertNotNull(imports);
- assertEquals(2, imports.size());
- assertEquals("javax.activation", imports.get(0).getPackage());
- assertEquals("javax.annotation", imports.get(1).getPackage());
- }
-
- @Test
- public void createListOfImportsWithExports() {
- List<Import> imports = Import.parse("org.wip.bar;version=\"2.0.0\",org.wip.foo", "org.wip.bar;version=\"2.0.0\"");
- assertNotNull(imports);
- assertEquals(1, imports.size());
- assertEquals("org.wip.foo", imports.get(0).getPackage());
- }
-}
diff --git a/karaf/shell/dev/src/test/java/org/apache/felix/karaf/shell/dev/util/TreeTest.java b/karaf/shell/dev/src/test/java/org/apache/felix/karaf/shell/dev/util/TreeTest.java
deleted file mode 100644
index c11e2c3..0000000
--- a/karaf/shell/dev/src/test/java/org/apache/felix/karaf/shell/dev/util/TreeTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.dev.util;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
-
-/**
- * Test cases for {@link org.apache.felix.karaf.shell.dev.util.Tree}
- * and {@link org.apache.felix.karaf.shell.dev.util.Node}
- */
-public class TreeTest {
-
- @Test
- public void writeTreeWithOneChild() throws IOException {
- Tree<String> tree = new Tree<String>("root");
- tree.addChild("child");
-
- BufferedReader reader = read(tree);
-
- assertEquals("root" , reader.readLine());
- assertEquals("+- child" , reader.readLine());
- }
-
- @Test
- public void writeTreeWithOneChildAndNodeConverter() throws IOException {
- Tree<String> tree = new Tree<String>("root");
- tree.addChild("child");
-
- StringWriter writer = new StringWriter();
- tree.write(new PrintWriter(writer), new Tree.Converter<String>() {
- public String toString(Node<String> node) {
- return "my " + node.getValue();
- }
- });
-
- BufferedReader reader = new BufferedReader(new StringReader(writer.getBuffer().toString()));
-
- assertEquals("my root" , reader.readLine());
- assertEquals("+- my child" , reader.readLine());
- }
-
- @Test
- public void writeTreeWithChildAndGrandChild() throws IOException {
- Tree<String> tree = new Tree<String>("root");
- Node<String> node = tree.addChild("child");
- node.addChild("grandchild");
-
- BufferedReader reader = read(tree);
-
- assertEquals("root" , reader.readLine());
- assertEquals("+- child" , reader.readLine());
- assertEquals(" +- grandchild", reader.readLine());
- }
-
- @Test
- public void writeTreeWithTwoChildrenAndOneGrandchild() throws IOException {
- Tree<String> tree = new Tree<String>("root");
- Node<String> child = tree.addChild("child1");
- child.addChild("grandchild");
- tree.addChild("child2");
-
- BufferedReader reader = read(tree);
-
- assertEquals("root" , reader.readLine());
- assertEquals("+- child1" , reader.readLine());
- assertEquals("| +- grandchild", reader.readLine());
- assertEquals("+- child2" , reader.readLine());
- }
-
- @Test
- public void flattenTree() throws IOException {
- Tree<String> tree = new Tree<String>("root");
- Node<String> child1 = tree.addChild("child1");
- child1.addChild("grandchild");
- Node child2 = tree.addChild("child2");
- child2.addChild("grandchild");
-
- Set<String> elements = tree.flatten();
- assertNotNull(elements);
- assertEquals(4, elements.size());
- assertTrue(elements.contains("root"));
- assertTrue(elements.contains("child1"));
- assertTrue(elements.contains("child2"));
- assertTrue(elements.contains("grandchild"));
- }
-
- @Test
- public void hasAncestor() throws IOException {
- Tree<String> tree = new Tree<String>("root");
- Node<String> child1 = tree.addChild("child1");
- child1.addChild("grandchild");
- Node child2 = tree.addChild("child2");
- Node node = child2.addChild("grandchild2");
-
- assertTrue(node.hasAncestor("child2"));
- assertTrue(node.hasAncestor("root"));
- assertFalse(node.hasAncestor("child1"));
- }
-
- private BufferedReader read(Tree<String> tree) {
- StringWriter writer = new StringWriter();
- tree.write(new PrintWriter(writer));
-
- BufferedReader reader = new BufferedReader(new StringReader(writer.getBuffer().toString()));
- return reader;
- }
-}
diff --git a/karaf/shell/dev/src/test/resources/org/apache/felix/karaf/shell/dev/framework/config.properties b/karaf/shell/dev/src/test/resources/org/apache/felix/karaf/shell/dev/framework/config.properties
deleted file mode 100644
index 5cc8009..0000000
--- a/karaf/shell/dev/src/test/resources/org/apache/felix/karaf/shell/dev/framework/config.properties
+++ /dev/null
@@ -1,351 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-#
-# Framework selection properties
-#
-karaf.framework=felix
-
-karaf.framework.equinox=${karaf.default.repository}/org/eclipse/osgi/${equinox.version}/osgi-${equinox.version}.jar
-karaf.framework.felix=${karaf.default.repository}/org/apache/felix/org.apache.felix.framework/${felix.framework.version}/org.apache.felix.framework-${felix.framework.version}.jar
-
-#
-# Framework config properties.
-#
-org.osgi.framework.system.packages=org.osgi.framework; version=1.5.0, \
- org.osgi.framework.launch; version=1.0.0, \
- org.osgi.framework.hooks.service; version=1.0.0, \
- org.osgi.service.packageadmin; version=1.2.0, \
- org.osgi.service.startlevel; version=1.1.0, \
- org.osgi.service.url; version=1.0.0, \
- org.osgi.util.tracker; version=1.4.0 \
- ${jre-${java.specification.version}}
-
-org.osgi.framework.system.packages.extra=\
- org.apache.felix.karaf.jaas.boot; version=${karaf.osgi.version}, \
- org.apache.felix.karaf.version; version=${karaf.osgi.version}
-
-# javax.transaction is needed to avoid class loader constraint violation when using javax.sql
-org.osgi.framework.bootdelegation=sun.*,com.sun.*,javax.transaction,javax.transaction.*
-
-# To enable the use of the startup.properties file to control the start level:
-karaf.auto.start=startup.properties
-#felix.auto.start=all
-
-org.osgi.framework.startlevel.beginning=100
-karaf.startlevel.bundle=60
-
-#
-# FileMonitor properties
-#
-felix.fileinstall.dir = ${karaf.base}/etc
-felix.fileinstall.filter = .*\\.cfg
-felix.fileinstall.poll = 1000
-felix.fileinstall.noInitialDelay = true
-
-#
-# Java platform package export properties.
-#
-
-# Standard package set. Note that:
-# - javax.transaction* is exported with a mandatory attribute
-jre-1.5=, \
- javax.accessibility, \
- javax.activity, \
- javax.crypto, \
- javax.crypto.interfaces, \
- javax.crypto.spec, \
- javax.imageio, \
- javax.imageio.event, \
- javax.imageio.metadata, \
- javax.imageio.plugins.bmp, \
- javax.imageio.plugins.jpeg, \
- javax.imageio.spi, \
- javax.imageio.stream, \
- javax.management, \
- javax.management.loading, \
- javax.management.modelmbean, \
- javax.management.monitor, \
- javax.management.openmbean, \
- javax.management.relation, \
- javax.management.remote, \
- javax.management.remote.rmi, \
- javax.management.timer, \
- javax.naming, \
- javax.naming.directory, \
- javax.naming.event, \
- javax.naming.ldap, \
- javax.naming.spi, \
- javax.net, \
- javax.net.ssl, \
- javax.print, \
- javax.print.attribute, \
- javax.print.attribute.standard, \
- javax.print.event, \
- javax.rmi, \
- javax.rmi.CORBA, \
- javax.rmi.ssl, \
- javax.security.auth, \
- javax.security.auth.callback, \
- javax.security.auth.kerberos, \
- javax.security.auth.login, \
- javax.security.auth.spi, \
- javax.security.auth.x500, \
- javax.security.cert, \
- javax.security.sasl, \
- javax.sound.midi, \
- javax.sound.midi.spi, \
- javax.sound.sampled, \
- javax.sound.sampled.spi, \
- javax.sql, \
- javax.sql.rowset, \
- javax.sql.rowset.serial, \
- javax.sql.rowset.spi, \
- javax.swing, \
- javax.swing.border, \
- javax.swing.colorchooser, \
- javax.swing.event, \
- javax.swing.filechooser, \
- javax.swing.plaf, \
- javax.swing.plaf.basic, \
- javax.swing.plaf.metal, \
- javax.swing.plaf.multi, \
- javax.swing.plaf.synth, \
- javax.swing.table, \
- javax.swing.text, \
- javax.swing.text.html, \
- javax.swing.text.html.parser, \
- javax.swing.text.rtf, \
- javax.swing.tree, \
- javax.swing.undo, \
- javax.transaction; javax.transaction.xa; partial=true; mandatory:=partial, \
- javax.xml, \
- javax.xml.datatype, \
- javax.xml.namespace, \
- javax.xml.parsers, \
- javax.xml.transform, \
- javax.xml.transform.dom, \
- javax.xml.transform.sax, \
- javax.xml.transform.stream, \
- javax.xml.validation, \
- javax.xml.xpath, \
- org.ietf.jgss, \
- org.omg.CORBA, \
- org.omg.CORBA_2_3, \
- org.omg.CORBA_2_3.portable, \
- org.omg.CORBA.DynAnyPackage, \
- org.omg.CORBA.ORBPackage, \
- org.omg.CORBA.portable, \
- org.omg.CORBA.TypeCodePackage, \
- org.omg.CosNaming, \
- org.omg.CosNaming.NamingContextExtPackage, \
- org.omg.CosNaming.NamingContextPackage, \
- org.omg.Dynamic, \
- org.omg.DynamicAny, \
- org.omg.DynamicAny.DynAnyFactoryPackage, \
- org.omg.DynamicAny.DynAnyPackage, \
- org.omg.IOP, \
- org.omg.IOP.CodecFactoryPackage, \
- org.omg.IOP.CodecPackage, \
- org.omg.Messaging, \
- org.omg.PortableInterceptor, \
- org.omg.PortableInterceptor.ORBInitInfoPackage, \
- org.omg.PortableServer, \
- org.omg.PortableServer.CurrentPackage, \
- org.omg.PortableServer.POAManagerPackage, \
- org.omg.PortableServer.POAPackage, \
- org.omg.PortableServer.portable, \
- org.omg.PortableServer.ServantLocatorPackage, \
- org.omg.SendingContext, \
- org.omg.stub.java.rmi, \
- org.omg.stub.javax.management.remote.rmi, \
- org.w3c.dom, \
- org.w3c.dom.bootstrap, \
- org.w3c.dom.css, \
- org.w3c.dom.events, \
- org.w3c.dom.html, \
- org.w3c.dom.ls, \
- org.w3c.dom.ranges, \
- org.w3c.dom.stylesheets, \
- org.w3c.dom.traversal, \
- org.w3c.dom.views, \
- org.xml.sax, \
- org.xml.sax.ext, \
- org.xml.sax.helpers
-
-# Standard package set. Note that:
-# - javax.transaction* is exported with a mandatory attribute
-jre-1.6=, \
- javax.accessibility, \
- javax.activation, \
- javax.activity, \
- javax.annotation, \
- javax.annotation.processing, \
- javax.crypto, \
- javax.crypto.interfaces, \
- javax.crypto.spec, \
- javax.imageio, \
- javax.imageio.event, \
- javax.imageio.metadata, \
- javax.imageio.plugins.bmp, \
- javax.imageio.plugins.jpeg, \
- javax.imageio.spi, \
- javax.imageio.stream, \
- javax.jws, \
- javax.jws.soap, \
- javax.lang.model, \
- javax.lang.model.element, \
- javax.lang.model.type, \
- javax.lang.model.util, \
- javax.management, \
- javax.management.loading, \
- javax.management.modelmbean, \
- javax.management.monitor, \
- javax.management.openmbean, \
- javax.management.relation, \
- javax.management.remote, \
- javax.management.remote.rmi, \
- javax.management.timer, \
- javax.naming, \
- javax.naming.directory, \
- javax.naming.event, \
- javax.naming.ldap, \
- javax.naming.spi, \
- javax.net, \
- javax.net.ssl, \
- javax.print, \
- javax.print.attribute, \
- javax.print.attribute.standard, \
- javax.print.event, \
- javax.rmi, \
- javax.rmi.CORBA, \
- javax.rmi.ssl, \
- javax.script, \
- javax.security.auth, \
- javax.security.auth.callback, \
- javax.security.auth.kerberos, \
- javax.security.auth.login, \
- javax.security.auth.spi, \
- javax.security.auth.x500, \
- javax.security.cert, \
- javax.security.sasl, \
- javax.sound.midi, \
- javax.sound.midi.spi, \
- javax.sound.sampled, \
- javax.sound.sampled.spi, \
- javax.sql, \
- javax.sql.rowset, \
- javax.sql.rowset.serial, \
- javax.sql.rowset.spi, \
- javax.swing, \
- javax.swing.border, \
- javax.swing.colorchooser, \
- javax.swing.event, \
- javax.swing.filechooser, \
- javax.swing.plaf, \
- javax.swing.plaf.basic, \
- javax.swing.plaf.metal, \
- javax.swing.plaf.multi, \
- javax.swing.plaf.synth, \
- javax.swing.table, \
- javax.swing.text, \
- javax.swing.text.html, \
- javax.swing.text.html.parser, \
- javax.swing.text.rtf, \
- javax.swing.tree, \
- javax.swing.undo, \
- javax.tools, \
- javax.transaction; javax.transaction.xa; partial=true; mandatory:=partial, \
- javax.xml, \
- javax.xml.bind, \
- javax.xml.bind.annotation, \
- javax.xml.bind.annotation.adapters, \
- javax.xml.bind.attachment, \
- javax.xml.bind.helpers, \
- javax.xml.bind.util, \
- javax.xml.crypto, \
- javax.xml.crypto.dom, \
- javax.xml.crypto.dsig, \
- javax.xml.crypto.dsig.dom, \
- javax.xml.crypto.dsig.keyinfo, \
- javax.xml.crypto.dsig.spec, \
- javax.xml.datatype, \
- javax.xml.namespace, \
- javax.xml.parsers, \
- javax.xml.soap, \
- javax.xml.stream, \
- javax.xml.stream.events, \
- javax.xml.stream.util, \
- javax.xml.transform, \
- javax.xml.transform.dom, \
- javax.xml.transform.sax, \
- javax.xml.transform.stax, \
- javax.xml.transform.stream, \
- javax.xml.validation, \
- javax.xml.ws, \
- javax.xml.ws.handler, \
- javax.xml.ws.handler.soap, \
- javax.xml.ws.http, \
- javax.xml.ws.soap, \
- javax.xml.ws.spi, \
- javax.xml.xpath, \
- org.ietf.jgss, \
- org.omg.CORBA, \
- org.omg.CORBA_2_3, \
- org.omg.CORBA_2_3.portable, \
- org.omg.CORBA.DynAnyPackage, \
- org.omg.CORBA.ORBPackage, \
- org.omg.CORBA.portable, \
- org.omg.CORBA.TypeCodePackage, \
- org.omg.CosNaming, \
- org.omg.CosNaming.NamingContextExtPackage, \
- org.omg.CosNaming.NamingContextPackage, \
- org.omg.Dynamic, \
- org.omg.DynamicAny, \
- org.omg.DynamicAny.DynAnyFactoryPackage, \
- org.omg.DynamicAny.DynAnyPackage, \
- org.omg.IOP, \
- org.omg.IOP.CodecFactoryPackage, \
- org.omg.IOP.CodecPackage, \
- org.omg.Messaging, \
- org.omg.PortableInterceptor, \
- org.omg.PortableInterceptor.ORBInitInfoPackage, \
- org.omg.PortableServer, \
- org.omg.PortableServer.CurrentPackage, \
- org.omg.PortableServer.POAManagerPackage, \
- org.omg.PortableServer.POAPackage, \
- org.omg.PortableServer.portable, \
- org.omg.PortableServer.ServantLocatorPackage, \
- org.omg.SendingContext, \
- org.omg.stub.java.rmi, \
- org.omg.stub.javax.management.remote.rmi, \
- org.w3c.dom, \
- org.w3c.dom.bootstrap, \
- org.w3c.dom.css, \
- org.w3c.dom.events, \
- org.w3c.dom.html, \
- org.w3c.dom.ls, \
- org.w3c.dom.ranges, \
- org.w3c.dom.stylesheets, \
- org.w3c.dom.traversal, \
- org.w3c.dom.views, \
- org.w3c.dom.xpath, \
- org.xml.sax, \
- org.xml.sax.ext, \
- org.xml.sax.helpers
diff --git a/karaf/shell/dev/src/test/resources/org/apache/felix/karaf/shell/dev/framework/enabled-config.properties b/karaf/shell/dev/src/test/resources/org/apache/felix/karaf/shell/dev/framework/enabled-config.properties
deleted file mode 100644
index 53c4eca..0000000
--- a/karaf/shell/dev/src/test/resources/org/apache/felix/karaf/shell/dev/framework/enabled-config.properties
+++ /dev/null
@@ -1,355 +0,0 @@
-################################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-################################################################################
-
-#
-# Framework selection properties
-#
-karaf.framework=felix
-
-karaf.framework.equinox=${karaf.default.repository}/org/eclipse/osgi/${equinox.version}/osgi-${equinox.version}.jar
-karaf.framework.felix=${karaf.default.repository}/org/apache/felix/org.apache.felix.framework/${felix.framework.version}/org.apache.felix.framework-${felix.framework.version}.jar
-
-# Here are the properties to enable debugging
-felix.log.level=4
-osgi.debug=etc/equinox-debug.properties
-
-#
-# Framework config properties.
-#
-org.osgi.framework.system.packages=org.osgi.framework; version=1.5.0, \
- org.osgi.framework.launch; version=1.0.0, \
- org.osgi.framework.hooks.service; version=1.0.0, \
- org.osgi.service.packageadmin; version=1.2.0, \
- org.osgi.service.startlevel; version=1.1.0, \
- org.osgi.service.url; version=1.0.0, \
- org.osgi.util.tracker; version=1.4.0 \
- ${jre-${java.specification.version}}
-
-org.osgi.framework.system.packages.extra=\
- org.apache.felix.karaf.jaas.boot; version=${karaf.osgi.version}, \
- org.apache.felix.karaf.version; version=${karaf.osgi.version}
-
-# javax.transaction is needed to avoid class loader constraint violation when using javax.sql
-org.osgi.framework.bootdelegation=sun.*,com.sun.*,javax.transaction,javax.transaction.*
-
-# To enable the use of the startup.properties file to control the start level:
-karaf.auto.start=startup.properties
-#felix.auto.start=all
-
-org.osgi.framework.startlevel.beginning=100
-karaf.startlevel.bundle=60
-
-#
-# FileMonitor properties
-#
-felix.fileinstall.dir = ${karaf.base}/etc
-felix.fileinstall.filter = .*\\.cfg
-felix.fileinstall.poll = 1000
-felix.fileinstall.noInitialDelay = true
-
-#
-# Java platform package export properties.
-#
-
-# Standard package set. Note that:
-# - javax.transaction* is exported with a mandatory attribute
-jre-1.5=, \
- javax.accessibility, \
- javax.activity, \
- javax.crypto, \
- javax.crypto.interfaces, \
- javax.crypto.spec, \
- javax.imageio, \
- javax.imageio.event, \
- javax.imageio.metadata, \
- javax.imageio.plugins.bmp, \
- javax.imageio.plugins.jpeg, \
- javax.imageio.spi, \
- javax.imageio.stream, \
- javax.management, \
- javax.management.loading, \
- javax.management.modelmbean, \
- javax.management.monitor, \
- javax.management.openmbean, \
- javax.management.relation, \
- javax.management.remote, \
- javax.management.remote.rmi, \
- javax.management.timer, \
- javax.naming, \
- javax.naming.directory, \
- javax.naming.event, \
- javax.naming.ldap, \
- javax.naming.spi, \
- javax.net, \
- javax.net.ssl, \
- javax.print, \
- javax.print.attribute, \
- javax.print.attribute.standard, \
- javax.print.event, \
- javax.rmi, \
- javax.rmi.CORBA, \
- javax.rmi.ssl, \
- javax.security.auth, \
- javax.security.auth.callback, \
- javax.security.auth.kerberos, \
- javax.security.auth.login, \
- javax.security.auth.spi, \
- javax.security.auth.x500, \
- javax.security.cert, \
- javax.security.sasl, \
- javax.sound.midi, \
- javax.sound.midi.spi, \
- javax.sound.sampled, \
- javax.sound.sampled.spi, \
- javax.sql, \
- javax.sql.rowset, \
- javax.sql.rowset.serial, \
- javax.sql.rowset.spi, \
- javax.swing, \
- javax.swing.border, \
- javax.swing.colorchooser, \
- javax.swing.event, \
- javax.swing.filechooser, \
- javax.swing.plaf, \
- javax.swing.plaf.basic, \
- javax.swing.plaf.metal, \
- javax.swing.plaf.multi, \
- javax.swing.plaf.synth, \
- javax.swing.table, \
- javax.swing.text, \
- javax.swing.text.html, \
- javax.swing.text.html.parser, \
- javax.swing.text.rtf, \
- javax.swing.tree, \
- javax.swing.undo, \
- javax.transaction; javax.transaction.xa; partial=true; mandatory:=partial, \
- javax.xml, \
- javax.xml.datatype, \
- javax.xml.namespace, \
- javax.xml.parsers, \
- javax.xml.transform, \
- javax.xml.transform.dom, \
- javax.xml.transform.sax, \
- javax.xml.transform.stream, \
- javax.xml.validation, \
- javax.xml.xpath, \
- org.ietf.jgss, \
- org.omg.CORBA, \
- org.omg.CORBA_2_3, \
- org.omg.CORBA_2_3.portable, \
- org.omg.CORBA.DynAnyPackage, \
- org.omg.CORBA.ORBPackage, \
- org.omg.CORBA.portable, \
- org.omg.CORBA.TypeCodePackage, \
- org.omg.CosNaming, \
- org.omg.CosNaming.NamingContextExtPackage, \
- org.omg.CosNaming.NamingContextPackage, \
- org.omg.Dynamic, \
- org.omg.DynamicAny, \
- org.omg.DynamicAny.DynAnyFactoryPackage, \
- org.omg.DynamicAny.DynAnyPackage, \
- org.omg.IOP, \
- org.omg.IOP.CodecFactoryPackage, \
- org.omg.IOP.CodecPackage, \
- org.omg.Messaging, \
- org.omg.PortableInterceptor, \
- org.omg.PortableInterceptor.ORBInitInfoPackage, \
- org.omg.PortableServer, \
- org.omg.PortableServer.CurrentPackage, \
- org.omg.PortableServer.POAManagerPackage, \
- org.omg.PortableServer.POAPackage, \
- org.omg.PortableServer.portable, \
- org.omg.PortableServer.ServantLocatorPackage, \
- org.omg.SendingContext, \
- org.omg.stub.java.rmi, \
- org.omg.stub.javax.management.remote.rmi, \
- org.w3c.dom, \
- org.w3c.dom.bootstrap, \
- org.w3c.dom.css, \
- org.w3c.dom.events, \
- org.w3c.dom.html, \
- org.w3c.dom.ls, \
- org.w3c.dom.ranges, \
- org.w3c.dom.stylesheets, \
- org.w3c.dom.traversal, \
- org.w3c.dom.views, \
- org.xml.sax, \
- org.xml.sax.ext, \
- org.xml.sax.helpers
-
-# Standard package set. Note that:
-# - javax.transaction* is exported with a mandatory attribute
-jre-1.6=, \
- javax.accessibility, \
- javax.activation, \
- javax.activity, \
- javax.annotation, \
- javax.annotation.processing, \
- javax.crypto, \
- javax.crypto.interfaces, \
- javax.crypto.spec, \
- javax.imageio, \
- javax.imageio.event, \
- javax.imageio.metadata, \
- javax.imageio.plugins.bmp, \
- javax.imageio.plugins.jpeg, \
- javax.imageio.spi, \
- javax.imageio.stream, \
- javax.jws, \
- javax.jws.soap, \
- javax.lang.model, \
- javax.lang.model.element, \
- javax.lang.model.type, \
- javax.lang.model.util, \
- javax.management, \
- javax.management.loading, \
- javax.management.modelmbean, \
- javax.management.monitor, \
- javax.management.openmbean, \
- javax.management.relation, \
- javax.management.remote, \
- javax.management.remote.rmi, \
- javax.management.timer, \
- javax.naming, \
- javax.naming.directory, \
- javax.naming.event, \
- javax.naming.ldap, \
- javax.naming.spi, \
- javax.net, \
- javax.net.ssl, \
- javax.print, \
- javax.print.attribute, \
- javax.print.attribute.standard, \
- javax.print.event, \
- javax.rmi, \
- javax.rmi.CORBA, \
- javax.rmi.ssl, \
- javax.script, \
- javax.security.auth, \
- javax.security.auth.callback, \
- javax.security.auth.kerberos, \
- javax.security.auth.login, \
- javax.security.auth.spi, \
- javax.security.auth.x500, \
- javax.security.cert, \
- javax.security.sasl, \
- javax.sound.midi, \
- javax.sound.midi.spi, \
- javax.sound.sampled, \
- javax.sound.sampled.spi, \
- javax.sql, \
- javax.sql.rowset, \
- javax.sql.rowset.serial, \
- javax.sql.rowset.spi, \
- javax.swing, \
- javax.swing.border, \
- javax.swing.colorchooser, \
- javax.swing.event, \
- javax.swing.filechooser, \
- javax.swing.plaf, \
- javax.swing.plaf.basic, \
- javax.swing.plaf.metal, \
- javax.swing.plaf.multi, \
- javax.swing.plaf.synth, \
- javax.swing.table, \
- javax.swing.text, \
- javax.swing.text.html, \
- javax.swing.text.html.parser, \
- javax.swing.text.rtf, \
- javax.swing.tree, \
- javax.swing.undo, \
- javax.tools, \
- javax.transaction; javax.transaction.xa; partial=true; mandatory:=partial, \
- javax.xml, \
- javax.xml.bind, \
- javax.xml.bind.annotation, \
- javax.xml.bind.annotation.adapters, \
- javax.xml.bind.attachment, \
- javax.xml.bind.helpers, \
- javax.xml.bind.util, \
- javax.xml.crypto, \
- javax.xml.crypto.dom, \
- javax.xml.crypto.dsig, \
- javax.xml.crypto.dsig.dom, \
- javax.xml.crypto.dsig.keyinfo, \
- javax.xml.crypto.dsig.spec, \
- javax.xml.datatype, \
- javax.xml.namespace, \
- javax.xml.parsers, \
- javax.xml.soap, \
- javax.xml.stream, \
- javax.xml.stream.events, \
- javax.xml.stream.util, \
- javax.xml.transform, \
- javax.xml.transform.dom, \
- javax.xml.transform.sax, \
- javax.xml.transform.stax, \
- javax.xml.transform.stream, \
- javax.xml.validation, \
- javax.xml.ws, \
- javax.xml.ws.handler, \
- javax.xml.ws.handler.soap, \
- javax.xml.ws.http, \
- javax.xml.ws.soap, \
- javax.xml.ws.spi, \
- javax.xml.xpath, \
- org.ietf.jgss, \
- org.omg.CORBA, \
- org.omg.CORBA_2_3, \
- org.omg.CORBA_2_3.portable, \
- org.omg.CORBA.DynAnyPackage, \
- org.omg.CORBA.ORBPackage, \
- org.omg.CORBA.portable, \
- org.omg.CORBA.TypeCodePackage, \
- org.omg.CosNaming, \
- org.omg.CosNaming.NamingContextExtPackage, \
- org.omg.CosNaming.NamingContextPackage, \
- org.omg.Dynamic, \
- org.omg.DynamicAny, \
- org.omg.DynamicAny.DynAnyFactoryPackage, \
- org.omg.DynamicAny.DynAnyPackage, \
- org.omg.IOP, \
- org.omg.IOP.CodecFactoryPackage, \
- org.omg.IOP.CodecPackage, \
- org.omg.Messaging, \
- org.omg.PortableInterceptor, \
- org.omg.PortableInterceptor.ORBInitInfoPackage, \
- org.omg.PortableServer, \
- org.omg.PortableServer.CurrentPackage, \
- org.omg.PortableServer.POAManagerPackage, \
- org.omg.PortableServer.POAPackage, \
- org.omg.PortableServer.portable, \
- org.omg.PortableServer.ServantLocatorPackage, \
- org.omg.SendingContext, \
- org.omg.stub.java.rmi, \
- org.omg.stub.javax.management.remote.rmi, \
- org.w3c.dom, \
- org.w3c.dom.bootstrap, \
- org.w3c.dom.css, \
- org.w3c.dom.events, \
- org.w3c.dom.html, \
- org.w3c.dom.ls, \
- org.w3c.dom.ranges, \
- org.w3c.dom.stylesheets, \
- org.w3c.dom.traversal, \
- org.w3c.dom.views, \
- org.w3c.dom.xpath, \
- org.xml.sax, \
- org.xml.sax.ext, \
- org.xml.sax.helpers
diff --git a/karaf/shell/log/NOTICE b/karaf/shell/log/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/shell/log/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/shell/log/pom.xml b/karaf/shell/log/pom.xml
deleted file mode 100644
index 00663b0..0000000
--- a/karaf/shell/log/pom.xml
+++ /dev/null
@@ -1,97 +0,0 @@
-<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/maven-v4_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.felix.karaf.shell</groupId>
- <artifactId>shell</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.log</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Shell Log Commands</name>
-
- <description>
- Provides the OSGi Log commands
- </description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.ops4j.pax.logging</groupId>
- <artifactId>pax-logging-service</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.ops4j.pax.logging</groupId>
- <artifactId>pax-logging-api</artifactId>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Import-Package>
- !${project.artifactId}*,
- org.osgi.service.command,
- org.apache.felix.gogo.commands,
- org.apache.felix.karaf.shell.console,
- *
- </Import-Package>
- <Private-Package>!*</Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/DisplayException.java b/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/DisplayException.java
deleted file mode 100644
index 314adca..0000000
--- a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/DisplayException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.log;
-
-import org.ops4j.pax.logging.spi.PaxLoggingEvent;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "log", name = "display-exception", description = "Displays the last occured exception from the log.")
-public class DisplayException extends OsgiCommandSupport {
-
- protected LruList events;
-
- public LruList getEvents() {
- return events;
- }
-
- public void setEvents(LruList events) {
- this.events = events;
- }
-
- protected Object doExecute() throws Exception {
- PaxLoggingEvent throwableEvent = null;
- Iterable<PaxLoggingEvent> le = events.getElements(Integer.MAX_VALUE);
- for (PaxLoggingEvent event : le) {
- if (event.getThrowableStrRep() != null) {
- throwableEvent = event;
- // Do not break, as we iterate from the oldest to the newest event
- }
- }
- if (throwableEvent != null) {
- for (String r : throwableEvent.getThrowableStrRep()) {
- System.out.println(r);
- }
- System.out.println();
- }
- return null;
- }
-
-}
diff --git a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/DisplayLog.java b/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/DisplayLog.java
deleted file mode 100644
index ee62ef7..0000000
--- a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/DisplayLog.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.log;
-
-import org.apache.felix.karaf.shell.log.layout.PatternConverter;
-import org.apache.felix.karaf.shell.log.layout.PatternParser;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Command;
-import org.ops4j.pax.logging.spi.PaxLoggingEvent;
-
-/**
- * Displays the last log entries
- */
-@Command(scope = "log", name = "display", description = "Displays log entries.")
-public class DisplayLog extends OsgiCommandSupport {
-
- @Option(name = "-n", aliases = {}, description="Number of entries to display", required = false, multiValued = false)
- protected int entries;
-
- @Option(name = "-p", aliases = {}, description="Pattern for formatting the output", required = false, multiValued = false)
- protected String overridenPattern;
-
- protected String pattern;
- protected LruList events;
-
- public LruList getEvents() {
- return events;
- }
-
- public void setEvents(LruList events) {
- this.events = events;
- }
-
- public String getPattern() {
- return pattern;
- }
-
- public void setPattern(String pattern) {
- this.pattern = pattern;
- }
-
- protected Object doExecute() throws Exception {
- PatternConverter cnv = new PatternParser(overridenPattern != null ? overridenPattern : pattern).parse();
-
- Iterable<PaxLoggingEvent> le = events.getElements(entries == 0 ? Integer.MAX_VALUE : entries);
- StringBuffer sb = new StringBuffer();
- for (PaxLoggingEvent event : le) {
- sb.setLength(0);
- for (PatternConverter pc = cnv; pc != null; pc = pc.next) {
- pc.format(sb, event);
- }
- System.out.print(sb.toString());
- if (event.getThrowableStrRep() != null) {
- for (String r : event.getThrowableStrRep()) {
- System.out.println(r);
- }
- }
- }
- System.out.println();
-
- return null;
- }
-
-}
diff --git a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/GetLogLevel.java b/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/GetLogLevel.java
deleted file mode 100644
index 618affe..0000000
--- a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/GetLogLevel.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.log;
-
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-/**
- * Get the log level for a given logger
- */
-@Command(scope = "log", name = "get", description = "Shows the currently set log level.")
-public class GetLogLevel extends OsgiCommandSupport {
-
- @Argument(index = 0, name = "logger", description = "The name of the logger, ALL or ROOT (default)", required = false, multiValued = false)
- String logger;
-
- static final String CONFIGURATION_PID = "org.ops4j.pax.logging";
- static final String ROOT_LOGGER_PREFIX = "log4j.rootLogger";
- static final String LOGGER_PREFIX = "log4j.logger.";
- static final String ALL_LOGGER = "ALL";
- static final String ROOT_LOGGER = "ROOT";
-
- protected Object doExecute() throws Exception {
- ConfigurationAdmin cfgAdmin = getConfigAdmin();
- Configuration cfg = cfgAdmin.getConfiguration(CONFIGURATION_PID, null);
- Dictionary props = cfg.getProperties();
-
- if (ROOT_LOGGER.equalsIgnoreCase(this.logger)) {
- this.logger = null;
- }
- if (ALL_LOGGER.equalsIgnoreCase(logger)) {
- String root = getLevel((String) props.get(ROOT_LOGGER_PREFIX));
- Map<String, String> loggers = new TreeMap<String, String>();
- for (Enumeration e = props.keys(); e.hasMoreElements();) {
- String prop = (String) e.nextElement();
- if (prop.startsWith(LOGGER_PREFIX)) {
- String val = getLevel((String) props.get(prop));
- loggers.put(prop.substring(LOGGER_PREFIX.length()), val);
- }
- }
- System.out.println("ROOT: " + root);
- for (String logger : loggers.keySet()) {
- System.out.println(logger + ": " + loggers.get(logger));
- }
- } else {
- String logger = this.logger;
- String val;
- for (;;) {
- String prop;
- if (logger == null) {
- prop = ROOT_LOGGER_PREFIX;
- } else {
- prop = LOGGER_PREFIX + logger;
- }
- val = (String) props.get(prop);
- val = getLevel(val);
- if (val != null || logger == null) {
- break;
- }
- int idx = logger.lastIndexOf('.');
- if (idx < 0) {
- logger = null;
- } else {
- logger = logger.substring(0, idx);
- }
- }
- String st = "Level: " + val;
- if (logger != this.logger) {
- st += " (inherited from " + (logger != null ? logger : "ROOT") + ")";
- }
- System.out.println(st);
- }
- return null;
- }
-
- protected String getLevel(String prop) {
- if (prop == null) {
- return null;
- } else {
- String val = prop.trim();
- int idx = val.indexOf(",");
- if (idx == 0) {
- val = null;
- } else if (idx > 0) {
- val = val.substring(0, idx);
- }
- return val;
- }
- }
-
- protected ConfigurationAdmin getConfigAdmin() {
- ServiceReference ref = getBundleContext().getServiceReference(ConfigurationAdmin.class.getName());
- return getService(ConfigurationAdmin.class, ref);
- }
-
-}
diff --git a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/Level.java b/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/Level.java
deleted file mode 100644
index b3192d1..0000000
--- a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/Level.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.log;
-
-/**
- * Enumeration of available log levels for the log:set command and
- * the command completer
- */
-public enum Level {
-
- TRACE,
- DEBUG,
- INFO,
- WARN,
- ERROR,
- DEFAULT;
-
- /**
- * Convert the list of values into a String array
- *
- * @return all the values as a String array
- */
- public static String[] strings() {
- String[] values = new String[values().length];
- for (int i = 0 ; i < values.length ; i++) {
- values[i] = values()[i].name();
- }
- return values;
- }
-
- /**
- * Check if the string value represents the default level
- *
- * @param level the level value
- * @return <code>true</code> if the value represents the {@link #DEFAULT} level
- */
- public static boolean isDefault(String level) {
- return valueOf(level).equals(DEFAULT);
- }
-}
diff --git a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/LruList.java b/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/LruList.java
deleted file mode 100644
index dacf244..0000000
--- a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/LruList.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.log;
-
-import java.util.Arrays;
-
-import org.ops4j.pax.logging.spi.PaxLoggingEvent;
-
-/**
- * A list that only keep the last N elements added
- */
-public class LruList {
-
- private PaxLoggingEvent[] elements;
- private transient int start = 0;
- private transient int end = 0;
- private transient boolean full = false;
- private final int maxElements;
-
- public LruList(int size) {
- if (size <= 0) {
- throw new IllegalArgumentException("The size must be greater than 0");
- }
- elements = new PaxLoggingEvent[size];
- maxElements = elements.length;
- }
-
- public int size() {
- synchronized (elements) {
- int size = 0;
- if (end < start) {
- size = maxElements - start + end;
- } else if (end == start) {
- size = (full ? maxElements : 0);
- } else {
- size = end - start;
- }
- return size;
- }
- }
-
- public void add(PaxLoggingEvent element) {
- synchronized (elements) {
- if (null == element) {
- throw new NullPointerException("Attempted to add null object to buffer");
- }
- if (size() == maxElements) {
- Object e = elements[start];
- if (null != e) {
- elements[start++] = null;
- if (start >= maxElements) {
- start = 0;
- }
- full = false;
- }
- }
- elements[end++] = element;
- if (end >= maxElements) {
- end = 0;
- }
- if (end == start) {
- full = true;
- }
- }
- }
-
- public Iterable<PaxLoggingEvent> getElements() {
- synchronized (elements) {
- return getElements(size());
- }
- }
-
- public Iterable<PaxLoggingEvent> getElements(int nb) {
- synchronized (elements) {
- int s = size();
- nb = Math.min(Math.max(0, nb), s);
- PaxLoggingEvent[] e = new PaxLoggingEvent[nb];
- for (int i = 0; i < nb; i++) {
- e[i] = elements[(i + s - nb + start) % maxElements];
- }
- return Arrays.asList(e);
- }
- }
-
-}
diff --git a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/SetLogLevel.java b/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/SetLogLevel.java
deleted file mode 100644
index 7a41d4c..0000000
--- a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/SetLogLevel.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.log;
-
-import java.io.IOException;
-import java.util.Dictionary;
-
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-
-/**
- * Set the log level for a given logger
- */
-@Command(scope = "log", name = "set", description = "Sets the log level.")
-public class SetLogLevel extends OsgiCommandSupport {
-
- @Argument(index = 0, name = "level", description = "The log level to set (TRACE, DEBUG, INFO, WARN, ERROR) or DEFAULT to unset", required = true, multiValued = false)
- String level;
-
- @Argument(index = 1, name = "logger", description = "Logger name or ROOT (default)", required = false, multiValued = false)
- String logger;
-
- static final String CONFIGURATION_PID = "org.ops4j.pax.logging";
- static final String ROOT_LOGGER_PREFIX = "log4j.rootLogger";
- static final String LOGGER_PREFIX = "log4j.logger.";
- static final String ROOT_LOGGER = "ROOT";
-
- protected Object doExecute() throws Exception {
- if (ROOT_LOGGER.equalsIgnoreCase(this.logger)) {
- this.logger = null;
- }
-
- // make sure both uppercase and lowercase levels are supported
- level = level.toUpperCase();
-
- try {
- Level.valueOf(level);
- } catch (IllegalArgumentException e) {
- System.err.println("level must be set to TRACE, DEBUG, INFO, WARN or ERROR (or DEFAULT to unset it)");
- return null;
- }
-
- if (Level.isDefault(level) && logger == null) {
- System.err.println("Can not unset the ROOT logger");
- return null;
- }
-
- Configuration cfg = getConfiguration();
- Dictionary props = cfg.getProperties();
-
- String logger = this.logger;
- String val;
- String prop;
- if (logger == null) {
- prop = ROOT_LOGGER_PREFIX;
- } else {
- prop = LOGGER_PREFIX + logger;
- }
- val = (String) props.get(prop);
- if (Level.isDefault(level)) {
- if (val != null) {
- val = val.trim();
- int idx = val.indexOf(",");
- if (idx < 0) {
- val = null;
- } else {
- val = val.substring(idx);
- }
- }
- } else {
- if (val == null) {
- val = level;
- } else {
- val = val.trim();
- int idx = val.indexOf(",");
- if (idx < 0) {
- val = level;
- } else {
- val = level + val.substring(idx);
- }
- }
- }
- if (val == null) {
- props.remove(prop);
- } else {
- props.put(prop, val);
- }
- cfg.update(props);
-
- return null;
- }
-
-
-
- protected Configuration getConfiguration() throws IOException {
- Configuration cfg = getConfigAdmin().getConfiguration(CONFIGURATION_PID, null);
- return cfg;
- }
-
- protected ConfigurationAdmin getConfigAdmin() {
- ServiceReference ref = getBundleContext().getServiceReference(ConfigurationAdmin.class.getName());
- return getService(ConfigurationAdmin.class, ref);
- }
-
-}
diff --git a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/VmLogAppender.java b/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/VmLogAppender.java
deleted file mode 100644
index cb67733..0000000
--- a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/VmLogAppender.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.log;
-
-import org.ops4j.pax.logging.spi.PaxAppender;
-import org.ops4j.pax.logging.spi.PaxLoggingEvent;
-
-/**
- * A Pax Logging appender that keep a list of last events
- */
-public class VmLogAppender implements PaxAppender {
-
- protected LruList events;
-
- public LruList getEvents() {
- return events;
- }
-
- public void setEvents(LruList events) {
- this.events = events;
- }
-
- public void doAppend(PaxLoggingEvent event) {
- if (events != null) {
- event.getProperties(); // ensure MDC properties are copied
- events.add(event);
- }
- }
-
-}
diff --git a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/completers/LogLevelCompleter.java b/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/completers/LogLevelCompleter.java
deleted file mode 100644
index 122d448..0000000
--- a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/completers/LogLevelCompleter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.log.completers;
-
-import java.util.List;
-
-import org.apache.felix.karaf.shell.console.Completer;
-import org.apache.felix.karaf.shell.console.completer.StringsCompleter;
-import org.apache.felix.karaf.shell.log.Level;
-
-/**
- * {@link Completer} implementation for completing log levels
- */
-public class LogLevelCompleter extends StringsCompleter {
-
- public LogLevelCompleter() {
- super(Level.strings());
- }
-
- @Override @SuppressWarnings("unchecked")
- public int complete(String buffer, int cursor, List candidates) {
- if (buffer == null) {
- return super.complete(null, cursor, candidates);
- } else {
- // support completing lower case as well with the toUpperCase() call
- return super.complete(buffer.toUpperCase(), cursor, candidates);
- }
- }
-}
diff --git a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/layout/AbsoluteTimeDateFormat.java b/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/layout/AbsoluteTimeDateFormat.java
deleted file mode 100644
index 8e443bf..0000000
--- a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/layout/AbsoluteTimeDateFormat.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.log.layout;
-
-import java.text.DateFormat;
-import java.text.FieldPosition;
-import java.text.ParsePosition;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-
-/**
- * Copied from log4j
- */
-/**
- Formats a {@link Date} in the format "HH:mm:ss,SSS" for example,
- "15:49:37,459".
-
- @author Ceki Gülcü
- @author Andrew Vajoczki
-
- @since 0.7.5
-*/
-public class AbsoluteTimeDateFormat extends DateFormat {
-
- /**
- String constant used to specify {@link
- org.apache.log4j.helpers.AbsoluteTimeDateFormat} in layouts. Current
- value is <b>ABSOLUTE</b>. */
- public final static String ABS_TIME_DATE_FORMAT = "ABSOLUTE";
-
- /**
- String constant used to specify {@link
- org.apache.log4j.helpers.DateTimeDateFormat} in layouts. Current
- value is <b>DATE</b>.
- */
- public final static String DATE_AND_TIME_DATE_FORMAT = "DATE";
-
- /**
- String constant used to specify {@link
- org.apache.log4j.helpers.ISO8601DateFormat} in layouts. Current
- value is <b>ISO8601</b>.
- */
- public final static String ISO8601_DATE_FORMAT = "ISO8601";
-
- public
- AbsoluteTimeDateFormat() {
- setCalendar(Calendar.getInstance());
- }
-
- public
- AbsoluteTimeDateFormat(TimeZone timeZone) {
- setCalendar(Calendar.getInstance(timeZone));
- }
-
- private static long previousTime;
- private static char[] previousTimeWithoutMillis = new char[9]; // "HH:mm:ss."
-
- /**
- Appends to <code>sbuf</code> the time in the format
- "HH:mm:ss,SSS" for example, "15:49:37,459"
-
- @param date the date to format
- @param sbuf the string buffer to write to
- @param fieldPosition remains untouched
- */
- public
- StringBuffer format(Date date, StringBuffer sbuf,
- FieldPosition fieldPosition) {
-
- long now = date.getTime();
- int millis = (int)(now % 1000);
-
- if ((now - millis) != previousTime) {
- // We reach this point at most once per second
- // across all threads instead of each time format()
- // is called. This saves considerable CPU time.
-
- calendar.setTime(date);
-
- int start = sbuf.length();
-
- int hour = calendar.get(Calendar.HOUR_OF_DAY);
- if(hour < 10) {
- sbuf.append('0');
- }
- sbuf.append(hour);
- sbuf.append(':');
-
- int mins = calendar.get(Calendar.MINUTE);
- if(mins < 10) {
- sbuf.append('0');
- }
- sbuf.append(mins);
- sbuf.append(':');
-
- int secs = calendar.get(Calendar.SECOND);
- if(secs < 10) {
- sbuf.append('0');
- }
- sbuf.append(secs);
- sbuf.append(',');
-
- // store the time string for next time to avoid recomputation
- sbuf.getChars(start, sbuf.length(), previousTimeWithoutMillis, 0);
-
- previousTime = now - millis;
- }
- else {
- sbuf.append(previousTimeWithoutMillis);
- }
-
-
-
- if(millis < 100)
- sbuf.append('0');
- if(millis < 10)
- sbuf.append('0');
-
- sbuf.append(millis);
- return sbuf;
- }
-
- /**
- This method does not do anything but return <code>null</code>.
- */
- public
- Date parse(String s, ParsePosition pos) {
- return null;
- }
-}
diff --git a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/layout/DateTimeDateFormat.java b/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/layout/DateTimeDateFormat.java
deleted file mode 100644
index 476b03a..0000000
--- a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/layout/DateTimeDateFormat.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.log.layout;
-
-import java.text.DateFormatSymbols;
-import java.text.FieldPosition;
-import java.text.ParsePosition;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-
-/**
- * Copied from log4j
- */
-/**
- Formats a {@link Date} in the format "dd MMM yyyy HH:mm:ss,SSS" for example,
- "06 Nov 1994 15:49:37,459".
-
- @author Ceki Gülcü
- @since 0.7.5
-*/
-public class DateTimeDateFormat extends AbsoluteTimeDateFormat {
-
- String[] shortMonths;
-
- public
- DateTimeDateFormat() {
- super();
- shortMonths = new DateFormatSymbols().getShortMonths();
- }
-
- public
- DateTimeDateFormat(TimeZone timeZone) {
- this();
- setCalendar(Calendar.getInstance(timeZone));
- }
-
- /**
- Appends to <code>sbuf</code> the date in the format "dd MMM yyyy
- HH:mm:ss,SSS" for example, "06 Nov 1994 08:49:37,459".
-
- @param sbuf the string buffer to write to
- */
- public
- StringBuffer format(Date date, StringBuffer sbuf,
- FieldPosition fieldPosition) {
-
- calendar.setTime(date);
-
- int day = calendar.get(Calendar.DAY_OF_MONTH);
- if(day < 10)
- sbuf.append('0');
- sbuf.append(day);
- sbuf.append(' ');
- sbuf.append(shortMonths[calendar.get(Calendar.MONTH)]);
- sbuf.append(' ');
-
- int year = calendar.get(Calendar.YEAR);
- sbuf.append(year);
- sbuf.append(' ');
-
- return super.format(date, sbuf, fieldPosition);
- }
-
- /**
- This method does not do anything but return <code>null</code>.
- */
- public
- Date parse(java.lang.String s, ParsePosition pos) {
- return null;
- }
-}
diff --git a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/layout/FormattingInfo.java b/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/layout/FormattingInfo.java
deleted file mode 100644
index 75f7834..0000000
--- a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/layout/FormattingInfo.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.log.layout;
-
-
-/**
- * Copied from log4j
- */
-/**
- FormattingInfo instances contain the information obtained when parsing
- formatting modifiers in conversion modifiers.
-
- @author <a href=mailto:jim_cakalic@na.biomerieux.com>Jim Cakalic</a>
- @author Ceki Gülcü
-
- @since 0.8.2
- */
-public class FormattingInfo {
- int min = -1;
- int max = 0x7FFFFFFF;
- boolean leftAlign = false;
-
- void reset() {
- min = -1;
- max = 0x7FFFFFFF;
- leftAlign = false;
- }
-
- void dump() {
- //LogLog.debug("min="+min+", max="+max+", leftAlign="+leftAlign);
- }
-}
-
diff --git a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/layout/ISO8601DateFormat.java b/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/layout/ISO8601DateFormat.java
deleted file mode 100644
index cf3a8ea..0000000
--- a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/layout/ISO8601DateFormat.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.log.layout;
-
-import java.text.FieldPosition;
-import java.text.ParsePosition;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-
-/**
- * Copied from log4j
- */
-// Contributors: Arndt Schoenewald <arndt@ibm23093i821.mc.schoenewald.de>
-/**
- Formats a {@link Date} in the format "yyyy-MM-dd HH:mm:ss,SSS" for example
- "1999-11-27 15:49:37,459".
-
- <p>Refer to the <a
- href=http://www.cl.cam.ac.uk/~mgk25/iso-time.html>summary of the
- International Standard Date and Time Notation</a> for more
- information on this format.
-
- @author Ceki Gülcü
- @author Andrew Vajoczki
-
- @since 0.7.5
-*/
-public class ISO8601DateFormat extends AbsoluteTimeDateFormat {
-
- public
- ISO8601DateFormat() {
- }
-
- public
- ISO8601DateFormat(TimeZone timeZone) {
- super(timeZone);
- }
-
- static private long lastTime;
- static private char[] lastTimeString = new char[20];
-
- /**
- Appends a date in the format "YYYY-mm-dd HH:mm:ss,SSS"
- to <code>sbuf</code>. For example: "1999-11-27 15:49:37,459".
-
- @param sbuf the <code>StringBuffer</code> to write to
- */
- public
- StringBuffer format(Date date, StringBuffer sbuf,
- FieldPosition fieldPosition) {
-
- long now = date.getTime();
- int millis = (int)(now % 1000);
-
- if ((now - millis) != lastTime) {
- // We reach this point at most once per second
- // across all threads instead of each time format()
- // is called. This saves considerable CPU time.
-
- calendar.setTime(date);
-
- int start = sbuf.length();
-
- int year = calendar.get(Calendar.YEAR);
- sbuf.append(year);
-
- String month;
- switch(calendar.get(Calendar.MONTH)) {
- case Calendar.JANUARY: month = "-01-"; break;
- case Calendar.FEBRUARY: month = "-02-"; break;
- case Calendar.MARCH: month = "-03-"; break;
- case Calendar.APRIL: month = "-04-"; break;
- case Calendar.MAY: month = "-05-"; break;
- case Calendar.JUNE: month = "-06-"; break;
- case Calendar.JULY: month = "-07-"; break;
- case Calendar.AUGUST: month = "-08-"; break;
- case Calendar.SEPTEMBER: month = "-09-"; break;
- case Calendar.OCTOBER: month = "-10-"; break;
- case Calendar.NOVEMBER: month = "-11-"; break;
- case Calendar.DECEMBER: month = "-12-"; break;
- default: month = "-NA-"; break;
- }
- sbuf.append(month);
-
- int day = calendar.get(Calendar.DAY_OF_MONTH);
- if(day < 10)
- sbuf.append('0');
- sbuf.append(day);
-
- sbuf.append(' ');
-
- int hour = calendar.get(Calendar.HOUR_OF_DAY);
- if(hour < 10) {
- sbuf.append('0');
- }
- sbuf.append(hour);
- sbuf.append(':');
-
- int mins = calendar.get(Calendar.MINUTE);
- if(mins < 10) {
- sbuf.append('0');
- }
- sbuf.append(mins);
- sbuf.append(':');
-
- int secs = calendar.get(Calendar.SECOND);
- if(secs < 10) {
- sbuf.append('0');
- }
- sbuf.append(secs);
-
- sbuf.append(',');
-
- // store the time string for next time to avoid recomputation
- sbuf.getChars(start, sbuf.length(), lastTimeString, 0);
- lastTime = now - millis;
- }
- else {
- sbuf.append(lastTimeString);
- }
-
-
- if (millis < 100)
- sbuf.append('0');
- if (millis < 10)
- sbuf.append('0');
-
- sbuf.append(millis);
- return sbuf;
- }
-
- /**
- This method does not do anything but return <code>null</code>.
- */
- public
- Date parse(java.lang.String s, ParsePosition pos) {
- return null;
- }
-}
-
diff --git a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/layout/PatternConverter.java b/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/layout/PatternConverter.java
deleted file mode 100644
index 1554b7f..0000000
--- a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/layout/PatternConverter.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.log.layout;
-
-import org.ops4j.pax.logging.spi.PaxLoggingEvent;
-
-/**
-
- <p>PatternConverter is an abtract class that provides the
- formatting functionality that derived classes need.
-
- <p>Conversion specifiers in a conversion patterns are parsed to
- individual PatternConverters. Each of which is responsible for
- converting a logging event in a converter specific manner.
-
- @author <a href="mailto:cakalijp@Maritz.com">James P. Cakalic</a>
- @author Ceki Gülcü
-
- @since 0.8.2
- */
-public abstract class PatternConverter {
- public PatternConverter next;
- int min = -1;
- int max = 0x7FFFFFFF;
- boolean leftAlign = false;
-
- protected
- PatternConverter() { }
-
- protected
- PatternConverter(FormattingInfo fi) {
- min = fi.min;
- max = fi.max;
- leftAlign = fi.leftAlign;
- }
-
- /**
- Derived pattern converters must override this method in order to
- convert conversion specifiers in the correct way.
- */
- abstract
- protected
- String convert(PaxLoggingEvent event);
-
- /**
- A template method for formatting in a converter specific way.
- */
- public
- void format(StringBuffer sbuf, PaxLoggingEvent e) {
- String s = convert(e);
-
- if(s == null) {
- if(0 < min)
- spacePad(sbuf, min);
- return;
- }
-
- int len = s.length();
-
- if(len > max)
- sbuf.append(s.substring(len-max));
- else if(len < min) {
- if(leftAlign) {
- sbuf.append(s);
- spacePad(sbuf, min-len);
- }
- else {
- spacePad(sbuf, min-len);
- sbuf.append(s);
- }
- }
- else
- sbuf.append(s);
- }
-
- static String[] SPACES = {" ", " ", " ", " ", //1,2,4,8 spaces
- " ", // 16 spaces
- " " }; // 32 spaces
-
- /**
- Fast space padding method.
- */
- public
- void spacePad(StringBuffer sbuf, int length) {
- while(length >= 32) {
- sbuf.append(SPACES[5]);
- length -= 32;
- }
-
- for(int i = 4; i >= 0; i--) {
- if((length & (1<<i)) != 0) {
- sbuf.append(SPACES[i]);
- }
- }
- }
-}
diff --git a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/layout/PatternParser.java b/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/layout/PatternParser.java
deleted file mode 100644
index f6507f8..0000000
--- a/karaf/shell/log/src/main/java/org/apache/felix/karaf/shell/log/layout/PatternParser.java
+++ /dev/null
@@ -1,567 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.log.layout;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Map;
-
-import org.apache.log4j.spi.LoggingEvent;
-import org.ops4j.pax.logging.spi.PaxLocationInfo;
-import org.ops4j.pax.logging.spi.PaxLoggingEvent;
-
-/**
- * Copied from log4j
- */
-// Contributors: Nelson Minar <(nelson@monkey.org>
-// Igor E. Poteryaev <jah@mail.ru>
-// Reinhard Deschler <reinhard.deschler@web.de>
-/**
- Most of the work of the {@link org.apache.log4j.PatternLayout} class
- is delegated to the PatternParser class.
-
- @author <a href=mailto:"cakalijp@Maritz.com">James P. Cakalic</a>
- @author Ceki Gülcü
- @author Anders Kristensen
-
- @since 0.8.2
-*/
-public class PatternParser {
-
- private static final String LINE_SEP = System.getProperty("line.separator");
-
- private static final char ESCAPE_CHAR = '%';
-
- private static final int LITERAL_STATE = 0;
- private static final int CONVERTER_STATE = 1;
- private static final int MINUS_STATE = 2;
- private static final int DOT_STATE = 3;
- private static final int MIN_STATE = 4;
- private static final int MAX_STATE = 5;
-
- static final int FULL_LOCATION_CONVERTER = 1000;
- static final int METHOD_LOCATION_CONVERTER = 1001;
- static final int CLASS_LOCATION_CONVERTER = 1002;
- static final int LINE_LOCATION_CONVERTER = 1003;
- static final int FILE_LOCATION_CONVERTER = 1004;
-
- static final int RELATIVE_TIME_CONVERTER = 2000;
- static final int THREAD_CONVERTER = 2001;
- static final int LEVEL_CONVERTER = 2002;
- static final int NDC_CONVERTER = 2003;
- static final int MESSAGE_CONVERTER = 2004;
-
- int state;
- protected StringBuffer currentLiteral = new StringBuffer(32);
- protected int patternLength;
- protected int i;
- PatternConverter head;
- PatternConverter tail;
- protected FormattingInfo formattingInfo = new FormattingInfo();
- protected String pattern;
-
- public
- PatternParser(String pattern) {
- this.pattern = pattern;
- patternLength = pattern.length();
- state = LITERAL_STATE;
- }
-
- private
- void addToList(PatternConverter pc) {
- if(head == null) {
- head = tail = pc;
- } else {
- tail.next = pc;
- tail = pc;
- }
- }
-
- protected
- String extractOption() {
- if((i < patternLength) && (pattern.charAt(i) == '{')) {
- int end = pattern.indexOf('}', i);
- if (end > i) {
- String r = pattern.substring(i + 1, end);
- i = end+1;
- return r;
- }
- }
- return null;
- }
-
-
- /**
- The option is expected to be in decimal and positive. In case of
- error, zero is returned. */
- protected
- int extractPrecisionOption() {
- String opt = extractOption();
- int r = 0;
- if(opt != null) {
- try {
- r = Integer.parseInt(opt);
- if(r <= 0) {
- //LogLog.error("Precision option (" + opt + ") isn't a positive integer.");
- r = 0;
- }
- }
- catch (NumberFormatException e) {
- //LogLog.error("Category option \""+opt+"\" not a decimal integer.", e);
- }
- }
- return r;
- }
-
- public
- PatternConverter parse() {
- char c;
- i = 0;
- while(i < patternLength) {
- c = pattern.charAt(i++);
- switch(state) {
- case LITERAL_STATE:
- // In literal state, the last char is always a literal.
- if(i == patternLength) {
- currentLiteral.append(c);
- continue;
- }
- if(c == ESCAPE_CHAR) {
- // peek at the next char.
- switch(pattern.charAt(i)) {
- case ESCAPE_CHAR:
- currentLiteral.append(c);
- i++; // move pointer
- break;
- case 'n':
- currentLiteral.append(LINE_SEP);
- i++; // move pointer
- break;
- default:
- if(currentLiteral.length() != 0) {
- addToList(new LiteralPatternConverter(
- currentLiteral.toString()));
- //LogLog.debug("Parsed LITERAL converter: \""
- // +currentLiteral+"\".");
- }
- currentLiteral.setLength(0);
- currentLiteral.append(c); // append %
- state = CONVERTER_STATE;
- formattingInfo.reset();
- }
- }
- else {
- currentLiteral.append(c);
- }
- break;
- case CONVERTER_STATE:
- currentLiteral.append(c);
- switch(c) {
- case '-':
- formattingInfo.leftAlign = true;
- break;
- case '.':
- state = DOT_STATE;
- break;
- default:
- if(c >= '0' && c <= '9') {
- formattingInfo.min = c - '0';
- state = MIN_STATE;
- }
- else
- finalizeConverter(c);
- } // switch
- break;
- case MIN_STATE:
- currentLiteral.append(c);
- if(c >= '0' && c <= '9')
- formattingInfo.min = formattingInfo.min*10 + (c - '0');
- else if(c == '.')
- state = DOT_STATE;
- else {
- finalizeConverter(c);
- }
- break;
- case DOT_STATE:
- currentLiteral.append(c);
- if(c >= '0' && c <= '9') {
- formattingInfo.max = c - '0';
- state = MAX_STATE;
- }
- else {
- //LogLog.error("Error occured in position "+i+".\n Was expecting digit, instead got char \""+c+"\".");
- state = LITERAL_STATE;
- }
- break;
- case MAX_STATE:
- currentLiteral.append(c);
- if(c >= '0' && c <= '9')
- formattingInfo.max = formattingInfo.max*10 + (c - '0');
- else {
- finalizeConverter(c);
- state = LITERAL_STATE;
- }
- break;
- } // switch
- } // while
- if(currentLiteral.length() != 0) {
- addToList(new LiteralPatternConverter(currentLiteral.toString()));
- //LogLog.debug("Parsed LITERAL converter: \""+currentLiteral+"\".");
- }
- return head;
- }
-
- protected
- void finalizeConverter(char c) {
- PatternConverter pc = null;
- switch(c) {
- case 'c':
- pc = new CategoryPatternConverter(formattingInfo,
- extractPrecisionOption());
- //LogLog.debug("CATEGORY converter.");
- //formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- case 'C':
- pc = new ClassNamePatternConverter(formattingInfo,
- extractPrecisionOption());
- //LogLog.debug("CLASS_NAME converter.");
- //formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- case 'd':
- String dateFormatStr = AbsoluteTimeDateFormat.ISO8601_DATE_FORMAT;
- DateFormat df;
- String dOpt = extractOption();
- if(dOpt != null)
- dateFormatStr = dOpt;
-
- if(dateFormatStr.equalsIgnoreCase(
- AbsoluteTimeDateFormat.ISO8601_DATE_FORMAT))
- df = new ISO8601DateFormat();
- else if(dateFormatStr.equalsIgnoreCase(
- AbsoluteTimeDateFormat.ABS_TIME_DATE_FORMAT))
- df = new AbsoluteTimeDateFormat();
- else if(dateFormatStr.equalsIgnoreCase(
- AbsoluteTimeDateFormat.DATE_AND_TIME_DATE_FORMAT))
- df = new DateTimeDateFormat();
- else {
- try {
- df = new SimpleDateFormat(dateFormatStr);
- }
- catch (IllegalArgumentException e) {
- //LogLog.error("Could not instantiate SimpleDateFormat with " + dateFormatStr, e);
- df = new ISO8601DateFormat();
- }
- }
- pc = new DatePatternConverter(formattingInfo, df);
- //LogLog.debug("DATE converter {"+dateFormatStr+"}.");
- //formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- case 'F':
- pc = new LocationPatternConverter(formattingInfo,
- FILE_LOCATION_CONVERTER);
- //LogLog.debug("File name converter.");
- //formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- /*case 'l':
- pc = new LocationPatternConverter(formattingInfo,
- FULL_LOCATION_CONVERTER);
- //LogLog.debug("Location converter.");
- //formattingInfo.dump();
- currentLiteral.setLength(0);
- break;*/
- case 'L':
- pc = new LocationPatternConverter(formattingInfo,
- LINE_LOCATION_CONVERTER);
- //LogLog.debug("LINE NUMBER converter.");
- //formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- case 'm':
- pc = new BasicPatternConverter(formattingInfo, MESSAGE_CONVERTER);
- //LogLog.debug("MESSAGE converter.");
- //formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- case 'M':
- pc = new LocationPatternConverter(formattingInfo,
- METHOD_LOCATION_CONVERTER);
- //LogLog.debug("METHOD converter.");
- //formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- case 'p':
- pc = new BasicPatternConverter(formattingInfo, LEVEL_CONVERTER);
- //LogLog.debug("LEVEL converter.");
- //formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- case 'r':
- pc = new BasicPatternConverter(formattingInfo,
- RELATIVE_TIME_CONVERTER);
- //LogLog.debug("RELATIVE time converter.");
- //formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- case 't':
- pc = new BasicPatternConverter(formattingInfo, THREAD_CONVERTER);
- //LogLog.debug("THREAD converter.");
- //formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- /*case 'u':
- if(i < patternLength) {
- char cNext = pattern.charAt(i);
- if(cNext >= '0' && cNext <= '9') {
- pc = new UserFieldPatternConverter(formattingInfo, cNext - '0');
- LogLog.debug("USER converter ["+cNext+"].");
- formattingInfo.dump();
- currentLiteral.setLength(0);
- i++;
- }
- else
- LogLog.error("Unexpected char" +cNext+" at position "+i);
- }
- break;*/
- /*case 'x':
- pc = new BasicPatternConverter(formattingInfo, NDC_CONVERTER);
- //LogLog.debug("NDC converter.");
- currentLiteral.setLength(0);
- break;*/
- case 'X':
- String xOpt = extractOption();
- pc = new MDCPatternConverter(formattingInfo, xOpt);
- currentLiteral.setLength(0);
- break;
- default:
- //LogLog.error("Unexpected char [" +c+"] at position "+i+" in conversion patterrn.");
- pc = new LiteralPatternConverter(currentLiteral.toString());
- currentLiteral.setLength(0);
- }
-
- addConverter(pc);
- }
-
- protected
- void addConverter(PatternConverter pc) {
- currentLiteral.setLength(0);
- // Add the pattern converter to the list.
- addToList(pc);
- // Next pattern is assumed to be a literal.
- state = LITERAL_STATE;
- // Reset formatting info
- formattingInfo.reset();
- }
-
- // ---------------------------------------------------------------------
- // PatternConverters
- // ---------------------------------------------------------------------
-
- private static class BasicPatternConverter extends PatternConverter {
- int type;
-
- BasicPatternConverter(FormattingInfo formattingInfo, int type) {
- super(formattingInfo);
- this.type = type;
- }
-
- public
- String convert(PaxLoggingEvent event) {
- switch(type) {
- case RELATIVE_TIME_CONVERTER:
- return (Long.toString(event.getTimeStamp() - LoggingEvent.getStartTime()));
- case THREAD_CONVERTER:
- return event.getThreadName();
- case LEVEL_CONVERTER:
- return event.getLevel().toString();
- // case NDC_CONVERTER:
- //return event.getNDC();
- case MESSAGE_CONVERTER: {
- return event.getRenderedMessage();
- }
- default: return null;
- }
- }
- }
-
- private static class LiteralPatternConverter extends PatternConverter {
- private String literal;
-
- LiteralPatternConverter(String value) {
- literal = value;
- }
-
- public
- final
- void format(StringBuffer sbuf, LoggingEvent event) {
- sbuf.append(literal);
- }
-
- public
- String convert(PaxLoggingEvent event) {
- return literal;
- }
- }
-
- private static class DatePatternConverter extends PatternConverter {
- private DateFormat df;
- private Date date;
-
- DatePatternConverter(FormattingInfo formattingInfo, DateFormat df) {
- super(formattingInfo);
- date = new Date();
- this.df = df;
- }
-
- public
- String convert(PaxLoggingEvent event) {
- date.setTime(event.getTimeStamp());
- String converted = null;
- try {
- converted = df.format(date);
- }
- catch (Exception ex) {
- //LogLog.error("Error occured while converting date.", ex);
- }
- return converted;
- }
- }
-
- private class LocationPatternConverter extends PatternConverter {
- int type;
-
- LocationPatternConverter(FormattingInfo formattingInfo, int type) {
- super(formattingInfo);
- this.type = type;
- }
-
- public
- String convert(PaxLoggingEvent event) {
- PaxLocationInfo locationInfo = event.getLocationInformation();
- switch(type) {
- /*case FULL_LOCATION_CONVERTER:
- return locationInfo.fullInfo;*/
- case METHOD_LOCATION_CONVERTER:
- return locationInfo.getMethodName();
- case LINE_LOCATION_CONVERTER:
- return locationInfo.getLineNumber();
- case FILE_LOCATION_CONVERTER:
- return locationInfo.getFileName();
- default: return null;
- }
- }
- }
-
- private static abstract class NamedPatternConverter extends PatternConverter {
- int precision;
-
- NamedPatternConverter(FormattingInfo formattingInfo, int precision) {
- super(formattingInfo);
- this.precision = precision;
- }
-
- abstract
- String getFullyQualifiedName(PaxLoggingEvent event);
-
- public
- String convert(PaxLoggingEvent event) {
- String n = getFullyQualifiedName(event);
- if(precision <= 0)
- return n;
- else {
- int len = n.length();
-
- // We substract 1 from 'len' when assigning to 'end' to avoid out of
- // bounds exception in return r.substring(end+1, len). This can happen if
- // precision is 1 and the category name ends with a dot.
- int end = len -1 ;
- for(int i = precision; i > 0; i--) {
- end = n.lastIndexOf('.', end-1);
- if(end == -1)
- return n;
- }
- return n.substring(end+1, len);
- }
- }
- }
-
- private class ClassNamePatternConverter extends NamedPatternConverter {
-
- ClassNamePatternConverter(FormattingInfo formattingInfo, int precision) {
- super(formattingInfo, precision);
- }
-
- String getFullyQualifiedName(PaxLoggingEvent event) {
- return event.getLocationInformation().getClassName();
- }
- }
-
- private class CategoryPatternConverter extends NamedPatternConverter {
-
- CategoryPatternConverter(FormattingInfo formattingInfo, int precision) {
- super(formattingInfo, precision);
- }
-
- String getFullyQualifiedName(PaxLoggingEvent event) {
- return event.getLoggerName();
- }
- }
-
- private class MDCPatternConverter extends PatternConverter {
- String key;
-
- MDCPatternConverter(FormattingInfo formattingInfo, String key) {
- super(formattingInfo);
- this.key = key;
- }
-
- public
- String convert(PaxLoggingEvent event) {
- if (key == null) {
- StringBuffer buf = new StringBuffer("{");
- Map properties = event.getProperties();
- if (properties.size() > 0) {
- Object[] keys = properties.keySet().toArray();
- Arrays.sort(keys);
- for (int i = 0; i < keys.length; i++) {
- buf.append('{');
- buf.append(keys[i]);
- buf.append(',');
- buf.append(properties.get(keys[i]));
- buf.append('}');
- }
- }
- buf.append('}');
- return buf.toString();
- } else {
- Object val = event.getProperties().get(key);
- if(val == null) {
- return null;
- } else {
- return val.toString();
- }
- }
- }
-
- }
-}
-
diff --git a/karaf/shell/log/src/main/resources/OSGI-INF/blueprint/shell-log.xml b/karaf/shell/log/src/main/resources/OSGI-INF/blueprint/shell-log.xml
deleted file mode 100644
index fff1541..0000000
--- a/karaf/shell/log/src/main/resources/OSGI-INF/blueprint/shell-log.xml
+++ /dev/null
@@ -1,77 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0">
-
- <!-- TODO: use dynamic CM config -->
-
- <cm:property-placeholder persistent-id="org.apache.felix.karaf.log">
- <cm:default-properties>
- <cm:property name="size" value="500"/>
- <cm:property name="pattern" value="%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n"/>
- </cm:default-properties>
- </cm:property-placeholder>
-
- <command-bundle xmlns="http://felix.apache.org/karaf/xmlns/shell/v1.0.0">
- <command name="log/display">
- <action class="org.apache.felix.karaf.shell.log.DisplayLog">
- <property name="events" ref="events"/>
- <property name="pattern" value="${pattern}"/>
- </action>
- </command>
- <link name="log/d" target="log/display"/>
- <command name="log/display-exception">
- <action class="org.apache.felix.karaf.shell.log.DisplayException">
- <property name="events" ref="events"/>
- </action>
- </command>
- <link name="log/de" target="log/display-exception"/>
- <command name="log/get">
- <action class="org.apache.felix.karaf.shell.log.GetLogLevel" />
- </command>
- <command name="log/set">
- <action class="org.apache.felix.karaf.shell.log.SetLogLevel" />
- <completers>
- <ref component-id="logLevelCompleter"/>
- <null/>
- </completers>
- </command>
-
- <alias name="ld" alias="log/d"/>
- <alias name="lde" alias="log/de"/>
- </command-bundle>
-
- <bean id="vmLogAppender" class="org.apache.felix.karaf.shell.log.VmLogAppender">
- <property name="events" ref="events"/>
- </bean>
-
- <bean id="events" class="org.apache.felix.karaf.shell.log.LruList">
- <argument value="${size}"/>
- </bean>
-
- <bean id="logLevelCompleter" class="org.apache.felix.karaf.shell.log.completers.LogLevelCompleter"/>
-
- <service ref="vmLogAppender" interface="org.ops4j.pax.logging.spi.PaxAppender">
- <service-properties>
- <entry key="org.ops4j.pax.logging.appender.name" value="VmLogAppender"/>
- </service-properties>
- </service>
-
-</blueprint>
diff --git a/karaf/shell/log/src/main/resources/OSGI-INF/metatype/metatype.properties b/karaf/shell/log/src/main/resources/OSGI-INF/metatype/metatype.properties
deleted file mode 100644
index 96bb60b..0000000
--- a/karaf/shell/log/src/main/resources/OSGI-INF/metatype/metatype.properties
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-#
-# This file contains localization strings for configuration labels and
-# descriptions as used in the metatype.xml descriptor
-
-log.name = Apache Felix Karaf Log
-log.description = Configuration of Apache Felix Karaf Log
-
-size.name = Size
-size.description = size of the log to keep in memory
-
-pattern.name = Pattern
-pattern.description = Pattern used to display log entries
diff --git a/karaf/shell/log/src/main/resources/OSGI-INF/metatype/metatype.xml b/karaf/shell/log/src/main/resources/OSGI-INF/metatype/metatype.xml
deleted file mode 100644
index c41898a..0000000
--- a/karaf/shell/log/src/main/resources/OSGI-INF/metatype/metatype.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0" localization="OSGI-INF/metatype/metatype">
- <OCD id="org.apache.felix.karaf.log" name="%log.name" description="%log.description">
- <AD id="size" type="Integer" default="500" name="%size.name"
- description="%size.description"/>
- <AD id="pattern" type="String" default="%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n" name="%pattern.name"
- description="%pattern.description"/>
- </OCD>
- <Designate pid="org.apache.felix.karaf.log">
- <Object ocdref="org.apache.felix.karaf.log"/>
- </Designate>
-</metatype:MetaData>
diff --git a/karaf/shell/log/src/test/java/org/apache/felix/karaf/shell/log/SetLogLevelTest.java b/karaf/shell/log/src/test/java/org/apache/felix/karaf/shell/log/SetLogLevelTest.java
deleted file mode 100644
index db95924..0000000
--- a/karaf/shell/log/src/test/java/org/apache/felix/karaf/shell/log/SetLogLevelTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.log;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.Hashtable;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-import org.osgi.service.cm.Configuration;
-
-/**
- * Test cases for {@link SetLogLevel}
- */
-@SuppressWarnings("unchecked")
-public class SetLogLevelTest extends TestCase {
-
- private static final String ROOT_LOGGER = "log4j.rootLogger";
- private static final String PACKAGE_LOGGER = "log4j.logger.org.apache.karaf.test";
- private static final PrintStream ORIGINAL_STDERR = System.err;
-
- private SetLogLevel command;
- private Hashtable properties;
- private ByteArrayOutputStream stderr;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- properties = new Hashtable();
- stderr = new ByteArrayOutputStream();
- System.setErr(new PrintStream(stderr));
-
- final Configuration configuration = EasyMock.createMock(Configuration.class);
- EasyMock.expect(configuration.getProperties()).andReturn(properties);
- configuration.update(properties);
- EasyMock.replay(configuration);
-
- command = new SetLogLevel() {
- @Override
- protected Configuration getConfiguration() throws IOException {
- return configuration;
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- System.setErr(ORIGINAL_STDERR);
- }
-
- public void testInvalidLogLevel() throws Exception {
- runCommand("log:set INVALID");
- assertTrue("Expected an error message on System.err",
- stderr.toString().contains("level must be set to"));
- }
-
- public void testSetLogLevel() throws Exception {
- runCommand("log:set INFO org.apache.karaf.test");
-
- assertEquals("INFO", properties.get(PACKAGE_LOGGER));
- }
-
- public void testSetRootLogLevel() throws Exception {
- runCommand("log:set INFO");
-
- assertEquals("INFO", properties.get(ROOT_LOGGER));
- }
-
- public void testSetLogLevelLowerCase() throws Exception {
- runCommand("log:set info org.apache.karaf.test");
-
- assertEquals("INFO", properties.get(PACKAGE_LOGGER));
- }
-
- public void testSetRootLogLevelLowerCase() throws Exception {
- runCommand("log:set info");
-
- assertEquals("INFO", properties.get(ROOT_LOGGER));
- }
-
- public void testChangeLogLevel() throws Exception {
- properties.put(PACKAGE_LOGGER, "DEBUG");
-
- runCommand("log:set INFO org.apache.karaf.test");
-
- assertEquals("INFO", properties.get(PACKAGE_LOGGER));
- }
-
- public void testChangeRootLogLevel() throws Exception {
- properties.put(ROOT_LOGGER, "DEBUG");
-
- runCommand("log:set INFO");
-
- assertEquals("INFO", properties.get(ROOT_LOGGER));
- }
-
- public void testChangeLogLevelWithAppender() throws Exception {
- properties.put(PACKAGE_LOGGER, "DEBUG, APPENDER1");
-
- runCommand("log:set INFO org.apache.karaf.test");
-
- assertEquals("INFO, APPENDER1", properties.get(PACKAGE_LOGGER));
- }
-
- public void testChangeRootLogLevelWithAppender() throws Exception {
- properties.put(ROOT_LOGGER, "DEBUG, APPENDER1");
-
- runCommand("log:set INFO");
-
- assertEquals("INFO, APPENDER1", properties.get(ROOT_LOGGER));
- }
-
-
- public void testUnsetLogLevel() throws Exception {
- properties.put(PACKAGE_LOGGER, "DEBUG");
-
- runCommand("log:set DEFAULT org.apache.karaf.test");
-
- assertFalse("Configuration for logger org.apache.karaf.test has been removed",
- properties.containsKey(PACKAGE_LOGGER));
- }
-
-
- public void testUnsetRootLogLevel() throws Exception {
- properties.put(ROOT_LOGGER, "INFO");
-
- runCommand("log:set DEFAULT");
-
- assertEquals("Configuration for root logger should not be removed",
- "INFO", properties.get(ROOT_LOGGER));
- assertTrue("Expected an error message on System.err",
- stderr.toString().contains("Can not unset the ROOT logger"));
- }
-
- /*
- * Simulate running the log:set command
- */
- private void runCommand(String commandline) throws Exception {
- String[] parts = commandline.split(" ");
-
- command.level = parts[1];
- if (parts.length == 3) {
- command.logger = "org.apache.karaf.test";
- }
-
- command.doExecute();
- }
-}
diff --git a/karaf/shell/log/src/test/java/org/apache/felix/karaf/shell/log/completers/LogLevelCompleterTest.java b/karaf/shell/log/src/test/java/org/apache/felix/karaf/shell/log/completers/LogLevelCompleterTest.java
deleted file mode 100644
index a7a1cf5..0000000
--- a/karaf/shell/log/src/test/java/org/apache/felix/karaf/shell/log/completers/LogLevelCompleterTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.log.completers;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.felix.karaf.shell.log.Level;
-
-import junit.framework.TestCase;
-
-/**
- * Test cases for {@link LogLevelCompleter}
- */
-public class LogLevelCompleterTest extends TestCase {
-
- private final LogLevelCompleter completer = new LogLevelCompleter();
-
- public void testComplete() throws Exception {
- assertCompletions("I", Level.INFO.name());
- assertCompletions("D", Level.DEBUG.name(), Level.DEFAULT.name());
- }
-
- public void testCompleteLowerCase() throws Exception {
- assertCompletions("i", Level.INFO.name());
- assertCompletions("d", Level.DEBUG.name(), Level.DEFAULT.name());
- }
-
- public void testCompleteWithNullBuffer() throws Exception {
- // an empty buffer should return all available options
- assertCompletions(null, Level.strings());
- }
-
- private void assertCompletions(String buffer, String... results) {
- List<String> candidates = new LinkedList<String>();
- assertEquals("Completer should have found a match", 0, completer.complete(buffer, 0, candidates));
- assertEquals(results.length, candidates.size());
- for (String result : results) {
- assertContains(result, candidates);
- }
- }
-
- private void assertContains(String value, List<String> values) {
- for (String element : values) {
- if (value.trim().equals(element.trim())) {
- return;
- }
- }
- fail("Element " + value + " not found in array");
- }
-}
diff --git a/karaf/shell/obr/NOTICE b/karaf/shell/obr/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/shell/obr/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/shell/obr/pom.xml b/karaf/shell/obr/pom.xml
deleted file mode 100644
index 2541b80..0000000
--- a/karaf/shell/obr/pom.xml
+++ /dev/null
@@ -1,86 +0,0 @@
-<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/maven-v4_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.felix.karaf.shell</groupId>
- <artifactId>shell</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.obr</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Shell OBR Commands</name>
-
- <description>
- Provides the OBR Shell commands
- </description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.bundlerepository</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>
- ${project.artifactId}*;version=${project.version}
- </Export-Package>
- <Import-Package>
- !${project.artifactId}*,
- org.osgi.service.command,
- org.apache.felix.gogo.commands,
- org.apache.felix.karaf.shell.console,
- *
- </Import-Package>
- <Private-Package>!*</Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/AddUrlCommand.java b/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/AddUrlCommand.java
deleted file mode 100644
index 3ccb1fe..0000000
--- a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/AddUrlCommand.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.obr;
-
-import java.util.List;
-
-import org.apache.felix.bundlerepository.RepositoryAdmin;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "obr", name = "addUrl", description = "Adds a list of repository URLs to the OBR service.")
-public class AddUrlCommand extends ObrCommandSupport {
-
- @Argument(index = 0, name = "urls", description = "Repository URLs to add to the OBR service separated by whitespaces", required = true, multiValued = true)
- List<String> urls;
-
- protected void doExecute(RepositoryAdmin admin) throws Exception {
- for (String url : urls) {
- admin.addRepository(url);
- }
- }
-}
diff --git a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/DeployCommand.java b/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/DeployCommand.java
deleted file mode 100644
index b29b8c2..0000000
--- a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/DeployCommand.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.obr;
-
-import java.util.List;
-
-import org.apache.felix.bundlerepository.RepositoryAdmin;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "obr", name = "deploy", description = "Deploys a list of bundles using OBR service")
-public class DeployCommand extends ObrCommandSupport {
-
- @Argument(index = 0, name = "bundles", description = "List of bundle names to deploy (separated by whitespaces)", required = true, multiValued = true)
- protected List<String> bundles;
-
- protected void doExecute(RepositoryAdmin admin) throws Exception {
- doDeploy(admin, bundles, false);
- }
-
-}
diff --git a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/FindCommand.java b/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/FindCommand.java
deleted file mode 100644
index e1b5462..0000000
--- a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/FindCommand.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.obr;
-
-import java.io.PrintStream;
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.felix.bundlerepository.Capability;
-import org.apache.felix.bundlerepository.Repository;
-import org.apache.felix.bundlerepository.RepositoryAdmin;
-import org.apache.felix.bundlerepository.Requirement;
-import org.apache.felix.bundlerepository.Resource;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.Version;
-
-@Command(scope = "obr", name = "find", description = "Find OBR bundles for a given filter")
-public class FindCommand extends ObrCommandSupport {
-
- @Argument(index = 0, name = "requirements", description = "Requirement", required = true, multiValued = true)
- List<String> requirements;
-
- protected void doExecute(RepositoryAdmin admin) throws Exception {
- List<Resource> matching = new ArrayList<Resource>();
- Resource[] resources = admin.discoverResources(parseRequirements(admin, requirements));
- if (resources == null)
- {
- System.err.println("No matching resources.");
- }
- else
- {
- for (int resIdx = 0; resIdx < resources.length; resIdx++)
- {
- if (resIdx > 0)
- {
- System.out.println("");
- }
- printResource(System.out, resources[resIdx]);
- }
- }
- }
-
- private void printResource(PrintStream out, Resource resource)
- {
- String name = resource.getPresentationName();
- if (name == null) {
- name = resource.getSymbolicName();
- }
-
- printUnderline(out, name.length());
- out.println(name);
- printUnderline(out, name .length());
-
- Map map = resource.getProperties();
- for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); )
- {
- Map.Entry entry = (Map.Entry) iter.next();
- if (entry.getValue().getClass().isArray())
- {
- out.println(entry.getKey() + ":");
- for (int j = 0; j < Array.getLength(entry.getValue()); j++)
- {
- out.println(" " + Array.get(entry.getValue(), j));
- }
- }
- else
- {
- out.println(entry.getKey() + ": " + entry.getValue());
- }
- }
-
- Requirement[] reqs = resource.getRequirements();
- if ((reqs != null) && (reqs.length > 0))
- {
- boolean hdr = false;
- for (int i = 0; i < reqs.length; i++)
- {
- if (!reqs[i].isOptional())
- {
- if (!hdr)
- {
- hdr = true;
- out.println("Requirements:");
- }
- out.println(" " + reqs[i].getName() + ":" + reqs[i].getFilter());
- }
- }
- hdr = false;
- for (int i = 0; i < reqs.length; i++)
- {
- if (reqs[i].isOptional())
- {
- if (!hdr)
- {
- hdr = true;
- out.println("Optional Requirements:");
- }
- out.println(" " + reqs[i].getName() + ":" + reqs[i].getFilter());
- }
- }
- }
-
- Capability[] caps = resource.getCapabilities();
- if ((caps != null) && (caps.length > 0))
- {
- out.println("Capabilities:");
- for (int i = 0; i < caps.length; i++)
- {
- out.println(" " + caps[i].getName() + ":" + caps[i].getPropertiesAsMap());
- }
- }
- }
-
-}
\ No newline at end of file
diff --git a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/InfoCommand.java b/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/InfoCommand.java
deleted file mode 100644
index b5d5915..0000000
--- a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/InfoCommand.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.obr;
-
-import java.io.PrintStream;
-import java.lang.reflect.Array;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.felix.bundlerepository.Capability;
-import org.apache.felix.bundlerepository.RepositoryAdmin;
-import org.apache.felix.bundlerepository.Requirement;
-import org.apache.felix.bundlerepository.Resource;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "obr", name = "info", description = "Prints information about OBR bundles")
-public class InfoCommand extends ObrCommandSupport {
-
- @Argument(index = 0, name = "bundles", description = "Specify bundles to query for information (separated by whitespaces)", required = true, multiValued = true)
- List<String> bundles;
-
- protected void doExecute(RepositoryAdmin admin) throws Exception {
- for (String bundle : bundles) {
- String[] target = getTarget(bundle);
- Resource[] resources = searchRepository(admin, target[0], target[1]);
- if (resources == null)
- {
- System.err.println("Unknown bundle and/or version: "
- + target[0]);
- }
- else
- {
- for (int resIdx = 0; resIdx < resources.length; resIdx++)
- {
- if (resIdx > 0)
- {
- System.out.println("");
- }
- printResource(System.out, resources[resIdx]);
- }
- }
- }
- }
-
- private void printResource(PrintStream out, Resource resource)
- {
- printUnderline(out, resource.getPresentationName().length());
- out.println(resource.getPresentationName());
- printUnderline(out, resource.getPresentationName().length());
-
- Map map = resource.getProperties();
- for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); )
- {
- Map.Entry entry = (Map.Entry) iter.next();
- if (entry.getValue().getClass().isArray())
- {
- out.println(entry.getKey() + ":");
- for (int j = 0; j < Array.getLength(entry.getValue()); j++)
- {
- out.println(" " + Array.get(entry.getValue(), j));
- }
- }
- else
- {
- out.println(entry.getKey() + ": " + entry.getValue());
- }
- }
-
- Requirement[] reqs = resource.getRequirements();
- if ((reqs != null) && (reqs.length > 0))
- {
- out.println("Requires:");
- for (int i = 0; i < reqs.length; i++)
- {
- out.println(" " + reqs[i].getName() + ":" + reqs[i].getFilter());
- }
- }
-
- Capability[] caps = resource.getCapabilities();
- if ((caps != null) && (caps.length > 0))
- {
- out.println("Capabilities:");
- for (int i = 0; i < caps.length; i++)
- {
- out.println(" " + caps[i].getName() + ":" + caps[i].getPropertiesAsMap());
- }
- }
- }
-
-}
diff --git a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/ListCommand.java b/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/ListCommand.java
deleted file mode 100644
index bb76b86..0000000
--- a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/ListCommand.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.obr;
-
-import java.util.List;
-
-import org.apache.felix.bundlerepository.RepositoryAdmin;
-import org.apache.felix.bundlerepository.Resource;
-import org.osgi.framework.Version;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "obr", name = "list", description = "Lists OBR bundles")
-public class ListCommand extends ObrCommandSupport {
-
- @Argument(index = 0, name = "args", description = "The arguments", required = false, multiValued = true)
- List<String> args;
-
- protected void doExecute(RepositoryAdmin admin) throws Exception {
- String substr = null;
-
- if (args != null) {
- for (String arg : args)
- {
- // Add a space in between tokens.
- if (substr == null)
- {
- substr = "";
- }
- else
- {
- substr += " ";
- }
-
- substr += arg;
- }
- }
-
- StringBuffer sb = new StringBuffer();
- if ((substr == null) || (substr.length() == 0))
- {
- sb.append("(|(presentationname=*)(symbolicname=*))");
- }
- else
- {
- sb.append("(|(presentationname=*");
- sb.append(substr);
- sb.append("*)(symbolicname=*");
- sb.append(substr);
- sb.append("*))");
- }
- Resource[] resources = admin.discoverResources(sb.toString());
- for (int resIdx = 0; (resources != null) && (resIdx < resources.length); resIdx++)
- {
- String name = resources[resIdx].getPresentationName();
- Version version = resources[resIdx].getVersion();
- if (version != null)
- {
- System.out.println(name + " (" + version + ")");
- }
- else
- {
- System.out.println(name);
- }
- }
-
- if (resources == null)
- {
- System.out.println("No matching bundles.");
- }
- }
-
-}
diff --git a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/ListUrlCommand.java b/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/ListUrlCommand.java
deleted file mode 100644
index 6dc9487..0000000
--- a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/ListUrlCommand.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy 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.felix.karaf.shell.obr;
-
-import org.apache.felix.bundlerepository.Repository;
-import org.apache.felix.bundlerepository.RepositoryAdmin;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "obr", name = "listUrl", description = "Displays the repository URLs currently associated with the OBR service.")
-public class ListUrlCommand extends ObrCommandSupport {
-
- protected void doExecute(RepositoryAdmin admin) {
- Repository[] repos = admin.listRepositories();
- if ((repos != null) && (repos.length > 0)) {
- for (int i = 0; i < repos.length; i++) {
- System.out.println(repos[i].getURI());
- }
- } else {
- System.out.println("No repository URLs are set.");
- }
- }
-
-}
diff --git a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/ObrCommandSupport.java b/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/ObrCommandSupport.java
deleted file mode 100644
index 6a2afba..0000000
--- a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/ObrCommandSupport.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.obr;
-
-import java.io.PrintStream;
-import java.util.List;
-
-import org.apache.felix.bundlerepository.Reason;
-import org.apache.felix.bundlerepository.RepositoryAdmin;
-import org.apache.felix.bundlerepository.Requirement;
-import org.apache.felix.bundlerepository.Resolver;
-import org.apache.felix.bundlerepository.Resource;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.Version;
-
-public abstract class ObrCommandSupport extends OsgiCommandSupport {
-
- protected static final char VERSION_DELIM = ',';
-
- protected Object doExecute() throws Exception {
- // Get repository admin service.
- ServiceReference ref = getBundleContext().getServiceReference(RepositoryAdmin.class.getName());
- if (ref == null) {
- System.out.println("RepositoryAdmin service is unavailable.");
- return null;
- }
- try {
- RepositoryAdmin admin = (RepositoryAdmin) getBundleContext().getService(ref);
- if (admin == null) {
- System.out.println("RepositoryAdmin service is unavailable.");
- return null;
- }
-
- doExecute(admin);
- }
- finally {
- getBundleContext().ungetService(ref);
- }
- return null;
- }
-
- protected abstract void doExecute(RepositoryAdmin admin) throws Exception;
-
- protected Resource[] searchRepository(RepositoryAdmin admin, String targetId, String targetVersion) throws InvalidSyntaxException
- {
- // Try to see if the targetId is a bundle ID.
- try
- {
- Bundle bundle = getBundleContext().getBundle(Long.parseLong(targetId));
- targetId = bundle.getSymbolicName();
- }
- catch (NumberFormatException ex)
- {
- // It was not a number, so ignore.
- }
-
- // The targetId may be a bundle name or a bundle symbolic name,
- // so create the appropriate LDAP query.
- StringBuffer sb = new StringBuffer("(|(presentationname=");
- sb.append(targetId);
- sb.append(")(symbolicname=");
- sb.append(targetId);
- sb.append("))");
- if (targetVersion != null)
- {
- sb.insert(0, "(&");
- sb.append("(version=");
- sb.append(targetVersion);
- sb.append("))");
- }
- return admin.discoverResources(sb.toString());
- }
-
- public Resource selectNewestVersion(Resource[] resources)
- {
- int idx = -1;
- Version v = null;
- for (int i = 0; (resources != null) && (i < resources.length); i++)
- {
- if (i == 0)
- {
- idx = 0;
- v = resources[i].getVersion();
- }
- else
- {
- Version vtmp = resources[i].getVersion();
- if (vtmp.compareTo(v) > 0)
- {
- idx = i;
- v = vtmp;
- }
- }
- }
- return (idx < 0) ? null : resources[idx];
- }
-
- protected String[] getTarget(String bundle) {
- String[] target;
- int idx = bundle.indexOf(VERSION_DELIM);
- if (idx > 0) {
- target = new String[] { bundle.substring(0, idx), bundle.substring(idx+1) };
- }
- else
- {
- target = new String[] { bundle, null };
- }
- return target;
- }
-
- protected void printUnderline(PrintStream out, int length)
- {
- for (int i = 0; i < length; i++)
- {
- out.print('-');
- }
- out.println("");
- }
-
- protected void doDeploy(RepositoryAdmin admin, List<String> bundles, boolean start) throws Exception {
- Resolver resolver = admin.resolver();
- for (String bundle : bundles) {
- String[] target = getTarget(bundle);
- Resource resource = selectNewestVersion(searchRepository(admin, target[0], target[1]));
- if (resource != null)
- {
- resolver.add(resource);
- }
- else
- {
- System.err.println("Unknown bundle - " + target[0]);
- }
- }
- if ((resolver.getAddedResources() != null) &&
- (resolver.getAddedResources().length > 0))
- {
- if (resolver.resolve())
- {
- System.out.println("Target resource(s):");
- printUnderline(System.out, 19);
- Resource[] resources = resolver.getAddedResources();
- for (int resIdx = 0; (resources != null) && (resIdx < resources.length); resIdx++)
- {
- System.out.println(" " + resources[resIdx].getPresentationName()
- + " (" + resources[resIdx].getVersion() + ")");
- }
- resources = resolver.getRequiredResources();
- if ((resources != null) && (resources.length > 0))
- {
- System.out.println("\nRequired resource(s):");
- printUnderline(System.out, 21);
- for (int resIdx = 0; resIdx < resources.length; resIdx++)
- {
- System.out.println(" " + resources[resIdx].getPresentationName()
- + " (" + resources[resIdx].getVersion() + ")");
- }
- }
- resources = resolver.getOptionalResources();
- if ((resources != null) && (resources.length > 0))
- {
- System.out.println("\nOptional resource(s):");
- printUnderline(System.out, 21);
- for (int resIdx = 0; resIdx < resources.length; resIdx++)
- {
- System.out.println(" " + resources[resIdx].getPresentationName()
- + " (" + resources[resIdx].getVersion() + ")");
- }
- }
-
- try
- {
- System.out.print("\nDeploying...");
- resolver.deploy(start ? Resolver.START : 0);
- System.out.println("done.");
- }
- catch (IllegalStateException ex)
- {
- System.err.println(ex);
- }
- }
- else
- {
- Reason[] reqs = resolver.getUnsatisfiedRequirements();
- if ((reqs != null) && (reqs.length > 0))
- {
- System.out.println("Unsatisfied requirement(s):");
- printUnderline(System.out, 27);
- for (int reqIdx = 0; reqIdx < reqs.length; reqIdx++)
- {
- System.out.println(" " + reqs[reqIdx].getRequirement().getFilter());
- System.out.println(" " + reqs[reqIdx].getResource().getPresentationName());
- }
- }
- else
- {
- System.out.println("Could not resolve targets.");
- }
- }
- }
-
- }
-
-
- protected Requirement parseRequirement(RepositoryAdmin admin, String req) throws InvalidSyntaxException {
- int p = req.indexOf(':');
- String name;
- String filter;
- if (p > 0) {
- name = req.substring(0, p);
- filter = req.substring(p + 1);
- } else {
- if (req.contains("package")) {
- name = "package";
- } else if (req.contains("service")) {
- name = "service";
- } else {
- name = "bundle";
- }
- filter = req;
- }
- if (!filter.startsWith("(")) {
- filter = "(" + filter + ")";
- }
- return admin.getHelper().requirement(name, filter);
- }
-
- protected Requirement[] parseRequirements(RepositoryAdmin admin, List<String> requirements) throws InvalidSyntaxException {
- Requirement[] reqs = new Requirement[requirements.size()];
- for (int i = 0; i < reqs.length; i++) {
- reqs[i] = parseRequirement(admin, requirements.get(i));
- }
- return reqs;
- }
-
-}
diff --git a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/RefreshUrlCommand.java b/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/RefreshUrlCommand.java
deleted file mode 100644
index 7509842..0000000
--- a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/RefreshUrlCommand.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.obr;
-
-import java.util.List;
-
-import org.apache.felix.bundlerepository.Repository;
-import org.apache.felix.bundlerepository.RepositoryAdmin;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "obr", name = "refreshUrl", description = "Reloads the repositories to obtain a fresh list of bundles.")
-public class RefreshUrlCommand extends ObrCommandSupport {
-
- @Argument(index = 0, name = "urls", description = "Repository URLs to refresh (leave empty for all)", required = false, multiValued = true)
- List<String> urls;
-
- protected void doExecute(RepositoryAdmin admin) throws Exception {
- if (urls != null && !urls.isEmpty()) {
- for (String url : urls) {
- admin.addRepository(url);
- }
- } else {
- Repository[] repos = admin.listRepositories();
- if ((repos != null) && (repos.length > 0)) {
- for (int i = 0; i < repos.length; i++) {
- admin.addRepository(repos[i].getURI());
- }
- }
- }
- }
-
-}
diff --git a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/RemoveUrlCommand.java b/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/RemoveUrlCommand.java
deleted file mode 100644
index 3ae7e4a..0000000
--- a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/RemoveUrlCommand.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.obr;
-
-import java.util.List;
-
-import org.apache.felix.bundlerepository.RepositoryAdmin;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "obr", name = "removeUrl", description = "Removes a list of repository URLs from the OBR service.")
-public class RemoveUrlCommand extends ObrCommandSupport {
-
- @Argument(index = 0, name = "urls", description = "Repository URLs to remove from OBR service", required = true, multiValued = true)
- List<String> urls;
-
- protected void doExecute(RepositoryAdmin admin) throws Exception {
- for (String url : urls) {
- admin.removeRepository(url);
- }
- }
-}
diff --git a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/ResolveCommand.java b/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/ResolveCommand.java
deleted file mode 100644
index 251f63f..0000000
--- a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/ResolveCommand.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.obr;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.felix.bundlerepository.Reason;
-import org.apache.felix.bundlerepository.Repository;
-import org.apache.felix.bundlerepository.RepositoryAdmin;
-import org.apache.felix.bundlerepository.Requirement;
-import org.apache.felix.bundlerepository.Resolver;
-import org.apache.felix.bundlerepository.Resource;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.Option;
-
-@Command(scope = "obr", name = "resolve", description = "Show the resolution output for a given set of requirements")
-public class ResolveCommand extends ObrCommandSupport {
-
- @Option(name = "-w", aliases = "--why", description = "Display the reason of the inclusion of the resource")
- boolean why;
-
- @Option(name = "-l", aliases = "--no-local", description = "Ignore local resources during resolution")
- boolean noLocal;
-
- @Option(name = "--no-remote", description = "Ignore remote resources during resolution")
- boolean noRemote;
-
- @Option(name = "--deploy", description = "Deploy the selected bundles")
- boolean deploy;
-
- @Option(name = "--start", description = "Deploy and start the selected bundles")
- boolean start;
-
- @Option(name = "--optional", description = "Resolve optional dependencies")
- boolean optional;
-
- @Argument(index = 0, name = "requirements", description = "Requirements", required = true, multiValued = true)
- List<String> requirements;
-
- protected void doExecute(RepositoryAdmin admin) throws Exception {
- List<Repository> repositories = new ArrayList<Repository>();
- repositories.add(admin.getSystemRepository());
- if (!noLocal) {
- repositories.add(admin.getLocalRepository());
- }
- if (!noRemote) {
- repositories.addAll(Arrays.asList(admin.listRepositories()));
- }
- Resolver resolver = admin.resolver(repositories.toArray(new Repository[repositories.size()]));
- for (Requirement requirement : parseRequirements(admin, requirements)) {
- resolver.add(requirement);
- }
- if (resolver.resolve(optional ? 0 : Resolver.NO_OPTIONAL_RESOURCES)) {
- Resource[] resources;
- resources = resolver.getRequiredResources();
- if ((resources != null) && (resources.length > 0)) {
- System.out.println("Required resource(s):");
- printUnderline(System.out, 21);
- for (int resIdx = 0; resIdx < resources.length; resIdx++) {
- System.out.println(" " + resources[resIdx].getPresentationName() + " (" + resources[resIdx].getVersion() + ")");
- if (why) {
- Reason[] req = resolver.getReason(resources[resIdx]);
- for (int reqIdx = 0; req != null && reqIdx < req.length; reqIdx++) {
- if (!req[reqIdx].getRequirement().isOptional()) {
- Resource r = req[reqIdx].getResource();
- if (r != null) {
- System.out.println(" - " + r.getPresentationName() + " / " + req[reqIdx].getRequirement().getName() + ":" + req[reqIdx].getRequirement().getFilter());
- } else {
- System.out.println(" - " + req[reqIdx].getRequirement().getName() + ":" + req[reqIdx].getRequirement().getFilter());
- }
- }
- }
- }
- }
- }
- resources = resolver.getOptionalResources();
- if ((resources != null) && (resources.length > 0)) {
- System.out.println();
- System.out.println("Optional resource(s):");
- printUnderline(System.out, 21);
- for (int resIdx = 0; resIdx < resources.length; resIdx++) {
- System.out.println(" " + resources[resIdx].getPresentationName()
- + " (" + resources[resIdx].getVersion() + ")");
- if (why) {
- Reason[] req = resolver.getReason(resources[resIdx]);
- for (int reqIdx = 0; req != null && reqIdx < req.length; reqIdx++) {
- if (!req[reqIdx].getRequirement().isOptional()) {
- Resource r = req[reqIdx].getResource();
- if (r != null) {
- System.out.println(" - " + r.getPresentationName() + " / " + req[reqIdx].getRequirement().getName() + ":" + req[reqIdx].getRequirement().getFilter());
- } else {
- System.out.println(" - " + req[reqIdx].getRequirement().getName() + ":" + req[reqIdx].getRequirement().getFilter());
- }
- }
- }
- }
- }
- }
- if (deploy || start) {
- try
- {
- System.out.print("\nDeploying...");
- resolver.deploy(start ? Resolver.START : 0);
- System.out.println("done.");
- }
- catch (IllegalStateException ex)
- {
- System.err.println(ex);
- }
- }
- } else {
- Reason[] reqs = resolver.getUnsatisfiedRequirements();
- if ((reqs != null) && (reqs.length > 0)) {
- System.out.println("Unsatisfied requirement(s):");
- printUnderline(System.out, 27);
- for (int reqIdx = 0; reqIdx < reqs.length; reqIdx++) {
- System.out.println(" " + reqs[reqIdx].getRequirement().getName() + ":" + reqs[reqIdx].getRequirement().getFilter());
- System.out.println(" " +reqs[reqIdx].getResource().getPresentationName());
- }
- } else {
- System.out.println("Could not resolve targets.");
- }
- }
- }
-
-}
\ No newline at end of file
diff --git a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/SourceCommand.java b/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/SourceCommand.java
deleted file mode 100644
index 403b05c..0000000
--- a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/SourceCommand.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.obr;
-
-import java.net.URI;
-import java.net.URL;
-import java.util.List;
-
-import org.apache.felix.bundlerepository.RepositoryAdmin;
-import org.apache.felix.bundlerepository.Resource;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.karaf.shell.obr.util.FileUtil;
-
-@Command(scope = "obr", name = "source", description = "Download the sources for an OBR bundle.")
-public class SourceCommand extends ObrCommandSupport {
-
- @Option(name = "-x", aliases = {}, description = "Extract the archive", required = false, multiValued = false)
- boolean extract;
-
- @Argument(index = 0, name = "folder", description = "Local folder for storing sources", required = true, multiValued = false)
- String localDir;
-
- @Argument(index = 1, name = "bundles", description = "List of bundles to download the sources for", required = true, multiValued = true)
- List<String> bundles;
-
- protected void doExecute(RepositoryAdmin admin) throws Exception {
- for (String bundle : bundles) {
- String[] target = getTarget(bundle);
- Resource resource = selectNewestVersion(searchRepository(admin, target[0], target[1]));
- if (resource == null)
- {
- System.err.println("Unknown bundle and/or version: " + target[0]);
- }
- else
- {
- URI srcURL = (URI) resource.getProperties().get(Resource.SOURCE_URI);
- if (srcURL != null)
- {
- FileUtil.downloadSource(System.out, System.err, srcURL.toURL(), localDir, extract);
- }
- else
- {
- System.err.println("Missing source URL: " + target[0]);
- }
- }
- }
- }
-
-}
diff --git a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/StartCommand.java b/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/StartCommand.java
deleted file mode 100644
index f662881..0000000
--- a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/StartCommand.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.obr;
-
-import org.apache.felix.bundlerepository.RepositoryAdmin;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "obr", name = "start", description = "Deploy and start a list of bundles using OBR.")
-public class StartCommand extends DeployCommand {
-
- protected void doExecute(RepositoryAdmin admin) throws Exception {
- doDeploy(admin, bundles, true);
- }
-
-}
diff --git a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/util/FileUtil.java b/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/util/FileUtil.java
deleted file mode 100644
index 7ebfbb4..0000000
--- a/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/util/FileUtil.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.obr.util;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.PrintStream;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.jar.JarEntry;
-import java.util.jar.JarInputStream;
-
-public class FileUtil
-{
- public static void downloadSource(
- PrintStream out, PrintStream err,
- URL srcURL, String dirStr, boolean extract)
- {
- // Get the file name from the URL.
- String fileName = (srcURL.getFile().lastIndexOf('/') > 0)
- ? srcURL.getFile().substring(srcURL.getFile().lastIndexOf('/') + 1)
- : srcURL.getFile();
-
- try
- {
- out.println("Connecting...");
-
- File dir = new File(dirStr);
- if (!dir.exists())
- {
- err.println("Destination directory does not exist.");
- }
- File file = new File(dir, fileName);
-
- OutputStream os = new FileOutputStream(file);
- URLConnection conn = srcURL.openConnection();
- int total = conn.getContentLength();
- InputStream is = conn.getInputStream();
-
- if (total > 0)
- {
- out.println("Downloading " + fileName
- + " ( " + total + " bytes ).");
- }
- else
- {
- out.println("Downloading " + fileName + ".");
- }
- byte[] buffer = new byte[4096];
- int count = 0;
- for (int len = is.read(buffer); len > 0; len = is.read(buffer))
- {
- count += len;
- os.write(buffer, 0, len);
- }
-
- os.close();
- is.close();
-
- if (extract)
- {
- is = new FileInputStream(file);
- JarInputStream jis = new JarInputStream(is);
- out.println("Extracting...");
- unjar(jis, dir);
- jis.close();
- file.delete();
- }
- }
- catch (Exception ex)
- {
- err.println(ex);
- }
- }
-
- public static void unjar(JarInputStream jis, File dir)
- throws IOException
- {
- // Reusable buffer.
- byte[] buffer = new byte[4096];
-
- // Loop through JAR entries.
- for (JarEntry je = jis.getNextJarEntry();
- je != null;
- je = jis.getNextJarEntry())
- {
- if (je.getName().startsWith("/"))
- {
- throw new IOException("JAR resource cannot contain absolute paths.");
- }
-
- File target = new File(dir, je.getName());
-
- // Check to see if the JAR entry is a directory.
- if (je.isDirectory())
- {
- if (!target.exists())
- {
- if (!target.mkdirs())
- {
- throw new IOException("Unable to create target directory: "
- + target);
- }
- }
- // Just continue since directories do not have content to copy.
- continue;
- }
-
- int lastIndex = je.getName().lastIndexOf('/');
- String name = (lastIndex >= 0) ?
- je.getName().substring(lastIndex + 1) : je.getName();
- String destination = (lastIndex >= 0) ?
- je.getName().substring(0, lastIndex) : "";
-
- // JAR files use '/', so convert it to platform separator.
- destination = destination.replace('/', File.separatorChar);
- copy(jis, dir, name, destination, buffer);
- }
- }
-
- public static void copy(
- InputStream is, File dir, String destName, String destDir, byte[] buffer)
- throws IOException
- {
- if (destDir == null)
- {
- destDir = "";
- }
-
- // Make sure the target directory exists and
- // that is actually a directory.
- File targetDir = new File(dir, destDir);
- if (!targetDir.exists())
- {
- if (!targetDir.mkdirs())
- {
- throw new IOException("Unable to create target directory: "
- + targetDir);
- }
- }
- else if (!targetDir.isDirectory())
- {
- throw new IOException("Target is not a directory: "
- + targetDir);
- }
-
- BufferedOutputStream bos = new BufferedOutputStream(
- new FileOutputStream(new File(targetDir, destName)));
- int count = 0;
- while ((count = is.read(buffer)) > 0)
- {
- bos.write(buffer, 0, count);
- }
- bos.close();
- }
-}
diff --git a/karaf/shell/obr/src/main/resources/OSGI-INF/blueprint/shell-obr.xml b/karaf/shell/obr/src/main/resources/OSGI-INF/blueprint/shell-obr.xml
deleted file mode 100644
index b56ed03..0000000
--- a/karaf/shell/obr/src/main/resources/OSGI-INF/blueprint/shell-obr.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <command-bundle xmlns="http://felix.apache.org/karaf/xmlns/shell/v1.0.0">
- <command name="obr/addUrl">
- <action class="org.apache.felix.karaf.shell.obr.AddUrlCommand"/>
- </command>
- <command name="obr/deploy">
- <action class="org.apache.felix.karaf.shell.obr.DeployCommand"/>
- </command>
- <command name="obr/find">
- <action class="org.apache.felix.karaf.shell.obr.FindCommand"/>
- </command>
- <command name="obr/info">
- <action class="org.apache.felix.karaf.shell.obr.InfoCommand"/>
- </command>
- <command name="obr/list">
- <action class="org.apache.felix.karaf.shell.obr.ListCommand"/>
- </command>
- <command name="obr/listUrl">
- <action class="org.apache.felix.karaf.shell.obr.ListUrlCommand"/>
- </command>
- <command name="obr/refreshUrl">
- <action class="org.apache.felix.karaf.shell.obr.RefreshUrlCommand"/>
- </command>
- <command name="obr/removeUrl">
- <action class="org.apache.felix.karaf.shell.obr.RemoveUrlCommand"/>
- </command>
- <command name="obr/resolve">
- <action class="org.apache.felix.karaf.shell.obr.ResolveCommand"/>
- </command>
- <command name="obr/source">
- <action class="org.apache.felix.karaf.shell.obr.SourceCommand"/>
- </command>
- <command name="obr/start">
- <action class="org.apache.felix.karaf.shell.obr.StartCommand"/>
- </command>
- </command-bundle>
-
-</blueprint>
diff --git a/karaf/shell/osgi/NOTICE b/karaf/shell/osgi/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/shell/osgi/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/shell/osgi/pom.xml b/karaf/shell/osgi/pom.xml
deleted file mode 100644
index 16c2789..0000000
--- a/karaf/shell/osgi/pom.xml
+++ /dev/null
@@ -1,99 +0,0 @@
-<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/maven-v4_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.felix.karaf.shell</groupId>
- <artifactId>shell</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.osgi</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Shell OSGi Commands</name>
-
- <description>
- Provides the OSGi Shell commands
- </description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-extender</artifactId>
- <optional>true</optional>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Import-Package>
- !${project.artifactId}*,
- org.osgi.service.command,
- org.apache.felix.gogo.commands,
- org.apache.felix.karaf.shell.console,
- org.springframework*;resolution:=optional,
- *
- </Import-Package>
- <DynamicImport-Package>
- org.springframework.*
- </DynamicImport-Package>
- <Private-Package>!*</Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/BlueprintListener.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/BlueprintListener.java
deleted file mode 100644
index 5c02f11..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/BlueprintListener.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleListener;
-import org.osgi.service.blueprint.container.BlueprintEvent;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-
-/**
- *
- * TODO: use event admin to receive WAIT topics notifications from blueprint extender
- *
- */
-public class BlueprintListener implements org.osgi.service.blueprint.container.BlueprintListener, BundleListener,
- BundleStateListener, BundleStateListener.Factory
-{
-
- public static enum BlueprintState {
- Unknown,
- Creating,
- Created,
- Destroying,
- Destroyed,
- Failure,
- GracePeriod,
- Waiting
- }
-
- private static final Logger LOG = LoggerFactory.getLogger(BlueprintListener.class);
-
- private final Map<Long, BlueprintState> states;
- private BundleContext bundleContext;
-
- public BlueprintListener() {
- this.states = new ConcurrentHashMap<Long, BlueprintState>();
- }
-
- public String getName() {
- return "Blueprint ";
- }
-
- public String getState(Bundle bundle) {
- BlueprintState state = states.get(bundle.getBundleId());
- if (state == null || bundle.getState() != Bundle.ACTIVE || state == BlueprintState.Unknown) {
- return null;
- }
- return state.toString();
- }
-
- public BundleStateListener getListener() {
- return this;
- }
-
- public BlueprintState getBlueprintState(Bundle bundle) {
- BlueprintState state = states.get(bundle.getBundleId());
- if (state == null || bundle.getState() != Bundle.ACTIVE) {
- state = BlueprintState.Unknown;
- }
- return state;
- }
-
- public void blueprintEvent(BlueprintEvent blueprintEvent) {
- BlueprintState state = getState(blueprintEvent);
- LOG.debug("Blueprint app state changed to " + state + " for bundle " + blueprintEvent.getBundle().getBundleId());
- states.put(blueprintEvent.getBundle().getBundleId(), state);
- }
-
- public void bundleChanged(BundleEvent event) {
- if (event.getType() == BundleEvent.UNINSTALLED) {
- states.remove(event.getBundle().getBundleId());
- }
- }
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- public void init() throws Exception {
- bundleContext.addBundleListener(this);
- }
-
- public void destroy() throws Exception {
- bundleContext.removeBundleListener(this);
- }
-
- private BlueprintState getState(BlueprintEvent blueprintEvent) {
- switch (blueprintEvent.getType()) {
- case BlueprintEvent.CREATING:
- return BlueprintState.Creating;
- case BlueprintEvent.CREATED:
- return BlueprintState.Created;
- case BlueprintEvent.DESTROYING:
- return BlueprintState.Destroying;
- case BlueprintEvent.DESTROYED:
- return BlueprintState.Destroyed;
- case BlueprintEvent.FAILURE:
- return BlueprintState.Failure;
- case BlueprintEvent.GRACE_PERIOD:
- return BlueprintState.GracePeriod;
- case BlueprintEvent.WAITING:
- return BlueprintState.Waiting;
- default:
- return BlueprintState.Unknown;
- }
- }
-}
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/BundleCommand.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/BundleCommand.java
deleted file mode 100644
index f5f074d..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/BundleCommand.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Argument;
-import org.osgi.framework.Bundle;
-
-public abstract class BundleCommand extends OsgiCommandSupport {
-
- @Argument(index = 0, name = "id", description = "The bundle ID", required = true, multiValued = false)
- long id;
-
- @Option(name = "--force", aliases = {}, description = "Forces the command to execute", required = false, multiValued = false)
- boolean force;
-
- protected Object doExecute() throws Exception {
- Bundle bundle = getBundleContext().getBundle(id);
- if (bundle == null) {
- System.out.println("Bundle " + id + " not found");
- return null;
- }
-
- if (!force && Util.isASystemBundle(getBundleContext(), bundle) && !Util.accessToSystemBundleIsAllowed(bundle.getBundleId(), session)) {
- return null;
- } else {
- doExecute(bundle);
- return null;
- }
- }
-
- protected abstract void doExecute(Bundle bundle) throws Exception;
-}
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/BundleLevel.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/BundleLevel.java
deleted file mode 100644
index 3eca185..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/BundleLevel.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.startlevel.StartLevel;
-
-@Command(scope = "osgi", name = "bundle-level", description = "Get or set the start level of a given bundle")
-public class BundleLevel extends BundleCommand {
-
- @Argument(index = 1, name = "startLevel", description = "The bundles new start level", required = false, multiValued = false)
- Integer level;
-
- protected void doExecute(Bundle bundle) throws Exception {
- // Get package admin service.
- ServiceReference ref = getBundleContext().getServiceReference(StartLevel.class.getName());
- if (ref == null) {
- System.out.println("StartLevel service is unavailable.");
- return;
- }
- StartLevel sl = getService(StartLevel.class, ref);
- if (sl == null) {
- System.out.println("StartLevel service is unavailable.");
- return;
- }
-
- if (level == null) {
- System.out.println("Level " + sl.getBundleStartLevel(bundle));
- }
- else if ((level < 50) && sl.getBundleStartLevel(bundle) > 50){
- for (;;) {
- StringBuffer sb = new StringBuffer();
- System.err.println("You are about to designate bundle as a system bundle. Do you want to continue (yes/no): ");
- System.err.flush();
- for (;;) {
- int c = System.in.read();
- if (c < 0) {
- return;
- }
- System.err.println((char) c);
- if (c == '\r' || c == '\n') {
- break;
- }
- sb.append((char) c);
- }
- String str = sb.toString();
- if ("yes".equals(str)) {
- sl.setBundleStartLevel(bundle, level);
- break;
- } else if ("no".equals(str)) {
- break;
- }
- }
- } else {
- sl.setBundleStartLevel(bundle, level);
- }
- }
-
-}
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/BundleStateListener.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/BundleStateListener.java
deleted file mode 100644
index 3f37c48..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/BundleStateListener.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import org.osgi.framework.Bundle;
-
-public interface BundleStateListener {
-
- public interface Factory {
-
- BundleStateListener getListener();
-
- }
-
- String getName();
-
- String getState(Bundle bundle);
-
-}
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/BundlesCommand.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/BundlesCommand.java
deleted file mode 100644
index f2bee4d..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/BundlesCommand.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Option;
-import org.osgi.framework.Bundle;
-
-public abstract class BundlesCommand extends OsgiCommandSupport {
-
- @Argument(index = 0, name = "ids", description = "The list of bundle IDs separated by whitespaces", required = true, multiValued = true)
- List<Long> ids;
-
- @Option(name = "--force", aliases = {}, description = "Forces the command to execute", required = false, multiValued = false)
- boolean force;
-
- protected Object doExecute() throws Exception {
- List<Bundle> bundles = new ArrayList<Bundle>();
- if (ids != null && !ids.isEmpty()) {
- for (long id : ids) {
- Bundle bundle = getBundleContext().getBundle(id);
- if (bundle == null) {
- System.err.println("Bundle ID" + id + " is invalid");
- } else {
- if (force || !Util.isASystemBundle(getBundleContext(), bundle) || Util.accessToSystemBundleIsAllowed(bundle.getBundleId(), session)) {
- bundles.add(bundle);
- }
- }
- }
- }
- doExecute(bundles);
- return null;
- }
-
- protected abstract void doExecute(List<Bundle> bundles) throws Exception;
-}
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/BundlesCommandOptional.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/BundlesCommandOptional.java
deleted file mode 100644
index 13974e0..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/BundlesCommandOptional.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.osgi.framework.Bundle;
-
-public abstract class BundlesCommandOptional extends OsgiCommandSupport {
-
- @Argument(index = 0, name = "ids", description = "The list of bundle IDs separated by whitespaces", required = false, multiValued = true)
- List<Long> ids;
-
- @Option(name = "--force", aliases = {}, description = "Forces the command to execute", required = false, multiValued = false)
- boolean force;
-
- protected Object doExecute() throws Exception {
- List<Bundle> bundles = new ArrayList<Bundle>();
- if (ids != null && !ids.isEmpty()) {
- for (long id : ids) {
- Bundle bundle = getBundleContext().getBundle(id);
- if (bundle == null) {
- System.err.println("Bundle ID" + id + " is invalid");
- } else {
- if (force || !Util.isASystemBundle(getBundleContext(), bundle) || Util.accessToSystemBundleIsAllowed(bundle.getBundleId(), session)) {
- bundles.add(bundle);
- }
- }
- }
- }
- doExecute(bundles);
- return null;
- }
-
- protected abstract void doExecute(List<Bundle> bundles) throws Exception;
-}
\ No newline at end of file
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/Headers.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/Headers.java
deleted file mode 100644
index 712a968..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/Headers.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.List;
-
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.osgi.framework.Bundle;
-
-@Command(scope = "osgi", name = "headers", description = "Displays OSGi headers of a given bundle")
-public class Headers extends OsgiCommandSupport {
-
- @Argument(index = 0, name = "ids", description = "A list of bundle IDs separated by whitespaces", required = false, multiValued = true)
- List<Long> ids;
-
- protected Object doExecute() throws Exception {
- if (ids != null && !ids.isEmpty()) {
- for (long id : ids) {
- Bundle bundle = getBundleContext().getBundle(id);
- if (bundle != null) {
- printHeaders(bundle);
- }
- else {
- System.err.println("Bundle ID " + id + " is invalid.");
- }
- }
- }
- else {
- Bundle[] bundles = getBundleContext().getBundles();
- for (int i = 0; i < bundles.length; i++) {
- printHeaders(bundles[i]);
- }
- }
- return null;
- }
-
- protected void printHeaders(Bundle bundle) throws Exception {
- String title = Util.getBundleName(bundle);
- System.out.println("\n" + title);
- System.out.println(Util.getUnderlineString(title));
- Dictionary dict = bundle.getHeaders();
- Enumeration keys = dict.keys();
- while (keys.hasMoreElements())
- {
- Object k = (String) keys.nextElement();
- Object v = dict.get(k);
- System.out.println(k + " = " + Util.getValueString(v));
- }
- }
-
-}
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/InstallBundle.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/InstallBundle.java
deleted file mode 100644
index c777b51..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/InstallBundle.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Command;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-
-@Command(scope = "osgi", name = "install", description = "Installs one or more bundles")
-public class InstallBundle extends OsgiCommandSupport {
-
- @Argument(index = 0, name = "urls", description = "Bundle URLs separated by whitespaces", required = true, multiValued = true)
- List<String> urls;
-
- @Option(name = "-s", aliases={"--start"}, description="Starts the bundles after installation", required = false, multiValued = false)
- boolean start;
-
- protected Object doExecute() throws Exception {
- List<Bundle> bundles = new ArrayList<Bundle>();
- StringBuffer sb = new StringBuffer();
- for (String url : urls) {
- Bundle bundle = install(url, System.out, System.err);
- if (bundle != null) {
- bundles.add(bundle);
- if (sb.length() > 0) {
- sb.append(", ");
- }
- sb.append(bundle.getBundleId());
- }
- }
- if (start) {
- for (Bundle bundle : bundles) {
- bundle.start();
- }
- }
- if (sb.toString().indexOf(',') > 0) {
- System.out.println("Bundle IDs: " + sb.toString());
- } else if (sb.length() > 0) {
- System.out.println("Bundle ID: " + sb.toString());
- }
- return null;
- }
-
- protected Bundle install(String location, PrintStream out, PrintStream err) {
- try {
- return getBundleContext().installBundle(location, null);
- } catch (IllegalStateException ex) {
- err.println(ex.toString());
- } catch (BundleException ex) {
- if (ex.getNestedException() != null) {
- err.println(ex.getNestedException().toString());
- } else {
- err.println(ex.toString());
- }
- } catch (Exception ex) {
- err.println(ex.toString());
- }
- return null;
- }
-
-}
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/ListBundles.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/ListBundles.java
deleted file mode 100644
index 523ec00..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/ListBundles.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import java.util.List;
-
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Command;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.osgi.service.startlevel.StartLevel;
-
-@Command(scope = "osgi", name = "list", description = "Lists all installed bundles")
-public class ListBundles extends OsgiCommandSupport {
-
- @Option(name = "-l", aliases = {}, description = "Show the locations", required = false, multiValued = false)
- boolean showLoc;
-
- @Option(name = "-s", description = "Shows the symbolic name", required = false, multiValued = false)
- boolean showSymbolic;
-
- @Option(name = "-u", description = "Shows the update locations", required = false, multiValued = false)
- boolean showUpdate;
-
- private List<BundleStateListener.Factory> bundleStateListenerFactories;
-
- public void setBundleStateListenerFactories(List<BundleStateListener.Factory> bundleStateListenerFactories) {
- this.bundleStateListenerFactories = bundleStateListenerFactories;
- }
-
- protected Object doExecute() throws Exception {
- ServiceReference ref = getBundleContext().getServiceReference(StartLevel.class.getName());
- StartLevel sl = null;
- if (ref != null) {
- sl = (StartLevel) getBundleContext().getService(ref);
- }
- if (sl == null) {
- System.out.println("StartLevel service is unavailable.");
- }
-
- ServiceReference pkgref = getBundleContext().getServiceReference(PackageAdmin.class.getName());
- PackageAdmin admin = null;
- if (pkgref != null) {
- admin = (PackageAdmin) getBundleContext().getService(pkgref);
- if (admin == null) {
- System.out.println("PackageAdmin service is unavailable.");
- }
- }
-
- Bundle[] bundles = getBundleContext().getBundles();
- if (bundles != null) {
- // Display active start level.
- if (sl != null) {
- System.out.println("START LEVEL " + sl.getStartLevel());
- }
-
- // Print column headers.
- String msg = " Name";
- if (showLoc) {
- msg = " Location";
- }
- else if (showSymbolic) {
- msg = " Symbolic name";
- }
- else if (showUpdate) {
- msg = " Update location";
- }
- String level = (sl == null) ? "" : " Level ";
- String headers = " ID State ";
- for (BundleStateListener.Factory factory : bundleStateListenerFactories) {
- BundleStateListener listener = factory.getListener();
- if (listener != null) {
- headers += " " + listener.getName() + " ";
- }
- }
- headers += level + msg;
- System.out.println(headers);
- for (int i = 0; i < bundles.length; i++) {
- // Get the bundle name or location.
- String name = (String) bundles[i].getHeaders().get(Constants.BUNDLE_NAME);
- // If there is no name, then default to symbolic name.
- name = (name == null) ? bundles[i].getSymbolicName() : name;
- // If there is no symbolic name, resort to location.
- name = (name == null) ? bundles[i].getLocation() : name;
-
- // Overwrite the default value is the user specifically
- // requested to display one or the other.
- if (showLoc) {
- name = bundles[i].getLocation();
- }
- else if (showSymbolic) {
- name = bundles[i].getSymbolicName();
- name = (name == null) ? "<no symbolic name>" : name;
- }
- else if (showUpdate) {
- name = (String) bundles[i].getHeaders().get(Constants.BUNDLE_UPDATELOCATION);
- name = (name == null) ? bundles[i].getLocation() : name;
- }
- // Show bundle version if not showing location.
- String version = (String) bundles[i].getHeaders().get(Constants.BUNDLE_VERSION);
- name = (!showLoc && !showUpdate && (version != null)) ? name + " (" + version + ")" : name;
- long l = bundles[i].getBundleId();
- String id = String.valueOf(l);
- if (sl == null) {
- level = "1";
- }
- else {
- level = String.valueOf(sl.getBundleStartLevel(bundles[i]));
- }
- while (level.length() < 5) {
- level = " " + level;
- }
- while (id.length() < 4) {
- id = " " + id;
- }
- String line = "[" + id + "] [" + getStateString(bundles[i]) + "]";
- for (BundleStateListener.Factory factory : bundleStateListenerFactories) {
- BundleStateListener listener = factory.getListener();
- if (listener != null) {
- String state = listener.getState(bundles[i]);
- line += " [" + getStateString(state, listener.getName().length()) + "]";
- }
- }
- line += " [" + level + "] " + name;
- System.out.println(line);
-
- if (admin != null) {
- Bundle[] fragments = admin.getFragments(bundles[i]);
- Bundle[] hosts = admin.getHosts(bundles[i]);
-
- if (fragments != null) {
- System.out.print(" Fragments: ");
- int ii = 0;
- for (Bundle fragment : fragments) {
- ii++;
- System.out.print(fragment.getBundleId());
- if ((fragments.length > 1) && ii < (fragments.length)) {
- System.out.print(",");
- }
- }
- System.out.println();
- }
-
- if (hosts != null) {
- System.out.print(" Hosts: ");
- int ii = 0;
- for (Bundle host : hosts) {
- ii++;
- System.out.print(host.getBundleId());
- if ((hosts.length > 1) && ii < (hosts.length)) {
- System.out.print(",");
- }
- }
- System.out.println();
- }
-
- }
- }
- }
- else {
- System.out.println("There are no installed bundles.");
- }
-
- getBundleContext().ungetService(ref);
- getBundleContext().ungetService(pkgref);
-
- return null;
- }
-
- public String getStateString(Bundle bundle)
- {
- int state = bundle.getState();
- if (state == Bundle.ACTIVE) {
- return "Active ";
- } else if (state == Bundle.INSTALLED) {
- return "Installed ";
- } else if (state == Bundle.RESOLVED) {
- return "Resolved ";
- } else if (state == Bundle.STARTING) {
- return "Starting ";
- } else if (state == Bundle.STOPPING) {
- return "Stopping ";
- } else {
- return "Unknown ";
- }
- }
-
- public String getStateString(String state, int length) {
- if (state == null) {
- state = "";
- }
- while (state.length() < length) {
- state += " ";
- }
- return state;
- }
-}
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/ListServices.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/ListServices.java
deleted file mode 100644
index 8685df7..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/ListServices.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import java.util.List;
-
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Command;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.command.Function;
-
-@Command(scope = "osgi", name = "ls", description = "Lists OSGi services")
-public class ListServices extends OsgiCommandSupport {
-
- @Option(name = "-a", aliases = {}, description = "Shows all services", required = false, multiValued = false)
- boolean showAll;
-
- @Option(name = "-u", aliases = {}, description = "Shows services which are in use", required = false, multiValued = false)
- boolean inUse;
-
- @Argument(index = 0, name = "ids", description = "Show only services for the given bundle ids", required = false, multiValued = true)
- List<Long> ids;
-
- protected Object doExecute() throws Exception {
- if (ids != null && !ids.isEmpty()) {
- for (long id : ids) {
- Bundle bundle = getBundleContext().getBundle(id);
- if (bundle != null) {
- boolean headerPrinted = false;
- boolean needSeparator = false;
- ServiceReference[] refs = null;
-
- // Get registered or in-use services.
- if (inUse) {
- refs = bundle.getServicesInUse();
- } else {
- refs = bundle.getRegisteredServices();
- }
-
- // Print properties for each service.
- for (int refIdx = 0;
- (refs != null) && (refIdx < refs.length);
- refIdx++) {
- String[] objectClass = (String[])
- refs[refIdx].getProperty("objectClass");
-
- // Determine if we need to print the service, depending
- // on whether it is a command service or not.
- boolean print = true;
- for (int ocIdx = 0;
- !showAll && (ocIdx < objectClass.length);
- ocIdx++) {
- if (objectClass[ocIdx].equals(Function.class.getName())) {
- print = false;
- }
- }
-
- // Print header if we have not already done so.
- if (!headerPrinted) {
- headerPrinted = true;
- String title = Util.getBundleName(bundle);
- title = (inUse)
- ? title + " uses:"
- : title + " provides:";
- System.out.println("");
- System.out.println(title);
- System.out.println(Util.getUnderlineString(title));
- }
-
- if (showAll || print) {
- // Print service separator if necessary.
- if (needSeparator) {
- System.out.println("----");
- }
-
- // Print service properties.
- String[] keys = refs[refIdx].getPropertyKeys();
- for (int keyIdx = 0;
- (keys != null) && (keyIdx < keys.length);
- keyIdx++) {
- Object v = refs[refIdx].getProperty(keys[keyIdx]);
- System.out.println(
- keys[keyIdx] + " = " + Util.getValueString(v));
- }
-
- needSeparator = true;
- }
- }
- } else {
- System.err.println("Bundle ID " + id + " is invalid.");
- }
- }
- }
- else
- {
- Bundle[] bundles = getBundleContext().getBundles();
- if (bundles != null)
- {
- // TODO: Sort list.
- for (int bundleIdx = 0; bundleIdx < bundles.length; bundleIdx++)
- {
- boolean headerPrinted = false;
- ServiceReference[] refs = null;
-
- // Get registered or in-use services.
- if (inUse)
- {
- refs = bundles[bundleIdx].getServicesInUse();
- }
- else
- {
- refs = bundles[bundleIdx].getRegisteredServices();
- }
-
- for (int refIdx = 0; (refs != null) && (refIdx < refs.length); refIdx++)
- {
- String[] objectClass = (String[])
- refs[refIdx].getProperty("objectClass");
-
- // Determine if we need to print the service, depending
- // on whether it is a command service or not.
- boolean print = true;
- for (int ocIdx = 0;
- !showAll && (ocIdx < objectClass.length);
- ocIdx++)
- {
- if (objectClass[ocIdx].equals(Function.class.getName()))
- {
- print = false;
- }
- }
-
- // Print the service if necessary.
- if (showAll || print)
- {
- if (!headerPrinted)
- {
- headerPrinted = true;
- String title = Util.getBundleName(bundles[bundleIdx]);
- title = (inUse)
- ? title + " uses:"
- : title + " provides:";
- System.out.println("\n" + title);
- System.out.println(Util.getUnderlineString(title));
- }
- System.out.println(Util.getValueString(objectClass));
- }
- }
- }
- }
- else
- {
- System.out.println("There are no registered services.");
- }
- }
- return null;
- }
-
-}
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/RefreshBundle.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/RefreshBundle.java
deleted file mode 100644
index 4bca7d0..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/RefreshBundle.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import java.util.List;
-
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-@Command(scope = "osgi", name = "refresh", description = "Refresh a bundle")
-public class RefreshBundle extends BundlesCommandOptional {
-
- protected void doExecute(List<Bundle> bundles) throws Exception {
- // Get package admin service.
- ServiceReference ref = getBundleContext().getServiceReference(PackageAdmin.class.getName());
- if (ref == null) {
- System.out.println("PackageAdmin service is unavailable.");
- return;
- }
- try {
- PackageAdmin pa = (PackageAdmin) getBundleContext().getService(ref);
- if (pa == null) {
- System.out.println("PackageAdmin service is unavailable.");
- return;
- }
- if (bundles.isEmpty()) {
- pa.refreshPackages(null);
- }
- else {
- pa.refreshPackages(bundles.toArray(new Bundle[bundles.size()]));
- }
- }
- finally {
- getBundleContext().ungetService(ref);
- }
- }
-}
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/ResolveBundle.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/ResolveBundle.java
deleted file mode 100644
index b717e9d..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/ResolveBundle.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import java.util.List;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "osgi", name = "resolve", description = "Resolve bundle(s)")
-public class ResolveBundle extends BundlesCommandOptional {
-
- protected void doExecute(List<Bundle> bundles) throws Exception {
- // Get package admin service.
- ServiceReference ref = getBundleContext().getServiceReference(PackageAdmin.class.getName());
- if (ref == null) {
- System.out.println("PackageAdmin service is unavailable.");
- return;
- }
- try {
- PackageAdmin pa = (PackageAdmin) getBundleContext().getService(ref);
- if (pa == null) {
- System.out.println("PackageAdmin service is unavailable.");
- return;
- }
- if (bundles.isEmpty()) {
- pa.resolveBundles(null);
- } else {
- pa.resolveBundles(bundles.toArray(new Bundle[bundles.size()]));
- }
- }
- finally {
- getBundleContext().ungetService(ref);
- }
- }
-
-}
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/RestartBundle.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/RestartBundle.java
deleted file mode 100644
index 9085395..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/RestartBundle.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import java.util.List;
-
-import org.osgi.framework.Bundle;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "osgi", name = "restart", description = "Stop and restart bundle(s)")
-public class RestartBundle extends BundlesCommand {
-
- protected void doExecute(List<Bundle> bundles) throws Exception {
- for (Bundle bundle : bundles) {
- bundle.stop();
- }
- for (Bundle bundle : bundles) {
- bundle.start();
- }
- }
-
-}
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/Shutdown.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/Shutdown.java
deleted file mode 100644
index 12d364b..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/Shutdown.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Command;
-import org.osgi.framework.Bundle;
-
-/**
- * Command to shut down Karaf
- */
-@Command(scope = "osgi", name = "shutdown", description = "Shuts the framework down")
-public class Shutdown extends OsgiCommandSupport {
-
- protected Object doExecute() throws Exception {
- new Thread() {
- public void run() {
- try {
- Bundle bundle = getBundleContext().getBundle(0);
- bundle.stop();
- } catch (Exception e) {
- log.error("Error when shutting down Apache Felix Karaf", e);
- }
- }
- }.start();
- return null;
- }
-
-}
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/SpringStateListenerFactory.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/SpringStateListenerFactory.java
deleted file mode 100644
index 9a0069c..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/SpringStateListenerFactory.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import java.util.Map;
-import java.util.Hashtable;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.springframework.osgi.context.event.OsgiBundleApplicationContextListener;
-import org.springframework.osgi.context.event.OsgiBundleApplicationContextEvent;
-import org.springframework.osgi.context.event.OsgiBundleContextFailedEvent;
-import org.springframework.osgi.context.event.OsgiBundleContextRefreshedEvent;
-import org.springframework.osgi.extender.event.BootstrappingDependencyEvent;
-import org.springframework.osgi.service.importer.event.OsgiServiceDependencyEvent;
-import org.springframework.osgi.service.importer.event.OsgiServiceDependencyWaitStartingEvent;
-import org.osgi.framework.BundleListener;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.ServiceRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class SpringStateListenerFactory implements BundleStateListener.Factory {
-
- private BundleContext bundleContext;
- private BundleStateListener listener;
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- public void init() {
- getListener();
- }
-
- public void destroy() throws Exception {
- if (listener instanceof Destroyable) {
- ((Destroyable) listener).destroy();
- }
- }
-
- public synchronized BundleStateListener getListener() {
- if (listener == null) {
- listener = createListener();
- }
- return listener;
- }
-
- private BundleStateListener createListener() {
- try {
- // Use dynamic class loading to make sure we actually try to reload the class for
- // dynamic imports to kick in if possible
- Class cl = getClass().getClassLoader().loadClass("org.apache.felix.karaf.shell.osgi.SpringStateListenerFactory$SpringApplicationListener");
- return (BundleStateListener) cl.getConstructor(BundleContext.class).newInstance(bundleContext);
-// return new SpringApplicationListener(bundleContext);
- } catch (Throwable t) {
- return null;
- }
- }
-
- public static interface Destroyable {
-
- public void destroy() throws Exception;
-
- }
-
- public static class SpringApplicationListener implements OsgiBundleApplicationContextListener,
- BundleListener, Destroyable, BundleStateListener {
-
- public static enum SpringState {
- Unknown,
- Waiting,
- Started,
- Failed,
- }
-
- private static final Logger LOG = LoggerFactory.getLogger(BlueprintListener.class);
-
- private final Map<Long, SpringState> states;
- private BundleContext bundleContext;
- private ServiceRegistration registration;
-
- public SpringApplicationListener(BundleContext bundleContext) {
- this.states = new ConcurrentHashMap<Long, SpringState>();
- this.bundleContext = bundleContext;
- this.bundleContext.addBundleListener(this);
- this.registration = this.bundleContext.registerService(OsgiBundleApplicationContextListener.class.getName(), this, new Hashtable());
- }
-
- public void destroy() throws Exception {
- bundleContext.removeBundleListener(this);
- registration.unregister();
- }
-
- public String getName() {
- return "Spring ";
- }
-
- public String getState(Bundle bundle) {
- SpringState state = states.get(bundle.getBundleId());
- if (state == null || bundle.getState() != Bundle.ACTIVE || state == SpringState.Unknown) {
- return null;
- }
- return state.toString();
- }
-
- public SpringState getSpringState(Bundle bundle) {
- SpringState state = states.get(bundle.getBundleId());
- if (state == null || bundle.getState() != Bundle.ACTIVE) {
- state = SpringState.Unknown;
- }
- return state;
- }
-
- public void onOsgiApplicationEvent(OsgiBundleApplicationContextEvent event) {
- SpringState state = null;
- if (event instanceof BootstrappingDependencyEvent) {
- OsgiServiceDependencyEvent de = ((BootstrappingDependencyEvent) event).getDependencyEvent();
- if (de instanceof OsgiServiceDependencyWaitStartingEvent) {
- state = SpringState.Waiting;
- }
- } else if (event instanceof OsgiBundleContextFailedEvent) {
- state = SpringState.Failed;
- } else if (event instanceof OsgiBundleContextRefreshedEvent) {
- state = SpringState.Started;
- }
- if (state != null) {
- LOG.debug("Spring app state changed to " + state + " for bundle " + event.getBundle().getBundleId());
- states.put(event.getBundle().getBundleId(), state);
- }
- }
-
- public void bundleChanged(BundleEvent event) {
- if (event.getType() == BundleEvent.UNINSTALLED) {
- states.remove(event.getBundle().getBundleId());
- }
- }
-
- }
-
-}
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/StartBundle.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/StartBundle.java
deleted file mode 100644
index 4a0cb0f..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/StartBundle.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import java.util.List;
-
-import org.osgi.framework.Bundle;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "osgi", name = "start", description = "Start bundle(s)")
-public class StartBundle extends BundlesCommand {
-
- protected void doExecute(List<Bundle> bundles) throws Exception {
- for (Bundle bundle : bundles) {
- bundle.start();
- }
- }
-
-}
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/StartLevel.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/StartLevel.java
deleted file mode 100644
index d266422..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/StartLevel.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.osgi.framework.ServiceReference;
-
-@Command(scope = "osgi", name = "start-level", description = "Get or set the system start level")
-public class StartLevel extends OsgiCommandSupport {
-
- @Argument(index = 0, name = "level", description = "The new system start level to set", required = false, multiValued = false)
- Integer level;
-
- protected Object doExecute() throws Exception {
- // Get package admin service.
- ServiceReference ref = getBundleContext().getServiceReference(org.osgi.service.startlevel.StartLevel.class.getName());
- if (ref == null) {
- System.out.println("StartLevel service is unavailable.");
- return null;
- }
- try {
- org.osgi.service.startlevel.StartLevel sl = (org.osgi.service.startlevel.StartLevel) getBundleContext().getService(ref);
- if (sl == null) {
- System.out.println("StartLevel service is unavailable.");
- return null;
- }
-
- if (level == null) {
- System.out.println("Level " + sl.getStartLevel());
- }
- else {
- sl.setStartLevel(level);
- }
- }
- finally {
- getBundleContext().ungetService(ref);
- }
- return null;
- }
-
-}
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/StopBundle.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/StopBundle.java
deleted file mode 100644
index 5036e01..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/StopBundle.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import java.util.List;
-
-import org.osgi.framework.Bundle;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "osgi", name = "stop", description = "Stop bundle(s)")
-public class StopBundle extends BundlesCommand {
-
- protected void doExecute(List<Bundle> bundles) throws Exception {
- for (Bundle bundle : bundles) {
- bundle.stop();
- }
- }
-
-}
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/UninstallBundle.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/UninstallBundle.java
deleted file mode 100644
index e8a8e51..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/UninstallBundle.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import java.util.List;
-
-import org.osgi.framework.Bundle;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "osgi", name = "uninstall", description = "Uninstall bundle(s)")
-public class UninstallBundle extends BundlesCommand {
-
- protected void doExecute(List<Bundle> bundles) throws Exception {
- for (Bundle bundle : bundles) {
- bundle.uninstall();
- }
- }
-
-}
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/UpdateBundle.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/UpdateBundle.java
deleted file mode 100644
index 6ee1a0a..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/UpdateBundle.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import java.io.InputStream;
-import java.net.URL;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.osgi.framework.Bundle;
-
-@Command(scope = "osgi", name = "update", description = "Update bundle")
-public class UpdateBundle extends BundleCommand {
-
- @Argument(index = 1, name = "location", description = "The bundles update location", required = false, multiValued = false)
- String location;
-
- protected void doExecute(Bundle bundle) throws Exception {
- if (location != null) {
- InputStream is = new URL(location).openStream();
- bundle.update(is);
- } else {
- bundle.update();
- }
- }
-
-}
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/Util.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/Util.java
deleted file mode 100644
index 94071df..0000000
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/Util.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.osgi;
-
-import java.io.IOException;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.startlevel.StartLevel;
-import org.osgi.service.command.CommandSession;
-
-public class Util
-{
- public static String getBundleName(Bundle bundle)
- {
- if (bundle != null)
- {
- String name = (String) bundle.getHeaders().get(Constants.BUNDLE_NAME);
- return (name == null)
- ? "Bundle " + Long.toString(bundle.getBundleId())
- : name + " (" + Long.toString(bundle.getBundleId()) + ")";
- }
- return "[STALE BUNDLE]";
- }
-
- private static StringBuffer m_sb = new StringBuffer();
-
- public static String getUnderlineString(String s)
- {
- synchronized (m_sb)
- {
- m_sb.delete(0, m_sb.length());
- for (int i = 0; i < s.length(); i++)
- {
- m_sb.append('-');
- }
- return m_sb.toString();
- }
- }
-
- public static String getValueString(Object obj)
- {
- synchronized (m_sb)
- {
- if (obj instanceof String)
- {
- return (String) obj;
- }
- else if (obj instanceof String[])
- {
- String[] array = (String[]) obj;
- m_sb.delete(0, m_sb.length());
- for (int i = 0; i < array.length; i++)
- {
- if (i != 0)
- {
- m_sb.append(", ");
- }
- m_sb.append(array[i].toString());
- }
- return m_sb.toString();
- }
- else if (obj instanceof Boolean)
- {
- return ((Boolean) obj).toString();
- }
- else if (obj instanceof Long)
- {
- return ((Long) obj).toString();
- }
- else if (obj instanceof Integer)
- {
- return ((Integer) obj).toString();
- }
- else if (obj instanceof Short)
- {
- return ((Short) obj).toString();
- }
- else if (obj instanceof Double)
- {
- return ((Double) obj).toString();
- }
- else if (obj instanceof Float)
- {
- return ((Float) obj).toString();
- }
- else if (obj == null)
- {
- return "null";
- }
- else
- {
- return obj.toString();
- }
- }
- }
-
- /**
- * Check if a bundle is a system bundle (start level < 50)
- *
- * @param bundleContext
- * @param bundle
- * @return true if the bundle has start level minor than 50
- */
- public static boolean isASystemBundle(BundleContext bundleContext, Bundle bundle) {
- ServiceReference ref = bundleContext.getServiceReference(StartLevel.class.getName());
- if (ref != null) {
- StartLevel sl = (StartLevel) bundleContext.getService(ref);
- if (sl != null) {
- int level = sl.getBundleStartLevel(bundle);
- int sbsl = 49;
- final String sbslProp = bundleContext.getProperty( "karaf.systemBundlesStartLevel" );
- if (sbslProp != null) {
- try {
- sbsl = Integer.valueOf( sbslProp );
- }
- catch( Exception ignore ) {
- // ignore
- }
- }
- return level <= sbsl;
- }
- }
- return false;
- }
-
- /**
- * Ask the user to confirm the access to a system bundle
- *
- * @param bundleId
- * @param session
- * @return true if the user confirm
- * @throws IOException
- */
- public static boolean accessToSystemBundleIsAllowed(long bundleId, CommandSession session) throws IOException {
- for (;;) {
- StringBuffer sb = new StringBuffer();
- System.err.print("You are about to access system bundle " + bundleId + ". Do you want to continue (yes/no): ");
- System.err.flush();
- for (;;) {
- int c = session.getKeyboard().read();
- if (c < 0) {
- return false;
- }
- System.err.print((char) c);
- if (c == '\r' || c == '\n') {
- break;
- }
- sb.append((char) c);
- }
- String str = sb.toString();
- if ("yes".equals(str)) {
- return true;
- }
- if ("no".equals(str)) {
- return false;
- }
- }
- }
-
-}
diff --git a/karaf/shell/osgi/src/main/resources/OSGI-INF/blueprint/shell-osgi.xml b/karaf/shell/osgi/src/main/resources/OSGI-INF/blueprint/shell-osgi.xml
deleted file mode 100644
index 9885d4e..0000000
--- a/karaf/shell/osgi/src/main/resources/OSGI-INF/blueprint/shell-osgi.xml
+++ /dev/null
@@ -1,81 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <command-bundle xmlns="http://felix.apache.org/karaf/xmlns/shell/v1.0.0">
- <command name="osgi/bundle-level">
- <action class="org.apache.felix.karaf.shell.osgi.BundleLevel"/>
- </command>
- <command name="osgi/headers">
- <action class="org.apache.felix.karaf.shell.osgi.Headers"/>
- </command>
- <command name="osgi/install">
- <action class="org.apache.felix.karaf.shell.osgi.InstallBundle"/>
- </command>
- <command name="osgi/list">
- <action class="org.apache.felix.karaf.shell.osgi.ListBundles">
- <property name="bundleStateListenerFactories">
- <list xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
- <ref component-id="blueprintListener" />
- <ref component-id="springListener" />
- </list>
- </property>
- </action>
- </command>
- <command name="osgi/ls">
- <action class="org.apache.felix.karaf.shell.osgi.ListServices"/>
- </command>
- <command name="osgi/refresh">
- <action class="org.apache.felix.karaf.shell.osgi.RefreshBundle"/>
- </command>
- <command name="osgi/update">
- <action class="org.apache.felix.karaf.shell.osgi.UpdateBundle"/>
- </command>
- <command name="osgi/resolve">
- <action class="org.apache.felix.karaf.shell.osgi.ResolveBundle"/>
- </command>
- <command name="osgi/restart">
- <action class="org.apache.felix.karaf.shell.osgi.RestartBundle"/>
- </command>
- <command name="osgi/shutdown">
- <action class="org.apache.felix.karaf.shell.osgi.Shutdown"/>
- </command>
- <command name="osgi/start">
- <action class="org.apache.felix.karaf.shell.osgi.StartBundle"/>
- </command>
- <command name="osgi/start-level">
- <action class="org.apache.felix.karaf.shell.osgi.StartLevel"/>
- </command>
- <command name="osgi/stop">
- <action class="org.apache.felix.karaf.shell.osgi.StopBundle"/>
- </command>
- <command name="osgi/uninstall">
- <action class="org.apache.felix.karaf.shell.osgi.UninstallBundle"/>
- </command>
- </command-bundle>
-
- <bean id="blueprintListener" class="org.apache.felix.karaf.shell.osgi.BlueprintListener" />
- <service ref="blueprintListener" interface="org.osgi.service.blueprint.container.BlueprintListener" />
-
- <bean id="springListener" class="org.apache.felix.karaf.shell.osgi.SpringStateListenerFactory" init-method="init" destroy-method="destroy">
- <property name="bundleContext" ref="blueprintBundleContext" />
- </bean>
-
-</blueprint>
\ No newline at end of file
diff --git a/karaf/shell/packages/NOTICE b/karaf/shell/packages/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/shell/packages/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/shell/packages/pom.xml b/karaf/shell/packages/pom.xml
deleted file mode 100644
index 0ad221e..0000000
--- a/karaf/shell/packages/pom.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-<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/maven-v4_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.felix.karaf.shell</groupId>
- <artifactId>shell</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.packages</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Shell PackageAdmin Commands</name>
-
- <description>
- Provides the PackageAdmin Shell commands
- </description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Import-Package>
- !${project.artifactId}*,
- org.osgi.service.command,
- org.apache.felix.gogo.commands,
- org.apache.felix.karaf.shell.console,
- *
- </Import-Package>
- <Private-Package>!*</Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/karaf/shell/packages/src/main/java/org/apache/felix/karaf/shell/packages/ExportsCommand.java b/karaf/shell/packages/src/main/java/org/apache/felix/karaf/shell/packages/ExportsCommand.java
deleted file mode 100644
index f823d7e..0000000
--- a/karaf/shell/packages/src/main/java/org/apache/felix/karaf/shell/packages/ExportsCommand.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.packages;
-
-import java.io.PrintStream;
-import java.util.List;
-
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Command;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-import org.osgi.service.packageadmin.ExportedPackage;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-@Command(scope = "packages", name = "exports", description = "Display exported packages")
-public class ExportsCommand extends PackageCommandSupport {
-
- @Option(name = "-i", aliases = { "--imports"}, description = "List bundles importing the specified packages")
- boolean imports;
-
- @Argument(index = 0, name = "ids", description = "The IDs of bundles to check", required = false, multiValued = true)
- List<Long> ids;
-
- protected void doExecute(PackageAdmin admin) throws Exception {
- if (ids != null && !ids.isEmpty()) {
- for (long id : ids) {
- Bundle bundle = getBundleContext().getBundle(id);
- if (bundle != null) {
- printExports(System.out, bundle, admin.getExportedPackages(bundle));
- } else {
- System.err.println("Bundle ID " + id + " is invalid.");
- }
- }
- }
- else {
- printExports(System.out, null, admin.getExportedPackages((Bundle) null));
- }
- }
-
- protected void printExports(PrintStream out, Bundle target, ExportedPackage[] exports) {
- if ((exports != null) && (exports.length > 0)) {
- for (int i = 0; i < exports.length; i++) {
- Bundle bundle = exports[i].getExportingBundle();
- out.print(getBundleName(bundle));
- out.println(": " + exports[i]);
- if (imports) {
- Bundle[] bs = exports[i].getImportingBundles();
- if (bs != null) {
- for (Bundle b : bs) {
- out.println("\t" + getBundleName(b));
- }
- }
- }
- }
- } else {
- out.println(getBundleName(target) + ": No active exported packages.");
- }
- }
-
- public static String getBundleName(Bundle bundle) {
- if (bundle != null) {
- String name = (String) bundle.getHeaders().get(Constants.BUNDLE_NAME);
- return (name == null)
- ? "Bundle " + Long.toString(bundle.getBundleId())
- : name + " (" + Long.toString(bundle.getBundleId()) + ")";
- }
- return "[STALE BUNDLE]";
- }
-
-}
diff --git a/karaf/shell/packages/src/main/java/org/apache/felix/karaf/shell/packages/ImportsCommand.java b/karaf/shell/packages/src/main/java/org/apache/felix/karaf/shell/packages/ImportsCommand.java
deleted file mode 100644
index ab423f3..0000000
--- a/karaf/shell/packages/src/main/java/org/apache/felix/karaf/shell/packages/ImportsCommand.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.packages;
-
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-import org.osgi.service.packageadmin.ExportedPackage;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "packages", name = "imports", description = "Display imported packages")
-public class ImportsCommand extends PackageCommandSupport {
-
- @Argument(index = 0, name = "ids", description = "The IDs of bundles to check", required = false, multiValued = true)
- List<Long> ids;
-
- protected void doExecute(PackageAdmin admin) throws Exception {
- Map<Long, List<ExportedPackage>> packages = new HashMap<Long, List<ExportedPackage>>();
- ExportedPackage[] exported = admin.getExportedPackages((Bundle) null);
- for (ExportedPackage pkg : exported) {
- Bundle[] bundles = pkg.getImportingBundles();
- if (bundles != null) {
- for (Bundle b : bundles) {
- List<ExportedPackage> p = packages.get(b.getBundleId());
- if (p == null) {
- p = new ArrayList<ExportedPackage>();
- packages.put(b.getBundleId(), p);
- }
- p.add(pkg);
- }
- }
- }
- if (ids != null && !ids.isEmpty()) {
- for (long id : ids) {
- Bundle bundle = getBundleContext().getBundle(id);
- if (bundle != null) {
- printImports(System.out, bundle, packages.get(bundle.getBundleId()));
- } else {
- System.err.println("Bundle ID " + id + " is invalid.");
- }
- }
- }
- else {
- List<ExportedPackage> pkgs = new ArrayList<ExportedPackage>();
- for (List<ExportedPackage> l : packages.values()) {
- pkgs.addAll(l);
- }
- printImports(System.out, null, pkgs);
- }
- }
-
- protected void printImports(PrintStream out, Bundle target, List<ExportedPackage> imports) {
- if ((imports != null) && (imports.size() > 0)) {
- for (ExportedPackage p : imports) {
- Bundle bundle = p.getExportingBundle();
- out.print(getBundleName(bundle));
- out.println(": " + p);
- }
- } else {
- out.println(getBundleName(target) + ": No active imported packages.");
- }
- }
-
- public static String getBundleName(Bundle bundle) {
- if (bundle != null) {
- String name = (String) bundle.getHeaders().get(Constants.BUNDLE_NAME);
- return (name == null)
- ? "Bundle " + Long.toString(bundle.getBundleId())
- : name + " (" + Long.toString(bundle.getBundleId()) + ")";
- }
- return "[STALE BUNDLE]";
- }
-
-}
diff --git a/karaf/shell/packages/src/main/java/org/apache/felix/karaf/shell/packages/PackageCommandSupport.java b/karaf/shell/packages/src/main/java/org/apache/felix/karaf/shell/packages/PackageCommandSupport.java
deleted file mode 100644
index 84ae132..0000000
--- a/karaf/shell/packages/src/main/java/org/apache/felix/karaf/shell/packages/PackageCommandSupport.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.packages;
-
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/**
- * Abstract class from which all commands related to the PackageAdmin
- * service should derive.
- * This command retrieves a reference to the PackageAdmin service before
- * calling another method to actually process the command.
- */
-public abstract class PackageCommandSupport extends OsgiCommandSupport {
-
- protected Object doExecute() throws Exception {
- // Get package admin service.
- ServiceReference ref = getBundleContext().getServiceReference(PackageAdmin.class.getName());
- if (ref == null) {
- System.out.println("PackageAdmin service is unavailable.");
- return null;
- }
- try {
- PackageAdmin admin = (PackageAdmin) getBundleContext().getService(ref);
- if (admin == null) {
- System.out.println("PackageAdmin service is unavailable.");
- return null;
- }
-
- doExecute(admin);
- }
- finally {
- getBundleContext().ungetService(ref);
- }
- return null;
- }
-
- protected abstract void doExecute(PackageAdmin admin) throws Exception;
-
-}
diff --git a/karaf/shell/packages/src/main/resources/OSGI-INF/blueprint/shell-packages.xml b/karaf/shell/packages/src/main/resources/OSGI-INF/blueprint/shell-packages.xml
deleted file mode 100644
index 59f63ca..0000000
--- a/karaf/shell/packages/src/main/resources/OSGI-INF/blueprint/shell-packages.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <command-bundle xmlns="http://felix.apache.org/karaf/xmlns/shell/v1.0.0">
- <command name="packages/exports">
- <action class="org.apache.felix.karaf.shell.packages.ExportsCommand"/>
- </command>
- <command name="packages/imports">
- <action class="org.apache.felix.karaf.shell.packages.ImportsCommand"/>
- </command>
- </command-bundle>
-
-</blueprint>
diff --git a/karaf/shell/pom.xml b/karaf/shell/pom.xml
deleted file mode 100644
index 3574434..0000000
--- a/karaf/shell/pom.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<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/maven-v4_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.felix.karaf</groupId>
- <artifactId>karaf</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>shell</artifactId>
- <packaging>pom</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Shell</name>
-
- <modules>
- <module>commands</module>
- <module>config</module>
- <module>console</module>
- <module>log</module>
- <module>obr</module>
- <module>osgi</module>
- <module>packages</module>
- <module>ssh</module>
- <module>wrapper</module>
- <module>dev</module>
- </modules>
-
-</project>
diff --git a/karaf/shell/ssh/NOTICE b/karaf/shell/ssh/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/shell/ssh/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/shell/ssh/pom.xml b/karaf/shell/ssh/pom.xml
deleted file mode 100644
index a9d2a3d..0000000
--- a/karaf/shell/ssh/pom.xml
+++ /dev/null
@@ -1,106 +0,0 @@
-<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/maven-v4_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.felix.karaf.shell</groupId>
- <artifactId>shell</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.ssh</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Shell SSH</name>
-
- <description>
- Provides SSH support to the console
- </description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.junit</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.sshd</groupId>
- <artifactId>sshd-core</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <resources>
- <resource>
- <directory>${project.basedir}/src/main/resources</directory>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Import-Package>
- !${project.artifactId}*,
- org.osgi.service.command,
- org.apache.felix.gogo.commands,
- org.apache.felix.karaf.shell.console,
- org.apache.sshd.server.keyprovider,
- org.apache.sshd.server.jaas,
- *
- </Import-Package>
- <Private-Package>org.apache.felix.karaf.jpm.*</Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellCommandFactory.java b/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellCommandFactory.java
deleted file mode 100644
index 4822347..0000000
--- a/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellCommandFactory.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.ssh;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintStream;
-
-import org.apache.sshd.server.Command;
-import org.apache.sshd.server.CommandFactory;
-import org.apache.sshd.server.Environment;
-import org.apache.sshd.server.ExitCallback;
-import org.osgi.service.command.CommandProcessor;
-import org.osgi.service.command.CommandSession;
-
-public class ShellCommandFactory implements CommandFactory {
-
- private CommandProcessor commandProcessor;
-
- public void setCommandProcessor(CommandProcessor commandProcessor) {
- this.commandProcessor = commandProcessor;
- }
-
- public Command createCommand(String command) {
- return new ShellCommand(command);
- }
-
- public class ShellCommand implements Command {
-
- private String command;
- private InputStream in;
- private OutputStream out;
- private OutputStream err;
- private ExitCallback callback;
-
- public ShellCommand(String command) {
- this.command = command;
- }
-
- public void setInputStream(InputStream in) {
- this.in = in;
- }
-
- public void setOutputStream(OutputStream out) {
- this.out = out;
- }
-
- public void setErrorStream(OutputStream err) {
- this.err = err;
- }
-
- public void setExitCallback(ExitCallback callback) {
- this.callback = callback;
- }
-
- public void start(final Environment env) throws IOException {
- try {
- CommandSession session = commandProcessor.createSession(in, new PrintStream(out), new PrintStream(err));
- session.execute(command);
- } catch (Exception e) {
- throw (IOException) new IOException("Unable to start shell").initCause(e);
- } finally {
- close(in, out, err);
- callback.onExit(0);
- }
- }
-
- public void destroy() {
- }
-
- }
-
- private static void close(Closeable... closeables) {
- for (Closeable c : closeables) {
- try {
- c.close();
- } catch (IOException e) {
- // Ignore
- }
- }
- }
-}
diff --git a/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellFactoryImpl.java b/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellFactoryImpl.java
deleted file mode 100644
index 98cadda..0000000
--- a/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellFactoryImpl.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.karaf.shell.ssh;
-
-import java.io.Closeable;
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.Callable;
-
-import jline.Terminal;
-import org.apache.felix.karaf.shell.console.Completer;
-import org.apache.felix.karaf.shell.console.completer.AggregateCompleter;
-import org.apache.felix.karaf.shell.console.jline.Console;
-import org.apache.sshd.common.Factory;
-import org.apache.sshd.server.Command;
-import org.apache.sshd.server.Environment;
-import org.apache.sshd.server.ExitCallback;
-import org.apache.sshd.server.Signal;
-import org.apache.sshd.server.SignalListener;
-import org.osgi.service.blueprint.container.ReifiedType;
-import org.osgi.service.command.CommandProcessor;
-import org.osgi.service.command.CommandSession;
-
-/**
- * SSHD {@link org.apache.sshd.server.Command} factory which provides access to Shell.
- *
- * @version $Rev: 731517 $ $Date: 2009-01-05 11:25:19 +0100 (Mon, 05 Jan 2009) $
- */
-public class ShellFactoryImpl implements Factory<Command>
-{
- private CommandProcessor commandProcessor;
- private List<Completer> completers;
-
- public void setCommandProcessor(CommandProcessor commandProcessor) {
- this.commandProcessor = commandProcessor;
- }
-
- public void setCompleters(List<Completer> completers) {
- this.completers = completers;
- }
-
- public Command create() {
- return new ShellImpl();
- }
-
- public class ShellImpl implements Command
- {
- private InputStream in;
-
- private OutputStream out;
-
- private OutputStream err;
-
- private ExitCallback callback;
-
- private boolean closed;
-
- public void setInputStream(final InputStream in) {
- this.in = in;
- }
-
- public void setOutputStream(final OutputStream out) {
- this.out = out;
- }
-
- public void setErrorStream(final OutputStream err) {
- this.err = err;
- }
-
- public void setExitCallback(ExitCallback callback) {
- this.callback = callback;
- }
-
- public void start(final Environment env) throws IOException {
- try {
- final Terminal terminal = new SshTerminal(env);
- Console console = new Console(commandProcessor,
- in,
- new PrintStream(new LfToCrLfFilterOutputStream(out), true),
- new PrintStream(new LfToCrLfFilterOutputStream(err), true),
- terminal,
- new AggregateCompleter(completers),
- new Runnable() {
- public void run() {
- destroy();
- }
- });
- final CommandSession session = console.getSession();
- session.put("APPLICATION", System.getProperty("karaf.name", "root"));
- for (Map.Entry<String,String> e : env.getEnv().entrySet()) {
- session.put(e.getKey(), e.getValue());
- }
- session.put("LINES", Integer.toString(terminal.getTerminalHeight()));
- session.put("COLUMNS", Integer.toString(terminal.getTerminalWidth()));
- env.addSignalListener(new SignalListener() {
- public void signal(Signal signal) {
- session.put("LINES", Integer.toString(terminal.getTerminalHeight()));
- session.put("COLUMNS", Integer.toString(terminal.getTerminalWidth()));
- }
- }, Signal.WINCH);
- session.put(".jline.terminal", terminal);
- new Thread(console).start();
- } catch (Exception e) {
- throw (IOException) new IOException("Unable to start shell").initCause(e);
- }
- }
-
- public void destroy() {
- if (!closed) {
- closed = true;
- ShellFactoryImpl.close(in, out, err);
- callback.onExit(0);
- }
- }
-
- }
-
- private static void close(Closeable... closeables) {
- for (Closeable c : closeables) {
- try {
- c.close();
- } catch (IOException e) {
- // Ignore
- }
- }
- }
-
- public static Converter getConverter() {
- return new Converter();
- }
-
- public static class Converter implements org.osgi.service.blueprint.container.Converter {
-
- public boolean canConvert(Object sourceObject, ReifiedType targetType) {
- return ShellFactoryImpl.class.isAssignableFrom(sourceObject.getClass())
- && Factory.class.equals(targetType.getRawClass())
- && Command.class.equals(targetType.getActualTypeArgument(0).getRawClass());
- }
-
- public Object convert(Object sourceObject, ReifiedType targetType) throws Exception {
- return sourceObject;
- }
- }
-
- // TODO: remove this class when sshd use lf->crlf conversion by default
- public class LfToCrLfFilterOutputStream extends FilterOutputStream {
-
- private boolean lastWasCr;
-
- public LfToCrLfFilterOutputStream(OutputStream out) {
- super(out);
- }
-
- @Override
- public void write(int b) throws IOException {
- if (!lastWasCr && b == '\n') {
- out.write('\r');
- out.write('\n');
- } else {
- out.write(b);
- }
- lastWasCr = b == '\r';
- }
-
- }
-
-
-}
diff --git a/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/SshAction.java b/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/SshAction.java
deleted file mode 100644
index 84f899d..0000000
--- a/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/SshAction.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.karaf.shell.ssh;
-
-import java.io.IOException;
-
-import org.apache.sshd.ClientChannel;
-import org.apache.sshd.ClientSession;
-import org.apache.sshd.SshClient;
-import org.apache.sshd.client.channel.ChannelShell;
-import org.apache.sshd.client.future.ConnectFuture;
-import org.apache.sshd.common.util.NoCloseInputStream;
-import org.apache.sshd.common.util.NoCloseOutputStream;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.karaf.shell.console.BlueprintContainerAware;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.osgi.service.blueprint.container.BlueprintContainer;
-
-/**
- * Connect to a SSH server.
- *
- * @version $Rev: 721244 $ $Date: 2008-11-27 18:19:56 +0100 (Thu, 27 Nov 2008) $
- */
-@Command(scope = "ssh", name = "ssh", description = "Connects to a remote SSH server")
-public class SshAction
- extends OsgiCommandSupport implements BlueprintContainerAware
-{
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Option(name="-l", aliases={"--username"}, description = "The user name for remote login", required = false, multiValued = false)
- private String username;
-
- @Option(name="-P", aliases={"--password"}, description = "The password for remote login", required = false, multiValued = false)
- private String password;
-
- @Argument(index = 0, name = "hostname", description = "The host name to connect to via SSH", required = true, multiValued = false)
- private String hostname;
-
- @Option(name="-p", aliases={"--port"}, description = "The port to use for SSH connection", required = false, multiValued = false)
- private int port = 22;
-
- private BlueprintContainer container;
-
- private ClientSession session;
- private String sshClientId;
-
- public void setBlueprintContainer(final BlueprintContainer container) {
- assert container != null;
- this.container = container;
- }
-
- public void setSshClientId(String sshClientId) {
- this.sshClientId = sshClientId;
- }
-
- @Override
- protected Object doExecute() throws Exception {
-
- //
- // TODO: Parse hostname for <username>@<hostname>
- //
-
- System.out.println("Connecting to host " + hostname + " on port " + port);
-
- // If the username/password was not configured via cli, then prompt the user for the values
- if (username == null || password == null) {
- log.debug("Prompting user for credentials");
- if (username == null) {
- username = readLine("Login: ");
- }
- if (password == null) {
- password = readLine("Password: ");
- }
- }
-
- // Create the client from prototype
- SshClient client = (SshClient) container.getComponentInstance(sshClientId);
- log.debug("Created client: {}", client);
- client.start();
-
- try {
- ConnectFuture future = client.connect(hostname, port);
- future.await();
- session = future.getSession();
- try {
- System.out.println("Connected");
-
- session.authPassword(username, password);
- int ret = session.waitFor(ClientSession.WAIT_AUTH | ClientSession.CLOSED | ClientSession.AUTHED, 0);
- if ((ret & ClientSession.AUTHED) == 0) {
- System.err.println("Authentication failed");
- return null;
- }
-
- ClientChannel channel = session.createChannel("shell");
- channel.setIn(new NoCloseInputStream(System.in));
- ((ChannelShell) channel).setupSensibleDefaultPty();
- channel.setOut(new NoCloseOutputStream(System.out));
- channel.setErr(new NoCloseOutputStream(System.err));
- channel.open();
- channel.waitFor(ClientChannel.CLOSED, 0);
- } finally {
- session.close(false);
- }
- } finally {
- client.stop();
- }
-
- return null;
- }
-
- public String readLine(String msg) throws IOException {
- StringBuffer sb = new StringBuffer();
- System.err.print(msg);
- System.err.flush();
- for (;;) {
- int c = super.session.getKeyboard().read();
- if (c < 0) {
- return null;
- }
- System.err.print((char) c);
- if (c == '\r' || c == '\n') {
- break;
- }
- sb.append((char) c);
- }
- return sb.toString();
- }
-
-}
diff --git a/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/SshServerAction.java b/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/SshServerAction.java
deleted file mode 100644
index 4d02a6c..0000000
--- a/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/SshServerAction.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.karaf.shell.ssh;
-
-import org.apache.sshd.SshServer;
-import org.apache.felix.karaf.shell.console.BlueprintContainerAware;
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Command;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.osgi.service.blueprint.container.BlueprintContainer;
-
-/**
- * Start a SSH server.
- *
- * @version $Rev: 720411 $ $Date: 2008-11-25 05:32:43 +0100 (Tue, 25 Nov 2008) $
- */
-@Command(scope = "ssh", name = "sshd", description = "Creates a SSH server")
-public class SshServerAction extends OsgiCommandSupport implements BlueprintContainerAware
-{
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Option(name="-p", aliases={ "--port" }, description = "The port to setup the SSH server (Default: 8101)", required = false, multiValued = false)
- private int port = 8101;
-
- @Option(name="-b", aliases={ "--background"}, description = "The service will run in the background (Default: true)", required = false, multiValued = false)
- private boolean background = true;
-
- private BlueprintContainer container;
-
- private String sshServerId;
-
- public void setBlueprintContainer(final BlueprintContainer container) {
- assert container != null;
- this.container = container;
- }
-
- public void setSshServerId(String sshServerId) {
- this.sshServerId = sshServerId;
- }
-
- protected Object doExecute() throws Exception {
- SshServer server = (SshServer) container.getComponentInstance(sshServerId);
-
- log.debug("Created server: {}", server);
-
- server.setPort(port);
-
- server.start();
-
- System.out.println("SSH server listening on port " + port);
-
- if (!background) {
- synchronized (this) {
- log.debug("Waiting for server to shutdown");
-
- wait();
- }
-
- server.stop();
- }
-
- return null;
- }
-}
diff --git a/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/SshServerFactory.java b/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/SshServerFactory.java
deleted file mode 100644
index 150da1f..0000000
--- a/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/SshServerFactory.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.ssh;
-
-import org.apache.sshd.SshServer;
-
-public class SshServerFactory {
-
- private SshServer server;
-
- private boolean start;
-
- public SshServerFactory(SshServer server) {
- this.server = server;
- }
-
- public boolean isStart() {
- return start;
- }
-
- public void setStart(boolean start) {
- this.start = start;
- }
-
- public void start() throws Exception {
- if (start) {
- try {
- server.start();
- } catch (Exception e) {
- e.printStackTrace();
- throw e;
- }
- }
- }
-
- public void stop() throws Exception {
- if (start) {
- server.stop();
- }
- }
-
-}
diff --git a/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/SshTerminal.java b/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/SshTerminal.java
deleted file mode 100644
index b4fe699..0000000
--- a/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/SshTerminal.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.karaf.shell.ssh;
-
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-import jline.Terminal;
-import org.apache.sshd.common.PtyMode;
-import org.apache.sshd.server.Environment;
-import org.apache.sshd.server.Signal;
-import org.apache.sshd.server.SignalListener;
-
-public class SshTerminal extends Terminal {
-
- public static final short ARROW_START = 27;
- public static final short ARROW_PREFIX = 91;
- public static final short ARROW_LEFT = 68;
- public static final short ARROW_RIGHT = 67;
- public static final short ARROW_UP = 65;
- public static final short ARROW_DOWN = 66;
- public static final short O_PREFIX = 79;
- public static final short HOME_CODE = 72;
- public static final short END_CODE = 70;
-
- public static final short DEL_THIRD = 51;
- public static final short DEL_SECOND = 126;
-
- private Environment environment;
- private boolean backspaceDeleteSwitched = false;
- private String encoding = System.getProperty("input.encoding", "UTF-8");
- private ReplayPrefixOneCharInputStream replayStream = new ReplayPrefixOneCharInputStream(encoding);
- private InputStreamReader replayReader;
- private boolean isWindowsTerminal;
-
- public SshTerminal(Environment environment) {
- this.environment = environment;
- try {
- replayReader = new InputStreamReader(replayStream, encoding);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- Integer verase = this.environment.getPtyModes().get(PtyMode.VERASE);
- backspaceDeleteSwitched = verase != null && verase == DELETE;
- this.isWindowsTerminal = "windows".equals(environment.getEnv().get("TERM"));
- }
-
- public void initializeTerminal() throws Exception {
- }
-
- public void restoreTerminal() throws Exception {
- }
-
- @Override
- public boolean isANSISupported() {
- return !isWindowsTerminal;
- }
-
- public int getTerminalWidth() {
- return Integer.valueOf(this.environment.getEnv().get(Environment.ENV_COLUMNS));
- }
-
- public int getTerminalHeight() {
- return Integer.valueOf(this.environment.getEnv().get(Environment.ENV_LINES));
- }
-
- public boolean isSupported() {
- return true;
- }
-
- public boolean getEcho() {
- return false;
- }
-
- public boolean isEchoEnabled() {
- return false;
- }
-
- public void enableEcho() {
- }
-
- public void disableEcho() {
- }
-
- public int readVirtualKey(InputStream in) throws IOException {
- int c = readCharacter(in);
-
- if (backspaceDeleteSwitched)
- if (c == DELETE)
- c = BACKSPACE;
- else if (c == BACKSPACE)
- c = DELETE;
-
- // in Unix terminals, arrow keys are represented by
- // a sequence of 3 characters. E.g., the up arrow
- // key yields 27, 91, 68
- if (c == ARROW_START) {
- //also the escape key is 27
- //thats why we read until we
- //have something different than 27
- //this is a bugfix, because otherwise
- //pressing escape and than an arrow key
- //was an undefined state
- while (c == ARROW_START)
- c = readCharacter(in);
- if (c == ARROW_PREFIX || c == O_PREFIX) {
- c = readCharacter(in);
- if (c == ARROW_UP) {
- return CTRL_P;
- } else if (c == ARROW_DOWN) {
- return CTRL_N;
- } else if (c == ARROW_LEFT) {
- return CTRL_B;
- } else if (c == ARROW_RIGHT) {
- return CTRL_F;
- } else if (c == HOME_CODE) {
- return CTRL_A;
- } else if (c == END_CODE) {
- return CTRL_E;
- } else if (c == DEL_THIRD) {
- c = readCharacter(in); // read 4th
- return DELETE;
- }
- }
- }
- // handle unicode characters, thanks for a patch from amyi@inf.ed.ac.uk
- if (c > 128) {
- // handle unicode characters longer than 2 bytes,
- // thanks to Marc.Herbert@continuent.com
- replayStream.setInput(c, in);
-// replayReader = new InputStreamReader(replayStream, encoding);
- c = replayReader.read();
-
- }
-
- return c;
- }
-
- /**
- * This is awkward and inefficient, but probably the minimal way to add
- * UTF-8 support to JLine
- *
- * @author <a href="mailto:Marc.Herbert@continuent.com">Marc Herbert</a>
- */
- static class ReplayPrefixOneCharInputStream extends InputStream {
- byte firstByte;
- int byteLength;
- InputStream wrappedStream;
- int byteRead;
-
- final String encoding;
-
- public ReplayPrefixOneCharInputStream(String encoding) {
- this.encoding = encoding;
- }
-
- public void setInput(int recorded, InputStream wrapped) throws IOException {
- this.byteRead = 0;
- this.firstByte = (byte) recorded;
- this.wrappedStream = wrapped;
-
- byteLength = 1;
- if (encoding.equalsIgnoreCase("UTF-8"))
- setInputUTF8(recorded, wrapped);
- else if (encoding.equalsIgnoreCase("UTF-16"))
- byteLength = 2;
- else if (encoding.equalsIgnoreCase("UTF-32"))
- byteLength = 4;
- }
-
-
- public void setInputUTF8(int recorded, InputStream wrapped) throws IOException {
- // 110yyyyy 10zzzzzz
- if ((firstByte & (byte) 0xE0) == (byte) 0xC0)
- this.byteLength = 2;
- // 1110xxxx 10yyyyyy 10zzzzzz
- else if ((firstByte & (byte) 0xF0) == (byte) 0xE0)
- this.byteLength = 3;
- // 11110www 10xxxxxx 10yyyyyy 10zzzzzz
- else if ((firstByte & (byte) 0xF8) == (byte) 0xF0)
- this.byteLength = 4;
- else
- throw new IOException("invalid UTF-8 first byte: " + firstByte);
- }
-
- public int read() throws IOException {
- if (available() == 0)
- return -1;
-
- byteRead++;
-
- if (byteRead == 1)
- return firstByte;
-
- return wrappedStream.read();
- }
-
- /**
- * InputStreamReader is greedy and will try to read bytes in advance. We
- * do NOT want this to happen since we use a temporary/"losing bytes"
- * InputStreamReader above, that's why we hide the real
- * wrappedStream.available() here.
- */
- public int available() {
- return byteLength - byteRead;
- }
- }
-
-}
diff --git a/karaf/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml b/karaf/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml
deleted file mode 100644
index 3f6edbc..0000000
--- a/karaf/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml
+++ /dev/null
@@ -1,110 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
- xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
- default-activation="lazy">
-
- <type-converters>
- <bean class="org.apache.felix.karaf.shell.ssh.ShellFactoryImpl" factory-method="getConverter" />
- </type-converters>
-
- <ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"/>
-
- <cm:property-placeholder persistent-id="org.apache.felix.karaf.shell">
- <cm:default-properties>
- <cm:property name="sshPort" value="8101"/>
- <cm:property name="sshHost" value="0.0.0.0"/>
- <cm:property name="sshRealm" value="karaf"/>
- <cm:property name="hostKey" value="${karaf.base}/etc/host.key"/>
- </cm:default-properties>
- </cm:property-placeholder>
-
- <command-bundle xmlns="http://felix.apache.org/karaf/xmlns/shell/v1.0.0">
- <command name="ssh/ssh">
- <action class="org.apache.felix.karaf.shell.ssh.SshAction">
- <property name="sshClientId">
- <bp:idref component-id="sshClient"/>
- </property>
- </action>
- </command>
- <command name="ssh/sshd">
- <action class="org.apache.felix.karaf.shell.ssh.SshServerAction">
- <property name="sshServerId">
- <bp:idref component-id="sshServer"/>
- </property>
- </action>
- </command>
- </command-bundle>
-
- <bean id="sshClient" class="org.apache.sshd.SshClient" factory-method="setUpDefaultClient" scope="prototype">
- </bean>
-
- <bean id="sshServer" class="org.apache.sshd.SshServer" factory-method="setUpDefaultServer" scope="prototype">
- <property name="port" value="${sshPort}"/>
- <property name="host" value="${sshHost}"/>
- <property name="shellFactory">
- <bean class="org.apache.felix.karaf.shell.ssh.ShellFactoryImpl">
- <property name="completers">
- <list>
- <ref component-id="commandCompleter"/>
- </list>
- </property>
- <property name="commandProcessor" ref="commandProcessor"/>
- </bean>
- </property>
- <property name="commandFactory">
- <bean class="org.apache.felix.karaf.shell.ssh.ShellCommandFactory">
- <property name="commandProcessor" ref="commandProcessor"/>
- </bean>
- </property>
- <property name="keyPairProvider" ref="keyPairProvider"/>
- <property name="passwordAuthenticator" ref="passwordAuthenticator"/>
- </bean>
-
- <bean id="keyPairProvider" class="org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider">
- <property name="path" value="${hostKey}"/>
- </bean>
- <bean id="passwordAuthenticator" class="org.apache.sshd.server.jaas.JaasPasswordAuthenticator">
- <property name="domain" value="${sshRealm}"/>
- </bean>
-
- <bean id="sshServerFactory" class="org.apache.felix.karaf.shell.ssh.SshServerFactory" init-method="start"
- destroy-method="stop" activation="eager">
- <argument ref="sshServer"/>
- <property name="start" value="$[karaf.startRemoteShell]"/>
- </bean>
-
- <reference id="commandProcessor" interface="org.osgi.service.command.CommandProcessor">
- </reference>
-
- <reference-list id="functions" filter="(&(osgi.command.scope=*)(osgi.command.function=*))"
- availability="optional" activation="eager">
- <reference-listener ref="commandCompleter"
- bind-method="register"
- unbind-method="unregister"/>
- </reference-list>
-
- <bean id="commandCompleter" class="org.apache.felix.karaf.shell.console.completer.CommandsCompleter">
- <property name="bundleContext" ref="blueprintBundleContext" />
- </bean>
-
-</blueprint>
diff --git a/karaf/shell/ssh/src/main/resources/OSGI-INF/metatype/metatype.properties b/karaf/shell/ssh/src/main/resources/OSGI-INF/metatype/metatype.properties
deleted file mode 100644
index 52263f1..0000000
--- a/karaf/shell/ssh/src/main/resources/OSGI-INF/metatype/metatype.properties
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy 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.
-#
-
-#
-# This file contains localization strings for configuration labels and
-# descriptions as used in the metatype.xml descriptor
-
-shell.name = Apache Felix Karaf Shell
-shell.description = Configuration of Apache Felix Karaf Shell
-
-sshPort.name = SSH Port
-sshPort.description = port of the SSH daemon
-
-sshHost.name = SSH Host
-sshHost.description = name of the host used to bind the SSH daemon
-
-sshRealm.name = SSH Realm
-sshRealm.description = name of the JAAS realm to use for SSH authentication
-
-hostKey.name = Host key
-hostKey.description = location of the host key for SSH
diff --git a/karaf/shell/ssh/src/main/resources/OSGI-INF/metatype/metatype.xml b/karaf/shell/ssh/src/main/resources/OSGI-INF/metatype/metatype.xml
deleted file mode 100644
index 8350f10..0000000
--- a/karaf/shell/ssh/src/main/resources/OSGI-INF/metatype/metatype.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0" localization="OSGI-INF/metatype/metatype">
- <OCD id="org.apache.felix.karaf.shell" name="%shell.name" description="%shell.description">
- <AD id="sshPort" type="Integer" default="8101" name="%sshPort.name" description="%sshPort.description"/>
- <AD id="sshHost" type="String" default="0.0.0.0" name="%sshHost.name" description="%sshHost.description"/>
- <AD id="sshRealm" type="String" default="karaf" name="%sshRealm.name" description="%sshRealm.description"/>
- <AD id="hostKey" type="String" default="${karaf.base}/etc/host.key" name="%hostKey.name" description="%hostKey.description"/>
- </OCD>
- <Designate pid="org.apache.felix.karaf.shell">
- <Object ocdref="org.apache.felix.karaf.shell"/>
- </Designate>
-</metatype:MetaData>
diff --git a/karaf/shell/wrapper/NOTICE b/karaf/shell/wrapper/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/shell/wrapper/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/shell/wrapper/pom.xml b/karaf/shell/wrapper/pom.xml
deleted file mode 100644
index 5051da7..0000000
--- a/karaf/shell/wrapper/pom.xml
+++ /dev/null
@@ -1,101 +0,0 @@
-<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/maven-v4_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.felix.karaf.shell</groupId>
- <artifactId>shell</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.wrapper</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Shell Service Wrapper</name>
-
- <description>
- Provides the Service Wrapper Shell integration
- </description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <build>
- <resources>
- <resource>
- <directory>${project.basedir}/src/main/resources</directory>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- <resource>
- <directory>${project.basedir}/src/main/filtered-resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <configuration>
- <mainClass>Main</mainClass>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Import-Package>
- !${project.artifactId}*,
- org.osgi.service.command,
- org.apache.felix.gogo.commands,
- org.apache.felix.karaf.shell.console,
- *
- </Import-Package>
- <Private-Package>!*</Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/karaf/shell/wrapper/src/main/java/org/apache/felix/karaf/shell/wrapper/InstallCommand.java b/karaf/shell/wrapper/src/main/java/org/apache/felix/karaf/shell/wrapper/InstallCommand.java
deleted file mode 100644
index 2aeeb5d..0000000
--- a/karaf/shell/wrapper/src/main/java/org/apache/felix/karaf/shell/wrapper/InstallCommand.java
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.shell.wrapper;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Scanner;
-
-import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.gogo.commands.Command;
-import org.fusesource.jansi.Ansi;
-
-/**
- * Installs this Karaf instance as a service in your operating systems.
- *
- * @version $Rev: 603634 $ $Date: 2007-12-12 16:07:16 +0100 (Wed, 12 Dec 2007) $
- */
-@Command(scope = "wrapper", name = "install", description = "Install the container as a system service in the OS.")
-public class InstallCommand extends OsgiCommandSupport
-{
- @Option(name="-n", aliases={"--name"}, description="The service name that will be used when installing the service. (Default: karaf)", required = false, multiValued = false)
- private String name="karaf";
-
- @Option(name="-d", aliases={"--display"}, description="The display name of the service.", required = false, multiValued = false)
- private String displayName;
-
- @Option(name="-D", aliases={"--description"}, description="The description of the service.", required = false, multiValued = false)
- private String description="";
-
- @Option(name="-s", aliases={"--start-type"}, description="Mode in which the service is installed. AUTO_START or DEMAND_START (Default: AUTO_START)", required = false, multiValued = false)
- private String startType="AUTO_START";
-
- protected Object doExecute() throws Exception {
-
- try {
- String name = getName();
- File base = new File(System.getProperty("karaf.base"));
- File bin = new File(base, "bin");
- File etc = new File(base, "etc");
- File lib = new File(base, "lib");
-
- HashMap<String, String> props = new HashMap<String, String>();
- props.put("${karaf.home}", System.getProperty("karaf.home"));
- props.put("${karaf.base}", base.getPath());
- props.put("${name}", name);
- props.put("${displayName}", getDisplayName());
- props.put("${description}", getDescription());
- props.put("${startType}", getStartType());
-
- String os = System.getProperty("os.name", "Unknown");
- File serviceFile = null;
- File wrapperConf = null;
- if( os.startsWith("Win") ) {
- mkdir(bin);
-
- copyResourceTo(new File(bin, name+"-wrapper.exe"), "windows/karaf-wrapper.exe", false);
-
- serviceFile = new File(bin,name+"-service.bat");
-
- wrapperConf = new File(etc,name+"-wrapper.conf");
- copyFilteredResourceTo(wrapperConf, "windows/karaf-wrapper.conf", props);
-
- copyFilteredResourceTo(serviceFile, "windows/karaf-service.bat", props);
-
- mkdir(lib);
- copyResourceTo(new File(lib, "wrapper.dll"), "windows/wrapper.dll", false);
- } else if( os.startsWith("Mac OS X") ) {
- mkdir(bin);
-
- File file = new File(bin, name+"-wrapper");
- copyResourceTo(file, "macosx/karaf-wrapper", false);
- chmod(file, "a+x");
-
- serviceFile = new File(bin,name+"-service");
- copyFilteredResourceTo(serviceFile, "unix/karaf-service", props);
- chmod(serviceFile, "a+x");
-
- wrapperConf = new File(etc,name+"-wrapper.conf");
- copyFilteredResourceTo(wrapperConf, "unix/karaf-wrapper.conf", props);
-
- mkdir(lib);
- copyResourceTo(new File(lib, "libwrapper.jnilib"), "macosx/libwrapper.jnilib", false);
-
- // TODO: figure out how to hook in the service that it starts up
- // when the machine boots up.
- } else if( os.startsWith("Linux") ) {
- mkdir(bin);
-
- File file = new File(bin, name+"-wrapper");
- copyResourceTo(file, "linux/karaf-wrapper", false);
- chmod(file, "a+x");
-
- serviceFile = new File(bin,name+"-service");
- copyFilteredResourceTo(serviceFile, "unix/karaf-service", props);
- chmod(serviceFile, "a+x");
-
- wrapperConf = new File(etc,name+"-wrapper.conf");
- copyFilteredResourceTo(wrapperConf, "unix/karaf-wrapper.conf", props);
-
- mkdir(lib);
- copyResourceTo(new File(lib, "libwrapper.so"), "linux/libwrapper.so", false);
-
- // TODO: figure out how to hook in the service that it starts up
- // when the machine boots up.
- } else {
- System.out.println("Your operating system '"+os+"' is not currently supported.");
- return 1;
- }
-
- // Install the wrapper jar to the lib directory..
- mkdir(lib);
- copyResourceTo(new File(lib, "karaf-wrapper.jar"), "all/karaf-wrapper.jar", false);
- mkdir(etc);
-
- System.out.println("");
- System.out.println("Setup complete. You may want to tweak the JVM properties in the wrapper configuration file:");
- System.out.println("\t" + wrapperConf.getPath());
- System.out.println("before installing and starting the service.");
- System.out.println("");
- if( os.startsWith("Win") ) {
- System.out.println("");
- System.out.println("To install the service, run: ");
- System.out.println(" C:> "+serviceFile.getPath()+" install");
- System.out.println("");
- System.out.println("Once installed, to start the service run: ");
- System.out.println(" C:> net start \""+name+"\"");
- System.out.println("");
- System.out.println("Once running, to stop the service run: ");
- System.out.println(" C:> net stop \""+name+"\"");
- System.out.println("");
- System.out.println("Once stopped, to remove the installed the service run: ");
- System.out.println(" C:> "+serviceFile.getPath()+" remove");
- System.out.println("");
- } else if( os.startsWith("Mac OS X") ) {
- System.out.println("");
- System.out.println("At this time it is not known how to get this service to start when the machine is rebooted.");
- System.out.println("If you know how to install the following service script so that it gets started");
- System.out.println("when OS X starts, please email dev@felix.apache.org and let us know how so");
- System.out.println("we can update this message.");
- System.out.println(" ");
- System.out.println(" To start the service:");
- System.out.println(" $ "+serviceFile.getPath()+" start");
- System.out.println("");
- System.out.println(" To stop the service:");
- System.out.println(" $ "+serviceFile.getPath()+" stop");
- System.out.println("");
- } else if( os.startsWith("Linux") ) {
- System.out.println("The way the service is installed depends upon your flavor of Linux.");
-
- // TODO: figure out if we can detect the Linux flavor
-
- System.out.println("");
- System.out.println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a("On Redhat/Fedora/CentOS Systems:").a(Ansi.Attribute.RESET).toString());
- System.out.println(" To install the service:");
- System.out.println(" $ ln -s "+serviceFile.getPath()+" /etc/init.d/");
- System.out.println(" $ chkconfig "+serviceFile.getName()+" --add");
- System.out.println("");
- System.out.println(" To start the service when the machine is rebooted:");
- System.out.println(" $ chkconfig "+serviceFile.getName()+" on");
- System.out.println("");
- System.out.println(" To disable starting the service when the machine is rebooted:");
- System.out.println(" $ chkconfig "+serviceFile.getName()+" off");
- System.out.println("");
- System.out.println(" To start the service:");
- System.out.println(" $ service "+serviceFile.getName()+" start");
- System.out.println("");
- System.out.println(" To stop the service:");
- System.out.println(" $ service "+serviceFile.getName()+" stop");
- System.out.println("");
- System.out.println(" To uninstall the service :");
- System.out.println(" $ chkconfig "+serviceFile.getName()+" --del");
- System.out.println(" $ rm /etc/init.d/"+serviceFile.getName());
-
- System.out.println("");
- System.out.println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a("On Ubuntu/Debian Systems:").a(Ansi.Attribute.RESET).toString());
- System.out.println(" To install the service:");
- System.out.println(" $ ln -s "+serviceFile.getPath()+" /etc/init.d/");
- System.out.println("");
- System.out.println(" To start the service when the machine is rebooted:");
- System.out.println(" $ update-rc.d "+serviceFile.getName()+" defaults");
- System.out.println("");
- System.out.println(" To disable starting the service when the machine is rebooted:");
- System.out.println(" $ update-rc.d -f "+serviceFile.getName()+" remove");
- System.out.println("");
- System.out.println(" To start the service:");
- System.out.println(" $ /etc/init.d/"+serviceFile.getName()+" start");
- System.out.println("");
- System.out.println(" To stop the service:");
- System.out.println(" $ /etc/init.d/"+serviceFile.getName()+" stop");
- System.out.println("");
- System.out.println(" To uninstall the service :");
- System.out.println(" $ rm /etc/init.d/"+serviceFile.getName());
-
- }
-
-
- } catch (Exception e) {
- e.printStackTrace();
- throw e;
- }
-
- return null;
- }
-
- private int chmod(File serviceFile, String mode) throws Exception {
- ProcessBuilder builder = new ProcessBuilder();
- builder.command("chmod", mode, serviceFile.getCanonicalPath());
- Process p = builder.start();
-
- PumpStreamHandler handler = new PumpStreamHandler(System.in, System.out, System.err);
- handler.attach(p);
- handler.start();
- int status = p.waitFor();
- handler.stop();
- return status;
- }
-
- private void copyResourceTo(File outFile, String resource, boolean text) throws Exception {
- if( !outFile.exists() ) {
- System.out.println(Ansi.ansi().a("Creating file: ")
- .a(Ansi.Attribute.INTENSITY_BOLD).a(outFile.getPath()).a(Ansi.Attribute.RESET).toString());
- InputStream is = InstallCommand.class.getResourceAsStream(resource);
- try {
- if( text ) {
- // Read it line at a time so that we can use the platform line ending when we write it out.
- PrintStream out = new PrintStream(new FileOutputStream(outFile));
- try {
- Scanner scanner = new Scanner(is);
- while (scanner.hasNextLine() ) {
- String line = scanner.nextLine();
- System.out.println("writing: "+line);
- out.println(line);
- }
- } finally {
- safeClose(out);
- }
- } else {
- // Binary so just write it out the way it came in.
- FileOutputStream out = new FileOutputStream(outFile);
- try {
- int c=0;
- while((c=is.read())>=0) {
- out.write(c);
- }
- } finally {
- safeClose(out);
- }
- }
- } finally {
- safeClose(is);
- }
- } else {
- System.out.println(Ansi.ansi()
- .fg(Ansi.Color.RED).a("File already exists").a(Ansi.Attribute.RESET)
- .a(". Move it out of the way if you want it re-created: ").a(outFile.getPath()).toString());
- }
- }
-
- private void copyFilteredResourceTo(File outFile, String resource, HashMap<String, String> props) throws Exception {
- if( !outFile.exists() ) {
- System.out.println(Ansi.ansi().a("Creating file: ")
- .a(Ansi.Attribute.INTENSITY_BOLD).a(outFile.getPath()).a(Ansi.Attribute.RESET).toString());
- InputStream is = InstallCommand.class.getResourceAsStream(resource);
- try {
- // Read it line at a time so that we can use the platform line ending when we write it out.
- PrintStream out = new PrintStream(new FileOutputStream(outFile));
- try {
- Scanner scanner = new Scanner(is);
- while (scanner.hasNextLine() ) {
- String line = scanner.nextLine();
- line = filter(line, props);
- out.println(line);
- }
- } finally {
- safeClose(out);
- }
- } finally {
- safeClose(is);
- }
- } else {
- System.out.println(Ansi.ansi()
- .fg(Ansi.Color.RED).a("File already exists").a(Ansi.Attribute.RESET)
- .a(". Move it out of the way if you want it re-created: ").a(outFile.getPath()).toString());
- }
- }
-
- private void safeClose(InputStream is) throws IOException {
- if( is==null)
- return;
- try {
- is.close();
- } catch (Throwable ignore) {
- }
- }
-
- private void safeClose(OutputStream is) throws IOException {
- if( is==null)
- return;
- try {
- is.close();
- } catch (Throwable ignore) {
- }
- }
-
- private String filter(String line, HashMap<String, String> props) {
- for (Map.Entry<String, String> i : props.entrySet()) {
- int p1 = line.indexOf(i.getKey());
- if( p1 >= 0 ) {
- String l1 = line.substring(0, p1);
- String l2 = line.substring(p1+i.getKey().length());
- line = l1+i.getValue()+l2;
- }
- }
- return line;
- }
-
- private void mkdir(File file) {
- if( !file.exists() ) {
- System.out.println(Ansi.ansi().a("Creating missing directory: ")
- .a(Ansi.Attribute.INTENSITY_BOLD).a(file.getPath()).a(Ansi.Attribute.RESET).toString());
- file.mkdirs();
- }
- }
-
- public String getName() {
- if( name == null ) {
- File base = new File(System.getProperty("karaf.base"));
- name = base.getName();
- }
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDisplayName() {
- if( displayName == null ) {
- displayName = getName();
- }
- return displayName;
- }
-
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getStartType() {
- return startType;
- }
-
- public void setStartType(String startType) {
- this.startType = startType;
- }
-}
diff --git a/karaf/shell/wrapper/src/main/java/org/apache/felix/karaf/shell/wrapper/PumpStreamHandler.java b/karaf/shell/wrapper/src/main/java/org/apache/felix/karaf/shell/wrapper/PumpStreamHandler.java
deleted file mode 100644
index 3809bed..0000000
--- a/karaf/shell/wrapper/src/main/java/org/apache/felix/karaf/shell/wrapper/PumpStreamHandler.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.karaf.shell.wrapper;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-
-//
-// Based on Apache Ant 1.6.5
-//
-
-/**
- * Copies standard output and error of children streams to standard output and error of the parent.
- *
- * @version $Rev: 705608 $ $Date: 2008-10-17 15:28:45 +0200 (Fri, 17 Oct 2008) $
- */
-public class PumpStreamHandler
-{
- private InputStream in;
-
- private OutputStream out;
-
- private OutputStream err;
-
- private Thread outputThread;
-
- private Thread errorThread;
-
- private StreamPumper inputPump;
-
- //
- // NOTE: May want to use a ThreadPool here, 3 threads per/pair seems kinda expensive :-(
- //
-
- public PumpStreamHandler(final InputStream in, final OutputStream out, final OutputStream err) {
- assert in != null;
- assert out != null;
- assert err != null;
-
- this.in = in;
- this.out = out;
- this.err = err;
- }
-
- public PumpStreamHandler(final OutputStream out, final OutputStream err) {
- this(null, out, err);
- }
-
- public PumpStreamHandler(final OutputStream outAndErr) {
- this(outAndErr, outAndErr);
- }
-
- /**
- * Set the input stream from which to read the standard output of the child.
- */
- public void setChildOutputStream(final InputStream in) {
- assert in != null;
-
- createChildOutputPump(in, out);
- }
-
- /**
- * Set the input stream from which to read the standard error of the child.
- */
- public void setChildErrorStream(final InputStream in) {
- assert in != null;
-
- if (err != null) {
- createChildErrorPump(in, err);
- }
- }
-
- /**
- * Set the output stream by means of which input can be sent to the child.
- */
- public void setChildInputStream(final OutputStream out) {
- assert out != null;
-
- if (in != null) {
- inputPump = createInputPump(in, out, true);
- }
- else {
- try {
- out.close();
- } catch (IOException e) { }
- }
- }
-
- /**
- * Attach to a child streams from the given process.
- *
- * @param p The process to attach to.
- */
- public void attach(final Process p) {
- assert p != null;
-
- setChildInputStream(p.getOutputStream());
- setChildOutputStream(p.getInputStream());
- setChildErrorStream(p.getErrorStream());
- }
- /**
- * Start pumping the streams.
- */
- public void start() {
- if (outputThread != null) {
- outputThread.start();
- }
-
- if (errorThread != null) {
- errorThread.start();
- }
-
- if (inputPump != null) {
- Thread inputThread = new Thread(inputPump);
- inputThread.setDaemon(true);
- inputThread.start();
- }
- }
-
- /**
- * Stop pumping the streams.
- */
- public void stop() {
- if (outputThread != null) {
- try {
- outputThread.join();
- }
- catch (InterruptedException e) {
- // ignore
- }
- }
-
- if (errorThread != null) {
- try {
- errorThread.join();
- }
- catch (InterruptedException e) {
- // ignore
- }
- }
-
- if (inputPump != null) {
- inputPump.stop();
- }
-
- try {
- err.flush();
- } catch (IOException e) { }
- try {
- out.flush();
- } catch (IOException e) { }
- }
-
- /**
- * Create the pump to handle child output.
- */
- protected void createChildOutputPump(final InputStream in, final OutputStream out) {
- assert in != null;
- assert out != null;
-
- outputThread = createPump(in, out);
- }
-
- /**
- * Create the pump to handle error output.
- */
- protected void createChildErrorPump(final InputStream in, final OutputStream out) {
- assert in != null;
- assert out != null;
-
- errorThread = createPump(in, out);
- }
-
- /**
- * Creates a stream pumper to copy the given input stream to the given output stream.
- */
- protected Thread createPump(final InputStream in, final OutputStream out) {
- assert in != null;
- assert out != null;
-
- return createPump(in, out, false);
- }
-
- /**
- * Creates a stream pumper to copy the given input stream to the
- * given output stream.
- *
- * @param in The input stream to copy from.
- * @param out The output stream to copy to.
- * @param closeWhenExhausted If true close the inputstream.
- * @return A thread object that does the pumping.
- */
- protected Thread createPump(final InputStream in, final OutputStream out, final boolean closeWhenExhausted) {
- assert in != null;
- assert out != null;
-
- final Thread result = new Thread(new StreamPumper(in, out, closeWhenExhausted));
- result.setDaemon(true);
- return result;
- }
-
- /**
- * Creates a stream pumper to copy the given input stream to the
- * given output stream. Used for standard input.
- */
- protected StreamPumper createInputPump(final InputStream in, final OutputStream out, final boolean closeWhenExhausted) {
- assert in != null;
- assert out != null;
-
- StreamPumper pumper = new StreamPumper(in, out, closeWhenExhausted);
- pumper.setAutoflush(true);
- return pumper;
- }
-}
\ No newline at end of file
diff --git a/karaf/shell/wrapper/src/main/java/org/apache/felix/karaf/shell/wrapper/StreamPumper.java b/karaf/shell/wrapper/src/main/java/org/apache/felix/karaf/shell/wrapper/StreamPumper.java
deleted file mode 100644
index 8c2e689..0000000
--- a/karaf/shell/wrapper/src/main/java/org/apache/felix/karaf/shell/wrapper/StreamPumper.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.karaf.shell.wrapper;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-
-//
-// Based on Apache Ant 1.6.5
-//
-
-/**
- * Copies all data from an input stream to an output stream.
- *
- * @version $Rev: 705608 $ $Date: 2008-10-17 15:28:45 +0200 (Fri, 17 Oct 2008) $
- */
-public class StreamPumper
- implements Runnable
-{
- private InputStream in;
-
- private OutputStream out;
-
- private volatile boolean finish;
-
- private volatile boolean finished;
-
- private boolean closeWhenExhausted;
-
- private boolean autoflush;
-
- private Exception exception;
-
- private int bufferSize = 128;
-
- private boolean started;
-
- /**
- * Create a new stream pumper.
- *
- * @param in Input stream to read data from
- * @param out Output stream to write data to.
- * @param closeWhenExhausted If true, the output stream will be closed when
- * the input is exhausted.
- */
- public StreamPumper(final InputStream in, final OutputStream out, final boolean closeWhenExhausted) {
- assert in != null;
- assert out != null;
-
- this.in = in;
- this.out = out;
- this.closeWhenExhausted = closeWhenExhausted;
- }
-
- /**
- * Create a new stream pumper.
- *
- * @param in Input stream to read data from
- * @param out Output stream to write data to.
- */
- public StreamPumper(final InputStream in, final OutputStream out) {
- this(in, out, false);
- }
-
- /**
- * Set whether data should be flushed through to the output stream.
- *
- * @param autoflush If true, push through data; if false, let it be buffered
- */
- public void setAutoflush(boolean autoflush) {
- this.autoflush = autoflush;
- }
-
- /**
- * Copies data from the input stream to the output stream.
- *
- * Terminates as soon as the input stream is closed or an error occurs.
- */
- public void run() {
- synchronized (this) {
- started = true;
- }
- finished = false;
- finish = false;
-
- final byte[] buf = new byte[bufferSize];
-
- int length;
- try {
- while ((length = in.read(buf)) > 0 && !finish) {
- out.write(buf, 0, length);
- if (autoflush) {
- out.flush();
- }
- }
- out.flush();
- }
- catch (Exception e) {
- synchronized (this) {
- exception = e;
- }
- }
- finally {
- if (closeWhenExhausted) {
- try {
- out.close();
- } catch (IOException e) { }
- }
- finished = true;
-
- synchronized (this) {
- notifyAll();
- }
- }
- }
-
- /**
- * Tells whether the end of the stream has been reached.
- *
- * @return true If the stream has been exhausted.
- */
- public boolean isFinished() {
- return finished;
- }
-
- /**
- * This method blocks until the stream pumper finishes.
- *
- * @see #isFinished()
- */
- public synchronized void waitFor() throws InterruptedException {
- while (!isFinished()) {
- wait();
- }
- }
-
- /**
- * Set the size in bytes of the read buffer.
- *
- * @param bufferSize the buffer size to use.
- * @throws IllegalStateException if the StreamPumper is already running.
- */
- public synchronized void setBufferSize(final int bufferSize) {
- if (started) {
- throw new IllegalStateException("Cannot set buffer size on a running StreamPumper");
- }
-
- this.bufferSize = bufferSize;
- }
-
- /**
- * Get the size in bytes of the read buffer.
- *
- * @return The size of the read buffer.
- */
- public synchronized int getBufferSize() {
- return bufferSize;
- }
-
- /**
- * Get the exception encountered, if any.
- *
- * @return The Exception encountered; or null if there was none.
- */
- public synchronized Exception getException() {
- return exception;
- }
-
- /**
- * Stop the pumper as soon as possible.
- *
- * Note that it may continue to block on the input stream
- * but it will really stop the thread as soon as it gets EOF
- * or any byte, and it will be marked as finished.
- */
- public synchronized void stop() {
- finish = true;
-
- notifyAll();
- }
-}
\ No newline at end of file
diff --git a/karaf/shell/wrapper/src/main/resources/OSGI-INF/blueprint/shell-wrapper.xml b/karaf/shell/wrapper/src/main/resources/OSGI-INF/blueprint/shell-wrapper.xml
deleted file mode 100644
index 522663b..0000000
--- a/karaf/shell/wrapper/src/main/resources/OSGI-INF/blueprint/shell-wrapper.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <command-bundle xmlns="http://felix.apache.org/karaf/xmlns/shell/v1.0.0">
- <command name="wrapper/install">
- <action class="org.apache.felix.karaf.shell.wrapper.InstallCommand"/>
- </command>
- </command-bundle>
-
-</blueprint>
diff --git a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/all/karaf-wrapper.jar b/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/all/karaf-wrapper.jar
deleted file mode 100755
index c766405..0000000
--- a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/all/karaf-wrapper.jar
+++ /dev/null
Binary files differ
diff --git a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/linux/karaf-wrapper b/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/linux/karaf-wrapper
deleted file mode 100644
index c58d4f7..0000000
--- a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/linux/karaf-wrapper
+++ /dev/null
Binary files differ
diff --git a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/linux/libwrapper.so b/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/linux/libwrapper.so
deleted file mode 100644
index df25ec6..0000000
--- a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/linux/libwrapper.so
+++ /dev/null
Binary files differ
diff --git a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/macosx/karaf-wrapper b/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/macosx/karaf-wrapper
deleted file mode 100644
index 8c281b9..0000000
--- a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/macosx/karaf-wrapper
+++ /dev/null
Binary files differ
diff --git a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/macosx/libwrapper.jnilib b/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/macosx/libwrapper.jnilib
deleted file mode 100644
index ae5a14e..0000000
--- a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/macosx/libwrapper.jnilib
+++ /dev/null
Binary files differ
diff --git a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/unix/karaf-service b/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/unix/karaf-service
deleted file mode 100755
index 4fbfbe8..0000000
--- a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/unix/karaf-service
+++ /dev/null
@@ -1,543 +0,0 @@
-#! /bin/sh
-
-# ------------------------------------------------------------------------
-# 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.
-# ------------------------------------------------------------------------
-
-# Application
-APP_NAME="${name}"
-APP_LONG_NAME="${displayName}"
-
-# Wrapper
-WRAPPER_CMD="${karaf.base}/bin/${APP_NAME}-wrapper"
-WRAPPER_CONF="${karaf.base}/etc/${APP_NAME}-wrapper.conf"
-
-# Priority at which to run the wrapper. See "man nice" for valid priorities.
-# nice is only used if a priority is specified.
-PRIORITY=
-
-# Location of the pid file.
-PIDDIR="${karaf.base}/data"
-
-# If uncommented, causes the Wrapper to be shutdown using an anchor file.
-# When launched with the 'start' command, it will also ignore all INT and
-# TERM signals.
-#IGNORE_SIGNALS=true
-
-# If specified, the Wrapper will be run as the specified user.
-# IMPORTANT - Make sure that the user has the required privileges to write
-# the PID file and wrapper.log files. Failure to be able to write the log
-# file will cause the Wrapper to exit without any way to write out an error
-# message.
-# NOTE - This will set the user which is used to run the Wrapper as well as
-# the JVM and is not useful in situations where a privileged resource or
-# port needs to be allocated prior to the user being changed.
-#RUN_AS_USER=
-
-# The following two lines are used by the chkconfig command. Change as is
-# appropriate for your application. They should remain commented.
-# chkconfig: 2345 20 80
-# description: ${displayName}
-
-# Do not modify anything beyond this point
-#-----------------------------------------------------------------------------
-
-# Get the fully qualified path to the script
-case $0 in
- /*)
- SCRIPT="$0"
- ;;
- *)
- PWD=`pwd`
- SCRIPT="$PWD/$0"
- ;;
-esac
-
-# Resolve the true real path without any sym links.
-CHANGED=true
-while [ "X$CHANGED" != "X" ]
-do
- # Change spaces to ":" so the tokens can be parsed.
- SCRIPT=`echo $SCRIPT | sed -e 's; ;:;g'`
- # Get the real path to this script, resolving any symbolic links
- TOKENS=`echo $SCRIPT | sed -e 's;/; ;g'`
- REALPATH=
- for C in $TOKENS; do
- REALPATH="$REALPATH/$C"
- while [ -h "$REALPATH" ] ; do
- LS="`ls -ld "$REALPATH"`"
- LINK="`expr "$LS" : '.*-> \(.*\)$'`"
- if expr "$LINK" : '/.*' > /dev/null; then
- REALPATH="$LINK"
- else
- REALPATH="`dirname "$REALPATH"`""/$LINK"
- fi
- done
- done
- # Change ":" chars back to spaces.
- REALPATH=`echo $REALPATH | sed -e 's;:; ;g'`
-
- if [ "$REALPATH" = "$SCRIPT" ]
- then
- CHANGED=""
- else
- SCRIPT="$REALPATH"
- fi
-done
-
-# Change the current directory to the location of the script
-cd "`dirname "$REALPATH"`"
-REALDIR=`pwd`
-
-# If the PIDDIR is relative, set its value relative to the full REALPATH to avoid problems if
-# the working directory is later changed.
-FIRST_CHAR=`echo $PIDDIR | cut -c1,1`
-if [ "$FIRST_CHAR" != "/" ]
-then
- PIDDIR=$REALDIR/$PIDDIR
-fi
-# Same test for WRAPPER_CMD
-FIRST_CHAR=`echo $WRAPPER_CMD | cut -c1,1`
-if [ "$FIRST_CHAR" != "/" ]
-then
- WRAPPER_CMD=$REALDIR/$WRAPPER_CMD
-fi
-# Same test for WRAPPER_CONF
-FIRST_CHAR=`echo $WRAPPER_CONF | cut -c1,1`
-if [ "$FIRST_CHAR" != "/" ]
-then
- WRAPPER_CONF=$REALDIR/$WRAPPER_CONF
-fi
-
-# Process ID
-ANCHORFILE="$PIDDIR/$APP_NAME.anchor"
-PIDFILE="$PIDDIR/$APP_NAME.pid"
-LOCKDIR="/var/lock/subsys"
-LOCKFILE="$LOCKDIR/$APP_NAME"
-pid=""
-
-# Resolve the location of the 'ps' command
-PSEXE="/usr/bin/ps"
-if [ ! -x $PSEXE ]
-then
- PSEXE="/bin/ps"
- if [ ! -x $PSEXE ]
- then
- echo "Unable to locate 'ps'."
- echo "Please report this message along with the location of the command on your system."
- exit 1
- fi
-fi
-
-# Resolve the os
-DIST_OS=`uname -s | tr [:upper:] [:lower:] | tr -d [:blank:]`
-case "$DIST_OS" in
- 'sunos')
- DIST_OS="solaris"
- ;;
- 'hp-ux' | 'hp-ux64')
- DIST_OS="hpux"
- ;;
- 'darwin')
- DIST_OS="macosx"
- ;;
- 'unix_sv')
- DIST_OS="unixware"
- ;;
-esac
-
-# Resolve the architecture
-DIST_ARCH=`uname -p | tr [:upper:] [:lower:] | tr -d [:blank:]`
-if [ "$DIST_ARCH" = "unknown" ]
-then
- DIST_ARCH=`uname -m | tr [:upper:] [:lower:] | tr -d [:blank:]`
-fi
-case "$DIST_ARCH" in
- 'amd64' | 'ia32' | 'ia64' | 'i386' | 'i486' | 'i586' | 'i686' | 'x86_64')
- DIST_ARCH="x86"
- ;;
- 'ip27')
- DIST_ARCH="mips"
- ;;
- 'power' | 'powerpc' | 'power_pc' | 'ppc64')
- DIST_ARCH="ppc"
- ;;
- 'pa_risc' | 'pa-risc')
- DIST_ARCH="parisc"
- ;;
- 'sun4u' | 'sparcv9')
- DIST_ARCH="sparc"
- ;;
- '9000/800')
- DIST_ARCH="parisc"
- ;;
-esac
-
-# Decide on the wrapper binary to use.
-# If a 32-bit wrapper binary exists then it will work on 32 or 64 bit
-# platforms, if the 64-bit binary exists then the distribution most
-# likely wants to use long names. Otherwise, look for the default.
-# For macosx, we also want to look for universal binaries.
-WRAPPER_TEST_CMD="$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32"
-if [ -x $WRAPPER_TEST_CMD ]
-then
- WRAPPER_CMD="$WRAPPER_TEST_CMD"
-else
- if [ "$DIST_OS" = "macosx" ]
- then
- WRAPPER_TEST_CMD="$WRAPPER_CMD-$DIST_OS-universal-32"
- if [ -x $WRAPPER_TEST_CMD ]
- then
- WRAPPER_CMD="$WRAPPER_TEST_CMD"
- else
- WRAPPER_TEST_CMD="$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-64"
- if [ -x $WRAPPER_TEST_CMD ]
- then
- WRAPPER_CMD="$WRAPPER_TEST_CMD"
- else
- WRAPPER_TEST_CMD="$WRAPPER_CMD-$DIST_OS-universal-64"
- if [ -x $WRAPPER_TEST_CMD ]
- then
- WRAPPER_CMD="$WRAPPER_TEST_CMD"
- else
- if [ ! -x $WRAPPER_CMD ]
- then
- echo "Unable to locate any of the following binaries:"
- echo " $WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32"
- echo " $WRAPPER_CMD-$DIST_OS-universal-32"
- echo " $WRAPPER_CMD-$DIST_OS-$DIST_ARCH-64"
- echo " $WRAPPER_CMD-$DIST_OS-universal-64"
- echo " $WRAPPER_CMD"
- exit 1
- fi
- fi
- fi
- fi
- else
- WRAPPER_TEST_CMD="$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-64"
- if [ -x $WRAPPER_TEST_CMD ]
- then
- WRAPPER_CMD="$WRAPPER_TEST_CMD"
- else
- if [ ! -x $WRAPPER_CMD ]
- then
- echo "Unable to locate any of the following binaries:"
- echo " $WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32"
- echo " $WRAPPER_CMD-$DIST_OS-$DIST_ARCH-64"
- echo " $WRAPPER_CMD"
- exit 1
- fi
- fi
- fi
-fi
-
-# Build the nice clause
-if [ "X$PRIORITY" = "X" ]
-then
- CMDNICE=""
-else
- CMDNICE="nice -$PRIORITY"
-fi
-
-# Build the anchor file clause.
-if [ "X$IGNORE_SIGNALS" = "X" ]
-then
- ANCHORPROP=
- IGNOREPROP=
-else
- ANCHORPROP=wrapper.anchorfile=$ANCHORFILE
- IGNOREPROP=wrapper.ignore_signals=TRUE
-fi
-
-# Build the lock file clause. Only create a lock file if the lock directory exists on this platform.
-if [ -d $LOCKDIR ]
-then
- LOCKPROP=wrapper.lockfile=$LOCKFILE
-else
- LOCKPROP=
-fi
-
-checkUser() {
- # Check the configured user. If necessary rerun this script as the desired user.
- if [ "X$RUN_AS_USER" != "X" ]
- then
- # Resolve the location of the 'id' command
- IDEXE="/usr/xpg4/bin/id"
- if [ ! -x $IDEXE ]
- then
- IDEXE="/usr/bin/id"
- if [ ! -x $IDEXE ]
- then
- echo "Unable to locate 'id'."
- echo "Please report this message along with the location of the command on your system."
- exit 1
- fi
- fi
-
- if [ "`$IDEXE -u -n`" = "$RUN_AS_USER" ]
- then
- # Already running as the configured user. Avoid password prompts by not calling su.
- RUN_AS_USER=""
- fi
- fi
- if [ "X$RUN_AS_USER" != "X" ]
- then
- # If LOCKPROP and $RUN_AS_USER are defined then the new user will most likely not be
- # able to create the lock file. The Wrapper will be able to update this file once it
- # is created but will not be able to delete it on shutdown. If $2 is defined then
- # the lock file should be created for the current command
- if [ "X$LOCKPROP" != "X" ]
- then
- if [ "X$2" != "X" ]
- then
- # Resolve the primary group
- RUN_AS_GROUP=`groups $RUN_AS_USER | awk '{print $3}' | tail -1`
- if [ "X$RUN_AS_GROUP" = "X" ]
- then
- RUN_AS_GROUP=RUN_AS_USER
- fi
- touch $LOCKFILE
- chown $RUN_AS_USER:$RUN_AS_GROUP $LOCKFILE
- fi
- fi
-
- # Still want to change users, recurse. This means that the user will only be
- # prompted for a password once.
- su -m $RUN_AS_USER -c "$REALPATH $1"
-
- # Now that we are the original user again, we may need to clean up the lock file.
- if [ "X$LOCKPROP" != "X" ]
- then
- getpid
- if [ "X$pid" = "X" ]
- then
- # Wrapper is not running so make sure the lock file is deleted.
- if [ -f $LOCKFILE ]
- then
- rm $LOCKFILE
- fi
- fi
- fi
-
- exit 0
- fi
-}
-
-getpid() {
- if [ -f $PIDFILE ]
- then
- if [ -r $PIDFILE ]
- then
- pid=`cat $PIDFILE`
- if [ "X$pid" != "X" ]
- then
- # It is possible that 'a' process with the pid exists but that it is not the
- # correct process. This can happen in a number of cases, but the most
- # common is during system startup after an unclean shutdown.
- # The ps statement below looks for the specific wrapper command running as
- # the pid. If it is not found then the pid file is considered to be stale.
- pidtest=`$PSEXE -p $pid -o command | grep $WRAPPER_CMD | tail -1`
- if [ "X$pidtest" = "X" ]
- then
- # This is a stale pid file.
- rm -f $PIDFILE
- echo "Removed stale pid file: $PIDFILE"
- pid=""
- fi
- fi
- else
- echo "Cannot read $PIDFILE."
- exit 1
- fi
- fi
-}
-
-testpid() {
- pid=`$PSEXE -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1`
- if [ "X$pid" = "X" ]
- then
- # Process is gone so remove the pid file.
- rm -f $PIDFILE
- pid=""
- fi
-}
-
-console() {
- echo "Running $APP_LONG_NAME..."
- getpid
- if [ "X$pid" = "X" ]
- then
- COMMAND_LINE="$CMDNICE $WRAPPER_CMD $WRAPPER_CONF wrapper.syslog.ident=$APP_NAME wrapper.pidfile=$PIDFILE $ANCHORPROP $LOCKPROP"
- exec $COMMAND_LINE
- else
- echo "$APP_LONG_NAME is already running."
- exit 1
- fi
-}
-
-start() {
- echo "Starting $APP_LONG_NAME..."
- getpid
- if [ "X$pid" = "X" ]
- then
- if [ ! -d ../../data ]; then
- mkdir ../../data
- fi
- if [ ! -d ../../data/log ]; then
- mkdir ../../data/log
- fi
- COMMAND_LINE="$CMDNICE $WRAPPER_CMD $WRAPPER_CONF wrapper.syslog.ident=$APP_NAME wrapper.pidfile=$PIDFILE wrapper.daemonize=TRUE $ANCHORPROP $IGNOREPROP $LOCKPROP"
- exec $COMMAND_LINE
- else
- echo "$APP_LONG_NAME is already running."
- exit 1
- fi
-}
-
-stopit() {
- echo "Stopping $APP_LONG_NAME..."
- getpid
- if [ "X$pid" = "X" ]
- then
- echo "$APP_LONG_NAME was not running."
- else
- if [ "X$IGNORE_SIGNALS" = "X" ]
- then
- # Running so try to stop it.
- kill $pid
- if [ $? -ne 0 ]
- then
- # An explanation for the failure should have been given
- echo "Unable to stop $APP_LONG_NAME."
- exit 1
- fi
- else
- rm -f $ANCHORFILE
- if [ -f $ANCHORFILE ]
- then
- # An explanation for the failure should have been given
- echo "Unable to stop $APP_LONG_NAME."
- exit 1
- fi
- fi
-
- # We can not predict how long it will take for the wrapper to
- # actually stop as it depends on settings in wrapper.conf.
- # Loop until it does.
- savepid=$pid
- CNT=0
- TOTCNT=0
- while [ "X$pid" != "X" ]
- do
- # Show a waiting message every 5 seconds.
- if [ "$CNT" -lt "5" ]
- then
- CNT=`expr $CNT + 1`
- else
- echo "Waiting for $APP_LONG_NAME to exit..."
- CNT=0
- fi
- TOTCNT=`expr $TOTCNT + 1`
-
- sleep 1
-
- testpid
- done
-
- pid=$savepid
- testpid
- if [ "X$pid" != "X" ]
- then
- echo "Failed to stop $APP_LONG_NAME."
- exit 1
- else
- echo "Stopped $APP_LONG_NAME."
- fi
- fi
-}
-
-status() {
- getpid
- if [ "X$pid" = "X" ]
- then
- echo "$APP_LONG_NAME is not running."
- exit 1
- else
- echo "$APP_LONG_NAME is running ($pid)."
- exit 0
- fi
-}
-
-dump() {
- echo "Dumping $APP_LONG_NAME..."
- getpid
- if [ "X$pid" = "X" ]
- then
- echo "$APP_LONG_NAME was not running."
-
- else
- kill -3 $pid
-
- if [ $? -ne 0 ]
- then
- echo "Failed to dump $APP_LONG_NAME."
- exit 1
- else
- echo "Dumped $APP_LONG_NAME."
- fi
- fi
-}
-
-case "$1" in
-
- 'console')
- checkUser $1 touchlock
- console
- ;;
-
- 'start')
- checkUser $1 touchlock
- start
- ;;
-
- 'stop')
- checkUser $1
- stopit
- ;;
-
- 'restart')
- checkUser $1 touchlock
- stopit
- start
- ;;
-
- 'status')
- checkUser $1
- status
- ;;
-
- 'dump')
- checkUser $1
- dump
- ;;
-
- *)
- echo "Usage: $0 { console | start | stop | restart | status | dump }"
- exit 1
- ;;
-esac
-
-exit 0
diff --git a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/unix/karaf-wrapper.conf b/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/unix/karaf-wrapper.conf
deleted file mode 100644
index 2ef29cb..0000000
--- a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/unix/karaf-wrapper.conf
+++ /dev/null
@@ -1,126 +0,0 @@
-# ------------------------------------------------------------------------
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ------------------------------------------------------------------------
-
-#********************************************************************
-# Wrapper Properties
-#********************************************************************
-set.default.KARAF_HOME=${karaf.home}
-set.default.KARAF_BASE=${karaf.base}
-
-# Java Application
-wrapper.working.dir=%KARAF_BASE%
-wrapper.java.command=java
-wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
-wrapper.java.classpath.1=%KARAF_BASE%/lib/karaf-wrapper.jar
-wrapper.java.classpath.2=%KARAF_HOME%/lib/karaf.jar
-wrapper.java.classpath.3=%KARAF_HOME%/lib/karaf-jaas-boot.jar
-wrapper.java.library.path.1=%KARAF_BASE%/lib/
-
-# Application Parameters. Add parameters as needed starting from 1
-wrapper.app.parameter.1=org.apache.felix.karaf.main.Bootstrap
-
-# JVM Parameters
-# note that n is the parameter number starting from 1.
-wrapper.java.additional.1=-Dkaraf.home=%KARAF_HOME%
-wrapper.java.additional.2=-Dkaraf.base=%KARAF_BASE%
-wrapper.java.additional.3=-Dcom.sun.management.jmxremote
-wrapper.java.additional.4=-Dkaraf.startLocalConsole=false
-wrapper.java.additional.5=-Dkaraf.startRemoteShell=true
-wrapper.java.additional.6=-Djava.endorsed.dirs="%JAVA_HOME%/jre/lib/endorsed;%JAVA_HOME%/lib/endorsed;%KARAF_HOME%/lib/endorsed"
-wrapper.java.additional.7=-Djava.ext.dirs="%JAVA_HOME%/jre/lib/ext;%JAVA_HOME%/lib/ext;%KARAF_HOME%/lib/ext"
-
-# Uncomment to enable jmx
-#wrapper.java.additional.n=-Dcom.sun.management.jmxremote.port=1616
-#wrapper.java.additional.n=-Dcom.sun.management.jmxremote.authenticate=false
-#wrapper.java.additional.n=-Dcom.sun.management.jmxremote.ssl=false
-
-# Uncomment to enable YourKit profiling
-#wrapper.java.additional.n=-Xrunyjpagent
-
-# Uncomment to enable remote debugging
-#wrapper.java.additional.n=-Xdebug -Xnoagent -Djava.compiler=NONE
-#wrapper.java.additional.n=-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
-
-# Initial Java Heap Size (in MB)
-#wrapper.java.initmemory=3
-
-# Maximum Java Heap Size (in MB)
-wrapper.java.maxmemory=512
-
-
-#********************************************************************
-# Wrapper Logging Properties
-#********************************************************************
-# Format of output for the console. (See docs for formats)
-wrapper.console.format=PM
-
-# Log Level for console output. (See docs for log levels)
-wrapper.console.loglevel=INFO
-
-# Log file to use for wrapper output logging.
-wrapper.logfile=%KARAF_BASE%/data/log/wrapper.log
-
-# Format of output for the log file. (See docs for formats)
-wrapper.logfile.format=LPTM
-
-# Log Level for log file output. (See docs for log levels)
-wrapper.logfile.loglevel=INFO
-
-# Maximum size that the log file will be allowed to grow to before
-# the log is rolled. Size is specified in bytes. The default value
-# of 0, disables log rolling. May abbreviate with the 'k' (kb) or
-# 'm' (mb) suffix. For example: 10m = 10 megabytes.
-wrapper.logfile.maxsize=10m
-
-# Maximum number of rolled log files which will be allowed before old
-# files are deleted. The default value of 0 implies no limit.
-wrapper.logfile.maxfiles=5
-
-# Log Level for sys/event log output. (See docs for log levels)
-wrapper.syslog.loglevel=NONE
-
-#********************************************************************
-# Wrapper Windows Properties
-#********************************************************************
-# Title to use when running as a console
-wrapper.console.title=${name}
-
-#********************************************************************
-# Wrapper Windows NT/2000/XP Service Properties
-#********************************************************************
-# WARNING - Do not modify any of these properties when an application
-# using this configuration file has been installed as a service.
-# Please uninstall the service before modifying this section. The
-# service can then be reinstalled.
-
-# Name of the service
-wrapper.ntservice.name=${name}
-
-# Display name of the service
-wrapper.ntservice.displayname=${displayName}
-
-# Description of the service
-wrapper.ntservice.description=${description}
-
-# Service dependencies. Add dependencies as needed starting from 1
-wrapper.ntservice.dependency.1=
-
-# Mode in which the service is installed. AUTO_START or DEMAND_START
-wrapper.ntservice.starttype=${startType}
-
-# Allow the service to interact with the desktop.
-wrapper.ntservice.interactive=false
diff --git a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/windows/karaf-service.bat b/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/windows/karaf-service.bat
deleted file mode 100644
index f29dccd..0000000
--- a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/windows/karaf-service.bat
+++ /dev/null
@@ -1,50 +0,0 @@
-@echo off
-
-REM ------------------------------------------------------------------------
-REM Licensed to the Apache Software Foundation (ASF) under one or more
-REM contributor license agreements. See the NOTICE file distributed with
-REM this work for additional information regarding copyright ownership.
-REM The ASF licenses this file to You under the Apache License, Version 2.0
-REM (the "License"); you may not use this file except in compliance with
-REM the License. You may obtain a copy of the License at
-REM
-REM http://www.apache.org/licenses/LICENSE-2.0
-REM
-REM Unless required by applicable law or agreed to in writing, software
-REM distributed under the License is distributed on an "AS IS" BASIS,
-REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-REM See the License for the specific language governing permissions and
-REM limitations under the License.
-REM ------------------------------------------------------------------------
-
-setlocal
-
-set APP_NAME=${name}
-set APP_LONG_NAME=${displayName}
-set APP_BASE=${karaf.base}
-
-if ""%1"" == ""run"" goto doRun
-if ""%1"" == ""install"" goto doInstall
-if ""%1"" == ""remove"" goto doRemove
-
-echo Usage: karaf-service ( commands ... )
-echo commands:
-echo run Start %APP_NAME% in the current console
-echo install Install %APP_NAME% as a Windows service
-echo remove Remove the %APP_NAME% Windows service
-goto end
-
-:doRun
-"%APP_BASE%\bin\%APP_NAME%-wrapper.exe" -c "%APP_BASE%\etc\%APP_NAME%-wrapper.conf"
-goto end
-
-:doInstall
-"%APP_BASE%\bin\%APP_NAME%-wrapper.exe" -i "%APP_BASE%\etc\%APP_NAME%-wrapper.conf"
-goto end
-
-:doRemove
-"%APP_BASE%\bin\%APP_NAME%-wrapper.exe" -r "%APP_BASE%\etc\%APP_NAME%-wrapper.conf"
-goto end
-
-:end
-if not "%PAUSE%" == "" pause
diff --git a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/windows/karaf-wrapper.conf b/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/windows/karaf-wrapper.conf
deleted file mode 100644
index 196beff..0000000
--- a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/windows/karaf-wrapper.conf
+++ /dev/null
@@ -1,126 +0,0 @@
-# ------------------------------------------------------------------------
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ------------------------------------------------------------------------
-
-#********************************************************************
-# Wrapper Properties
-#********************************************************************
-set.default.KARAF_HOME=${karaf.home}
-set.default.KARAF_BASE=${karaf.base}
-
-# Java Application
-wrapper.working.dir=%KARAF_BASE%
-wrapper.java.command=java
-wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
-wrapper.java.classpath.1=%KARAF_BASE%/lib/karaf-wrapper.jar
-wrapper.java.classpath.2=%KARAF_HOME%/lib/karaf.jar
-wrapper.java.classpath.3=%KARAF_HOME%/lib/karaf-jaas-boot.jar
-wrapper.java.library.path.1=%KARAF_BASE%/lib/
-
-# Application Parameters. Add parameters as needed starting from 1
-wrapper.app.parameter.1=org.apache.felix.karaf.main.Bootstrap
-
-# JVM Parameters
-# note that n is the parameter number starting from 1.
-wrapper.java.additional.1=-Dkaraf.home="%KARAF_HOME%"
-wrapper.java.additional.2=-Dkaraf.base="%KARAF_BASE%"
-wrapper.java.additional.3=-Dcom.sun.management.jmxremote
-wrapper.java.additional.4=-Dkaraf.startLocalConsole=false
-wrapper.java.additional.5=-Dkaraf.startRemoteShell=true
-wrapper.java.additional.6=-Djava.endorsed.dirs="%JAVA_HOME%/jre/lib/endorsed;%JAVA_HOME%/lib/endorsed;%KARAF_HOME%/lib/endorsed"
-wrapper.java.additional.7=-Djava.ext.dirs="%JAVA_HOME%/jre/lib/ext;%JAVA_HOME%/lib/ext;%KARAF_HOME%/lib/ext"
-
-# Uncomment to enable jmx
-#wrapper.java.additional.n=-Dcom.sun.management.jmxremote.port=1616
-#wrapper.java.additional.n=-Dcom.sun.management.jmxremote.authenticate=false
-#wrapper.java.additional.n=-Dcom.sun.management.jmxremote.ssl=false
-
-# Uncomment to enable YourKit profiling
-#wrapper.java.additional.n=-Xrunyjpagent
-
-# Uncomment to enable remote debugging
-#wrapper.java.additional.n=-Xdebug -Xnoagent -Djava.compiler=NONE
-#wrapper.java.additional.n=-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
-
-# Initial Java Heap Size (in MB)
-#wrapper.java.initmemory=3
-
-# Maximum Java Heap Size (in MB)
-wrapper.java.maxmemory=512
-
-
-#********************************************************************
-# Wrapper Logging Properties
-#********************************************************************
-# Format of output for the console. (See docs for formats)
-wrapper.console.format=PM
-
-# Log Level for console output. (See docs for log levels)
-wrapper.console.loglevel=INFO
-
-# Log file to use for wrapper output logging.
-wrapper.logfile=%KARAF_BASE%/data/log/wrapper.log
-
-# Format of output for the log file. (See docs for formats)
-wrapper.logfile.format=LPTM
-
-# Log Level for log file output. (See docs for log levels)
-wrapper.logfile.loglevel=INFO
-
-# Maximum size that the log file will be allowed to grow to before
-# the log is rolled. Size is specified in bytes. The default value
-# of 0, disables log rolling. May abbreviate with the 'k' (kb) or
-# 'm' (mb) suffix. For example: 10m = 10 megabytes.
-wrapper.logfile.maxsize=10m
-
-# Maximum number of rolled log files which will be allowed before old
-# files are deleted. The default value of 0 implies no limit.
-wrapper.logfile.maxfiles=5
-
-# Log Level for sys/event log output. (See docs for log levels)
-wrapper.syslog.loglevel=NONE
-
-#********************************************************************
-# Wrapper Windows Properties
-#********************************************************************
-# Title to use when running as a console
-wrapper.console.title=${name}
-
-#********************************************************************
-# Wrapper Windows NT/2000/XP Service Properties
-#********************************************************************
-# WARNING - Do not modify any of these properties when an application
-# using this configuration file has been installed as a service.
-# Please uninstall the service before modifying this section. The
-# service can then be reinstalled.
-
-# Name of the service
-wrapper.ntservice.name=${name}
-
-# Display name of the service
-wrapper.ntservice.displayname=${displayName}
-
-# Description of the service
-wrapper.ntservice.description=${description}
-
-# Service dependencies. Add dependencies as needed starting from 1
-wrapper.ntservice.dependency.1=
-
-# Mode in which the service is installed. AUTO_START or DEMAND_START
-wrapper.ntservice.starttype=${startType}
-
-# Allow the service to interact with the desktop.
-wrapper.ntservice.interactive=false
diff --git a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/windows/karaf-wrapper.exe b/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/windows/karaf-wrapper.exe
deleted file mode 100644
index a46a2ac..0000000
--- a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/windows/karaf-wrapper.exe
+++ /dev/null
Binary files differ
diff --git a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/windows/wrapper.dll b/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/windows/wrapper.dll
deleted file mode 100644
index 37c4f33..0000000
--- a/karaf/shell/wrapper/src/main/resources/org/apache/felix/karaf/shell/wrapper/windows/wrapper.dll
+++ /dev/null
Binary files differ
diff --git a/karaf/tooling/cmdhelp-maven-plugin/pom.xml b/karaf/tooling/cmdhelp-maven-plugin/pom.xml
deleted file mode 100644
index 4edc4a1..0000000
--- a/karaf/tooling/cmdhelp-maven-plugin/pom.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-<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/maven-v4_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.felix.karaf.tooling</groupId>
- <artifactId>tooling</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.tooling</groupId>
- <artifactId>cmdhelp-maven-plugin</artifactId>
- <packaging>maven-plugin</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Maven2 Command Help plugin</name>
-
- <description>
- A Maven 2 plugin for extracting Karaf command helps into markup
- </description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.xbean</groupId>
- <artifactId>xbean-finder-shaded</artifactId>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/karaf/tooling/cmdhelp-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/cmdhelp/CmdHelpMojo.java b/karaf/tooling/cmdhelp-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/cmdhelp/CmdHelpMojo.java
deleted file mode 100644
index fe634a3..0000000
--- a/karaf/tooling/cmdhelp-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/cmdhelp/CmdHelpMojo.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.tooling.cmdhelp;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintStream;
-import java.io.Writer;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.apache.felix.gogo.commands.Action;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.karaf.shell.console.commands.BlueprintCommand;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-import org.apache.xbean.finder.ClassFinder;
-import org.osgi.service.command.CommandSession;
-
-/**
- * Generates docbook for Karaf commands
- *
- * @version $Revision: 1.1 $
- * @goal cmdhelp
- * @phase generate-resources
- * @execute phase="generate-resources"
- * @requiresDependencyResolution runtime
- * @inheritByDefault false
- * @description Generates help for Karaf commands
- */
-public class CmdHelpMojo extends AbstractMojo {
-
- /**
- * The maven project.
- *
- * @parameter expression="${project}"
- * @required
- */
- protected MavenProject project;
-
- /**
- * The output folder
- *
- * @parameter default-value="${project.build.directory}/docbkx/sources"
- */
- protected File targetFolder;
-
- public void execute() throws MojoExecutionException, MojoFailureException {
- try {
- if (!targetFolder.exists()) {
- targetFolder.mkdirs();
- }
-
- List<URL> urls = new ArrayList<URL>();
- for (Object object : project.getCompileClasspathElements()) {
- String path = (String) object;
- urls.add(new File(path).toURI().toURL());
- }
-
- ClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), getClass().getClassLoader());
- ClassFinder finder = new ClassFinder(loader, urls);
- List<Class> classes = finder.findAnnotatedClasses(Command.class);
- if (classes.isEmpty()) {
- throw new MojoFailureException("No command found");
- }
-
- Map<String, Set<String>> commands = new TreeMap<String, Set<String>>();
-
- for (Class clazz : classes) {
- try {
- String help = new HelpPrinter(clazz).printHelp();
- Command cmd = (Command) clazz.getAnnotation(Command.class);
- File output = new File(targetFolder, cmd.scope() + "-" + cmd.name() + ".xml");
- Writer writer = new OutputStreamWriter(new FileOutputStream(output));
- writer.write(help);
- writer.close();
-
- Set<String> cmds = commands.get(cmd.scope());
- if (cmds == null) {
- cmds = new TreeSet<String>();
- commands.put(cmd.scope(), cmds);
- }
- cmds.add(cmd.name());
- getLog().info("Found command: " + cmd.scope() + ":" + cmd.name());
- } catch (Exception e) {
- getLog().warn("Unable to write help for " + clazz.getName(), e);
- }
- }
-
- PrintStream writer = new PrintStream(new FileOutputStream(new File(targetFolder, "commands.xml")));
- writer.println("<chapter id='commands' xmlns:xi=\"http://www.w3.org/2001/XInclude\">");
- writer.println(" <title>Commands</title>");
- writer.println(" <toc></toc>");
-
- for (String key : commands.keySet()) {
- writer.println(" <section id='commands-" + key + "'>");
- writer.println(" <title>" + key + "</title>");
- for (String cmd : commands.get(key)) {
- writer.println(" <xi:include href='" + key + "-" + cmd + ".xml' parse='xml'/>");
- }
- writer.println(" </section>");
- }
- writer.println("</chapter>");
- writer.close();
-
- } catch (Exception e) {
- throw new MojoExecutionException("Error building commands help", e);
- }
- }
-
- public static class HelpPrinter extends BlueprintCommand {
-
- private final Class<Action> actionClass;
-
- public HelpPrinter(Class<Action> actionClass) {
- this.actionClass = actionClass;
- }
-
- public String printHelp() throws Exception {
- PrintStream oldout = System.out;
- try {
- Action action = actionClass.newInstance();
- CommandSession session = new DummyCommandSession();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream newout = new PrintStream(baos);
- System.setOut(newout);
- new Preparator().prepare(action, session, Collections.<Object>singletonList("--help"));
- newout.close();
- baos.close();
- return baos.toString();
- } finally {
- System.setOut(oldout);
- }
- }
-
- protected class Preparator extends BlueprintActionPreparator {
-
- @Override
- protected void printUsage(CommandSession session, Command command, Set<Option> options, Set<Argument> args, PrintStream out)
- {
- List<Argument> arguments = new ArrayList<Argument>(args);
- Collections.sort(arguments, new Comparator<Argument>() {
- public int compare(Argument o1, Argument o2) {
- return Integer.valueOf(o1.index()).compareTo(Integer.valueOf(o2.index()));
- }
- });
- options = new HashSet<Option>(options);
- options.add(HELP);
-
- out.println("<section>");
- out.print(" <title>");
- out.print(command.scope());
- out.print(":");
- out.print(command.name());
- out.println("</title>");
- out.println(" <section>");
- out.println(" <title>Description</title>");
- out.println(" <para>");
- out.println(command.description());
- out.println(" </para>");
- out.println(" </section>");
-
- StringBuffer syntax = new StringBuffer();
- syntax.append(String.format("%s:%s", command.scope(), command.name()));
- if (options.size() > 0) {
- syntax.append(" [options]");
- }
- if (arguments.size() > 0) {
- syntax.append(' ');
- for (Argument argument : arguments) {
- syntax.append(String.format(argument.required() ? "%s " : "[%s] ", argument.name()));
- }
- }
- out.println(" <section>");
- out.println(" <title>Syntax</title>");
- out.println(" <para>");
- out.println(syntax.toString());
- out.println(" </para>");
- out.println(" </section>");
-
- if (arguments.size() > 0)
- {
- out.println(" <section>");
- out.println(" <title>Arguments</title>");
- out.println(" <informaltable>");
- for (Argument argument : arguments)
- {
- out.println(" <tr>");
- out.println(" <td>" + argument.name() + "</td>");
- out.println(" <td>" + argument.description() + "</td>");
- out.println(" </tr>");
- }
-
- out.println(" </informaltable>");
- out.println(" </section>");
- }
- if (options.size() > 0)
- {
- out.println(" <section>");
- out.println(" <title>Options</title>");
- out.println(" <informaltable>");
-
- for (Option option : options)
- {
- String opt = option.name();
- for (String alias : option.aliases())
- {
- opt += ", " + alias;
- }
- out.println(" <tr>");
- out.println(" <td>" + opt + "</td>");
- out.println(" <td>" + option.description() + "</td>");
- out.println(" </tr>");
- }
-
- out.println(" </informaltable>");
- out.println(" </section>");
- }
- out.println("</section>");
- }
-
- }
-
- protected static class DummyCommandSession implements CommandSession {
- public Object convert(Class<?> type, Object instance) {
- return null;
- }
- public CharSequence format(Object target, int level) {
- return null;
- }
- public void put(String name, Object value) {
- }
- public Object get(String name) {
- return null;
- }
- public PrintStream getConsole() {
- return null;
- }
- public InputStream getKeyboard() {
- return null;
- }
- public void close() {
- }
- public Object execute(CharSequence commandline) throws Exception {
- return null;
- }
- }
-
- }
-
-}
diff --git a/karaf/tooling/features-maven-plugin/NOTICE b/karaf/tooling/features-maven-plugin/NOTICE
deleted file mode 100644
index 8656d3d..0000000
--- a/karaf/tooling/features-maven-plugin/NOTICE
+++ /dev/null
@@ -1,16 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/tooling/features-maven-plugin/pom.xml b/karaf/tooling/features-maven-plugin/pom.xml
deleted file mode 100644
index 1a44ed5..0000000
--- a/karaf/tooling/features-maven-plugin/pom.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-<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/maven-v4_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.felix.karaf.tooling</groupId>
- <artifactId>tooling</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.tooling</groupId>
- <artifactId>features-maven-plugin</artifactId>
- <packaging>maven-plugin</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Maven2 Features plugin</name>
-
- <description>
- A Maven 2 plugin for working with feature descriptors
- </description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.features</groupId>
- <artifactId>org.apache.felix.karaf.features.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/AddFeaturesToRepoMojo.java b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/AddFeaturesToRepoMojo.java
deleted file mode 100644
index 666d041..0000000
--- a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/AddFeaturesToRepoMojo.java
+++ /dev/null
@@ -1,326 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.tooling.features;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Properties;
-import java.util.Hashtable;
-import java.util.Set;
-import java.util.HashSet;
-import java.io.File;
-import java.io.IOException;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.BufferedOutputStream;
-import java.io.FileOutputStream;
-import java.io.FileInputStream;
-import java.net.URI;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.w3c.dom.*;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.artifact.Artifact;
-import org.xml.sax.SAXException;
-
-/**
- * Generates the features XML file
- *
- * @version $Revision: 1.1 $
- * @goal add-features-to-repo
- * @phase compile
- * @execute phase="compile"
- * @requiresDependencyResolution runtime
- * @inheritByDefault true
- * @description Add the features to the repository
- */
-public class AddFeaturesToRepoMojo extends MojoSupport {
-
- /**
- * @parameter
- */
- private List<String> descriptors;
-
- /**
- * @parameter
- */
- private List<String> features;
-
- /**
- * @parameter
- */
- private File repository;
-
- /**
- * @parameter
- */
- private boolean skipNonMavenProtocols = true;
-
- public void execute() throws MojoExecutionException, MojoFailureException {
- try {
- Map<String, Feature> featuresMap = new HashMap<String, Feature>();
- for (String uri : descriptors) {
- Repository repo = new Repository(URI.create(translateFromMaven(uri)));
- for (Feature f : repo.getFeatures()) {
- featuresMap.put(f.getName(), f);
- }
- }
- Set<String> transitiveFeatures = new HashSet<String>();
- addFeatures(features, transitiveFeatures, featuresMap);
- Set<String> bundles = new HashSet<String>();
- for (String feature : transitiveFeatures) {
- bundles.addAll(featuresMap.get(feature).getBundles());
- }
- getLog().info("Base repo: " + localRepo.getUrl());
- for (String bundle : bundles) {
- final int index = bundle.indexOf("mvn:");
- if (index < 0) {
- if (skipNonMavenProtocols) {
- continue;
- }
- throw new MojoExecutionException("Bundle url is not a maven url: " + bundle);
- }
- else {
- bundle = bundle.substring(index);
- }
- // Truncate the URL when a '#' or a '?' is encountered
- final int index1 = bundle.indexOf('?');
- final int index2 = bundle.indexOf('#');
- int endIndex = -1;
- if (index1 > 0) {
- if (index2 > 0) {
- endIndex = Math.min(index1, index2);
- } else {
- endIndex = index1;
- }
- } else if (index2 > 0) {
- endIndex = index2;
- }
- if (endIndex >= 0) {
- bundle = bundle.substring(0, endIndex);
- }
-
- String[] parts = bundle.substring("mvn:".length()).split("/");
- String groupId = parts[0];
- String artifactId = parts[1];
- String version = null;
- String classifier = null;
- String type = "jar";
- if (parts.length > 2) {
- version = parts[2];
- if (parts.length > 3) {
- type = parts[3];
- if (parts.length > 4) {
- classifier = parts[4];
- }
- }
- }
- String dir = groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/";
- String name = artifactId + "-" + version + (classifier != null ? "-" + classifier : "") + "." + type;
-
- Artifact artifact;
- try {
- artifact = this.factory.createArtifactWithClassifier(groupId, artifactId, version, type, classifier);
- getLog().info("Copying bundle: " + bundle);
- resolver.resolve(artifact, this.remoteRepos, this.localRepo);
- copy(new FileInputStream(artifact.getFile()),
- repository,
- name,
- dir,
- new byte[8192]);
- } catch (ArtifactResolutionException e) {
- getLog().error("Can't resolve bundle " + bundle, e);
- } catch (ArtifactNotFoundException e) {
- getLog().error("Can't resolve bundle " + bundle, e);
- }
-
-
- }
- } catch (MojoExecutionException e) {
- throw e;
- } catch (MojoFailureException e) {
- throw e;
- } catch (Exception e) {
- throw new MojoExecutionException("Error populating repository", e);
- }
- }
-
- private void addFeatures(List<String> features, Set<String> transitiveFeatures, Map<String, Feature> featuresMap) {
- for (String feature : features) {
- Feature f = featuresMap.get(feature);
- if (f == null) {
- throw new IllegalArgumentException("Unable to find the feature '" + feature + "'");
- }
- transitiveFeatures.add(feature);
- addFeatures(f.getDependencies(), transitiveFeatures, featuresMap);
- }
- }
-
- public static void copy(
- InputStream is, File dir, String destName, String destDir, byte[] buffer)
- throws IOException
- {
- if (destDir == null)
- {
- destDir = "";
- }
-
- // Make sure the target directory exists and
- // that is actually a directory.
- File targetDir = new File(dir, destDir);
- if (!targetDir.exists())
- {
- if (!targetDir.mkdirs())
- {
- throw new IOException("Unable to create target directory: "
- + targetDir);
- }
- }
- else if (!targetDir.isDirectory())
- {
- throw new IOException("Target is not a directory: "
- + targetDir);
- }
-
- BufferedOutputStream bos = new BufferedOutputStream(
- new FileOutputStream(new File(targetDir, destName)));
- int count = 0;
- while ((count = is.read(buffer)) > 0)
- {
- bos.write(buffer, 0, count);
- }
- bos.close();
- }
-
- public static class Feature {
-
- private String name;
- private List<String> dependencies = new ArrayList<String>();
- private List<String> bundles = new ArrayList<String>();
- private Map<String, Map<String,String>> configs = new HashMap<String, Map<String,String>>();
-
- public Feature(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public List<String> getDependencies() {
- return dependencies;
- }
-
- public List<String> getBundles() {
- return bundles;
- }
-
- public Map<String, Map<String, String>> getConfigurations() {
- return configs;
- }
-
- public void addDependency(String dependency) {
- dependencies.add(dependency);
- }
-
- public void addBundle(String bundle) {
- bundles.add(bundle);
- }
-
- public void addConfig(String name, Map<String,String> properties) {
- configs.put(name, properties);
- }
- }
-
- public static class Repository {
-
- private URI uri;
- private List<Feature> features;
-
- public Repository(URI uri) {
- this.uri = uri;
- }
-
- public URI getURI() {
- return uri;
- }
-
- public Feature[] getFeatures() throws Exception {
- if (features == null) {
- load();
- }
- return features.toArray(new Feature[features.size()]);
- }
-
- public void load() throws IOException {
- try {
- features = new ArrayList<Feature>();
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- Document doc = factory.newDocumentBuilder().parse(uri.toURL().openStream());
- NodeList nodes = doc.getDocumentElement().getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++) {
- org.w3c.dom.Node node = nodes.item(i);
- if (!(node instanceof Element) || !"feature".equals(node.getNodeName())) {
- continue;
- }
- Element e = (Element) nodes.item(i);
- String name = e.getAttribute("name");
- Feature f = new Feature(name);
- NodeList featureNodes = e.getElementsByTagName("feature");
- for (int j = 0; j < featureNodes.getLength(); j++) {
- Element b = (Element) featureNodes.item(j);
- f.addDependency(b.getTextContent());
- }
- NodeList configNodes = e.getElementsByTagName("config");
- for (int j = 0; j < configNodes.getLength(); j++) {
- Element c = (Element) configNodes.item(j);
- String cfgName = c.getAttribute("name");
- String data = c.getTextContent();
- Properties properties = new Properties();
- properties.load(new ByteArrayInputStream(data.getBytes()));
- Map<String, String> hashtable = new Hashtable<String, String>();
- for (Object key : properties.keySet()) {
- String n = key.toString();
- hashtable.put(n, properties.getProperty(n));
- }
- f.addConfig(cfgName, hashtable);
- }
- NodeList bundleNodes = e.getElementsByTagName("bundle");
- for (int j = 0; j < bundleNodes.getLength(); j++) {
- Element b = (Element) bundleNodes.item(j);
- f.addBundle(b.getTextContent());
- }
- features.add(f);
- }
- } catch (SAXException e) {
- throw (IOException) new IOException().initCause(e);
- } catch (ParserConfigurationException e) {
- throw (IOException) new IOException().initCause(e);
- }
- }
-
- }
-}
diff --git a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesFileMojo.java b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesFileMojo.java
deleted file mode 100644
index 4562b8b..0000000
--- a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesFileMojo.java
+++ /dev/null
@@ -1,479 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.tooling.features;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.jar.Manifest;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipException;
-import java.util.zip.ZipFile;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.InvalidArtifactRTException;
-import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
-import org.apache.maven.artifact.metadata.ResolutionGroup;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.versioning.ArtifactVersion;
-import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
-import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
-import org.apache.maven.artifact.versioning.VersionRange;
-import org.apache.maven.model.Dependency;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-
-/**
- * Generates the features XML file
- *
- * @version $Revision: 1.1 $
- * @goal generate-features-file
- * @phase compile
- * @execute phase="compile"
- * @requiresDependencyResolution runtime
- * @inheritByDefault true
- * @description Generates the features XML file
- */
-@SuppressWarnings("unchecked")
-public class GenerateFeaturesFileMojo extends MojoSupport {
- protected static final String SEPARATOR = "/";
-
- /**
- * The file to generate
- *
- * @parameter default-value="${project.build.directory}/classes/feature.xml"
- */
- private File outputFile;
-
- /**
- * The name of the feature, which defaults to the artifact ID if its not
- * specified
- *
- * @parameter default-value="${project.artifactId}"
- */
- private String featureName;
-
- /**
- * The artifact type for attaching the generated file to the project
- *
- * @parameter default-value="xml"
- */
- private String attachmentArtifactType = "xml";
-
- /**
- * The artifact classifier for attaching the generated file to the project
- *
- * @parameter default-value="features"
- */
- private String attachmentArtifactClassifier = "features";
-
- /**
- * Should we generate a <feature> for the current project?
- *
- * @parameter default-value="false"
- */
- private boolean includeProject = false;
-
- /**
- * Should we generate a <feature> for the current project's <dependency>s?
- *
- * @parameter default-value="true"
- */
- private boolean includeDependencies = true;
-
- /**
- * The kernel version for which to generate the bundle
- *
- * @parameter
- */
- private String karafVersion;
-
- /**
- * A properties file containing bundle translations
- *
- * @parameter
- */
- private File translation;
-
- /*
- * The translations
- */
- private Map<String, Map<VersionRange, String>> translations = new HashMap<String, Map<VersionRange,String>>() {
- @Override
- public Map<VersionRange, String> get(Object key) {
- if (super.get(key) == null) {
- super.put(key.toString(), new HashMap<VersionRange, String>());
- }
- return super.get(key);
- }
- };
-
- /*
- * These bundles are the features that will be built
- */
- private Set<Artifact> features = new HashSet<Artifact>();
-
- /*
- * These bundles are provided by SMX4 and will be excluded from <feature/>
- * generation
- */
- private Set<Artifact> provided = new HashSet<Artifact>();
-
- /*
- * List of bundles included in the current feature
- */
- private Set<Artifact> currentFeature = new HashSet<Artifact>();
-
- /*
- * List of missing bundles
- */
- private Set<Artifact> missingBundles = new TreeSet<Artifact>();
-
- public void execute() throws MojoExecutionException, MojoFailureException {
- OutputStream out = null;
- try {
- prepare();
- getLog().info(String.format("-- Start generating %s --", outputFile.getAbsolutePath()));
- outputFile.getParentFile().mkdirs();
- out = new FileOutputStream(outputFile);
-
- PrintStream printer = new PrintStream(out);
- populateProperties(printer);
- getLog().info(String.format("-- Done generating %s --", outputFile.getAbsolutePath()));
-
- // now lets attach it
- projectHelper.attachArtifact(project, attachmentArtifactType, attachmentArtifactClassifier, outputFile);
- } catch (Exception e) {
- throw new MojoExecutionException("Unable to create dependencies file: " + e, e);
- } finally {
- if (out != null) {
- try {
- out.close();
- } catch (IOException e) {
- getLog().info("Failed to close: " + outputFile + ". Reason: " + e, e);
- }
- }
- }
- }
-
- protected void populateProperties(PrintStream out) throws ArtifactResolutionException, ArtifactNotFoundException, IOException {
- out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- out.println("<features>");
- if (includeProject) {
- writeCurrentProjectFeature(out);
- }
- if (includeDependencies) {
- writeProjectDependencyFeatures(out);
- }
- out.println("</features>");
- }
-
- private void prepare() throws ArtifactResolutionException, ArtifactNotFoundException, IOException, InvalidVersionSpecificationException {
- if (translation != null) {
- InputStream stream = null;
- try {
- stream = new BufferedInputStream(new FileInputStream(translation));
- Properties file = new Properties();
- file.load(stream);
- ArrayList<String> stringNames = getStringNames(file);
- for (String key : stringNames) {
- String[] elements = key.split("/");
- translations.get(String.format("%s/%s", elements[0], elements[1]))
- .put(VersionRange.createFromVersionSpec(elements[2]), file.getProperty(key));
- }
- getLog().info("Loaded " + translations.size() + " bundle name translation rules from " + translation.getAbsolutePath());
- } finally {
- if (stream != null) {
- stream.close();
- }
- }
- }
-
- Artifact kernel = factory.createArtifact("org.apache.felix.karaf",
- "apache-felix-karaf",
- karafVersion, Artifact.SCOPE_PROVIDED, "pom");
- resolver.resolve(kernel, remoteRepos, localRepo);
- getLog().info("-- List of bundles provided by Karaf " + karafVersion + " --");
- for (Artifact artifact : getDependencies(kernel)) {
- getLog().info(" " + artifact);
- provided.add(artifact);
- }
- getLog().info("-- <end of list> --");
- }
-
- private ArrayList<String> getStringNames(Properties file) {
- // this method simulate the Properties.stringPropertyNames() of JDK6 in order to make this class
- // compile with jdk5
- ArrayList<String> ret = new ArrayList<String>();
- Enumeration<?> name = file.propertyNames();
- while (name.hasMoreElements()) {
- Object ele = name.nextElement();
- if (ele instanceof String && file.get(ele) instanceof String) {
- ret.add((String)ele);
- }
- }
- return ret;
- }
-
- private void writeProjectDependencyFeatures(PrintStream out) {
- Set<Artifact> dependencies = (Set<Artifact>)project.getDependencyArtifacts();
- dependencies.removeAll(provided);
- for (Artifact artifact : dependencies) {
- getLog().info(" Generating feature " + artifact.getArtifactId() + " from " + artifact);
- out.println(" <feature name='" + artifact.getArtifactId() + "'>");
- currentFeature.clear();
- writeBundle(out, artifact);
- features.add(artifact);
- out.println(" </feature>");
- }
- if (missingBundles.size() > 0) {
- getLog().info("-- Some bundles were missing --");
- for (Artifact artifact : missingBundles) {
- getLog().info(String.format(" %s", artifact));
- }
- }
- }
-
- private void writeBundle(PrintStream out, Artifact artifact) {
- Artifact replacement = getReplacement(artifact);
- if (replacement != null) {
- writeBundle(out, replacement);
- return;
- }
- if (isProvided(artifact)) {
- getLog().debug(String.format("Skipping '%s' -- bundle will be provided at runtime", artifact));
- return;
- }
- if (features.contains(artifact)) {
- // if we already created a feature for this one, just add that instead of the bundle
- out.println(String.format(" <feature>%s</feature>", artifact.getArtifactId()));
- return;
- }
- // first write the dependencies
- for (Artifact dependency : getDependencies(artifact)) {
- if (dependency.isOptional() || Artifact.SCOPE_TEST.equals(dependency.getScope())) {
- // omit optional dependencies
- getLog().debug(String.format("Omitting optional and/or test scoped dependency '%s' for '%s'",
- dependency, artifact));
- continue;
- }
- getLog().debug(String.format("Adding '%s' as a dependency for '%s'", dependency, artifact));
- writeBundle(out, dependency);
- }
- // skip the bundle if it was already added to this feature previously
- if (!currentFeature.add(artifact)) {
- getLog().debug(String.format("Artifact '%s' was already added to the current feature", artifact));
- return;
- }
- // and then write the bundle itself
- if (isBundle(artifact)) {
- getLog().info(String.format(" adding bundle %s", artifact));
- writeBundle(out, artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion());
- } else {
- Artifact wrapper = findServicemixBundle(artifact);
- if (wrapper != null) {
- getLog().info(String.format(" adding bundle %s (for %s)", wrapper, artifact));
- writeBundle(out, wrapper.getGroupId(), wrapper.getArtifactId(), wrapper.getBaseVersion());
- } else {
- getLog().error(String.format(" unable to find suitable bundle for artifact '%s'", artifact));
- missingBundles.add(artifact);
- }
- }
- }
-
- private Artifact getReplacement(Artifact artifact) {
- String key = String.format("%s/%s", artifact.getGroupId(), artifact.getArtifactId());
- String bundle = null;
- for (VersionRange range : translations.get(key).keySet()) {
- try {
- if (range.containsVersion(artifact.getSelectedVersion())) {
- bundle = translations.get(key).get(range);
- break;
- }
- } catch (OverConstrainedVersionException e) {
- bundle = null;
- }
- }
- if (bundle != null) {
- String[] split = bundle.split("/");
- return factory.createArtifact(split[0], split[1], split[2], Artifact.SCOPE_PROVIDED, artifact.getArtifactHandler().getPackaging());
- } else {
- return null;
- }
- }
-
- private Artifact findServicemixBundle(Artifact artifact) {
- Artifact noVersionWrapper = factory.createArtifact("org.apache.servicemix.bundles",
- "org.apache.servicemix.bundles." + artifact.getArtifactId(),
- "",
- artifact.getScope(), artifact.getType());
- try {
- List versions = artifactMetadataSource.retrieveAvailableVersions(noVersionWrapper, localRepo, remoteRepos);
- Artifact wrapper = factory.createArtifact("org.apache.servicemix.bundles",
- "org.apache.servicemix.bundles." + artifact.getArtifactId(),
- getBestVersionForArtifact(artifact, versions),
- artifact.getScope(), artifact.getType());
- // let's check if the servicemix bundle for this artifact exists
- resolver.resolve(wrapper, remoteRepos, localRepo);
- for (Artifact dependency : getDependencies(wrapper)) {
- //some of these wrapper bundles provide for multiple JAR files, no need to include any of them after adding the wrapper
- getLog().debug(String.format("'%s' also provides '%s'", wrapper, dependency));
- currentFeature.add(dependency);
- }
- return wrapper;
- } catch (ArtifactResolutionException e) {
- getLog().debug("Couldn't find a ServiceMix bundle for " + artifact, e);
- } catch (ArtifactNotFoundException e) {
- getLog().debug("Couldn't find a ServiceMix bundle for " + artifact, e);
- } catch (ArtifactMetadataRetrievalException e) {
- getLog().debug("Couldn't find a ServiceMix bundle for " + artifact, e);
- }
- if (artifact.getArtifactId().contains("-")) {
- //let's try to see if we can't find a bundle wrapping multiple artifacts (e.g. mina -> mina-core, mina-codec, ...)
- return findServicemixBundle(factory.createArtifact(artifact.getGroupId(), artifact.getArtifactId().split("-")[0],
- artifact.getVersion(), artifact.getScope(), artifact.getType()));
- } else {
- return null;
- }
- }
-
- protected String getBestVersionForArtifact(Artifact artifact, List<ArtifactVersion> versions) throws ArtifactMetadataRetrievalException {
- if (versions.size() == 0) {
- throw new ArtifactMetadataRetrievalException("No wrapper bundle available for " + artifact);
- }
- Collections.sort(versions, Collections.reverseOrder());
- //check for same version
- for (ArtifactVersion version : versions) {
- if (version.toString().startsWith(artifact.getVersion())) {
- return version.toString();
- }
- }
- //check for same major/minor version
- for (ArtifactVersion version : versions) {
- String[] elements = version.toString().split("\\.");
- if (elements.length >= 2 && artifact.getVersion().startsWith(elements[0] + "." + elements[1])) {
- return version.toString();
- }
- }
- throw new ArtifactMetadataRetrievalException("No suitable version found for " + artifact + " wrapper bundle");
- }
-
- private boolean isProvided(Artifact bundle) {
- for (Artifact artifact : provided) {
- if (bundle.getArtifactId().equals(artifact.getArtifactId())
- && bundle.getGroupId().equals(artifact.getGroupId())) {
- return true;
- }
- }
- return false;
- }
-
- private boolean isBundle(Artifact artifact) {
- if (artifact.getArtifactHandler().getPackaging().equals("bundle")) {
- return true;
- } else {
- try {
- resolver.resolve(artifact, remoteRepos, localRepo);
- ZipFile file = new ZipFile(artifact.getFile());
- ZipEntry entry = file.getEntry("META-INF/MANIFEST.MF");
- Manifest manifest = new Manifest(file.getInputStream(entry));
- if (ManifestUtils.isBundle(manifest)) {
- getLog().debug(String.format("MANIFEST.MF for '%s' contains Bundle-Name '%s'",
- artifact, ManifestUtils.getBsn(manifest)));
- return true;
- }
- } catch (ZipException e) {
- getLog().warn("Unable to determine if " + artifact + " is a bundle; defaulting to false", e);
- } catch (IOException e) {
- getLog().warn("Unable to determine if " + artifact + " is a bundle; defaulting to false", e);
- } catch (Exception e) {
- getLog().warn("Unable to determine if " + artifact + " is a bundle; defaulting to false", e);
- }
- }
- return false;
- }
-
- private List<Artifact> getDependencies(Artifact artifact) {
- List<Artifact> list = new ArrayList<Artifact>();
- try {
- ResolutionGroup pom = artifactMetadataSource.retrieve(artifact, localRepo, remoteRepos);
- if (pom != null) {
- list.addAll(pom.getArtifacts());
- }
- } catch (ArtifactMetadataRetrievalException e) {
- getLog().warn("Unable to retrieve metadata for " + artifact + ", not including dependencies for it");
- } catch (InvalidArtifactRTException e) {
- getLog().warn("Unable to retrieve metadata for " + artifact + ", not including dependencies for it");
- }
- return list;
- }
-
-
- private void writeCurrentProjectFeature(PrintStream out) {
- out.println(" <feature name='" + featureName + "'>");
-
- writeBundle(out, project.getGroupId(), project.getArtifactId(), project.getVersion());
- out.println();
-
- Iterator iterator = project.getDependencies().iterator();
- while (iterator.hasNext()) {
- Dependency dependency = (Dependency)iterator.next();
-
- if (isValidDependency(dependency)) {
- out.print(" ");
- writeBundle(out, dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion());
- }
- }
-
- out.println(" </feature>");
- }
-
- protected boolean isValidDependency(Dependency dependency) {
- // TODO filter out only compile time dependencies which are OSGi
- // bundles?
- return true;
- }
-
- protected void writeBundle(PrintStream out, String groupId, String artifactId, String version) {
- out.print(" <bundle>mvn:");
- out.print(groupId);
- out.print("/");
- out.print(artifactId);
- out.print("/");
- out.print(version);
- out.print("</bundle>");
- out.println();
- }
-}
diff --git a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesXmlMojo.java b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesXmlMojo.java
deleted file mode 100644
index 6e6092c..0000000
--- a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesXmlMojo.java
+++ /dev/null
@@ -1,570 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.tooling.features;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.Stack;
-import java.util.jar.Manifest;
-import java.util.zip.ZipException;
-import java.util.zip.ZipFile;
-
-import org.apache.felix.utils.manifest.Clause;
-import org.apache.felix.utils.version.VersionRange;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.InvalidArtifactRTException;
-import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
-import org.apache.maven.artifact.metadata.ResolutionGroup;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.DefaultArtifactCollector;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.shared.dependency.tree.DependencyNode;
-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
-import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
-
-
-/**
- * Generates the features XML file
- *
- * @version $Revision: 1.1 $
- * @goal generate-features-xml
- * @phase compile
- * @execute phase="compile"
- * @requiresDependencyResolution runtime
- * @inheritByDefault true
- * @description Generates the features XML file
- */
-@SuppressWarnings("unchecked")
-public class GenerateFeaturesXmlMojo extends MojoSupport {
- protected static final String SEPARATOR = "/";
-
- /**
- * The dependency tree builder to use.
- *
- * @component
- * @required
- * @readonly
- */
- private DependencyTreeBuilder dependencyTreeBuilder;
-
- /**
- * The file to generate
- *
- * @parameter default-value="${project.build.directory}/classes/feature.xml"
- */
- private File outputFile;
-
- /**
- * The artifact type for attaching the generated file to the project
- *
- * @parameter default-value="xml"
- */
- private String attachmentArtifactType = "xml";
-
- /**
- * The artifact classifier for attaching the generated file to the project
- *
- * @parameter default-value="features"
- */
- private String attachmentArtifactClassifier = "features";
-
- /**
- * The kernel version for which to generate the bundle
- *
- * @parameter
- */
- private String kernelVersion;
-
- /*
- * A list of packages exported by the kernel
- */
- private Map<String, VersionRange> kernelExports = new HashMap<String, VersionRange>();
-
- /**
- * A file containing the list of bundles
- *
- * @parameter
- */
- private File bundles;
-
- /*
- * A set of known bundles
- */
- private Set<String> knownBundles = new HashSet<String>();
-
- /*
- * A list of exports by the bundles
- */
- private Map<String, Map<VersionRange, Artifact>> bundleExports = new HashMap<String, Map<VersionRange, Artifact>>();
-
- /*
- * The set of system exports
- */
- private List<String> systemExports = new LinkedList<String>();
-
- /*
- * These bundles are the features that will be built
- */
- private Map<Artifact, Feature> features = new HashMap<Artifact, Feature>();
-
- public void execute() throws MojoExecutionException, MojoFailureException {
- PrintStream out = null;
- try {
- out = new PrintStream(new FileOutputStream(outputFile));
- readSystemPackages();
- readKernelBundles();
- readBundles();
- discoverBundles();
- writeFeatures(out);
- // now lets attach it
- projectHelper.attachArtifact(project, attachmentArtifactType, attachmentArtifactClassifier, outputFile);
- } catch (Exception e) {
- getLog().error(e);
- throw new MojoExecutionException("Unable to create features.xml file: " + e, e);
- } finally {
- if (out != null) {
- out.close();
- }
- }
- }
-
- /*
- * Read all the system provided packages from the <code>config.properties</code> file
- */
- private void readSystemPackages() throws IOException {
- Properties properties = new Properties();
- properties.load(getClass().getClassLoader().getResourceAsStream("config.properties"));
- readSystemPackages(properties, "jre-1.5");
- readSystemPackages(properties, "osgi");
- }
-
-
- private void readSystemPackages(Properties properties, String key) {
- String packages = (String) properties.get(key);
- for (String pkg : packages.split(";")) {
- systemExports.add(pkg.trim());
- }
- }
-
- /*
- * Download a Kernel distro and check the list of bundles provided by the Kernel
- */
- private void readKernelBundles() throws ArtifactResolutionException, ArtifactNotFoundException, MojoExecutionException,
- ZipException, IOException, DependencyTreeBuilderException {
- final Collection<Artifact> kernelArtifacts;
- if (kernelVersion == null) {
- getLog().info("Step 1: Building list of provided bundle exports");
- kernelArtifacts = new HashSet<Artifact>();
- DependencyNode tree = dependencyTreeBuilder.buildDependencyTree(project, localRepo, factory, artifactMetadataSource, new ArtifactFilter() {
-
- public boolean include(Artifact artifact) {
- return true;
- }
-
- }, new DefaultArtifactCollector());
- tree.accept(new DependencyNodeVisitor() {
- public boolean endVisit(DependencyNode node) {
- // we want the next sibling too
- return true;
- }
- public boolean visit(DependencyNode node) {
- if (node.getState() != DependencyNode.OMITTED_FOR_CONFLICT) {
- Artifact artifact = node.getArtifact();
- if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) && !artifact.getType().equals("pom")) {
- kernelArtifacts.add(artifact);
- }
- }
- // we want the children too
- return true;
- }
- });
- } else {
- getLog().info("Step 1 : Building list of kernel exports");
- getLog().warn("Use of 'kernelVersion' is deprecated -- use a dependency with scope 'provided' instead");
- Artifact kernel = factory.createArtifact("org.apache.felix.karaf", "apache-felix-karaf", kernelVersion, Artifact.SCOPE_PROVIDED, "pom");
- resolver.resolve(kernel, remoteRepos, localRepo);
- kernelArtifacts = getDependencies(kernel);
- }
- for (Artifact artifact : kernelArtifacts) {
- registerKernelBundle(artifact);
- }
- getLog().info("...done!");
- }
-
- private void registerKernelBundle(Artifact artifact) throws ArtifactResolutionException, ArtifactNotFoundException, ZipException,
- IOException {
- Manifest manifest = getManifest(artifact);
- for (Clause clause : ManifestUtils.getExports(manifest)) {
- kernelExports.put(clause.getName(), ManifestUtils.getVersionRange(clause));
- getLog().debug(" adding kernel export " + clause.getName() + " (" + ManifestUtils.getVersionRange(clause) + ")");
- }
- registerBundle(artifact);
- }
-
- /*
- * Read the list of bundles we can use to satisfy links
- */
- private void readBundles() throws IOException, ArtifactResolutionException, ArtifactNotFoundException {
- BufferedReader reader = null;
- try {
- if (bundles != null) {
- getLog().info("Step 2 : Building a list of exports for bundles in " + bundles.getAbsolutePath());
- reader = new BufferedReader(new FileReader(bundles));
- String line = reader.readLine();
- while (line != null) {
- if (line.contains("/") && !line.startsWith("#")) {
- String[] elements = line.split("/");
- Artifact artifact = factory.createArtifact(elements[0], elements[1], elements[2], Artifact.SCOPE_PROVIDED,
- elements[3]);
- registerBundle(artifact);
- }
- line = reader.readLine();
- }
- } else {
- getLog().info("Step 2 : No Bundle file supplied for building list of exports");
- }
- } finally {
- if (reader != null) {
- reader.close();
- }
- }
- getLog().info("...done!");
- }
-
- /*
- * Auto-discover bundles currently in the dependencies
- */
- private void discoverBundles() throws ArtifactResolutionException, ArtifactNotFoundException, ZipException, IOException {
- getLog().info("Step 3 : Discovering bundles in Maven dependencies");
- for (Artifact dependency : (Set<Artifact>) project.getArtifacts()) {
- // we will generate a feature for this afterwards
- if (project.getDependencyArtifacts().contains(dependency)) {
- continue;
- }
- // this is a provided bundle, has been handled in step 1
- if (dependency.getScope().equals(Artifact.SCOPE_PROVIDED)) {
- continue;
- }
- if (isDiscoverableBundle(dependency)) {
- getLog().info(" Discovered " + dependency);
- registerBundle(dependency);
- }
- }
- getLog().info("...done!");
- }
-
- /*
- * Write all project dependencies as feature
- */
- private void writeFeatures(PrintStream out) throws ArtifactResolutionException, ArtifactNotFoundException,
- ZipException, IOException {
- getLog().info("Step 4 : Generating " + outputFile.getAbsolutePath());
- out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- out.println("<features>");
- Set<Artifact> dependencies = (Set<Artifact>)project.getDependencyArtifacts();
- for (Artifact artifact : dependencies) {
- if (!artifact.getScope().equals(Artifact.SCOPE_PROVIDED) && !artifact.getType().equals("pom")) {
- getLog().info(" Generating feature " + artifact.getArtifactId() + " from " + artifact);
- Feature feature = getFeature(artifact);
- feature.write(out);
- registerFeature(artifact, feature);
- }
- }
- out.println("</features>");
- getLog().info("...done!");
- }
-
- /*
- * Get the feature for an artifact
- */
- private Feature getFeature(Artifact artifact) throws ArtifactResolutionException, ArtifactNotFoundException, ZipException, IOException {
- Feature feature = new Feature(artifact);
- addRequirements(artifact, feature);
- return feature;
- }
-
- /*
- * Only auto-discover an OSGi bundle
- * - if it is not already known as a feature itself
- * - if it is not another version of an already known bundle
- */
- private boolean isDiscoverableBundle(Artifact artifact) {
- if (isBundle(artifact) && !isFeature(artifact) && !artifact.getScope().equals(Artifact.SCOPE_PROVIDED)) {
- for (String known : knownBundles) {
- String[] elements = known.split("/");
- if (artifact.getGroupId().equals(elements[0]) &&
- artifact.getArtifactId().equals(elements[1])) {
- getLog().debug(String.format(" Avoid auto-discovery for %s because of existing bundle %s",
- toString(artifact), known));
- return false;
- }
- }
- return true;
- }
- return false;
- }
-
- /*
- * Check if the given artifact is a bundle
- */
- private boolean isBundle(Artifact artifact) {
- if (knownBundles.contains(toString(artifact)) || artifact.getArtifactHandler().getPackaging().equals("bundle")) {
- return true;
- } else {
- try {
- Manifest manifest = getManifest(artifact);
- if (ManifestUtils.getBsn(manifest) != null) {
- getLog().debug(String.format("MANIFEST.MF for '%s' contains Bundle-Name '%s'",
- artifact, ManifestUtils.getBsn(manifest)));
- return true;
- }
- } catch (ZipException e) {
- getLog().debug("Unable to determine if " + artifact + " is a bundle; defaulting to false", e);
- } catch (IOException e) {
- getLog().debug("Unable to determine if " + artifact + " is a bundle; defaulting to false", e);
- } catch (Exception e) {
- getLog().debug("Unable to determine if " + artifact + " is a bundle; defaulting to false", e);
- }
- }
- return false;
- }
-
- /*
- * Add requirements for an artifact to a feature
- */
- private void addRequirements(Artifact artifact, Feature feature) throws ArtifactResolutionException, ArtifactNotFoundException, ZipException, IOException {
- Manifest manifest = getManifest(artifact);
- Collection<Clause> remaining = getRemainingImports(manifest);
- Artifact previous = null;
- for (Clause clause : remaining) {
- Artifact add = null;
- Map<VersionRange, Artifact> versions = bundleExports.get(clause.getName());
- if (versions != null) {
- for (VersionRange range : versions.keySet()) {
- add = versions.get(range);
- if (range.intersect(ManifestUtils.getVersionRange(clause)) != null) {
- add = versions.get(range);
- }
- }
- }
- if (add == null) {
- if (ManifestUtils.isOptional(clause)) {
- // debug logging for optional dependency...
- getLog().debug(String.format(" Unable to find suitable bundle for optional dependency %s (%s)",
- clause.getName(), ManifestUtils.getVersionRange(clause)));
- } else {
- // ...but a warning for a mandatory dependency
- getLog().warn(
- String.format(" Unable to find suitable bundle for dependency %s (%s) (required by %s)",
- clause.getName(), ManifestUtils.getVersionRange(clause), artifact.getArtifactId()));
- }
- } else {
- if (!add.equals(previous) && feature.push(add) && !isFeature(add)) {
- //and get requirements for the bundle we just added
- getLog().debug(" Getting requirements for " + add);
- addRequirements(add, feature);
- }
- }
- previous = add;
- }
- }
-
- /*
- * Check if a given bundle is itself being generated as a feature
- */
- private boolean isFeature(Artifact artifact) {
- return features.containsKey(artifact);
- }
-
-
- /*
- * Register a bundle, enlisting all packages it provides
- */
- private void registerBundle(Artifact artifact) throws ArtifactResolutionException, ArtifactNotFoundException, ZipException,
- IOException {
- getLog().debug("Registering bundle " + artifact);
- knownBundles.add(toString(artifact));
- Manifest manifest = getManifest(artifact);
- for (Clause clause : getManifestEntries(ManifestUtils.getExports(manifest))) {
- Map<VersionRange, Artifact> versions = bundleExports.get(clause.getName());
- if (versions == null) {
- versions = new HashMap<VersionRange, Artifact>();
- }
- versions.put(ManifestUtils.getVersionRange(clause), artifact);
- getLog().debug(String.format(" %s exported by bundle %s", clause.getName(), artifact));
- bundleExports.put(clause.getName(), versions);
- }
- }
-
- /*
- * Register a feature and also register the bundle for the feature
- */
- private void registerFeature(Artifact artifact, Feature feature) throws ArtifactResolutionException, ArtifactNotFoundException, ZipException,
- IOException {
- features.put(artifact, feature);
- registerBundle(artifact);
- }
-
- /*
- * Determine the list of imports to be resolved
- */
- private Collection<Clause> getRemainingImports(Manifest manifest) {
- // take all imports
- Collection<Clause> input = getManifestEntries(ManifestUtils.getImports(manifest));
- Collection<Clause> output = new LinkedList<Clause>(input);
- // remove imports satisfied by exports in the same bundle
- for (Clause clause : input) {
- for (Clause export : getManifestEntries(ManifestUtils.getExports(manifest))) {
- if (clause.getName().equals(export.getName())) {
- output.remove(clause);
- }
- }
- }
- // remove imports for packages exported by the kernel
- for (Clause clause : input) {
- for (String export : kernelExports.keySet()) {
- if (clause.getName().equals(export)) {
- output.remove(clause);
- }
- }
- }
- // remove imports for packages exported by the system bundle
- for (Clause clause : input) {
- if (systemExports.contains(clause.getName())) {
- output.remove(clause);
- }
- }
- return output;
- }
-
- private Collection<Clause> getManifestEntries(List imports) {
- if (imports == null) {
- return new LinkedList<Clause>();
- } else {
- return (Collection<Clause>)imports;
- }
- }
-
- private Manifest getManifest(Artifact artifact) throws ArtifactResolutionException, ArtifactNotFoundException, ZipException,
- IOException {
- File localFile = new File(localRepo.pathOf(artifact));
- ZipFile file;
- if (localFile.exists()) {
- //avoid going over to the repository if the file is already on the disk
- file = new ZipFile(localFile);
- } else {
- resolver.resolve(artifact, remoteRepos, localRepo);
- file = new ZipFile(artifact.getFile());
- }
- return new Manifest(file.getInputStream(file.getEntry("META-INF/MANIFEST.MF")));
- }
-
- private List<Artifact> getDependencies(Artifact artifact) {
- List<Artifact> list = new ArrayList<Artifact>();
- try {
- ResolutionGroup pom = artifactMetadataSource.retrieve(artifact, localRepo, remoteRepos);
- if (pom != null) {
- list.addAll(pom.getArtifacts());
- }
- } catch (ArtifactMetadataRetrievalException e) {
- getLog().warn("Unable to retrieve metadata for " + artifact + ", not including dependencies for it");
- } catch (InvalidArtifactRTException e) {
- getLog().warn("Unable to retrieve metadata for " + artifact + ", not including dependencies for it");
- }
- return list;
- }
-
- public static String toString(Artifact artifact) {
- return String.format("%s/%s/%s", artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());
- }
-
- private class Feature {
-
- private Stack<Artifact> artifacts = new Stack<Artifact>();
- private final Artifact artifact;
-
- private Feature(Artifact artifact) {
- super();
- this.artifact = artifact;
- artifacts.push(artifact);
- }
-
- public boolean push(Artifact item) {
- if (artifacts.contains(item)) {
- artifacts.remove(item);
- artifacts.push(item);
- return false;
- }
- if (!artifacts.contains(item)) {
- artifacts.push(item);
- return true;
- }
- return false;
- }
-
- public void write(PrintStream out) {
- out.println(" <feature name='" + artifact.getArtifactId() + "' version='"
- + artifact.getBaseVersion() + "'>");
-
- Stack<Artifact> resulting = new Stack<Artifact>();
- resulting.addAll(artifacts);
-
- // remove dependencies for included features
- for (Artifact next : artifacts) {
- if (isFeature(next)) {
- resulting.removeAll(features.get(next).getDependencies());
- }
- }
-
- while (!resulting.isEmpty()) {
- Artifact next = resulting.pop();
- if (isFeature(next)) {
- out.println(" <feature version='"
- + next.getBaseVersion() + "'>" + String.format("%s</feature>", next.getArtifactId()));
- } else {
- out.println(String.format(" <bundle>mvn:%s/%s/%s</bundle>",
- next.getGroupId(), next.getArtifactId(), next.getBaseVersion()));
- }
- }
- out.println(" </feature>");
- }
-
- public List<Artifact> getDependencies() {
- List<Artifact> dependencies = new LinkedList<Artifact>(artifacts);
- dependencies.remove(artifact);
- return dependencies;
- }
- }
-}
diff --git a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/GraphArtifactCollector.java b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/GraphArtifactCollector.java
deleted file mode 100644
index 05608d9..0000000
--- a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/GraphArtifactCollector.java
+++ /dev/null
@@ -1,435 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.tooling.features;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
-import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
-import org.apache.maven.artifact.metadata.ResolutionGroup;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactCollector;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
-import org.apache.maven.artifact.resolver.CyclicDependencyException;
-import org.apache.maven.artifact.resolver.ResolutionListener;
-import org.apache.maven.artifact.resolver.ResolutionNode;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.artifact.versioning.ArtifactVersion;
-import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
-import org.apache.maven.artifact.versioning.VersionRange;
-
-/**
- * @version $Revision: 1.1 $
- */
-public class GraphArtifactCollector implements ArtifactCollector {
- public ArtifactResolutionResult collect(
- Set artifacts,
- Artifact originatingArtifact,
- ArtifactRepository localRepository,
- List remoteRepositories,
- ArtifactMetadataSource source,
- ArtifactFilter filter,
- List listeners) throws ArtifactResolutionException {
- return collect(artifacts, originatingArtifact, Collections.EMPTY_MAP,
- localRepository, remoteRepositories, source, filter, listeners);
- }
-
- public ArtifactResolutionResult collect(
- Set artifacts,
- Artifact originatingArtifact,
- Map managedVersions,
- ArtifactRepository localRepository,
- List remoteRepositories,
- ArtifactMetadataSource source,
- ArtifactFilter filter,
- List listeners) throws ArtifactResolutionException {
- Map resolvedArtifacts = new HashMap();
-
- ResolutionNode root = new ResolutionNode(originatingArtifact, remoteRepositories);
- root.addDependencies(artifacts, remoteRepositories, filter);
- recurse(root, resolvedArtifacts, managedVersions, localRepository,
- remoteRepositories, source, filter, listeners);
-
- Set set = new HashSet();
- for (Iterator i = resolvedArtifacts.values().iterator(); i.hasNext();) {
- List nodes = (List) i.next();
- for (Iterator j = nodes.iterator(); j.hasNext();) {
- ResolutionNode node = (ResolutionNode) j.next();
- Artifact artifact = node.getArtifact();
- if (!node.equals(root) && node.isActive() && node.filterTrail(filter)
- // If it was optional and not a direct dependency,
- // we don't add it or its children, just allow the
- // update of the version and scope
- && (node.isChildOfRootNode() || !artifact.isOptional())) {
- artifact.setDependencyTrail(node.getDependencyTrail());
- set.add(node);
- }
- }
- }
-
- ArtifactResolutionResult result = new ArtifactResolutionResult();
- result.setArtifactResolutionNodes(set);
- return result;
- }
-
- private void recurse(
- ResolutionNode node,
- Map resolvedArtifacts,
- Map managedVersions,
- ArtifactRepository localRepository,
- List remoteRepositories,
- ArtifactMetadataSource source,
- ArtifactFilter filter,
- List listeners) throws CyclicDependencyException, ArtifactResolutionException,
- OverConstrainedVersionException {
- fireEvent(ResolutionListener.TEST_ARTIFACT, listeners, node);
-
- // TODO: use as a conflict resolver
- Object key = node.getKey();
- if (managedVersions.containsKey(key)) {
- Artifact artifact = (Artifact) managedVersions.get(key);
- fireEvent(ResolutionListener.MANAGE_ARTIFACT, listeners, node, artifact);
- if (artifact.getVersion() != null) {
- node.getArtifact().setVersion(artifact.getVersion());
- }
- if (artifact.getScope() != null) {
- node.getArtifact().setScope(artifact.getScope());
- }
- }
-
- List previousNodes = (List) resolvedArtifacts.get(key);
- if (previousNodes != null) {
- node = checkPreviousNodes(node, listeners, previousNodes);
- }
- else {
- previousNodes = new ArrayList();
- resolvedArtifacts.put(key, previousNodes);
- }
- previousNodes.add(node);
-
- if (node.isActive()) {
- fireEvent(ResolutionListener.INCLUDE_ARTIFACT, listeners, node);
- }
-
- // don't pull in the transitive deps of a system-scoped dependency.
- if (node.isActive() && !Artifact.SCOPE_SYSTEM.equals(node.getArtifact().getScope())) {
- fireEvent(ResolutionListener.PROCESS_CHILDREN, listeners, node);
- for (Iterator i = node.getChildrenIterator(); i.hasNext();) {
- ResolutionNode child = (ResolutionNode) i.next();
- // We leave in optional ones, but don't pick up its dependencies
- if (!child.isResolved()
- && (!child.getArtifact().isOptional() || child.isChildOfRootNode())) {
- Artifact artifact = child.getArtifact();
- try {
- if (artifact.getVersion() == null) {
- // set the recommended version
- // TODO: maybe its better to just pass the range
- // through to retrieval and use a transformation?
- ArtifactVersion version;
- version = getArtifactVersion(localRepository, remoteRepositories, source, artifact);
-
- artifact.selectVersion(version.toString());
- fireEvent(ResolutionListener.SELECT_VERSION_FROM_RANGE,
- listeners, child);
- }
-
- ResolutionGroup rGroup = source.retrieve(artifact,
- localRepository, remoteRepositories);
-
- // TODO might be better to have source.retreive() throw
- // a specific exception for this situation
- // and catch here rather than have it return null
- if (rGroup == null) {
- // relocated dependency artifact is declared
- // excluded, no need to add and recurse further
- continue;
- }
-
- child.addDependencies(rGroup.getArtifacts(),
- rGroup.getResolutionRepositories(), filter);
- }
- catch (CyclicDependencyException e) {
- // would like to throw this, but we have crappy stuff in
- // the repo
-
- fireEvent(ResolutionListener.OMIT_FOR_CYCLE, listeners,
- new ResolutionNode(e.getArtifact(), remoteRepositories, child));
- }
- catch (ArtifactMetadataRetrievalException e) {
- artifact.setDependencyTrail(node.getDependencyTrail());
- throw new ArtifactResolutionException(
- "Unable to get dependency information: "
- + e.getMessage(), artifact, e);
- }
-
- recurse(child, resolvedArtifacts, managedVersions,
- localRepository, remoteRepositories, source,
- filter, listeners);
- }
- }
- fireEvent(ResolutionListener.FINISH_PROCESSING_CHILDREN, listeners,
- node);
- }
- }
-
- private ArtifactVersion getArtifactVersion(
- ArtifactRepository localRepository,
- List remoteRepositories,
- ArtifactMetadataSource source,
- Artifact artifact) throws OverConstrainedVersionException,
- ArtifactMetadataRetrievalException {
- ArtifactVersion version;
- if (!artifact.isSelectedVersionKnown()) {
- List versions = artifact.getAvailableVersions();
- if (versions == null) {
- versions = source.retrieveAvailableVersions(
- artifact, localRepository,
- remoteRepositories);
- artifact.setAvailableVersions(versions);
- }
-
- VersionRange versionRange = artifact.getVersionRange();
-
- version = versionRange.matchVersion(versions);
-
- if (version == null) {
- if (versions.isEmpty()) {
- throw new OverConstrainedVersionException(
- "No versions are present in the repository for the artifact with a range "
- + versionRange, artifact, remoteRepositories);
- }
- else {
- throw new OverConstrainedVersionException(
- "Couldn't find a version in "
- + versions
- + " to match range "
- + versionRange,
- artifact, remoteRepositories);
- }
- }
- }
- else {
- version = artifact.getSelectedVersion();
- }
- return version;
- }
-
- private ResolutionNode checkPreviousNodes(
- ResolutionNode node,
- List listeners,
- List previousNodes) throws OverConstrainedVersionException {
- for (Iterator i = previousNodes.iterator(); i.hasNext();) {
- ResolutionNode previous = (ResolutionNode) i.next();
- if (previous.isActive()) {
- // Version mediation
- VersionRange previousRange = previous.getArtifact().getVersionRange();
- VersionRange currentRange = node.getArtifact().getVersionRange();
- // TODO: why do we force the version on it? what if they
- // don't match?
- if (previousRange == null) {
- // version was already resolved
- node.getArtifact().setVersion(previous.getArtifact().getVersion());
- }
- else if (currentRange == null) {
- // version was already resolved
- previous.getArtifact().setVersion(node.getArtifact().getVersion());
- }
- else {
- // TODO: shouldn't need to double up on this work, only
- // done for simplicity of handling recommended
- // version but the restriction is identical
- VersionRange newRange = previousRange.restrict(currentRange);
- // TODO: ick. this forces the OCE that should have come
- // from the previous call. It is still correct
- if (newRange.isSelectedVersionKnown(previous.getArtifact())) {
- fireEvent(ResolutionListener.RESTRICT_RANGE,
- listeners, node, previous.getArtifact(),
- newRange);
- }
- previous.getArtifact().setVersionRange(newRange);
- node.getArtifact().setVersionRange(
- currentRange.restrict(previousRange));
-
- // Select an appropriate available version from the (now
- // restricted) range
- // Note this version was selected before to get the
- // appropriate POM
- // But it was reset by the call to setVersionRange on
- // restricting the version
- ResolutionNode[] resetNodes = {previous, node};
- for (int j = 0; j < 2; j++) {
- Artifact resetArtifact = resetNodes[j]
- .getArtifact();
- if (resetArtifact.getVersion() == null
- && resetArtifact.getVersionRange() != null
- && resetArtifact.getAvailableVersions() != null) {
-
- resetArtifact
- .selectVersion(resetArtifact
- .getVersionRange()
- .matchVersion(
- resetArtifact
- .getAvailableVersions())
- .toString());
- fireEvent(ResolutionListener.SELECT_VERSION_FROM_RANGE,
- listeners, resetNodes[j]);
- }
- }
- }
-
- // Conflict Resolution
- // TODO: use as conflict resolver(s), chain
-
- // TODO: should this be part of mediation?
- // previous one is more dominant
- if (previous.getDepth() <= node.getDepth()) {
- checkScopeUpdate(node, previous, listeners);
- }
- else {
- checkScopeUpdate(previous, node, listeners);
- }
-
- if (previous.getDepth() <= node.getDepth()) {
- // previous was nearer
- fireEvent(ResolutionListener.OMIT_FOR_NEARER,
- listeners, node, previous.getArtifact());
- node.disable();
- node = previous;
- }
- else {
- fireEvent(ResolutionListener.OMIT_FOR_NEARER,
- listeners, previous, node.getArtifact());
- previous.disable();
- }
- }
- }
- return node;
- }
-
- private void checkScopeUpdate(ResolutionNode farthest,
- ResolutionNode nearest, List listeners) {
- boolean updateScope = false;
- Artifact farthestArtifact = farthest.getArtifact();
- Artifact nearestArtifact = nearest.getArtifact();
-
- if (Artifact.SCOPE_RUNTIME.equals(farthestArtifact.getScope())
- && (Artifact.SCOPE_TEST.equals(nearestArtifact.getScope()) || Artifact.SCOPE_PROVIDED
- .equals(nearestArtifact.getScope()))) {
- updateScope = true;
- }
-
- if (Artifact.SCOPE_COMPILE.equals(farthestArtifact.getScope())
- && !Artifact.SCOPE_COMPILE.equals(nearestArtifact.getScope())) {
- updateScope = true;
- }
-
- // current POM rules all
- if (nearest.getDepth() < 2 && updateScope) {
- updateScope = false;
-
- fireEvent(ResolutionListener.UPDATE_SCOPE_CURRENT_POM, listeners,
- nearest, farthestArtifact);
- }
-
- if (updateScope) {
- fireEvent(ResolutionListener.UPDATE_SCOPE, listeners, nearest,
- farthestArtifact);
-
- // previously we cloned the artifact, but it is more effecient to
- // just update the scope
- // if problems are later discovered that the original object needs
- // its original scope value, cloning may
- // again be appropriate
- nearestArtifact.setScope(farthestArtifact.getScope());
- }
- }
-
- private void fireEvent(int event, List listeners, ResolutionNode node) {
- fireEvent(event, listeners, node, null);
- }
-
- private void fireEvent(int event, List listeners, ResolutionNode node,
- Artifact replacement) {
- fireEvent(event, listeners, node, replacement, null);
- }
-
- private void fireEvent(int event, List listeners, ResolutionNode node,
- Artifact replacement, VersionRange newRange) {
- for (Iterator i = listeners.iterator(); i.hasNext();) {
- ResolutionListener listener = (ResolutionListener) i.next();
-
- switch (event) {
- case ResolutionListener.TEST_ARTIFACT:
- listener.testArtifact(node.getArtifact());
- break;
- case ResolutionListener.PROCESS_CHILDREN:
- listener.startProcessChildren(node.getArtifact());
- break;
- case ResolutionListener.FINISH_PROCESSING_CHILDREN:
- listener.endProcessChildren(node.getArtifact());
- break;
- case ResolutionListener.INCLUDE_ARTIFACT:
- listener.includeArtifact(node.getArtifact());
- break;
- case ResolutionListener.OMIT_FOR_NEARER:
- String version = node.getArtifact().getVersion();
- String replacementVersion = replacement.getVersion();
- if (version != null ? !version.equals(replacementVersion)
- : replacementVersion != null) {
- listener.omitForNearer(node.getArtifact(), replacement);
- }
- break;
- case ResolutionListener.OMIT_FOR_CYCLE:
- listener.omitForCycle(node.getArtifact());
- break;
- case ResolutionListener.UPDATE_SCOPE:
- listener
- .updateScope(node.getArtifact(), replacement.getScope());
- break;
- case ResolutionListener.UPDATE_SCOPE_CURRENT_POM:
- listener.updateScopeCurrentPom(node.getArtifact(), replacement
- .getScope());
- break;
- case ResolutionListener.MANAGE_ARTIFACT:
- listener.manageArtifact(node.getArtifact(), replacement);
- break;
- case ResolutionListener.SELECT_VERSION_FROM_RANGE:
- listener.selectVersionFromRange(node.getArtifact());
- break;
- case ResolutionListener.RESTRICT_RANGE:
- if (node.getArtifact().getVersionRange().hasRestrictions()
- || replacement.getVersionRange().hasRestrictions()) {
- listener.restrictRange(node.getArtifact(), replacement,
- newRange);
- }
- break;
- default:
- throw new IllegalStateException("Unknown event: " + event);
- }
- }
- }
-}
diff --git a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ManifestUtils.java b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ManifestUtils.java
deleted file mode 100644
index d21a3d9..0000000
--- a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ManifestUtils.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.tooling.features;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.jar.Manifest;
-
-import org.apache.felix.utils.manifest.Clause;
-import org.apache.felix.utils.manifest.Parser;
-import org.apache.felix.utils.version.VersionRange;
-import org.osgi.framework.Constants;
-
-
-/**
- * A set of utility methods to ease working with {@link org.apache.felix.utils.manifest.Parser} and
- * {@link org.apache.felix.utils.manifest.Clause}
- */
-
-public class ManifestUtils {
-
- private ManifestUtils() {
- // hide the constructor
- }
-
- /**
- * Get the list of imports from the manifest. If no imports have been defined, this method returns an empty list.
- *
- * @param manifest the manifest
- * @return the list of imports
- */
- public static List<Clause> getImports(Manifest manifest) {
- List<Clause> result = new LinkedList<Clause>();
- Clause[] clauses = Parser.parseHeader(getHeader(Constants.IMPORT_PACKAGE, manifest));
- for (Clause clause : clauses) {
- result.add(clause);
- }
- return result;
- }
-
- /**
- * Get the list of non-optional imports from the manifest.
- *
- * @param manifest the manifest
- * @return the list of non-optional imports
- */
- public static List<Clause> getMandatoryImports(Manifest manifest) {
- List<Clause> result = new LinkedList<Clause>();
- for (Clause clause : getImports(manifest)) {
- if (!isOptional(clause)) {
- result.add(clause);
- }
- }
- return result;
- }
-
- /**
- * Get the list of exports from the manifest. If no exports have been defined, this method returns an empty list.
- *
- * @param manifest the manifest
- * @return the list of exports
- */
- public static List<Clause> getExports(Manifest manifest) {
- List<Clause> result = new LinkedList<Clause>();
- Clause[] clauses = Parser.parseHeader(getHeader(Constants.EXPORT_PACKAGE, manifest));
- for (Clause clause : clauses) {
- result.add(clause);
- }
- return result;
- }
-
- /**
- * Check if a given manifest clause represents an optional import
- *
- * @param clause the manifest clause
- * @return <code>true</code> for an optional import, <code>false</code> for mandatory imports
- */
- public static boolean isOptional(Clause clause) {
- return "optional".equals(clause.getDirective("resolution"));
- }
-
- /**
- * Check if the manifest contains the mandatory Bundle-Symbolic-Name
- *
- * @param manifest the manifest
- * @return <code>true</code> if the manifest specifies a Bundle-Symbolic-Name
- */
- public static boolean isBundle(Manifest manifest) {
- return getBsn(manifest) != null;
- }
-
- public static boolean matches(Clause requirement, Clause export) {
- if (requirement.getName().equals(export.getName())) {
- VersionRange importVersionRange = getVersionRange(requirement);
- VersionRange exportVersionRange = getVersionRange(export);
- VersionRange intersection = importVersionRange.intersect(exportVersionRange);
- return intersection != null;
- }
- return false;
- }
-
- public static String getHeader(String name, Manifest manifest) {
- String value = manifest.getMainAttributes().getValue(name);
- return value;
- }
-
- public static String getBsn(Manifest manifest) {
- String bsn = getHeader(Constants.BUNDLE_SYMBOLICNAME, manifest);
- return bsn;
- }
-
- public static VersionRange getVersionRange(Clause clause)
- {
- String v = clause.getAttribute(Constants.VERSION_ATTRIBUTE);
- if (v == null)
- {
- v = clause.getAttribute(Constants.PACKAGE_SPECIFICATION_VERSION);
- }
- if (v == null)
- {
- v = clause.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE);
- }
- return VersionRange.parseVersionRange(v);
- }
-}
diff --git a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/MojoSupport.java b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/MojoSupport.java
deleted file mode 100644
index 7d491e5..0000000
--- a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/MojoSupport.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.tooling.features;
-
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactCollector;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.ArtifactResolver;
-import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
-import org.apache.maven.artifact.versioning.VersionRange;
-import org.apache.maven.model.Dependency;
-import org.apache.maven.model.DependencyManagement;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
-import org.apache.maven.project.MavenProjectHelper;
-import org.apache.maven.project.ProjectBuildingException;
-
-/**
- * @version $Revision: 1.1 $
- */
-public abstract class MojoSupport extends AbstractMojo {
-
- /**
- * Maven ProjectHelper
- *
- * @component
- */
- protected MavenProjectHelper projectHelper;
-
- /**
- * The maven project.
- *
- * @parameter expression="${project}"
- * @required
- * @readonly
- */
- protected MavenProject project;
-
- /**
- * Directory that resources are copied to during the build.
- *
- * @parameter expression="${project.build.directory}/${project.artifactId}-${project.version}-installer"
- * @required
- */
- protected File workDirectory;
-
- /**
- * @component
- */
- protected MavenProjectBuilder projectBuilder;
-
- /**
- * @parameter default-value="${localRepository}"
- */
- protected ArtifactRepository localRepo;
-
- /**
- * @parameter default-value="${project.remoteArtifactRepositories}"
- */
- protected List remoteRepos;
-
- /**
- * @component
- */
- protected ArtifactMetadataSource artifactMetadataSource;
-
- /**
- * @component
- */
- protected ArtifactResolver resolver;
-
- protected ArtifactCollector collector = new GraphArtifactCollector();
-
- /**
- * @component
- */
- protected ArtifactFactory factory;
-
- protected MavenProject getProject() {
- return project;
- }
-
- protected File getWorkDirectory() {
- return workDirectory;
- }
-
- public MavenProjectHelper getProjectHelper() {
- return projectHelper;
- }
-
- protected void removeBranch(ResolutionListenerImpl listener,
- Artifact artifact) {
- Node n = listener.getNode(artifact);
- if (n != null) {
- for (Iterator it = n.getParents().iterator(); it.hasNext();) {
- Node parent = (Node) it.next();
- parent.getChildren().remove(n);
- }
- }
- }
-
- protected void removeChildren(ResolutionListenerImpl listener,
- Artifact artifact) {
- Node n = listener.getNode(artifact);
- n.getChildren().clear();
- }
-
- protected Set getArtifacts(Node n, Set s) {
- if (!s.contains(n.getArtifact())) {
- s.add(n.getArtifact());
- for (Iterator iter = n.getChildren().iterator(); iter.hasNext();) {
- Node c = (Node) iter.next();
- getArtifacts(c, s);
- }
- }
- return s;
- }
-
- protected void excludeBranch(Node n, Set excludes) {
- excludes.add(n);
- for (Iterator iter = n.getChildren().iterator(); iter.hasNext();) {
- Node c = (Node) iter.next();
- excludeBranch(c, excludes);
- }
- }
-
- protected void print(Node rootNode) {
- for (Iterator iter = getArtifacts(rootNode, new HashSet()).iterator(); iter.hasNext();) {
- Artifact a = (Artifact) iter.next();
- getLog().info(" " + a);
- }
- }
-
- protected Set retainArtifacts(Set includes, ResolutionListenerImpl listener) {
- Set finalIncludes = new HashSet();
- Set filteredArtifacts = getArtifacts(listener.getRootNode(),
- new HashSet());
- for (Iterator iter = includes.iterator(); iter.hasNext();) {
- Artifact artifact = (Artifact) iter.next();
- for (Iterator iter2 = filteredArtifacts.iterator(); iter2.hasNext();) {
- Artifact filteredArtifact = (Artifact) iter2.next();
- if (filteredArtifact.getArtifactId().equals(
- artifact.getArtifactId())
- && filteredArtifact.getType()
- .equals(artifact.getType())
- && filteredArtifact.getGroupId().equals(
- artifact.getGroupId())) {
- if (!filteredArtifact.getVersion().equals(
- artifact.getVersion())) {
- getLog()
- .warn(
- "Resolved artifact "
- + artifact
- + " has a different version from that in dependency management "
- + filteredArtifact
- + ", overriding dependency management");
- }
- finalIncludes.add(artifact);
- }
- }
-
- }
-
- return finalIncludes;
- }
-
- protected ResolutionListenerImpl resolveProject() {
- Map managedVersions = null;
- try {
- managedVersions = createManagedVersionMap(project.getId(), project
- .getDependencyManagement());
- } catch (ProjectBuildingException e) {
- getLog().error(
- "An error occurred while resolving project dependencies.",
- e);
- }
- ResolutionListenerImpl listener = new ResolutionListenerImpl();
- listener.setLog(getLog());
- try {
- collector.collect(project.getDependencyArtifacts(), project
- .getArtifact(), managedVersions, localRepo, remoteRepos,
- artifactMetadataSource, null, Collections
- .singletonList(listener));
- } catch (ArtifactResolutionException e) {
- getLog().error(
- "An error occurred while resolving project dependencies.",
- e);
- }
- if (getLog().isDebugEnabled()) {
- getLog().debug("Dependency graph");
- getLog().debug("================");
- print(listener.getRootNode());
- getLog().debug("================");
- }
- return listener;
- }
-
- protected Map createManagedVersionMap(String projectId,
- DependencyManagement dependencyManagement) throws ProjectBuildingException {
- Map map;
- if (dependencyManagement != null
- && dependencyManagement.getDependencies() != null) {
- map = new HashMap();
- for (Iterator i = dependencyManagement.getDependencies().iterator(); i
- .hasNext();) {
- Dependency d = (Dependency) i.next();
-
- try {
- VersionRange versionRange = VersionRange
- .createFromVersionSpec(d.getVersion());
- Artifact artifact = factory.createDependencyArtifact(d
- .getGroupId(), d.getArtifactId(), versionRange, d
- .getType(), d.getClassifier(), d.getScope());
- map.put(d.getManagementKey(), artifact);
- } catch (InvalidVersionSpecificationException e) {
- throw new ProjectBuildingException(projectId,
- "Unable to parse version '" + d.getVersion()
- + "' for dependency '"
- + d.getManagementKey() + "': "
- + e.getMessage(), e);
- }
- }
- } else {
- map = Collections.EMPTY_MAP;
- }
- return map;
- }
-
- /**
- * Set up a classloader for the execution of the main class.
- *
- * @return
- * @throws MojoExecutionException
- */
- protected URLClassLoader getClassLoader() throws MojoExecutionException {
- try {
- Set urls = new HashSet();
-
- URL mainClasses = new File(project.getBuild().getOutputDirectory())
- .toURL();
- getLog().debug("Adding to classpath : " + mainClasses);
- urls.add(mainClasses);
-
- URL testClasses = new File(project.getBuild()
- .getTestOutputDirectory()).toURL();
- getLog().debug("Adding to classpath : " + testClasses);
- urls.add(testClasses);
-
- Set dependencies = project.getArtifacts();
- Iterator iter = dependencies.iterator();
- while (iter.hasNext()) {
- Artifact classPathElement = (Artifact) iter.next();
- getLog().debug(
- "Adding artifact: " + classPathElement.getFile()
- + " to classpath");
- urls.add(classPathElement.getFile().toURL());
- }
- URLClassLoader appClassloader = new URLClassLoader((URL[]) urls
- .toArray(new URL[urls.size()]), this.getClass().getClassLoader());
- return appClassloader;
- } catch (MalformedURLException e) {
- throw new MojoExecutionException(
- "Error during setting up classpath", e);
- }
- }
-
- protected String translateFromMaven(String uri) {
- if (uri.startsWith("mvn:")) {
- String[] parts = uri.substring("mvn:".length()).split("/");
- String groupId = parts[0];
- String artifactId = parts[1];
- String version = null;
- String classifier = null;
- String type = "jar";
- if (parts.length > 2) {
- version = parts[2];
- if (parts.length > 3) {
- type = parts[3];
- if (parts.length > 4) {
- classifier = parts[4];
- }
- }
- }
- String dir = groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/";
- String name = artifactId + "-" + version + (classifier != null ? "-" + classifier : "") + "." + type;
-
- return getLocalRepoUrl() + "/" + dir + name;
- }
- if (System.getProperty("os.name").startsWith("Windows") && uri.startsWith("file:")) {
- String baseDir = uri.substring(5).replace('\\', '/').replaceAll(" ", "%20");
- String result = baseDir;
- if (baseDir.indexOf(":") > 0) {
- result = "file:///" + baseDir;
- }
- return result;
- }
- return uri;
- }
-
- protected String getLocalRepoUrl() {
- if (System.getProperty("os.name").startsWith("Windows")) {
- String baseDir = localRepo.getBasedir().replace('\\', '/').replaceAll(" ", "%20");
- return localRepo.getProtocol() + ":///" + baseDir;
- } else {
- return localRepo.getUrl();
- }
- }
-}
diff --git a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/Node.java b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/Node.java
deleted file mode 100644
index 18fe8bc..0000000
--- a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/Node.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.tooling.features;
-
-import java.util.Set;
-import java.util.HashSet;
-
-import org.apache.maven.artifact.Artifact;
-
-/**
- * @version $Revision: 1.1 $
-*/
-public class Node {
- private Set children = new HashSet();
- private Set parents = new HashSet();
- private Artifact artifact;
-
- public Set getChildren() {
- return children;
- }
-
- public Artifact getArtifact() {
- return artifact;
- }
-
- public Set getParents() {
- return parents;
- }
-
- public void setChildren(Set children) {
- this.children = children;
- }
-
- public void setParents(Set parents) {
- this.parents = parents;
- }
-
- public void setArtifact(Artifact artifact) {
- this.artifact = artifact;
- }
-}
diff --git a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ResolutionListenerImpl.java b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ResolutionListenerImpl.java
deleted file mode 100644
index c43dff2..0000000
--- a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ResolutionListenerImpl.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.tooling.features;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Stack;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.resolver.ResolutionListener;
-import org.apache.maven.artifact.versioning.VersionRange;
-import org.apache.maven.plugin.logging.Log;
-
-/**
- * @author Edwin Punzalan
- * @version $Revision: 1.1 $
- */
-public class ResolutionListenerImpl implements ResolutionListener {
- private Stack parents = new Stack();
- private Map artifacts = new HashMap();
- private Node rootNode;
- private Log log;
-
- public void setLog(Log log) {
- this.log = log;
- }
-
- public Log getLog() {
- return log;
- }
-
- public void testArtifact(Artifact artifact) {
- // getLog().debug("testArtifact: " + artifact);
- // intentionally blank
- }
-
- public void startProcessChildren(Artifact artifact) {
- // getLog().debug("startProcessChildren: " + artifact);
- Node node = (Node) artifacts.get(artifact.getDependencyConflictId());
- if (parents.isEmpty()) {
- rootNode = node;
- }
- parents.push(node);
- }
-
- public void endProcessChildren(Artifact artifact) {
- // getLog().debug("endProcessChildren: " + artifact);
- Node check = (Node) parents.pop();
- assert artifact.equals(check.getArtifact());
- }
-
- public void omitForNearer(Artifact omitted, Artifact kept) {
- // getLog().debug("omitForNearer: omitted=" + omitted + ", kept=" +
- // kept);
- assert omitted.getDependencyConflictId().equals(
- kept.getDependencyConflictId());
- Node node = (Node) artifacts.get(omitted.getDependencyConflictId());
- assert node != null;
- node.setArtifact(kept);
- }
-
- public void omitForCycle(Artifact artifact) {
- // getLog().debug("omitForCycle: " + artifact);
- // intentionally blank
- }
-
- public void includeArtifact(Artifact artifact) {
- // getLog().debug("includeArtifact: " + artifact);
- Node node = (Node) artifacts.get(artifact.getDependencyConflictId());
- if (node == null) {
- node = new Node();
- artifacts.put(artifact.getDependencyConflictId(), node);
- }
- node.setArtifact(artifact);
- if (!parents.isEmpty()) {
- Node parent = (Node) parents.peek();
- parent.getChildren().add(node);
- node.getParents().add(parent);
- }
- if (rootNode != null) {
- // print(rootNode, "");
- }
- }
-
- protected void print(Node node, String string) {
- // getLog().debug(string + rootNode.getArtifact());
- for (Iterator iter = node.getChildren().iterator(); iter.hasNext();) {
- Node n = (Node) iter.next();
- print(n, string + " ");
- }
- }
-
- public void updateScope(Artifact artifact, String scope) {
- // getLog().debug("updateScope: " + artifact);
- Node node = (Node) artifacts.get(artifact.getDependencyConflictId());
-
- node.getArtifact().setScope(scope);
- }
-
- public void manageArtifact(Artifact artifact, Artifact replacement) {
- // getLog().debug("manageArtifact: artifact=" + artifact + ",
- // replacement=" + replacement);
- Node node = (Node) artifacts.get(artifact.getDependencyConflictId());
- if (node != null) {
- if (replacement.getVersion() != null) {
- node.getArtifact().setVersion(replacement.getVersion());
- }
- if (replacement.getScope() != null) {
- node.getArtifact().setScope(replacement.getScope());
- }
- }
- }
-
- public void updateScopeCurrentPom(Artifact artifact, String key) {
-
- getLog().debug("updateScopeCurrentPom: " + artifact);
- // intentionally blank
- }
-
- public void selectVersionFromRange(Artifact artifact) {
-
- getLog().debug("selectVersionFromRange: " + artifact);
- // intentionally blank
- }
-
- public void restrictRange(Artifact artifact, Artifact artifact1,
- VersionRange versionRange) {
-
- getLog().debug("restrictRange: " + artifact);
- // intentionally blank
- }
-
- public Node getNode(Artifact artifact) {
- return (Node) artifacts.get(artifact.getDependencyConflictId());
- }
-
- public Collection getArtifacts() {
- return artifacts.values();
- }
-
- public Node getRootNode() {
- return rootNode;
- }
-}
diff --git a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ValidateFeaturesMojo.java b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ValidateFeaturesMojo.java
deleted file mode 100644
index dc1fde0..0000000
--- a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ValidateFeaturesMojo.java
+++ /dev/null
@@ -1,515 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.tooling.features;
-
-import static org.apache.felix.karaf.tooling.features.ManifestUtils.getExports;
-import static org.apache.felix.karaf.tooling.features.ManifestUtils.getMandatoryImports;
-import static org.apache.felix.karaf.tooling.features.ManifestUtils.matches;
-
-import java.io.*;
-import java.net.URI;
-import java.util.*;
-import java.util.jar.Manifest;
-import java.util.zip.ZipException;
-import java.util.zip.ZipFile;
-
-import org.apache.felix.karaf.features.Feature;
-import org.apache.felix.karaf.features.Repository;
-import org.apache.felix.karaf.features.internal.RepositoryImpl;
-import org.apache.felix.utils.manifest.Clause;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.DefaultArtifactRepository;
-import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.DefaultArtifactCollector;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.shared.dependency.tree.DependencyNode;
-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
-import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
-
-/**
- * Validates a features XML file
- *
- * @version $Revision: 1.1 $
- * @goal validate
- * @execute phase="process-resources"
- * @requiresDependencyResolution runtime
- * @inheritByDefault true
- * @description Validates the features XML file
- */
-@SuppressWarnings("unchecked")
-public class ValidateFeaturesMojo extends MojoSupport {
-
- private static final String MVN_URI_PREFIX = "mvn:";
- private static final String MVN_REPO_SEPARATOR = "!";
-
- /**
- * The dependency tree builder to use.
- *
- * @component
- * @required
- * @readonly
- */
- private DependencyTreeBuilder dependencyTreeBuilder;
-
- /**
- * The file to generate
- *
- * @parameter default-value="${project.build.directory}/classes/features.xml"
- */
- private File file;
-
- /**
- * karaf config.properties
- *
- * @parameter default-value="config.properties"
- */
- private String karafConfig;
-
- /**
- * which jre version we wanna parse to get jre exported package in config.properties
- *
- * @parameter default-value="jre-1.5"
- */
- private String jreVersion;
-
- /**
- * The repositories which are included from the plugin config
- * @parameter
- */
- private List<String> repositories;
-
- /*
- * A map to cache the mvn: uris and the artifacts that correspond with them
- */
- private Map<String, Artifact> bundles = new HashMap<String, Artifact>();
-
- /*
- * A map to cache manifests that have been extracted from the bundles
- */
- private Map<Artifact, Manifest> manifests = new HashMap<Artifact, Manifest>();
-
- /*
- * The list of features, includes both the features to be validated and the features from included <repository>s
- */
- private Features features = new Features();
-
- /*
- * The packages exported by the features themselves -- useful when features depend on other features
- */
- private Map<String, Set<Clause>> featureExports = new HashMap<String, Set<Clause>>();
-
- /*
- * The set of packages exported by the system bundle and by Karaf itself
- */
- private Set<String> systemExports = new HashSet<String>();
-
- /**
- * The Mojo's main method
- */
- public void execute() throws MojoExecutionException, MojoFailureException {
- try {
- prepare();
- Repository repository = new RepositoryImpl(file.toURI());
- analyze(repository);
- validate(repository);
- } catch (Exception e) {
- e.printStackTrace();
- throw new MojoExecutionException(String.format("Unable to validate %s: %s", file.getAbsolutePath(), e.getMessage()), e);
- }
-
- }
-
- /*
- * Prepare for validation by determing system and Karaf exports
- */
- private void prepare() throws Exception {
- info("== Preparing for validation ==");
- info(" - getting list of system bundle exports");
- readSystemPackages();
- info(" - getting list of provided bundle exports");
- readProvidedBundles();
- }
-
- /*
- * Analyse the descriptor and any <repository>s that might be part of it
- */
- private void analyze(Repository repository) throws Exception {
- info("== Analyzing feature descriptor ==");
- info(" - read %s", file.getAbsolutePath());
-
- features.add(repository.getFeatures());
-
- // add the repositories from the plugin configuration
- if (repositories != null) {
- for (String uri : repositories) {
- getLog().info(String.format(" - adding repository from %s", uri));
- Repository dependency = new RepositoryImpl(URI.create(translateFromMaven(uri)));
- features.add(dependency.getFeatures());
- validateBundlesAvailable(dependency);
- analyzeExports(dependency);
- }
- }
-
- for (URI uri : repository.getRepositories()) {
- Artifact artifact = resolve(uri.toString());
- Repository dependency = new RepositoryImpl(new File(localRepo.getBasedir(), localRepo.pathOf(artifact)).toURI());
- getLog().info(String.format(" - adding %d known features from %s", dependency.getFeatures().length, uri));
- features.add(dependency.getFeatures());
- // we need to do this to get all the information ready for further processing
- validateBundlesAvailable(dependency);
- analyzeExports(dependency);
- }
-
- }
-
- /*
- * Perform the actual validation
- */
- private void validate(Repository repository) throws Exception {
- info("== Validating feature descriptor ==");
- info(" - validating %d features", repository.getFeatures().length);
- info(" - step 1: Checking if all artifacts exist");
- validateBundlesAvailable(repository);
- info(" OK: all %d OSGi bundles have been found", bundles.size());
- info(" - step 2: Checking if all imports for bundles can be resolved");
- validateImportsExports(repository);
- info("== Done! ==========================");
- }
-
-
- /*
- * Determine list of exports by bundles that have been marked provided in the pom
- * //TODO: we probably want to figure this out somewhere from the Karaf build itself instead of putting the burden on the user
- */
- private void readProvidedBundles() throws Exception {
- DependencyNode tree = dependencyTreeBuilder.buildDependencyTree(project, localRepo, factory, artifactMetadataSource, new ArtifactFilter() {
-
- public boolean include(Artifact artifact) {
- return true;
- }
-
- }, new DefaultArtifactCollector());
- tree.accept(new DependencyNodeVisitor() {
- public boolean endVisit(DependencyNode node) {
- // we want the next sibling too
- return true;
- }
-
- public boolean visit(DependencyNode node) {
- if (node.getState() != DependencyNode.OMITTED_FOR_CONFLICT) {
- Artifact artifact = node.getArtifact();
- info(" scanning %s for exports", artifact);
- if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) && !artifact.getType().equals("pom")) {
- try {
- for (Clause clause : ManifestUtils.getExports(getManifest(artifact))) {
- getLog().debug(" adding " + clause.getName() + " to list of available packages");
- systemExports.add(clause.getName());
- }
- } catch (ArtifactResolutionException e) {
- error("Unable to find bundle exports for %s: %s", e, artifact, e.getMessage());
- } catch (ArtifactNotFoundException e) {
- error("Unable to find bundle exports for %s: %s", e, artifact, e.getMessage());
- } catch (IOException e) {
- error("Unable to find bundle exports for %s: %s", e, artifact, e.getMessage());
- }
- }
- }
- // we want the children too
- return true;
- }
- });
- }
-
- /*
- * Read system packages from a properties file
- * //TODO: we should probably grab this file from the Karaf distro itself instead of duplicating it in the plugin
- */
- private void readSystemPackages() throws IOException {
- Properties properties = new Properties();
- if (karafConfig.equals("config.properties")) {
- properties.load(getClass().getClassLoader().getResourceAsStream("config.properties"));
- } else {
- properties.load(new FileInputStream(new File(karafConfig)));
- }
-
- String packages = (String) properties.get(jreVersion);
- for (String pkg : packages.split(";")) {
- systemExports .add(pkg.trim());
- }
- for (String pkg : packages.split(",")) {
- systemExports .add(pkg.trim());
- }
- }
-
- /*
- * Analyze exports in all features in the repository without validating the features
- * (e.g. used for <repository> elements found in a descriptor)
- */
- private void analyzeExports(Repository repository) throws Exception {
- for (Feature feature : repository.getFeatures()) {
- Set<Clause> exports = new HashSet<Clause>();
- for (String bundle : feature.getBundles()) {
- exports.addAll(getExports(getManifest(bundles.get(bundle))));
- }
- info(" scanning feature %s for exports", feature.getName());
- featureExports.put(feature.getName(), exports);
- }
- }
-
- /*
- * Check if all the bundles can be downloaded and are actually OSGi bundles and not plain JARs
- */
- private void validateBundlesAvailable(Repository repository) throws Exception {
- for (Feature feature : repository.getFeatures()) {
- for (String bundle : feature.getBundles()) {
- // this will throw an exception if the artifact can not be resolved
- final Artifact artifact = resolve(bundle);
- bundles.put(bundle, artifact);
- if (isBundle(artifact)) {
- manifests.put(artifact, getManifest(artifact));
- } else {
- throw new Exception(String.format("%s is not an OSGi bundle", bundle));
- }
- }
- }
- }
-
- /*
- * Validate if all features in a repository have bundles which can be resolved
- */
- private void validateImportsExports(Repository repository) throws ArtifactResolutionException, ArtifactNotFoundException, Exception {
- for (Feature feature : repository.getFeatures()) {
- // make sure the feature hasn't been validated before as a dependency
- if (!featureExports.containsKey(feature.getName())) {
- validateImportsExports(feature);
- }
- }
- }
-
- /*
- * Validate if all imports for a feature are being matched with exports
- */
- private void validateImportsExports(Feature feature) throws Exception {
- Map<Clause, String> imports = new HashMap<Clause, String>();
- Set<Clause> exports = new HashSet<Clause>();
- for (Feature dependency : feature.getDependencies()) {
- if (featureExports.containsKey(dependency.getName())) {
- exports.addAll(featureExports.get(dependency.getName()));
- } else {
- validateImportsExports(features.get(dependency.getName(), dependency.getVersion()));
- }
- }
- for (String bundle : feature.getBundles()) {
- Manifest meta = manifests.get(bundles.get(bundle));
- exports.addAll(getExports(meta));
- for (Clause clause : getMandatoryImports(meta)) {
- imports.put(clause, bundle);
- }
- }
-
- // setting up the set of required imports
- Set<Clause> requirements = new HashSet<Clause>();
- requirements.addAll(imports.keySet());
-
- // now, let's remove requirements whenever we find a matching export for them
- for (Clause element : imports.keySet()) {
- if (systemExports.contains(element.getName())) {
- debug("%s is resolved by a system bundle export or provided bundle", element);
- requirements.remove(element);
- continue;
- }
- for (Clause export : exports) {
- if (matches(element, export)) {
- debug("%s is resolved by export %s", element, export);
- requirements.remove(element);
- continue;
- }
- debug("%s is not resolved by export %s", element, export);
- }
- }
-
- // if there are any more requirements left here, there's a problem with the feature
- if (!requirements.isEmpty()) {
- warn("Failed to validate feature %s", feature.getName());
- for (Clause entry : requirements) {
- warn("No export found to match %s (imported by %s)",
- entry, imports.get(entry));
- }
- throw new Exception(String.format("%d unresolved imports in feature %s",
- requirements.size(), feature.getName()));
- }
- info(" OK: imports resolved for %s", feature.getName());
- featureExports.put(feature.getName(), exports);
- }
-
- /*
- * Check if the artifact is an OSGi bundle
- */
- private boolean isBundle(Artifact artifact) {
- if ("bundle".equals(artifact.getArtifactHandler().getPackaging())) {
- return true;
- } else {
- try {
- return ManifestUtils.isBundle(getManifest(artifact));
- } catch (ZipException e) {
- getLog().debug("Unable to determine if " + artifact + " is a bundle; defaulting to false", e);
- } catch (IOException e) {
- getLog().debug("Unable to determine if " + artifact + " is a bundle; defaulting to false", e);
- } catch (Exception e) {
- getLog().debug("Unable to determine if " + artifact + " is a bundle; defaulting to false", e);
- }
- }
- return false;
- }
-
- /*
- * Extract the META-INF/MANIFEST.MF file from an artifact
- */
- private Manifest getManifest(Artifact artifact) throws ArtifactResolutionException, ArtifactNotFoundException,
- ZipException, IOException {
- File localFile = new File(localRepo.pathOf(artifact));
- ZipFile file;
- if (localFile.exists()) {
- // avoid going over to the repository if the file is already on the disk
- file = new ZipFile(localFile);
- } else {
- resolver.resolve(artifact, remoteRepos, localRepo);
- file = new ZipFile(artifact.getFile());
- }
- // let's replace syserr for now to hide warnings being issues by the Manifest reading process
- PrintStream original = System.err;
- try {
- System.setErr(new PrintStream(new ByteArrayOutputStream()));
- return new Manifest(file.getInputStream(file.getEntry("META-INF/MANIFEST.MF")));
- } finally {
- System.setErr(original);
- }
- }
-
- /*
- * Resolve an artifact, downloading it from remote repositories when necessary
- */
- private Artifact resolve(String bundle) throws Exception, ArtifactNotFoundException {
- Artifact artifact = getArtifact(bundle);
- if (bundle.indexOf(MVN_REPO_SEPARATOR) >= 0) {
- if (bundle.startsWith(MVN_URI_PREFIX)) {
- bundle = bundle.substring(MVN_URI_PREFIX.length());
- }
- String repo = bundle.substring(0, bundle.indexOf(MVN_REPO_SEPARATOR));
- ArtifactRepository repository = new DefaultArtifactRepository(artifact.getArtifactId() + "-repo", repo,
- new DefaultRepositoryLayout());
- List<ArtifactRepository> repos = new LinkedList<ArtifactRepository>();
- repos.add(repository);
- resolver.resolve(artifact, repos, localRepo);
- } else {
- resolver.resolve(artifact, remoteRepos, localRepo);
- }
- if (artifact == null) {
- throw new Exception("Unable to resolve artifact for uri " + bundle);
- } else {
- return artifact;
- }
- }
-
- /*
- * Create an artifact for a given mvn: uri
- */
- private Artifact getArtifact(String uri) {
- // remove the mvn: prefix when necessary
- if (uri.startsWith(MVN_URI_PREFIX)) {
- uri = uri.substring(MVN_URI_PREFIX.length());
- }
- // remove the repository url when specified
- if (uri.contains(MVN_REPO_SEPARATOR)) {
- uri = uri.split(MVN_REPO_SEPARATOR)[1];
- }
- String[] elements = uri.split("/");
- switch (elements.length) {
- case 5:
- return factory.createArtifactWithClassifier(elements[0], elements[1], elements[2], elements[3], elements[4]);
- case 3:
- return factory.createArtifact(elements[0], elements[1], elements[2], Artifact.SCOPE_PROVIDED, "jar");
- default:
- return null;
- }
-
- }
-
- /*
- * Helper method for debug logging
- */
- private void debug(String message, Object... parms) {
- if (getLog().isDebugEnabled()) {
- getLog().debug(String.format(message, parms));
- }
- }
-
- /*
- * Helper method for info logging
- */
- private void info(String message, Object... parms) {
- getLog().info(String.format(message, parms));
- }
-
- /*
- * Helper method for warn logging
- */
- private void warn(String message, Object... parms) {
- getLog().warn(String.format(message, parms));
- }
-
- /*
- * Helper method for error logging
- */
- private void error(String message, Exception error, Object... parms) {
- getLog().error(String.format(message, parms), error);
- }
-
- /*
- * Convenience collection for holding features
- */
- private class Features {
-
- private List<Feature> features = new LinkedList<Feature>();
-
- public void add(Feature feature) {
- features.add(feature);
- }
-
- public Feature get(String name, String version) throws Exception {
- for (Feature feature : features) {
- if (name.equals(feature.getName()) && version.equals(feature.getVersion())) {
- return feature;
- }
- }
- throw new Exception(String.format("Unable to find definition for feature %s (version %s)",
- name, version));
- }
-
- public void add(Feature[] array) {
- for (Feature feature : array) {
- add(feature);
- }
- }
- }
-}
diff --git a/karaf/tooling/features-maven-plugin/src/main/resources/config.properties b/karaf/tooling/features-maven-plugin/src/main/resources/config.properties
deleted file mode 100644
index 870e83c..0000000
--- a/karaf/tooling/features-maven-plugin/src/main/resources/config.properties
+++ /dev/null
@@ -1,144 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-jre-1.5= \
- javax.accessibility; \
- javax.activity; \
- javax.crypto; \
- javax.crypto.interfaces; \
- javax.crypto.spec; \
- javax.imageio; \
- javax.imageio.event; \
- javax.imageio.metadata; \
- javax.imageio.plugins.bmp; \
- javax.imageio.plugins.jpeg; \
- javax.imageio.spi; \
- javax.imageio.stream; \
- javax.management; \
- javax.management.loading; \
- javax.management.modelmbean; \
- javax.management.monitor; \
- javax.management.openmbean; \
- javax.management.relation; \
- javax.management.remote; \
- javax.management.remote.rmi; \
- javax.management.timer; \
- javax.naming; \
- javax.naming.directory; \
- javax.naming.event; \
- javax.naming.ldap; \
- javax.naming.spi; \
- javax.net; \
- javax.net.ssl; \
- javax.print; \
- javax.print.attribute; \
- javax.print.attribute.standard; \
- javax.print.event; \
- javax.rmi; \
- javax.rmi.CORBA; \
- javax.rmi.ssl; \
- javax.security.auth; \
- javax.security.auth.callback; \
- javax.security.auth.kerberos; \
- javax.security.auth.login; \
- javax.security.auth.spi; \
- javax.security.auth.x500; \
- javax.security.cert; \
- javax.security.sasl; \
- javax.sound.midi; \
- javax.sound.midi.spi; \
- javax.sound.sampled; \
- javax.sound.sampled.spi; \
- javax.sql; \
- javax.sql.rowset; \
- javax.sql.rowset.serial; \
- javax.sql.rowset.spi; \
- javax.swing; \
- javax.swing.border; \
- javax.swing.colorchooser; \
- javax.swing.event; \
- javax.swing.filechooser; \
- javax.swing.plaf; \
- javax.swing.plaf.basic; \
- javax.swing.plaf.metal; \
- javax.swing.plaf.multi; \
- javax.swing.plaf.synth; \
- javax.swing.table; \
- javax.swing.text; \
- javax.swing.text.html; \
- javax.swing.text.html.parser; \
- javax.swing.text.rtf; \
- javax.swing.tree; \
- javax.swing.undo; \
- javax.xml; \
- javax.xml.datatype; \
- javax.xml.namespace; \
- javax.xml.parsers; \
- javax.xml.transform; \
- javax.xml.transform.dom; \
- javax.xml.transform.sax; \
- javax.xml.transform.stream; \
- javax.xml.validation; \
- javax.xml.xpath; \
- org.ietf.jgss; \
- org.omg.CORBA; \
- org.omg.CORBA_2_3; \
- org.omg.CORBA_2_3.portable; \
- org.omg.CORBA.DynAnyPackage; \
- org.omg.CORBA.ORBPackage; \
- org.omg.CORBA.portable; \
- org.omg.CORBA.TypeCodePackage; \
- org.omg.CosNaming; \
- org.omg.CosNaming.NamingContextExtPackage; \
- org.omg.CosNaming.NamingContextPackage; \
- org.omg.Dynamic; \
- org.omg.DynamicAny; \
- org.omg.DynamicAny.DynAnyFactoryPackage; \
- org.omg.DynamicAny.DynAnyPackage; \
- org.omg.IOP; \
- org.omg.IOP.CodecFactoryPackage; \
- org.omg.IOP.CodecPackage; \
- org.omg.Messaging; \
- org.omg.PortableInterceptor; \
- org.omg.PortableInterceptor.ORBInitInfoPackage; \
- org.omg.PortableServer; \
- org.omg.PortableServer.CurrentPackage; \
- org.omg.PortableServer.POAManagerPackage; \
- org.omg.PortableServer.POAPackage; \
- org.omg.PortableServer.portable; \
- org.omg.PortableServer.ServantLocatorPackage; \
- org.omg.SendingContext; \
- org.omg.stub.java.rmi; \
- org.omg.stub.javax.management.remote.rmi; \
- org.w3c.dom; \
- org.w3c.dom.bootstrap; \
- org.w3c.dom.css; \
- org.w3c.dom.events; \
- org.w3c.dom.html; \
- org.w3c.dom.ls; \
- org.w3c.dom.ranges; \
- org.w3c.dom.stylesheets; \
- org.w3c.dom.traversal; \
- org.w3c.dom.views; \
- org.xml.sax; \
- org.xml.sax.ext; \
- org.xml.sax.helpers; \
- sun.misc; \
- sun.reflect
-
-osgi= \
- org.osgi.framework;
diff --git a/karaf/tooling/features-maven-plugin/src/test/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesFileMojoTest.java b/karaf/tooling/features-maven-plugin/src/test/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesFileMojoTest.java
deleted file mode 100644
index 4f8c499..0000000
--- a/karaf/tooling/features-maven-plugin/src/test/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesFileMojoTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.tooling.features;
-
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
-import org.apache.maven.artifact.versioning.ArtifactVersion;
-import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
-import org.easymock.EasyMock;
-
-/**
- * Test cases for {@link GenerateFeaturesFileMojo}
- */
-public class GenerateFeaturesFileMojoTest extends TestCase {
-
- private GenerateFeaturesFileMojo mojo;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mojo = new GenerateFeaturesFileMojo();
- }
-
- public void testGetBestVersionForArtifactWithOneVersion() throws Exception {
- final Artifact artifact = EasyMock.createMock(Artifact.class);
- expect(artifact.getVersion()).andReturn("2.1.6");
- replay(artifact);
-
- assertEquals("2.1.6_1-SNAPSHOT", mojo.getBestVersionForArtifact(artifact, createVersionList("2.1.6_1-SNAPSHOT")));
- }
-
- public void testGetBestVersionForArtifactWithTwoVersions() throws Exception {
- final Artifact artifact = EasyMock.createMock(Artifact.class);
- expect(artifact.getVersion()).andReturn("2.1.6");
- replay(artifact);
-
- assertEquals("2.1.6_2-SNAPSHOT", mojo.getBestVersionForArtifact(artifact, createVersionList("2.1.6_1-SNAPSHOT", "2.1.6_2-SNAPSHOT")));
- }
-
- public void testGetBestVersionForArtifactWithSameMajorMinor() throws Exception {
- final Artifact artifact = EasyMock.createMock(Artifact.class);
- expect(artifact.getVersion()).andReturn("3.8.2").anyTimes();
- replay(artifact);
-
- assertEquals("3.8.1_1-SNAPSHOT", mojo.getBestVersionForArtifact(artifact, createVersionList("3.8.1_1-SNAPSHOT")));
- }
-
-
- public void testGetBestVersionForArtifactWithOneNonMatchingVersion() throws Exception {
- final Artifact artifact = EasyMock.createMock(Artifact.class);
- expect(artifact.getVersion()).andReturn("9.1.0.1").anyTimes();
- replay(artifact);
-
- try {
- mojo.getBestVersionForArtifact(artifact, createVersionList("9.0_1-SNAPSHOT"));
- fail("ArtifactMetadataRetrievalException should have been thrown if no matching version was found");
- } catch (ArtifactMetadataRetrievalException e) {
- // this is expected
- }
- }
-
- public void testGetBestVersionForArtifactWithNoVersions() throws Exception {
- try {
- mojo.getBestVersionForArtifact(EasyMock.createMock(Artifact.class), createVersionList());
- fail("ArtifactMetadataRetrievalException should have been thrown if no matching version was found");
- } catch (ArtifactMetadataRetrievalException e) {
- // this is expected
- }
- }
-
- private List<ArtifactVersion> createVersionList(String... versions) {
- List<ArtifactVersion> results = new ArrayList<ArtifactVersion>();
- for (final String version : versions) {
- results.add(new DefaultArtifactVersion(version));
- }
- return results;
- }
-}
diff --git a/karaf/tooling/features-maven-plugin/src/test/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesXmlMojoTest.java b/karaf/tooling/features-maven-plugin/src/test/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesXmlMojoTest.java
deleted file mode 100644
index dff00cf..0000000
--- a/karaf/tooling/features-maven-plugin/src/test/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesXmlMojoTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.tooling.features;
-
-import org.apache.maven.artifact.Artifact;
-import org.easymock.EasyMock;
-
-import static org.easymock.EasyMock.*;
-
-import junit.framework.TestCase;
-
-/**
- * Test cases for {@link GenerateFeaturesXmlMojo}
- */
-public class GenerateFeaturesXmlMojoTest extends TestCase {
-
- public void testToString() throws Exception {
- Artifact artifact = EasyMock.createMock(Artifact.class);
-
- expect(artifact.getGroupId()).andReturn("org.apache.felix.karaf.test");
- expect(artifact.getArtifactId()).andReturn("test-artifact");
- expect(artifact.getVersion()).andReturn("1.2.3");
-
- replay(artifact);
-
- assertEquals("org.apache.felix.karaf.test/test-artifact/1.2.3", GenerateFeaturesXmlMojo.toString(artifact));
- }
-
-}
diff --git a/karaf/tooling/features-maven-plugin/src/test/java/org/apache/felix/karaf/tooling/features/ManifestUtilsTest.java b/karaf/tooling/features-maven-plugin/src/test/java/org/apache/felix/karaf/tooling/features/ManifestUtilsTest.java
deleted file mode 100644
index efa1136..0000000
--- a/karaf/tooling/features-maven-plugin/src/test/java/org/apache/felix/karaf/tooling/features/ManifestUtilsTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.tooling.features;
-
-import static org.apache.felix.karaf.tooling.features.ManifestUtils.matches;
-
-import junit.framework.TestCase;
-
-import java.util.HashMap;
-
-import org.apache.felix.utils.manifest.Attribute;
-import org.apache.felix.utils.manifest.Clause;
-import org.apache.felix.utils.manifest.Directive;
-import org.osgi.framework.Constants;
-
-/**
- * Test cased for {@link org.apache.felix.karaf.tooling.features.ManifestUtils}
- */
-public class ManifestUtilsTest extends TestCase {
-
- public void testIsOptional() {
- Directive[] directive = new Directive[0];
- Attribute[] attribute = new Attribute[0];
- Clause clause = new Clause("org.apache.karaf.test", directive, attribute);
- assertFalse(ManifestUtils.isOptional(clause));
-
- directive = new Directive[1];
- directive[0] = new Directive("resolution", "mandatory");
- clause = new Clause("org.apache.karaf.test", directive, attribute);
-
- assertFalse(ManifestUtils.isOptional(clause));
-
- directive[0] = new Directive("resolution", "optional");
- clause = new Clause("org.apache.karaf.test", directive, attribute);
- assertTrue(ManifestUtils.isOptional(clause));
- }
-
- public void testMatches() {
- assertFalse(matches(clause("org.apache.karaf.dev"), clause("org.apache.karaf.test")));
- assertTrue(matches(clause("org.apache.karaf.test"), clause("org.apache.karaf.test")));
-
- assertFalse(matches(clause("org.apache.karaf.test", "1.2.0"), clause("org.apache.karaf.test", "[1.1.0, 1.1.0]")));
- assertTrue(matches(clause("org.apache.karaf.test", "1.1.0"), clause("org.apache.karaf.test", "[1.1.0, 1.1.0]")));
-
- // a single version means >= 1.0.0, so 1.1.O should be a match
- assertTrue(matches(clause("org.apache.karaf.test", "1.0.0"), clause("org.apache.karaf.test", "1.1.0")));
- assertTrue(matches(clause("org.apache.karaf.test", "1.0.0"), clause("org.apache.karaf.test")));
-
- assertFalse(matches(clause("org.apache.karaf.test", "[1.1.0, 1.2.0)"), clause("org.apache.karaf.test", "[1.0.0, 1.0.0]")));
- assertFalse(matches(clause("org.apache.karaf.test", "[1.1.0, 1.2.0)"), clause("org.apache.karaf.test", "[1.2.0, 1.2.0]")));
- assertTrue(matches(clause("org.apache.karaf.test", "[1.1.0, 1.2.0)"), clause("org.apache.karaf.test", "[1.1.0, 1.1.0]")));
- assertTrue(matches(clause("org.apache.karaf.test", "[1.1.0, 1.2.0)"), clause("org.apache.karaf.test", "[1.1.1, 1.1.1]")));
- assertTrue(matches(clause("org.apache.karaf.test", "[1.1.0, 1.1.0]"), clause("org.apache.karaf.test", "[1.1.0, 1.1.0]")));
- assertFalse(matches(clause("org.apache.karaf.test", "[1.1.0, 1.1.0]"), clause("org.apache.karaf.test", "1.1.1")));
- assertTrue(matches(clause("org.apache.karaf.test", "[1.1.0, 1.1.0]"), clause("org.apache.karaf.test", "1.0.0")));
- }
-
- private Clause clause(String name) {
- return new Clause(name, new Directive[0], new Attribute[0]);
- }
-
- private Clause clause(String name, String version) {
- Attribute[] attribute = {new Attribute(Constants.VERSION_ATTRIBUTE, version)};
- return new Clause(name, new Directive[0], attribute);
- }
-}
diff --git a/karaf/tooling/pom.xml b/karaf/tooling/pom.xml
deleted file mode 100644
index 5122c27..0000000
--- a/karaf/tooling/pom.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<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/maven-v4_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.felix.karaf</groupId>
- <artifactId>karaf</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.tooling</groupId>
- <artifactId>tooling</artifactId>
- <packaging>pom</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Tooling</name>
-
- <modules>
- <module>features-maven-plugin</module>
- <module>cmdhelp-maven-plugin</module>
- <module>testing</module>
- </modules>
-
-</project>
diff --git a/karaf/tooling/testing/pom.xml b/karaf/tooling/testing/pom.xml
deleted file mode 100644
index 1961923..0000000
--- a/karaf/tooling/testing/pom.xml
+++ /dev/null
@@ -1,146 +0,0 @@
-<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/maven-v4_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.felix.karaf.tooling</groupId>
- <artifactId>tooling</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.tooling</groupId>
- <artifactId>org.apache.felix.karaf.tooling.testing</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Testing environment</name>
-
- <description>
- A bundle to help using Pax-Exam and Karaf.
- </description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <!-- The assembly and all the dependencies -->
- <dependency>
- <groupId>org.apache.felix.karaf</groupId>
- <artifactId>apache-felix-karaf</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <!-- Pax EXAM -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam</artifactId>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-container-default</artifactId>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit-extender-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <resources>
- <resource>
- <directory>${project.basedir}/src/main/resources</directory>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-filtered</id>
- <!-- here the phase you need -->
- <phase>compile</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <outputDirectory>${basedir}/target/classes/</outputDirectory>
- <resources>
- <resource>
- <directory>../../assembly/src/main/filtered-resources/etc</directory>
- <filtering>true</filtering>
- <includes>
- <include>config.properties</include>
- <include>startup.properties</include>
- </includes>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <!-- generate dependencies versions -->
- <plugin>
- <groupId>org.apache.servicemix.tooling</groupId>
- <artifactId>depends-maven-plugin</artifactId>
- <version>1.1</version>
- <executions>
- <execution>
- <id>generate-depends-file</id>
- <goals>
- <goal>generate-depends-file</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>org.apache.felix.karaf.testing;version=${project.version}</Export-Package>
- <Import-Package>
- !org.apache.felix.karaf.testing*,
- *
- </Import-Package>
- <Include-Resource>
- {maven-resources},
- org/apache/felix/karaf/testing/config.properties=target/classes/config.properties,
- org/apache/felix/karaf/testing/startup.properties=target/classes/startup.properties
- </Include-Resource>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git a/karaf/tooling/testing/src/main/java/org/apache/felix/karaf/testing/AbstractIntegrationTest.java b/karaf/tooling/testing/src/main/java/org/apache/felix/karaf/testing/AbstractIntegrationTest.java
deleted file mode 100644
index 17177b6..0000000
--- a/karaf/tooling/testing/src/main/java/org/apache/felix/karaf/testing/AbstractIntegrationTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.testing;
-
-import java.util.Collection;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-
-import static org.apache.felix.karaf.testing.Helper.mavenBundle;
-
-public abstract class AbstractIntegrationTest {
-
- public static final long DEFAULT_TIMEOUT = 30000;
-
- @Inject
- protected BundleContext bundleContext;
-
- protected <T> T getOsgiService(Class<T> type, long timeout) {
- return getOsgiService(type, null, timeout);
- }
-
- protected <T> T getOsgiService(Class<T> type) {
- return getOsgiService(type, null, DEFAULT_TIMEOUT);
- }
-
- protected <T> T getOsgiService(Class<T> type, String filter, long timeout) {
- ServiceTracker tracker = null;
- try {
- String flt;
- if (filter != null) {
- if (filter.startsWith("(")) {
- flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")" + filter + ")";
- } else {
- flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")(" + filter + "))";
- }
- } else {
- flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
- }
- Filter osgiFilter = FrameworkUtil.createFilter(flt);
- tracker = new ServiceTracker(bundleContext, osgiFilter, null);
- tracker.open(true);
- // Note that the tracker is not closed to keep the reference
- // This is buggy, as the service reference may change i think
- Object svc = type.cast(tracker.waitForService(timeout));
- if (svc == null) {
- Dictionary dic = bundleContext.getBundle().getHeaders();
- System.err.println("Test bundle headers: " + explode(dic));
-
- for (ServiceReference ref : asCollection(bundleContext.getAllServiceReferences(null, null))) {
- System.err.println("ServiceReference: " + ref);
- }
-
- for (ServiceReference ref : asCollection(bundleContext.getAllServiceReferences(null, flt))) {
- System.err.println("Filtered ServiceReference: " + ref);
- }
-
- throw new RuntimeException("Gave up waiting for service " + flt);
- }
- return type.cast(svc);
- } catch (InvalidSyntaxException e) {
- throw new IllegalArgumentException("Invalid filter", e);
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
-
- protected Bundle installBundle(String groupId, String artifactId) throws Exception {
- MavenArtifactProvisionOption mvnUrl = mavenBundle(groupId, artifactId);
- return bundleContext.installBundle(mvnUrl.getURL());
- }
-
- protected Bundle getInstalledBundle(String symbolicName) {
- for (Bundle b : bundleContext.getBundles()) {
- if (b.getSymbolicName().equals(symbolicName)) {
- return b;
- }
- }
- return null;
- }
-
- /*
- * Explode the dictionary into a ,-delimited list of key=value pairs
- */
- private static String explode(Dictionary dictionary) {
- Enumeration keys = dictionary.keys();
- StringBuffer result = new StringBuffer();
- while (keys.hasMoreElements()) {
- Object key = keys.nextElement();
- result.append(String.format("%s=%s", key, dictionary.get(key)));
- if (keys.hasMoreElements()) {
- result.append(", ");
- }
- }
- return result.toString();
- }
-
- /*
- * Provides an iterable collection of references, even if the original array is null
- */
- private static final Collection<ServiceReference> asCollection(ServiceReference[] references) {
- List<ServiceReference> result = new LinkedList<ServiceReference>();
- if (references != null) {
- for (ServiceReference reference : references) {
- result.add(reference);
- }
- }
- return result;
- }
-
-}
\ No newline at end of file
diff --git a/karaf/tooling/testing/src/main/java/org/apache/felix/karaf/testing/Helper.java b/karaf/tooling/testing/src/main/java/org/apache/felix/karaf/testing/Helper.java
deleted file mode 100644
index e509575..0000000
--- a/karaf/tooling/testing/src/main/java/org/apache/felix/karaf/testing/Helper.java
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.testing;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.ops4j.pax.exam.CoreOptions;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
-import org.ops4j.pax.exam.options.SystemPropertyOption;
-
-import static org.ops4j.pax.exam.CoreOptions.bootClasspathLibrary;
-import static org.ops4j.pax.exam.CoreOptions.bootDelegationPackages;
-import static org.ops4j.pax.exam.CoreOptions.frameworkStartLevel;
-import static org.ops4j.pax.exam.CoreOptions.maven;
-import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
-import static org.ops4j.pax.exam.OptionUtils.combine;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
-
-/**
- * Helper class for setting up a pax-exam test environment for karaf.
- *
- * A simple configuration for pax-exam can be create using the following
- * code:
- * <pre>
- * @Configuration
- * public static Option[] configuration() throws Exception{
- * return combine(
- * // Default karaf environment
- * Helper.getDefaultOptions(),
- * // Test on both equinox and felix
- * equinox(), felix()
- * );
- * }
- * </pre>
- *
- */
-public final class Helper {
-
- private Helper() {
- }
-
- /**
- * Create an provisioning option for the specified maven artifact
- * (groupId and artifactId), using the version found in the list
- * of dependencies of this maven project.
- *
- * @param groupId the groupId of the maven bundle
- * @param artifactId the artifactId of the maven bundle
- * @return the provisioning option for the given bundle
- */
- public static MavenArtifactProvisionOption mavenBundle(String groupId, String artifactId) {
- return CoreOptions.mavenBundle(groupId, artifactId).versionAsInProject();
- }
-
- /**
- * Return a map of system properties for karaf.
- * The default karaf home directory is "target/karaf.home".
- *
- * @return a list of system properties for karaf
- */
- public static Properties getDefaultSystemOptions() {
- return getDefaultSystemOptions("target/karaf.home");
- }
-
- /**
- * Return a map of system properties for karaf,
- * using the specified folder for the karaf home directory.
- *
- * @param karafHome the karaf home directory
- * @return a list of system properties for karaf
- */
- public static Properties getDefaultSystemOptions(String karafHome) {
- Properties sysProps = new Properties();
- sysProps.setProperty("karaf.name", "root");
- sysProps.setProperty("karaf.home", karafHome);
- sysProps.setProperty("karaf.base", karafHome);
- sysProps.setProperty("karaf.startLocalConsole", "false");
- sysProps.setProperty("karaf.startRemoteShell", "false");
- sysProps.setProperty("org.osgi.framework.startlevel.beginning", "100");
- return sysProps;
- }
-
- /**
- * Return an array of pax-exam options to correctly configure the osgi
- * framework for karaf.
- *
- * @param sysOptions test-specific system property options
- * @return default pax-exam options for karaf osgi framework
- */
- public static Option[] getDefaultConfigOptions(SystemPropertyOption... sysOptions) {
- return getDefaultConfigOptions(getDefaultSystemOptions(),
- getResource("/org/apache/felix/karaf/testing/config.properties"),
- sysOptions);
- }
-
- /**
- * Return an array of pax-exam options to configure the osgi
- * framework for karaf, given the system properties and the
- * location of the osgi framework properties file.
- *
- * @param sysProps karaf system properties
- * @param configProperties the URL to load the osgi framework properties from
- * @param sysOptions test-specific system property options
- * @return pax-exam options for karaf osgi framework
- */
- public static Option[] getDefaultConfigOptions(Properties sysProps, URL configProperties, SystemPropertyOption... sysOptions) {
- // Load props
- Properties configProps = loadProperties(configProperties);
-
- // Set system props
- for (Enumeration e = sysProps.propertyNames(); e.hasMoreElements();) {
- String key = (String) e.nextElement();
- configProps.setProperty(key, sysProps.getProperty(key));
- }
- // Perform variable substitution for system properties.
- for (Enumeration e = configProps.propertyNames(); e.hasMoreElements();) {
- String name = (String) e.nextElement();
- configProps.setProperty(name, substVars(configProps.getProperty(name), name, null, configProps));
- }
- // Transform system properties to VM options
- List<Option> options = new ArrayList<Option>();
- String vmOptions = "";
- for (Enumeration e = configProps.propertyNames(); e.hasMoreElements();) {
- String name = (String) e.nextElement();
- String value = configProps.getProperty(name);
- value = align(value);
- if ("org.osgi.framework.system.packages".equals(name)) {
- String extra = align(configProps.getProperty("org.osgi.framework.system.packages.extra"));
- vmOptions = vmOptions + " -D" + name + "=" + value + "," + extra;
- } else if ("org.osgi.framework.bootdelegation".equals(name)) {
- options.add(bootDelegationPackages(value));
- } else {
- vmOptions = vmOptions + " -D" + name + "=" + value;
- }
- }
-
- // add test-specific system properties
- if (sysOptions != null) {
- for (SystemPropertyOption sysOption : sysOptions) {
- vmOptions = vmOptions + " -D" + sysOption.getKey() + "=" + sysOption.getValue();
- }
- }
-
- if (configProps.getProperty("org.osgi.framework.startlevel.beginning") != null) {
- options.add(frameworkStartLevel(Integer.parseInt(configProps.getProperty("org.osgi.framework.startlevel.beginning"))));
- }
-
- options.add(vmOption(vmOptions));
-
- return options.toArray(new Option[options.size()]);
- }
-
- /**
- * Return an array of pax-exam options for the provisioning of karaf system bundles.
- *
- * @return an array of pax-exam options for provisioning karaf system bundles
- */
- public static Option[] getDefaultProvisioningOptions() {
- return getDefaultProvisioningOptions(getDefaultSystemOptions(),
- getResource("/org/apache/felix/karaf/testing/startup.properties"));
- }
-
- /**
- * Return an array of pax-exam options for the provisioning of karaf system bundles,
- * given the karaf system properties and the location of the startup bundles config file.
- *
- * @param sysProps karaf system properties
- * @param startupProperties the URL to load the system bundles from
- * @return an array of pax-exam options for provisioning karaf system bundles
- */
- public static Option[] getDefaultProvisioningOptions(Properties sysProps, URL startupProperties) {
- Properties startupProps = loadProperties(startupProperties);
- // Perform variable substitution for system properties.
- for (Enumeration e = startupProps.propertyNames(); e.hasMoreElements();) {
- String name = (String) e.nextElement();
- startupProps.setProperty(name, substVars(startupProps.getProperty(name), name, null, sysProps));
- }
- // Transform to sys props options
- List<Option> options = new ArrayList<Option>();
- options.add(bootClasspathLibrary(mavenBundle("org.apache.felix.karaf.jaas", "org.apache.felix.karaf.jaas.boot")).afterFramework());
- options.add(bootClasspathLibrary(mavenBundle("org.apache.felix.karaf", "org.apache.felix.karaf.main")).afterFramework());
- for (Enumeration e = startupProps.propertyNames(); e.hasMoreElements();) {
- String name = (String) e.nextElement();
- String value = startupProps.getProperty(name);
- MavenArtifactProvisionOption opt = convertToMaven(name);
- if (opt.getURL().contains("org.apache.felix.karaf.features")) {
- opt.noStart();
- }
- opt.startLevel(Integer.parseInt(value));
- options.add(opt);
- }
- options.add(mavenBundle("org.apache.felix.karaf.tooling", "org.apache.felix.karaf.tooling.testing"));
- options.add(wrappedBundle(maven("org.ops4j.pax.exam", "pax-exam-container-default")));
- // We need to add pax-exam-junit here when running with the ibm
- // jdk to avoid the following exception during the test run:
- // ClassNotFoundException: org.ops4j.pax.exam.junit.Configuration
- if ("IBM Corporation".equals(System.getProperty("java.vendor"))) {
- options.add(wrappedBundle(maven("org.ops4j.pax.exam", "pax-exam-junit")));
- }
- return options.toArray(new Option[options.size()]);
- }
-
- /**
- * Return an array of options for setting up a pax-exam test environment for karaf.
- *
- * @return an array of pax-exam options
- */
- public static Option[] getDefaultOptions() {
- return getDefaultOptions(null);
- }
-
- /**
- * Return an array of options for setting up a pax-exam test environment for karaf.
- *
- * @param sysOptions test-specific system property options
- * @return an array of pax-exam options
- */
- public static Option[] getDefaultOptions(SystemPropertyOption... sysOptions) {
- return combine(getDefaultConfigOptions(sysOptions), getDefaultProvisioningOptions());
- }
-
- /**
- * Retrieve the pax-exam option for provisioning the given maven bundle.
- *
- * @param options the list of pax-exam options
- * @param groupId the maven group id
- * @param artifactId the maven artifact id
- * @return the pax-exam provisioning option for the bundle or <code>null</code> if not found
- */
- public static MavenArtifactProvisionOption findMaven(Option[] options, String groupId, String artifactId) {
- for (Option option : options) {
- if (option instanceof MavenArtifactProvisionOption) {
- MavenArtifactProvisionOption mvn = (MavenArtifactProvisionOption) option;
- if (mvn.getURL().startsWith("mvn:" + groupId + "/" + artifactId + "/")) {
- return mvn;
- }
- }
- }
- return null;
- }
-
- private static Properties loadProperties(URL location) {
- try {
- Properties props = new Properties();
- InputStream is = location.openStream();
- try {
- props.load(is);
- } finally {
- is.close();
- }
- return props;
- } catch (IOException e) {
- throw new RuntimeException("Unable to load properties from " + location, e);
- }
- }
-
- private static URL getResource(String location) {
- URL url = null;
- if (Thread.currentThread().getContextClassLoader() != null) {
- url = Thread.currentThread().getContextClassLoader().getResource(location);
- }
- if (url == null) {
- url = Helper.class.getResource(location);
- }
- if (url == null) {
- throw new RuntimeException("Unable to find resource " + location);
- }
- return url;
- }
-
- private static final String DELIM_START = "${";
- private static final String DELIM_STOP = "}";
-
- /**
- * <p>
- * This method performs property variable substitution on the
- * specified value. If the specified value contains the syntax
- * <tt>${<prop-name>}</tt>, where <tt><prop-name></tt>
- * refers to either a configuration property or a system property,
- * then the corresponding property value is substituted for the variable
- * placeholder. Multiple variable placeholders may exist in the
- * specified value as well as nested variable placeholders, which
- * are substituted from inner most to outer most. Configuration
- * properties override system properties.
- * </p>
- *
- * @param val The string on which to perform property substitution.
- * @param currentKey The key of the property being evaluated used to
- * detect cycles.
- * @param cycleMap Map of variable references used to detect nested cycles.
- * @param configProps Set of configuration properties.
- * @return The value of the specified string after system property substitution.
- * @throws IllegalArgumentException If there was a syntax error in the
- * property placeholder syntax or a recursive variable reference.
- */
- private static String substVars(String val, String currentKey,
- Map<String, String> cycleMap, Properties configProps)
- throws IllegalArgumentException {
- // If there is currently no cycle map, then create
- // one for detecting cycles for this invocation.
- if (cycleMap == null) {
- cycleMap = new HashMap<String, String>();
- }
-
- // Put the current key in the cycle map.
- cycleMap.put(currentKey, currentKey);
-
- // Assume we have a value that is something like:
- // "leading ${foo.${bar}} middle ${baz} trailing"
-
- // Find the first ending '}' variable delimiter, which
- // will correspond to the first deepest nested variable
- // placeholder.
- int stopDelim = val.indexOf(DELIM_STOP);
-
- // Find the matching starting "${" variable delimiter
- // by looping until we find a start delimiter that is
- // greater than the stop delimiter we have found.
- int startDelim = val.indexOf(DELIM_START);
- while (stopDelim >= 0) {
- int idx = val.indexOf(DELIM_START, startDelim + DELIM_START.length());
- if ((idx < 0) || (idx > stopDelim)) {
- break;
- } else if (idx < stopDelim) {
- startDelim = idx;
- }
- }
-
- // If we do not have a start or stop delimiter, then just
- // return the existing value.
- if ((startDelim < 0) && (stopDelim < 0)) {
- return val;
- }
- // At this point, we found a stop delimiter without a start,
- // so throw an exception.
- else if (((startDelim < 0) || (startDelim > stopDelim))
- && (stopDelim >= 0)) {
- throw new IllegalArgumentException(
- "stop delimiter with no start delimiter: "
- + val);
- }
-
- // At this point, we have found a variable placeholder so
- // we must perform a variable substitution on it.
- // Using the start and stop delimiter indices, extract
- // the first, deepest nested variable placeholder.
- String variable =
- val.substring(startDelim + DELIM_START.length(), stopDelim);
-
- // Verify that this is not a recursive variable reference.
- if (cycleMap.get(variable) != null) {
- throw new IllegalArgumentException(
- "recursive variable reference: " + variable);
- }
-
- // Get the value of the deepest nested variable placeholder.
- // Try to configuration properties first.
- String substValue = (configProps != null)
- ? configProps.getProperty(variable, null)
- : null;
- if (substValue == null) {
- // Ignore unknown property values.
- substValue = System.getProperty(variable, "");
- }
-
- // Remove the found variable from the cycle map, since
- // it may appear more than once in the value and we don't
- // want such situations to appear as a recursive reference.
- cycleMap.remove(variable);
-
- // Append the leading characters, the substituted value of
- // the variable, and the trailing characters to get the new
- // value.
- val = val.substring(0, startDelim)
- + substValue
- + val.substring(stopDelim + DELIM_STOP.length(), val.length());
-
- // Now perform substitution again, since there could still
- // be substitutions to make.
- val = substVars(val, currentKey, cycleMap, configProps);
-
- // Return the value.
- return val;
- }
-
- private static MavenArtifactProvisionOption convertToMaven(String location) {
- String[] p = location.split("/");
- if (p.length >= 4 && p[p.length-1].startsWith(p[p.length-3] + "-" + p[p.length-2])) {
- MavenArtifactProvisionOption opt = new MavenArtifactProvisionOption();
- int artifactIdVersionLength = p[p.length-3].length() + 1 + p[p.length-2].length(); // (artifactId + "-" + version).length
- if (p[p.length-1].charAt(artifactIdVersionLength) == '-') {
- opt.classifier((p[p.length-1].substring(artifactIdVersionLength + 1, p[p.length-1].lastIndexOf('.'))));
- }
- StringBuffer sb = new StringBuffer();
- for (int j = 0; j < p.length - 3; j++) {
- if (j > 0) {
- sb.append('.');
- }
- sb.append(p[j]);
- }
- opt.groupId(sb.toString());
- opt.artifactId(p[p.length-3]);
- opt.version(p[p.length-2]);
- opt.type(p[p.length-1].substring(p[p.length-1].lastIndexOf('.') + 1));
- return opt;
- } else {
- throw new IllegalArgumentException("Unable to extract maven information from " + location);
- }
- }
-
-
- private static String align(String value) {
- return value != null ? value.replaceAll("\r", "").replaceAll("\n", "").replaceAll(" ", "") : "";
- }
-
-}
diff --git a/karaf/webconsole/admin/NOTICE b/karaf/webconsole/admin/NOTICE
deleted file mode 100644
index 4493c5b..0000000
--- a/karaf/webconsole/admin/NOTICE
+++ /dev/null
@@ -1,25 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-This product includes software from http://www.json.org.
-Copyright (c) 2002 JSON.org
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
-- JSON License
diff --git a/karaf/webconsole/admin/pom.xml b/karaf/webconsole/admin/pom.xml
deleted file mode 100644
index c4107ef..0000000
--- a/karaf/webconsole/admin/pom.xml
+++ /dev/null
@@ -1,110 +0,0 @@
-<?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/maven-v4_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.felix.karaf.webconsole</groupId>
- <artifactId>webconsole</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.webconsole</groupId>
- <artifactId>org.apache.felix.karaf.webconsole.admin</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Web Console :: Admin Plugin</name>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.webconsole</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.admin</groupId>
- <artifactId>org.apache.felix.karaf.admin.core</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>20070829</version>
- <scope>compile</scope>
- <optional>true</optional>
- </dependency>
-
- <!-- Only needed while running the unit tests -->
- <dependency>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- <version>${commons.logging.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Import-Package>!${project.artifactId}*,*</Import-Package>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Embed-Dependency>
- <!-- Required for JSON data transfer -->
- <!-- TODO: this needs to be put in a common place for reuse. -->
- json
- </Embed-Dependency>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git a/karaf/webconsole/admin/src/main/java/org/apache/felix/karaf/webconsole/admin/AdminPlugin.java b/karaf/webconsole/admin/src/main/java/org/apache/felix/karaf/webconsole/admin/AdminPlugin.java
deleted file mode 100644
index db54122..0000000
--- a/karaf/webconsole/admin/src/main/java/org/apache/felix/karaf/webconsole/admin/AdminPlugin.java
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- * Copyright 2009 Marcin.
- *
- * Licensed 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.
- * under the License.
- */
-package org.apache.felix.karaf.webconsole.admin;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.felix.karaf.admin.AdminService;
-import org.apache.felix.karaf.admin.Instance;
-import org.apache.felix.karaf.admin.InstanceSettings;
-import org.apache.felix.webconsole.AbstractWebConsolePlugin;
-import org.json.JSONException;
-import org.json.JSONWriter;
-import org.osgi.framework.BundleContext;
-
-/**
- * Felix Web Console plugin for interacting with the {@link AdminService}
- */
-public class AdminPlugin extends AbstractWebConsolePlugin {
-
- public static final String NAME = "admin";
- public static final String LABEL = "Admin";
- private String adminJs = "/admin/res/ui/admin.js";
- private BundleContext bundleContext;
- private AdminService adminService;
- private Log log = LogFactory.getLog(AdminPlugin.class);
- private ClassLoader classLoader;
-
- /**
- * Blueprint lifecycle callback methods
- */
- public void start() {
- super.activate(bundleContext);
- this.classLoader = this.getClass().getClassLoader();
- this.log.info(LABEL + " plugin activated");
- }
-
- public void stop() {
- this.log.info(LABEL + " plugin deactivated");
- super.deactivate();
- }
-
- @Override
- public String getTitle() {
- return LABEL;
- }
-
- @Override
- public String getLabel() {
- return NAME;
- }
-
- @Override
- protected void renderContent(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
- final PrintWriter pw = res.getWriter();
-
- String appRoot = (String) req.getAttribute("org.apache.felix.webconsole.internal.servlet.OsgiManager.appRoot");
- final String adminScriptTag = "<script src='" + appRoot + this.adminJs + "' language='JavaScript'></script>";
- pw.println(adminScriptTag);
-
- pw.println("<script type='text/javascript'>");
- pw.println("// <![CDATA[");
- pw.println("var imgRoot = '" + appRoot + "/res/imgs';");
- pw.println("// ]]>");
- pw.println("</script>");
-
- pw.println("<div id='plugin_content'/>");
-
- pw.println("<script type='text/javascript'>");
- pw.println("// <![CDATA[");
- pw.print("renderAdmin( ");
- writeJSON(pw);
- pw.println(" )");
- pw.println("// ]]>");
- pw.println("</script>");
- }
-
- @Override
- protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
- boolean success = false;
-
- String action = req.getParameter("action");
- String name = req.getParameter("name");
-
- if (action == null) {
- success = true;
- } else if ("create".equals(action)) {
- int port = parsePortNumber(req.getParameter("port"));
- String location = parseString(req.getParameter("location"));
- List<String> featureURLs = parseStringList(req.getParameter("featureURLs"));
- List<String> features = parseStringList(req.getParameter("features"));
- InstanceSettings settings = new InstanceSettings(port, location, featureURLs, features);
- success = createInstance(name, settings);
- } else if ("destroy".equals(action)) {
- success = destroyInstance(name);
- } else if ("start".equals(action)) {
- String javaOpts = req.getParameter("javaOpts");
- success = startInstance(name, javaOpts);
- } else if ("stop".equals(action)) {
- success = stopInstance(name);
- }
-
- if (success) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }
- this.renderJSON(res, null);
- } else {
- super.doPost(req, res);
- }
- }
-
- /*
- * Parse the String value, returning <code>null</code> if the String is empty
- */
- private String parseString(String value) {
- if (value != null && value.trim().length() == 0) {
- value = null;
- }
- return value;
- }
-
- private List<String> parseStringList(String value) {
- List<String> list = new ArrayList<String>();
- if (value != null) {
- for (String el : value.split(",")) {
- String trimmed = el.trim();
- if (trimmed.length() == 0) {
- continue;
- }
- list.add(trimmed);
- }
- }
- return list;
- }
-
- /*
- * Parse the port number for the String given, returning 0 if the String does not represent an integer
- */
- private int parsePortNumber(String port) {
- try {
- return Integer.parseInt(port);
- } catch (NumberFormatException e) {
- return 0;
- }
- }
-
- protected URL getResource(String path) {
- path = path.substring(NAME.length() + 1);
- URL url = this.classLoader.getResource(path);
- if (url != null) {
- InputStream ins = null;
- try {
- ins = url.openStream();
- if (ins == null) {
- this.log.error("failed to open " + url);
- url = null;
- }
- } catch (IOException e) {
- this.log.error(e.getMessage(), e);
- url = null;
- } finally {
- if (ins != null) {
- try {
- ins.close();
- } catch (IOException e) {
- this.log.error(e.getMessage(), e);
- }
- }
- }
- }
- return url;
- }
-
- private void renderJSON(final HttpServletResponse response, final String feature) throws IOException {
- response.setContentType("application/json");
- response.setCharacterEncoding("UTF-8");
-
- final PrintWriter pw = response.getWriter();
- writeJSON(pw);
- }
-
- private void writeJSON(final PrintWriter pw) {
- final JSONWriter jw = new JSONWriter(pw);
- final Instance[] instances = adminService.getInstances();
- try {
- jw.object();
- jw.key("status");
- jw.value(getStatusLine());
- jw.key("instances");
- jw.array();
- for (Instance i : instances) {
- instanceInfo(jw, i);
- }
- jw.endArray();
- jw.endObject();
- } catch (JSONException ex) {
- Logger.getLogger(AdminPlugin.class.getName()).log(Level.SEVERE, null, ex);
- } catch (Exception ex) {
- Logger.getLogger(AdminPlugin.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
-
- private void instanceInfo(JSONWriter jw, Instance instance) throws JSONException, Exception {
- jw.object();
- jw.key("pid");
- jw.value(instance.getPid());
- jw.key("name");
- jw.value(instance.getName());
- jw.key("port");
- jw.value(instance.getPort());
- jw.key("state");
- jw.value(instance.getState());
- jw.key("location");
- jw.value(instance.getLocation());
- jw.key("actions");
- jw.array();
- action(jw, "destroy", "Destroy", "delete");
- if (instance.getState().equals(Instance.STARTED)) {
- action(jw, "stop", "Stop", "stop");
- } else if (instance.getState().equals(Instance.STARTING)) {
- action(jw, "stop", "Stop", "stop");
- } else if (instance.getState().equals(Instance.STOPPED)) {
- action(jw, "start", "Start", "start");
- }
- jw.endArray();
- jw.endObject();
- }
-
- private void action(JSONWriter jw, String op, String title, String image) throws JSONException {
- jw.object();
- jw.key("op").value(op);
- jw.key("title").value(title);
- jw.key("image").value(image);
- jw.endObject();
- }
-
- private String getStatusLine() {
- final Instance[] instances = adminService.getInstances();
- int started = 0, starting = 0, stopped = 0;
- for (Instance instance : instances) {
- try {
- if (instance.getState().equals(Instance.STARTED)) {
- started++;
- } else if (instance.getState().equals(Instance.STARTING)) {
- starting++;
- } else if (instance.getState().equals(Instance.STOPPED)) {
- stopped++;
- }
- } catch (Exception ex) {
- Logger.getLogger(AdminPlugin.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- final StringBuffer buffer = new StringBuffer();
- buffer.append("Instance information: ");
- buffer.append(instances.length);
- buffer.append(" instance");
- if (instances.length != 1) {
- buffer.append('s');
- }
- buffer.append(" in total");
- if (started == instances.length) {
- buffer.append(" - all started");
- } else {
- if (started != 0) {
- buffer.append(", ");
- buffer.append(started);
- buffer.append(" started");
- }
- if (starting != 0) {
- buffer.append(", ");
- buffer.append(starting);
- buffer.append(" starting");
- }
- buffer.append('.');
- }
- return buffer.toString();
- }
-
- private boolean createInstance(String name, InstanceSettings settings) {
- try {
- adminService.createInstance(name, settings);
- return true;
- } catch (Exception ex) {
- Logger.getLogger(AdminPlugin.class.getName()).log(Level.SEVERE, null, ex);
- }
- return false;
- }
-
- private boolean destroyInstance(String name) {
- try {
- Instance instance = adminService.getInstance(name);
- if (instance != null) {
- instance.destroy();
- return true;
- }
- } catch (Exception ex) {
- Logger.getLogger(AdminPlugin.class.getName()).log(Level.SEVERE, null, ex);
- }
- return false;
- }
-
- private boolean startInstance(String name, String javaOpts) {
- try {
- Instance instance = adminService.getInstance(name);
- if (instance != null) {
- instance.start(javaOpts);
- return true;
- }
- } catch (Exception ex) {
- Logger.getLogger(AdminPlugin.class.getName()).log(Level.SEVERE, null, ex);
- }
- return false;
- }
-
- private boolean stopInstance(String name) {
- try {
- Instance instance = adminService.getInstance(name);
- if (instance != null) {
- instance.stop();
- return true;
- }
- } catch (Exception ex) {
- Logger.getLogger(AdminPlugin.class.getName()).log(Level.SEVERE, null, ex);
- }
- return false;
- }
-
- /**
- * @param adminService the adminService to set
- */
- public void setAdminService(AdminService adminService) {
- this.adminService = adminService;
- }
-
- /**
- * @param bundleContext the bundleContext to set
- */
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-}
diff --git a/karaf/webconsole/admin/src/main/resources/OSGI-INF/blueprint/webconsole-admin.xml b/karaf/webconsole/admin/src/main/resources/OSGI-INF/blueprint/webconsole-admin.xml
deleted file mode 100644
index 696b388..0000000
--- a/karaf/webconsole/admin/src/main/resources/OSGI-INF/blueprint/webconsole-admin.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0">
-
- <reference id="adminService" interface="org.apache.felix.karaf.admin.AdminService" />
-
- <bean id="adminPlugin" class="org.apache.felix.karaf.webconsole.admin.AdminPlugin" init-method="start" destroy-method="stop">
- <property name="adminService" ref="adminService" />
- <property name="bundleContext" ref="blueprintBundleContext" />
- </bean>
-
- <service ref="adminPlugin" interface="javax.servlet.Servlet" >
- <service-properties>
- <entry key="felix.webconsole.label" value="admin"/>
- </service-properties>
- </service>
-
-</blueprint>
diff --git a/karaf/webconsole/admin/src/main/resources/res/ui/admin.js b/karaf/webconsole/admin/src/main/resources/res/ui/admin.js
deleted file mode 100644
index cc48772..0000000
--- a/karaf/webconsole/admin/src/main/resources/res/ui/admin.js
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-function renderAdmin( data ) {
- $(document).ready( function() {
- renderView();
- renderData( data );
- } );
-}
-
-function renderView() {
- renderStatusLine();
- var txt = "<form method='post'><div class='table'><table id='create_instance_table' class='tablelayout'><tbody>" +
- "<tr><input type='hidden' name='action' value='create'/>" +
- "<td>Name: <input id='name' type='text' name='name' style='width:70%' colspan='2'/></td>" +
- "<td>Port: <input id='port' type='text' name='port' style='width:70%' colspan='2'/></td>" +
- "<td>Location: <input id='location' type='text' name='location' style='width:70%' colspan='2'/></td>" +
- "<td />" +
- "</tr><tr><td>Features: <input id='features' type='text' name='features' style='width:70%' colspan='2'" +
- " title='Specify initial features separated by commas.'/></td>" +
- "<td colspan='2'>Feature URLs: <input id='featureURLs' type='text' name='featureURLs' style='width:80%' colspan='2'" +
- " title='Specify additional feature URLs separate by commas.'/></td>" +
- "<td class='col_Actions'><input type='button' value='Create' onclick='createInstance()'/></td>" +
- "</tr></tbody></table></div></form><br/>";
- $("#plugin_content").append( txt );
- renderTable( "Karaf Instances", "instances_table", ["Pid", "Name", "Port", "State", "Location", "Actions"] );
- renderStatusLine();
-}
-
-function createInstance() {
- var name = document.getElementById( "name" ).value;
- var port = document.getElementById( "port" ).value;
- var location = document.getElementById( "location" ).value;
- var features = document.getElementById( "features" ).value;
- var featureURLs = document.getElementById( "featureURLs" ).value;
- postCreateInstance( name, port, location, features, featureURLs );
-}
-
-function postCreateInstance( /* String */ name, /* String */ port, /* String */ location,
- /* String */ features, /* String */ featureURLs ) {
- $.post( pluginRoot, {"action": "create", "name": name, "port": port, "location": location,
- "features": features, "featureURLs": featureURLs }, function( data ) {
- renderData( data );
- }, "json" );
-}
-
-function renderStatusLine() {
- $("#plugin_content").append( "<div class='fullwidth'><div class='statusline'/></div>" );
-}
-
-function renderTable( /* String */ title, /* String */ id, /* array of Strings */ columns ) {
- var txt = "<div class='table'><table class='tablelayout'><tbody><tr>" +
- "<td style='color:#6181A9;background-color:#e6eeee'>" +
- title + "</td></tr></tbody></table>" +
- "<table id='" + id + "' class='tablelayout'><thead><tr>";
- for ( var name in columns ) {
- txt = txt + "<th class='col_" + columns[name] + "' style='border-top:#e6eeee'>" + columns[name] + "</th>";
- }
- txt = txt + "</tr></thead><tbody></tbody></table></div>";
- $("#plugin_content").append( txt );
-}
-
-function renderData( /* Object */ data ) {
- renderStatusData( data.status );
- renderInstancesTableData( data.instances );
- $("#instances_table").tablesorter( {
- headers: {
- 5: {
- sorter: false
- }
- },
- sortList: [[0,0]],
- } );
-}
-
-function renderStatusData( /* String */ status ) {
- $(".statusline").empty().append( status );
-}
-
-function renderInstancesTableData( /* array of Objects */ instances ) {
- $("#instances_table > tbody > tr").remove();
- for ( var idx in instances ) {
- var trElement = tr( null, {
- id: instances[idx].pid
- } );
- renderInstanceData( trElement, instances[idx] );
- $("#instances_table > tbody").append( trElement );
- }
- $("#instances_table").trigger( "update" );
-}
-
-function renderInstanceData( /* Element */ parent, /* Object */ instance ) {
- parent.appendChild( td( null, null, [ text( instance.pid ) ] ) );
- parent.appendChild( td( null, null, [ text( instance.name ) ] ) );
- parent.appendChild( td( null, null, [ text( instance.port ) ] ) );
- parent.appendChild( td( null, null, [ text( instance.state ) ] ) );
- parent.appendChild( td( null, null, [ text( instance.location ) ] ) );
- var actionsTd = td( null, null );
- var div = createElement( "div", null, {
- style: {
- "text-align": "left"
- }
- } );
- actionsTd.appendChild( div );
-
- for ( var a in instance.actions ) {
- instanceButton( div, instance.name, instance.actions[a] );
- }
- parent.appendChild( actionsTd );
-}
-
-function instanceButton( /* Element */ parent, /* String */ name, /* Obj */ action ) {
- var input = createElement( "input", null, {
- type: 'image',
- style: {
- "margin-left": "10px"
- },
- title: action.title,
- alt: action.title,
- src: imgRoot + '/bundle_' + action.image + '.png'
- } );
- $(input).click( function() {
- changeInstanceState( action.op, name )
- } );
- parent.appendChild( input );
-}
-
-function changeInstanceState( /* String */ action, /* String */ name) {
- $.post( pluginRoot, {
- "action": action,
- "name": name
- }, function( data ) {
- renderData( data );
- }, "json" );
-}
-
-
diff --git a/karaf/webconsole/admin/src/test/java/org/apache/felix/karaf/webconsole/admin/AdminPluginTest.java b/karaf/webconsole/admin/src/test/java/org/apache/felix/karaf/webconsole/admin/AdminPluginTest.java
deleted file mode 100644
index 7bf25a2..0000000
--- a/karaf/webconsole/admin/src/test/java/org/apache/felix/karaf/webconsole/admin/AdminPluginTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.webconsole.admin;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintWriter;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import junit.framework.TestCase;
-
-import org.apache.felix.karaf.admin.AdminService;
-import org.apache.felix.karaf.admin.Instance;
-import org.apache.felix.karaf.admin.InstanceSettings;
-import org.easymock.EasyMock;
-import org.easymock.IAnswer;
-
-public class AdminPluginTest extends TestCase {
- public void testParseStringList() throws Exception {
- assertEquals(Arrays.asList("a", "b"), testParseStringList(" a ,b"));
- assertEquals(Collections.emptyList(), testParseStringList(null));
- assertEquals(Arrays.asList("hello"), testParseStringList("hello"));
- assertEquals(Arrays.asList("b"), testParseStringList(",b,"));
- }
-
- @SuppressWarnings("unchecked")
- private List<String> testParseStringList(String s) throws Exception {
- AdminPlugin ap = new AdminPlugin();
- Method m = ap.getClass().getDeclaredMethod("parseStringList", new Class [] {String.class});
- m.setAccessible(true);
- return (List<String>) m.invoke(ap, s);
- }
-
- public void testDoPostCreate() throws Exception {
- InstanceSettings is =
- new InstanceSettings(1234, null, Collections.singletonList("http://someURL"), Arrays.asList("abc", "def"));
- AdminService adminService = EasyMock.createMock(AdminService.class);
- EasyMock.expect(adminService.createInstance("instance1", is)).andReturn(null);
- EasyMock.expect(adminService.getInstances()).andReturn(new Instance[] {}).anyTimes();
- EasyMock.replay(adminService);
-
- AdminPlugin ap = new AdminPlugin();
- ap.setAdminService(adminService);
-
- final Map<String, String> params = new HashMap<String, String>();
- params.put("action", "create");
- params.put("name", "instance1");
- params.put("port", "1234");
- params.put("featureURLs", "http://someURL");
- params.put("features", "abc,def");
- HttpServletRequest req = EasyMock.createMock(HttpServletRequest.class);
- EasyMock.expect(req.getParameter((String) EasyMock.anyObject())).andAnswer(new IAnswer<String>() {
- public String answer() throws Throwable {
- return params.get(EasyMock.getCurrentArguments()[0]);
- }
- }).anyTimes();
-
- HttpServletResponse res = EasyMock.createNiceMock(HttpServletResponse.class);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintWriter pw = new PrintWriter(baos);
- EasyMock.expect(res.getWriter()).andReturn(pw);
-
- EasyMock.replay(req);
- EasyMock.replay(res);
- ap.doPost(req, res);
- EasyMock.verify(adminService);
-
- // Check that the operation has succeeded. This will cause some information to be written to
- // the outputstream...
- pw.flush();
- String s = new String(baos.toByteArray());
- assertTrue(s.contains("instance"));
- }
-}
diff --git a/karaf/webconsole/branding/NOTICE b/karaf/webconsole/branding/NOTICE
deleted file mode 100644
index a2d6256..0000000
--- a/karaf/webconsole/branding/NOTICE
+++ /dev/null
@@ -1,21 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
diff --git a/karaf/webconsole/branding/pom.xml b/karaf/webconsole/branding/pom.xml
deleted file mode 100644
index cb3b650..0000000
--- a/karaf/webconsole/branding/pom.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-<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/maven-v4_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.felix.karaf.webconsole</groupId>
- <artifactId>webconsole</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.webconsole</groupId>
- <artifactId>org.apache.felix.karaf.webconsole.branding</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Web Console :: Branding</name>
-
- <description>Apache Felix Karaf branding for the Apache Felix Web Console. This fragment
- attaches to the org.apache.felix.webconsole bundle to provide branding
- through the /META-INF/webconsole.properties.
- </description>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.webconsole</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>${felix.plugin.version}</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Bundle-DocURL>http://felix.apache.org/site/apache-felix-karaf.html</Bundle-DocURL>
- <Fragment-Host>org.apache.felix.webconsole;bundle-version="[3,4)"</Fragment-Host>
- <Export-Package>!*</Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-
-</project>
\ No newline at end of file
diff --git a/karaf/webconsole/branding/src/main/java/org/apache/felix/karaf/webconsole/JaasSecurityProvider.java b/karaf/webconsole/branding/src/main/java/org/apache/felix/karaf/webconsole/JaasSecurityProvider.java
deleted file mode 100644
index b2a37ba..0000000
--- a/karaf/webconsole/branding/src/main/java/org/apache/felix/karaf/webconsole/JaasSecurityProvider.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.webconsole;
-
-import java.io.IOException;
-import javax.security.auth.Subject;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.NameCallback;
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.auth.login.LoginContext;
-
-import org.apache.felix.webconsole.WebConsoleSecurityProvider;
-
-public class JaasSecurityProvider implements WebConsoleSecurityProvider {
-
- private String realm;
-
- public String getRealm() {
- return realm;
- }
-
- public void setRealm(String realm) {
- this.realm = realm;
- }
-
- public Object authenticate(final String username, final String password) {
- try {
- Subject subject = new Subject();
- LoginContext loginContext = new LoginContext(realm, subject, new CallbackHandler() {
- public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
- for (int i = 0; i < callbacks.length; i++) {
- if (callbacks[i] instanceof NameCallback) {
- ((NameCallback) callbacks[i]).setName(username);
- } else if (callbacks[i] instanceof PasswordCallback) {
- ((PasswordCallback) callbacks[i]).setPassword(password.toCharArray());
- } else {
- throw new UnsupportedCallbackException(callbacks[i]);
- }
- }
- }
- });
- loginContext.login();
- return subject;
- } catch (Exception e) {
- return null;
- }
- }
-
- public boolean authorize(Object o, String s) {
- return true;
- }
-}
diff --git a/karaf/webconsole/branding/src/main/resources/META-INF/webconsole.properties b/karaf/webconsole/branding/src/main/resources/META-INF/webconsole.properties
deleted file mode 100644
index a742b7d..0000000
--- a/karaf/webconsole/branding/src/main/resources/META-INF/webconsole.properties
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-
-#
-# This file contains branding properties to overwrite the default
-# branding of the Apache Felix Web Console when deployed in an
-# Apache Felix Karaf application.
-
-webconsole.product.name = Apache Felix Karaf
-webconsole.product.url = http://felix.apache.org/site/apache-felix-karaf.html
-webconsole.product.image = /res/karaf/imgs/logo.png
-
-webconsole.vendor.name = The Apache Software Foundation
-webconsole.vendor.url = http://www.apache.org
-webconsole.vendor.image = /res/karaf/imgs/logo.png
-
-webconsole.favicon = /res/karaf/imgs/favicon.ico
-webconsole.stylesheet = /res/karaf/ui/webconsole.css
diff --git a/karaf/webconsole/branding/src/main/resources/OSGI-INF/blueprint/webconsole.xml b/karaf/webconsole/branding/src/main/resources/OSGI-INF/blueprint/webconsole.xml
deleted file mode 100644
index 4bdbc87..0000000
--- a/karaf/webconsole/branding/src/main/resources/OSGI-INF/blueprint/webconsole.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
- xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
- default-activation="lazy">
-
- <ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"/>
-
- <cm:property-placeholder persistent-id="org.apache.felix.karaf.webconsole">
- <cm:default-properties>
- <cm:property name="realm" value="karaf"/>
- </cm:default-properties>
- </cm:property-placeholder>
-
- <bean id="securityProvider" class="org.apache.felix.karaf.webconsole.JaasSecurityProvider">
- <property name="realm" value="${realm}"/>
- </bean>
-
- <service auto-export="interfaces" ref="securityProvider" />
-
-</blueprint>
diff --git a/karaf/webconsole/branding/src/main/resources/OSGI-INF/metatype/metatype.properties b/karaf/webconsole/branding/src/main/resources/OSGI-INF/metatype/metatype.properties
deleted file mode 100644
index 9f27442..0000000
--- a/karaf/webconsole/branding/src/main/resources/OSGI-INF/metatype/metatype.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-#
-# This file contains localization strings for configuration labels and
-# descriptions as used in the metatype.xml descriptor
-
-webconsole.name = Apache Felix Karaf WebConsole
-webconsole.description = Configuration of Apache Felix Karaf WebConsole
-
-realm.name = Realm
-realm.description = The JAAS realm name to use for authentication
diff --git a/karaf/webconsole/branding/src/main/resources/OSGI-INF/metatype/metatype.xml b/karaf/webconsole/branding/src/main/resources/OSGI-INF/metatype/metatype.xml
deleted file mode 100644
index 2e0a845..0000000
--- a/karaf/webconsole/branding/src/main/resources/OSGI-INF/metatype/metatype.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0" localization="OSGI-INF/metatype/metatype">
- <OCD id="org.apache.felix.karaf.webconsole" name="%webconsole.name" description="%webconsole.description">
- <AD id="realm" type="String" default="karaf" name="%realm.name" description="%realm.description"/>
- </OCD>
- <Designate pid="org.apache.felix.karaf.webconsole">
- <Object ocdref="org.apache.felix.karaf.webconsole"/>
- </Designate>
-</metatype:MetaData>
diff --git a/karaf/webconsole/branding/src/main/resources/res/karaf/imgs/favicon.ico b/karaf/webconsole/branding/src/main/resources/res/karaf/imgs/favicon.ico
deleted file mode 100644
index c37dbe8..0000000
--- a/karaf/webconsole/branding/src/main/resources/res/karaf/imgs/favicon.ico
+++ /dev/null
Binary files differ
diff --git a/karaf/webconsole/branding/src/main/resources/res/karaf/imgs/logo.png b/karaf/webconsole/branding/src/main/resources/res/karaf/imgs/logo.png
deleted file mode 100644
index bd24038..0000000
--- a/karaf/webconsole/branding/src/main/resources/res/karaf/imgs/logo.png
+++ /dev/null
Binary files differ
diff --git a/karaf/webconsole/branding/src/main/resources/res/karaf/ui/webconsole.css b/karaf/webconsole/branding/src/main/resources/res/karaf/ui/webconsole.css
deleted file mode 100644
index ea9b12f..0000000
--- a/karaf/webconsole/branding/src/main/resources/res/karaf/ui/webconsole.css
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * The webconsole.css is the main CSS which sets up the following parts
- *
- * div main -> outermost div just inside body
- * div lead -> the page lead with title and logo
- * div technav -> the top navigation
- * div content -> the div surrounding the content being rendered by
- * the plugin in the renderContent (or service) method
- *
- * See also http://felix.apache.org/site/branding-the-web-console.html
- */
-#main {
- width: 90% !important;
- margin-left: 5%;
-}
-#main img { border: none }
-
-
-/* LOGO & BRANDING */
-#lead {
- padding-top: 10px;
- margin: 0;
- height: 73px; /* must be the same as logo (#lead p) height */
-}
-#lead h1 { /* This contains the page title */
- font-size: 26px;
- font-weight: bold;
- float: left;
-}
-#lead p { /* This contains the logo */
- float: right;
- height: 73px; /* must be the same as #lead height */
-}
-
-
-/* TOP NAVIGATION */
-#technav {
- font-size: 10px;
- line-height: 21px;
- padding: 0;
- margin: 0;
-}
-#technav div {
- display: inline;
- padding: .2em 1em;
- white-space: nowrap;
-}
-
-/* CENTRAL CONTENT AREA STYLING */
-#content {
- font-size: 8pt;
-}
-
-/* used in some plugins - showing ID (long) element in tables */
-.col_Id {
- width: 5em;
-}
-
-/* styling button groups like in the bundles & log plugins */
-.buttonGroup {
- text-align: right;
- padding: .5em 1em .5em 0;
- vertical-align: middle;
-}
-.buttonGroup select {
- display: inline;
- float: none;
- margin: 0;
-}
-
-/* The following styles are not complete. They usually apply only padding,
- * margin... mostly *WHERE* the elements are visualised. Visual styling like
- * colors and fonts are applied automatically by a JavaScript that borrows
- * the visual element styles from the JQuery UI theme
- */
-
-/* input box, checkbox & buttons styling */
-.inputText, input.text, input.password, input.file, textarea, select {
- color: #184054;
- background-color: #f0f0f0;
-}
-.inputText, input.text, input.password, textarea {
- border: 1px solid #999999;
- border-bottom: 1px solid #cccccc;
- border-right: 1px solid #cccccc;
-}
-
-/* tables styling - must be in synch with tablesorter CSS */
-td, th { vertical-align: top }
-table.nicetable {
- width: 100%;
- text-align: left;
-}
-table.nicetable th, table.nicetable td {
- border-bottom: 1px solid #cccccc;
- text-align: left;
- padding: .2em;
- padding-left: .8em;
-}
-
-/* tablesorter styling */
-tr .header {
- background-image: url(../lib/bg.gif);
- background-repeat: no-repeat;
- background-position: center right;
- cursor: pointer;
-}
-tr .headerSortUp {
- background-image: url(../lib/asc.gif);
-}
-tr .headerSortDown {
- background-image: url(../lib/desc.gif);
-}
-
-/* status line */
-.statline {
- margin-top: .5em !important;
- margin-bottom: .5em !important;
- padding: .2em;
-}
-
-/* zebra tables */
-.even {
- /* default background unmodified from JQuery UI Theme */
-}
-
-.odd {
- /* overwrite background from JQuery UI Theme */
- background: none !important;
-}
-
-/*
- * Common UI style to define button icons like in bundles plugin. The HTML markup is:
- * <ul class="icons ui-widget">
- * <li class="dynhover" title="tooltip comes here"><span class="ui-icon ui-icon-refresh"> </span></li>
- * </ul>
- */
-ul.icons {
- margin: 0;
- padding: 0
-}
-ul.icons span.ui-icon {
- float: left;
- margin: 0 1px
-}
-ul.icons li {
- margin: 1px;
- position: relative;
- padding: 1px 0;
- cursor: pointer;
- float: left;
- list-style: none
-}
diff --git a/karaf/webconsole/features/NOTICE b/karaf/webconsole/features/NOTICE
deleted file mode 100644
index 4493c5b..0000000
--- a/karaf/webconsole/features/NOTICE
+++ /dev/null
@@ -1,25 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-This product includes software from http://www.json.org.
-Copyright (c) 2002 JSON.org
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
-- JSON License
diff --git a/karaf/webconsole/features/pom.xml b/karaf/webconsole/features/pom.xml
deleted file mode 100644
index 8c43abe..0000000
--- a/karaf/webconsole/features/pom.xml
+++ /dev/null
@@ -1,105 +0,0 @@
-<?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/maven-v4_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.felix.karaf.webconsole</groupId>
- <artifactId>webconsole</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.webconsole</groupId>
- <artifactId>org.apache.felix.karaf.webconsole.features</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Web Console :: Features Plugin</name>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.webconsole</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.features</groupId>
- <artifactId>org.apache.felix.karaf.features.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>20070829</version>
- <scope>compile</scope>
- <optional>true</optional>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Import-Package>!${project.artifactId}*,*</Import-Package>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Embed-Dependency>
- <!-- Required for JSON data transfer -->
- <!-- TODO: this needs to be put in a common place for reuse. -->
- json
- </Embed-Dependency>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git a/karaf/webconsole/features/src/main/java/org/apache/felix/karaf/webconsole/features/ExtendedFeature.java b/karaf/webconsole/features/src/main/java/org/apache/felix/karaf/webconsole/features/ExtendedFeature.java
deleted file mode 100644
index 3cac3a4..0000000
--- a/karaf/webconsole/features/src/main/java/org/apache/felix/karaf/webconsole/features/ExtendedFeature.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.webconsole.features;
-
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.felix.karaf.features.Feature;
-
-
-/**
- *
- */
-public class ExtendedFeature implements Feature
-{
-
- public enum State
- {
- INSTALLED, UNINSTALLED;
-
- @Override
- public String toString()
- {
- //only capitalize the first letter
- String s = super.toString();
- return s.substring( 0, 1 ) + s.substring( 1 ).toLowerCase();
- }
- };
-
- protected State state;
- protected String repository;
- protected Feature feature;
-
-
- //
- // Constructors
- //
-
- public ExtendedFeature( State state, String repository, Feature feature )
- {
- this.state = state;
- this.repository = repository;
- this.feature = feature;
- }
-
-
- //
- // Feature interface
- //
-
-
- public List<String> getBundles()
- {
- return this.feature.getBundles();
- }
-
-
- public Map<String, Map<String, String>> getConfigurations()
- {
- return this.feature.getConfigurations();
- }
-
-
- public List<Feature> getDependencies()
- {
- return this.feature.getDependencies();
- }
-
-
- public String getId()
- {
- return this.feature.getId();
- }
-
-
- public String getName()
- {
- return this.feature.getName();
- }
-
-
- public String getVersion()
- {
- return this.feature.getVersion();
- }
-
-
- //
- // Additional methods
- //
-
-
- public String getRepository() {
- return this.repository;
- }
-
-
- public State getState() {
- return this.state;
- }
-}
diff --git a/karaf/webconsole/features/src/main/java/org/apache/felix/karaf/webconsole/features/FeaturesPlugin.java b/karaf/webconsole/features/src/main/java/org/apache/felix/karaf/webconsole/features/FeaturesPlugin.java
deleted file mode 100644
index a68f44f..0000000
--- a/karaf/webconsole/features/src/main/java/org/apache/felix/karaf/webconsole/features/FeaturesPlugin.java
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.webconsole.features;
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.net.URI;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.felix.karaf.features.Feature;
-import org.apache.felix.karaf.features.FeaturesService;
-import org.apache.felix.karaf.features.Repository;
-import org.apache.felix.webconsole.AbstractWebConsolePlugin;
-import org.json.JSONException;
-import org.json.JSONWriter;
-import org.osgi.framework.BundleContext;
-
-
-/**
- * The <code>FeaturesPlugin</code>
- */
-public class FeaturesPlugin extends AbstractWebConsolePlugin
-{
-
- /** Pseudo class version ID to keep the IDE quite. */
- private static final long serialVersionUID = 1L;
-
- public static final String NAME = "features";
-
- public static final String LABEL = "Features";
-
- private Log log = LogFactory.getLog(FeaturesPlugin.class);
-
- private ClassLoader classLoader;
-
- private String featuresJs = "/features/res/ui/features.js";
-
- private FeaturesService featuresService;
-
- private BundleContext bundleContext;
-
-
- //
- // Blueprint lifecycle callback methods
- //
-
- public void start()
- {
- super.activate( bundleContext );
-
- this.classLoader = this.getClass().getClassLoader();
-
- this.log.info( LABEL + " plugin activated" );
- }
-
-
- public void stop()
- {
- this.log.info( LABEL + " plugin deactivated" );
- super.deactivate();
- }
-
-
- //
- // AbstractWebConsolePlugin interface
- //
-
- public String getLabel()
- {
- return NAME;
- }
-
-
- public String getTitle()
- {
- return LABEL;
- }
-
-
- protected void doPost( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException
- {
- boolean success = false;
-
- final String action = req.getParameter( "action" );
- final String feature = req.getParameter( "feature" );
- final String version = req.getParameter( "version" );
- final String url = req.getParameter( "url" );
-
- if ( action == null )
- {
- success = true;
- }
- else if ( "installFeature".equals( action ) )
- {
- success = this.installFeature(feature, version);
- }
- else if ( "uninstallFeature".equals( action ) )
- {
- success = this.uninstallFeature( feature, version );
- }
- else if ( "refreshRepository".equals( action ) )
- {
- success = this.refreshRepository( url );
- }
- else if ( "removeRepository".equals( action ) )
- {
- success = this.removeRepository( url );
- }
- else if ( "addRepository".equals( action ) )
- {
- success = this.addRepository( url );
- }
-
- if ( success )
- {
- // let's wait a little bit to give the framework time
- // to process our request
- try
- {
- Thread.sleep( 800 );
- }
- catch ( InterruptedException e )
- {
- // we ignore this
- }
- this.renderJSON( resp, null );
- }
- else
- {
- super.doPost( req, resp );
- }
- }
-
-
- protected void renderContent( HttpServletRequest request, HttpServletResponse response ) throws IOException
- {
-
- // get request info from request attribute
- final PrintWriter pw = response.getWriter();
-
- String appRoot = ( String ) request
- .getAttribute( "org.apache.felix.webconsole.internal.servlet.OsgiManager.appRoot" );
- final String featuresScriptTag = "<script src='" + appRoot + this.featuresJs
- + "' language='JavaScript'></script>";
- pw.println( featuresScriptTag );
-
- pw.println( "<script type='text/javascript'>" );
- pw.println( "// <![CDATA[" );
- pw.println( "var imgRoot = '" + appRoot + "/res/imgs';" );
- pw.println( "// ]]>" );
- pw.println( "</script>" );
-
- pw.println( "<div id='plugin_content'/>" );
-
- pw.println( "<script type='text/javascript'>" );
- pw.println( "// <![CDATA[" );
- pw.print( "renderFeatures( " );
- writeJSON( pw );
- pw.println( " )" );
- pw.println( "// ]]>" );
- pw.println( "</script>" );
- }
-
-
- //
- // Additional methods
- //
-
- protected URL getResource( String path )
- {
- path = path.substring( NAME.length() + 1 );
- URL url = this.classLoader.getResource( path );
- if (url != null) {
- InputStream ins = null;
- try {
- ins = url.openStream();
- if (ins == null) {
- this.log.error("failed to open " + url);
- url = null;
- }
- } catch (IOException e) {
- this.log.error(e.getMessage(), e);
- url = null;
- } finally {
- if (ins != null) {
- try {
- ins.close();
- } catch (IOException e) {
- this.log.error(e.getMessage(), e);
- }
- }
- }
- }
-
- return url;
- }
-
-
- private boolean installFeature(String feature, String version) {
- boolean success = false;
- if ( featuresService == null )
- {
- this.log.error( "Shell Features service is unavailable." );
- }
- try
- {
- featuresService.installFeature( feature, version );
- success = true;
- }
- catch ( Exception e )
- {
- this.log.error( "failed to install feature: ", e );
- }
- return success;
- }
-
-
- private boolean uninstallFeature(String feature, String version) {
- boolean success = false;
- if ( featuresService == null )
- {
- this.log.error( "Shell Features service is unavailable." );
- }
- try
- {
- featuresService.uninstallFeature( feature, version );
- success = true;
- }
- catch ( Exception e )
- {
- this.log.error( "failed to install feature: ", e );
- }
- return success;
- }
-
-
- private boolean removeRepository(String url) {
- boolean success = false;
- if ( featuresService == null )
- {
- this.log.error( "Shell Features service is unavailable." );
- }
- try
- {
- featuresService.removeRepository( new URI( url ) );
- success = true;
- }
- catch ( Exception e )
- {
- this.log.error( "failed to install feature: ", e );
- }
- return success;
- }
-
-
- private boolean refreshRepository(String url) {
- boolean success = false;
- if ( featuresService == null )
- {
- this.log.error( "Shell Features service is unavailable." );
- }
- try
- {
- featuresService.removeRepository( new URI( url ) );
- featuresService.addRepository( new URI( url ) );
- success = true;
- }
- catch ( Exception e )
- {
- this.log.error( "failed to install feature: ", e );
- }
- return success;
- }
-
-
- private boolean addRepository(String url) {
- boolean success = false;
- if ( featuresService == null )
- {
- this.log.error( "Shell Features service is unavailable." );
- }
- try
- {
- featuresService.addRepository( new URI( url ) );
- success = true;
- }
- catch ( Exception e )
- {
- this.log.error( "failed to install feature: ", e );
- }
- return success;
- }
-
-
- private void renderJSON( final HttpServletResponse response, final String feature ) throws IOException
- {
- response.setContentType( "application/json" );
- response.setCharacterEncoding( "UTF-8" );
-
- final PrintWriter pw = response.getWriter();
- writeJSON( pw );
- }
-
-
- private void writeJSON( final PrintWriter pw ) throws IOException
- {
- final List<Repository> repositories = this.getRepositories();
- final List<ExtendedFeature> features = this.getFeatures( repositories );
- final String statusLine = this.getStatusLine( features );
-
- final JSONWriter jw = new JSONWriter( pw );
-
- try
- {
- jw.object();
-
- jw.key( "status" );
- jw.value( statusLine );
-
- jw.key( "repositories" );
- jw.array();
- for ( Repository r : repositories )
- {
- jw.object();
- jw.key( "name" );
- jw.value( r.getName() );
- jw.key( "url" );
- String uri = r.getURI().toString();
- jw.value( uri );
- jw.key( "actions" );
- jw.array();
- boolean enable = true;
- if ( uri.startsWith( "bundle" ) ) {
- enable = false;
- }
- action( jw, enable, "refreshRepository", "Refresh", "refresh" );
- action( jw, enable, "removeRepository", "Remove", "delete" );
- jw.endArray();
- jw.endObject();
- }
- jw.endArray();
-
- jw.key( "features" );
- jw.array();
- for ( ExtendedFeature f : features )
- {
- featureInfo( jw, f );
- }
- jw.endArray();
-
- jw.endObject();
-
- }
- catch ( JSONException je )
- {
- throw new IOException( je.toString() );
- }
-
- }
-
-
- private List<Repository> getRepositories()
- {
- List<Repository> repositories = new ArrayList<Repository>();
-
- if ( featuresService == null )
- {
- this.log.error( "Shell Features service is unavailable." );
- return repositories;
- }
-
- try
- {
- for ( Repository r : featuresService.listRepositories() ) {
- repositories.add( r );
- }
- }
- catch ( Exception e )
- {
- this.log.error( e.getMessage() );
- }
-
- return repositories;
- }
-
-
- private List<ExtendedFeature> getFeatures( List<Repository> repositories )
- {
- List<ExtendedFeature> features = new ArrayList<ExtendedFeature>();
-
- if ( featuresService == null )
- {
- this.log.error( "Shell Features service is unavailable." );
- return features;
- }
-
- try
- {
- for ( Repository r : repositories )
- {
- for ( Feature f : r.getFeatures() )
- {
- ExtendedFeature.State state =
- featuresService.isInstalled(f) ? ExtendedFeature.State.INSTALLED : ExtendedFeature.State.UNINSTALLED;
- features.add( new ExtendedFeature( state, r.getName(), f ) );
- }
- }
- }
- catch ( Exception e )
- {
- this.log.error( e.getMessage() );
- }
-
- Collections.sort( features, new ExtendedFeatureComparator() );
- return features;
- }
-
-
- class ExtendedFeatureComparator implements Comparator<ExtendedFeature>
- {
- public int compare( ExtendedFeature o1, ExtendedFeature o2 )
- {
- return o1.getName().toLowerCase().compareTo( o2.getName().toLowerCase() );
- }
- }
-
-
- private String getStatusLine( final List<ExtendedFeature> features )
- {
- int installed = 0;
- for ( ExtendedFeature f : features )
- {
- if ( f.getState() == ExtendedFeature.State.INSTALLED )
- {
- installed++;
- }
- }
- final StringBuffer buffer = new StringBuffer();
- buffer.append( "Feature information: " );
- appendFeatureInfoCount( buffer, "in total", features.size() );
- if ( installed == features.size() )
- {
- buffer.append( " - all " );
- appendFeatureInfoCount( buffer, "active.", features.size() );
- }
- else
- {
- if ( installed != 0 )
- {
- buffer.append( ", " );
- appendFeatureInfoCount( buffer, "installed", installed );
- }
- buffer.append( '.' );
- }
- return buffer.toString();
- }
-
-
- private void appendFeatureInfoCount( final StringBuffer buf, String msg, int count )
- {
- buf.append( count );
- buf.append( " feature" );
- if ( count != 1 )
- buf.append( 's' );
- buf.append( ' ' );
- buf.append( msg );
- }
-
-
- private void featureInfo( JSONWriter jw, ExtendedFeature feature ) throws JSONException
- {
- jw.object();
- jw.key( "id" );
- jw.value( feature.getId() );
- jw.key( "name" );
- jw.value( feature.getName() );
- jw.key( "version" );
- jw.value( feature.getVersion() );
- jw.key( "repository" );
- jw.value( feature.getRepository() );
- jw.key( "state" );
- ExtendedFeature.State state = feature.getState();
- jw.value( state.toString() );
-
- jw.key( "actions" );
- jw.array();
-
- if ( state == ExtendedFeature.State.INSTALLED )
- {
- action( jw, true, "uninstallFeature", "Uninstall", "delete" );
- }
- else if ( state == ExtendedFeature.State.UNINSTALLED )
- {
- action( jw, true, "installFeature", "Install", "start" );
- }
- jw.endArray();
-
- jw.endObject();
- }
-
-
- private void action( JSONWriter jw, boolean enabled, String op, String title, String image ) throws JSONException
- {
- jw.object();
- jw.key( "enabled" ).value( enabled );
- jw.key( "op" ).value( op );
- jw.key( "title" ).value( title );
- jw.key( "image" ).value( image );
- jw.endObject();
- }
-
-
- //
- // Dependency Injection setters
- //
-
- public void setFeaturesService(FeaturesService featuresService)
- {
- this.featuresService = featuresService;
- }
-
-
- public void setBundleContext(BundleContext bundleContext)
- {
- this.bundleContext = bundleContext;
- }
-}
diff --git a/karaf/webconsole/features/src/main/resources/OSGI-INF/blueprint/webconsole-features.xml b/karaf/webconsole/features/src/main/resources/OSGI-INF/blueprint/webconsole-features.xml
deleted file mode 100644
index b009592..0000000
--- a/karaf/webconsole/features/src/main/resources/OSGI-INF/blueprint/webconsole-features.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0">
-
- <reference id="featuresService" interface="org.apache.felix.karaf.features.FeaturesService" />
-
- <bean id="featuresPlugin" class="org.apache.felix.karaf.webconsole.features.FeaturesPlugin" init-method="start" destroy-method="stop">
- <property name="featuresService" ref="featuresService" />
- <property name="bundleContext" ref="blueprintBundleContext" />
- </bean>
-
- <service ref="featuresPlugin" interface="javax.servlet.Servlet" >
- <service-properties>
- <entry key="felix.webconsole.label" value="features"/>
- </service-properties>
- </service>
-
-</blueprint>
diff --git a/karaf/webconsole/features/src/main/resources/res/ui/features.js b/karaf/webconsole/features/src/main/resources/res/ui/features.js
deleted file mode 100644
index 3bfc2e4..0000000
--- a/karaf/webconsole/features/src/main/resources/res/ui/features.js
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-function renderFeatures( data ) {
- $(document).ready( function() {
- renderView();
- renderData( data );
- } );
-}
-
-function renderView() {
- renderStatusLine();
- renderTable( "Feature Repositories", "repository_table", ["Name", "URL", "Actions"] );
- var txt = "<form method='post'><div class='table'><table id='repository_table_footer' class='tablelayout'><tbody>" +
- "<tr><input type='hidden' name='action' value='addRepository'/>" +
- "<td><input id='url' type='text' name='url' style='width:100%' colspan='2'/></td>" +
- "<td class='col_Actions'><input type='button' value='Add URL' onclick='addRepositoryUrl()'/></td>" +
- "</tr></tbody></table></div></form><br/>";
- $("#plugin_content").append( txt );
- renderTable( "Features", "feature_table", ["Name", "Version", "Repository", "Status", "Actions"] );
- renderStatusLine();
-}
-
-function addRepositoryUrl() {
- var url = document.getElementById( "url" ).value;
- changeRepositoryState( "addRepository", url );
-}
-
-function renderStatusLine() {
- $("#plugin_content").append( "<div class='fullwidth'><div class='statusline'/></div>" );
-}
-
-function renderTable( /* String */ title, /* String */ id, /* array of Strings */ columns ) {
- var txt = "<div class='table'><table class='tablelayout'><tbody><tr>" +
- "<td style='color:#6181A9;background-color:#e6eeee'>" +
- title + "</td></tr></tbody></table>" +
- "<table id='" + id + "' class='tablelayout'><thead><tr>";
- for ( var name in columns ) {
- txt = txt + "<th class='col_" + columns[name] + "' style='border-top:#e6eeee'>" + columns[name] + "</th>";
- }
- txt = txt + "</tr></thead><tbody></tbody></table></div>";
- $("#plugin_content").append( txt );
-}
-
-function renderData( /* Object */ data ) {
- renderStatusData( data.status );
- renderRepositoryTableData( data.repositories );
- renderFeatureTableData( data.features );
- $("#repository_table").tablesorter( {
- headers: {
- 2: { sorter: false }
- },
- sortList: [[0,0]],
- } );
- $("#feature_table").tablesorter( {
- headers: {
- 4: { sorter: false }
- },
- sortList: [[0,0]],
- } );
-}
-
-function renderStatusData( /* String */ status ) {
- $(".statusline").empty().append( status );
-}
-
-function renderRepositoryTableData( /* array of Objects */ repositories ) {
- var trElement;
- var input;
- var needsLegend = false;
- $("#repository_table > tbody > tr").remove();
- for ( var idx in repositories ) {
- var name = repositories[idx].name;
- trElement = tr( null, { id: "repository-" + name } );
- renderRepositoryData( trElement, repositories[idx] );
- $("#repository_table > tbody").append( trElement );
- if ( name[ name.length - 1 ] == "*" ) {
- needsLegend = true;
- }
- }
- $("#repository_table").trigger( "update" );
- if ( needsLegend ) {
- trElement = tr( null, null ) ;
- trElement.appendChild( td( null, { colspan: 3 },
- [ text( "* Installed via deploy directory" ) ] ) );
- $("#repository_table_footer > tbody").prepend( trElement );
- }
- $("#repository_table_footer").trigger( "update" );
-}
-
-function renderRepositoryData( /* Element */ parent, /* Object */ repository ) {
- parent.appendChild( td( null, null, [ text( repository.name ) ] ) );
- parent.appendChild( td( null, null, [ text( repository.url ) ] ) );
-
- var actionsTd = td( null, null );
- var div = createElement( "div", null, {
- style: { "text-align": "left"}
- } );
- actionsTd.appendChild( div );
-
- for ( var a in repository.actions ) {
- repositoryButton( div, repository.url, repository.actions[a] );
- }
- parent.appendChild( actionsTd );
-}
-
-function repositoryButton( /* Element */ parent, /* String */ url, /* Obj */ action ) {
- if ( !action.enabled ) {
- return;
- }
-
- var input = createElement( "input", null, {
- type: 'image',
- style: {"margin-left": "10px"},
- title: action.title,
- alt: action.title,
- src: imgRoot + '/bundle_' + action.image + '.png'
- } );
- $(input).click( function() {changeRepositoryState( action.op, url )} );
-
- if ( !action.enabled ) {
- $(input).attr( "disabled", true );
- }
- parent.appendChild( input );
-}
-
-function changeRepositoryState( /* String */ action, /* String */ url ) {
- $.post( pluginRoot, {"action": action, "url": url}, function( data ) {
- renderData( data );
- }, "json" );
-}
-
-function renderFeatureTableData( /* array of Objects */ features ) {
- $("#feature_table > tbody > tr").remove();
- for ( var idx in features ) {
- var trElement = tr( null, { id: "feature-" + features[idx].id } );
- renderFeatureData( trElement, features[idx] );
- $("#feature_table > tbody").append( trElement );
- }
- $("#feature_table").trigger( "update" );
-}
-
-function renderFeatureData( /* Element */ parent, /* Object */ feature ) {
- parent.appendChild( td( null, null, [ text( feature.name ) ] ) );
- parent.appendChild( td( null, null, [ text( feature.version ) ] ) );
- parent.appendChild( td( null, null, [ text( feature.repository ) ] ) );
- parent.appendChild( td( null, null, [ text( feature.state ) ] ) );
- var actionsTd = td( null, null );
- var div = createElement( "div", null, {
- style: { "text-align": "left"}
- } );
- actionsTd.appendChild( div );
-
- for ( var a in feature.actions ) {
- featureButton( div, feature.name, feature.version, feature.actions[a] );
- }
- parent.appendChild( actionsTd );
-}
-
-function featureButton( /* Element */ parent, /* String */ name, /* String */ version, /* Obj */ action ) {
- if ( !action.enabled ) {
- return;
- }
-
- var input = createElement( "input", null, {
- type: 'image',
- style: {"margin-left": "10px"},
- title: action.title,
- alt: action.title,
- src: imgRoot + '/bundle_' + action.image + '.png'
- } );
- $(input).click( function() {changeFeatureState( action.op, name, version )} );
-
- if ( !action.enabled ) {
- $(input).attr( "disabled", true );
- }
- parent.appendChild( input );
-}
-
-function changeFeatureState( /* String */ action, /* String */ feature, /* String */ version ) {
- $.post( pluginRoot, {"action": action, "feature": feature, "version": version}, function( data ) {
- renderData( data );
- }, "json" );
-}
diff --git a/karaf/webconsole/gogo/NOTICE b/karaf/webconsole/gogo/NOTICE
deleted file mode 100644
index 46a8a29..0000000
--- a/karaf/webconsole/gogo/NOTICE
+++ /dev/null
@@ -1,30 +0,0 @@
-Apache Felix Karaf
-Copyright 2010 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-This product includes software from http://www.json.org.
-Copyright (c) 2002 JSON.org
-
-This product includes software written by
-Antony Lesuisse.
-Licensed under Public Domain.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
-- JSON License
-- Public Domain
diff --git a/karaf/webconsole/gogo/pom.xml b/karaf/webconsole/gogo/pom.xml
deleted file mode 100644
index 802cae6..0000000
--- a/karaf/webconsole/gogo/pom.xml
+++ /dev/null
@@ -1,105 +0,0 @@
-<?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/maven-v4_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.felix.karaf.webconsole</groupId>
- <artifactId>webconsole</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.webconsole</groupId>
- <artifactId>org.apache.felix.karaf.webconsole.gogo</artifactId>
- <packaging>bundle</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Web Console :: Gogo Plugin</name>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.webconsole</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.shell</groupId>
- <artifactId>org.apache.felix.karaf.shell.console</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>20070829</version>
- <scope>compile</scope>
- <optional>true</optional>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Import-Package>!${project.artifactId}*,*</Import-Package>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
- <Embed-Dependency>
- <!-- Required for JSON data transfer -->
- <!-- TODO: this needs to be put in a common place for reuse. -->
- json
- </Embed-Dependency>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git a/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/GogoPlugin.java b/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/GogoPlugin.java
deleted file mode 100644
index bed29dc..0000000
--- a/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/GogoPlugin.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Based on http://antony.lesuisse.org/software/ajaxterm/
- * Public Domain License
- */
-
-package org.apache.felix.karaf.webconsole.gogo;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.InterruptedIOException;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.net.URL;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.zip.GZIPOutputStream;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.felix.karaf.shell.console.Completer;
-import org.apache.felix.karaf.shell.console.completer.AggregateCompleter;
-import org.apache.felix.karaf.shell.console.jline.Console;
-import org.apache.felix.webconsole.AbstractWebConsolePlugin;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.command.CommandProcessor;
-import org.osgi.service.command.CommandSession;
-
-/**
- * The <code>GogoPlugin</code>
- */
-public class GogoPlugin extends AbstractWebConsolePlugin {
-
- /** Pseudo class version ID to keep the IDE quite. */
- private static final long serialVersionUID = 1L;
-
- public static final String NAME = "gogo";
-
- public static final String LABEL = "Gogo";
-
- public static final int TERM_WIDTH = 120;
- public static final int TERM_HEIGHT = 39;
-
- private Log log = LogFactory.getLog(GogoPlugin.class);
-
- private BundleContext bundleContext;
-
- private CommandProcessor commandProcessor;
-
- private List<Completer> completers;
-
- public void setBundleContext(BundleContext bundleContext)
- {
- this.bundleContext = bundleContext;
- }
-
- public void setCommandProcessor(CommandProcessor commandProcessor)
- {
- this.commandProcessor = commandProcessor;
- }
-
- public void setCompleters(List<Completer> completers)
- {
- this.completers = completers;
- }
-
- /*
- * Blueprint lifecycle callback methods
- */
-
- public void start()
- {
- super.activate( bundleContext );
- this.log.info( LABEL + " plugin activated" );
- }
-
- public void stop()
- {
- this.log.info( LABEL + " plugin deactivated" );
- super.deactivate();
- }
-
- //
- // AbstractWebConsolePlugin interface
- //
- public String getLabel()
- {
- return NAME;
- }
-
-
- public String getTitle()
- {
- return LABEL;
- }
-
-
- protected void renderContent( HttpServletRequest request, HttpServletResponse response ) throws IOException
- {
- PrintWriter pw = response.getWriter();
-
- String appRoot = request.getContextPath() + request.getServletPath();
- pw.println( "<link href=\"" + appRoot + "/gogo/res/ui/gogo.css\" rel=\"stylesheet\" type=\"text/css\" />" );
- pw.println( "<script src=\"" + appRoot + "/gogo/res/ui/gogo.js\" type=\"text/javascript\"></script>" );
- pw.println( "<div id='console'><div id='term'></div></div>" );
- pw.println( "<script type=\"text/javascript\"><!--" );
- pw.println( "window.onload = function() { gogo.Terminal(document.getElementById(\"term\"), " + TERM_WIDTH + ", " + TERM_HEIGHT + "); }" );
- pw.println( "--></script>" );
- }
-
- protected URL getResource( String path )
- {
- path = path.substring( NAME.length() + 1 );
- URL url = this.getClass().getClassLoader().getResource( path );
- if (url != null) {
- InputStream ins = null;
- try {
- ins = url.openStream();
- if (ins == null) {
- this.log.error("failed to open " + url);
- url = null;
- }
- } catch (IOException e) {
- this.log.error(e.getMessage(), e);
- url = null;
- } finally {
- if (ins != null) {
- try {
- ins.close();
- } catch (IOException e) {
- this.log.error(e.getMessage(), e);
- }
- }
- }
- }
- return url;
- }
-
- @Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- String encoding = request.getHeader("Accept-Encoding");
- boolean supportsGzip = (encoding != null && encoding.toLowerCase().indexOf("gzip") > -1);
- SessionTerminal st = (SessionTerminal) request.getSession(true).getAttribute("terminal");
- if (st == null || st.isClosed()) {
- st = new SessionTerminal();
- request.getSession().setAttribute("terminal", st);
- }
- String str = request.getParameter("k");
- String f = request.getParameter("f");
- String dump = st.handle(str, f != null && f.length() > 0);
- if (dump != null) {
- if (supportsGzip) {
- response.setHeader("Content-Encoding", "gzip");
- response.setHeader("Content-Type", "text/html");
- try {
- GZIPOutputStream gzos = new GZIPOutputStream(response.getOutputStream());
- gzos.write(dump.getBytes());
- gzos.close();
- } catch (IOException ie) {
- // handle the error here
- ie.printStackTrace();
- }
- } else {
- response.getOutputStream().write(dump.getBytes());
- }
- }
- }
-
-
- public class SessionTerminal implements Runnable {
-
- private Terminal terminal;
- private Console console;
- private PipedOutputStream in;
- private PipedInputStream out;
- private boolean closed;
-
- public SessionTerminal() throws IOException {
- try {
- this.terminal = new Terminal(TERM_WIDTH, TERM_HEIGHT);
- terminal.write("\u001b\u005B20\u0068"); // set newline mode on
-
- in = new PipedOutputStream();
- out = new PipedInputStream();
- PrintStream pipedOut = new PrintStream(new PipedOutputStream(out), true);
-
- console = new Console(commandProcessor,
- new PipedInputStream(in),
- pipedOut,
- pipedOut,
- new WebTerminal(TERM_WIDTH, TERM_HEIGHT),
- new AggregateCompleter(completers),
- null);
- CommandSession session = console.getSession();
- session.put("APPLICATION", System.getProperty("karaf.name", "root"));
- session.put("USER", "karaf");
- session.put("COLUMNS", Integer.toString(TERM_WIDTH));
- session.put("LINES", Integer.toString(TERM_HEIGHT));
- } catch (IOException e) {
- e.printStackTrace();
- throw e;
- } catch (Exception e) {
- e.printStackTrace();
- throw (IOException) new IOException().initCause(e);
- }
- new Thread(console).start();
- new Thread(this).start();
- }
-
- public boolean isClosed() {
- return closed;
- }
-
- public String handle(String str, boolean forceDump) throws IOException {
- try {
- if (str != null && str.length() > 0) {
- String d = terminal.pipe(str);
- for (byte b : d.getBytes()) {
- in.write(b);
- }
- in.flush();
- }
- } catch (IOException e) {
- closed = true;
- throw e;
- }
- try {
- return terminal.dump(10, forceDump);
- } catch (InterruptedException e) {
- throw new InterruptedIOException(e.toString());
- }
- }
-
- public void run() {
- try {
- for (;;) {
- byte[] buf = new byte[8192];
- int l = out.read(buf);
- InputStreamReader r = new InputStreamReader(new ByteArrayInputStream(buf, 0, l));
- StringBuilder sb = new StringBuilder();
- for (;;) {
- int c = r.read();
- if (c == -1) {
- break;
- }
- sb.append((char) c);
- }
- if (sb.length() > 0) {
- terminal.write(sb.toString());
- }
- String s = terminal.read();
- if (s != null && s.length() > 0) {
- for (byte b : s.getBytes()) {
- in.write(b);
- }
- }
- }
- } catch (IOException e) {
- closed = true;
- e.printStackTrace();
- }
- }
-
- }
-}
diff --git a/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/Terminal.java b/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/Terminal.java
deleted file mode 100644
index 661d1f9..0000000
--- a/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/Terminal.java
+++ /dev/null
@@ -1,1502 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Based on http://antony.lesuisse.org/software/ajaxterm/
- * Public Domain License
- */
-
-/**
- * See http://www.ecma-international.org/publications/standards/Ecma-048.htm
- * and http://vt100.net/docs/vt510-rm/
- */
-
-package org.apache.felix.karaf.webconsole.gogo;
-
-import java.util.Arrays;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-public class Terminal {
-
- enum State {
- None,
- Esc,
- Str,
- Csi,
- }
-
- private int width;
- private int height;
- private int attr;
- private boolean eol;
- private int cx;
- private int cy;
- private int[] screen;
- private int[] screen2;
- private State vt100_parse_state = State.None;
- private int vt100_parse_len;
- private int vt100_lastchar;
- private int vt100_parse_func;
- private String vt100_parse_param;
- private boolean vt100_mode_autowrap;
- private boolean vt100_mode_insert;
- private boolean vt100_charset_is_single_shift;
- private boolean vt100_charset_is_graphical;
- private boolean vt100_mode_lfnewline;
- private boolean vt100_mode_origin;
- private boolean vt100_mode_inverse;
- private boolean vt100_mode_cursorkey;
- private boolean vt100_mode_cursor;
- private boolean vt100_mode_alt_screen;
- private boolean vt100_mode_backspace;
- private boolean vt100_mode_column_switch;
- private boolean vt100_keyfilter_escape;
- private int[] vt100_charset_graph = new int[] {
- 0x25ca, 0x2026, 0x2022, 0x3f,
- 0xb6, 0x3f, 0xb0, 0xb1,
- 0x3f, 0x3f, 0x2b, 0x2b,
- 0x2b, 0x2b, 0x2b, 0xaf,
- 0x2014, 0x2014, 0x2014, 0x5f,
- 0x2b, 0x2b, 0x2b, 0x2b,
- 0x7c, 0x2264, 0x2265, 0xb6,
- 0x2260, 0xa3, 0xb7, 0x7f
- };
- private int vt100_charset_g_sel;
- private int[] vt100_charset_g = { 0, 0 };
- private Map<String, Object> vt100_saved;
- private Map<String, Object> vt100_saved2;
- private int vt100_saved_cx;
- private int vt100_saved_cy;
- private String vt100_out;
-
- private int scroll_area_y0;
- private int scroll_area_y1;
-
- private List<Integer> tab_stops;
-
- private int utf8_char;
- private int utf8_units_count;
- private int utf8_units_received;
-
- private AtomicBoolean dirty = new AtomicBoolean(true);
-
- public Terminal() {
- this(80, 24);
- }
-
- public Terminal(int width, int height) {
- this.width = width;
- this.height = height;
- reset_hard();
- }
-
- private void reset_hard() {
- // Attribute mask: 0x0XFB0000
- // X: Bit 0 - Underlined
- // Bit 1 - Negative
- // Bit 2 - Concealed
- // F: Foreground
- // B: Background
- attr = 0x00fe0000;
- // UTF-8 decoder
- utf8_units_count = 0;
- utf8_units_received = 0;
- utf8_char = 0;
- // Key filter
- vt100_keyfilter_escape = false;
- // Last char
- vt100_lastchar = 0;
- // Control sequences
- vt100_parse_len = 0;
- vt100_parse_state = State.None;
- vt100_parse_func = 0;
- vt100_parse_param = "";
- // Buffers
- vt100_out = "";
- // Invoke other resets
- reset_screen();
- reset_soft();
- }
-
- private void reset_soft() {
- // Attribute mask: 0x0XFB0000
- // X: Bit 0 - Underlined
- // Bit 1 - Negative
- // Bit 2 - Concealed
- // F: Foreground
- // B: Background
- attr = 0x00fe0000;
- // Scroll parameters
- scroll_area_y0 = 0;
- scroll_area_y1 = height;
- // Character sets
- vt100_charset_is_single_shift = false;
- vt100_charset_is_graphical = false;
- vt100_charset_g_sel = 0;
- vt100_charset_g = new int[] { 0, 0 };
- // Modes
- vt100_mode_insert = false;
- vt100_mode_lfnewline = false;
- vt100_mode_cursorkey = false;
- vt100_mode_column_switch = false;
- vt100_mode_inverse = false;
- vt100_mode_origin = false;
- vt100_mode_autowrap = true;
- vt100_mode_cursor = true;
- vt100_mode_alt_screen = false;
- vt100_mode_backspace = false;
- // Init DECSC state
- esc_DECSC();
- vt100_saved2 = vt100_saved;
- esc_DECSC();
- }
-
- private void reset_screen() {
- // Screen
- screen = new int[width * height];
- Arrays.fill(screen, attr | 0x0020);
- screen2 = new int[width * height];
- Arrays.fill(screen2, attr | 0x0020);
- // Scroll parameters
- scroll_area_y0 = 0;
- scroll_area_y1 = height;
- // Cursor position
- cx = 0;
- cy = 0;
- // Tab stops
- tab_stops = new ArrayList<Integer>();
- for (int i = 7; i < width; i += 8) {
- tab_stops.add(i);
- }
- }
-
- //
- // UTF-8 functions
- //
-
- private String utf8_decode(String d) {
- StringBuilder o = new StringBuilder();
- for (char c : d.toCharArray()) {
- if (utf8_units_count != utf8_units_received) {
- utf8_units_received++;
- if ((c & 0xc0) == 0x80) {
- utf8_char = (utf8_char << 6) | (c & 0x3f);
- if (utf8_units_count == utf8_units_received) {
- if (utf8_char < 0x10000) {
- o.append((char) utf8_char);
- }
- utf8_units_count = utf8_units_received = 0;
- }
- } else {
- o.append('?');
- while (utf8_units_received-- > 0) {
- o.append('?');
- }
- utf8_units_count = 0;
- }
- } else {
- if ((c & 0x80) == 0x00) {
- o.append(c);
- } else if ((c & 0xe0) == 0xc0) {
- utf8_units_count = 1;
- utf8_char = c & 0x1f;
- } else if ((c & 0xf0) == 0xe0) {
- utf8_units_count = 2;
- utf8_char = c & 0x0f;
- } else if ((c & 0xf8) == 0xf0) {
- utf8_units_count = 3;
- utf8_char = c & 0x07;
- } else {
- o.append('?');
- }
-
- }
- }
- return o.toString();
- }
-
- private int utf8_charwidth(int c) {
- if (c >= 0x2e80) {
- return 2;
- } else {
- return 1;
- }
- }
-
- //
- // Low-level terminal functions
- //
-
- private int[] peek(int y0, int x0, int y1, int x1) {
- int from = width * y0 + x0;
- int to = width * (y1 - 1) + x1;
- int newLength = to - from;
- if (newLength < 0)
- throw new IllegalArgumentException(from + " > " + to);
- int[] copy = new int[newLength];
- System.arraycopy(screen, from, copy, 0,
- Math.min(screen.length - from, newLength));
- return copy;
- }
-
- private void poke(int y, int x, int[] s) {
- System.arraycopy(s, 0, screen, width * y + x, s.length);
- setDirty();
- }
-
- private void fill(int y0, int x0, int y1, int x1, int c) {
- int d0 = width * y0 + x0;
- int d1 = width * (y1 - 1) + x1;
- if (d0 <= d1) {
- Arrays.fill(screen, width * y0 + x0, width * (y1 - 1) + x1, c);
- setDirty();
- }
- }
-
- private void clear(int y0, int x0, int y1, int x1) {
- fill(y0, x0, y1, x1, attr | 0x20);
- }
-
- //
- // Scrolling functions
- //
-
- private void scroll_area_up(int y0, int y1) {
- scroll_area_up(y0, y1, 1);
- }
-
- private void scroll_area_up(int y0, int y1, int n) {
- n = Math.min(y1 - y0, n);
- poke(y0, 0, peek(y0 + n, 0, y1, width));
- clear(y1-n, 0, y1, width);
- }
-
- private void scroll_area_down(int y0, int y1) {
- scroll_area_down(y0, y1, 1);
- }
-
- private void scroll_area_down(int y0, int y1, int n) {
- n = Math.min(y1 - y0, n);
- poke(y0 + n, 0, peek(y0, 0, y1-n, width));
- clear(y0, 0, y0 + n, width);
- }
-
- private void scroll_area_set(int y0, int y1) {
- y0 = Math.max(0, Math.min(height - 1, y0));
- y1 = Math.max(1, Math.min(height, y1));
- if (y1 > y0) {
- scroll_area_y0 = y0;
- scroll_area_y1 = y1;
- }
- }
-
- private void scroll_line_right(int y, int x) {
- scroll_line_right(y, x, 1);
- }
-
- private void scroll_line_right(int y, int x, int n) {
- if (x < width) {
- n = Math.min(width - cx, n);
- poke(y, x + n, peek(y, x, y + 1, width - n));
- clear(y, x, y + 1, x + n);
- }
- }
-
- private void scroll_line_left(int y, int x) {
- scroll_line_left(y, x, 1);
- }
-
- private void scroll_line_left(int y, int x, int n) {
- if (x < width) {
- n = Math.min(width - cx, n);
- poke(y, x, peek(y, x + n, y + 1, width));
- clear(y, width - n, y + 1, width);
- }
- }
-
- //
- // Cursor functions
- //
-
- private int[] cursor_line_width(int next_char) {
- int wx = utf8_charwidth(next_char);
- int lx = 0;
- for (int x = 0; x < Math.min(cx, width); x++) {
- int c = peek(cy, x, cy + 1, x + 1)[0] & 0xffff;
- wx += utf8_charwidth(c);
- lx += 1;
- }
- return new int[] { wx, lx };
- }
-
- private void cursor_up() {
- cursor_up(1);
- }
-
- private void cursor_up(int n) {
- cy = Math.max(scroll_area_y0, cy - n);
- setDirty();
- }
-
- private void cursor_down() {
- cursor_down(1);
- }
-
- private void cursor_down(int n) {
- cy = Math.min(scroll_area_y1 - 1, cy + n);
- setDirty();
- }
-
- private void cursor_left() {
- cursor_left(1);
- }
-
- private void cursor_left(int n) {
- eol = false;
- cx = Math.max(0, cx - n);
- setDirty();
- }
-
- private void cursor_right() {
- cursor_right(1);
- }
-
- private void cursor_right(int n) {
- eol = cx + n >= width;
- cx = Math.min(width - 1, cx + n);
- setDirty();
- }
-
- private void cursor_set_x(int x) {
- eol = false;
- cx = Math.max(0, x);
- setDirty();
- }
-
- private void cursor_set_y(int y) {
- cy = Math.max(0, Math.min(height - 1, y));
- setDirty();
- }
-
- private void cursor_set(int y, int x) {
- cursor_set_x(x);
- cursor_set_y(y);
- }
-
- //
- // Dumb terminal
- //
-
- private void ctrl_BS() {
- int dy = (cx - 1) / width;
- cursor_set(Math.max(scroll_area_y0, cy + dy), (cx - 1) % width);
- }
-
- private void ctrl_HT() {
- ctrl_HT(1);
- }
-
- private void ctrl_HT(int n) {
- if (n > 0 && cx >= width) {
- return;
- }
- if (n <= 0 && cx == 0) {
- return;
- }
- int ts = -1;
- for (int i = 0; i < tab_stops.size(); i++) {
- if (cx >= tab_stops.get(i)) {
- ts = i;
- }
- }
- ts += n;
- if (ts < tab_stops.size() && ts >= 0) {
- cursor_set_x(tab_stops.get(ts));
- } else {
- cursor_set_x(width - 1);
- }
- }
-
- private void ctrl_LF() {
- if (vt100_mode_lfnewline) {
- ctrl_CR();
- }
- if (cy == scroll_area_y1 - 1) {
- scroll_area_up(scroll_area_y0, scroll_area_y1);
- } else {
- cursor_down();
- }
- }
-
- private void ctrl_CR() {
- cursor_set_x(0);
- }
-
- private boolean dumb_write(int c) {
- if (c < 32) {
- if (c == 8) {
- ctrl_BS();
- } else if (c == 9) {
- ctrl_HT();
- } else if (c >= 10 && c <= 12) {
- ctrl_LF();
- } else if (c == 13) {
- ctrl_CR();
- }
- return true;
- }
- return false;
- }
-
- private void dumb_echo(int c) {
- if (eol) {
- if (vt100_mode_autowrap) {
- ctrl_CR();
- ctrl_LF();
- } else {
- cx = cursor_line_width(c)[1] - 1;
- }
- }
- if (vt100_mode_insert) {
- scroll_line_right(cy, cx);
- }
- if (vt100_charset_is_single_shift) {
- vt100_charset_is_single_shift = false;
- } else if (vt100_charset_is_graphical && ((c & 0xffe0) == 0x0060)) {
- c = vt100_charset_graph[c - 0x60];
- }
- poke(cy, cx, new int[] { attr | c });
- cursor_right();
- }
-
- //
- // VT100
- //
-
- private void vt100_charset_update() {
- vt100_charset_is_graphical = (vt100_charset_g[vt100_charset_g_sel] == 2);
- }
-
- private void vt100_charset_set(int g) {
- // Invoke active character set
- vt100_charset_g_sel = g;
- vt100_charset_update();
- }
-
- private void vt100_charset_select(int g, int charset) {
- // Select charset
- vt100_charset_g[g] = charset;
- vt100_charset_update();
- }
-
- private void vt100_setmode(String p, boolean state) {
- // Set VT100 mode
- String[] ps = vt100_parse_params(p, new String[0]);
- for (String m : ps) {
- // 1 : GATM: Guarded area transfer
- // 2 : KAM: Keyboard action
- // 3 : CRM: Control representation
- if ("4".equals(m)) {
- // Insertion replacement mode
- vt100_mode_insert = state;
- // 5 : SRTM: Status reporting transfer
- // 7 : VEM: Vertical editing
- // 10 : HEM: Horizontal editing
- // 11 : PUM: Positioning nit
- // 12 : SRM: Send/receive
- // 13 : FEAM: Format effector action
- // 14 : FETM: Format effector transfer
- // 15 : MATM: Multiple area transfer
- // 16 : TTM: Transfer termination
- // 17 : SATM: Selected area transfer
- // 18 : TSM: Tabulation stop
- // 19 : EBM: Editing boundary
- } else if ("20".equals(m)) {
- // LNM: Line feed/new line
- vt100_mode_lfnewline = state;
- } else if ("?1".equals(m)) {
- // DECCKM: Cursor keys
- vt100_mode_cursorkey = state;
- // ?2 : DECANM: ANSI
- } else if ("?3".equals(m)) {
- // DECCOLM: Column
- if (vt100_mode_column_switch) {
- if (state) {
- width = 132;
- } else {
- width = 80;
- }
- reset_screen();
- }
- // ?4 : DECSCLM: Scrolling
- } else if ("?5".equals(m)) {
- // DECSCNM: Screen
- vt100_mode_inverse = state;
- } else if ("?6".equals(m)) {
- // DECOM: Origin
- vt100_mode_origin = state;
- if (state) {
- cursor_set(scroll_area_y0, 0);
- } else {
- cursor_set(0, 0);
- }
- } else if ("?7".equals(m)) {
- // DECAWM: Autowrap
- vt100_mode_autowrap = state;
- // ?8 : DECARM: Autorepeat
- // ?9 : Interlacing
- // ?18 : DECPFF: Print form feed
- // ?19 : DECPEX: Printer extent
- } else if ("?25".equals(m)) {
- // DECTCEM: Text cursor enable
- vt100_mode_cursor = state;
- // ?34 : DECRLM: Cursor direction, right to left
- // ?35 : DECHEBM: Hebrew keyboard mapping
- // ?36 : DECHEM: Hebrew encoding mode
- } else if ("?40".equals(m)) {
- // Column switch control
- vt100_mode_column_switch = state;
- // ?42 : DECNRCM: National replacement character set
- } else if ("?47".equals(m)) {
- // Alternate screen mode
- if ((state && !vt100_mode_alt_screen) || (!state && vt100_mode_alt_screen)) {
- int[] s = screen; screen = screen2; screen2 = s;
- Map<String, Object> map = vt100_saved; vt100_saved = vt100_saved2; vt100_saved = map;
- }
- vt100_mode_alt_screen = state;
- // ?57 : DECNAKB: Greek keyboard mapping
- } else if ("?67".equals(m)) {
- // DECBKM: Backarrow key
- vt100_mode_backspace = state;
- }
- // ?98 : DECARSM: auto-resize
- // ?101 : DECCANSM: Conceal answerback message
- // ?109 : DECCAPSLK: caps lock
- }
- }
-
- private void ctrl_SO() {
- vt100_charset_set(1);
- }
-
- private void ctrl_SI() {
- vt100_charset_set(0);
- }
-
- private void esc_CSI() {
- vt100_parse_reset(State.Csi);
- }
-
- private void esc_DECALN() {
- fill(0, 0, height, width, 0x00fe0045);
- }
-
- private void esc_G0_0() {
- vt100_charset_select(0, 0);
- }
- private void esc_G0_1() {
- vt100_charset_select(0, 1);
- }
- private void esc_G0_2() {
- vt100_charset_select(0, 2);
- }
- private void esc_G0_3() {
- vt100_charset_select(0, 3);
- }
- private void esc_G0_4() {
- vt100_charset_select(0, 4);
- }
-
- private void esc_G1_0() {
- vt100_charset_select(1, 0);
- }
- private void esc_G1_1() {
- vt100_charset_select(1, 1);
- }
- private void esc_G1_2() {
- vt100_charset_select(1, 2);
- }
- private void esc_G1_3() {
- vt100_charset_select(1, 3);
- }
- private void esc_G1_4() {
- vt100_charset_select(1, 4);
- }
-
- private void esc_DECSC() {
- vt100_saved = new HashMap<String, Object>();
- vt100_saved.put("cx", cx);
- vt100_saved.put("cy", cy);
- vt100_saved.put("attr", attr);
- vt100_saved.put("vt100_charset_g_sel", vt100_charset_g_sel);
- vt100_saved.put("vt100_charset_g", vt100_charset_g);
- vt100_saved.put("vt100_mode_autowrap", vt100_mode_autowrap);
- vt100_saved.put("vt100_mode_origin", vt100_mode_origin);
- }
-
- private void esc_DECRC() {
- cx = (Integer) vt100_saved.get("cx");
- cy = (Integer) vt100_saved.get("cy");
- attr = (Integer) vt100_saved.get("attr");
- vt100_charset_g_sel = (Integer) vt100_saved.get("vt100_charset_g_sel");
- vt100_charset_g = (int[]) vt100_saved.get("vt100_charset_g");
- vt100_charset_update();
- vt100_mode_autowrap = (Boolean) vt100_saved.get("vt100_mode_autowrap");
- vt100_mode_origin = (Boolean) vt100_saved.get("vt100_mode_origin");
- }
-
- private void esc_IND() {
- ctrl_LF();
- }
-
- private void esc_NEL() {
- ctrl_CR();
- ctrl_LF();
- }
-
- private void esc_HTS() {
- csi_CTC("0");
- }
-
- private void esc_RI() {
- if (cy == scroll_area_y0) {
- scroll_area_down(scroll_area_y0, scroll_area_y1);
- } else {
- cursor_up();
- }
- }
-
- private void esc_SS2() {
- vt100_charset_is_single_shift = true;
- }
-
- private void esc_SS3() {
- vt100_charset_is_single_shift = true;
- }
-
- private void esc_DCS() {
- vt100_parse_reset(State.Str);
- }
-
- private void esc_SOS() {
- vt100_parse_reset(State.Str);
- }
-
- private void esc_DECID() {
- csi_DA("0");
- }
-
- private void esc_ST() {
- }
-
- private void esc_OSC() {
- vt100_parse_reset(State.Str);
- }
-
- private void esc_PM() {
- vt100_parse_reset(State.Str);
- }
-
- private void esc_APC() {
- vt100_parse_reset(State.Str);
- }
-
- private void esc_RIS() {
- reset_hard();
- }
-
- private void csi_ICH(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 1 });
- scroll_line_right(cy, cx, ps[0]);
- }
-
- private void csi_CUU(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 1 });
- cursor_up(Math.max(1, ps[0]));
- }
-
- private void csi_CUD(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 1 });
- cursor_down(Math.max(1, ps[0]));
- }
-
- private void csi_CUF(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 1 });
- cursor_right(Math.max(1, ps[0]));
- }
-
- private void csi_CUB(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 1 });
- cursor_left(Math.max(1, ps[0]));
- }
-
- private void csi_CNL(String p) {
- csi_CUD(p);
- ctrl_CR();
- }
-
- private void csi_CPL(String p) {
- csi_CUU(p);
- ctrl_CR();
- }
-
- private void csi_CHA(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 1 });
- cursor_set_x(ps[0] - 1);
- }
-
- private void csi_CUP(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 1, 1 });
- if (vt100_mode_origin) {
- cursor_set(scroll_area_y0 + ps[0] - 1, ps[1] - 1);
- } else {
- cursor_set(ps[0] - 1, ps[1] - 1);
- }
- }
-
- private void csi_CHT(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 1 });
- ctrl_HT(Math.max(1, ps[0]));
- }
-
- private void csi_ED(String p) {
- String[] ps = vt100_parse_params(p, new String[] { "0" });
- if ("0".equals(ps[0])) {
- clear(cy, cx, height, width);
- } else if ("1".equals(ps[0])) {
- clear(0, 0, cy + 1, cx + 1);
- } else if ("2".equals(ps[0])) {
- clear(0, 0, height, width);
- }
- }
-
- private void csi_EL(String p) {
- String[] ps = vt100_parse_params(p, new String[] { "0" });
- if ("0".equals(ps[0])) {
- clear(cy, cx, cy + 1, width);
- } else if ("1".equals(ps[0])) {
- clear(cy, 0, cy + 1, cx + 1);
- } else if ("2".equals(ps[0])) {
- clear(cy, 0, cy + 1, width);
- }
- }
-
- private void csi_IL(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 1 });
- if (cy >= scroll_area_y0 && cy < scroll_area_y1) {
- scroll_area_down(cy, scroll_area_y1, Math.max(1, ps[0]));
- }
- }
-
- private void csi_DL(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 1 });
- if (cy >= scroll_area_y0 && cy < scroll_area_y1) {
- scroll_area_up(cy, scroll_area_y1, Math.max(1, ps[0]));
- }
- }
-
- private void csi_DCH(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 1 });
- scroll_line_left(cy, cx, Math.max(1, ps[0]));
- }
-
- private void csi_SU(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 1 });
- scroll_area_up(scroll_area_y0, scroll_area_y1, Math.max(1, ps[0]));
- }
-
- private void csi_SD(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 1 });
- scroll_area_down(scroll_area_y0, scroll_area_y1, Math.max(1, ps[0]));
- }
-
- private void csi_CTC(String p) {
- String[] ps = vt100_parse_params(p, new String[] { "0" });
- for (String m : ps) {
- if ("0".equals(m)) {
- if (tab_stops.indexOf(cx) < 0) {
- tab_stops.add(cx);
- Collections.sort(tab_stops);
- }
- } else if ("2".equals(m)) {
- tab_stops.remove(Integer.valueOf(cx));
- } else if ("5".equals(m)) {
- tab_stops = new ArrayList<Integer>();
- }
- }
- }
-
- private void csi_ECH(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 1 });
- int n = Math.min(width - cx, Math.max(1, ps[0]));
- clear(cy, cx, cy + 1, cx + n);
- }
-
- private void csi_CBT(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 1 });
- ctrl_HT(1 - Math.max(1, ps[0]));
- }
-
- private void csi_HPA(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 1 });
- cursor_set_x(ps[0] - 1);
- }
-
- private void csi_HPR(String p) {
- csi_CUF(p);
- }
-
- private void csi_REP(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 1 });
- if (vt100_lastchar < 32) {
- return;
- }
- int n = Math.min(2000, Math.max(1, ps[0]));
- while (n-- > 0) {
- dumb_echo(vt100_lastchar);
- }
- vt100_lastchar = 0;
- }
-
- private void csi_DA(String p) {
- String[] ps = vt100_parse_params(p, new String[] { "0" });
- if ("0".equals(ps[0])) {
- vt100_out = "\u001b[?1;2c";
- } else if (">0".equals(ps[0]) || ">".equals(ps[0])) {
- vt100_out = "\u001b[>0;184;0c";
- }
- }
-
- private void csi_VPA(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 1 });
- cursor_set_y(ps[0] - 1);
- }
-
- private void csi_VPR(String p) {
- csi_CUD(p);
- }
-
- private void csi_HVP(String p) {
- csi_CUP(p);
- }
-
- private void csi_TBC(String p) {
- String[] ps = vt100_parse_params(p, new String[] { "0" });
- if ("0".equals(ps[0])) {
- csi_CTC("2");
- } else if ("3".equals(ps[0])) {
- csi_CTC("5");
- }
- }
-
- private void csi_SM(String p) {
- vt100_setmode(p, true);
- }
-
- private void csi_RM(String p) {
- vt100_setmode(p, false);
- }
-
- private void csi_SGR(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 0 });
- for (int m : ps) {
- if (m == 0) {
- attr = 0x00fe0000;
- } else if (m == 1) {
- attr |= 0x08000000;
- } else if (m == 4) {
- attr |= 0x01000000;
- } else if (m == 7) {
- attr |= 0x02000000;
- } else if (m == 8) {
- attr |= 0x04000000;
- } else if (m == 24) {
- attr &= 0x7eff0000;
- } else if (m == 27) {
- attr &= 0x7dff0000;
- } else if (m == 28) {
- attr &= 0x7bff0000;
- } else if (m >= 30 && m <= 37) {
- attr = (attr & 0x7f0f0000) | ((m - 30) << 20);
- } else if (m == 39) {
- attr = (attr & 0x7f0f0000) | 0x00f00000;
- } else if (m >= 40 && m <= 47) {
- attr = (attr & 0x7ff00000) | ((m - 40) << 16);
- } else if (m == 49) {
- attr = (attr & 0x7ff00000) | 0x000e0000;
- }
- }
- }
-
- private void csi_DSR(String p) {
- String[] ps = vt100_parse_params(p, new String[] { "0" });
- if ("5".equals(ps[0])) {
- vt100_out = "\u001b[0n";
- } else if ("6".equals(ps[0])) {
- vt100_out = "\u001b[" + (cy + 1) + ";" + (cx + 1) + "R";
- } else if ("7".equals(ps[0])) {
- vt100_out = "gogo-term";
- } else if ("8".equals(ps[0])) {
- vt100_out = "1.0-SNAPSHOT";
- } else if ("?6".equals(ps[0])) {
- vt100_out = "\u001b[" + (cy + 1) + ";" + (cx + 1) + ";0R";
- } else if ("?15".equals(ps[0])) {
- vt100_out = "\u001b[?13n";
- } else if ("?25".equals(ps[0])) {
- vt100_out = "\u001b[?20n";
- } else if ("?26".equals(ps[0])) {
- vt100_out = "\u001b[?27;1n";
- } else if ("?53".equals(ps[0])) {
- vt100_out = "\u001b[?53n";
- }
- // ?75 : Data Integrity report
- // ?62 : Macro Space report
- // ?63 : Memory Checksum report
- }
-
- private void csi_DECSTBM(String p) {
- int[] ps = vt100_parse_params(p, new int[] { 1, height });
- scroll_area_set(ps[0] - 1, ps[1]);
- if (vt100_mode_origin) {
- cursor_set(scroll_area_y0, 0);
- } else {
- cursor_set(0, 0);
- }
- }
-
- private void csi_SCP(String p) {
- vt100_saved_cx = cx;
- vt100_saved_cy = cy;
- }
-
- private void csi_RCP(String p) {
- cx = vt100_saved_cx;
- cy = vt100_saved_cy;
- }
-
- private void csi_DECREQTPARM(String p) {
- String[] ps = vt100_parse_params(p, new String[0]);
- if ("0".equals(ps[0])) {
- vt100_out = "\u001b[2;1;1;112;112;1;0x";
- } else if ("1".equals(ps[0])) {
- vt100_out = "\u001b[3;1;1;112;112;1;0x";
- }
- }
-
- private void csi_DECSTR(String p) {
- reset_soft();
- }
-
- //
- // VT100 parser
- //
-
- private String[] vt100_parse_params(String p, String[] defaults) {
- String prefix = "";
- if (p.length() > 0) {
- if (p.charAt(0) >= '<' && p.charAt(0) <= '?') {
- prefix = "" + p.charAt(0);
- p = p.substring(1);
- }
- }
- String[] ps = p.split(";");
- int n = Math.max(ps.length, defaults.length);
- String[] values = new String[n];
- for (int i = 0; i < n; i++) {
- String value = null;
- if (i < ps.length) {
- value = prefix + ps[i];
- }
- if (value == null && i < defaults.length) {
- value = defaults[i];
- }
- if (value == null) {
- value = "";
- }
- values[i] = value;
- }
- return values;
- }
-
- private int[] vt100_parse_params(String p, int[] defaults) {
- String prefix = "";
- p = p == null ? "" : p;
- if (p.length() > 0) {
- if (p.charAt(0) >= '<' && p.charAt(0) <= '?') {
- prefix = p.substring(0, 1);
- p = p.substring(1);
- }
- }
- String[] ps = p.split(";");
- int n = Math.max(ps.length, defaults.length);
- int[] values = new int[n];
- for (int i = 0; i < n; i++) {
- Integer value = null;
- if (i < ps.length) {
- String v = prefix + ps[i];
- try {
- value = Integer.parseInt(v);
- } catch (NumberFormatException e) {
- }
- }
- if (value == null && i < defaults.length) {
- value = defaults[i];
- }
- if (value == null) {
- value = 0;
- }
- values[i] = value;
- }
- return values;
- }
-
- private void vt100_parse_reset() {
- vt100_parse_reset(State.None);
- }
-
- private void vt100_parse_reset(State state) {
- vt100_parse_state = state;
- vt100_parse_len = 0;
- vt100_parse_func = 0;
- vt100_parse_param = "";
- }
-
- private void vt100_parse_process() {
- if (vt100_parse_state == State.Esc) {
- switch (vt100_parse_func) {
- case 0x0036: /* DECBI */ break;
- case 0x0037: esc_DECSC(); break;
- case 0x0038: esc_DECRC(); break;
- case 0x0042: /* BPH */ break;
- case 0x0043: /* NBH */ break;
- case 0x0044: esc_IND(); break;
- case 0x0045: esc_NEL(); break;
- case 0x0046: /* SSA */ esc_NEL(); break;
- case 0x0048: esc_HTS(); break;
- case 0x0049: /* HTJ */ break;
- case 0x004A: /* VTS */ break;
- case 0x004B: /* PLD */ break;
- case 0x004C: /* PLU */ break;
- case 0x004D: esc_RI(); break;
- case 0x004E: esc_SS2(); break;
- case 0x004F: esc_SS3(); break;
- case 0x0050: esc_DCS(); break;
- case 0x0051: /* PU1 */ break;
- case 0x0052: /* PU2 */ break;
- case 0x0053: /* STS */ break;
- case 0x0054: /* CCH */ break;
- case 0x0055: /* MW */ break;
- case 0x0056: /* SPA */ break;
- case 0x0057: /* ESA */ break;
- case 0x0058: esc_SOS(); break;
- case 0x005A: /* SCI */ break;
- case 0x005B: esc_CSI(); break;
- case 0x005C: esc_ST(); break;
- case 0x005D: esc_OSC(); break;
- case 0x005E: esc_PM(); break;
- case 0x005F: esc_APC(); break;
- case 0x0060: /* DMI */ break;
- case 0x0061: /* INT */ break;
- case 0x0062: /* EMI */ break;
- case 0x0063: esc_RIS(); break;
- case 0x0064: /* CMD */ break;
- case 0x006C: /* RM */ break;
- case 0x006E: /* LS2 */ break;
- case 0x006F: /* LS3 */ break;
- case 0x007C: /* LS3R */ break;
- case 0x007D: /* LS2R */ break;
- case 0x007E: /* LS1R */ break;
- case 0x2338: esc_DECALN(); break;
- case 0x2841: esc_G0_0(); break;
- case 0x2842: esc_G0_1(); break;
- case 0x2830: esc_G0_2(); break;
- case 0x2831: esc_G0_3(); break;
- case 0x2832: esc_G0_4(); break;
- case 0x2930: esc_G1_2(); break;
- case 0x2931: esc_G1_3(); break;
- case 0x2932: esc_G1_4(); break;
- case 0x2941: esc_G1_0(); break;
- case 0x2942: esc_G1_1(); break;
- }
- if (vt100_parse_state == State.Esc) {
- vt100_parse_reset();
- }
- } else {
- switch (vt100_parse_func) {
- case 0x0040: csi_ICH(vt100_parse_param); break;
- case 0x0041: csi_CUU(vt100_parse_param); break;
- case 0x0042: csi_CUD(vt100_parse_param); break;
- case 0x0043: csi_CUF(vt100_parse_param); break;
- case 0x0044: csi_CUB(vt100_parse_param); break;
- case 0x0045: csi_CNL(vt100_parse_param); break;
- case 0x0046: csi_CPL(vt100_parse_param); break;
- case 0x0047: csi_CHA(vt100_parse_param); break;
- case 0x0048: csi_CUP(vt100_parse_param); break;
- case 0x0049: csi_CHT(vt100_parse_param); break;
- case 0x004A: csi_ED(vt100_parse_param); break;
- case 0x004B: csi_EL(vt100_parse_param); break;
- case 0x004C: csi_IL(vt100_parse_param); break;
- case 0x004D: csi_DL(vt100_parse_param); break;
- case 0x004E: /* EF */ break;
- case 0x004F: /* EA */ break;
- case 0x0050: csi_DCH(vt100_parse_param); break;
- case 0x0051: /* SEE */ break;
- case 0x0052: /* CPR */ break;
- case 0x0053: csi_SU(vt100_parse_param); break;
- case 0x0054: csi_SD(vt100_parse_param); break;
- case 0x0055: /* NP */ break;
- case 0x0056: /* PP */ break;
- case 0x0057: csi_CTC(vt100_parse_param); break;
- case 0x0058: csi_ECH(vt100_parse_param); break;
- case 0x0059: /* CVT */ break;
- case 0x005A: csi_CBT(vt100_parse_param); break;
- case 0x005B: /* SRS */ break;
- case 0x005C: /* PTX */ break;
- case 0x005D: /* SDS */ break;
- case 0x005E: /* SIMD */ break;
- case 0x0060: csi_HPA(vt100_parse_param); break;
- case 0x0061: csi_HPR(vt100_parse_param); break;
- case 0x0062: csi_REP(vt100_parse_param); break;
- case 0x0063: csi_DA(vt100_parse_param); break;
- case 0x0064: csi_VPA(vt100_parse_param); break;
- case 0x0065: csi_VPR(vt100_parse_param); break;
- case 0x0066: csi_HVP(vt100_parse_param); break;
- case 0x0067: csi_TBC(vt100_parse_param); break;
- case 0x0068: csi_SM(vt100_parse_param); break;
- case 0x0069: /* MC */ break;
- case 0x006A: /* HPB */ break;
- case 0x006B: /* VPB */ break;
- case 0x006C: csi_RM(vt100_parse_param); break;
- case 0x006D: csi_SGR(vt100_parse_param); break;
- case 0x006E: csi_DSR(vt100_parse_param); break;
- case 0x006F: /* DAQ */ break;
- case 0x0072: csi_DECSTBM(vt100_parse_param); break;
- case 0x0073: csi_SCP(vt100_parse_param); break;
- case 0x0075: csi_RCP(vt100_parse_param); break;
- case 0x0078: csi_DECREQTPARM(vt100_parse_param); break;
- case 0x2040: /* SL */ break;
- case 0x2041: /* SR */ break;
- case 0x2042: /* GSM */ break;
- case 0x2043: /* GSS */ break;
- case 0x2044: /* FNT */ break;
- case 0x2045: /* TSS */ break;
- case 0x2046: /* JFY */ break;
- case 0x2047: /* SPI */ break;
- case 0x2048: /* QUAD */ break;
- case 0x2049: /* SSU */ break;
- case 0x204A: /* PFS */ break;
- case 0x204B: /* SHS */ break;
- case 0x204C: /* SVS */ break;
- case 0x204D: /* IGS */ break;
- case 0x204E: /* deprecated: HTSA */ break;
- case 0x204F: /* IDCS */ break;
- case 0x2050: /* PPA */ break;
- case 0x2051: /* PPR */ break;
- case 0x2052: /* PPB */ break;
- case 0x2053: /* SPD */ break;
- case 0x2054: /* DTA */ break;
- case 0x2055: /* SLH */ break;
- case 0x2056: /* SLL */ break;
- case 0x2057: /* FNK */ break;
- case 0x2058: /* SPQR */ break;
- case 0x2059: /* SEF */ break;
- case 0x205A: /* PEC */ break;
- case 0x205B: /* SSW */ break;
- case 0x205C: /* SACS */ break;
- case 0x205D: /* SAPV */ break;
- case 0x205E: /* STAB */ break;
- case 0x205F: /* GCC */ break;
- case 0x2060: /* TAPE */ break;
- case 0x2061: /* TALE */ break;
- case 0x2062: /* TAC */ break;
- case 0x2063: /* TCC */ break;
- case 0x2064: /* TSR */ break;
- case 0x2065: /* SCO */ break;
- case 0x2066: /* SRCS */ break;
- case 0x2067: /* SCS */ break;
- case 0x2068: /* SLS */ break;
- case 0x2069: /* SPH */ break;
- case 0x206A: /* SPL */ break;
- case 0x206B: /* SCP */ break;
- case 0x2170: csi_DECSTR(vt100_parse_param); break;
- case 0x2472: /* DECCARA */ break;
- case 0x2477: /* DECRQPSR */ break;
- }
- if (vt100_parse_state == State.Csi) {
- vt100_parse_reset();
- }
- }
- }
-
- private boolean vt100_write(int c) {
- if (c < 32) {
- if (c == 27) {
- vt100_parse_reset(State.Esc);
- return true;
- } else if (c == 14) {
- ctrl_SO();
- } else if (c == 15) {
- ctrl_SI();
- }
- } else if ((c & 0xffe0) == 0x0080) {
- vt100_parse_reset(State.Esc);
- vt100_parse_func = (char)(c - 0x0040);
- vt100_parse_process();
- return true;
- }
- if (vt100_parse_state != State.None) {
- if (vt100_parse_state == State.Str) {
- if (c >= 32) {
- return true;
- }
- vt100_parse_reset();
- } else {
- if (c < 32) {
- if (c == 24 || c == 26) {
- vt100_parse_reset();
- return true;
- }
- } else {
- vt100_parse_len += 1;
- if (vt100_parse_len > 32) {
- vt100_parse_reset();
- } else {
- int msb = c & 0xf0;
- if (msb == 0x20) {
- vt100_parse_func <<= 8;
- vt100_parse_func += (char) c;
- } else if (msb == 0x30 && vt100_parse_state == State.Csi) {
- vt100_parse_param += new String(new char[] { (char) c } );
- } else {
- vt100_parse_func <<= 8;
- vt100_parse_func += (char) c;
- vt100_parse_process();
- }
- return true;
- }
- }
- }
- }
- vt100_lastchar = c;
- return false;
- }
-
- //
- // Dirty
- //
-
- private synchronized void setDirty() {
- dirty.set(true);
- notifyAll();
- }
-
- //
- // External interface
- //
-
- public synchronized boolean setSize(int w, int h) {
- if (w < 2 || w > 256 || h < 2 || h > 256) {
- return false;
- }
- this.width = w;
- this.height = h;
- reset_screen();
- return true;
- }
-
- public synchronized String read() {
- String d = vt100_out;
- vt100_out = "";
- return d;
- }
-
- public synchronized String pipe(String d) {
- String o = "";
- for (char c : d.toCharArray()) {
- if (vt100_keyfilter_escape) {
- vt100_keyfilter_escape = false;
- if (vt100_mode_cursorkey) {
- switch (c) {
- case '~': o += "~"; break;
- case 'A': o += "\u001bOA"; break;
- case 'B': o += "\u001bOB"; break;
- case 'C': o += "\u001bOC"; break;
- case 'D': o += "\u001bOD"; break;
- case 'F': o += "\u001bOF"; break;
- case 'H': o += "\u001bOH"; break;
- case '1': o += "\u001b[5~"; break;
- case '2': o += "\u001b[6~"; break;
- case '3': o += "\u001b[2~"; break;
- case '4': o += "\u001b[3~"; break;
- case 'a': o += "\u001bOP"; break;
- case 'b': o += "\u001bOQ"; break;
- case 'c': o += "\u001bOR"; break;
- case 'd': o += "\u001bOS"; break;
- case 'e': o += "\u001b[15~"; break;
- case 'f': o += "\u001b[17~"; break;
- case 'g': o += "\u001b[18~"; break;
- case 'h': o += "\u001b[19~"; break;
- case 'i': o += "\u001b[20~"; break;
- case 'j': o += "\u001b[21~"; break;
- case 'k': o += "\u001b[23~"; break;
- case 'l': o += "\u001b[24~"; break;
- }
- } else {
- switch (c) {
- case '~': o += "~"; break;
- case 'A': o += "\u001b[A"; break;
- case 'B': o += "\u001b[B"; break;
- case 'C': o += "\u001b[C"; break;
- case 'D': o += "\u001b[D"; break;
- case 'F': o += "\u001b[F"; break;
- case 'H': o += "\u001b[H"; break;
- case '1': o += "\u001b[5~"; break;
- case '2': o += "\u001b[6~"; break;
- case '3': o += "\u001b[2~"; break;
- case '4': o += "\u001b[3~"; break;
- case 'a': o += "\u001bOP"; break;
- case 'b': o += "\u001bOQ"; break;
- case 'c': o += "\u001bOR"; break;
- case 'd': o += "\u001bOS"; break;
- case 'e': o += "\u001b[15~"; break;
- case 'f': o += "\u001b[17~"; break;
- case 'g': o += "\u001b[18~"; break;
- case 'h': o += "\u001b[19~"; break;
- case 'i': o += "\u001b[20~"; break;
- case 'j': o += "\u001b[21~"; break;
- case 'k': o += "\u001b[23~"; break;
- case 'l': o += "\u001b[24~"; break;
- }
- }
- } else if (c == '~') {
- vt100_keyfilter_escape = true;
- } else if (c == 127) {
- if (vt100_mode_backspace) {
- o += (char) 8;
- } else {
- o += (char) 127;
- }
- } else {
- o += c;
- if (vt100_mode_lfnewline && c == 13) {
- o += (char) 10;
- }
- }
- }
- return o;
- }
-
- public synchronized boolean write(String d) {
- d = utf8_decode(d);
- for (int c : d.toCharArray()) {
- if (vt100_write(c)) {
- continue;
- }
- if (dumb_write(c)) {
- continue;
- }
- if (c <= 0xffff) {
- dumb_echo(c);
- }
- }
- return true;
- }
-
- public synchronized String dump(long timeout, boolean forceDump) throws InterruptedException {
- if (!dirty.get() && timeout > 0) {
- wait(timeout);
- }
- if (dirty.compareAndSet(true, false) || forceDump) {
- StringBuilder sb = new StringBuilder();
- int prev_attr = -1;
- int cx = Math.min(this.cx, width - 1);
- int cy = this.cy;
- sb.append("<div><pre class='term'>");
- for (int y = 0; y < height; y++) {
- int wx = 0;
- for (int x = 0; x < width; x++) {
- int d = screen[y * width + x];
- int c = d & 0xffff;
- int a = d >> 16;
- if (cy == y && cx == x && vt100_mode_cursor) {
- a = a & 0xfff0 | 0x000c;
- }
- if (a != prev_attr) {
- if (prev_attr != -1) {
- sb.append("</span>");
- }
- int bg = a & 0x000f;
- int fg = (a & 0x00f0) >> 4;
- boolean inv = (a & 0x0200) != 0;
- boolean inv2 = vt100_mode_inverse;
- if (inv && !inv2 || inv2 && !inv) {
- int i = fg; fg = bg; bg = i;
- }
- if ((a & 0x0400) != 0) {
- fg = 0x0c;
- }
- String ul;
- if ((a & 0x0100) != 0) {
- ul = " ul";
- } else {
- ul = "";
- }
- String b;
- if ((a & 0x0800) != 0) {
- b = " b";
- } else {
- b = "";
- }
- sb.append("<span class='f").append(fg).append(" b").append(bg).append(ul).append(b).append("'>");
- prev_attr = a;
- }
- switch (c) {
- case '&': sb.append("&"); break;
- case '<': sb.append("<"); break;
- case '>': sb.append(">"); break;
- default:
- wx += utf8_charwidth(c);
- if (wx <= width) {
- sb.append((char) c);
- }
- break;
- }
- }
- sb.append("\n");
- }
- sb.append("</span></pre></div>");
- return sb.toString();
- }
- return null;
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder();
- for (int y = 0; y < height; y++) {
- for (int x = 0; x < width; x++) {
- sb.append((char) (screen[y * width + x] & 0xffff));
- }
- sb.append("\n");
- }
- return sb.toString();
- }
-}
diff --git a/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/WebTerminal.java b/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/WebTerminal.java
deleted file mode 100644
index 550cb03..0000000
--- a/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/WebTerminal.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.karaf.webconsole.gogo;
-
-import java.io.InputStreamReader;
-import java.io.InputStream;
-import java.io.IOException;
-
-public class WebTerminal extends jline.Terminal {
-
- public static final short ARROW_START = 27;
- public static final short ARROW_PREFIX = 91;
- public static final short ARROW_LEFT = 68;
- public static final short ARROW_RIGHT = 67;
- public static final short ARROW_UP = 65;
- public static final short ARROW_DOWN = 66;
- public static final short O_PREFIX = 79;
- public static final short HOME_CODE = 72;
- public static final short END_CODE = 70;
-
- public static final short DEL_THIRD = 51;
- public static final short DEL_SECOND = 126;
-
- private int width;
- private int height;
- private boolean backspaceDeleteSwitched = false;
- private String encoding = System.getProperty("input.encoding", "UTF-8");
- private ReplayPrefixOneCharInputStream replayStream = new ReplayPrefixOneCharInputStream(encoding);
- private InputStreamReader replayReader;
-
- public WebTerminal(int width, int height) {
- this.width = width;
- this.height = height;
- try {
- replayReader = new InputStreamReader(replayStream, encoding);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public void initializeTerminal() throws Exception {
- }
-
- public void restoreTerminal() throws Exception {
- }
-
- public int getTerminalWidth() {
- return width;
- }
-
- public int getTerminalHeight() {
- return height;
- }
-
- public boolean isSupported() {
- return true;
- }
-
- public boolean getEcho() {
- return false;
- }
-
- public boolean isEchoEnabled() {
- return false;
- }
-
- public void enableEcho() {
- }
-
- public void disableEcho() {
- }
-
- public int readVirtualKey(InputStream in) throws IOException {
- int c = readCharacter(in);
-
- if (backspaceDeleteSwitched) {
- if (c == DELETE) {
- c = '\b';
- } else if (c == '\b') {
- c = DELETE;
- }
- }
-
- // in Unix terminals, arrow keys are represented by
- // a sequence of 3 characters. E.g., the up arrow
- // key yields 27, 91, 68
- if (c == ARROW_START) {
- //also the escape key is 27
- //thats why we read until we
- //have something different than 27
- //this is a bugfix, because otherwise
- //pressing escape and than an arrow key
- //was an undefined state
- while (c == ARROW_START) {
- c = readCharacter(in);
- }
- if (c == ARROW_PREFIX || c == O_PREFIX) {
- c = readCharacter(in);
- if (c == ARROW_UP) {
- return CTRL_P;
- } else if (c == ARROW_DOWN) {
- return CTRL_N;
- } else if (c == ARROW_LEFT) {
- return CTRL_B;
- } else if (c == ARROW_RIGHT) {
- return CTRL_F;
- } else if (c == HOME_CODE) {
- return CTRL_A;
- } else if (c == END_CODE) {
- return CTRL_E;
- } else if (c == DEL_THIRD) {
- c = readCharacter(in); // read 4th
- return DELETE;
- }
- }
- }
- // handle unicode characters, thanks for a patch from amyi@inf.ed.ac.uk
- if (c > 128) {
- // handle unicode characters longer than 2 bytes,
- // thanks to Marc.Herbert@continuent.com
- replayStream.setInput(c, in);
- c = replayReader.read();
- }
-
- return c;
- }
-
- /**
- * This is awkward and inefficient, but probably the minimal way to add
- * UTF-8 support to JLine
- *
- * @author <a href="mailto:Marc.Herbert@continuent.com">Marc Herbert</a>
- */
- static class ReplayPrefixOneCharInputStream extends InputStream {
-
- byte firstByte;
- int byteLength;
- InputStream wrappedStream;
- int byteRead;
-
- final String encoding;
-
- public ReplayPrefixOneCharInputStream(String encoding) {
- this.encoding = encoding;
- }
-
- public void setInput(int recorded, InputStream wrapped) throws IOException {
- this.byteRead = 0;
- this.firstByte = (byte) recorded;
- this.wrappedStream = wrapped;
-
- byteLength = 1;
- if (encoding.equalsIgnoreCase("UTF-8")) {
- setInputUTF8(recorded, wrapped);
- } else if (encoding.equalsIgnoreCase("UTF-16")) {
- byteLength = 2;
- } else if (encoding.equalsIgnoreCase("UTF-32")) {
- byteLength = 4;
- }
- }
-
-
- public void setInputUTF8(int recorded, InputStream wrapped) throws IOException {
- // 110yyyyy 10zzzzzz
- if ((firstByte & (byte) 0xE0) == (byte) 0xC0) {
- this.byteLength = 2;
- // 1110xxxx 10yyyyyy 10zzzzzz
- } else if ((firstByte & (byte) 0xF0) == (byte) 0xE0) {
- this.byteLength = 3;
- // 11110www 10xxxxxx 10yyyyyy 10zzzzzz
- } else if ((firstByte & (byte) 0xF8) == (byte) 0xF0) {
- this.byteLength = 4;
- } else {
- throw new IOException("invalid UTF-8 first byte: " + firstByte);
- }
- }
-
- public int read() throws IOException {
- if (available() == 0) {
- return -1;
- }
-
- byteRead++;
-
- if (byteRead == 1) {
- return firstByte;
- }
-
- return wrappedStream.read();
- }
-
- /**
- * InputStreamReader is greedy and will try to read bytes in advance. We
- * do NOT want this to happen since we use a temporary/"losing bytes"
- * InputStreamReader above, that's why we hide the real
- * wrappedStream.available() here.
- */
- public int available() {
- return byteLength - byteRead;
- }
- }
-
-}
diff --git a/karaf/webconsole/gogo/src/main/resources/OSGI-INF/blueprint/webconsole-gogo.xml b/karaf/webconsole/gogo/src/main/resources/OSGI-INF/blueprint/webconsole-gogo.xml
deleted file mode 100644
index de8770a..0000000
--- a/karaf/webconsole/gogo/src/main/resources/OSGI-INF/blueprint/webconsole-gogo.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0">
-
- <reference id="commandProcessor" interface="org.osgi.service.command.CommandProcessor" />
-
- <bean id="gogoPlugin" class="org.apache.felix.karaf.webconsole.gogo.GogoPlugin" init-method="start" destroy-method="stop">
- <property name="completers">
- <list>
- <ref component-id="commandCompleter"/>
- </list>
- </property>
- <property name="commandProcessor" ref="commandProcessor" />
- <property name="bundleContext" ref="blueprintBundleContext" />
- </bean>
-
- <reference-list id="functions" filter="(&(osgi.command.scope=*)(osgi.command.function=*))" availability="optional">
- <reference-listener ref="commandCompleter"
- bind-method="register"
- unbind-method="unregister"/>
- </reference-list>
-
- <bean id="commandCompleter" class="org.apache.felix.karaf.shell.console.completer.CommandsCompleter">
- <property name="bundleContext" ref="blueprintBundleContext" />
- </bean>
-
- <service ref="gogoPlugin" interface="javax.servlet.Servlet" >
- <service-properties>
- <entry key="felix.webconsole.label" value="gogo"/>
- </service-properties>
- </service>
-
-</blueprint>
diff --git a/karaf/webconsole/gogo/src/main/resources/res/ui/gogo.css b/karaf/webconsole/gogo/src/main/resources/res/ui/gogo.css
deleted file mode 100644
index b15ece8..0000000
--- a/karaf/webconsole/gogo/src/main/resources/res/ui/gogo.css
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Based on http://antony.lesuisse.org/software/ajaxterm/
- * Public Domain License
- */
-
-div#console {
- font-size: 12px;
- margin: 12px;
-}
-
-div#term {
- display: inline-block;
-}
-
-pre.stat {
- margin: 0px;
- padding: 4px;
- display: block;
- font-family: monospace;
- white-space: pre;
- background-color: black;
- border-top: 1px solid black;
- color: white;
-}
-pre.stat span {
- padding: 0px;
-}
-pre.stat .on {
- background-color: #080;
- font-weight: bold;
- color: white;
- cursor: pointer;
-}
-pre.stat .off {
- background-color: #888;
- font-weight: bold;
- color: white;
- cursor: pointer;
-}
-pre.term {
- margin: 0px;
- padding: 4px;
- display: block;
- font-family: monospace;
- white-space: pre;
- background:#000;
- border-top: 1px solid white;
- color: #eee;
-}
-pre.term span.f0 { color: #000000; }
-pre.term span.f1 { color: #c00006; }
-pre.term span.f2 { color: #1bc806; }
-pre.term span.f3 { color: #c3c609; }
-pre.term span.f4 { color: #0000c2; }
-pre.term span.f5 { color: #bf00c2; }
-pre.term span.f6 { color: #19c4c2; }
-pre.term span.f7 { color: #f2f2f2; }
-pre.term span.f12 { color: transparent; }
-pre.term span.f14 { color: #000000; }
-pre.term span.f15 { color: #bbbbbb; }
-pre.term span.b0 { background-color: #000000; }
-pre.term span.b1 { background-color: #cc2300; }
-pre.term span.b2 { background-color: #00cc00; }
-pre.term span.b3 { background-color: #cccc00; }
-pre.term span.b4 { background-color: #0e2acc; }
-pre.term span.b5 { background-color: #cc34cc; }
-pre.term span.b6 { background-color: #00cccc; }
-pre.term span.b7 { background-color: #f5f5f5; }
-pre.term span.b12 { background-color: #555555; }
-pre.term span.b14 { background-color: transparent; }
-pre.term span.b15 { background-color: #ffffff; }
-pre.term span.ul { text-decoration: underline; }
-pre.term span.b { font-weight:900; }
-
diff --git a/karaf/webconsole/gogo/src/main/resources/res/ui/gogo.js b/karaf/webconsole/gogo/src/main/resources/res/ui/gogo.js
deleted file mode 100644
index 771efe0..0000000
--- a/karaf/webconsole/gogo/src/main/resources/res/ui/gogo.js
+++ /dev/null
@@ -1,246 +0,0 @@
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-//
-// Based on http://antony.lesuisse.org/software/ajaxterm/
-// Public Domain License
-//
-
-gogo = { };
-
-gogo.Terminal_ctor = function(div, width, height) {
-
- var ie = (window.ActiveXObject) ? 0 : 1;
- var query0 = "w=" + width + "&h=" + height;
- var query1 = query0 + "&k=";
- var buf = "";
- var timeout;
- var error_timeout;
- var keybuf = [];
- var sending = 0;
- var rmax = 1;
- var force = 1;
-
- var dstat = document.createElement('pre');
- var sled = document.createElement('span');
- var sdebug = document.createElement('span');
- var dterm = document.createElement('div');
-
- function debug(s) {
- sdebug.innerHTML = s;
- }
-
- function error() {
- sled.className = 'off';
- debug("Connection lost timeout ts:" + ((new Date).getTime()));
- }
-
- function update() {
- if (sending == 0) {
- sending = 1;
- sled.className = 'on';
- var r = new XMLHttpRequest();
- var send = "";
- while (keybuf.length > 0) {
- send += keybuf.pop();
- }
- var query = query1 + send;
- if (force) {
- query = query + "&f=1";
- force = 0;
- }
- r.open("POST", "gogo", true);
- r.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
- r.onreadystatechange = function () {
- if (r.readyState == 4) {
- if (r.status == 200) {
- window.clearTimeout(error_timeout);
- if (r.responseText.length > 0) {
- dterm.innerHTML = r.responseText;
- rmax = 100;
- } else {
- rmax *= 2;
- if (rmax > 2000)
- rmax = 2000;
- }
- sending=0;
- sled.className = 'off';
- timeout = window.setTimeout(update, rmax);
- } else {
- debug("Connection error status:" + r.status);
- }
- }
- }
- error_timeout = window.setTimeout(error, 5000);
- r.send(query);
- }
- }
-
- function queue(s) {
- keybuf.unshift(s);
- if (sending == 0) {
- window.clearTimeout(timeout);
- timeout = window.setTimeout(update, 1);
- }
- }
-
- function keypress(ev) {
- // Translate to standard keycodes
- if (!ev)
- ev = window.event;
- var kc;
- if (ev.keyCode)
- kc = ev.keyCode;
- if (ev.which)
- kc = ev.which;
- if (ev.ctrlKey) {
- if (kc >= 0 && kc <= 32)
- kc = kc;
- else if (kc >= 65 && kc <= 90)
- kc -= 64;
- else if (kc >= 97 && kc <= 122)
- kc -= 96;
- else {
- switch (kc) {
- case 54: kc=30; break; // Ctrl-^
- case 109: kc=31; break; // Ctrl-_
- case 219: kc=27; break; // Ctrl-[
- case 220: kc=28; break; // Ctrl-\
- case 221: kc=29; break; // Ctrl-]
- default: return true;
- }
- }
- } else if (ev.which == 0) {
- switch(kc) {
- case 8: break; // Backspace
- case 9: break; // Tab
- case 27: break; // ESC
- case 33: kc = 63276; break; // PgUp
- case 34: kc = 63277; break; // PgDn
- case 35: kc = 63275; break; // End
- case 36: kc = 63273; break; // Home
- case 37: kc = 63234; break; // Left
- case 38: kc = 63232; break; // Up
- case 39: kc = 63235; break; // Right
- case 40: kc = 63233; break; // Down
- case 45: kc = 63302; break; // Ins
- case 46: kc = 63272; break; // Del
- case 112: kc = 63236; break; // F1
- case 113: kc = 63237; break; // F2
- case 114: kc = 63238; break; // F3
- case 115: kc = 63239; break; // F4
- case 116: kc = 63240; break; // F5
- case 117: kc = 63241; break; // F6
- case 118: kc = 63242; break; // F7
- case 119: kc = 63243; break; // F8
- case 120: kc = 63244; break; // F9
- case 121: kc = 63245; break; // F10
- case 122: kc = 63246; break; // F11
- case 123: kc = 63247; break; // F12
- default: return true;
- }
- }
- if (kc == 8)
- kc = 127;
-
- var k = "";
- // Build character
- switch (kc) {
- case 126: k = "~~"; break;
- case 63232: k = "~A"; break; // Up
- case 63233: k = "~B"; break; // Down
- case 63234: k = "~D"; break; // Left
- case 63235: k = "~C"; break; // Right
- case 63276: k = "~1"; break; // PgUp
- case 63277: k = "~2"; break; // PgDn
- case 63273: k = "~H"; break; // Home
- case 63275: k = "~F"; break; // End
- case 63302: k = "~3"; break; // Ins
- case 63272: k = "~4"; break; // Del
- case 63236: k = "~a"; break; // F1
- case 63237: k = "~b"; break; // F2
- case 63238: k = "~c"; break; // F3
- case 63239: k = "~d"; break; // F4
- case 63240: k = "~e"; break; // F5
- case 63241: k = "~f"; break; // F6
- case 63242: k = "~g"; break; // F7
- case 63243: k = "~h"; break; // F8
- case 63244: k = "~i"; break; // F9
- case 63245: k = "~j"; break; // F10
- case 63246: k = "~k"; break; // F11
- case 63247: k = "~l"; break; // F12
- default: k = String.fromCharCode(kc); break;
- }
- queue(encodeURIComponent(k));
-
- ev.cancelBubble = true;
- if (ev.stopPropagation) ev.stopPropagation();
- if (ev.preventDefault) ev.preventDefault();
-
- return true;
- }
-
- function keydown(ev) {
- if (!ev)
- ev = window.event;
- if (ie) {
- o = { 9:1, 8:1, 27:1, 33:1, 34:1, 35:1, 36:1, 37:1, 38:1, 39:1, 40:1, 45:1, 46:1, 112:1,
- 113:1, 114:1, 115:1, 116:1, 117:1, 118:1, 119:1, 120:1, 121:1, 122:1, 123:1 };
- if (o[ev.keyCode] || ev.ctrlKey || ev.altKey) {
- ev.which = 0;
- return keypress(ev);
- }
- }
- }
-
- function init() {
- if (typeof(XMLHttpRequest) == "undefined") {
- XMLHttpRequest = function() {
- try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); }
- catch(e) {}
- try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); }
- catch(e) {}
- try { return new ActiveXObject("Msxml2.XMLHTTP"); }
- catch(e) {}
- try { return new ActiveXObject("Microsoft.XMLHTTP"); }
- catch(e) {}
- throw new Error("This browser does not support XMLHttpRequest.");
- };
- }
- sled.appendChild(document.createTextNode('\xb7'));
- sled.className = 'off';
- dstat.appendChild(sled);
- dstat.appendChild(document.createTextNode(' '));
- dstat.appendChild(sdebug);
- dstat.className = 'stat';
- div.appendChild(dstat);
- var d = document.createElement('div');
- d.appendChild(dterm);
- div.appendChild(d);
- document.onkeypress = keypress;
- document.onkeydown = keydown;
- timeout = window.setTimeout(update, 100);
- }
-
- init();
-
-}
-
-gogo.Terminal = function(div, width, height) {
- return new this.Terminal_ctor(div, width, height);
-}
-
diff --git a/karaf/webconsole/pom.xml b/karaf/webconsole/pom.xml
deleted file mode 100644
index e8da6bc..0000000
--- a/karaf/webconsole/pom.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?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/maven-v4_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.felix.karaf</groupId>
- <artifactId>karaf</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.webconsole</groupId>
- <artifactId>webconsole</artifactId>
- <packaging>pom</packaging>
- <version>1.7.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: Web Console</name>
-
- <modules>
- <module>features</module>
- <module>gogo</module>
- <module>branding</module>
- <module>admin</module>
- </modules>
-
-</project>