edu.vub.at.objects.coercion
Class Coercer

java.lang.Object
  extended byedu.vub.at.objects.coercion.Coercer
All Implemented Interfaces:
java.lang.reflect.InvocationHandler

public final class Coercer
extends java.lang.Object
implements java.lang.reflect.InvocationHandler

A coercer is a dynamic proxy which is used to 'cast' Ambienttalk base-level NATObjects to a certain ATxxx interface. The dynamic proxy is responsible for transforming java calls to meta_invoke calls. For example, a method from an AT interface ATExpression base_getExpression() throws NATException receives the following implementation: ATExpression getExpression() throws NATException { return principal.meta_invoke(principal, Reflection.downSelector("getExpression"), NATTable.EMPTY).asExpression(); } where principal is the original object 'coerced into' the given interface

Author:
tvcutsem

Field Summary
private  NATObject principal_
           
private  java.lang.Thread wrappingThread_
           
 
Constructor Summary
private Coercer(NATObject principal)
           
 
Method Summary
static java.lang.Object coerce(ATObject object, java.lang.Class type)
           
 java.lang.Object invoke(java.lang.Object receiver, java.lang.reflect.Method method, java.lang.Object[] arguments)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

principal_

private final NATObject principal_

wrappingThread_

private final java.lang.Thread wrappingThread_
Constructor Detail

Coercer

private Coercer(NATObject principal)
Method Detail

coerce

public static final java.lang.Object coerce(ATObject object,
                                            java.lang.Class type)
                                     throws XTypeMismatch
Throws:
XTypeMismatch

invoke

public java.lang.Object invoke(java.lang.Object receiver,
                               java.lang.reflect.Method method,
                               java.lang.Object[] arguments)
                        throws java.lang.Throwable
Specified by:
invoke in interface java.lang.reflect.InvocationHandler
Throws:
java.lang.Throwable