Chapter 7. SCA intents with OW2 FraSCAti

Table of Contents

The debug intent
SCA intent
SCA definition
Intent implementation
Use your SCA intent

SCA intents can be used for non-functional concerns, such as transactions, debuging, etc.

This chapter is organized as following: the section called “The debug intent” illustrates how to use the debug intent of OW2 FraSCAti and the section called “SCA intent” explains how to create your own intent.

The debug intent

Debugging an SCA application can be done with FraSCAti thanks to the debug intent.

This intent traces when entering and exiting implementation code of an SCA component. It can be set onto a component, then the debug traces will appear both when calling a service of the component and when a reference of the component uses another component's service. Finer grain debugging can be set by setting the debug intent only on a given service or reference of a component.

Let's see how to use it on the helloworld-pojo example.

The SCA composite file of this example is:

<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://helloworld"
  xmlns:hw="http://helloworld" name="helloworld">

  <service name="r" promote="client"/>

  <component name="client">
    <service name="r">
      <interface.java interface="java.lang.Runnable" />
    </service>
    
    <reference name="printService" target="server" />
    
    <implementation.java class="org.ow2.frascati.examples.helloworld.pojo.Client" />
  </component>
  
  <component name="server">
    <service name="printService">
      <interface.java interface="org.ow2.frascati.examples.helloworld.pojo.PrintService"/>
    </service>

    <implementation.java class="org.ow2.frascati.examples.helloworld.pojo.Server" />
  </component>

</composite>

The standard output when running this example is:

CLIENT created.
SERVER created.
SERVER: setting header to '--->> '.
SERVER: begin printing...
--->> Hello World!
SERVER: print done.

Now, let's put the debug intent on the service named r of the client component, and on the server component:

<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://helloworld"
  xmlns:hw="http://helloworld" name="helloworld">

  <service name="r" promote="client"/>

  <component name="client">
    <service name="r" requires="frascati.debug">
      <interface.java interface="java.lang.Runnable" />
    </service>
    
    <reference name="printService" target="server" />
    
    <implementation.java class="org.ow2.frascati.examples.helloworld.pojo.Client" />
  </component>
  
  <component name="server">
    <service name="printService" requires="frascati.debug">
      <interface.java interface="org.ow2.frascati.examples.helloworld.pojo.PrintService"/>
    </service>

    <implementation.java class="org.ow2.frascati.examples.helloworld.pojo.Server" />
  </component>

</composite>

As a result, the run method of the service is logged, like the print method executed by the server component:

CLIENT created.
[FRASCATI-DEBUG] Entering 'java.lang.Runnable.run' in component 'client'
SERVER created.
SERVER: setting header to '--->> '
[FRASCATI-DEBUG] Entering 'org.ow2.frascati.examples.helloworld.pojo.PrintService.print' in component 'server'
SERVER: begin printing...
--->> Hello World!
SERVER: print done.
[FRASCATI-DEBUG] Exiting 'org.ow2.frascati.examples.helloworld.pojo.PrintService.print' from component 'server'
[FRASCATI-DEBUG] Exiting 'java.lang.Runnable.run' from component 'client'