You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

JBI Component Framework

JCF (JBI Component Framework) is a ServiceMix subproject aiming at simplifying the writing of standard JBI components. This helps you focusing on the business logic (for a Service Engine) or the protocol side (Binding Component), instead of having to dive into the JBI Api and the JBI specification (though the spec is really readable, an overview is given here).

Contents

Other Links

Mandatory concepts

The two most important concepts in JCF are Endpoints and Component. An JCF endpoint represents a JBI endpoint: usually a Service Unit deployed on this component will contain a JCF endpoint definition. When started, this JCF endpoint will activate a JBI endpoint so that it can receive and process JBI exchanges. The component is a container of endpoints and manages their lifecycles, deployment, etc ...

Component

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.

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 ...

Simple component
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 };
  }
} 

Endpoints

Optional concepts

Deployer

Bootstrap

Service Engines

This tutorial will help you creating a Service Engine using ServiceMix JCF.

Binding Components

This tutorial will guide your through the different steps needed to create a Binding Component using ServiceMix JCF.

#top

  • No labels