From 6f74207c87e3315e68ed2b3091181f6e84c31a31 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Thu, 10 Dec 2015 16:34:47 +0000 Subject: Initial commit of basic listener --- pom.xml | 54 ++++++++++++++++++++++ .../java/uk/co/blatech/blaears/Application.java | 12 +++++ .../blaears/controllers/IndexController.java | 15 ++++++ .../blaears/controllers/MsgRelayController.java | 20 ++++++++ src/main/resources/templates/index.vm | 10 ++++ 5 files changed, 111 insertions(+) create mode 100644 pom.xml create mode 100644 src/main/java/uk/co/blatech/blaears/Application.java create mode 100644 src/main/java/uk/co/blatech/blaears/controllers/IndexController.java create mode 100644 src/main/java/uk/co/blatech/blaears/controllers/MsgRelayController.java create mode 100644 src/main/resources/templates/index.vm diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..381a874 --- /dev/null +++ b/pom.xml @@ -0,0 +1,54 @@ + + + 4.0.0 + + uk.co.blatech + blaears + 0.0.1-SNAPSHOT + jar + + blaears + Listens for commands and does things + + + org.springframework.boot + spring-boot-starter-parent + 1.3.0.RELEASE + + + + + UTF-8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter-velocity + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + +€ \ No newline at end of file diff --git a/src/main/java/uk/co/blatech/blaears/Application.java b/src/main/java/uk/co/blatech/blaears/Application.java new file mode 100644 index 0000000..7c21af9 --- /dev/null +++ b/src/main/java/uk/co/blatech/blaears/Application.java @@ -0,0 +1,12 @@ +package uk.co.blatech.blaears; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} \ No newline at end of file diff --git a/src/main/java/uk/co/blatech/blaears/controllers/IndexController.java b/src/main/java/uk/co/blatech/blaears/controllers/IndexController.java new file mode 100644 index 0000000..1bcfab0 --- /dev/null +++ b/src/main/java/uk/co/blatech/blaears/controllers/IndexController.java @@ -0,0 +1,15 @@ +package uk.co.blatech.blaears.controllers; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@Controller +public class IndexController { + @RequestMapping("/") + String index(@RequestParam(value="name", required=false, defaultValue="World") String name, Model model){ + model.addAttribute("name", name); + return "index"; + } +} \ No newline at end of file diff --git a/src/main/java/uk/co/blatech/blaears/controllers/MsgRelayController.java b/src/main/java/uk/co/blatech/blaears/controllers/MsgRelayController.java new file mode 100644 index 0000000..a89b47c --- /dev/null +++ b/src/main/java/uk/co/blatech/blaears/controllers/MsgRelayController.java @@ -0,0 +1,20 @@ +package uk.co.blatech.blaears.controllers; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import java.io.IOException; + +@Controller +public class MsgRelayController { + @RequestMapping("/msgrelay") + void relay(@RequestParam(value="text", required=true) String text){ + try { + Runtime.getRuntime().exec("echo theblueroom test | ./msgrelay.bash " + text); + } catch (IOException e) { + System.out.println("Failed to run command echo theblueroom test | ./msgrelay.bash " + text); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/src/main/resources/templates/index.vm b/src/main/resources/templates/index.vm new file mode 100644 index 0000000..a5a8d27 --- /dev/null +++ b/src/main/resources/templates/index.vm @@ -0,0 +1,10 @@ + + + + + + + +Hello $name + + \ No newline at end of file -- cgit v1.2.3