This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new 0f24169 CAMEL-13193: camel3 - Remove deprecate jolokia commands 0f24169 is described below commit 0f2416909e7d3d29e997c76ee4252e6b0757823b Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Wed Feb 13 16:31:03 2019 +0100 CAMEL-13193: camel3 - Remove deprecate jolokia commands --- apache-camel/pom.xml | 4 - apache-camel/src/main/descriptors/common-bin.xml | 1 - bom/camel-bom/pom.xml | 5 - parent/pom.xml | 5 - platforms/commands/commands-jolokia/pom.xml | 85 -- .../jolokia/DefaultJolokiaCamelController.java | 898 --------------------- .../commands/jolokia/JolokiaCamelController.java | 48 -- .../commands/jolokia/JolokiaClientFactory.java | 53 -- .../camel/commands/jolokia/NoopStringEscape.java | 37 - .../src/main/resources/LICENSE.txt | 203 ----- .../commands-jolokia/src/main/resources/NOTICE.txt | 11 - .../commands/jolokia/JolokiaCommandsTest.java | 143 ---- .../camel/commands/jolokia/JolokiaRemoteTest.java | 225 ------ .../src/test/resources/log4j2.properties | 30 - platforms/commands/pom.xml | 1 - .../camel-spring-boot-dependencies/pom.xml | 5 - 16 files changed, 1754 deletions(-) diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml index 8994b85..45e6c31 100644 --- a/apache-camel/pom.xml +++ b/apache-camel/pom.xml @@ -2820,10 +2820,6 @@ <artifactId>camel-commands-core</artifactId> </dependency> <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-commands-jolokia</artifactId> - </dependency> - <dependency> <groupId>org.apache.camel.karaf</groupId> <artifactId>camel-karaf-commands</artifactId> </dependency> diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml index 0b09ed7..9fb4be9 100644 --- a/apache-camel/src/main/descriptors/common-bin.xml +++ b/apache-camel/src/main/descriptors/common-bin.xml @@ -343,7 +343,6 @@ <include>org.apache.camel:camel-catalog-provider-karaf</include> <include>org.apache.camel:camel-catalog-provider-springboot</include> <include>org.apache.camel:camel-commands-core</include> - <include>org.apache.camel:camel-commands-jolokia</include> <include>org.apache.camel.karaf:camel-karaf-commands</include> <include>org.apache.camel:camel-route-parser</include> </includes> diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml index ca08c47..ceaf59b 100644 --- a/bom/camel-bom/pom.xml +++ b/bom/camel-bom/pom.xml @@ -423,11 +423,6 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-commands-jolokia</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> <artifactId>camel-consul</artifactId> <version>${project.version}</version> </dependency> diff --git a/parent/pom.xml b/parent/pom.xml index 4e7404e..3b1cc7b 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -3643,11 +3643,6 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-commands-jolokia</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> <groupId>org.apache.camel.karaf</groupId> <artifactId>camel-karaf-commands</artifactId> <version>${project.version}</version> diff --git a/platforms/commands/commands-jolokia/pom.xml b/platforms/commands/commands-jolokia/pom.xml deleted file mode 100644 index 2ed7bec..0000000 --- a/platforms/commands/commands-jolokia/pom.xml +++ /dev/null @@ -1,85 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<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>3.0.0-SNAPSHOT</version> - </parent> - - <artifactId>camel-commands-jolokia</artifactId> - <packaging>jar</packaging> - <name>Camel :: Platforms :: Commands :: Jolokia (deprecated)</name> - <description>Camel Commands using Jolokia</description> - - <properties> - <!-- use by camel-catalog --> - <firstVersion>2.15.0</firstVersion> - <label>tooling</label> - - <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> - - <!-- 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> - - <!-- logging --> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-api</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-slf4j-impl</artifactId> - <scope>test</scope> - </dependency> - - - </dependencies> - -</project> diff --git a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/DefaultJolokiaCamelController.java b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/DefaultJolokiaCamelController.java deleted file mode 100644 index 397ec20..0000000 --- a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/DefaultJolokiaCamelController.java +++ /dev/null @@ -1,898 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS 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.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import javax.management.InstanceNotFoundException; -import javax.management.ObjectName; - -import org.apache.camel.commands.AbstractCamelController; - -import org.jolokia.client.J4pClient; -import org.jolokia.client.exception.J4pException; -import org.jolokia.client.exception.J4pRemoteException; -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; -import org.jolokia.client.request.J4pVersionRequest; -import org.jolokia.client.request.J4pVersionResponse; -import org.json.simple.JSONObject; - -/** - * A {@link org.apache.camel.commands.CamelController} that uses Jolokia Client to connect to remote JVMs which - * has an Jolokia agent running. - */ -public class DefaultJolokiaCamelController extends AbstractCamelController implements JolokiaCamelController { - - private Map<String, ObjectName> cache = new HashMap<>(100); - - 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 = removeLeadingAndEndingQuotes(id); - if (camelContextName.equals(id)) { - found = name; - break; - } - } - } - if (found != null) { - on = found; - cache.put(camelContextName, on); - } - } - return on; - } - - @Override - public void using(J4pClient client) { - this.jolokia = client; - this.url = null; - } - - @Override - public void connect(String url, String username, String password) throws Exception { - this.jolokia = JolokiaClientFactory.createJolokiaClient(url, username, password); - this.url = url; - } - - @Override - public boolean ping() { - if (jolokia == null) { - throw new IllegalStateException("Need to connect to remote jolokia first"); - } - - J4pVersionResponse vr; - try { - vr = jolokia.execute(new J4pVersionRequest()); - return vr != null && vr.getValue() != null; - } catch (J4pException e) { - return false; - } - } - - @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<>(); - - ObjectName found = lookupCamelContext(camelContextName); - if (found != null) { - - String pattern = String.format("%s:context=%s,type=services,name=DefaultTypeConverter", found.getDomain(), found.getKeyProperty("context")); - ObjectName tc = ObjectName.getInstance(pattern); - - String pattern2 = String.format("%s:context=%s,type=services,name=DefaultAsyncProcessorAwaitManager", found.getDomain(), found.getKeyProperty("context")); - ObjectName am = ObjectName.getInstance(pattern2); - - List<J4pReadRequest> list = new ArrayList<>(); - list.add(new J4pReadRequest(found)); - list.add(new J4pReadRequest(tc)); - list.add(new J4pReadRequest(am)); - - List<J4pReadResponse> rr = jolokia.execute(list); - if (rr != null && rr.size() > 0) { - // camel context attributes - J4pReadResponse first = rr.get(0); - for (String key : first.getAttributes()) { - answer.put(asKey(key), first.getValue(key)); - } - - // type converter attributes - if (rr.size() >= 2) { - J4pReadResponse second = rr.get(1); - for (String key : second.getAttributes()) { - answer.put("typeConverter." + asKey(key), second.getValue(key)); - } - } - - // async processor await manager attributes - if (rr.size() >= 3) { - J4pReadResponse second = rr.get(2); - for (String key : second.getAttributes()) { - answer.put("asyncProcessorAwaitManager." + asKey(key), second.getValue(key)); - } - } - } - - // would be great if there was an api in jolokia to read optional (eg ignore if an mbean does not exists) - answer.put("streamCachingEnabled", false); - try { - pattern = String.format("%s:context=%s,type=services,name=DefaultStreamCachingStrategy", found.getDomain(), found.getKeyProperty("context")); - ObjectName sc = ObjectName.getInstance(pattern); - - // there is only a mbean if stream caching is enabled - J4pReadResponse rsc = jolokia.execute(new J4pReadRequest(sc)); - if (rsc != null) { - for (String key : rsc.getAttributes()) { - answer.put("streamCaching." + asKey(key), rsc.getValue(key)); - } - } - answer.put("streamCachingEnabled", true); - } catch (J4pRemoteException e) { - // ignore - boolean ignore = InstanceNotFoundException.class.getName().equals(e.getErrorType()); - if (!ignore) { - throw e; - } - } - - // store some data using special names as that is what the core-commands expects - answer.put("name", answer.get("camelId")); - answer.put("status", answer.get("state")); - answer.put("version", answer.get("camelVersion")); - answer.put("suspended", "Suspended".equals(answer.get("state"))); - TimeUnit unit = TimeUnit.valueOf((String) answer.get("timeUnit")); - long timeout = (Long) answer.get("timeout"); - answer.put("shutdownTimeout", "" + unit.toSeconds(timeout)); - answer.put("applicationContextClassLoader", answer.get("applicationContextClassName")); - answer.put("HeadersMapFactory", answer.get("headersMapFactoryClassName")); - } - - 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<>(); - - J4pSearchResponse sr = jolokia.execute(new J4pSearchRequest("*:type=context,*")); - - List<J4pReadRequest> list = new ArrayList<>(); - for (ObjectName on : sr.getObjectNames()) { - list.add(new J4pReadRequest(on, "CamelId", "State", "Uptime", "ExchangesTotal", "ExchangesInflight", "ExchangesFailed")); - } - - List<J4pReadResponse> lrr = jolokia.execute(list); - for (J4pReadResponse rr : lrr) { - Map<String, String> row = new LinkedHashMap<>(); - row.put("name", rr.getValue("CamelId").toString()); - row.put("state", rr.getValue("State").toString()); - row.put("uptime", rr.getValue("Uptime").toString()); - row.put("exchangesTotal", rr.getValue("ExchangesTotal").toString()); - row.put("exchangesInflight", rr.getValue("ExchangesInflight").toString()); - row.put("exchangesFailed", rr.getValue("ExchangesFailed").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 List<Map<String, Object>> browseInflightExchanges(String camelContextName, String route, int limit, boolean sortByLongestDuration) throws Exception { - if (jolokia == null) { - throw new IllegalStateException("Need to connect to remote jolokia first"); - } - - List<Map<String, Object>> answer = new ArrayList<>(); - - ObjectName found = lookupCamelContext(camelContextName); - if (found != null) { - String pattern = String.format("%s:context=%s,type=services,name=DefaultInflightRepository", found.getDomain(), found.getKeyProperty("context")); - ObjectName on = ObjectName.getInstance(pattern); - J4pExecResponse er = jolokia.execute(new J4pExecRequest(on, "browse(String,int,boolean)", route, limit, sortByLongestDuration)); - if (er != null) { - JSONObject data = er.getValue(); - if (data != null) { - for (Object obj : data.values()) { - JSONObject inflight = (JSONObject) obj; - - Map<String, Object> row = new LinkedHashMap<>(); - row.put("exchangeId", asString(inflight.get("exchangeId"))); - row.put("fromRouteId", asString(inflight.get("fromRouteId"))); - row.put("routeId", asString(inflight.get("routeId"))); - row.put("nodeId", asString(inflight.get("nodeId"))); - row.put("elapsed", asString(inflight.get("elapsed"))); - row.put("duration", asString(inflight.get("duration"))); - answer.add(row); - } - } - } - } - - return answer; - } - - @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<>(); - - ObjectName found = camelContextName != null ? lookupCamelContext(camelContextName) : null; - if (found != null) { - - String pattern = String.format("%s:context=%s,type=routes,*", found.getDomain(), found.getKeyProperty("context")); - J4pSearchResponse sr = jolokia.execute(new J4pSearchRequest(pattern)); - - List<J4pReadRequest> list = new ArrayList<>(); - for (ObjectName on : sr.getObjectNames()) { - list.add(new J4pReadRequest(on, "CamelId", "RouteId", "State", "Uptime", "ExchangesTotal", "ExchangesInflight", "ExchangesFailed")); - } - - 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<>(); - row.put("camelContextName", rr.getValue("CamelId").toString()); - row.put("routeId", routeId); - row.put("state", rr.getValue("State").toString()); - row.put("uptime", rr.getValue("Uptime").toString()); - row.put("exchangesTotal", rr.getValue("ExchangesTotal").toString()); - row.put("exchangesInflight", rr.getValue("ExchangesInflight").toString()); - row.put("exchangesFailed", rr.getValue("ExchangesFailed").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<>(); - for (ObjectName on : sr.getObjectNames()) { - list.add(new J4pExecRequest(on, "reset(boolean)", true)); - } - - jolokia.execute(list); - } - } - - @Override - 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 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 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 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 routeId, 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=\"%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 routeId, 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) { - 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 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 getRestApiDocAsJson(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=services,name=DefaultRestRegistry", found.getDomain(), found.getKeyProperty("context")); - ObjectName on = ObjectName.getInstance(pattern); - - J4pExecResponse response = jolokia.execute(new J4pExecRequest(on, "apiDocAsJson()")); - if (response != null) { - String json = response.getValue(); - return json; - } - } - - return null; - } - - @Override - public List<Map<String, String>> getEndpoints(String camelContextName) throws Exception { - if (jolokia == null) { - throw new IllegalStateException("Need to connect to remote jolokia first"); - } - - List<Map<String, String>> answer = new ArrayList<>(); - - ObjectName found = lookupCamelContext(camelContextName); - if (found != null) { - String pattern = String.format("%s:context=%s,type=endpoints,*", found.getDomain(), found.getKeyProperty("context")); - J4pSearchResponse sr = jolokia.execute(new J4pSearchRequest(pattern)); - - List<J4pReadRequest> list = new ArrayList<>(); - 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<>(); - 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>> getEndpointRuntimeStatistics(String camelContextName) throws Exception { - if (jolokia == null) { - throw new IllegalStateException("Need to connect to remote jolokia first"); - } - - List<Map<String, String>> answer = new ArrayList<>(); - - ObjectName found = lookupCamelContext(camelContextName); - if (found != null) { - String pattern = String.format("%s:context=%s,type=services,name=DefaultRuntimeEndpointRegistry", found.getDomain(), found.getKeyProperty("context")); - ObjectName on = ObjectName.getInstance(pattern); - - J4pExecResponse response = jolokia.execute(new J4pExecRequest(on, "endpointStatistics()")); - if (response != null) { - JSONObject data = response.getValue(); - for (Object obj : data.values()) { - JSONObject data2 = (JSONObject) obj; - JSONObject service = (JSONObject) data2.values().iterator().next(); - - Map<String, String> row = new LinkedHashMap<>(); - row.put("index", asString(service.get("index"))); - row.put("url", asString(service.get("url"))); - row.put("routeId", asString(service.get("routeId"))); - row.put("direction", asString(service.get("direction"))); - row.put("static", asString(service.get("static"))); - row.put("dynamic", asString(service.get("dynamic"))); - row.put("hits", asString(service.get("hits"))); - answer.add(row); - } - } - - // sort the list - Collections.sort(answer, new Comparator<Map<String, String>>() { - @Override - public int compare(Map<String, String> endpoint1, Map<String, String> endpoint2) { - // sort by route id - String route1 = endpoint1.get("routeId"); - String route2 = endpoint2.get("routeId"); - int num = route1.compareTo(route2); - if (num == 0) { - // we want in before out - String dir1 = endpoint1.get("direction"); - String dir2 = endpoint2.get("direction"); - num = dir1.compareTo(dir2); - } - return num; - } - - }); - } - - return answer; - } - - @Override - public List<Map<String, String>> getRestServices(String camelContextName) throws Exception { - if (jolokia == null) { - throw new IllegalStateException("Need to connect to remote jolokia first"); - } - - List<Map<String, String>> answer = new ArrayList<>(); - - 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.getValue(); - if (data != null) { - for (Object obj : data.values()) { - JSONObject data2 = (JSONObject) obj; - JSONObject service = (JSONObject) data2.values().iterator().next(); - - Map<String, String> row = new LinkedHashMap<>(); - 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; - } - - @Override - 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 String explainEipAsJSon(String camelContextName, String nameOrId, 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, "explainEipJson(java.lang.String,boolean)", nameOrId, allOptions)); - if (response != null) { - String json = response.getValue(); - return json; - } - } - - return null; - } - - @Override - public List<Map<String, String>> listComponents(String camelContextName) throws Exception { - if (jolokia == null) { - throw new IllegalStateException("Need to connect to remote jolokia first"); - } - - List<Map<String, String>> answer = new ArrayList<>(); - - 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 component = (JSONObject) obj; - - Map<String, String> row = new LinkedHashMap<>(); - row.put("artifactId", asString(component.get("artifactId"))); - row.put("title", asString(component.get("title"))); - 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; - } - - @Override - public List<Map<String, String>> getTransformers(String camelContextName) throws Exception { - if (jolokia == null) { - throw new IllegalStateException("Need to connect to remote jolokia first"); - } - - List<Map<String, String>> answer = new ArrayList<>(); - - ObjectName found = lookupCamelContext(camelContextName); - if (found != null) { - String pattern = String.format("%s:context=%s,type=services,name=DefaultTransformerRegistry", found.getDomain(), found.getKeyProperty("context")); - ObjectName on = ObjectName.getInstance(pattern); - - J4pExecResponse response = jolokia.execute(new J4pExecRequest(on, "listTransformers()")); - if (response != null) { - JSONObject data = response.getValue(); - if (data != null) { - for (Object obj : data.values()) { - JSONObject data2 = (JSONObject) obj; - JSONObject service = (JSONObject) data2.values().iterator().next(); - - Map<String, String> row = new LinkedHashMap<>(); - row.put("scheme", asString(service.get("scheme"))); - row.put("from", asString(service.get("from"))); - row.put("to", asString(service.get("to"))); - row.put("static", asString(service.get("static"))); - row.put("dynamic", asString(service.get("dynamic"))); - row.put("description", asString(service.get("description"))); - 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 scheme1 = service1.get("scheme"); - String scheme2 = service2.get("scheme"); - if (scheme1 != null && scheme2 != null) { - return scheme1.compareTo(scheme2); - } else if (scheme1 != null) { - return -1; - } else if (scheme2 != null) { - return 1; - } else { - String from1 = service1.get("from"); - String from2 = service2.get("from"); - if (from1.equals(from2)) { - String to1 = service1.get("to"); - String to2 = service2.get("to"); - return to1.compareTo(to2); - } - return from1.compareTo(from2); - } - } - }); - } - return answer; - } - - @Override - public List<Map<String, String>> getValidators(String camelContextName) throws Exception { - if (jolokia == null) { - throw new IllegalStateException("Need to connect to remote jolokia first"); - } - - List<Map<String, String>> answer = new ArrayList<>(); - - ObjectName found = lookupCamelContext(camelContextName); - if (found != null) { - String pattern = String.format("%s:context=%s,type=services,name=DefaultValidatorRegistry", found.getDomain(), found.getKeyProperty("context")); - ObjectName on = ObjectName.getInstance(pattern); - - J4pExecResponse response = jolokia.execute(new J4pExecRequest(on, "listValidators()")); - if (response != null) { - JSONObject data = response.getValue(); - if (data != null) { - for (Object obj : data.values()) { - JSONObject data2 = (JSONObject) obj; - JSONObject service = (JSONObject) data2.values().iterator().next(); - - Map<String, String> row = new LinkedHashMap<>(); - row.put("type", asString(service.get("type"))); - row.put("static", asString(service.get("static"))); - row.put("dynamic", asString(service.get("dynamic"))); - row.put("description", asString(service.get("description"))); - 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 type1 = service1.get("type"); - String type2 = service2.get("type"); - return type1.compareTo(type2); - } - }); - } - return answer; - } - - private static String asKey(String attributeKey) { - char ch = Character.toLowerCase(attributeKey.charAt(0)); - return ch + attributeKey.substring(1); - } - - private static String asString(Object basePath) { - if (basePath == null) { - return null; - } else { - return basePath.toString(); - } - } - - private static String removeLeadingAndEndingQuotes(String s) { - if (s == null || s.isEmpty()) { - return s; - } - - String copy = s.trim(); - if (copy.startsWith("'") && copy.endsWith("'")) { - return copy.substring(1, copy.length() - 1); - } - if (copy.startsWith("\"") && copy.endsWith("\"")) { - return copy.substring(1, copy.length() - 1); - } - - // no quotes, so return as-is - return s; - } - -} 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 deleted file mode 100644 index 974cbcc..0000000 --- a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaCamelController.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.commands.jolokia; - -import org.apache.camel.commands.CamelController; -import org.jolokia.client.J4pClient; - -public interface JolokiaCamelController extends CamelController { - - /** - * To use the existing {@link org.jolokia.client.J4pClient} with this controller. - * - * @param client the client to use - */ - void using(J4pClient client); - - /** - * 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; - - /** - * After connecting the ping command can be used to check if the connection works. - * - * @return <tt>true</tt> if connection works, <tt>false</tt> otherwise - */ - boolean ping(); - -} 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 deleted file mode 100644 index 96d6c54..0000000 --- a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/JolokiaClientFactory.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.commands.jolokia; - -import org.jolokia.client.BasicAuthenticator; -import org.jolokia.client.J4pClient; -import org.jolokia.client.J4pClientBuilder; -import org.jolokia.client.J4pClientBuilderFactory; - -/** - * A factory to create a {@link org.jolokia.client.J4pClient} jolokia client that connects to a remote JVM. - */ -public final class JolokiaClientFactory { - - private JolokiaClientFactory() { - } - - public static J4pClient createJolokiaClient(String jolokiaUrl, String username, String password) { - J4pClientBuilder builder = J4pClientBuilderFactory.url(jolokiaUrl); - boolean auth = false; - if (isNotEmpty(username)) { - builder = builder.user(username); - auth = true; - } - if (isNotEmpty(password)) { - builder = builder.password(password); - auth = true; - } - if (auth) { - builder = builder.authenticator(new BasicAuthenticator(true)); - } - return builder.build(); - } - - private static boolean isNotEmpty(String text) { - return text != null && !text.isEmpty(); - } - -} diff --git a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/NoopStringEscape.java b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/NoopStringEscape.java deleted file mode 100644 index d1cdd39..0000000 --- a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/NoopStringEscape.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.commands.jolokia; - -import org.apache.camel.commands.StringEscape; - -public class NoopStringEscape implements StringEscape { - - @Override - public String unescapeJava(String s) { - return s; - } - - @Override - public String escapeJava(String s) { - return s; - } - - @Override - public String hex(char c) { - return Character.toString(c); - } -} diff --git a/platforms/commands/commands-jolokia/src/main/resources/LICENSE.txt b/platforms/commands/commands-jolokia/src/main/resources/LICENSE.txt deleted file mode 100644 index 6b0b127..0000000 --- a/platforms/commands/commands-jolokia/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. - diff --git a/platforms/commands/commands-jolokia/src/main/resources/NOTICE.txt b/platforms/commands/commands-jolokia/src/main/resources/NOTICE.txt deleted file mode 100644 index 2e215bf..0000000 --- a/platforms/commands/commands-jolokia/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. diff --git a/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaCommandsTest.java b/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaCommandsTest.java deleted file mode 100644 index ab4f8b9..0000000 --- a/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaCommandsTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.commands.jolokia; - -import org.apache.camel.commands.ContextInfoCommand; -import org.apache.camel.commands.ContextListCommand; -import org.apache.camel.commands.EipExplainCommand; -import org.apache.camel.commands.EndpointExplainCommand; -import org.apache.camel.commands.EndpointListCommand; -import org.apache.camel.commands.RouteInfoCommand; -import org.apache.camel.commands.RouteListCommand; -import org.apache.camel.commands.RouteShowCommand; -import org.junit.Ignore; -import org.junit.Test; - -@Ignore("used for manual testing") -public class JolokiaCommandsTest { - - private String url = "http://localhost:8080/jolokia"; - - private JolokiaCamelController controller; - - @Test - public void testContextList() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - if (!controller.ping()) { - throw new IllegalArgumentException("Error connecting to " + url); - } - - ContextListCommand cmd = new ContextListCommand(); - cmd.execute(controller, System.out, System.err); - } - - @Test - public void testContextInfo() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - if (!controller.ping()) { - throw new IllegalArgumentException("Error connecting to " + url); - } - - ContextInfoCommand cmd = new ContextInfoCommand("camel-1", true); - cmd.setStringEscape(new NoopStringEscape()); - cmd.execute(controller, System.out, System.err); - } - - @Test - public void testEndpointList() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - if (!controller.ping()) { - throw new IllegalArgumentException("Error connecting to " + url); - } - - EndpointListCommand cmd = new EndpointListCommand("camel-1", true, true, true); - cmd.execute(controller, System.out, System.err); - } - - @Test - public void testEndpointExplain() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - if (!controller.ping()) { - throw new IllegalArgumentException("Error connecting to " + url); - } - - EndpointExplainCommand cmd = new EndpointExplainCommand("camel-1", true, "rest*"); - cmd.execute(controller, System.out, System.err); - } - - @Test - public void testEipExplain() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - if (!controller.ping()) { - throw new IllegalArgumentException("Error connecting to " + url); - } - - EipExplainCommand cmd = new EipExplainCommand("camel-1", "transform", true); - cmd.execute(controller, System.out, System.err); - } - - @Test - public void testRouteList() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - if (!controller.ping()) { - throw new IllegalArgumentException("Error connecting to " + url); - } - - RouteListCommand cmd = new RouteListCommand("camel-1"); - cmd.execute(controller, System.out, System.err); - } - - @Test - public void testRouteInfo() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - if (!controller.ping()) { - throw new IllegalArgumentException("Error connecting to " + url); - } - - RouteInfoCommand cmd = new RouteInfoCommand("route1", "camel-1"); - cmd.setStringEscape(new NoopStringEscape()); - cmd.execute(controller, System.out, System.err); - } - - @Test - public void testRouteShow() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - if (!controller.ping()) { - throw new IllegalArgumentException("Error connecting to " + url); - } - - RouteShowCommand cmd = new RouteShowCommand("route1", "camel-1"); - cmd.execute(controller, System.out, System.err); - } - -} 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 deleted file mode 100644 index c06eaa4..0000000 --- a/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java +++ /dev/null @@ -1,225 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS 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 JolokiaCamelController controller; - - @Test - public void testPing() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - boolean pong = controller.ping(); - System.out.println("Ping responsed: " + pong); - } - - @Test - public void testRemoteCamelContexts() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - List<Map<String, String>> data = controller.getCamelContexts(); - System.out.println(data); - } - - @Test - public void testRemoteCamelContextInformation() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - Map<String, Object> data = controller.getCamelContextInformation("camel-1"); - System.out.println(data); - } - - @Test - public void testRemoteCamelContextStatsAsXml() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - String data = controller.getCamelContextStatsAsXml("camel-1", true, false); - System.out.println(data); - } - - @Test - public void testRemoteCamelContextControl() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - controller.suspendContext("camel-1"); - Map<String, Object> data = controller.getCamelContextInformation("camel-1"); - System.out.println(data); - - Thread.sleep(500); - - controller.resumeContext("camel-1"); - data = controller.getCamelContextInformation("camel-1"); - System.out.println(data); - } - - @Test - public void testRemoteGetAllRoutes() throws Exception { - controller = new DefaultJolokiaCamelController(); - 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 DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - List<Map<String, String>> data = controller.getRoutes("camel-1"); - System.out.println(data); - } - - @Test - public void testRemoteGetRoutesFilter() throws Exception { - controller = new DefaultJolokiaCamelController(); - 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 DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - controller.resetRouteStats("camel-1"); - } - - @Test - public void testRemoteRouteControl() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - controller.suspendRoute("camel-1", "route1"); - List<Map<String, String>> data = controller.getRoutes("camel-1", "route1"); - System.out.println(data); - - Thread.sleep(500); - - controller.resumeRoute("camel-1", "route1"); - data = controller.getRoutes("camel-1", "route1"); - System.out.println(data); - } - - @Test - public void testRouteModel() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - String data = controller.getRouteModelAsXml("camel-1", "route1"); - System.out.println(data); - } - - @Test - public void testRouteStats() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - String data = controller.getRouteStatsAsXml("camel-1", "route1", true, true); - System.out.println(data); - } - - @Test - public void testRestsModel() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - String data = controller.getRestModelAsXml("camel-1"); - System.out.println(data); - } - - @Test - public void testRestsApiDoc() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - String data = controller.getRestApiDocAsJson("camel-1"); - System.out.println(data); - } - - @Test - public void testGetEndpoints() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - List<Map<String, String>> data = controller.getEndpoints("camel-1"); - System.out.println(data); - } - - @Test - public void testGetRestServices() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - List<Map<String, String>> data = controller.getRestServices("camel-1"); - System.out.println(data); - } - - @Test - public void testExplainEndpointJson() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - String data = controller.explainEndpointAsJSon("camel-1", "log:foo", true); - System.out.println(data); - } - - @Test - public void testExplainEipJson() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - String data = controller.explainEipAsJSon("camel-1", "transform", true); - System.out.println(data); - } - - @Test - public void testListComponents() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - List<Map<String, String>> data = controller.listComponents("camel-1"); - System.out.println(data); - } - - @Test - public void testInflight() throws Exception { - controller = new DefaultJolokiaCamelController(); - controller.connect(url, null, null); - - List<Map<String, Object>> data = controller.browseInflightExchanges("camel-1", "route1", 500, false); - System.out.println(data); - } - -} diff --git a/platforms/commands/commands-jolokia/src/test/resources/log4j2.properties b/platforms/commands/commands-jolokia/src/test/resources/log4j2.properties deleted file mode 100644 index 05e32de..0000000 --- a/platforms/commands/commands-jolokia/src/test/resources/log4j2.properties +++ /dev/null @@ -1,30 +0,0 @@ -## --------------------------------------------------------------------------- -## Licensed to the Apache Software Foundation (ASF) under one or more -## contributor license agreements. See the NOTICE file distributed with -## this work for additional information regarding copyright ownership. -## The ASF licenses this file to You under the Apache License, Version 2.0 -## (the "License"); you may not use this file except in compliance with -## the License. You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## --------------------------------------------------------------------------- - -appender.file.type = File -appender.file.name = file -appender.file.fileName = target/camel-commands-core-test.log -appender.file.layout.type = PatternLayout -appender.file.layout.pattern = %d %-5p %c{1} - %m %n -appender.out.type = Console -appender.out.name = out -appender.out.layout.type = PatternLayout -appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n -logger.commands.name = org.apache.camel.commands -logger.commands.level = DEBUG -rootLogger.level = INFO -rootLogger.appenderRef.out.ref = out diff --git a/platforms/commands/pom.xml b/platforms/commands/pom.xml index 23aaeae..dbdbc83 100644 --- a/platforms/commands/pom.xml +++ b/platforms/commands/pom.xml @@ -32,7 +32,6 @@ <modules> <module>commands-core</module> - <module>commands-jolokia</module> </modules> </project> diff --git a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml index fbdc27a..0a127a5 100644 --- a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml +++ b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml @@ -633,11 +633,6 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-commands-jolokia</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> <artifactId>camel-consul</artifactId> <version>${project.version}</version> </dependency>