Creating Apache Camel Components with Options

import java.util.Map;

import org.apache.camel.Endpoint;
import org.apache.camel.impl.DefaultComponent;

@SuppressWarnings("unchecked")
public final class SampleComponent extends DefaultComponent {
  private static final String PARAM_PARAM1 = "param1";
  private static final String PARAM_PARAM2 = "param2";

  @Override
  protected Endpoint createEndpoint(final String uri, final String url, final Map params) {
    ...

    /* Set param1 */
    String param1 = (String) params.remove(PARAM_PARAM1);

    if (param1 == null)
      param1 = ""; // Default

    /* Set param2 */
    String param2 = (String) params.remove(PARAM_PARAM2);

    if (param2 == null)
      param2 = "";

    return new SampleEndpoint(param1, param2);
  }

}

2 thoughts on “Creating Apache Camel Components with Options

  1. You can configure the endpoint to be lenient. Just override and return true in the isLenientProperties() method in your custom Endpoint. Then Camel will not validate that all options is used.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s