Introduction

Raccoon is a java orientated framework and it's aim is to ease the work of java developpers. As such, in every java application, developpers handle JavaBeans when manipulating data which is a sort of intelligent equivalent of the C Structure.

Now when this data (a java bean instance) is to be sent over the TIB, the current TIB/Rendezvous API doesn't take a java bean natively: the native format is a TibrvMsg instance or the MTree instance, depending on whether you're using the TIB/Rendezvous API or the TIB/Adapter SDK.

So what Raccoon offers is automatic conversion from a java bean instance to an MTree or TibrvMsg instance and back. Therefore java developpers using the Raccoon framework don't need any TIBCO specific knowledge. However for this automatic conversion to be possible there are certain rules to respect; these rules are delved into in the following sections.

The name of the module that handles automatic conversion from JavanBeans to a TibrvMsg or MTree instance is called BadhnAti. This word comes from Sanskrit and it means 'he who binds'.

JavaBean properties

Duke Beans JavaBeans have many characteristics and it isn't the intention of this document to cover all aspects related to these components. If the reader is interested in having more in-depth information we suggest reading the Java Bean specification that can be found on the sun site.

Currently Raccoon distinguishes two types of Java Beans:

  • The Castor Bean: this a java bean that is usable by the Castor XML framework. Therefore this kind of JavaBean can be serialized into an XML String or an XML String can be converted back into a Java Bean instance. It isn't possible to serialize a Castor compliant bean into an MTree instance if the wireformat is Rv. However if the wirformat is AE than it is possible, but not recommended, to serialize a Castor compliant bean into an MTree or TibrvMsg instance.
  • The Raccoon Bean: this a java bean is Castor compliant and therefore is usable by the Castor XML framework. This kind of JavaBean can be serialized into an XML String or an XML String can be converted back into a Java Bean instance. However a Raccoon compliant bean bears more characteristics than a Castor compliant bean; these extra characteristics make it possible to serialize a Castor compliant bean into an MTree or TibrvMsg instance. A Raccoon compliant bean instance can be serialized no matter what the format is (Rv or AE).

Regarding support: Raccoon is capable of handling AE v3.0 compliant messages and Rv messages that are compliant to the Message Broker v3.x format. It is important to note that Rv messages are not compatible with AE messages, this is why Raccoon supports specifically these two types.

Additional issues

Multi-threading issues

Regarding multi-threading issues our reference is the java bean specification, in particular paragraphe 2.8:

"Java Beans should assume that they are running in a multi-threaded environment and that several different threads may be simultaneously delivering events and/or calling methods and/or setting properties. It is the responsibility of each java bean developer to make sure that their bean behaves properly under multi-threaded access. For simple beans this can generally be handled by simply making all the methods synchronized".

However we understand that it isn't always possible to have a thread safe java bean, therefore Raccoon offers a special EventListener that handles of pool of java bean instances. Each java bean instance is associated to a unique thread. Of course it is up to the java developper to implement a method called clone() :o)

Bound Properties

The BadhnAti module assumes that java bean properties aren't bound. If the java bean has bound properties then the BadhnAti module will not guarantee the behaviour and may fail to dynamically instanciate the java bean.

When introspecting a java bean it is impossible to determine (to our knowledge anyway) the behaviour of bound properties.

What is a bound property?

Sometimes when a bean property changes then either the bean container or some other bean may wish to be notified of the change. The notification should be sent after the property has been modified.

A component can choose to provide a change notification service for some or all of its properties. Such properties are commonly known as bound properties, as they allow other components to bind special behaviour to property changes.

Constrained Properties

The BadhnAti module assumes that java bean properties aren't constrained. If the java bean has constrained properties then the BadhnAti module will not handle exceptions and may fail to dynamically instanciate the java bean.

When introspecting a java bean it is impossible to determine (to our knowledge anyway) the behaviour of constrained properties. Of course one could implement iterative behaviour: try until succeed but we haven't.

What is a constrained property?

Sometimes when a property change occurs some other bean may wish to validate the change and reject it if it is inappropriate. We refer to properties that undergo this kind of checking as constrained properties.

In Java Beans, constrained property setter methods are required to support the PropertyVetoException. This documents to the users of the constrained property that attempted updates may be vetoed.

JavaBean types

The Castor Bean
A Castor bean is a Java Bean that is usable by the Castor XML framework. Just to make sure that we're all on the same wavelength, a Castor Bean has to have one or more of the following methods:
  • Simple properties: Raccoon relies on design patterns to locate properties of interest (i.e. that are serializable).

    A simple property of a java bean means that the java bean has to implement the following methods:



    public <PropertyType> get<PropertyName>();

    public void set<PropertyName>(<PropertyType> pNewValue);



    If the Bean Introspector module locates a matching pair of get<PropertyName>() and set<PropertyName> methods than the property propertyName is considered to be a serializable property and will be sent over the messaging layer.

    All properties are considered neither bound nor constrained
  • Boolean properties: in addition to the previous properties the Bean Introspector module searches for boolean properties that conform the Java Bean specification for the getter method:



    public boolean is<PropertyName>();

    public boolean has<PropertyName>();



    If the Bean Introspector module locates a matching pair of is<PropertyName>() and set<PropertyName> or has<PropertyName>() and set<PropertyName> methods than the property propertyName is considered to be a serializable property and will be sent over the messaging layer.
  • Indexed properties: This feature isn't currently supported but it will be in the future. It is for that reason that Raccoon is able to generate the source code of indexed properties, but it isn't currently using them.

    An indexed property is a property of that is an array type <PropertyElement>[] than a search for the following methods will occur:



    public <PropertyType> get<PropertyName>(int pIndexOfElement);

    public void set<PropertyName>(int pIndexOfElement, <PropertyType> pNewValue);



    If the Bean Introspector module locates a matching pair of get<PropertyName>() and set<PropertyName> methods than the property propertyName is considered to be a serializable property and will be sent over the messaging layer.

    A complete example of the expected methods for a String[] named address is:



    public String[] getAddress();

    public void setAddress(String[] pNewValue);

    public String getAddress(int pIndexOfElement);

    public void setAddress(int pIndexOfElement, String pNewValue);



The Raccoon Bean
A Raccoon bean is a Java Bean that is firstly a Castor Bean, it is therefore usable by the Castor XML framework. For Castor Bean to be Raccoon Compliant Bean it has to offer the following characteristic:
  • Collection properties: these are Java Bean properties that have getters/setters and adders if they are collection elements (such as java.util.Vector)

    A collection property of a java bean means that the java bean has to implement the following methods:



    public <PropertyType> get<PropertyName>();

    public void set<PropertyName>(<PropertyType> pNewValue);

    public void add<PropertyName>(<CollectionType> pNewValueToAdd);



    If the Bean Introspector module locates a matching pair of get<PropertyName>(), add<PropertyName>() and set<PropertyName> methods than the property propertyName is considered to be a serializable property and will be sent over the messaging layer.

    All properties are considered neither bound nor constrained

    A complete example of the expected methods for a Vector of String named address is:



    public Vector getAddress();

    public void setAddress(Vector pNewValue);

    public void addAddress(String pNewValueToAdd);



    It also acceptable to have an adder that is written without an 's', for example:



    public Vector getFriends();

    public void setFriends(Vector pNewValue);

    public void addFriend(Friend pNewFriend);