You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/12/11 18:56:23 UTC
[1/6] camel git commit: CAMEL-8044: Camel commands useable for remote
JVMs using jolokia
Repository: camel
Updated Branches:
refs/heads/master 001969206 -> b15b009a2
CAMEL-8044: Camel commands useable for remote JVMs using jolokia
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/636c6fce
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/636c6fce
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/636c6fce
Branch: refs/heads/master
Commit: 636c6fce48cd4f5b8f297ecd7f5c3d79bfc14ff0
Parents: 0019692
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Dec 11 15:52:09 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Dec 11 18:56:09 2014 +0100
----------------------------------------------------------------------
parent/pom.xml | 1 +
.../src/main/resources/LICENSE.txt | 203 -----------
.../src/main/resources/META-INF/LICENSE.txt | 203 +++++++++++
.../src/main/resources/META-INF/NOTICE.txt | 11 +
.../commands-core/src/main/resources/NOTICE.txt | 11 -
platforms/commands/commands-jolokia/pom.xml | 76 ++++
.../jolokia/JolokiaCamelController.java | 363 +++++++++++++++++++
.../commands/jolokia/JolokiaClientFactory.java | 49 +++
.../commands/jolokia/RemoteCamelController.java | 33 ++
.../src/main/resources/LICENSE.txt | 203 +++++++++++
.../src/main/resources/NOTICE.txt | 11 +
.../commands/jolokia/JolokiaRemoteTest.java | 110 ++++++
.../src/test/resources/log4j.properties | 36 ++
platforms/commands/pom.xml | 1 +
14 files changed, 1097 insertions(+), 214 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/636c6fce/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 60648ac..27e16d8 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -261,6 +261,7 @@
<jmockit-version>1.5</jmockit-version>
<jodatime-bundle-version>1.6.2</jodatime-bundle-version>
<jodatime2-bundle-version>2.5</jodatime2-bundle-version>
+ <jolokia-version>1.2.3</jolokia-version>
<josql-bundle-version>1.5_5</josql-bundle-version>
<josql-version>1.5</josql-version>
<jruby-version>1.7.16</jruby-version>
http://git-wip-us.apache.org/repos/asf/camel/blob/636c6fce/platforms/commands/commands-core/src/main/resources/LICENSE.txt
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/resources/LICENSE.txt b/platforms/commands/commands-core/src/main/resources/LICENSE.txt
deleted file mode 100644
index 6b0b127..0000000
--- a/platforms/commands/commands-core/src/main/resources/LICENSE.txt
+++ /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.
-
http://git-wip-us.apache.org/repos/asf/camel/blob/636c6fce/platforms/commands/commands-core/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/resources/META-INF/LICENSE.txt b/platforms/commands/commands-core/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/platforms/commands/commands-core/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ 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.
+
http://git-wip-us.apache.org/repos/asf/camel/blob/636c6fce/platforms/commands/commands-core/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/resources/META-INF/NOTICE.txt b/platforms/commands/commands-core/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/platforms/commands/commands-core/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
http://git-wip-us.apache.org/repos/asf/camel/blob/636c6fce/platforms/commands/commands-core/src/main/resources/NOTICE.txt
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/resources/NOTICE.txt b/platforms/commands/commands-core/src/main/resources/NOTICE.txt
deleted file mode 100644
index 2e215bf..0000000
--- a/platforms/commands/commands-core/src/main/resources/NOTICE.txt
+++ /dev/null
@@ -1,11 +0,0 @@
- =========================================================================
- == NOTICE file corresponding to the section 4 d of ==
- == the Apache License, Version 2.0, ==
- == in this case for the Apache Camel distribution. ==
- =========================================================================
-
- This product includes software developed by
- The Apache Software Foundation (http://www.apache.org/).
-
- Please read the different LICENSE files present in the licenses directory of
- this distribution.
http://git-wip-us.apache.org/repos/asf/camel/blob/636c6fce/platforms/commands/commands-jolokia/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/pom.xml b/platforms/commands/commands-jolokia/pom.xml
new file mode 100644
index 0000000..8bbfc64
--- /dev/null
+++ b/platforms/commands/commands-jolokia/pom.xml
@@ -0,0 +1,76 @@
+<?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.
+-->
+<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">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>commands</artifactId>
+ <version>2.15-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-commands-jolokia</artifactId>
+ <packaging>bundle</packaging>
+ <name>Camel :: Platforms :: Commands :: Jolokia</name>
+ <description>Camel Commands using Jolokia</description>
+
+ <properties>
+ <camel.osgi.export.pkg>org.apache.camel.commands.jolokia*</camel.osgi.export.pkg>
+ </properties>
+
+ <dependencies>
+
+ <!-- camel -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-commands-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+ <!-- jolokia -->
+ <dependency>
+ <groupId>org.jolokia</groupId>
+ <artifactId>jolokia-client-java</artifactId>
+ <version>${jolokia-version}</version>
+ </dependency>
+
+ <!-- Test -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/636c6fce/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java
new file mode 100644
index 0000000..dd034cc
--- /dev/null
+++ b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java
@@ -0,0 +1,363 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.commands.jolokia;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import javax.management.ObjectName;
+
+import org.apache.camel.commands.AbstractCamelController;
+import org.apache.camel.util.LRUCache;
+import org.apache.camel.util.StringHelper;
+import org.jolokia.client.J4pClient;
+import org.jolokia.client.request.J4pExecRequest;
+import org.jolokia.client.request.J4pExecResponse;
+import org.jolokia.client.request.J4pReadRequest;
+import org.jolokia.client.request.J4pReadResponse;
+import org.jolokia.client.request.J4pSearchRequest;
+import org.jolokia.client.request.J4pSearchResponse;
+
+/**
+ * A {@link org.apache.camel.commands.CamelController} that uses Jolokia Client to connect to remote JVMs which
+ * has an Jolokia agent running.
+ */
+public class JolokiaCamelController extends AbstractCamelController implements RemoteCamelController {
+
+ private Map<String, ObjectName> cache = new LRUCache<String, ObjectName>(1000);
+
+ private J4pClient jolokia;
+ private String url;
+
+ private ObjectName lookupCamelContext(String camelContextName) throws Exception {
+ ObjectName on = cache.get(camelContextName);
+ if (on == null) {
+ ObjectName found = null;
+ J4pSearchResponse sr = jolokia.execute(new J4pSearchRequest("*:type=context,*"));
+ if (sr != null) {
+ for (ObjectName name : sr.getObjectNames()) {
+ String id = name.getKeyProperty("name");
+ id = StringHelper.removeLeadingAndEndingQuotes(id);
+ if (camelContextName.equals(id)) {
+ found = name;
+ break;
+ }
+ }
+ }
+ if (found != null) {
+ on = found;
+ cache.put(camelContextName, on);
+ }
+ }
+ return on;
+ }
+
+ @Override
+ public void connect(String url, String username, String password) throws Exception {
+ this.jolokia = JolokiaClientFactory.createJolokiaClient(url, username, password);
+ this.url = url;
+ }
+
+ @Override
+ public Map<String, Object> getCamelContextInformation(String camelContextName) throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+
+ Map<String, Object> answer = new LinkedHashMap<String, Object>();
+
+ ObjectName found = lookupCamelContext(camelContextName);
+ if (found != null) {
+ J4pReadResponse rr = jolokia.execute(new J4pReadRequest(found));
+ if (rr != null) {
+ for (String key : rr.getAttributes()) {
+ answer.put(asKey(key), rr.getValue(key));
+ }
+ }
+ }
+
+ return answer;
+ }
+
+ @Override
+ public List<Map<String, String>> getCamelContexts() throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+
+ List<Map<String, String>> answer = new ArrayList<Map<String, String>>();
+
+ J4pSearchResponse sr = jolokia.execute(new J4pSearchRequest("*:type=context,*"));
+
+ List<J4pReadRequest> list = new ArrayList<J4pReadRequest>();
+ for (ObjectName on : sr.getObjectNames()) {
+ list.add(new J4pReadRequest(on, "CamelId", "State", "Uptime"));
+ }
+
+ List<J4pReadResponse> lrr = jolokia.execute(list);
+ for (J4pReadResponse rr : lrr) {
+ Map<String, String> row = new LinkedHashMap<String, String>();
+ row.put("name", rr.getValue("CamelId").toString());
+ row.put("state", rr.getValue("State").toString());
+ row.put("uptime", rr.getValue("Uptime").toString());
+ answer.add(row);
+ }
+
+ return answer;
+ }
+
+ @Override
+ public String getCamelContextStatsAsXml(String camelContextName, boolean fullStats, boolean includeProcessors) throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+
+ ObjectName found = lookupCamelContext(camelContextName);
+ if (found != null) {
+ J4pExecResponse er = jolokia.execute(new J4pExecRequest(found, "dumpRoutesStatsAsXml(boolean,boolean)", fullStats, includeProcessors));
+ if (er != null) {
+ String xml = er.getValue();
+ return xml;
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public void startContext(String camelContextName) throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+
+ ObjectName found = lookupCamelContext(camelContextName);
+ if (found != null) {
+ jolokia.execute(new J4pExecRequest(found, "start"));
+ }
+ }
+
+ @Override
+ public void stopContext(String camelContextName) throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+
+ ObjectName found = lookupCamelContext(camelContextName);
+ if (found != null) {
+ jolokia.execute(new J4pExecRequest(found, "stop"));
+ }
+ }
+
+ @Override
+ public void suspendContext(String camelContextName) throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+
+ ObjectName found = lookupCamelContext(camelContextName);
+ if (found != null) {
+ jolokia.execute(new J4pExecRequest(found, "suspend"));
+ }
+ }
+
+ @Override
+ public void resumeContext(String camelContextName) throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+
+ ObjectName found = lookupCamelContext(camelContextName);
+ if (found != null) {
+ jolokia.execute(new J4pExecRequest(found, "resume"));
+ }
+ }
+
+ @Override
+ public List<Map<String, String>> getRoutes(String camelContextName) throws Exception {
+ return getRoutes(camelContextName, null);
+ }
+
+ @Override
+ public List<Map<String, String>> getRoutes(String camelContextName, String filter) throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+
+ List<Map<String, String>> answer = new ArrayList<Map<String, String>>();
+
+ if (camelContextName != null) {
+
+ J4pSearchResponse sr = jolokia.execute(new J4pSearchRequest("*:type=routes,*"));
+
+ List<J4pReadRequest> list = new ArrayList<J4pReadRequest>();
+ for (ObjectName on : sr.getObjectNames()) {
+ list.add(new J4pReadRequest(on, "CamelId", "RouteId", "State"));
+ }
+
+ List<J4pReadResponse> lrr = jolokia.execute(list);
+ for (J4pReadResponse rr : lrr) {
+ String routeId = rr.getValue("RouteId").toString();
+ if (filter == null || routeId.matches(filter)) {
+ Map<String, String> row = new LinkedHashMap<String, String>();
+ row.put("camelContextName", rr.getValue("CamelId").toString());
+ row.put("routeId", routeId);
+ row.put("state", rr.getValue("State").toString());
+ answer.add(row);
+ }
+ }
+
+ } else {
+ List<Map<String, String>> camelContexts = this.getCamelContexts();
+ for (Map<String, String> row : camelContexts) {
+ List<Map<String, String>> routes = getRoutes(row.get("name"), filter);
+ answer.addAll(routes);
+ }
+ }
+
+ // sort the list
+ Collections.sort(answer, new Comparator<Map<String, String>>() {
+ @Override
+ public int compare(Map<String, String> o1, Map<String, String> o2) {
+ // group by camel context first, then by route name
+ String c1 = o1.get("camelContextName");
+ String c2 = o2.get("camelContextName");
+
+ int answer = c1.compareTo(c2);
+ if (answer == 0) {
+ // okay from same camel context, then sort by route id
+ answer = o1.get("routeId").compareTo(o2.get("routeId"));
+ }
+ return answer;
+ }
+ });
+ return answer;
+ }
+
+ @Override
+ public void resetRouteStats(String camelContextName) throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+
+ ObjectName found = lookupCamelContext(camelContextName);
+
+ if (found != null) {
+ String pattern = String.format("%s:context=%s,type=routes,name=*", found.getDomain(), found.getKeyProperty("context"));
+ J4pSearchResponse sr = jolokia.execute(new J4pSearchRequest(pattern));
+
+ List<J4pExecRequest> list = new ArrayList<J4pExecRequest>();
+ for (ObjectName on : sr.getObjectNames()) {
+ list.add(new J4pExecRequest(on, "reset(boolean)", true));
+ }
+
+ jolokia.execute(list);
+ }
+ }
+
+ @Override
+ public void startRoute(String s, String s2) throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+ }
+
+ @Override
+ public void stopRoute(String s, String s2) throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+ }
+
+ @Override
+ public void suspendRoute(String s, String s2) throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+ }
+
+ @Override
+ public void resumeRoute(String s, String s2) throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+ }
+
+ @Override
+ public String getRouteModelAsXml(String s, String s2) throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+ return null;
+ }
+
+ @Override
+ public String getRouteStatsAsXml(String s, String s2, boolean b, boolean b2) throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+ return null;
+ }
+
+ @Override
+ public List<Map<String, String>> getEndpoints(String s) throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+ return null;
+ }
+
+ @Override
+ public String getRestModelAsXml(String s) throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+ return null;
+ }
+
+ @Override
+ public List<Map<String, String>> getRestServices(String s) throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+ return null;
+ }
+
+ @Override
+ public String explainEndpointAsJSon(String s, String s2, boolean b) throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+ return null;
+ }
+
+ @Override
+ public List<Map<String, String>> listComponents(String s) throws Exception {
+ if (jolokia == null) {
+ throw new IllegalStateException("Need to connect to remote jolokia first");
+ }
+ return null;
+ }
+
+ private static String asKey(String attributeKey) {
+ char ch = Character.toLowerCase(attributeKey.charAt(0));
+ return ch + attributeKey.substring(1);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/636c6fce/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaClientFactory.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaClientFactory.java b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaClientFactory.java
new file mode 100644
index 0000000..98c23ef
--- /dev/null
+++ b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaClientFactory.java
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.commands.jolokia;
+
+import org.jolokia.client.J4pClient;
+import org.jolokia.client.J4pClientBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.camel.util.ObjectHelper.isNotEmpty;
+
+/**
+ * A factory to create a {@link org.jolokia.client.J4pClient} jolokia client that connects to a remote JVM.
+ */
+public final class JolokiaClientFactory {
+
+ private static final Logger LOG = LoggerFactory.getLogger(JolokiaClientFactory.class);
+
+ private JolokiaClientFactory() {
+ }
+
+ public static J4pClient createJolokiaClient(String jolokiaUrl, String username, String password) {
+ LOG.info("Creating jolokia client at URL: {}", jolokiaUrl);
+
+ J4pClientBuilder builder = J4pClient.url(jolokiaUrl);
+ if (isNotEmpty(username)) {
+ builder = builder.user(username);
+ }
+ if (isNotEmpty(password)) {
+ builder = builder.password(password);
+ }
+ return builder.build();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/636c6fce/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/RemoteCamelController.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/RemoteCamelController.java b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/RemoteCamelController.java
new file mode 100644
index 0000000..3a2ba3b
--- /dev/null
+++ b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/RemoteCamelController.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.commands.jolokia;
+
+import org.apache.camel.commands.CamelController;
+
+public interface RemoteCamelController extends CamelController {
+
+ /**
+ * Connects to the remote JVM using the given url to the remote jolokia agent
+ *
+ * @param url the url for the remote jolokia agent
+ * @param username optional username
+ * @param password optional password
+ * @throws Exception can be thrown
+ */
+ void connect(String url, String username, String password) throws Exception;
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/636c6fce/platforms/commands/commands-jolokia/src/main/resources/LICENSE.txt
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/src/main/resources/LICENSE.txt b/platforms/commands/commands-jolokia/src/main/resources/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/platforms/commands/commands-jolokia/src/main/resources/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ 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.
+
http://git-wip-us.apache.org/repos/asf/camel/blob/636c6fce/platforms/commands/commands-jolokia/src/main/resources/NOTICE.txt
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/src/main/resources/NOTICE.txt b/platforms/commands/commands-jolokia/src/main/resources/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/platforms/commands/commands-jolokia/src/main/resources/NOTICE.txt
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
http://git-wip-us.apache.org/repos/asf/camel/blob/636c6fce/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java b/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
new file mode 100644
index 0000000..52048b4
--- /dev/null
+++ b/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
@@ -0,0 +1,110 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.commands.jolokia;
+
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore("used for manual testing")
+public class JolokiaRemoteTest {
+
+ private String url = "http://localhost:8080/jolokia";
+
+ private RemoteCamelController controller;
+
+ @Test
+ public void testRemoteCamelContexts() throws Exception {
+ controller = new JolokiaCamelController();
+ controller.connect(url, null, null);
+
+ List<Map<String, String>> data = controller.getCamelContexts();
+ System.out.println(data);
+ }
+
+ @Test
+ public void testRemoteCamelContextInformation() throws Exception {
+ controller = new JolokiaCamelController();
+ controller.connect(url, null, null);
+
+ Map<String, Object> data = controller.getCamelContextInformation("myCamel");
+ System.out.println(data);
+ }
+
+ @Test
+ public void testRemoteCamelContextStatsAsXml() throws Exception {
+ controller = new JolokiaCamelController();
+ controller.connect(url, null, null);
+
+ String data = controller.getCamelContextStatsAsXml("myCamel", true, false);
+ System.out.println(data);
+ }
+
+ @Test
+ public void testRemoteCamelContextControl() throws Exception {
+ controller = new JolokiaCamelController();
+ controller.connect(url, null, null);
+
+ controller.suspendContext("myCamel");
+ Map<String, Object> data = controller.getCamelContextInformation("myCamel");
+ System.out.println(data);
+
+ Thread.sleep(500);
+
+ controller.resumeContext("myCamel");
+ data = controller.getCamelContextInformation("myCamel");
+ System.out.println(data);
+ }
+
+ @Test
+ public void testRemoteGetAllRoutes() throws Exception {
+ controller = new JolokiaCamelController();
+ controller.connect(url, null, null);
+
+ List<Map<String, String>> data = controller.getRoutes(null);
+ System.out.println(data);
+ }
+
+ @Test
+ public void testRemoteGetRoutes() throws Exception {
+ controller = new JolokiaCamelController();
+ controller.connect(url, null, null);
+
+ List<Map<String, String>> data = controller.getRoutes("myCamel");
+ System.out.println(data);
+ }
+
+ @Test
+ public void testRemoteGetRoutesFilter() throws Exception {
+ controller = new JolokiaCamelController();
+ controller.connect(url, null, null);
+
+ List<Map<String, String>> data = controller.getRoutes(null, "route2");
+ System.out.println(data);
+ }
+
+ @Test
+ public void testRemoteResetRouteStats() throws Exception {
+ controller = new JolokiaCamelController();
+ controller.connect(url, null, null);
+
+ controller.resetRouteStats("myCamel");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/636c6fce/platforms/commands/commands-jolokia/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/src/test/resources/log4j.properties b/platforms/commands/commands-jolokia/src/test/resources/log4j.properties
new file mode 100644
index 0000000..b8ef5dc
--- /dev/null
+++ b/platforms/commands/commands-jolokia/src/test/resources/log4j.properties
@@ -0,0 +1,36 @@
+## ------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT 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 logging properties used for testing.
+#
+log4j.rootLogger=INFO, out
+
+# uncomment the following to enable camel debugging
+log4j.logger.org.apache.camel.commands=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d %-5p %c{1} - %m %n
+log4j.appender.file.file=target/camel-commands-core-test.log
http://git-wip-us.apache.org/repos/asf/camel/blob/636c6fce/platforms/commands/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/commands/pom.xml b/platforms/commands/pom.xml
index 911090b..224ae8c 100644
--- a/platforms/commands/pom.xml
+++ b/platforms/commands/pom.xml
@@ -30,6 +30,7 @@
<modules>
<module>commands-core</module>
+ <module>commands-jolokia</module>
</modules>
</project>
[2/6] camel git commit: CAMEL-8044: Camel commands useable for remote
JVMs using jolokia
Posted by da...@apache.org.
CAMEL-8044: Camel commands useable for remote JVMs using jolokia
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b15b009a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b15b009a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b15b009a
Branch: refs/heads/master
Commit: b15b009a21805bfbc2553fbbec5a132aecd69681
Parents: 57b91f8
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Dec 11 18:56:01 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Dec 11 18:56:10 2014 +0100
----------------------------------------------------------------------
.../jolokia/JolokiaCamelController.java | 37 ++++++++++++++++++--
.../commands/jolokia/JolokiaRemoteTest.java | 9 +++++
2 files changed, 44 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/b15b009a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java
index bb87e81..3e7b251 100644
--- a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java
+++ b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java
@@ -491,9 +491,42 @@ public class JolokiaCamelController extends AbstractCamelController implements R
throw new IllegalStateException("Need to connect to remote jolokia first");
}
- // TODO: implement me
+ List<Map<String, String>> answer = new ArrayList<Map<String, String>>();
- return null;
+ ObjectName found = lookupCamelContext(camelContextName);
+ if (found != null) {
+ J4pExecResponse response = jolokia.execute(new J4pExecRequest(found, "listComponents()"));
+ if (response != null) {
+ JSONObject data = response.getValue();
+ for (Object obj : data.values()) {
+ JSONObject data2 = (JSONObject) obj;
+ JSONObject component = (JSONObject) data2.values().iterator().next();
+
+ Map<String, String> row = new LinkedHashMap<String, String>();
+ row.put("artifactId", asString(component.get("artifactId")));
+ row.put("description", asString(component.get("description")));
+ row.put("groupId", asString(component.get("groupId")));
+ row.put("label", asString(component.get("label")));
+ row.put("name", asString(component.get("name")));
+ row.put("status", asString(component.get("status")));
+ row.put("type", asString(component.get("type")));
+ row.put("version", asString(component.get("version")));
+ answer.add(row);
+ }
+ }
+
+ // sort the list
+ Collections.sort(answer, new Comparator<Map<String, String>>() {
+ @Override
+ public int compare(Map<String, String> component1, Map<String, String> component2) {
+ String name1 = component1.get("name");
+ String name2 = component2.get("name");
+ return name1.compareTo(name2);
+ }
+ });
+ }
+
+ return answer;
}
private static String asKey(String attributeKey) {
http://git-wip-us.apache.org/repos/asf/camel/blob/b15b009a/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java b/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
index 2afc2c2..bdfa8fa 100644
--- a/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
+++ b/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
@@ -177,4 +177,13 @@ public class JolokiaRemoteTest {
System.out.println(data);
}
+ @Test
+ public void testListComponents() throws Exception {
+ controller = new JolokiaCamelController();
+ controller.connect(url, null, null);
+
+ List<Map<String, String>> data = controller.listComponents("myCamel");
+ System.out.println(data);
+ }
+
}
[3/6] camel git commit: CAMEL-8044: Camel commands useable for remote
JVMs using jolokia
Posted by da...@apache.org.
CAMEL-8044: Camel commands useable for remote JVMs using jolokia
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7f5e278f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7f5e278f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7f5e278f
Branch: refs/heads/master
Commit: 7f5e278f650ebc08e44ff3018047852d6351bef9
Parents: 3636e30
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Dec 11 17:43:49 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Dec 11 18:56:10 2014 +0100
----------------------------------------------------------------------
.../jolokia/JolokiaCamelController.java | 60 ++++++++++++--------
1 file changed, 35 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/7f5e278f/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java
index 730c913..bb87e81 100644
--- a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java
+++ b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java
@@ -431,35 +431,37 @@ public class JolokiaCamelController extends AbstractCamelController implements R
J4pExecResponse response = jolokia.execute(new J4pExecRequest(on, "listRestServices()"));
if (response != null) {
- JSONObject data = response.asJSONObject();
- // TODO: parse the open data type
- }
+ JSONObject data = response.getValue();
+ for (Object obj : data.values()) {
+ JSONObject data2 = (JSONObject) obj;
+ JSONObject service = (JSONObject) data2.values().iterator().next();
- /*
- List<RestRegistry.RestService> services = new ArrayList<RestRegistry.RestService>(context.getRestRegistry().listAllRestServices());
- Collections.sort(services, new Comparator<RestRegistry.RestService>() {
- @Override
- public int compare(RestRegistry.RestService o1, RestRegistry.RestService o2) {
- return o1.getUrl().compareTo(o2.getUrl());
- }
- });
- for (RestRegistry.RestService service : services) {
Map<String, String> row = new LinkedHashMap<String, String>();
- row.put("basePath", service.getBasePath());
- row.put("baseUrl", service.getBaseUrl());
- row.put("consumes", service.getConsumes());
- row.put("description", service.getDescription());
- row.put("inType", service.getInType());
- row.put("method", service.getMethod());
- row.put("outType", service.getOutType());
- row.put("produces", service.getProduces());
- row.put("routeId", service.getRouteId());
- row.put("state", service.getState());
- row.put("uriTemplate", service.getUriTemplate());
- row.put("url", service.getUrl());
+ row.put("basePath", asString(service.get("basePath")));
+ row.put("baseUrl", asString(service.get("baseUrl")));
+ row.put("consumes", asString(service.get("consumes")));
+ row.put("description", asString(service.get("description")));
+ row.put("inType", asString(service.get("inType")));
+ row.put("method", asString(service.get("method")));
+ row.put("outType", asString(service.get("outType")));
+ row.put("produces", asString(service.get("produces")));
+ row.put("routeId", asString(service.get("routeId")));
+ row.put("state", asString(service.get("state")));
+ row.put("uriTemplate", asString(service.get("uriTemplate")));
+ row.put("url", asString(service.get("url")));
answer.add(row);
}
- } */
+ }
+
+ // sort the list
+ Collections.sort(answer, new Comparator<Map<String, String>>() {
+ @Override
+ public int compare(Map<String, String> service1, Map<String, String> service2) {
+ String url1 = service1.get("url");
+ String url2 = service2.get("url");
+ return url1.compareTo(url2);
+ }
+ });
}
return answer;
@@ -499,4 +501,12 @@ public class JolokiaCamelController extends AbstractCamelController implements R
return ch + attributeKey.substring(1);
}
+ private static String asString(Object basePath) {
+ if (basePath == null) {
+ return null;
+ } else {
+ return basePath.toString();
+ }
+ }
+
}
[4/6] camel git commit: CAMEL-8044: Camel commands useable for remote
JVMs using jolokia
Posted by da...@apache.org.
CAMEL-8044: Camel commands useable for remote JVMs using jolokia
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f030c8bf
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f030c8bf
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f030c8bf
Branch: refs/heads/master
Commit: f030c8bf87160457a92105a80ebf69ac4758fe62
Parents: 636c6fc
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Dec 11 17:03:21 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Dec 11 18:56:10 2014 +0100
----------------------------------------------------------------------
.../jolokia/JolokiaCamelController.java | 78 ++++++++++++++++++--
.../commands/jolokia/JolokiaRemoteTest.java | 43 +++++++++++
2 files changed, 113 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/f030c8bf/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java
index dd034cc..3dc86d2 100644
--- a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java
+++ b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java
@@ -272,59 +272,121 @@ public class JolokiaCamelController extends AbstractCamelController implements R
}
@Override
- public void startRoute(String s, String s2) throws Exception {
+ public void startRoute(String camelContextName, String routeId) throws Exception {
if (jolokia == null) {
throw new IllegalStateException("Need to connect to remote jolokia first");
}
+
+ ObjectName found = lookupCamelContext(camelContextName);
+ if (found != null) {
+ String pattern = String.format("%s:context=%s,type=routes,name=\"%s\"", found.getDomain(), found.getKeyProperty("context"), routeId);
+ ObjectName on = ObjectName.getInstance(pattern);
+ jolokia.execute(new J4pExecRequest(on, "start()"));
+ }
}
@Override
- public void stopRoute(String s, String s2) throws Exception {
+ public void stopRoute(String camelContextName, String routeId) throws Exception {
if (jolokia == null) {
throw new IllegalStateException("Need to connect to remote jolokia first");
}
+
+ ObjectName found = lookupCamelContext(camelContextName);
+ if (found != null) {
+ String pattern = String.format("%s:context=%s,type=routes,name=\"%s\"", found.getDomain(), found.getKeyProperty("context"), routeId);
+ ObjectName on = ObjectName.getInstance(pattern);
+ jolokia.execute(new J4pExecRequest(on, "stop()"));
+ }
}
@Override
- public void suspendRoute(String s, String s2) throws Exception {
+ public void suspendRoute(String camelContextName, String routeId) throws Exception {
if (jolokia == null) {
throw new IllegalStateException("Need to connect to remote jolokia first");
}
+
+ ObjectName found = lookupCamelContext(camelContextName);
+ if (found != null) {
+ String pattern = String.format("%s:context=%s,type=routes,name=\"%s\"", found.getDomain(), found.getKeyProperty("context"), routeId);
+ ObjectName on = ObjectName.getInstance(pattern);
+ jolokia.execute(new J4pExecRequest(on, "suspend()"));
+ }
}
@Override
- public void resumeRoute(String s, String s2) throws Exception {
+ public void resumeRoute(String camelContextName, String routeId) throws Exception {
if (jolokia == null) {
throw new IllegalStateException("Need to connect to remote jolokia first");
}
+
+ ObjectName found = lookupCamelContext(camelContextName);
+ if (found != null) {
+ String pattern = String.format("%s:context=%s,type=routes,name=\"%s\"", found.getDomain(), found.getKeyProperty("context"), routeId);
+ ObjectName on = ObjectName.getInstance(pattern);
+ jolokia.execute(new J4pExecRequest(on, "resume()"));
+ }
}
@Override
- public String getRouteModelAsXml(String s, String s2) throws Exception {
+ public String getRouteModelAsXml(String camelContextName, String routeId) throws Exception {
if (jolokia == null) {
throw new IllegalStateException("Need to connect to remote jolokia first");
}
+
+ ObjectName found = lookupCamelContext(camelContextName);
+ if (found != null) {
+ String pattern = String.format("%s:context=%s,type=routes,name=\"%s\"", found.getDomain(), found.getKeyProperty("context"), routeId);
+ ObjectName on = ObjectName.getInstance(pattern);
+ J4pExecResponse response = jolokia.execute(new J4pExecRequest(on, "dumpRouteAsXml()"));
+ if (response != null) {
+ String xml = response.getValue();
+ return xml;
+ }
+ }
+
return null;
}
@Override
- public String getRouteStatsAsXml(String s, String s2, boolean b, boolean b2) throws Exception {
+ public String getRouteStatsAsXml(String camelContextName, String routeId, boolean fullStats, boolean includeProcessors) throws Exception {
if (jolokia == null) {
throw new IllegalStateException("Need to connect to remote jolokia first");
}
+
+ ObjectName found = lookupCamelContext(camelContextName);
+ if (found != null) {
+ String pattern = String.format("%s:context=%s,type=routes,name=\"%s\"", found.getDomain(), found.getKeyProperty("context"), routeId);
+ ObjectName on = ObjectName.getInstance(pattern);
+ J4pExecResponse response = jolokia.execute(new J4pExecRequest(on, "dumpRouteStatsAsXml(boolean,boolean)", fullStats, includeProcessors));
+ if (response != null) {
+ String xml = response.getValue();
+ return xml;
+ }
+ }
+
return null;
}
@Override
- public List<Map<String, String>> getEndpoints(String s) throws Exception {
+ public String getRestModelAsXml(String camelContextName) throws Exception {
if (jolokia == null) {
throw new IllegalStateException("Need to connect to remote jolokia first");
}
+
+ ObjectName found = lookupCamelContext(camelContextName);
+ if (found != null) {
+ J4pExecResponse response = jolokia.execute(new J4pExecRequest(found, "dumpRestsAsXml()"));
+ if (response != null) {
+ String xml = response.getValue();
+ return xml;
+ }
+ }
+
return null;
}
@Override
- public String getRestModelAsXml(String s) throws Exception {
+ public List<Map<String, String>> getEndpoints(String s) throws Exception {
if (jolokia == null) {
throw new IllegalStateException("Need to connect to remote jolokia first");
}
http://git-wip-us.apache.org/repos/asf/camel/blob/f030c8bf/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java b/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
index 52048b4..86656be 100644
--- a/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
+++ b/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
@@ -107,4 +107,47 @@ public class JolokiaRemoteTest {
controller.resetRouteStats("myCamel");
}
+ @Test
+ public void testRemoteRouteControl() throws Exception {
+ controller = new JolokiaCamelController();
+ controller.connect(url, null, null);
+
+ controller.suspendRoute("myCamel", "route2");
+ List<Map<String, String>> data = controller.getRoutes("myCamel", "route2");
+ System.out.println(data);
+
+ Thread.sleep(500);
+
+ controller.resumeRoute("myCamel", "route2");
+ data = controller.getRoutes("myCamel", "route2");
+ System.out.println(data);
+ }
+
+ @Test
+ public void testRouteModel() throws Exception {
+ controller = new JolokiaCamelController();
+ controller.connect(url, null, null);
+
+ String data = controller.getRouteModelAsXml("myCamel", "route2");
+ System.out.println(data);
+ }
+
+ @Test
+ public void testRouteStats() throws Exception {
+ controller = new JolokiaCamelController();
+ controller.connect(url, null, null);
+
+ String data = controller.getRouteStatsAsXml("myCamel", "route2", true, true);
+ System.out.println(data);
+ }
+
+ @Test
+ public void testRestsModel() throws Exception {
+ controller = new JolokiaCamelController();
+ controller.connect(url, null, null);
+
+ String data = controller.getRestModelAsXml("myCamel");
+ System.out.println(data);
+ }
+
}
[5/6] camel git commit: Fixed number of index was wrong on the mbean
open type
Posted by da...@apache.org.
Fixed number of index was wrong on the mbean open type
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/57b91f81
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/57b91f81
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/57b91f81
Branch: refs/heads/master
Commit: 57b91f81aabca8d39923e6ac0e77dab323127c37
Parents: 7f5e278
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Dec 11 18:55:37 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Dec 11 18:56:10 2014 +0100
----------------------------------------------------------------------
.../apache/camel/api/management/mbean/CamelOpenMBeanTypes.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/57b91f81/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java b/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
index c2dfa59..f0fad68 100644
--- a/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
+++ b/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
@@ -68,7 +68,7 @@ public final class CamelOpenMBeanTypes {
public static TabularType explainEndpointTabularType() throws OpenDataException {
CompositeType ct = explainEndpointsCompositeType();
- return new TabularType("explainEndpoint", "Explain how this endpoint is configured", ct, new String[]{"option", "kind", "type", "java type", "value", "default value", "description"});
+ return new TabularType("explainEndpoint", "Explain how this endpoint is configured", ct, new String[]{"option"});
}
public static CompositeType explainEndpointsCompositeType() throws OpenDataException {
@@ -79,7 +79,7 @@ public final class CamelOpenMBeanTypes {
public static TabularType listComponentsTabularType() throws OpenDataException {
CompositeType ct = listComponentsCompositeType();
- return new TabularType("listComponents", "Lists all the components", ct, new String[]{"name", "description", "label", "status", "type", "groupId", "artifactId", "version"});
+ return new TabularType("listComponents", "Lists all the components", ct, new String[]{"name"});
}
public static CompositeType listComponentsCompositeType() throws OpenDataException {
[6/6] camel git commit: CAMEL-8044: Camel commands useable for remote
JVMs using jolokia
Posted by da...@apache.org.
CAMEL-8044: Camel commands useable for remote JVMs using jolokia
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3636e302
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3636e302
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3636e302
Branch: refs/heads/master
Commit: 3636e302ecd9f67f758dae644e474c13ae06a07a
Parents: f030c8b
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Dec 11 17:24:22 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Dec 11 18:56:10 2014 +0100
----------------------------------------------------------------------
.../jolokia/JolokiaCamelController.java | 89 ++++++++++++++++++--
.../commands/jolokia/JolokiaRemoteTest.java | 27 ++++++
2 files changed, 110 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/3636e302/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java
index 3dc86d2..730c913 100644
--- a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java
+++ b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java
@@ -34,6 +34,7 @@ import org.jolokia.client.request.J4pReadRequest;
import org.jolokia.client.request.J4pReadResponse;
import org.jolokia.client.request.J4pSearchRequest;
import org.jolokia.client.request.J4pSearchResponse;
+import org.json.simple.JSONObject;
/**
* A {@link org.apache.camel.commands.CamelController} that uses Jolokia Client to connect to remote JVMs which
@@ -386,34 +387,110 @@ public class JolokiaCamelController extends AbstractCamelController implements R
}
@Override
- public List<Map<String, String>> getEndpoints(String s) throws Exception {
+ public List<Map<String, String>> getEndpoints(String camelContextName) throws Exception {
if (jolokia == null) {
throw new IllegalStateException("Need to connect to remote jolokia first");
}
- return null;
+
+ List<Map<String, String>> answer = new ArrayList<Map<String, String>>();
+
+ ObjectName found = lookupCamelContext(camelContextName);
+ if (found != null) {
+ J4pSearchResponse sr = jolokia.execute(new J4pSearchRequest("*:type=endpoints,*"));
+
+ List<J4pReadRequest> list = new ArrayList<J4pReadRequest>();
+ for (ObjectName on : sr.getObjectNames()) {
+ list.add(new J4pReadRequest(on, "CamelId", "EndpointUri", "State"));
+ }
+
+ List<J4pReadResponse> lrr = jolokia.execute(list);
+ for (J4pReadResponse rr : lrr) {
+ Map<String, String> row = new LinkedHashMap<String, String>();
+ row.put("camelContextName", rr.getValue("CamelId").toString());
+ row.put("uri", rr.getValue("EndpointUri").toString());
+ row.put("state", rr.getValue("State").toString());
+ answer.add(row);
+ }
+ }
+
+ return answer;
}
@Override
- public List<Map<String, String>> getRestServices(String s) throws Exception {
+ public List<Map<String, String>> getRestServices(String camelContextName) throws Exception {
if (jolokia == null) {
throw new IllegalStateException("Need to connect to remote jolokia first");
}
- return null;
+
+ List<Map<String, String>> answer = new ArrayList<Map<String, String>>();
+
+ ObjectName found = lookupCamelContext(camelContextName);
+ if (found != null) {
+ String pattern = String.format("%s:context=%s,type=services,name=DefaultRestRegistry", found.getDomain(), found.getKeyProperty("context"));
+ ObjectName on = ObjectName.getInstance(pattern);
+
+ J4pExecResponse response = jolokia.execute(new J4pExecRequest(on, "listRestServices()"));
+ if (response != null) {
+ JSONObject data = response.asJSONObject();
+ // TODO: parse the open data type
+ }
+
+ /*
+ List<RestRegistry.RestService> services = new ArrayList<RestRegistry.RestService>(context.getRestRegistry().listAllRestServices());
+ Collections.sort(services, new Comparator<RestRegistry.RestService>() {
+ @Override
+ public int compare(RestRegistry.RestService o1, RestRegistry.RestService o2) {
+ return o1.getUrl().compareTo(o2.getUrl());
+ }
+ });
+ for (RestRegistry.RestService service : services) {
+ Map<String, String> row = new LinkedHashMap<String, String>();
+ row.put("basePath", service.getBasePath());
+ row.put("baseUrl", service.getBaseUrl());
+ row.put("consumes", service.getConsumes());
+ row.put("description", service.getDescription());
+ row.put("inType", service.getInType());
+ row.put("method", service.getMethod());
+ row.put("outType", service.getOutType());
+ row.put("produces", service.getProduces());
+ row.put("routeId", service.getRouteId());
+ row.put("state", service.getState());
+ row.put("uriTemplate", service.getUriTemplate());
+ row.put("url", service.getUrl());
+ answer.add(row);
+ }
+ } */
+ }
+
+ return answer;
}
@Override
- public String explainEndpointAsJSon(String s, String s2, boolean b) throws Exception {
+ public String explainEndpointAsJSon(String camelContextName, String uri, boolean allOptions) throws Exception {
if (jolokia == null) {
throw new IllegalStateException("Need to connect to remote jolokia first");
}
+
+ ObjectName found = lookupCamelContext(camelContextName);
+ if (found != null) {
+ J4pExecResponse response = jolokia.execute(new J4pExecRequest(found, "explainEndpointJson(java.lang.String,boolean)", uri, allOptions));
+ if (response != null) {
+ String json = response.getValue();
+ return json;
+ }
+ }
+
return null;
}
@Override
- public List<Map<String, String>> listComponents(String s) throws Exception {
+ public List<Map<String, String>> listComponents(String camelContextName) throws Exception {
if (jolokia == null) {
throw new IllegalStateException("Need to connect to remote jolokia first");
}
+
+ // TODO: implement me
+
return null;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/3636e302/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java b/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
index 86656be..2afc2c2 100644
--- a/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
+++ b/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
@@ -150,4 +150,31 @@ public class JolokiaRemoteTest {
System.out.println(data);
}
+ @Test
+ public void testGetEndpoints() throws Exception {
+ controller = new JolokiaCamelController();
+ controller.connect(url, null, null);
+
+ List<Map<String, String>> data = controller.getEndpoints("myCamel");
+ System.out.println(data);
+ }
+
+ @Test
+ public void testGetRestServices() throws Exception {
+ controller = new JolokiaCamelController();
+ controller.connect(url, null, null);
+
+ List<Map<String, String>> data = controller.getRestServices("myCamel");
+ System.out.println(data);
+ }
+
+ @Test
+ public void testExplainEndpointJson() throws Exception {
+ controller = new JolokiaCamelController();
+ controller.connect(url, null, null);
+
+ String data = controller.explainEndpointAsJSon("myCamel", "log:foo", true);
+ System.out.println(data);
+ }
+
}