To customize the components in camel, it is necessary to understand the key concepts in camel, to understand the construction process and the initiation process of camel Middle road, and to have the relevant narration in the previous article.
Here is an example of a custom component. This example is also subject to a file poll, which is the specific code below.
Component classes:
[Java] view plain copy package com.xtayfjpk.esb.components.file; Import Java.util.Map; Import Org.apache.camel.Endpoint; Import org.apache.camel.impl.DefaultComponent; public class Myfilecomponent extends Defaultcomponent {@Override protected Endpoint createendpoint (String URI, String remaining, map<string, object> parameters) throws Exception {return new Myfileendpoint (this, URI); } }
Endpoint class:
[Java] View plain copy package com.xtayfjpk.esb.components.file; import java.io.file; import org.apache.camel.consumer; import org.apache.camel.exchange; import org.apache.camel.processor; import org.apache.camel.producer; import org.apache.camel.component.file.filecomponent; import org.apache.camel.impl.defaultendpoint; import org.apache.camel.impl.defaultexchange; public class myfileendpoint extends defaultendpoint { public myfileendpoint ( Myfilecomponent component, string uri) { super (uri, component); } @Override puBlic producer createproducer () throws Exception { return new myfileproducer (this); } @Override public consumer createconsumer (processor processor) throws Exception { return new myfileconsumer (this, processor); } @Override public boolean issingleton () { return false; }