Further maven module restructure
This commit is contained in:
15
spring-cli/samples/actuator.groovy
Normal file
15
spring-cli/samples/actuator.groovy
Normal file
@@ -0,0 +1,15 @@
|
||||
package org.test
|
||||
|
||||
@Grab("org.springframework.zero:spring-zero-actuator:0.5.0.BUILD-SNAPSHOT")
|
||||
|
||||
@Controller
|
||||
class SampleController {
|
||||
|
||||
@RequestMapping("/")
|
||||
@ResponseBody
|
||||
public def hello() {
|
||||
[message: "Hello World!"]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
23
spring-cli/samples/app.groovy
Normal file
23
spring-cli/samples/app.groovy
Normal file
@@ -0,0 +1,23 @@
|
||||
package org.test
|
||||
|
||||
@Component
|
||||
class Example implements CommandLineRunner {
|
||||
|
||||
@Autowired
|
||||
private MyService myService
|
||||
|
||||
void run(String... args) {
|
||||
print "Hello " + this.myService.sayWorld()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Service
|
||||
class MyService {
|
||||
|
||||
String sayWorld() {
|
||||
return "World!"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
17
spring-cli/samples/integration.groovy
Normal file
17
spring-cli/samples/integration.groovy
Normal file
@@ -0,0 +1,17 @@
|
||||
package org.test
|
||||
|
||||
@Component
|
||||
@EnableIntegrationPatterns
|
||||
class SpringIntegrationExample implements CommandLineRunner {
|
||||
|
||||
@Bean
|
||||
MessageFlow flow(ApplicationContext context) {
|
||||
def builder = new IntegrationBuilder(context)
|
||||
builder.messageFlow { transform {"Hello, $it!"} }
|
||||
}
|
||||
|
||||
@Override
|
||||
void run(String... args) {
|
||||
print flow().sendAndReceive("World")
|
||||
}
|
||||
}
|
||||
35
spring-cli/samples/job.groovy
Normal file
35
spring-cli/samples/job.groovy
Normal file
@@ -0,0 +1,35 @@
|
||||
package org.test
|
||||
|
||||
@Grab("org.hsqldb:hsqldb-j5:2.0.0")
|
||||
@Configuration
|
||||
@EnableBatchProcessing
|
||||
class JobConfig {
|
||||
|
||||
@Autowired
|
||||
private JobBuilderFactory jobs
|
||||
|
||||
@Autowired
|
||||
private StepBuilderFactory steps
|
||||
|
||||
@Bean
|
||||
protected Tasklet tasklet() {
|
||||
return new Tasklet() {
|
||||
@Override
|
||||
RepeatStatus execute(StepContribution contribution, ChunkContext context) {
|
||||
return RepeatStatus.FINISHED
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
Job job() throws Exception {
|
||||
return jobs.get("job").start(step1()).build()
|
||||
}
|
||||
|
||||
@Bean
|
||||
protected Step step1() throws Exception {
|
||||
return steps.get("step1").tasklet(tasklet()).build()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
10
spring-cli/samples/runner.groovy
Normal file
10
spring-cli/samples/runner.groovy
Normal file
@@ -0,0 +1,10 @@
|
||||
package org.test
|
||||
|
||||
class Runner implements CommandLineRunner {
|
||||
|
||||
void run(String... args) {
|
||||
print "Hello World!"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
9
spring-cli/samples/runner.xml
Normal file
9
spring-cli/samples/runner.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean id="runner" class="org.test.Runner"/>
|
||||
|
||||
</beans>
|
||||
|
||||
25
spring-cli/samples/template.groovy
Normal file
25
spring-cli/samples/template.groovy
Normal file
@@ -0,0 +1,25 @@
|
||||
package org.test
|
||||
|
||||
import static org.springframework.zero.cli.template.GroovyTemplate.template;
|
||||
|
||||
@Component
|
||||
class Example implements CommandLineRunner {
|
||||
|
||||
@Autowired
|
||||
private MyService myService
|
||||
|
||||
void run(String... args) {
|
||||
print template("test.txt", ["message":myService.sayWorld()])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Service
|
||||
class MyService {
|
||||
|
||||
String sayWorld() {
|
||||
return "World"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
11
spring-cli/samples/ui.groovy
Normal file
11
spring-cli/samples/ui.groovy
Normal file
@@ -0,0 +1,11 @@
|
||||
@Grab("org.thymeleaf:thymeleaf-spring3:2.0.16")
|
||||
@Controller
|
||||
class Example {
|
||||
|
||||
@RequestMapping("/")
|
||||
public String helloWorld(Map<String,Object> model) {
|
||||
model.putAll([title: "My Page", date: new Date(), message: "Hello World"])
|
||||
return "home";
|
||||
}
|
||||
|
||||
}
|
||||
23
spring-cli/samples/web.groovy
Normal file
23
spring-cli/samples/web.groovy
Normal file
@@ -0,0 +1,23 @@
|
||||
@Controller
|
||||
class Example {
|
||||
|
||||
@Autowired
|
||||
private MyService myService;
|
||||
|
||||
@RequestMapping("/")
|
||||
@ResponseBody
|
||||
public String helloWorld() {
|
||||
return myService.sayWorld();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Service
|
||||
class MyService {
|
||||
|
||||
public String sayWorld() {
|
||||
return "World!";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user