diff options
author | Joe Robinson <joe@lc8n.com> | 2015-12-10 16:34:47 +0000 |
---|---|---|
committer | Joe Robinson <joe@lc8n.com> | 2015-12-10 16:34:47 +0000 |
commit | 6f74207c87e3315e68ed2b3091181f6e84c31a31 (patch) | |
tree | 2b941065ae5c94775cb6f3590b9a0d3e691ae8ed |
Initial commit of basic listener
-rw-r--r-- | pom.xml | 54 | ||||
-rw-r--r-- | src/main/java/uk/co/blatech/blaears/Application.java | 12 | ||||
-rw-r--r-- | src/main/java/uk/co/blatech/blaears/controllers/IndexController.java | 15 | ||||
-rw-r--r-- | src/main/java/uk/co/blatech/blaears/controllers/MsgRelayController.java | 20 | ||||
-rw-r--r-- | src/main/resources/templates/index.vm | 10 |
5 files changed, 111 insertions, 0 deletions
@@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>uk.co.blatech</groupId> + <artifactId>blaears</artifactId> + <version>0.0.1-SNAPSHOT</version> + <packaging>jar</packaging> + + <name>blaears</name> + <description>Listens for commands and does things</description> + + <parent> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-parent</artifactId> + <version>1.3.0.RELEASE</version> + <relativePath/> <!-- lookup parent from repository --> + </parent> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <java.version>1.8</java.version> + </properties> + + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-velocity</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + </plugin> + </plugins> + </build> + + +</project> +€
\ 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 @@ +<!DOCTYPE html> +<html> +<head lang="en"> + <meta charset="UTF-8"> + <title></title> +</head> +<body> +Hello $name +</body> +</html>
\ No newline at end of file |