|
|||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
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. |
Semi-transparent asynchronous method invocation mechanism implementation.
Semi-transparent mechanism try to solve problems found with the total-transparent mechanism. It focuses on:
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:
rami_
and they always returned a
FutureClient
.
jaya.
. 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.MyClassLimitation:
MyClass
with the following
statement at the very beginning of the file:jaya.path
property. In our example, at least two
files has been created in the current directory ".":
jaya/mypackage/MyClass.java
and
jaya/java/lang/Object.java
since MyClass
inherits
from java.lang.Object
. If otherpackage.MyInterface
interface, then the
jaya/otherpackage/MyInterface.java
would have been created too.
Compile thoses files using any standard java compiler:javac jaya/mypackage/MyClass.java jaya/java/lang/Object.javaThen, two class has been created defining semi-transparent asynchronous proxy for any
MyClass
instance.
The semi-transparent asynchronous proxy generated by the
JayaCompiler
can be instanciated as their proxied object. Hence,
you may rewrite the generic
example into:
try{ // Step 1 jaya.mypackage.MyClass myObject = new jaya.mypackage.MyClass(); // Step 2 FutureClient future = myObject.rami_myMethod(myParameters); // Step 3 doingSomething(); MyResult result = null; result = (MyResult) future.waitForResult(); // Step 4 MyInfos infos = result.getInfos(); }catch(Throwable t) { handleException(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.
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:
ComputerClass
:
java -Djaya.path=. mandala.rami.transparency.semi.JayaCompiler package.ComputerClass
javac jaya/*.java
Framework.getSemiTransparentAsynchronousProxy(Object)
:
// Step 1 ComputerClass computerTmp = library.getComputer(); jaya.package.ComputerClass computer = (jaya.package.ComputerClass) mandala.rami.Framework.getSemiTransparentAsynchronousProxy(computerTmp); // Step 2 FutureClient future1 = computer.rami_compute(something1); // Step 3 FutureClient future2 = computer.rami_compute(something2); try{ // 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); }
|
|||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |