You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2017/12/03 20:45:34 UTC
juneau git commit: Add EchoCommand to examples.
Repository: juneau
Updated Branches:
refs/heads/master 3d3e00b1c -> 42ab16e70
Add EchoCommand to examples.
Project: http://git-wip-us.apache.org/repos/asf/juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/juneau/commit/42ab16e7
Tree: http://git-wip-us.apache.org/repos/asf/juneau/tree/42ab16e7
Diff: http://git-wip-us.apache.org/repos/asf/juneau/diff/42ab16e7
Branch: refs/heads/master
Commit: 42ab16e70364c786b99bbca15ef4a0de6e415430
Parents: 3d3e00b
Author: JamesBognar <ja...@apache.org>
Authored: Sun Dec 3 15:45:31 2017 -0500
Committer: JamesBognar <ja...@apache.org>
Committed: Sun Dec 3 15:45:31 2017 -0500
----------------------------------------------------------------------
.../juneau-examples-rest/examples.cfg | 18 ++++++++
.../juneau-examples-rest.launch | 6 +++
.../juneau/examples/rest/EchoCommand.java | 46 ++++++++++++++++++++
3 files changed, 70 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/juneau/blob/42ab16e7/juneau-examples/juneau-examples-rest/examples.cfg
----------------------------------------------------------------------
diff --git a/juneau-examples/juneau-examples-rest/examples.cfg b/juneau-examples/juneau-examples-rest/examples.cfg
index df6aac8..af53440 100755
--- a/juneau-examples/juneau-examples-rest/examples.cfg
+++ b/juneau-examples/juneau-examples-rest/examples.cfg
@@ -54,6 +54,24 @@ port = 10000,0,0,0
stylesheet = styles/devops.css
#=======================================================================================================================
+# Console settings
+#=======================================================================================================================
+[Console]
+
+enabled = true
+
+# List of available console commands.
+# These are classes that implements ConsoleCommand that allow you to submit commands to the microservice via
+# the console.
+# When listed here, the implementations must provide a no-arg constructor.
+# They can also be provided dynamically by overriding the Microservice.createConsoleCommands() method.
+commands =
+ org.apache.juneau.microservice.console.ExitCommand,
+ org.apache.juneau.microservice.console.RestartCommand,
+ org.apache.juneau.microservice.console.HelpCommand,
+ org.apache.juneau.examples.rest.EchoCommand
+
+#=======================================================================================================================
# Logger settings
#-----------------------------------------------------------------------------------------------------------------------
# See FileHandler Java class for details.
http://git-wip-us.apache.org/repos/asf/juneau/blob/42ab16e7/juneau-examples/juneau-examples-rest/juneau-examples-rest.launch
----------------------------------------------------------------------
diff --git a/juneau-examples/juneau-examples-rest/juneau-examples-rest.launch b/juneau-examples/juneau-examples-rest/juneau-examples-rest.launch
index baf89fb..cf31023 100644
--- a/juneau-examples/juneau-examples-rest/juneau-examples-rest.launch
+++ b/juneau-examples/juneau-examples-rest/juneau-examples-rest.launch
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/RestMicroservice.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
<booleanAttribute key="org.eclipse.jdt.debug.ui.CONSIDER_INHERITED_MAIN" value="true"/>
<booleanAttribute key="org.eclipse.jdt.debug.ui.INCLUDE_EXTERNAL_JARS" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
http://git-wip-us.apache.org/repos/asf/juneau/blob/42ab16e7/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/EchoCommand.java
----------------------------------------------------------------------
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/EchoCommand.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/EchoCommand.java
new file mode 100644
index 0000000..5ccb48d
--- /dev/null
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/EchoCommand.java
@@ -0,0 +1,46 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.examples.rest;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.juneau.microservice.console.*;
+import org.apache.juneau.utils.*;
+
+/**
+ * Implements an 'echo' console command that simply returns the command arguments as a comma-delimited list.
+ */
+public class EchoCommand extends ConsoleCommand {
+
+ @Override /* ConsoleCommand */
+ public String getName() {
+ return "echo";
+ }
+
+ @Override /* ConsoleCommand */
+ public String getInfo() {
+ return "Echo command";
+ }
+
+ @Override /* ConsoleCommand */
+ public String getDescription() {
+ return "Simple prints the args of the command as a serialized ObjectMap.";
+ }
+
+ @Override /* ConsoleCommand */
+ public boolean execute(Scanner in, PrintWriter out, Args args) {
+ out.println(args);
+ return false;
+ }
+}