In this section, we will show you some of the reconfiguration actions available with FraSCAti. We will show how to perform these reconfigurations both programmaticaly (FraSCAti FScript) and graphically (FraSCAti Explorer). This section relies on the reconfig example but you can reproduce actions on whatever you want.
FraSCAti introduces a life cycle to SCA components. It means that you are able to start and stop any SCA composite / components in the architecture. By stopping a component, all incoming calls are queued and you can perform reconfiguration on it. Stopinng a composite implies stoppin all its descendants. For more details on the Lifecycle, take a look at http://fractal.ow2.org/specification/index.html#tth_sEc4.5.
Nothing difficult here, you just need to call the start/stop action with the targeted component as parameter.
FraSCAtiFScript> $root #<scacomponent: reconfig> FraSCAtiFScript> stop($root) FraSCAtiFScript> state($root) STOPPED FraSCAtiFScript> start($root) FraSCAtiFScript> state($root) STARTED
FraSCAti Explorer offers actions on objects in the tree with a
right-click. It opens a menu with all available actions. On a
component, you can find the
Stop menu item (if the
component status is
STARTED). Just click on the
menu item and the component is stopped. The component is now displayed
in grey-scaled color.
The component is now stopped. The menu now display the start action. Note that there is also an icon available on the menu bar to stop/start components.
As described in the SCA specification, properties are used to configure components without hard-coded values in the implementation. FraSCAti goes a step forward by allowing to dynamically reconfigure properties on running components/composites.
You can get the value of any SCA property with the value() procedure. To set a value, you just have to call set-value with the property node as first parameter and the new value in second position.
FraSCAtiFScript> dollarRate = $root/scaproperty::dollarExchangeRate; [#<scaproperty: currency-converter.dollarExchangeRate>] FraSCAtiFScript> value($dollarRate) 0.75 FraSCAtiFScript> set-value($dollarRate, 0.81) FraSCAtiFScript> value($dollarRate) 0.81
SCA Intents are used to add non-functionnal services to business components. SCA Intents are implemented as SCA components in OW2 FraSCAti. In this way, you don't need to use another technology to develop intents.
OW2 FraSCAti allows you to dynamically weaves intents (in a Aspect Oriented Programming way) on SCA services / references. Intents can be declared in a static way with the 'requires' keyword in the SCA composite file.
Fot this tutorial part, you need to load the frascati debug intent into the FraSCAti runtime.
First, we need to get a reference to the SCA intent to weave.
Here we store a reference to the frascati debug intent into the
debugIntent variable. Then we have to get a
reference to the targetted SCA service or reference. We will store the
run service of the reconfig component into the
runService variable. Last, you just have to call
the add-scaintent(<target>, <intent>) procedure to weave
the intent on the targetted SCA service/reference. so, the last action
weaves the debug intent on the run service.
FraSCAtiFScript> debugIntent = $domain/scachild::frascati-debug; [#<scacomponent: frascati-debug>] FraSCAtiFScript> runService = $domain/scachild::reconfig/scaservice::r; [#<scaservice: reconfig.r>] FraSCAtiFScript> add-scaintent($runService, $debugIntent)
Now, if you invoke the
run method of
r service, you will see the trace of the debug
intent on the console.
[INFO] [FRASCATI-DEBUG] Before calling: [INFO] [FRASCATI-DEBUG] component: reconfig [INFO] [FRASCATI-DEBUG] service: r [INFO] [FRASCATI-DEBUG] method: public abstract void java.lang.Runnable.run() [INFO] 100$ are worth about 75.0€. [INFO] Updating exchange rate to 0.823 ...Setting Dollar exchange rate to '0.823'. [INFO] Done! [INFO] 100$ are now worth about 82.3€. [INFO] Updating exchange rate to 0.698177756 ... [INFO] +-> Adding procedure 'reconfigure-converter' to FraSCAti FScript engine [INFO] Setting Dollar exchange rate to '0.698177756'. [INFO] Done! [INFO] 100$ are now worth about 69.8177756€. [INFO] [FRASCATI-DEBUG] After calling: [INFO] [FRASCATI-DEBUG] component: reconfig [INFO] [FRASCATI-DEBUG] service: r [INFO] [FRASCATI-DEBUG] method: public abstract void java.lang.Runnable.run()
Let's remoce the intent.
FraSCAtiFScript> remove-scaintent($runService, $debugIntent)
The output is now as following after a r/run() invocation:
[INFO] 100$ are worth about 69.8177756€. [INFO] Updating exchange rate to 0.823 ...Setting Dollar exchange rate to '0.823'. [INFO] Done! [INFO] 100$ are now worth about 82.3€. [INFO] Updating exchange rate to 0.698177756 ... [INFO] +-> Adding procedure 'reconfigure-converter' to FraSCAti FScript engine [INFO] Setting Dollar exchange rate to '0.698177756'. [INFO] Done! [INFO] 100$ are now worth about 69.8177756€.
Weave / unweave intents with FraSCAti Explorer is as easy as
drag and drop an SCA intent (an SCA component with a service
interface) on the target SCA service / reference. A new icon is now
displayed as child of the service / reference item to show intents
weaved on it. A right-click on an intent icon enables the 'Remove
intent' menu item. By clicking on it, you remove the intent from the
target service / reference.
SCA wires are involved when no remote communications are required and when components are in the same runtime box.
We first need to get a reference to the SCA service and the SCA
reference implied in the wire. We also need a reference to the
component owning the SCA reference because we need to stop it before
unwiring. The following commands remove the wire between the
updater reference of the
client component and the
exchangeRateUpdater service of the
FraSCAtiFScript> client = $domain/scadescendant::client; [#<scacomponent: client>] FraSCAtiFScript> client-updater = $client/scareference::updater; [#<scareference: client.updater>] FraSCAtiFScript> updater-service = $domain/scadescendant::converter/scaservice::exchangeRateUpdater; [#<scaservice: converter.exchangeRateUpdater>] FraSCAtiFScript> stop($client) FraSCAtiFScript> remove-scawire($client-updater, $updater-service) FraSCAtiFScript> start($client)
There is no need to stop the component owning the reference to wire an SCA reference.
FraSCAtiFScript> add-scawire($client-updater, $updater-service)
you can check wire/unwire actions by invoking services using the
updater service (the
r service for instance).
Within the FraSCAti explorer framework, you need to stop the
component owning the SCA reference to wire/unwire to enable the
wire/unwire menu item on SCA references. Once the component stopped, a
right-click on a SCA reference will propose you either the
unwire menu item if the reference is bound or the
wire menu item if the reference is not bound.
For instance, we can stop the client component. Its
updater reference is bound, so we can unwire it
with the menu item.
updater reference is now unbound. We can
wire it to an SCA service by clicking on the wire menu item on the
updater reference. A new window appears, allowing
you to select the SCA service to bind in a tree. Of course, the SCA
service interface must match to the one of the SCA reference.
One would like to dynamically add a remote binding to an SCA service/reference or just add a new remote binding (rest, ws, rmi, etc.) in order to use (or to be used by) an external service. It's possible! No need to deploy a new application or to restart it.
To remove an existing SCA binding, you can use the remove-scabinding procedure as following:
FraSCAtiFScript> itf = $domain/scadescendant::converter/scaservice::currencyConverter; [#<scaservice: converter.currencyConverter>] FraSCAtiFScript> $itf/scabinding::* [#<scabinding: converter-ws-skeleton>, #<scabinding: converter-RESTful-skeleton>] FraSCAtiFScript> wsbinding = $itf/scabinding::converter-ws-skeleton; [#<scabinding: converter-ws-skeleton>] FraSCAtiFScript> remove-scabinding($itf,$wsbinding) FraSCAtiFScript> $itf/scabinding::* [#<scabinding: converter-RESTful-skeleton>]
The first parameter of the
remove-scabinding procedure is the SCA
service (or reference) owning the binding and the second one is the
binding node previously selected with the help of the
Select an SCA service or reference, then right-click and select
Add SCA binding ... menu item. A new window
will be open to let you choose the binding type and fill in binding
The following window will appear:
First, select the tab related to the SCA binding type you want
to add. Then fill in parameter(s) with appropriate value(s) and click
Add Binding button. The binding is now added
and up! You can see it on the next screenshot.
If you want to remove an existing SCA binding, select it in the
explorer tree, then right-click on it and select the
SCA binding menu item. That's all!
FraSCAti allows you to dynamically add SCA components to SCA composites. Adding a component A into composite B does not remove the component A from its previous parent. A is now shared between 2 composites. Removing a component has the same semantic. It just remove the component from the specified composite. The component still exists if it was contained in more than one composite.
For instance, we can add the
FraSCAtiFScript> $root #<scacomponent: reconfig> FraSCAtiFScript> add-scachild($root/scachild::converter, $root/scachild::client)
you can see that the
client component is
still a child of the
reconfig composite but also a
child of the
converter composite. If you don't want
to share it, you can just remove the
component from the
All SCA services and references must be unwired/unbound beforere removing a component!
FraSCAtiFScript> remove-scachild($root, $root/scachild::client)
There is a dedicated instruction
sca-remove to be
able to remove (unload) SCA composites from the SCA domain. This
instruction CANNOT works if the argument is not a top level composite
contained in the SCA domain.
The argument is the name of the composite to remove.