Commit 1bcd3de7 authored by Phillip Webb's avatar Phillip Webb

Polish

parent 0f9c7059
......@@ -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
......@@ -55,6 +55,7 @@ public abstract class AbstractEndpoint<T> implements Endpoint<T> {
this.id = id;
}
@Override
public boolean isEnabled() {
return this.enabled;
}
......
......@@ -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 {
......
......@@ -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);
......
......@@ -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 {
......
......@@ -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());
......
......@@ -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));
......
......@@ -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}"
}
}
\ No newline at end of file
}
/*
* 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;
......
/*
* 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();
}
}
......
/*
* 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);
}
}
......
/*
* 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) {
......
/*
* 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();
}
}
......@@ -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)
......
......@@ -59,7 +59,7 @@ public class SampleActuatorNoWebApplicationTests {
context.close();
}
}
@Test
public void endpointsExist() throws Exception {
assertNotNull(context.getBean(MetricsEndpoint.class));
......
......@@ -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
......
......@@ -57,7 +57,7 @@ public class SampleSecureApplicationTests {
new Callable<ConfigurableApplicationContext>() {
@Override
public ConfigurableApplicationContext call() throws Exception {
return (ConfigurableApplicationContext) SpringApplication
return SpringApplication
.run(SampleSecureApplication.class);
}
});
......
......@@ -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");
}
......
......@@ -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());
}
......
......@@ -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 {
......
......@@ -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";
}
......
......@@ -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);
......
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(
......
......@@ -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>() {
......
......@@ -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
......
......@@ -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
......
......@@ -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;
}
......
......@@ -45,6 +45,7 @@ public interface EmbeddedServletContainer {
// Do nothing
}
@Override
public int getPort() {
return 0;
}
......
......@@ -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);
}
}
......
......@@ -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 {
......
......@@ -179,6 +179,7 @@ public class MockEmbeddedServletContainerFactory extends
return this.registeredFilters;
}
@Override
public int getPort() {
return this.port;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment