Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
01ebd6da
Commit
01ebd6da
authored
Jul 21, 2013
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix CLI script
parent
5d4f0750
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
25 additions
and
14 deletions
+25
-14
README.md
README.md
+4
-4
TomcatEmbeddedServletContainer.java
...ntext/embedded/tomcat/TomcatEmbeddedServletContainer.java
+3
-1
SimpleMainTests.java
...t/java/org/springframework/bootstrap/SimpleMainTests.java
+6
-5
LoggingApplicationContextInitializerTests.java
...nitializer/LoggingApplicationContextInitializerTests.java
+1
-0
SpringCli.java
...-cli/src/main/java/org/springframework/cli/SpringCli.java
+1
-1
SpringApplicationRunner.java
...g/springframework/cli/runner/SpringApplicationRunner.java
+6
-0
spring
spring-cli/src/main/scripts/spring
+2
-2
SpringCliTests.java
...src/test/java/org/springframework/cli/SpringCliTests.java
+2
-1
No files found.
README.md
View file @
01ebd6da
...
@@ -30,7 +30,7 @@ instructions will look like this:
...
@@ -30,7 +30,7 @@ instructions will look like this:
2) Get Spring
2) Get Spring
$ curl -s
spring
.cfapps.io/installer | bash
$ curl -s
initializr
.cfapps.io/installer | bash
or use the
[
Windows installer
](
#installing
)
or use the
[
Windows installer
](
#installing
)
...
@@ -43,7 +43,7 @@ or above.
...
@@ -43,7 +43,7 @@ or above.
An
`alias`
can be used for the Spring Zero command line tool:
An
`alias`
can be used for the Spring Zero command line tool:
$ alias spr="java -jar ~/.m2/repository/org/springframework/zero/spring-cli/0.5.0.BUILD-SNAPSHOT/spring-cli-0.5.0.BUILD-SNAPSHOT.jar"
$ alias spr
ing
="java -jar ~/.m2/repository/org/springframework/zero/spring-cli/0.5.0.BUILD-SNAPSHOT/spring-cli-0.5.0.BUILD-SNAPSHOT.jar"
_Also see [docs/CONTRIBUTING](docs/CONTRIBUTING.md) if you want to submit pull requests._
_Also see [docs/CONTRIBUTING](docs/CONTRIBUTING.md) if you want to submit pull requests._
...
@@ -62,7 +62,7 @@ snippets that can just run, for example:
...
@@ -62,7 +62,7 @@ snippets that can just run, for example:
}
}
}
}
<ctrl-d>
<ctrl-d>
$ spr run app.groovy
$ spr
ing
run app.groovy
$ curl localhost:8080
$ curl localhost:8080
Hello World!
Hello World!
...
@@ -165,7 +165,7 @@ _See [spring-launcher/README](spring-launcher/README.md) &
...
@@ -165,7 +165,7 @@ _See [spring-launcher/README](spring-launcher/README.md) &
## Samples
## Samples
Groovy samples for use with the command line application are available in
Groovy samples for use with the command line application are available in
[
spring-cli/samples
](
spring-cli/samples/#
)
. To run the CLI samples type
[
spring-cli/samples
](
spring-cli/samples/#
)
. To run the CLI samples type
`spr run <sample>.groovy`
from samples directory.
`spr
ing
run <sample>.groovy`
from samples directory.
Java samples are available in
[
spring-zero-sample
](
spring-zero-samples/#
)
and should
Java samples are available in
[
spring-zero-sample
](
spring-zero-samples/#
)
and should
be build with maven and run use
`java -jar target/<sample>.jar`
. The following java
be build with maven and run use
`java -jar target/<sample>.jar`
. The following java
...
...
spring-bootstrap/src/main/java/org/springframework/bootstrap/context/embedded/tomcat/TomcatEmbeddedServletContainer.java
View file @
01ebd6da
...
@@ -38,6 +38,8 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
...
@@ -38,6 +38,8 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
private
final
Log
logger
=
LogFactory
.
getLog
(
TomcatEmbeddedServletContainer
.
class
);
private
final
Log
logger
=
LogFactory
.
getLog
(
TomcatEmbeddedServletContainer
.
class
);
private
static
int
containerCounter
=
0
;
private
final
Tomcat
tomcat
;
private
final
Tomcat
tomcat
;
/**
/**
...
@@ -55,7 +57,7 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
...
@@ -55,7 +57,7 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
this
.
tomcat
.
start
();
this
.
tomcat
.
start
();
// Unlike Jetty, all Tomcat threads are daemon threads. We create a
// Unlike Jetty, all Tomcat threads are daemon threads. We create a
// blocking non-daemon to stop immediate shutdown
// blocking non-daemon to stop immediate shutdown
Thread
awaitThread
=
new
Thread
()
{
Thread
awaitThread
=
new
Thread
(
"container-"
+
(
containerCounter
++)
)
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
TomcatEmbeddedServletContainer
.
this
.
tomcat
.
getServer
().
await
();
TomcatEmbeddedServletContainer
.
this
.
tomcat
.
getServer
().
await
();
...
...
spring-bootstrap/src/test/java/org/springframework/bootstrap/SimpleMainTests.java
View file @
01ebd6da
...
@@ -39,6 +39,7 @@ import static org.junit.Assert.assertTrue;
...
@@ -39,6 +39,7 @@ import static org.junit.Assert.assertTrue;
@Configuration
@Configuration
public
class
SimpleMainTests
{
public
class
SimpleMainTests
{
private
static
final
String
SPRING_STARTUP
=
"root of context hierarchy"
;
private
PrintStream
savedOutput
;
private
PrintStream
savedOutput
;
private
ByteArrayOutputStream
output
;
private
ByteArrayOutputStream
output
;
...
@@ -58,33 +59,33 @@ public class SimpleMainTests {
...
@@ -58,33 +59,33 @@ public class SimpleMainTests {
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
emptyApplicationContext
()
throws
Exception
{
public
void
emptyApplicationContext
()
throws
Exception
{
SpringApplication
.
main
(
getArgs
());
SpringApplication
.
main
(
getArgs
());
assertTrue
(
getOutput
().
contains
(
"Pre-instantiating singletons"
));
assertTrue
(
getOutput
().
contains
(
SPRING_STARTUP
));
}
}
@Test
@Test
public
void
basePackageScan
()
throws
Exception
{
public
void
basePackageScan
()
throws
Exception
{
SpringApplication
.
main
(
getArgs
(
ClassUtils
.
getPackageName
(
getClass
())
SpringApplication
.
main
(
getArgs
(
ClassUtils
.
getPackageName
(
getClass
())
+
".sampleconfig"
));
+
".sampleconfig"
));
assertTrue
(
getOutput
().
contains
(
"Pre-instantiating singletons"
));
assertTrue
(
getOutput
().
contains
(
SPRING_STARTUP
));
}
}
@Test
@Test
public
void
configClassContext
()
throws
Exception
{
public
void
configClassContext
()
throws
Exception
{
SpringApplication
.
main
(
getArgs
(
getClass
().
getName
()));
SpringApplication
.
main
(
getArgs
(
getClass
().
getName
()));
assertTrue
(
getOutput
().
contains
(
"Pre-instantiating singletons"
));
assertTrue
(
getOutput
().
contains
(
SPRING_STARTUP
));
}
}
@Test
@Test
public
void
xmlContext
()
throws
Exception
{
public
void
xmlContext
()
throws
Exception
{
SpringApplication
.
main
(
getArgs
(
"org/springframework/bootstrap/sample-beans.xml"
));
SpringApplication
.
main
(
getArgs
(
"org/springframework/bootstrap/sample-beans.xml"
));
assertTrue
(
getOutput
().
contains
(
"Pre-instantiating singletons"
));
assertTrue
(
getOutput
().
contains
(
SPRING_STARTUP
));
}
}
@Test
@Test
public
void
mixedContext
()
throws
Exception
{
public
void
mixedContext
()
throws
Exception
{
SpringApplication
.
main
(
getArgs
(
getClass
().
getName
(),
SpringApplication
.
main
(
getArgs
(
getClass
().
getName
(),
"org/springframework/bootstrap/sample-beans.xml"
));
"org/springframework/bootstrap/sample-beans.xml"
));
assertTrue
(
getOutput
().
contains
(
"Pre-instantiating singletons"
));
assertTrue
(
getOutput
().
contains
(
SPRING_STARTUP
));
}
}
private
String
[]
getArgs
(
String
...
args
)
{
private
String
[]
getArgs
(
String
...
args
)
{
...
...
spring-bootstrap/src/test/java/org/springframework/bootstrap/context/initializer/LoggingApplicationContextInitializerTests.java
View file @
01ebd6da
...
@@ -71,6 +71,7 @@ public class LoggingApplicationContextInitializerTests {
...
@@ -71,6 +71,7 @@ public class LoggingApplicationContextInitializerTests {
System
.
clearProperty
(
"LOG_PATH"
);
System
.
clearProperty
(
"LOG_PATH"
);
System
.
clearProperty
(
"PID"
);
System
.
clearProperty
(
"PID"
);
System
.
setOut
(
this
.
savedOutput
);
System
.
setOut
(
this
.
savedOutput
);
System
.
out
.
println
(
getOutput
());
}
}
private
String
getOutput
()
{
private
String
getOutput
()
{
...
...
spring-cli/src/main/java/org/springframework/cli/SpringCli.java
View file @
01ebd6da
...
@@ -39,7 +39,7 @@ import java.util.Set;
...
@@ -39,7 +39,7 @@ import java.util.Set;
*/
*/
public
class
SpringCli
{
public
class
SpringCli
{
public
static
final
String
CLI_APP
=
"spr"
;
public
static
final
String
CLI_APP
=
"spr
ing
"
;
private
static
final
Set
<
SpringCliException
.
Option
>
NO_EXCEPTION_OPTIONS
=
EnumSet
private
static
final
Set
<
SpringCliException
.
Option
>
NO_EXCEPTION_OPTIONS
=
EnumSet
.
noneOf
(
SpringCliException
.
Option
.
class
);
.
noneOf
(
SpringCliException
.
Option
.
class
);
...
...
spring-cli/src/main/java/org/springframework/cli/runner/SpringApplicationRunner.java
View file @
01ebd6da
...
@@ -33,6 +33,10 @@ import org.springframework.cli.compiler.GroovyCompiler;
...
@@ -33,6 +33,10 @@ import org.springframework.cli.compiler.GroovyCompiler;
*/
*/
public
class
SpringApplicationRunner
{
public
class
SpringApplicationRunner
{
private
static
int
watcherCounter
=
0
;
private
static
int
runnerCounter
=
0
;
// FIXME logging
// FIXME logging
private
SpringApplicationRunnerConfiguration
configuration
;
private
SpringApplicationRunnerConfiguration
configuration
;
...
@@ -118,6 +122,7 @@ public class SpringApplicationRunner {
...
@@ -118,6 +122,7 @@ public class SpringApplicationRunner {
* @param sources the sources to launch
* @param sources the sources to launch
*/
*/
public
RunThread
(
Object
...
sources
)
{
public
RunThread
(
Object
...
sources
)
{
super
(
"runner-"
+
(
runnerCounter
++));
this
.
sources
=
sources
;
this
.
sources
=
sources
;
if
(
sources
.
length
!=
0
&&
sources
[
0
]
instanceof
Class
)
{
if
(
sources
.
length
!=
0
&&
sources
[
0
]
instanceof
Class
)
{
setContextClassLoader
(((
Class
<?>)
sources
[
0
]).
getClassLoader
());
setContextClassLoader
(((
Class
<?>)
sources
[
0
]).
getClassLoader
());
...
@@ -171,6 +176,7 @@ public class SpringApplicationRunner {
...
@@ -171,6 +176,7 @@ public class SpringApplicationRunner {
private
long
previous
;
private
long
previous
;
public
FileWatchThread
()
{
public
FileWatchThread
()
{
super
(
"filewatcher-"
+
(
watcherCounter
++));
this
.
previous
=
0
;
this
.
previous
=
0
;
for
(
File
file
:
SpringApplicationRunner
.
this
.
files
)
{
for
(
File
file
:
SpringApplicationRunner
.
this
.
files
)
{
long
current
=
file
.
lastModified
();
long
current
=
file
.
lastModified
();
...
...
spring-cli/src/main/scripts/spring
View file @
01ebd6da
...
@@ -63,7 +63,7 @@ if [ -f build.gradle ]; then
...
@@ -63,7 +63,7 @@ if [ -f build.gradle ]; then
TARGETDIR
=
build/classes/main
TARGETDIR
=
build/classes/main
fi
fi
for
f
in
"
${
TARGETDIR
}
"
"
${
SPRING_HOME
}
"
/classes
"
${
SPRING_BIN
}
"
"
${
SPRING_HOME
}
"
/
*
.jar
"
${
SPRING_HOME
}
"
/lib/
*
.jar
;
do
for
f
in
.
"
${
TARGETDIR
}
"
"
${
SPRING_HOME
}
"
/classes
"
${
SPRING_BIN
}
"
"
${
SPRING_HOME
}
"
/
*
.jar
"
${
SPRING_HOME
}
"
/lib/
*
.jar
;
do
if
[
-f
$f
-o
-d
$f
]
;
then
if
[
-f
$f
-o
-d
$f
]
;
then
if
[
"
${
CLASSPATH
}
"
==
""
]
;
then
if
[
"
${
CLASSPATH
}
"
==
""
]
;
then
CLASSPATH
=
"
${
f
}
"
CLASSPATH
=
"
${
f
}
"
...
@@ -77,4 +77,4 @@ if $cygwin; then
...
@@ -77,4 +77,4 @@ if $cygwin; then
CLASSPATH
=
`
cygpath
--path
--mixed
"
$CLASSPATH
"
`
CLASSPATH
=
`
cygpath
--path
--mixed
"
$CLASSPATH
"
`
fi
fi
${
JAVA_HOME
}
/bin/java
${
JAVA_OPTS
}
-cp
"
$CLASSPATH
"
org.springframework.bootstrap.cli.SpringBootstrapCli
$*
${
JAVA_HOME
}
/bin/java
${
JAVA_OPTS
}
-cp
"
$CLASSPATH
"
org.springframework.cli.SpringCli
$*
\ No newline at end of file
\ No newline at end of file
spring-cli/src/test/java/org/springframework/cli/SpringCliTests.java
View file @
01ebd6da
...
@@ -133,7 +133,8 @@ public class SpringCliTests {
...
@@ -133,7 +133,8 @@ public class SpringCliTests {
@Test
@Test
public
void
exceptionMessages
()
throws
Exception
{
public
void
exceptionMessages
()
throws
Exception
{
assertThat
(
new
NoSuchCommandException
(
"name"
).
getMessage
(),
assertThat
(
new
NoSuchCommandException
(
"name"
).
getMessage
(),
equalTo
(
"spr: 'name' is not a valid command. See 'spr help'."
));
equalTo
(
SpringCli
.
CLI_APP
+
": 'name' is not a valid command. See '"
+
SpringCli
.
CLI_APP
+
" help'."
));
}
}
@Test
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment