Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Section
Column

The component is one of the two mandatory classes that you will have to implement. JCF provides a very easy to use class that you should inherit called DefaultComponent.

The same class will be used to implement a Binding Component and a Service Engine. It handles the JBI component life cycle, service unit management, and all the services defined in the JBI specification.

This class is abstract and you will need to implement a few methods to start using it. Those are:

Those methods are related to the next concept, but are quite easy to grok. The getConfiguredEndpoints is used in the lightweight deployment mode, where the component is configured statically with its endpoints. This method will return the list of JCF endpoints contained by this component.
The getEndpointClasses method is used when validating a XBean based deployment, to make sure the deployed endpoint is correct. The component should return a list of known endpoint classes that will be accepted.

The code snippet on the right shows the most simple component. This rather simple code will create a full-blown JBI component, supporting deployment of service units, and all the advanced features provided by JCF !

Note the @XBean pseudo-annotation which is used by the xbean plugin to generate an xml schema we will leverage for deployment ...

Column
Code Block
langjava
titleSimple component
langjava
package com.foo;

import java.util.List;
import org.apache.servicemix.common.DefaultComponent;

/**
 * @org.apache.xbean.XBean element="component"
 */
public class MyComponent extends DefaultComponent {
  private MyEndpoint[] endpoints;

  public MyEndpoint[] getEndpoints() {
    return endpoints;
  }
  public void setEndpoint(MyEndpoint[] endpoints) {
    this.endpoints = endpoints;
  }

  protected List getConfiguredEndpoints() {
    return asList(endpoints);
  }

  protected Class[] getEndpointClasses() {
    return new Class[] { MyEndpoint.class };
  }
} 

...