On the QAFE demo site you’ll see a sample application called “Random Demo”.
This class uses a direct link with the java.util.Random class which can be found in this rt.jar (distributed with every JDK installation). To use this class in QAFE, we make a “link” to this class by defining a resource. A QAFE Resource is the “connection” between the real implementation and the “source” for service definitions in QAFE.
Oke, this might sound a bit odd, but with an example I’ll try to make it clear:
Say you want to use a method called “nextLong()” from the class “java.util.Random” that can be found in the “rt.jar” of the JDK installation (see also the javadoc). In QAFE this would be translated in two two tiers at least:
- The Resource-tier
- The Integration-tier
The Resource-Tier
The resource-tier is as follows:
<resource-tier>
<resources>
<javaclass id="RandomResource" classname="java.util.Random"
jarfile-location="file:/C:/jdk1.5.0_10/jre/lib/rt.jar"/>
</resources>
</resource-tier>
So what we are saying here is: we have a “javaclass” which can be found in jarfile-location and the fully qualified classname is denoted by the “classname” attribute and for QAFE we call this java class “RandomResource”. The only requirement for this class is that the empty constructor is available. Note that the jarfile-location can be anywhere as long as the URL can be reached.
The Integration-Tier
So now the connection is made to the “real” implementation of the class and from now on we use the id “RandomResource” to access methods from this javaclass. The method that we wanted was “nextLong()“. The way to do that in QAFE is by defining a service in the integration-tier
<integration-tier>
<services>
<service id="randomService" resource-ref="RandomResource">
<method id="nextLong">
<out name="nextLongOutput"/>
</method>
</service>
</services>
</integration-tier>
We define in the integration-tier a service (we can define more than one service in the “services” tag). In this case the service id equals “randomService” and it references to the resource id that we just defined in the previous step “RandomResource”.
Since we wanted to call the method “nextLong” we create a method with the same name as id (<method id=”nextLong”>). Note that this is case sensitive. Furthermore, according to the javadoc, this method in the Random class returns a value. We need to store that output in a variable. For this example we define an <out> child element of the method, with name equals “nextLongOutput“.
It doesn’t matter how complex the object is that you return. QAFE easily manages that object and passes it through to the other layers (business-actions, presentation).
In the next sessions we’ll talk more about datahandling in QAFE.
