2005/5/9

     
 

ACDK DMI

artefaktur

The Dynamic Method Invocation (DMI) mechanism allows to call the methods of an ACDK DMI Server object (Any ACDK C++-, CfgScript- or Java-classes, or COM/ActiveX and CORBA components) at runtime via C++ (also C++ to C++ in the sense weak binding via reflection), Java, CfgScript, COM, CORBA, Perl, Python, Tcl or Lisp.



Sub chapter pages:

Dynamic Method Invocation (DMI) - is a core ACDK feature for integration of scripting, middleware and distributed computing, like COM+ and CORBA.

Because DMI connects different languages and middle ware technologies, and these languages and middle wares has different language like features a mapping of these features has to be defined.

ACDK provides a standard interface to Objects constructors, methods and member variables.

To provide a flexibility data type for dynamic invocation ScriptVar is used as wrapper for all ACDK types.

Each ACDK object implements the StdDispatch interface. This interface provides the basic methods to access member by name and calling function by name dynamically at runtime.

ACDK DMI can be used in C++ to load and invoke classes at runtime.

CfgScript is a ACDK scripting language similar to Java/JavaScript but can direcly make usage of ACDK C++ classes.

How to implement own Objects, which can be called via DMI clients.

With DmiProxies foreign DMI Servers can implement ACDK Interfaces and extends existing classes.

A Delegate is a wrapper to a function, similar to function pointers.

Subclassing To make DMI subclassing available for a implementation language the language must be capable to act as DMI Server.




(defun foo (self sarg)
  (sarg 'toLower)
)

; static method
(defun bar (arg)
)


(defclass TheClass
  (
  (foo :initform bar)
  )
)



#define ACDK_WITH_DMI_PROXY \
  static RObject getDmiProxy(IN(RObject) delegate);
class SampleClass_DmiProxy
: extends DmiProxy
, implements SampleClass
{
};
//static 
RObject 
SampleClass::getDmiProxy(IN(RObject) delegate)
{
  return new SampleClass_DmiProxy(delegate);
}

class SampleClass
: extends ::acdk::lang::Object
{
  ACDK_WITH_METAINFO(SampleClass)
public:
  virtual RString foo(IN(RString) sarg);
};
class SampleClass_DMI_Proxy
: extends SampleClass
{
  RObject _delegate;
public:
  SampleClass_DMI_Proxy(IN(RObject) delegate)
  : _delegate(delegate)
  {
  }
public:
  virtual RString foo(IN(RString) sarg)
  {
    return (RString)_delegate->invoke("foo", sarg);
  }
};