Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ public IrcMessage newInstance() {
return new IrcMessage(getCamelContext());
}

@Override
protected boolean isPopulateHeadersSupported() {
return true;
}

@Override
protected void populateInitialHeaders(Map<String, Object> map) {
map.put(IrcConstants.IRC_MESSAGE_TYPE, messageType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ protected Object createBody() {
return null;
}

@Override
protected boolean isPopulateHeadersSupported() {
return true;
}

@Override
protected void populateInitialHeaders(Map<String, Object> map) {
if (jmsMessage != null && map != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ protected Object createBody() {
return null;
}

@Override
protected boolean isPopulateHeadersSupported() {
return true;
}

@Override
protected void populateInitialHeaders(Map<String, Object> map) {
if (mailMessage != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* A Camel message to be created upon each scheduled job execution.
*/
public class QuartzMessage extends DefaultMessage {

private final JobExecutionContext jobExecutionContext;

public QuartzMessage(Exchange exchange, JobExecutionContext jobExecutionContext) {
Expand All @@ -40,6 +41,11 @@ public JobExecutionContext getJobExecutionContext() {
return jobExecutionContext;
}

@Override
protected boolean isPopulateHeadersSupported() {
return true;
}

@Override
protected void populateInitialHeaders(Map<String, Object> map) {
super.populateInitialHeaders(map);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ protected Object createBody() {
return null;
}

@Override
protected boolean isPopulateHeadersSupported() {
return true;
}

@Override
protected void populateInitialHeaders(Map<String, Object> map) {
if (jmsMessage != null && map != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* Represents a {@link org.apache.camel.Message} for working with XMPP
*/
public class XmppMessage extends DefaultMessage {

private Stanza xmppPacket;

public XmppMessage(CamelContext camelContext) {
Expand Down Expand Up @@ -89,6 +90,11 @@ protected Object createBody() {
return null;
}

@Override
protected boolean isPopulateHeadersSupported() {
return true;
}

@Override
protected void populateInitialHeaders(Map<String, Object> map) {
if (xmppPacket != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ protected void setUp() {
camelContext.start();
}

@Test
public void testHasHeaders() {
Message msg = new DefaultMessage(camelContext);
assertFalse(msg.hasHeaders());

msg.setHeader("foo", "cheese");
assertTrue(msg.hasHeaders());
assertEquals("cheese", msg.getHeader("foo"));
}

@Test
public void testLookupCaseAgnostic() {
Message msg = new DefaultMessage(camelContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public MyFaultMessage(Exchange exchange) {
super(exchange);
}

@Override
protected boolean isPopulateHeadersSupported() {
return true;
}

@Override
protected void populateInitialHeaders(Map<String, Object> map) {
throw new IllegalArgumentException("Forced headers error");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,11 @@ public void setHeaders(Map<String, Object> headers) {

@Override
public boolean hasHeaders() {
if (headers == null) {
if (headers == null && isPopulateHeadersSupported()) {
// force creating headers
headers = createHeaders();
}
return !headers.isEmpty();
return headers != null && !headers.isEmpty();
}

@Override
Expand Down Expand Up @@ -328,6 +328,13 @@ protected void populateInitialHeaders(Map<String, Object> map) {
// do nothing by default
}

/**
* Whether subclasses need to populate headers when creating message.
*/
protected boolean isPopulateHeadersSupported() {
return false;
}

/**
* Returns true if the headers have been mutated in some way
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ from("direct:start")
.to("mock:result");
----

==== Custom Camel components

Custom components which has a custom message implementation by extending `DefaultMessage`, which rely on the `populateInitialHeaders`
to initialize headers must now add the following method:

[source,java]
----
@Override
protected boolean isPopulateHeadersSupported() {
return true;
}
----

=== camel-jbang

The `camel-kamelets-catalog` JAR is now downloaded on-demand.
Expand Down
Loading