Differences between revisions 4 and 5
Revision 4 as of 2005-09-26 18:21:20
Size: 2735
Editor: M358P009
Revision 5 as of 2009-09-20 21:55:27
Size: 2737
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
A proof-of-concept implementation can be found here: [http://issues.apache.org/jira/browse/HARMONY-5] A proof-of-concept implementation can be found here: [[http://issues.apache.org/jira/browse/HARMONY-5]]

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

  • vm/core/comp_model/VmComponent.h -- defines ComponentInfo, DependencyInfo and the functions every component has to provide.

  • vm/core/comp_model/ComponentModel.[ch] -- The central files of the component model

  • vm/core/comp_model/interfaces/TestComponent1.h -- The interface of TestComponent1

  • vm/core/comp_model/interfaces/TestComponent2.h -- The interface of TestComponent2

  • vm/components/TestComponent1Impl/TestComponent1Impl.c -- An implementation of TestComponent1

  • vm/components/TestComponent2Impl/TestComponent2Impl.c -- An implementation of TestComponent2

  • vm/test/comp_model/TestComponentModel.c -- A simple test case for the component model.


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


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


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