Package mandala.rami.transparency.semi

Semi-transparent asynchronous method invocation mechanism implementation.


Interface Summary
SemiTransparentAsynchronousProxy This interface defines methods any semi-transparent asynchronous proxy must have.

Class Summary
JayaCompiler This class implements the semi transparent reflexive asynchronous method invocation mechanism.
SourceGenerator This class provides the SourceGenerator.generateClass(Class) method} which generates the source of the semi-transparency asynchronous proxy class for the given class.

Package mandala.rami.transparency.semi Description

Semi-transparent asynchronous method invocation mechanism implementation.

Semi-transparent reflective asynchronous method invocation

Problems solved

Semi-transparent mechanism try to solve problems found with the total-transparent mechanism. It focuses on:

The Jaya Compiler

The semi-transparent mechanism consist of the use of an instance of a class generated by the JayaCompiler -- the semi-transparent asynchronous proxy -- and which contains:

Consider the generic example. In a semi-transparent reflective asynchronous mechanism, you'll have to compile MyClass with the JayaCompiler:

java -Djaya.path=. mandala.rami.transparency.semi.JayaCompiler mypackage.MyClass
Note that your classes can't be compiled if they are in the anonymous (default) package! Hence, you must declare MyClass with the following statement at the very beginning of the file:
package mypackage;

This instruction print the java source files it has created in the directory specified by the jaya.path property. In our example, at least two files has been created in the current directory ".": jaya/mypackage/ and jaya/java/lang/ since MyClass inherits from java.lang.Object. If MyClass implements the otherpackage.MyInterface interface, then the jaya/otherpackage/ would have been created too. Compile thoses files using any standard java compiler:
javac jaya/mypackage/ jaya/java/lang/
Then, two class has been created defining semi-transparent asynchronous proxy for any MyClass instance.

Semi-transparent asynchronous proxy instanciation

The semi-transparent asynchronous proxy generated by the JayaCompiler can be instanciated as their proxied object. Hence, you may rewrite the generic example into:

    // Step 1
    jaya.mypackage.MyClass myObject = new jaya.mypackage.MyClass();

    // Step 2
    FutureClient future = myObject.rami_myMethod(myParameters);

    // Step 3

    MyResult result = null;

    result = (MyResult) future.waitForResult();

    // Step 4
    MyInfos infos = result.getInfos();

}catch(Throwable t) {

to see step 2 and step 3 executing concurrently. As you can see exception may be raised by the method waitForResult ensuring that any exception raised during the asynchronous call is catched on result recovery.

Getting a semi-transparent asynchronous proxy on already instantiated object

Last, suppose that you want to invoke in a semi-transparent asynchronous manner methods of an object that is given to you by a library. For example, consider the following code:

// Step 1
ComputerClass computer = library.getComputer();

// Step 2
Result result1 = computer.compute(something1);
// Step 3
Result result2 = computer.compute(something2);

// Step 4
return result1.operation(result2);
You may want to parallelize Step 2 and Step 3 to achieve better performance on multiple processors. The following steps will achieve this goal:
  1. compile ComputerClass:
    java -Djaya.path=. mandala.rami.transparency.semi.JayaCompiler package.ComputerClass
  2. compile the generated java source files:
    javac jaya/*.java
  3. modify the code so it uses the Framework.getSemiTransparentAsynchronousProxy(Object):
    // Step 1
    ComputerClass computerTmp = library.getComputer();
    jaya.package.ComputerClass computer = (jaya.package.ComputerClass) 
    // Step 2
    FutureClient future1 = computer.rami_compute(something1);
    // Step 3
    FutureClient future2 = computer.rami_compute(something2);
        // Step 4
        Result result1 = (Result) future1.waitForResult();
        // Step 5
        Result result2 = (Result) future2.waitForResult();
        // Step 6
        return result1.operation(result2);
    } catch (Throwable t) {
        return handleException(t);

    Mandala help mailing list