diff --git a/eclipse/eclipse-code-formatter.xml b/eclipse/eclipse-code-formatter.xml
index ea51ccce7b5..303449503ee 100644
--- a/eclipse/eclipse-code-formatter.xml
+++ b/eclipse/eclipse-code-formatter.xml
@@ -17,7 +17,7 @@
-
+
diff --git a/eclipse/org.eclipse.jdt.core.prefs b/eclipse/org.eclipse.jdt.core.prefs
index b25b4acfb08..24bf63fd737 100644
--- a/eclipse/org.eclipse.jdt.core.prefs
+++ b/eclipse/org.eclipse.jdt.core.prefs
@@ -184,7 +184,7 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
-org.eclipse.jdt.core.formatter.indentation.size=8
+org.eclipse.jdt.core.formatter.indentation.size=4
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/MessageChannelMetricWriter.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/MessageChannelMetricWriter.java
index 3cff4fce818..924667582df 100644
--- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/MessageChannelMetricWriter.java
+++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/MessageChannelMetricWriter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2013 the original author or authors.
+ * Copyright 2012-2015 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,7 +18,6 @@ package org.springframework.boot.actuate.metrics.writer;
import org.springframework.boot.actuate.metrics.Metric;
import org.springframework.messaging.MessageChannel;
-import org.springframework.messaging.support.MessageBuilder;
/**
* A {@link MetricWriter} that publishes the metric updates on a {@link MessageChannel}.
@@ -26,13 +25,10 @@ import org.springframework.messaging.support.MessageBuilder;
* carry an additional header "metricName" with the name of the metric in it.
*
* @author Dave Syer
+ * @see MetricWriterMessageHandler
*/
public class MessageChannelMetricWriter implements MetricWriter {
- private static final String METRIC_NAME = "metricName";
-
- private final String DELETE = "delete";
-
private final MessageChannel channel;
public MessageChannelMetricWriter(MessageChannel channel) {
@@ -41,20 +37,17 @@ public class MessageChannelMetricWriter implements MetricWriter {
@Override
public void increment(Delta> delta) {
- this.channel.send(MessageBuilder.withPayload(delta)
- .setHeader(METRIC_NAME, delta.getName()).build());
+ this.channel.send(MetricMessage.forIncrement(delta));
}
@Override
public void set(Metric> value) {
- this.channel.send(MessageBuilder.withPayload(value)
- .setHeader(METRIC_NAME, value.getName()).build());
+ this.channel.send(MetricMessage.forSet(value));
}
@Override
public void reset(String metricName) {
- this.channel.send(MessageBuilder.withPayload(this.DELETE)
- .setHeader(METRIC_NAME, metricName).build());
+ this.channel.send(MetricMessage.forReset(metricName));
}
}
diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/MetricMessage.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/MetricMessage.java
new file mode 100644
index 00000000000..3c38cc7099b
--- /dev/null
+++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/MetricMessage.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2012-2015 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.writer;
+
+import org.springframework.boot.actuate.metrics.Metric;
+import org.springframework.messaging.Message;
+import org.springframework.messaging.support.MessageBuilder;
+
+/**
+ * A metric message sent via Spring Integration.
+ *
+ * @author Phillip Webb
+ */
+class MetricMessage {
+
+ private static final String METRIC_NAME = "metricName";
+
+ private static final String DELETE = "delete";
+
+ private final Message> message;
+
+ public MetricMessage(Message> message) {
+ this.message = message;
+ }
+
+ public boolean isReset() {
+ return DELETE.equals(getPayload());
+ }
+
+ public Object getPayload() {
+ return this.message.getPayload();
+ }
+
+ public String getMetricName() {
+ return this.message.getHeaders().get(METRIC_NAME, String.class);
+ }
+
+ public static Message> forIncrement(Delta> delta) {
+ return forPayload(delta.getName(), delta);
+ }
+
+ public static Message> forSet(Metric> value) {
+ return forPayload(value.getName(), value);
+ }
+
+ public static Message> forReset(String metricName) {
+ return forPayload(metricName, DELETE);
+ }
+
+ private static Message> forPayload(String metricName, Object payload) {
+ MessageBuilder