OpenWGA 7.2 - OpenWGA Concepts and Features

Data sources

Bean Adapter

The Bean Adapter is a comfortable and easy way to access generic third party systems from OpenWGA and process their data in WebTML templates. It uses a some custom Java Bean that has to be provided by you to to retrieve this data. It therefor calls the getter methods of this bean and provides the retrieved data to WebTML.

Because of this approach the Bean Adapter is less suitable for sources of real "classic content" but rather for building interfaces to other types of systems  and integrate their data and functionality, like instant messaging servers, mail boxes etc.

While it is possible to use your custom Java beans directly from TMLScript it has some benefits to use the Bean Adapter instead:

  • OpenWGA manages the creation of those beans per user, request or web application, to maintain the correct scope of it
  • OpenWGA can pass login information of the OpenWGA domain to the bean which may be neccessary to create connections to backend systems
  • The retrieved data is directly available as items/metadata in WebTML and TMLScript, so the usual functionalities can be used to put them out

Java Bean prerequisites

The Bean Adapter is merely the interface between a custom Java Bean and OpenWGA/WebTML. Therefor a Java Bean offering the desired connectivity functionality needs to be available in the Classpath of OpenWGA. Just drop the JAR Library files holding your bean and any dependency classes into the "system file container" of any of your applications designs (see File containers in folder "files").

A Java Bean that should be used by Bean Adapter needs to follow the following rules:

  • The JavaBean either needs to have a default constructor or an implementation of interface de.innovationgate.webgate.api.simple.BeanCreationHandler from OpenWGA classpath needs to be created which will be called to create bean instances.
  • A single JavaBean instance must be suitable to be used in either one of the following scopes:
    • In a single request only
    • For a single user
    • For all users

Connecting

The RSS Feed Connector is a data source which can be found on the virtual database server "Other sources" which is built-in on every OpenWGA runtime without registration.

screenshot_99(005).png

The only mandatory configuration option for the bean adapter is the Class name of JavaBean which takes the fully qualified name of the bean class. 

If you use a bean creation handler for bean creation you also need to add option Creation handler class and fill it with the fully qualified name of the creation handler class . You find this optional setting when clicking on "show/hide more options..." in the "Database Configuration" section and looking it up in the now appearing combo box.

Per default OpenWGA creates a single Java Bean for every request and destroys it again after that request. If this is too frequent for what you do (maybe the backend connections that you need to build need too much time to rebuild them on every request) then you may change that scope scheme via optional setting instantiate one bean per. Here you can decide that only one bean is created for every user, which is persisted between requests. You can also decided to only create one bean for all users and requests. In that case all users will get the same data.

Using in WebTML

You can treat the Bean Adapter like a database that only servers one content document. By accessing this document you simply change the WebTML context to this database. Assuming a bean adapter under database key "im" that would be:

<tml:range context="db:im">

... Access to Bean Adapter Data here ....

</tml:range>

Inside you can retrieve the properties of the bean, implemented as getter/setter methods on it, just like items. Assuming we have the following bean representing a basic instant messaging awareness service:

public interface InstantMessaging {


    public List<String> getContacts();


    public boolean isOnline(String user);


}

Then we can retrieve the users contacts by requesting item "contacts". The following example iterates over the values of this item via <tml:foreach> :

<tml:range context="db:im">


    <ul>

    <tml:foreach type="itemvalue" item="contacts" currentvalue="user">

        <li><tml:item name="user"/>

    </tml:foreach>

    </ul>


</tml:range>

We can retrieve the current bean itself by using the native object of the current database, retrievable in TMLScript via "db().nativeObject". Here we can call methods of that bean, for example to determine the online status of a user:

<li><tml:item name="user"/> <tml:script expression="db().nativeObject.isOnline(user) ? 'ONLINE' : '(offline)'"/>