Show Table of Contents

Chapter 48. Component Interface
Abstract
This chapter describes how to implement the
Component interface.
48.1. The Component Interface
Overview
To implement a Apache Camel component, you must implement the
org.apache.camel.Component interface. An instance of Component type provides the entry point into a custom component. That is, all of the other objects in a component are ultimately accessible through the Component instance. Figure 48.1, “Component Inheritance Hierarchy” shows the relevant Java interfaces and classes that make up the Component inheritance hierarchy.
Figure 48.1. Component Inheritance Hierarchy

The Component interface
Example 48.1, “Component Interface” shows the definition of the
org.apache.camel.Component interface.
Example 48.1. Component Interface
package org.apache.camel;
public interface Component {
CamelContext getCamelContext();
void setCamelContext(CamelContext context);
Endpoint createEndpoint(String uri) throws Exception;
}Component methods
The
Component interface defines the following methods:
getCamelContext()andsetCamelContext()—References theCamelContextto which thisComponentbelongs. ThesetCamelContext()method is automatically called when you add the component to aCamelContext.createEndpoint()—The factory method that gets called to createEndpointinstances for this component. Theuriparameter is the endpoint URI, which contains the details required to create the endpoint.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.