Proposed Component Model written in C

A proof-of-concept implementation can be found here: http://issues.apache.org/jira/browse/HARMONY-5

Source Files

Description

All components are packed in a shared library and are loaded by the component model with dlopen. The component model will load all the components it can find in a certain set of directories which has to be passed to the function "componentModelInitialize". The components have to provide the following functions:

/** Get the ComponentInfo object for this component. 
 */
ComponentInfo *getComponentInfo();

/** Get the number of dependencies of this component. 
 */
int getNumDependencies();

/** Get a dependency of this component. 
 */
DependencyInfo *getDependency(int i);

/** Initialize the component (will not be called before all dependencies have been set). 
 */
void initialize();

ComponentInfo and DependencyInfo are structs which contain information about the component and it's dependencies. When the component model loads the components it first gets the ComponentInfo entries for all components and resolves the function pointers for the three functions mentioned above. In a second step it resolves the dependencies of all components and injects the dependent components with the setter function from the DependencyInfo entry. After that it calls initialize for all components.

A component which depends on another component gets the function pointer table of this component set by the component model. For example, TestComponent1 gets a pointer to a TestComponent2 and can then call the functions defined there.

Building and running the test case

It can be built with

libtoolize
aclocal
autoconf
automake
./configure
make

The test case can be started from the vm-directory with the command

test/comp_model/TestComponentModel

ComponentModelFunctionPointers (last edited 2009-09-20 21:55:27 by localhost)