Commit 00caa0de authored by Philippe Merle's avatar Philippe Merle

* added an SCA property to configure/reconfigure the header of debug traces.

* used getComponentContext().getFcComponent() to retrieve the invoked component.
* displayed the nature of the invoked interface (an SCA service or reference).
* added an STP/SCA component diagram.
* added more comments
parent 78df5d60
/***
* OW2 FraSCAti Debug intent
* Copyright (C) 2008-2009 INRIA, USTL
/**
* OW2 FraSCAti: SCA Intent Debug
* Copyright (C) 2008-2010 INRIA, USTL
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -20,26 +20,39 @@
* Contact: frascati@ow2.org
*
* Author: Nicolas Dolet
*
* Contributor(s): Philippe Merle
*
*/
package org.ow2.frascati.intent.debug;
import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.Interface;
import org.objectweb.fractal.api.type.InterfaceType;
import org.objectweb.fractal.util.Fractal;
import org.osoa.sca.annotations.Scope;
import org.osoa.sca.annotations.Property;
import org.ow2.frascati.tinfi.control.intent.IntentHandler;
import org.ow2.frascati.tinfi.control.intent.IntentJoinPoint;
/**
* {@link IntentHandler} implementation for a simple debug
* {@link IntentHandler} implementation for a simple debug.
*
* @author <a href="mailto:nicolas.dolet@inria.fr">Nicolas Dolet</a>
* @version $Revision$
* @version 1.3
*/
@Scope("COMPOSITE")
public class DebugIntentHandler
implements IntentHandler {
/**
* A configurable header to add to debug traces.
*/
@Property(name= "header")
protected String header = "[FRASCATI-DEBUG]";
// --------------------------------------------------------------------------
// Implementation of the IntentHandler interface
// --------------------------------------------------------------------------
......@@ -48,19 +61,44 @@ public class DebugIntentHandler
* @see org.ow2.frascati.tinfi.control.intent.IntentHandler#invoke(IntentJoinPoint)
*/
public Object invoke(IntentJoinPoint ijp) throws Throwable {
Object ret;
Component c = ((Interface) ijp.getComponentContext()).getFcItfOwner();
//
// Obtain reflective information on the current invocation.
//
// The invoked component.
Component c = ijp.getComponentContext().getFcComponent();
// Its component name.
String componentName = Fractal.getNameController(c).getFcName();
// The invoked method.
String methodDesc = ijp.getMethod().toString();
String interfaceDesc = ijp.getInterface().getFcItfName();
System.err.println("[FRASCATI-DEBUG] Entering in component '" + componentName + "'");
System.err.println("[FRASCATI-DEBUG] \t interface: " + interfaceDesc);
System.err.println("[FRASCATI-DEBUG] \t method: " + methodDesc);
ret = ijp.proceed();
System.err.println("[FRASCATI-DEBUG] Exiting component '" + componentName + "'");
System.err.println("[FRASCATI-DEBUG] \t method: " + methodDesc);
System.err.println("[FRASCATI-DEBUG] \t interface: " + interfaceDesc);
// The name of the invoked SCA service or reference.
String interfaceName = ijp.getInterface().getFcItfName();
// Is an SCA service or reference?
String serviceOrReference = ((InterfaceType)ijp.getInterface().getFcItfType())
.isFcClientItf() ? "reference" : "service";
//
// Before the current invocation.
//
System.err.println(header + " Before calling:");
System.err.println(header + "\t component: " + componentName);
System.err.println(header + "\t " + serviceOrReference + ": " + interfaceName);
System.err.println(header + "\t method: " + methodDesc);
//
// Proceed the current invocation.
//
Object ret = ijp.proceed();
//
// After the current invocation.
//
System.err.println(header + " After calling:");
System.err.println(header + "\t component: " + componentName);
System.err.println(header + "\t " + serviceOrReference + ": " + interfaceName);
System.err.println(header + "\t method: " + methodDesc);
return ret;
}
}
<?xml version="1.0" encoding="ISO-8859-15"?>
<!-- OW2 FraSCAti Debug Intent -->
<!-- Copyright (C) 2009 INRIA, USTL -->
<?xml version="1.0" encoding="UTF-8"?>
<!-- OW2 FraSCAti: SCA Intent Debug -->
<!-- Copyright (C) 2009-2010 INRIA, USTL -->
<!-- -->
<!-- This library is free software; you can redistribute it and/or -->
<!-- modify it under the terms of the GNU Lesser General Public -->
......@@ -20,17 +20,15 @@
<!-- -->
<!-- Author: Nicolas Dolet -->
<!-- -->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:hw="http://debug-intent" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="frascati.debug">
<service name="intent" promote="debugIntentHandler/debug">
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:di="http://debug-intent" name="frascati.debug">
<service name="intent" promote="debug-intent-handler/intent">
<interface.java interface="org.ow2.frascati.tinfi.control.intent.IntentHandler"/>
</service>
<component name="debugIntentHandler">
<service name="debug">
<interface.java interface="org.ow2.frascati.tinfi.control.intent.IntentHandler"/>
</service>
<component name="debug-intent-handler">
<implementation.java class="org.ow2.frascati.intent.debug.DebugIntentHandler"/>
<service name="intent">
<interface.java interface="org.ow2.frascati.tinfi.control.intent.IntentHandler"/>
</service>
<property name="header">[FRASCATI-DEBUG]</property>
</component>
</composite>
</composite>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" xmi:id="_X7ixMB-SEd-x_4DUXm5yAQ" type="Sca" measurementUnit="Pixel">
<children xmi:type="notation:Node" xmi:id="_X-sy4B-SEd-x_4DUXm5yAQ" type="2001">
<children xmi:type="notation:Node" xmi:id="_X-tZ8B-SEd-x_4DUXm5yAQ" type="5008"/>
<children xmi:type="notation:Node" xmi:id="_X-uBAB-SEd-x_4DUXm5yAQ" type="7001">
<styles xmi:type="notation:SortingStyle" xmi:id="_X-uBAR-SEd-x_4DUXm5yAQ"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_X-uBAh-SEd-x_4DUXm5yAQ"/>
</children>
<children xmi:type="notation:Node" xmi:id="_X-uoEB-SEd-x_4DUXm5yAQ" type="7002">
<styles xmi:type="notation:SortingStyle" xmi:id="_X-uoER-SEd-x_4DUXm5yAQ"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_X-uoEh-SEd-x_4DUXm5yAQ"/>
</children>
<children xmi:type="notation:Node" xmi:id="_X-uoEx-SEd-x_4DUXm5yAQ" type="7003">
<styles xmi:type="notation:SortingStyle" xmi:id="_X-uoFB-SEd-x_4DUXm5yAQ"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_X-uoFR-SEd-x_4DUXm5yAQ"/>
</children>
<children xmi:type="notation:Node" xmi:id="_X-vPIB-SEd-x_4DUXm5yAQ" type="7004">
<children xmi:type="notation:Node" xmi:id="_X-3K8B-SEd-x_4DUXm5yAQ" type="3012">
<children xmi:type="notation:Node" xmi:id="_X-3yAB-SEd-x_4DUXm5yAQ" type="5007"/>
<children xmi:type="notation:Node" xmi:id="_X-4ZEB-SEd-x_4DUXm5yAQ" type="7009">
<styles xmi:type="notation:SortingStyle" xmi:id="_X-4ZER-SEd-x_4DUXm5yAQ"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_X-4ZEh-SEd-x_4DUXm5yAQ"/>
</children>
<children xmi:type="notation:Node" xmi:id="_X-4ZEx-SEd-x_4DUXm5yAQ" type="7010">
<styles xmi:type="notation:SortingStyle" xmi:id="_X-4ZFB-SEd-x_4DUXm5yAQ"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_X-4ZFR-SEd-x_4DUXm5yAQ"/>
</children>
<children xmi:type="notation:Node" xmi:id="_X-5AIB-SEd-x_4DUXm5yAQ" type="7011">
<styles xmi:type="notation:SortingStyle" xmi:id="_X-5AIR-SEd-x_4DUXm5yAQ"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_X-5AIh-SEd-x_4DUXm5yAQ"/>
</children>
<children xmi:type="notation:Node" xmi:id="_X-5AIx-SEd-x_4DUXm5yAQ" type="7012">
<styles xmi:type="notation:SortingStyle" xmi:id="_X-5AJB-SEd-x_4DUXm5yAQ"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_X-5AJR-SEd-x_4DUXm5yAQ"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_X-3K8R-SEd-x_4DUXm5yAQ" fontName="Lucida Grande"/>
<element xmi:type="sca:Component" href="frascati.debug.composite#//@composite/@component.0"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_X-3K8h-SEd-x_4DUXm5yAQ" x="62" y="13"/>
</children>
<styles xmi:type="notation:SortingStyle" xmi:id="_X-vPIR-SEd-x_4DUXm5yAQ"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_X-vPIh-SEd-x_4DUXm5yAQ"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_X-sy4R-SEd-x_4DUXm5yAQ" fontName="Lucida Grande"/>
<element xmi:type="sca:Composite" href="frascati.debug.composite#//@composite"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_X-sy4h-SEd-x_4DUXm5yAQ" width="361" height="241"/>
</children>
<styles xmi:type="notation:DiagramStyle" xmi:id="_X7ixMR-SEd-x_4DUXm5yAQ"/>
<element xmi:type="sca:DocumentRoot" href="frascati.debug.composite#/"/>
</notation:Diagram>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment