1
2
3
4
5
6
7 package org.mule.endpoint.inbound;
8
9 import org.mule.api.MuleEvent;
10 import org.mule.api.MuleException;
11 import org.mule.api.config.MuleProperties;
12 import org.mule.api.endpoint.InboundEndpoint;
13 import org.mule.api.processor.MessageProcessor;
14 import org.mule.api.transport.PropertyScope;
15 import org.mule.util.ObjectUtils;
16 import org.mule.util.StringUtils;
17
18
19
20
21
22
23 public class InboundEndpointPropertyMessageProcessor implements MessageProcessor
24 {
25 private InboundEndpoint endpoint;
26
27 public InboundEndpointPropertyMessageProcessor(InboundEndpoint endpoint)
28 {
29 this.endpoint = endpoint;
30 }
31
32 public MuleEvent process(MuleEvent event) throws MuleException
33 {
34
35 String inboundEndpoint = endpoint.getName();
36
37 if (StringUtils.isBlank(inboundEndpoint))
38 {
39
40 inboundEndpoint = endpoint.getEndpointURI().getUri().toString();
41 }
42 event.getMessage().setProperty(MuleProperties.MULE_ORIGINATING_ENDPOINT_PROPERTY, inboundEndpoint, PropertyScope.INBOUND);
43 return event;
44 }
45
46 @Override
47 public String toString()
48 {
49 return ObjectUtils.toString(this);
50 }
51 }