Xebia

Blog Xebia France

J2EE, Agility and SOA

November 30th, 2009

Devoxx Day 4 Integration for the Web with iBeans


Ross Mason created Female mule ESB plan in 2003 then founded MuleSource, the firm behind this popular ESB OPEN SOURCE. Having stationed during time in the support of this ESB, the editor has recently operated on a diversification of his portfolio and was rechristened for occasion MuleSoft. So last months saw the appearance of Tcat Server, an offer Tomcat for firm, of iBeans, and lately of .

Among these new products, iBeans is probably most intriguing. The principle of this framework: a solution of integration for applications Web with idea that iBeans intervenes where Female mule ESB stops.

After a discreet appearance in beta stage, MuleSoft reveals little by little information on iBeans for two months. It is in this context that Ross Mason introduced iBeans to Devoxx 2009 in Antwerp.

 

What an iBean?

An iBean is a component similar to those given by Spring or EJB. He distinguishes itself by his role: he is only devoted to a task of integration. He will be so representative to display a simple interface to achieve a distant service.

These tasks of development are habitually performed with the aid of group of IPA - INTERNATIONAL PHONETIC ALPHABETS in non-specialised components. The framework of MuleSoft offers therefore here to bring an environment specific for this type of task.

The role described here seems to be at first sight that of ESB. iBeans is however intended to domicile within an application Web. Ross Mason explains that during the development of such application, it is often necessary to integrate with several distant services. And yet ESB is still not present in the environment of application to get rid of the ballast from her of these tasks and to give him a simple and easily usable service. Beyond internal services to the firm, application can also need to use services on Internet such as Twitter or Amazon Web Services (AWS). In these two scenarioes, iBeans bring an answer by simplifying integration directly at the level of application.

The central repository

One of the main purposes of iBeans is to be a r utilisable, possibly beyond borders of the firm. For example, an iBean allowing to achieve in Twitter could probably be reused in most applications need to use this service. It is for this reason that MuleSoft set up a central repository so that the developers could share the iBeans that they create.

In practice, it is about a repository Subversion on whom iBeans can be published. iBeans is then available in form of artefacts Maven.

Architecture

iBeans is components having a cycle of life distinct from the applicatif container (Spring, Guice) with which they integrate. So, every injection of iBean draws away the creation of a new authority.

These components are developed with the aid of annotations which allow to integrate with channels. Every channel brings the support of a particular protocol. Currently the available channels is: HTTP / REST, JMS, FTP, SMTP, POP3, JDBC and XMPP. Other types of channels will arrive at future, and he is really sure possible to develop it oneself.

Feature is that the framework is not intended to be included in war of application Web, but directly within Tomcat. Ross Mason justifies him mainly by the mutualisation that it allows.

Creation of iBeans

The framework iBeans offers to the developer group of annotations that can be used to create new iBeans easily. An iBeans can invoke a synchronous service and accept or send an asynchronous message.

Invoke a service

The conjuration of a distant service is simple with iBeans. Example according to watch how to invoke the IPA - INTERNATIONAL PHONETIC ALPHABET REST of Twitter:

public interface MYTWITTERIBEAN {

  @Call (uri = "http://twitter.com/statuses/show/ {idem}.json")
  StatusesShow G-string (@UriParam ("idem ") G-string idem);

}

It is about a simple interface with a method. The annotation @Call will be discerned by the framework which will find the parametre of URL to be used thanks to the annotation @UriParam.

Send a message

It is also possible to send an asynchronous message. Example according to watch how to program a regular dispatch of messages JMS:

public class JmsScheduleSendBean
{
  private AtomicInteger count = new AtomicInteger (1);

  @Schedule (intervalley = 1000)
  @Send (config = "Jms-publish")
  send public Object ()
  {
    return " New Message " + count.getAndIncrement ();
  }
}

The annotation @Send point out that the object turned by method must be sent on the tail JMS jms-publish. The annotation @Schedule program a conjuration of method all seconds.

Receive a message

Finally, it is possible to receive an asynchronous message. Always in the case of JMS, the reception of message is made thanks to the annotation @Receive :

In this example, messages accepted on the tail jms-receive entraineront the conjuration of method receive() with the contents of the message JMS in argument. Transformers will be used to perform a possible adaptation of type. Finally, the chain of character turned by method will be returned here as message on the tail jms-result.

Transformers

To perform automatic conversions of type, it is possible to define Transformers. There also, it is thanks to an annotation that this definition is going to be made. Following example shows one to transform simple:

public class SimpleTransformer {

  @Transformer
  URL TOURL (G-string G-string) throws MalformedURLException {
    return new URL (G-string);
  }

}

It is not necessary to register this class to the framework, this one will undertake to discover it thanks to its annotation and deduct entries and taken out from transformation with the aid of the parametres of entrance and of exit of method.

Use to transform will be made also automatically in iBeans when type accepted by a service and type returned by its corresponding method are not compatible.

Integration in frameworks applicatifs

iBeans is possible integrate with the common containers of injections of dependency such as Spring and Guice. All over the architectural choice which was made to intend him only in Tomcat, the integration in EJB is not rather logically possible.

Once performed shape, applicatifs components can have an iBean injected with the aid of the annotation @IntegrationBean.

Integration Javacript

This possibility is original for a framework of integration but is not without reminding of DWR and of Seam Remoting. It is a question here he can invoke an iBean displayed on a server since the navigator, in Ajax, via a call Javascript. Example below shows such conjuration:

The future for iBeans

Possibilities given by iBeans are interesting, but plan is there only at its beginning. Ross Mason announces many additional possibilities to come:

  • Integration in GWT / GXT, Grail, Play framework, JSF, and Struts 2
  • Support of the Web Services with JAX-WS and JAX-RS
  • Centralised shape
  • Female mule ESB 3.0 will be capable of loading iBeans what will allow a more important capitalisation on the developed components
  • iBeans graphic solution of mapping of data under Eclipse offered by MuleSoft will integrate with ,

Conclusion

The tasks which iBeans allows to accomplish are not unpublished: they could already be performed within ESB. The positioning of solution of integration for application Web differentiates it from this type of product, but it goes however to the meeting of LIGHTWEIGHT ESB, such as Spring Integration and Apache Camel, who develops for several years.
It will nonetheless be possible to find the IPA - INTERNATIONAL PHONETIC ALPHABET offered by nicer iBeans than that of these two direct rivals as part of integrations within applications Web. But it is especially the r -utilisabilit of the iBeans that seems successful: annotated interfaces can very easily be encapsul es in an artefact Maven, to be then imported in dependency in interested applications, then injected into components jobs, without additional shape.

The choice of MuleSoft to include iBeans directly in Tomcat can be surprising. They would rather expect to find this framework within war of application. Ross Mason remains vague on the reasons of this choice. If technical reasons can justify him, it is especially possible to imagine commercial reasons: the editor distributes so iBeans with Tcat Server and has two very appealing products, with Female mule ESB, for the firm.

  key words :, ,

You can follow answers accepted by this article thanks to the thread of comments.

An answer to Devoxx Day 4 Integration for the Web with iBeans

  • On December 7th, 2009 in 16:26 (), Hax said :

    Although side Popular dance they do not cease making things more and more simple. They are still far from what can make Python in Ruby / and it is very frustrating.

Leave a comment

Xebia IT Architects lock France
Defence Colis e - 10/12, avenue of The Ark
92419 Courbevoie Cedex

T l : +33 (0) 1 46 91 76 16
Fax : +33 (0) 1 46 91 88 00
E-mail : info@xebia.fr