title: Camel Interceptor per Endpoint, not per CamelContext
body: <p>Is it a possible to declare Interceptor per Endpoint, not per CamelContext? In my case I've lots of CamelContexts and I want to extract common code with endpoints declarations and interceptors to one file: camel-common-context.xml. There is absolutely no problem with extracting endpoints, but how to extract interceptors? Is it a possible or they just should be inside every CamelContext where I want to use an endpoint? In my case they're not visible in related camel contexts after modification which I posted below:</p>
  
  <p>my camel-common-context.xml:</p>
  
  <pre><code>&lt;camelContext id="esb" xmlns="http://camel.apache.org/schema/spring"&gt;
          &lt;endpoint id="externalSystem" uri="${external.system.url}?throwExceptionOnFailure=false" /&gt;
  
          &lt;interceptFrom&gt;
              &lt;convertBodyTo type="java.lang.String" /&gt;
              &lt;when&gt;
                  &lt;xpath&gt;not(/soapenv:Envelope)&lt;/xpath&gt;
                  &lt;process ref="soapFaultProcessor" /&gt;
              &lt;/when&gt;
              &lt;otherwise&gt;
                  &lt;convertBodyTo type="java.lang.String" /&gt;
              &lt;/otherwise&gt;
          &lt;/interceptFrom&gt;
  
          &lt;interceptSendToEndpoint uri="ref:externalSystem"&gt;
              &lt;setHeader headerName="SYSTEM"&gt;
                  &lt;constant&gt;EXTERNAL&lt;/constant&gt;
              &lt;/setHeader&gt;
              &lt;convertBodyTo type="java.lang.String" /&gt;
              &lt;to uri="log:wSSProcessor_external_system_request?level=DEBUG" /&gt;
          &lt;/interceptSendToEndpoint&gt;
  &lt;/camelContext&gt;
  </code></pre>
  
  <p>Other camel contexts (I'm only importing resource):</p>
  
  <pre><code>&lt;import resource="camel-common-context.xml" /&gt;
  </code></pre>
  
  <p>I've no problems when I'm declaring each endpoint with interceptor in every camel-context, but it's a wrong pattern with lots of copy-paste.</p>
  
  <p>In this <a href="https://stackoverflow.com/questions/29810796/camel-in-osgi-container-apply-interceptstrategy-to-all-camel-contexts">question</a> I see that there is an information that " I dont think this is possible using InterceptorStrategy since that expects it is running in the same camel context". What's more I think that using multiple contexts with one application is a <a href="http://camel.apache.org/why-use-multiple-camelcontext.html" rel="nofollow noreferrer">bad pattern</a> </p>
  
  <hr>
  
  <p>UPDATE</p>
  
  <p>I was trying to change my architecture to one Camel Context with more Route Contexts follow up @Lukasz N answer, but I hit a snag <a href="https://issues.apache.org/jira/browse/CAMEL-4025" rel="nofollow noreferrer">CamelBugWithRouteContexts</a>. It looks quite impossible to resolve my problem but it should works well on versions of camel higher than 2.8. </p>