mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Final polish before 1.0.0.RC1
This commit is contained in:
parent
853b0a8027
commit
ac54d7fe3c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -53,6 +53,7 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
|
||||
* Configuration triggered from {@link EndpointWebMvcAutoConfiguration} when a new
|
||||
* {@link EmbeddedServletContainer} running on a different port is required.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @see EndpointWebMvcAutoConfiguration
|
||||
*/
|
||||
@Configuration
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -48,11 +48,9 @@ import org.springframework.messaging.support.ExecutorSubscribableChannel;
|
||||
import com.codahale.metrics.MetricRegistry;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for metrics services. Creates
|
||||
* user-facing {@link GaugeService} and {@link CounterService} instances, and also back
|
||||
* end repositories to catch the data pumped into them.
|
||||
* </p>
|
||||
* end repositories to catch the data pumped into them. </p>
|
||||
* <p>
|
||||
* An {@link InMemoryMetricRepository} is always created unless another
|
||||
* {@link MetricRepository} is already provided by the user. In general, even if metric
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -21,7 +21,6 @@ import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* Abstract base for {@link Endpoint} implementations.
|
||||
* <p>
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Christian Dupuis
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -35,7 +35,6 @@ public class TraceEndpoint extends AbstractEndpoint<List<Trace>> {
|
||||
|
||||
/**
|
||||
* Create a new {@link TraceEndpoint} instance.
|
||||
*
|
||||
* @param repository the trace repository
|
||||
*/
|
||||
public TraceEndpoint(TraceRepository repository) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@ -184,8 +184,6 @@ public class EndpointMBeanExporter extends MBeanExporter implements SmartLifecyc
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
// SmartLifeCycle implementation
|
||||
|
||||
@Override
|
||||
public final int getPhase() {
|
||||
return this.phase;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -46,7 +46,6 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
|
||||
* @author Phillip Webb
|
||||
* @author Christian Dupuis
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class EndpointHandlerMapping extends RequestMappingHandlerMapping implements
|
||||
ApplicationContextAware {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -17,18 +17,26 @@
|
||||
package org.springframework.boot.actuate.endpoint.mvc;
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.Endpoint;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* Adapter class to expose {@link Endpoint}s as {@link MvcEndpoint}s.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class GenericMvcEndpoint implements MvcEndpoint {
|
||||
public class EndpointMvcAdapter implements MvcEndpoint {
|
||||
|
||||
private Endpoint<?> delegate;
|
||||
private final Endpoint<?> delegate;
|
||||
|
||||
public GenericMvcEndpoint(Endpoint<?> delegate) {
|
||||
/**
|
||||
* Create a new {@link EndpointMvcAdapter}.
|
||||
* @param delegate the underlying {@link Endpoint} to adapt.
|
||||
*/
|
||||
public EndpointMvcAdapter(Endpoint<?> delegate) {
|
||||
Assert.notNull(delegate, "Delegate must not be null");
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@ -49,11 +57,9 @@ public class GenericMvcEndpoint implements MvcEndpoint {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getEndpointType() {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends Endpoint<?>> type = (Class<? extends Endpoint<?>>) this.delegate
|
||||
.getClass();
|
||||
return type;
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Class<? extends Endpoint> getEndpointType() {
|
||||
return this.delegate.getClass();
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -27,9 +27,11 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
/**
|
||||
* Adapter to expose {@link EnvironmentEndpoint} as an {@link MvcEndpoint}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class EnvironmentMvcEndpoint extends GenericMvcEndpoint implements
|
||||
public class EnvironmentMvcEndpoint extends EndpointMvcAdapter implements
|
||||
EnvironmentAware {
|
||||
|
||||
private Environment environment;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@ -38,8 +38,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.ServletWrappingController;
|
||||
|
||||
/**
|
||||
* {@link Endpoint} implementation to register the Jolokia infrastructure with the Boot
|
||||
* management subsystem.
|
||||
* {@link MvcEndpoint} to expose Jolokia.
|
||||
*
|
||||
* @author Christian Dupuis
|
||||
*/
|
||||
@ -110,7 +109,8 @@ public class JolokiaMvcEndpoint implements MvcEndpoint, InitializingBean,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getEndpointType() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Class<? extends Endpoint> getEndpointType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -18,17 +18,19 @@ package org.springframework.boot.actuate.endpoint.mvc;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.Endpoint;
|
||||
import org.springframework.boot.actuate.web.ErrorController;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
|
||||
/**
|
||||
* Special endpoint for handling "/error" path when the management servlet is in a child
|
||||
* context. The regular {@link ErrorController} should be available there but because of
|
||||
* the way the handler mappings are set up it will not be detected.
|
||||
* Special {@link MvcEndpoint} for handling "/error" path when the management servlet is
|
||||
* in a child context. The regular {@link ErrorController} should be available there but
|
||||
* because of the way the handler mappings are set up it will not be detected.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@ -36,9 +38,11 @@ import org.springframework.web.context.request.RequestContextHolder;
|
||||
public class ManagementErrorEndpoint implements MvcEndpoint {
|
||||
|
||||
private final ErrorController controller;
|
||||
private String path;
|
||||
|
||||
private final String path;
|
||||
|
||||
public ManagementErrorEndpoint(String path, ErrorController controller) {
|
||||
Assert.notNull(controller, "Controller must not be null");
|
||||
this.path = path;
|
||||
this.controller = controller;
|
||||
}
|
||||
@ -61,7 +65,8 @@ public class ManagementErrorEndpoint implements MvcEndpoint {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getEndpointType() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Class<? extends Endpoint> getEndpointType() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -25,11 +25,13 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
/**
|
||||
* Adapter to expose {@link MetricsEndpoint} as an {@link MvcEndpoint}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class MetricsMvcEndpoint extends GenericMvcEndpoint {
|
||||
public class MetricsMvcEndpoint extends EndpointMvcAdapter {
|
||||
|
||||
private MetricsEndpoint delegate;
|
||||
private final MetricsEndpoint delegate;
|
||||
|
||||
public MetricsMvcEndpoint(MetricsEndpoint delegate) {
|
||||
super(delegate);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -29,10 +29,22 @@ import org.springframework.boot.actuate.endpoint.Endpoint;
|
||||
*/
|
||||
public interface MvcEndpoint {
|
||||
|
||||
/**
|
||||
* Return the MVC path of the endpoint.
|
||||
*/
|
||||
String getPath();
|
||||
|
||||
/**
|
||||
* Return if the endpoint exposes sensitive information.
|
||||
*/
|
||||
boolean isSensitive();
|
||||
|
||||
Class<?> getEndpointType();
|
||||
/**
|
||||
* Return the type of {@link Endpoint} exposed, or {@code null} if this
|
||||
* {@link MvcEndpoint} exposes information that cannot be represented as a traditional
|
||||
* {@link Endpoint}.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
Class<? extends Endpoint> getEndpointType();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -60,7 +60,7 @@ public class MvcEndpoints implements ApplicationContextAware, InitializingBean {
|
||||
Endpoint.class).values();
|
||||
for (Endpoint<?> endpoint : delegates) {
|
||||
if (isGenericEndpoint(endpoint.getClass())) {
|
||||
this.endpoints.add(new GenericMvcEndpoint(endpoint));
|
||||
this.endpoints.add(new EndpointMvcAdapter(endpoint));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -85,4 +85,4 @@ public class MvcEndpoints implements ApplicationContextAware, InitializingBean {
|
||||
&& !MvcEndpoint.class.isAssignableFrom(type);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -22,9 +22,11 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* Adapter to expose {@link ShutdownEndpoint} as an {@link MvcEndpoint}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class ShutdownMvcEndpoint extends GenericMvcEndpoint {
|
||||
public class ShutdownMvcEndpoint extends EndpointMvcAdapter {
|
||||
|
||||
public ShutdownMvcEndpoint(ShutdownEndpoint delegate) {
|
||||
super(delegate);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -17,7 +17,7 @@
|
||||
package org.springframework.boot.actuate.health;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link HealthIndicator} that simply returns "ok".
|
||||
* Default implementation of {@link HealthIndicator} that simply returns {@literal "ok"}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -49,7 +49,6 @@ public abstract class AbstractMetricExporter implements Exporter {
|
||||
|
||||
/**
|
||||
* The earliest time for which data will be exported.
|
||||
*
|
||||
* @param earliestTimestamp the timestamp to set
|
||||
*/
|
||||
public void setEarliestTimestamp(Date earliestTimestamp) {
|
||||
@ -58,7 +57,6 @@ public abstract class AbstractMetricExporter implements Exporter {
|
||||
|
||||
/**
|
||||
* Ignore timestamps (export all metrics).
|
||||
*
|
||||
* @param ignoreTimestamps the flag to set
|
||||
*/
|
||||
public void setIgnoreTimestamps(boolean ignoreTimestamps) {
|
||||
@ -96,7 +94,6 @@ public abstract class AbstractMetricExporter implements Exporter {
|
||||
* prefixes). If the metrics to be exported partition into groups identified by a
|
||||
* String, subclasses should override this method. Otherwise the default should be
|
||||
* fine (iteration over all metrics).
|
||||
*
|
||||
* @return groups of metrics to iterate over (default singleton empty string)
|
||||
*/
|
||||
protected Iterable<String> groups() {
|
||||
@ -105,7 +102,6 @@ public abstract class AbstractMetricExporter implements Exporter {
|
||||
|
||||
/**
|
||||
* Write the values associated with a group.
|
||||
*
|
||||
* @param group the group to write
|
||||
* @param values the values to write
|
||||
*/
|
||||
@ -113,10 +109,9 @@ public abstract class AbstractMetricExporter implements Exporter {
|
||||
|
||||
/**
|
||||
* Get the next group of metrics to write.
|
||||
*
|
||||
* @param group the group name to write
|
||||
* @return some metrics to write
|
||||
*/
|
||||
protected abstract Iterable<Metric<?>> next(String group);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -37,6 +37,7 @@ public class InMemoryMetricRepository implements MetricRepository, MultiMetricRe
|
||||
PrefixMetricReader {
|
||||
|
||||
private SimpleInMemoryRepository<Metric<?>> metrics = new SimpleInMemoryRepository<Metric<?>>();
|
||||
|
||||
private Collection<String> groups = new HashSet<String>();
|
||||
|
||||
@Override
|
||||
|
@ -43,6 +43,7 @@ public class RedisMultiMetricRepository implements MultiMetricRepository {
|
||||
private static final String DEFAULT_METRICS_PREFIX = "spring.groups.";
|
||||
|
||||
private String prefix = DEFAULT_METRICS_PREFIX;
|
||||
|
||||
private String keys = this.prefix + "keys";
|
||||
|
||||
private BoundZSetOperations<String, String> zSetOperations;
|
||||
@ -57,7 +58,6 @@ public class RedisMultiMetricRepository implements MultiMetricRepository {
|
||||
|
||||
/**
|
||||
* The prefix for all metrics keys.
|
||||
*
|
||||
* @param prefix the prefix to set for all metrics keys
|
||||
*/
|
||||
public void setPrefix(String prefix) {
|
||||
|
@ -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.actuate.metrics.repository.redis;
|
||||
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
@ -8,6 +24,8 @@ import org.springframework.data.redis.serializer.GenericToStringSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
/**
|
||||
* General Utils for working with Redis.
|
||||
*
|
||||
* @author Luke Taylor
|
||||
*/
|
||||
class RedisUtils {
|
||||
|
@ -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.actuate.metrics.rich;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -30,6 +30,7 @@ import com.codahale.metrics.Timer;
|
||||
/**
|
||||
* A {@link MetricWriter} that send data to a Codahale {@link MetricRegistry} based on a
|
||||
* naming convention:
|
||||
*
|
||||
* <ul>
|
||||
* <li>Updates to {@link #increment(Delta)} with names in "meter.*" are treated as
|
||||
* {@link Meter} events</li>
|
||||
@ -49,7 +50,8 @@ public class CodahaleMetricWriter implements MetricWriter {
|
||||
private final MetricRegistry registry;
|
||||
|
||||
/**
|
||||
* @param registry
|
||||
* Create a new {@link CodahaleMetricWriter} instance.
|
||||
* @param registry the underlying metric registry
|
||||
*/
|
||||
public CodahaleMetricWriter(MetricRegistry registry) {
|
||||
this.registry = registry;
|
||||
@ -94,17 +96,20 @@ public class CodahaleMetricWriter implements MetricWriter {
|
||||
this.registry.remove(metricName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple {@link Gauge} implementation to {@literal double} value.
|
||||
*/
|
||||
private static class SimpleGauge implements Gauge<Double> {
|
||||
|
||||
private final double gauge;
|
||||
private final double value;
|
||||
|
||||
private SimpleGauge(double gauge) {
|
||||
this.gauge = gauge;
|
||||
private SimpleGauge(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getValue() {
|
||||
return this.gauge;
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -54,9 +54,7 @@ public class DefaultCounterService implements CounterService {
|
||||
if (metricName.startsWith("counter") || metricName.startsWith("meter")) {
|
||||
return metricName;
|
||||
}
|
||||
else {
|
||||
return "counter." + metricName;
|
||||
}
|
||||
return "counter." + metricName;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -46,9 +46,7 @@ public class DefaultGaugeService implements GaugeService {
|
||||
|| metricName.startsWith("timer")) {
|
||||
return metricName;
|
||||
}
|
||||
else {
|
||||
return "gauge." + metricName;
|
||||
}
|
||||
return "gauge." + metricName;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -81,6 +81,9 @@ public class ManagementServerProperties implements SecurityPrequisite {
|
||||
return this.security;
|
||||
}
|
||||
|
||||
/**
|
||||
* Security configuration.
|
||||
*/
|
||||
public static class Security {
|
||||
|
||||
private boolean enabled = true;
|
||||
@ -116,11 +119,8 @@ public class ManagementServerProperties implements SecurityPrequisite {
|
||||
}
|
||||
|
||||
private static Security maybeCreateSecurity() {
|
||||
if (ClassUtils
|
||||
.isPresent("org.springframework.security.core.Authentication", null)) {
|
||||
return new Security();
|
||||
}
|
||||
return null;
|
||||
return (ClassUtils.isPresent("org.springframework.security.core.Authentication",
|
||||
null) ? new Security() : null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -36,7 +36,6 @@ public interface ErrorController {
|
||||
|
||||
/**
|
||||
* Extract a useful model of the error from the request attributes.
|
||||
*
|
||||
* @param attributes the request attributes
|
||||
* @param trace flag to indicate that stack trace information should be included
|
||||
* @return a model containing error messages and codes etc.
|
||||
|
@ -260,7 +260,8 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getEndpointType() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Class<? extends Endpoint> getEndpointType() {
|
||||
return Endpoint.class;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -146,7 +146,7 @@ public class EndpointHandlerMappingTests {
|
||||
|
||||
}
|
||||
|
||||
private static class TestMvcEndpoint extends GenericMvcEndpoint {
|
||||
private static class TestMvcEndpoint extends EndpointMvcAdapter {
|
||||
|
||||
public TestMvcEndpoint(TestEndpoint delegate) {
|
||||
super(delegate);
|
||||
@ -154,7 +154,7 @@ public class EndpointHandlerMappingTests {
|
||||
|
||||
}
|
||||
|
||||
private static class TestActionEndpoint extends GenericMvcEndpoint {
|
||||
private static class TestActionEndpoint extends EndpointMvcAdapter {
|
||||
|
||||
public TestActionEndpoint(TestEndpoint delegate) {
|
||||
super(delegate);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -54,10 +54,9 @@ public class RedisServer implements TestRule {
|
||||
try {
|
||||
this.resource = obtainResource();
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception ex) {
|
||||
maybeCleanup();
|
||||
|
||||
return failOrSkip(e);
|
||||
return failOrSkip(ex);
|
||||
}
|
||||
|
||||
return new Statement() {
|
||||
@ -82,17 +81,18 @@ public class RedisServer implements TestRule {
|
||||
};
|
||||
}
|
||||
|
||||
private Statement failOrSkip(Exception e) {
|
||||
private Statement failOrSkip(Exception exception) {
|
||||
String serversRequired = System.getenv(EXTERNAL_SERVERS_REQUIRED);
|
||||
if ("true".equalsIgnoreCase(serversRequired)) {
|
||||
logger.error(this.resourceDescription + " IS REQUIRED BUT NOT AVAILABLE", e);
|
||||
logger.error(this.resourceDescription + " IS REQUIRED BUT NOT AVAILABLE",
|
||||
exception);
|
||||
fail(this.resourceDescription + " IS NOT AVAILABLE");
|
||||
// Never reached, here to satisfy method signature
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
logger.error(this.resourceDescription + " IS NOT AVAILABLE, SKIPPING TESTS",
|
||||
e);
|
||||
exception);
|
||||
return new Statement() {
|
||||
|
||||
@Override
|
||||
|
@ -40,7 +40,6 @@ import org.springframework.util.StringUtils;
|
||||
* the {@link AutoConfigurationReport} to the log. Reports are logged at the
|
||||
* {@link LogLevel#DEBUG DEBUG} level unless there was a problem, in which case they are
|
||||
* the {@link LogLevel#INFO INFO} level is used.
|
||||
*
|
||||
* <p>
|
||||
* This initializer is not intended to be shared across multiple application context
|
||||
* instances.
|
||||
|
@ -39,20 +39,17 @@ import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||
* have {@code tomat-embedded.jar} on your classpath you are likely to want a
|
||||
* {@link TomcatEmbeddedServletContainerFactory} (unless you have defined your own
|
||||
* {@link EmbeddedServletContainerFactory} bean).
|
||||
*
|
||||
* <p>
|
||||
* Auto-configuration tries to be as intelligent as possible and will back-away as you
|
||||
* define more of your own configuration. You can always manually {@link #exclude()} any
|
||||
* configuration that you never want to apply. Auto-configuration is always applied after
|
||||
* user-defined beans have been registered.
|
||||
*
|
||||
* <p>
|
||||
* The package of the class that is annotated with {@code @EnableAutoConfiguration} has
|
||||
* specific significance and is often used as a 'default'. For example, it will be used
|
||||
* when scanning for {@code @Entity} classes. It is generally recommended that you place
|
||||
* {@code @EnableAutoConfiguration} in a root package so that all sub-packages and classes
|
||||
* can be searched.
|
||||
*
|
||||
* <p>
|
||||
* Auto-configuration classes are regular Spring {@link Configuration} beans. They are
|
||||
* located using the {@link SpringFactoriesLoader} mechanism (keyed against this class).
|
||||
|
@ -33,6 +33,8 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
/**
|
||||
* Basic {@link BatchConfigurer} implementation.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@Component
|
||||
@ -41,15 +43,28 @@ public class BasicBatchConfigurer implements BatchConfigurer {
|
||||
private static Log logger = LogFactory.getLog(BasicBatchConfigurer.class);
|
||||
|
||||
private DataSource dataSource;
|
||||
|
||||
private EntityManagerFactory entityManagerFactory;
|
||||
|
||||
private PlatformTransactionManager transactionManager;
|
||||
|
||||
private JobRepository jobRepository;
|
||||
|
||||
private JobLauncher jobLauncher;
|
||||
|
||||
/**
|
||||
* Create a new {@link BasicBatchConfigurer} instance.
|
||||
* @param dataSource the underlying data source
|
||||
*/
|
||||
public BasicBatchConfigurer(DataSource dataSource) {
|
||||
this(dataSource, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link BasicBatchConfigurer} instance.
|
||||
* @param dataSource the underlying data source
|
||||
* @param entityManagerFactory the entity manager factory (or {@code null})
|
||||
*/
|
||||
public BasicBatchConfigurer(DataSource dataSource,
|
||||
EntityManagerFactory entityManagerFactory) {
|
||||
this.entityManagerFactory = entityManagerFactory;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -38,7 +38,8 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class BatchDatabaseInitializer implements EnvironmentAware {
|
||||
|
||||
private static final String DEFAULT_SCHEMA_LOCATION = "classpath:org/springframework/batch/core/schema-@@platform@@.sql";
|
||||
private static final String DEFAULT_SCHEMA_LOCATION = "classpath:org/springframework/"
|
||||
+ "batch/core/schema-@@platform@@.sql";
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -198,16 +198,26 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
|
||||
if (this.types.isEmpty() && this.names.isEmpty()) {
|
||||
addDeducedBeanType(context, metadata, this.types);
|
||||
}
|
||||
Assert.isTrue(
|
||||
!this.types.isEmpty() || !this.names.isEmpty()
|
||||
|| !this.annotations.isEmpty(),
|
||||
"@"
|
||||
+ ClassUtils.getShortName(annotationType)
|
||||
+ " annotations must specify at least one bean (type, name or annotation)");
|
||||
Assert.isTrue(hasAtLeastOne(this.types, this.names, this.annotations),
|
||||
annotationName(annotationType) + " annotations must "
|
||||
+ "specify at least one bean (type, name or annotation)");
|
||||
this.strategy = (SearchStrategy) metadata.getAnnotationAttributes(
|
||||
annotationType.getName()).get("search");
|
||||
}
|
||||
|
||||
private boolean hasAtLeastOne(List<?>... lists) {
|
||||
for (List<?> list : lists) {
|
||||
if (!list.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String annotationName(Class<?> annotationType) {
|
||||
return "@" + ClassUtils.getShortName(annotationType);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private void collect(MultiValueMap<String, Object> attributes, String key,
|
||||
List<String> destination) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -34,7 +34,8 @@ import org.springframework.web.context.support.StandardServletEnvironment;
|
||||
*/
|
||||
class OnWebApplicationCondition extends SpringBootCondition {
|
||||
|
||||
private static final String WEB_CONTEXT_CLASS = "org.springframework.web.context.support.GenericWebApplicationContext";
|
||||
private static final String WEB_CONTEXT_CLASS = "org.springframework.web.context."
|
||||
+ "support.GenericWebApplicationContext";
|
||||
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -31,9 +31,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
|
||||
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
||||
import org.springframework.boot.bind.RelaxedPropertyResolver;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@ -177,6 +177,9 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Base {@link Condition} for non-embedded database checks.
|
||||
*/
|
||||
static abstract class NonEmbeddedDatabaseCondition extends SpringBootCondition {
|
||||
|
||||
protected abstract String getDataSourceClassName();
|
||||
@ -243,6 +246,10 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Condition} to detect when a commons-dbcp {@code BasicDataSource} backed
|
||||
* database is used.
|
||||
*/
|
||||
static class BasicDatabaseCondition extends NonEmbeddedDatabaseCondition {
|
||||
|
||||
private Condition tomcatCondition = new TomcatDatabaseCondition();
|
||||
@ -256,12 +263,15 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
if (matches(context, metadata, this.tomcatCondition)) {
|
||||
return ConditionOutcome.noMatch("tomcat DataSource");
|
||||
return ConditionOutcome.noMatch("Tomcat DataSource");
|
||||
}
|
||||
return super.getMatchOutcome(context, metadata);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Condition} to detect when a Tomcat DataSource backed database is used.
|
||||
*/
|
||||
static class TomcatDatabaseCondition extends NonEmbeddedDatabaseCondition {
|
||||
|
||||
@Override
|
||||
@ -271,6 +281,9 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Condition} to detect when an embedded database is used.
|
||||
*/
|
||||
static class EmbeddedDatabaseCondition extends SpringBootCondition {
|
||||
|
||||
private SpringBootCondition tomcatCondition = new TomcatDatabaseCondition();
|
||||
@ -293,6 +306,9 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Condition} to detect when a database is configured.
|
||||
*/
|
||||
static class DatabaseCondition extends SpringBootCondition {
|
||||
|
||||
private SpringBootCondition tomcatCondition = new TomcatDatabaseCondition();
|
||||
|
@ -80,16 +80,14 @@ public class JmsTemplateAutoConfiguration {
|
||||
private ActiveMQConnectionFactoryProperties config;
|
||||
|
||||
@Bean
|
||||
ConnectionFactory jmsConnectionFactory() {
|
||||
public ConnectionFactory jmsConnectionFactory() {
|
||||
if (this.config.isPooled()) {
|
||||
PooledConnectionFactory pool = new PooledConnectionFactory();
|
||||
pool.setConnectionFactory(new ActiveMQConnectionFactory(this.config
|
||||
.getBrokerURL()));
|
||||
return pool;
|
||||
}
|
||||
else {
|
||||
return new ActiveMQConnectionFactory(this.config.getBrokerURL());
|
||||
}
|
||||
return new ActiveMQConnectionFactory(this.config.getBrokerURL());
|
||||
}
|
||||
|
||||
}
|
||||
@ -108,9 +106,7 @@ public class JmsTemplateAutoConfiguration {
|
||||
if (this.inMemory) {
|
||||
return "vm://localhost";
|
||||
}
|
||||
else {
|
||||
return this.brokerURL;
|
||||
}
|
||||
return this.brokerURL;
|
||||
}
|
||||
|
||||
public void setBrokerURL(String brokerURL) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* 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.
|
||||
@ -27,7 +27,6 @@ import org.springframework.jmx.export.MBeanExporter;
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} to enable/disable Spring's
|
||||
* {@link EnableMBeanExport} mechanism based on configuration properties.
|
||||
*
|
||||
* <p>
|
||||
* To disable auto export of annotation beans set <code>spring.jmx.enabled: false</code>.
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -48,7 +48,6 @@ public class ReactorAutoConfiguration {
|
||||
@ConditionalOnMissingBean(Environment.class)
|
||||
@EnableReactor
|
||||
protected static class ReactorConfiguration {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,6 +33,11 @@ import org.springframework.security.config.annotation.ObjectPostProcessor;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.authentication.configurers.provisioning.InMemoryUserDetailsManagerConfigurer;
|
||||
|
||||
/**
|
||||
* Configuration for a Spring Security in-memory {@link AuthenticationManager}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnBean(ObjectPostProcessor.class)
|
||||
@ConditionalOnMissingBean(AuthenticationManager.class)
|
||||
@ -69,4 +74,4 @@ public class AuthenticationManagerConfiguration {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.boot.autoconfigure.security;
|
||||
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
@ -24,6 +25,11 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Spring Security.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass(AuthenticationManager.class)
|
||||
@EnableConfigurationProperties
|
||||
@ -37,4 +43,4 @@ public class SecurityAutoConfiguration {
|
||||
return new SecurityProperties();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,6 @@ import org.springframework.web.servlet.support.RequestDataValueProcessor;
|
||||
@ConditionalOnClass({ EnableWebSecurity.class })
|
||||
@ConditionalOnMissingBean(WebSecurityConfiguration.class)
|
||||
@ConditionalOnWebApplication
|
||||
// @ConditionalOnMissingBean(annotation = EnableWebSecurity.class)
|
||||
public class SpringBootWebSecurityConfiguration {
|
||||
|
||||
private static List<String> DEFAULT_IGNORED = Arrays.asList("/css/**", "/js/**",
|
||||
@ -107,6 +106,39 @@ public class SpringBootWebSecurityConfiguration {
|
||||
return new IgnoredPathsWebSecurityConfigurerAdapter();
|
||||
}
|
||||
|
||||
public static void configureHeaders(HeadersConfigurer<?> configurer,
|
||||
SecurityProperties.Headers headers) throws Exception {
|
||||
if (headers.getHsts() != Headers.HSTS.none) {
|
||||
boolean includeSubdomains = headers.getHsts() == Headers.HSTS.all;
|
||||
HstsHeaderWriter writer = new HstsHeaderWriter(includeSubdomains);
|
||||
writer.setRequestMatcher(AnyRequestMatcher.INSTANCE);
|
||||
configurer.addHeaderWriter(writer);
|
||||
}
|
||||
if (headers.isContentType()) {
|
||||
configurer.contentTypeOptions();
|
||||
}
|
||||
if (headers.isXss()) {
|
||||
configurer.xssProtection();
|
||||
}
|
||||
if (headers.isCache()) {
|
||||
configurer.cacheControl();
|
||||
}
|
||||
if (headers.isFrame()) {
|
||||
configurer.frameOptions();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getIgnored(SecurityProperties security) {
|
||||
List<String> ignored = new ArrayList<String>(security.getIgnored());
|
||||
if (ignored.isEmpty()) {
|
||||
ignored.addAll(DEFAULT_IGNORED);
|
||||
}
|
||||
else if (ignored.contains("none")) {
|
||||
ignored.remove("none");
|
||||
}
|
||||
return ignored;
|
||||
}
|
||||
|
||||
// Get the ignored paths in early
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
private static class IgnoredPathsWebSecurityConfigurerAdapter implements
|
||||
@ -135,10 +167,12 @@ public class SpringBootWebSecurityConfiguration {
|
||||
@ConditionalOnExpression("${security.basic.enabled:true}")
|
||||
@Configuration
|
||||
protected static class WebMvcSecurityConfigurationConditions {
|
||||
|
||||
@Configuration
|
||||
@EnableWebMvcSecurity
|
||||
protected static class DefaultWebMvcSecurityConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Pull in a plain @EnableWebSecurity if Spring MVC is not available
|
||||
@ -223,37 +257,4 @@ public class SpringBootWebSecurityConfiguration {
|
||||
|
||||
}
|
||||
|
||||
public static void configureHeaders(HeadersConfigurer<?> configurer,
|
||||
SecurityProperties.Headers headers) throws Exception {
|
||||
if (headers.getHsts() != Headers.HSTS.none) {
|
||||
boolean includeSubdomains = headers.getHsts() == Headers.HSTS.all;
|
||||
HstsHeaderWriter writer = new HstsHeaderWriter(includeSubdomains);
|
||||
writer.setRequestMatcher(AnyRequestMatcher.INSTANCE);
|
||||
configurer.addHeaderWriter(writer);
|
||||
}
|
||||
if (headers.isContentType()) {
|
||||
configurer.contentTypeOptions();
|
||||
}
|
||||
if (headers.isXss()) {
|
||||
configurer.xssProtection();
|
||||
}
|
||||
if (headers.isCache()) {
|
||||
configurer.cacheControl();
|
||||
}
|
||||
if (headers.isFrame()) {
|
||||
configurer.frameOptions();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getIgnored(SecurityProperties security) {
|
||||
List<String> ignored = new ArrayList<String>(security.getIgnored());
|
||||
if (ignored.isEmpty()) {
|
||||
ignored.addAll(DEFAULT_IGNORED);
|
||||
}
|
||||
else if (ignored.contains("none")) {
|
||||
ignored.remove("none");
|
||||
}
|
||||
return ignored;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ public final class CommandLineInvoker {
|
||||
lines.add(line);
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
catch (IOException ex) {
|
||||
throw new RuntimeException("Failed to read standard output");
|
||||
}
|
||||
return lines;
|
||||
|
@ -112,11 +112,14 @@ public class CommandCompleter extends StringsCompleter {
|
||||
}
|
||||
this.console.drawLine();
|
||||
}
|
||||
catch (IOException e) {
|
||||
Log.error(e.getMessage() + " (" + e.getClass().getName() + ")");
|
||||
catch (IOException ex) {
|
||||
Log.error(ex.getMessage() + " (" + ex.getClass().getName() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encapsulated options and usage help.
|
||||
*/
|
||||
private static class OptionHelpLine {
|
||||
|
||||
private final String options;
|
||||
|
@ -20,7 +20,7 @@ import jline.console.completer.ArgumentCompleter.ArgumentList;
|
||||
import jline.console.completer.ArgumentCompleter.WhitespaceArgumentDelimiter;
|
||||
|
||||
/**
|
||||
* Escape ware variant of {@link WhitespaceArgumentDelimiter}.
|
||||
* Escape aware variant of {@link WhitespaceArgumentDelimiter}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
|
@ -103,7 +103,7 @@ class RunProcessCommand extends AbstractCommand {
|
||||
}
|
||||
reader.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception ex) {
|
||||
}
|
||||
};
|
||||
}.start();
|
||||
@ -135,7 +135,7 @@ class RunProcessCommand extends AbstractCommand {
|
||||
this.process = null;
|
||||
return true;
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
@ -64,8 +64,7 @@ import org.springframework.boot.cli.util.ResourceUtils;
|
||||
*
|
||||
* <li>Generated class files can also be loaded using
|
||||
* {@link ClassLoader#getResource(String)}</li>
|
||||
*
|
||||
* <ul>
|
||||
* </ul>
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Dave Syer
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -61,7 +61,6 @@ public final class RepositoryConfigurationFactory {
|
||||
/**
|
||||
* Add the default local M2 cache directory as a remote repository. Only do this if
|
||||
* the local cache location has been changed from the default.
|
||||
*
|
||||
* @param repositoryConfiguration
|
||||
*/
|
||||
public static void addDefaultCacheAsRespository(
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -54,7 +54,7 @@ public final class JreProxySelector implements ProxySelector {
|
||||
URI uri = new URI(repository.getUrl()).parseServerAuthority();
|
||||
proxies = java.net.ProxySelector.getDefault().select(uri);
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception ex) {
|
||||
// URL invalid or not accepted by selector or no selector at all, simply use
|
||||
// no proxy
|
||||
}
|
||||
@ -113,7 +113,7 @@ public final class JreProxySelector implements ProxySelector {
|
||||
try {
|
||||
url = new URL(context.getRepository().getUrl());
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception ex) {
|
||||
url = null;
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ public final class JreProxySelector implements ProxySelector {
|
||||
System.getProperty("http.proxyPassword"));
|
||||
}
|
||||
}
|
||||
catch (SecurityException e) {
|
||||
catch (SecurityException ex) {
|
||||
// oh well, let's hope the proxy can do without auth
|
||||
}
|
||||
}
|
||||
|
@ -28,5 +28,9 @@ import org.eclipse.aether.graph.Dependency;
|
||||
*/
|
||||
public interface ManagedDependenciesFactory {
|
||||
|
||||
/**
|
||||
* Returns the managed dependencies.
|
||||
*/
|
||||
List<Dependency> getManagedDependencies();
|
||||
|
||||
}
|
||||
|
@ -34,8 +34,7 @@ public final class RepositoryConfiguration {
|
||||
private final boolean snapshotsEnabled;
|
||||
|
||||
/**
|
||||
* Creates a new {@code RepositoryConfiguration}.
|
||||
*
|
||||
* Creates a new {@code RepositoryConfiguration} instance.
|
||||
* @param name The name of the repository
|
||||
* @param uri The uri of the repository
|
||||
* @param snapshotsEnabled {@code true} if the repository should enable access to
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -101,7 +101,6 @@ public class GroovyBeansTransformation implements ASTTransformation {
|
||||
/**
|
||||
* Extract a top-level <code>beans{}</code> closure from inside this block if
|
||||
* there is one. Removes it from the block at the same time.
|
||||
*
|
||||
* @param block a block statement (class definition)
|
||||
* @return a beans Closure if one can be found, null otherwise
|
||||
*/
|
||||
@ -128,9 +127,7 @@ public class GroovyBeansTransformation implements ASTTransformation {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -22,9 +22,14 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.boot.cli.compiler.autoconfigure.SpringMobileCompilerAutoConfiguration;
|
||||
|
||||
/**
|
||||
* Pseudo annotation used to trigger {@link SpringMobileCompilerAutoConfiguration}.
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface EnableDeviceResolver {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -22,9 +22,13 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.boot.cli.compiler.autoconfigure.SpringIntegrationCompilerAutoConfiguration;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
|
||||
/**
|
||||
* Pseudo annotation used to trigger {@link SpringIntegrationCompilerAutoConfiguration}.
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ -32,4 +36,4 @@ import org.springframework.context.annotation.ImportResource;
|
||||
@ImportResource("classpath:/org/springframework/boot/groovy/integration.xml")
|
||||
public @interface EnableIntegrationPatterns {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -22,9 +22,14 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.boot.cli.compiler.autoconfigure.JmsCompilerAutoConfiguration;
|
||||
|
||||
/**
|
||||
* Pseudo annotation used to trigger {@link JmsCompilerAutoConfiguration}.
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface EnableJmsMessaging {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -28,6 +28,8 @@ import java.util.Map;
|
||||
import org.codehaus.groovy.control.CompilationFailedException;
|
||||
|
||||
/**
|
||||
* Helpful utilties for working with Groovy {@link Template}s.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public abstract class GroovyTemplate {
|
||||
|
@ -50,9 +50,9 @@ public class SampleMongoApplicationTests {
|
||||
output.contains("firstName='Alice', lastName='Smith'"));
|
||||
}
|
||||
|
||||
private boolean serverNotRunning(IllegalStateException e) {
|
||||
private boolean serverNotRunning(IllegalStateException ex) {
|
||||
@SuppressWarnings("serial")
|
||||
NestedCheckedException nested = new NestedCheckedException("failed", e) {
|
||||
NestedCheckedException nested = new NestedCheckedException("failed", ex) {
|
||||
};
|
||||
if (nested.contains(IOException.class)) {
|
||||
Throwable root = nested.getRootCause();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -19,11 +19,12 @@ package org.springframework.boot.gradle
|
||||
import org.springframework.boot.loader.tools.Layout
|
||||
import org.springframework.boot.loader.tools.Layouts
|
||||
|
||||
|
||||
/**
|
||||
* Gradle DSL Extension for 'Spring Boot'. Most of the time Spring Boot can guess the
|
||||
* settings in this extension, but occasionally you might need to explicitly set one
|
||||
* or two of them. E.g.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* apply plugin: "spring-boot"
|
||||
* springBoot {
|
||||
@ -53,7 +54,7 @@ public class SpringBootPluginExtension {
|
||||
String mainClass
|
||||
|
||||
/**
|
||||
* The name of the ivy configuration name to treat as 'provided' (when packaging
|
||||
* The name of the ivy configuration name to treat as 'provided' (when packaging
|
||||
* those dependencies in a separate path). If not specified 'providedRuntime' will
|
||||
* be used.
|
||||
*/
|
||||
@ -73,15 +74,14 @@ public class SpringBootPluginExtension {
|
||||
* The layout of the archive if it can't be derived from the file extension.
|
||||
* Valid values are JAR, WAR, ZIP, DIR (for exploded zip file). ZIP and DIR
|
||||
* are actually synonymous, and should be used if there is no MANIFEST.MF
|
||||
* available, or if you want the MANIFEST.MF 'Main-Class' to be
|
||||
* PropertiesLauncher. Gradle will coerce literal String values to the
|
||||
* available, or if you want the MANIFEST.MF 'Main-Class' to be
|
||||
* PropertiesLauncher. Gradle will coerce literal String values to the
|
||||
* correct type.
|
||||
*/
|
||||
LayoutType layout;
|
||||
|
||||
/**
|
||||
* Convenience method for use in a custom task.
|
||||
*
|
||||
* @return the Layout to use or null if not explicitly set
|
||||
*/
|
||||
Layout convertLayout() {
|
||||
|
@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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.gradle.task;
|
||||
|
||||
@ -13,7 +28,7 @@ import org.springframework.boot.loader.tools.LibraryScope;
|
||||
|
||||
/**
|
||||
* Expose Gradle {@link Configuration}s as {@link Libraries}.
|
||||
*
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class ProjectLibraries implements Libraries {
|
||||
@ -26,7 +41,6 @@ class ProjectLibraries implements Libraries {
|
||||
|
||||
/**
|
||||
* Create a new {@link ProjectLibraries} instance of the specified {@link Project}.
|
||||
*
|
||||
* @param project the gradle project
|
||||
*/
|
||||
public ProjectLibraries(Project project) {
|
||||
@ -35,7 +49,6 @@ class ProjectLibraries implements Libraries {
|
||||
|
||||
/**
|
||||
* Set the name of the provided configuration. Defaults to 'providedRuntime'.
|
||||
*
|
||||
* @param providedConfigurationName the providedConfigurationName to set
|
||||
*/
|
||||
public void setProvidedConfigurationName(String providedConfigurationName) {
|
||||
|
@ -95,8 +95,8 @@ public class RunApp extends DefaultTask {
|
||||
getLogger().info("Looking for main in: " + main.getOutput().getClassesDir());
|
||||
try {
|
||||
return MainClassFinder.findMainClass(main.getOutput().getClassesDir());
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("Cannot find main class", e);
|
||||
} catch (IOException ex) {
|
||||
throw new IllegalStateException("Cannot find main class", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,6 @@ import org.springframework.boot.loader.util.SystemPropertyUtils;
|
||||
* {@link Launcher} for archives with user-configured classpath and main class via a
|
||||
* properties file. This model is often more flexible and more amenable to creating
|
||||
* well-behaved OS-level services than a model based on executable jars.
|
||||
*
|
||||
* <p>
|
||||
* Looks in various places for a properties file to extract loader settings, defaulting to
|
||||
* <code>application.properties</code> either on the current classpath or in the current
|
||||
@ -62,7 +61,6 @@ import org.springframework.boot.loader.util.SystemPropertyUtils;
|
||||
* <code>file:</code> or any valid URL). Once that file is located turns it into
|
||||
* Properties and extracts optional values (which can also be provided overridden as
|
||||
* System properties in case the file doesn't exist):
|
||||
*
|
||||
* <ul>
|
||||
* <li><code>loader.path</code>: a comma-separated list of directories to append to the
|
||||
* classpath (containing file resources and/or nested archives in *.jar or *.zip).
|
||||
@ -345,7 +343,7 @@ public class PropertiesLauncher extends Launcher {
|
||||
try {
|
||||
return loaderClass.getConstructor(ClassLoader.class).newInstance(parent);
|
||||
}
|
||||
catch (NoSuchMethodException e) {
|
||||
catch (NoSuchMethodException ex) {
|
||||
// Ignore and try with URLs
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -28,11 +28,14 @@ import java.util.jar.Manifest;
|
||||
import org.springframework.boot.loader.AsciiBytes;
|
||||
|
||||
/**
|
||||
* Decorator to apply an {@link Archive.EntryFilter} to an existing {@link Archive}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class FilteredArchive extends Archive {
|
||||
|
||||
private Archive parent;
|
||||
|
||||
private EntryFilter filter;
|
||||
|
||||
public FilteredArchive(Archive parent, EntryFilter filter) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -22,14 +22,11 @@ import java.util.Set;
|
||||
|
||||
/**
|
||||
* Helper class for resolving placeholders in texts. Usually applied to file paths.
|
||||
*
|
||||
* <p>
|
||||
* A text may contain {@code $ ...} placeholders, to be resolved as system properties:
|
||||
* e.g. {@code $ user.dir} . Default values can be supplied using the ":" separator
|
||||
* between key and value.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* Adapted from Spring.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
@ -40,13 +37,19 @@ import java.util.Set;
|
||||
*/
|
||||
public abstract class SystemPropertyUtils {
|
||||
|
||||
/** Prefix for system property placeholders: "${" */
|
||||
/**
|
||||
* Prefix for system property placeholders: "${"
|
||||
*/
|
||||
public static final String PLACEHOLDER_PREFIX = "${";
|
||||
|
||||
/** Suffix for system property placeholders: "}" */
|
||||
/**
|
||||
* Suffix for system property placeholders: "}"
|
||||
*/
|
||||
public static final String PLACEHOLDER_SUFFIX = "}";
|
||||
|
||||
/** Value separator for system property placeholders: ":" */
|
||||
/**
|
||||
* Value separator for system property placeholders: ":"
|
||||
*/
|
||||
public static final String VALUE_SEPARATOR = ":";
|
||||
|
||||
private static final String SIMPLE_PREFIX = PLACEHOLDER_PREFIX.substring(1);
|
||||
@ -166,7 +169,6 @@ public abstract class SystemPropertyUtils {
|
||||
* Search the System properties and environment variables for a value with the
|
||||
* provided key. Environment variables in <code>UPPER_CASE</code> style are allowed
|
||||
* where System properties would normally be <code>lower.case</code>.
|
||||
*
|
||||
* @param key the key to resolve
|
||||
* @param text optional extra context for an error message if the key resolution fails
|
||||
* (e.g. if System properties are not accessible)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -88,14 +88,14 @@ public class SimpleJsonParser implements JsonParser {
|
||||
try {
|
||||
return Long.valueOf(json);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
catch (NumberFormatException ex) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
try {
|
||||
return Double.valueOf(json);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
catch (NumberFormatException ex) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
|
@ -109,8 +109,8 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {
|
||||
ReflectionUtils.findMethod(connector.getClass(), "getLocalPort"),
|
||||
connector)).toString();
|
||||
}
|
||||
catch (Exception e) {
|
||||
return "could not determine port ( " + e.getMessage() + ")";
|
||||
catch (Exception ex) {
|
||||
return "could not determine port ( " + ex.getMessage() + ")";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
package org.springframework.boot.context.embedded.tomcat;
|
||||
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
@ -16,6 +14,8 @@ package org.springframework.boot.context.embedded.tomcat;
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.context.embedded.tomcat;
|
||||
|
||||
import org.apache.catalina.loader.WebappClassLoader;
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Classes and utilities that are useful when unit-testing Spring Boot applications.
|
||||
* This package is only intended for use in 'src/test' and should not be used in your
|
||||
* 'src/main' code.
|
||||
*/
|
||||
package org.springframework.boot.test;
|
||||
|
@ -394,12 +394,14 @@ public class EnableConfigurationPropertiesTests {
|
||||
|
||||
@Configuration
|
||||
protected static class DefaultConfiguration {
|
||||
|
||||
@Bean
|
||||
public TestProperties testProperties() {
|
||||
TestProperties test = new TestProperties();
|
||||
test.setName("bar");
|
||||
return test;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ -410,10 +412,12 @@ public class EnableConfigurationPropertiesTests {
|
||||
@EnableConfigurationProperties
|
||||
@Configuration
|
||||
public static class ExampleConfig {
|
||||
|
||||
@Bean
|
||||
public External external() {
|
||||
return new External();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EnableConfigurationProperties(External.class)
|
||||
@ -461,6 +465,7 @@ public class EnableConfigurationPropertiesTests {
|
||||
|
||||
@ConfigurationProperties(name = "spring_test_external")
|
||||
public static class SystemEnvVar {
|
||||
|
||||
public String getVal() {
|
||||
return this.val;
|
||||
}
|
||||
@ -475,6 +480,7 @@ public class EnableConfigurationPropertiesTests {
|
||||
|
||||
@Component
|
||||
protected static class TestConsumer {
|
||||
|
||||
@Autowired
|
||||
private TestProperties properties;
|
||||
|
||||
@ -495,7 +501,9 @@ public class EnableConfigurationPropertiesTests {
|
||||
|
||||
@ConfigurationProperties
|
||||
protected static class NestedProperties {
|
||||
|
||||
private String name;
|
||||
|
||||
private Nested nested = new Nested();
|
||||
|
||||
public void setName(String name) {
|
||||
@ -507,6 +515,7 @@ public class EnableConfigurationPropertiesTests {
|
||||
}
|
||||
|
||||
protected static class Nested {
|
||||
|
||||
private String name;
|
||||
|
||||
public void setName(String name) {
|
||||
@ -514,15 +523,18 @@ public class EnableConfigurationPropertiesTests {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ConfigurationProperties
|
||||
protected static class BaseProperties {
|
||||
|
||||
private String name;
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected static class DerivedProperties extends BaseProperties {
|
||||
@ -530,8 +542,11 @@ public class EnableConfigurationPropertiesTests {
|
||||
|
||||
@ConfigurationProperties
|
||||
protected static class TestProperties {
|
||||
|
||||
private String name;
|
||||
|
||||
private int[] array;
|
||||
|
||||
private List<Integer> list = new ArrayList<Integer>();
|
||||
|
||||
// No getter - you should be able to bind to a write-only bean
|
||||
@ -551,6 +566,7 @@ public class EnableConfigurationPropertiesTests {
|
||||
public List<Integer> getList() {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ConfigurationProperties(ignoreUnknownFields = false)
|
||||
@ -559,12 +575,10 @@ public class EnableConfigurationPropertiesTests {
|
||||
|
||||
@ConfigurationProperties(name = "spring.foo")
|
||||
protected static class EmbeddedTestProperties extends TestProperties {
|
||||
|
||||
}
|
||||
|
||||
@ConfigurationProperties(ignoreUnknownFields = false, ignoreNestedProperties = true)
|
||||
protected static class IgnoreNestedTestProperties extends TestProperties {
|
||||
|
||||
}
|
||||
|
||||
@ConfigurationProperties
|
||||
@ -600,6 +614,7 @@ public class EnableConfigurationPropertiesTests {
|
||||
}
|
||||
|
||||
protected static class MoreProperties {
|
||||
|
||||
private String name;
|
||||
|
||||
public void setName(String name) {
|
||||
@ -611,6 +626,7 @@ public class EnableConfigurationPropertiesTests {
|
||||
|
||||
@ConfigurationProperties(path = "${binding.location:classpath:name.yml}")
|
||||
protected static class ResourceBindingProperties {
|
||||
|
||||
private String name;
|
||||
|
||||
public void setName(String name) {
|
||||
@ -623,6 +639,7 @@ public class EnableConfigurationPropertiesTests {
|
||||
@EnableConfigurationProperties
|
||||
@ConfigurationProperties(path = "${binding.location:classpath:map.yml}")
|
||||
protected static class ResourceBindingPropertiesWithMap {
|
||||
|
||||
private Map<String, String> mymap;
|
||||
|
||||
public void setMymap(Map<String, String> mymap) {
|
||||
|
Loading…
Reference in New Issue
Block a user