1
- @Grab (" org.springframework.zero:spring-actuator:0.5.0.BUILD-SNAPSHOT" )
1
+ package app
2
+
2
3
@Grab (" org.codehaus.groovy:groovy-ant:2.1.6" )
3
4
@Grab (" org.codehaus.groovy.modules.http-builder:http-builder:0.5.2" )
4
5
@Grab (group = ' net.sf.json-lib' , module = ' json-lib' , version = ' 2.3' , classifier = ' jdk15' )
@@ -14,6 +15,9 @@ class MainController {
14
15
@Value (' ${TMPDIR:.}' )
15
16
private String tmpdir
16
17
18
+ @Autowired
19
+ private Reactor reactor
20
+
17
21
private gettingStartedRepos = []
18
22
19
23
@RequestMapping (" /" )
@@ -29,12 +33,6 @@ class MainController {
29
33
template " home.html" , model
30
34
}
31
35
32
- @RequestMapping (" /installer" )
33
- @ResponseBody
34
- String installer (@RequestHeader (required = false ) String host ) {
35
- template " installer.sh" , [host : host!= null ? host : home]
36
- }
37
-
38
36
@RequestMapping (" /spring" )
39
37
@ResponseBody
40
38
ResponseEntity<byte[]> spring () {
@@ -54,9 +52,12 @@ class MainController {
54
52
@ResponseBody
55
53
ResponseEntity<byte[]> spring (PomRequest request ) {
56
54
55
+ def tempFiles = []
56
+
57
57
def model = [:]
58
58
String pom = new String (pom(request, model). body)
59
59
File dir = File . createTempFile(" tmp" ," " ,new File (tmpdir));
60
+ tempFiles << dir
60
61
dir. delete()
61
62
dir. mkdirs()
62
63
new File (dir, " pom.xml" ). write(pom)
@@ -65,12 +66,15 @@ class MainController {
65
66
src. mkdirs()
66
67
67
68
def body = template " Application.java" , model
68
- log. info(" Creating: " + src + " Application.java" )
69
+ log. info(" Creating: " + src + " / Application.java" )
69
70
new File (src, " Application.java" ). write(body)
70
71
71
72
File download = new File (tmpdir, dir. name + " .zip" )
72
73
log. info(" Creating: " + download)
73
-
74
+ tempFiles << download
75
+
76
+ reactor. notify(" tempfiles" , Event . wrap(tempFiles))
77
+
74
78
new AntBuilder (). zip(destfile : download) {
75
79
zipfileset(dir :dir, includes :" **" )
76
80
}
@@ -135,13 +139,60 @@ class MainController {
135
139
136
140
}
137
141
138
- import org.springframework.actuate.properties.SecurityProperties
142
+ import reactor.spring.context.ConsumerBeanPostProcessor ;
143
+ @Configuration
144
+ @EnableReactor
145
+ class ReactorConfiguration {
146
+
147
+ @Bean
148
+ public reactor.core.Environment reactorEnvironment () {
149
+ return new reactor.core.Environment (); // TODO: use Spring Environment to configure?
150
+ }
151
+
152
+ @Bean
153
+ public Reactor rootReactor () {
154
+ return reactorEnvironment(). getRootReactor();
155
+ }
156
+
157
+ }
158
+
159
+ @Component
160
+ @Log
161
+ class TemporaryFileCleaner {
162
+
163
+ @Autowired
164
+ Reactor reactor
165
+
166
+ @PostConstruct
167
+ void init () {
168
+ reactor. on(Selectors . $(" tempfiles" ), [
169
+ accept : {
170
+ def tempFiles = event. data
171
+ log. info " Tempfiles: " + tempFiles
172
+ if (tempFiles) {
173
+ tempFiles. each {
174
+ File file = it as File
175
+ if (file. directory) {
176
+ file. deleteDir()
177
+ } else {
178
+ file. delete()
179
+ }
180
+ }
181
+ }
182
+ }
183
+ ] as Consumer )
184
+ }
185
+
186
+ }
187
+
188
+ @Grab (" org.springframework.boot:spring-boot-starter-actuator:0.5.0.M1" )
189
+ import org.springframework.boot.ops.properties.SecurityProperties
139
190
@EnableWebSecurity
140
191
@Configuration
141
192
@Log
142
193
class SecurityConfiguration {
143
194
144
- @Bean (name = " org.springframework.actuate .properties.SecurityProperties" )
195
+ @Bean (name = " org.springframework.boot.ops .properties.SecurityProperties" )
145
196
SecurityProperties securityProperties () {
146
197
SecurityProperties security = new SecurityProperties ()
147
198
security. getBasic(). setPath(" /gs/**" )
@@ -165,12 +216,12 @@ class PomRequest {
165
216
def style = []
166
217
167
218
String name = " demo"
168
- String description = " Demo project for Spring Zero "
219
+ String description = " Demo project for Spring Boot "
169
220
String groupId = " org.test"
170
221
String artifactId
171
222
String version = " 0.0.1.SNAPSHOT"
172
223
String packageName
173
- String getName () {
224
+ String getArtifactId () {
174
225
artifactId == null ? name : artifactId
175
226
}
176
227
String getPackageName () {
0 commit comments