This commit is contained in:
Phillip Webb
2014-01-02 12:04:45 -08:00
parent 0f9c705980
commit 1bcd3de7b5
31 changed files with 159 additions and 56 deletions

View File

@@ -200,7 +200,7 @@ webapp or service:
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency
</dependencies>
## Terminate SSL in Tomcat
@@ -818,7 +818,7 @@ change the behaviour:
classpath resource or a URL). A separate `Environment` property
source is set up for this document and it can be overridden by
system properties, environment variables or the command line.
No matter what you set in the environment, Spring Boot will always
load `application.properties` as described above. If YAML is used then
files with the ".yml" extension are also added to the list by default.
@@ -942,4 +942,4 @@ it with
after which you can run the application with
$ java -jar target/*.jar

View File

@@ -55,6 +55,7 @@ public abstract class AbstractEndpoint<T> implements Endpoint<T> {
this.id = id;
}
@Override
public boolean isEnabled() {
return this.enabled;
}

View File

@@ -186,14 +186,17 @@ public class EndpointMBeanExporter extends MBeanExporter implements SmartLifecyc
// SmartLifeCycle implementation
@Override
public final int getPhase() {
return this.phase;
}
@Override
public final boolean isAutoStartup() {
return this.autoStartup;
}
@Override
public final boolean isRunning() {
this.lifecycleLock.lock();
try {
@@ -204,6 +207,7 @@ public class EndpointMBeanExporter extends MBeanExporter implements SmartLifecyc
}
}
@Override
public final void start() {
this.lifecycleLock.lock();
try {
@@ -217,6 +221,7 @@ public class EndpointMBeanExporter extends MBeanExporter implements SmartLifecyc
}
}
@Override
public final void stop() {
this.lifecycleLock.lock();
try {
@@ -229,6 +234,7 @@ public class EndpointMBeanExporter extends MBeanExporter implements SmartLifecyc
}
}
@Override
public final void stop(Runnable callback) {
this.lifecycleLock.lock();
try {

View File

@@ -68,6 +68,7 @@ public class JolokiaMvcEndpoint implements MvcEndpoint, InitializingBean,
this.controller.afterPropertiesSet();
}
@Override
public void setServletContext(ServletContext servletContext) {
this.controller.setServletContext(servletContext);
}
@@ -76,6 +77,7 @@ public class JolokiaMvcEndpoint implements MvcEndpoint, InitializingBean,
this.controller.setInitParameters(initParameters);
}
@Override
public final void setApplicationContext(ApplicationContext context)
throws BeansException {
this.controller.setApplicationContext(context);

View File

@@ -34,6 +34,8 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
* Tests for {@link SimpleHealthIndicator}.
*
* @author Dave Syer
*/
public class SimpleHealthIndicatorTests {

View File

@@ -73,7 +73,8 @@ public abstract class JpaBaseConfiguration implements BeanFactoryAware, Environm
@Bean
@ConditionalOnMissingBean(EntityManagerFactoryInfo.class)
public LocalContainerEntityManagerFactoryBean entityManagerFactory(JpaVendorAdapter jpaVendorAdapter) {
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
JpaVendorAdapter jpaVendorAdapter) {
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
entityManagerFactoryBean.setJpaVendorAdapter(jpaVendorAdapter);
entityManagerFactoryBean.setDataSource(getDataSource());

View File

@@ -137,10 +137,8 @@ public abstract class AbstractJpaAutoConfigurationTests {
@Test
public void usesManuallyDefinedEntityManagerFactoryBeanIfAvailable() {
setupTestConfiguration(TestConfigurationWithEntityManagerFactory.class);
this.context.refresh();
LocalContainerEntityManagerFactoryBean factoryBean = this.context
.getBean(LocalContainerEntityManagerFactoryBean.class);
Map<String, Object> map = factoryBean.getJpaPropertyMap();
@@ -149,10 +147,8 @@ public abstract class AbstractJpaAutoConfigurationTests {
@Test
public void usesManuallyDefinedTransactionManagerBeanIfAvailable() {
setupTestConfiguration(TestConfigurationWithTransactionManager.class);
this.context.refresh();
PlatformTransactionManager txManager = this.context
.getBean(PlatformTransactionManager.class);
assertThat(txManager, instanceOf(CustomJpaTransactionManager.class));

View File

@@ -8,7 +8,7 @@ class SpringIntegrationExample implements CommandLineRunner {
DirectChannel input() {
new DirectChannel();
}
@Override
void run(String... args) {
print new MessagingTemplate(input()).convertSendAndReceive("World")
@@ -23,4 +23,4 @@ class HelloTransformer {
"Hello, ${payload}"
}
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2012-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.cli.command;
import java.io.IOException;

View File

@@ -1,6 +1,21 @@
/*
* Copyright 2012-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.cli.command;
import org.springframework.boot.cli.command.AbstractCommand;
/**
* @author Dave Syer
@@ -10,7 +25,8 @@ public class PromptCommand extends AbstractCommand {
private final ShellCommand runCmd;
public PromptCommand(ShellCommand runCmd) {
super("prompt", "Change the prompt used with the current 'shell' command. Execute with no arguments to return to the previous value.");
super("prompt", "Change the prompt used with the current 'shell' command. "
+ "Execute with no arguments to return to the previous value.");
this.runCmd = runCmd;
}
@@ -18,10 +34,11 @@ public class PromptCommand extends AbstractCommand {
public void run(String... strings) throws Exception {
if (strings.length > 0) {
for (String string : strings) {
runCmd.pushPrompt(string + " ");
this.runCmd.pushPrompt(string + " ");
}
} else {
runCmd.popPrompt();
}
else {
this.runCmd.popPrompt();
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2012-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.cli.command;
import java.io.IOException;
@@ -12,7 +28,8 @@ public class Shell {
public static void main(String... args) throws IOException {
if (args.length == 0) {
SpringCli.main("shell"); // right into the REPL by default
} else {
}
else {
SpringCli.main(args);
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2012-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.cli.command;
import java.io.IOException;
@@ -26,8 +42,11 @@ import org.springframework.util.StringUtils;
public class ShellCommand extends AbstractCommand {
private String defaultPrompt = "$ ";
private SpringCli springCli;
private String prompt = this.defaultPrompt;
private Stack<String> prompts = new Stack<String>();
public ShellCommand(SpringCli springCli) {
@@ -186,8 +205,8 @@ public class ShellCommand extends AbstractCommand {
String version = ShellCommand.class.getPackage().getImplementationVersion();
version = (version == null ? "" : " (v" + version + ")");
System.out.println("Spring Boot CLI" + version);
System.out
.println("Hit TAB to complete. Type 'help' and hit RETURN for help, and 'quit' to exit.");
System.out.println("Hit TAB to complete. Type 'help' and hit "
+ "RETURN for help, and 'quit' to exit.");
}
public void pushPrompt(String prompt) {

View File

@@ -1,7 +1,21 @@
/*
* Copyright 2012-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.cli.command;
import org.springframework.boot.cli.command.AbstractCommand;
import org.springframework.boot.cli.command.RunCommand;
/**
* @author Jon Brisbin
@@ -11,13 +25,14 @@ public class StopCommand extends AbstractCommand {
private final RunCommand runCmd;
public StopCommand(RunCommand runCmd) {
super("stop", "Stop the currently-running application started with the 'run' command.");
super("stop",
"Stop the currently-running application started with the 'run' command.");
this.runCmd = runCmd;
}
@Override
public void run(String... strings) throws Exception {
runCmd.stop();
this.runCmd.stop();
}
}

View File

@@ -47,6 +47,7 @@ public final class JreProxySelector implements ProxySelector {
public JreProxySelector() {
}
@Override
public Proxy getProxy(RemoteRepository repository) {
List<java.net.Proxy> proxies = null;
try {
@@ -95,6 +96,7 @@ public final class JreProxySelector implements ProxySelector {
public static final Authentication INSTANCE = new JreProxyAuthentication();
@Override
public void fill(AuthenticationContext context, String key,
Map<String, String> data) {
Proxy proxy = context.getProxy();
@@ -136,6 +138,7 @@ public final class JreProxySelector implements ProxySelector {
}
}
@Override
public void digest(AuthenticationDigest digest) {
// we don't know anything about the JRE's current authenticator, assume the
// worst (i.e. interactive)

View File

@@ -59,7 +59,7 @@ public class SampleActuatorNoWebApplicationTests {
context.close();
}
}
@Test
public void endpointsExist() throws Exception {
assertNotNull(context.getBean(MetricsEndpoint.class));

View File

@@ -53,7 +53,8 @@ public class SampleSecureApplication extends WebMvcConfigurerAdapter {
public static void main(String[] args) throws Exception {
// Set user password to "password" for demo purposes only
new SpringApplicationBuilder(SampleSecureApplication.class).properties(
"security.basic.enabled=false", "security.user.password=password").run(args);
"security.basic.enabled=false", "security.user.password=password").run(
args);
}
@Override

View File

@@ -57,7 +57,7 @@ public class SampleSecureApplicationTests {
new Callable<ConfigurableApplicationContext>() {
@Override
public ConfigurableApplicationContext call() throws Exception {
return (ConfigurableApplicationContext) SpringApplication
return SpringApplication
.run(SampleSecureApplication.class);
}
});

View File

@@ -32,14 +32,14 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@EnableAutoConfiguration
public class SampleServletApplication {
@SuppressWarnings("serial")
@Bean
public Servlet dispatcherServlet() {
return new GenericServlet() {
@Override
public void service(ServletRequest req, ServletResponse res) throws ServletException,
IOException {
public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException {
res.setContentType("text/plain");
res.getWriter().append("Hello World");
}

View File

@@ -67,8 +67,8 @@ public class SampleServletApplicationTests {
@Test
public void testHome() throws Exception {
ResponseEntity<String> entity = getRestTemplate("user", getPassword()).getForEntity(
"http://localhost:8080", String.class);
ResponseEntity<String> entity = getRestTemplate("user", getPassword())
.getForEntity("http://localhost:8080", String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("Hello World", entity.getBody());
}

View File

@@ -56,7 +56,8 @@ public class NonAutoConfigurationSampleTomcatApplicationTests {
@Configuration
@Import({ EmbeddedServletContainerAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class })
@ComponentScan(basePackageClasses = { SampleController.class, HelloWorldService.class })
public static class NonAutoConfigurationSampleTomcatApplication {

View File

@@ -14,9 +14,9 @@ public class WelcomeController {
private String message = "Hello World";
@RequestMapping("/")
public String welcome(Map<String,Object> model) {
public String welcome(Map<String, Object> model) {
model.put("time", new Date());
model.put("message", message );
model.put("message", message);
return "welcome";
}

View File

@@ -43,8 +43,7 @@ public class SpringBootPlugin implements Plugin<Project> {
// register BootRepackage so that we can use
// task foo(type: BootRepackage) {}
project.getExtensions().getExtraProperties()
.set("BootRepackage", Repackage.class);
project.getExtensions().getExtraProperties().set("BootRepackage", Repackage.class);
Repackage packageTask = addRepackageTask(project);
ensureTaskRunsOnAssembly(project, packageTask);
addRunJarTask(project);

View File

@@ -1,3 +1,4 @@
package org.springframework.boot.gradle.task;
import java.io.File;
@@ -20,6 +21,7 @@ class ProjectLibraries implements Libraries {
private final Project project;
private String providedConfigurationName = "providedRuntime";
private String customConfigurationName = null;
/**
@@ -47,18 +49,16 @@ class ProjectLibraries implements Libraries {
@Override
public void doWithLibraries(LibraryCallback callback) throws IOException {
FileCollection custom = this.customConfigurationName != null ? this.project
.getConfigurations().findByName(this.customConfigurationName) : null;
FileCollection custom = this.customConfigurationName != null ? this.project.getConfigurations().findByName(
this.customConfigurationName)
: null;
if (custom != null) {
libraries(LibraryScope.CUSTOM, custom, callback);
}
else {
FileCollection compile = this.project.getConfigurations()
.getByName("compile");
} else {
FileCollection compile = this.project.getConfigurations().getByName("compile");
FileCollection runtime = this.project.getConfigurations()
.getByName("runtime");
FileCollection runtime = this.project.getConfigurations().getByName("runtime");
runtime = runtime.minus(compile);
FileCollection provided = this.project.getConfigurations().findByName(

View File

@@ -57,8 +57,7 @@ public class Repackage extends DefaultTask {
}
if (this.customConfiguration != null) {
libraries.setCustomConfigurationName(this.customConfiguration);
}
else if (extension.getCustomConfiguration() != null) {
} else if (extension.getCustomConfiguration() != null) {
libraries.setCustomConfigurationName(extension.getCustomConfiguration());
}
project.getTasks().withType(Jar.class, new Action<Jar>() {

View File

@@ -39,7 +39,7 @@ import org.springframework.boot.loader.AsciiBytes;
/**
* {@link Archive} implementation backed by an exploded archive directory.
*
*
* @author Phillip Webb
*/
public class ExplodedArchive extends Archive {
@@ -72,7 +72,8 @@ public class ExplodedArchive extends Archive {
private void buildEntries(File file) {
if (!file.equals(this.root)) {
String name = file.toURI().getPath().substring(root.toURI().getPath().length());
String name = file.toURI().getPath()
.substring(root.toURI().getPath().length());
FileEntry entry = new FileEntry(new AsciiBytes(name), file);
this.entries.put(entry.getName(), entry);
}
@@ -88,7 +89,7 @@ public class ExplodedArchive extends Archive {
@Override
public URL getUrl() throws MalformedURLException {
FilteredURLStreamHandler handler = new FilteredURLStreamHandler();
return new URL("file", "", -1, this.root.toURI().getPath(), handler);
return new URL("file", "", -1, this.root.toURI().getPath(), handler);
}
@Override

View File

@@ -121,8 +121,8 @@ public class ExplodedArchiveTests {
Archive nested = this.archive.getNestedArchive(entry);
Map<String, Entry> nestedEntries = getEntriesMap(nested);
assertThat(nestedEntries.size(), equalTo(1));
assertThat(nested.getUrl().toString(),
equalTo("file:" + this.rootFolder.toURI().getPath() + "d/"));
assertThat(nested.getUrl().toString(), equalTo("file:"
+ this.rootFolder.toURI().getPath() + "d/"));
}
@Test

View File

@@ -76,24 +76,29 @@ public class SimpleJsonParser implements JsonParser {
if (json.startsWith("[")) {
return parseListInternal(json);
}
if (json.startsWith("{")) {
return parseMapInternal(json);
}
if (json.startsWith("\"")) {
return trimTrailingCharacter(trimLeadingCharacter(json, '"'), '"');
}
try {
return Long.valueOf(json);
}
catch (NumberFormatException e) {
// ignore
}
try {
return Double.valueOf(json);
}
catch (NumberFormatException e) {
// ignore
}
return json;
}

View File

@@ -45,6 +45,7 @@ public interface EmbeddedServletContainer {
// Do nothing
}
@Override
public int getPort() {
return 0;
}

View File

@@ -330,7 +330,8 @@ public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProc
if (resource != null && resource.exists()) {
for (PropertySourceLoader loader : loaders) {
if (loader.supports(resource)) {
PropertySource<?> propertySource = loader.load(resource.getDescription(), resource);
PropertySource<?> propertySource = loader.load(
resource.getDescription(), resource);
propertySources.addFirst(propertySource);
}
}

View File

@@ -77,11 +77,10 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem {
Assert.notNull(configLocation, "ConfigLocation must not be null");
String resolvedLocation = SystemPropertyUtils.resolvePlaceholders(configLocation);
ILoggerFactory factory = StaticLoggerBinder.getSingleton().getLoggerFactory();
Assert.isInstanceOf(
LoggerContext.class,
factory,
"LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation ("
+ factory.getClass() + ")");
Assert.isInstanceOf(LoggerContext.class, factory,
"LoggerFactory is not a Logback LoggerContext but "
+ "Logback is on the classpath. Either remove Logback "
+ "or the competing implementation (" + factory.getClass() + ")");
LoggerContext context = (LoggerContext) factory;
context.stop();
try {

View File

@@ -179,6 +179,7 @@ public class MockEmbeddedServletContainerFactory extends
return this.registeredFilters;
}
@Override
public int getPort() {
return this.port;
}