Skip to content

Commit 0ccc883

Browse files
author
Dave Syer
committed
Update for 0.5.0.M1
1 parent 9d4a6bf commit 0ccc883

File tree

6 files changed

+165
-60
lines changed

6 files changed

+165
-60
lines changed

.cfignore

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
.classpath
77
.project
88
.settings
9-
bin
109
build
1110
target
1211
.springBeans

app.groovy

+64-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
@Grab("org.springframework.zero:spring-actuator:0.5.0.BUILD-SNAPSHOT")
1+
package app
2+
23
@Grab("org.codehaus.groovy:groovy-ant:2.1.6")
34
@Grab("org.codehaus.groovy.modules.http-builder:http-builder:0.5.2")
45
@Grab(group='net.sf.json-lib', module='json-lib', version='2.3', classifier='jdk15')
@@ -14,6 +15,9 @@ class MainController {
1415
@Value('${TMPDIR:.}')
1516
private String tmpdir
1617

18+
@Autowired
19+
private Reactor reactor
20+
1721
private gettingStartedRepos = []
1822

1923
@RequestMapping("/")
@@ -29,12 +33,6 @@ class MainController {
2933
template "home.html", model
3034
}
3135

32-
@RequestMapping("/installer")
33-
@ResponseBody
34-
String installer(@RequestHeader(required=false) String host) {
35-
template "installer.sh", [host: host!=null ? host : home]
36-
}
37-
3836
@RequestMapping("/spring")
3937
@ResponseBody
4038
ResponseEntity<byte[]> spring() {
@@ -54,9 +52,12 @@ class MainController {
5452
@ResponseBody
5553
ResponseEntity<byte[]> spring(PomRequest request) {
5654

55+
def tempFiles = []
56+
5757
def model = [:]
5858
String pom = new String(pom(request, model).body)
5959
File dir = File.createTempFile("tmp","",new File(tmpdir));
60+
tempFiles << dir
6061
dir.delete()
6162
dir.mkdirs()
6263
new File(dir, "pom.xml").write(pom)
@@ -65,12 +66,15 @@ class MainController {
6566
src.mkdirs()
6667

6768
def body = template "Application.java", model
68-
log.info("Creating: " + src + "Application.java")
69+
log.info("Creating: " + src + "/Application.java")
6970
new File(src, "Application.java").write(body)
7071

7172
File download = new File(tmpdir, dir.name + ".zip")
7273
log.info("Creating: " + download)
73-
74+
tempFiles << download
75+
76+
reactor.notify("tempfiles", Event.wrap(tempFiles))
77+
7478
new AntBuilder().zip(destfile: download) {
7579
zipfileset(dir:dir, includes:"**")
7680
}
@@ -135,13 +139,60 @@ class MainController {
135139

136140
}
137141

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
139190
@EnableWebSecurity
140191
@Configuration
141192
@Log
142193
class SecurityConfiguration {
143194

144-
@Bean(name = "org.springframework.actuate.properties.SecurityProperties")
195+
@Bean(name = "org.springframework.boot.ops.properties.SecurityProperties")
145196
SecurityProperties securityProperties() {
146197
SecurityProperties security = new SecurityProperties()
147198
security.getBasic().setPath("/gs/**")
@@ -165,12 +216,12 @@ class PomRequest {
165216
def style = []
166217

167218
String name = "demo"
168-
String description = "Demo project for Spring Zero"
219+
String description = "Demo project for Spring Boot"
169220
String groupId = "org.test"
170221
String artifactId
171222
String version = "0.0.1.SNAPSHOT"
172223
String packageName
173-
String getName() {
224+
String getArtifactId() {
174225
artifactId == null ? name : artifactId
175226
}
176227
String getPackageName() {

logback.xml

+4-16
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<configuration>
3-
<property name="CONSOLE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${PID:- } [%t] --- %-40.40logger{39} : %m%n%wex"/>
43

5-
<conversionRule conversionWord="wex" converterClass="org.springframework.bootstrap.logging.logback.WhitespaceThrowableProxyConverter" />
6-
7-
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
8-
<encoder>
9-
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
10-
</encoder>
11-
</appender>
12-
13-
<root level="INFO">
14-
<appender-ref ref="CONSOLE" />
15-
</root>
16-
17-
<logger name="org.springframework.zero" level="DEBUG"/>
18-
<logger name="org.springframework.security" level="DEBUG"/>
19-
<logger name="sun.net.www.protocol.http.HttpURLConnection" level="TRACE"/>
4+
<include resource="org/springframework/boot/logging/logback/base.xml"/>
205

6+
<logger name="org.springframework" level="DEBUG"/>
7+
<logger name="org.springframework.core.env" level="WARN"/>
8+
<logger name="org.springframework.jndi" level="WARN"/>
219

2210
</configuration>

manifest.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ applications:
55
instances: 1
66
url: initializr.cfapps.io
77
path: .
8-
command: java -jar ./spring/lib/*.jar run --local app.groovy -- --server.port=$PORT
8+
command: java -jar ./spring/lib/*.jar run --cp . --local app.groovy -- --server.port=$PORT
99
# buildpack: https://github.com/dsyer/cloudfoundry-buildpack-java

static/install.sh

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/sh
2+
3+
set -e
4+
# set -x
5+
6+
VERSION="0.5.0.M1"
7+
if [ -z "${PREFIX}" ]; then
8+
PREFIX="/usr/local/bin"
9+
fi
10+
if [ -z "${JAR_FILE}" ]; then
11+
JAR_FILE="/tmp/spring.jar"
12+
if [ -z "${JAR_URL}" ]; then
13+
14+
echo "Downloading spring ${VERSION} distribution"
15+
echo
16+
17+
JAR_URL="https://repo.springsource.org/milestone/org/springframework/boot/spring-boot-cli/${VERSION}/spring-boot-cli-${VERSION}.jar"
18+
curl --progress-bar --fail "$JAR_URL" -o "$JAR_FILE"
19+
20+
fi
21+
fi
22+
trap "echo Installation failed." EXIT
23+
24+
test -f "${JAR_FILE}"
25+
26+
SPRING_HOME="${HOME}/.spring"
27+
mkdir -p "$SPRING_HOME"
28+
cp "$JAR_FILE" "${SPRING_HOME}/spring.jar"
29+
cd "${SPRING_HOME}"
30+
echo
31+
32+
rm -rf "${SPRING_HOME}"/spring
33+
cat > "${SPRING_HOME}"/spring <<"EOF"
34+
#!/bin/sh
35+
java -jar ${SPRING_HOME}/spring.jar \$*
36+
EOF
37+
chmod +x "${SPRING_HOME}/spring"
38+
test -x "${SPRING_HOME}/spring"
39+
40+
echo "spring ${VERSION} has been installed in your home directory (~/.spring)."
41+
echo
42+
43+
if rm -f "$PREFIX/spring" && ln -sf "${SPRING_HOME}/spring" "$PREFIX/spring" >/dev/null 2>&1; then
44+
echo
45+
echo "Linking ~/.spring/spring to $PREFIX/spring for your convenience."
46+
cat <<"EOF"
47+
48+
To get started:
49+
50+
$ spring --version
51+
$ spring help
52+
53+
And take a look at the README at https://github.com/springsource/spring-boot#readme.
54+
55+
EOF
56+
elif type sudo >/dev/null 2>&1; then
57+
echo "Linking ~/.spring/spring to $PREFIX/spring for your convenience."
58+
echo "This may prompt for your password."
59+
if sudo rm -f "$PREFIX/spring" && sudo ln -sf "${SPRING_HOME}/spring" "$PREFIX/spring" >/dev/null 2>&1; then
60+
cat <<"EOF"
61+
62+
To get started:
63+
64+
$ spring --version
65+
$ spring help
66+
67+
And take a look at the README at https://github.com/springsource/spring-boot#readme.
68+
69+
EOF
70+
else
71+
cat <<"EOF"
72+
Couldn't create the symlink. Please either:
73+
(1) Run the following as root:
74+
cp ~/.spring/spring /usr/bin/spring
75+
(2) Add ~/.spring to your path, or
76+
(3) Rerun this command to try again.
77+
78+
Then to get started, take a look at 'spring help' or see the README at
79+
https://github.com/springsource/spring-boot#readme.
80+
EOF
81+
fi
82+
else
83+
cat <<"EOF"
84+
85+
Now you need to do one of the following:
86+
87+
(1) Add ~/.spring to your path, or
88+
(2) Run this command as root:
89+
cp ~/.spring/spring /usr/bin/spring
90+
91+
Then to get started, take a look at 'spring help' or see the README at
92+
https://github.com/springsource/spring-boot#readme.
93+
EOF
94+
fi
95+
96+
trap - EXIT

templates/installer.sh

-29
This file was deleted.

0 commit comments

Comments
 (0)