How does Tuscany start components from a contribution?
Contributed by Giorgio Zoppi <email@example.com>
This document describes how a composite file (i.e.
MyComposite.composite) gets processed for a simple composite. When
the XML parser sees a composite element, create a composite, it checks
if it is autowired and if it has an item autowire, it sets the
composite to be autowired, then it checks if it's local and if it has
constrainting types. If the composite has constrainting types, they
Then the parser reads, if they are present, the policies for the
composite. Suppose that in my simple example i have no constrain or
At a given point the parser sees an <component> item, in this case, the runtime:
- It creates a RuntimeComponent by the RuntimeComponentFactory,
sets its name, it looks if the component needs to be autowired,
then it checks if it has constrainting types. If the composite has
constrainting types, they are processed.
Then the parser reads, if they are present, the policies for the component.
At other point the runtime sees an extension point, which it could be
a service, a binding, an implementation type and so on..In this
document we suppose, that the runtime sees:
The runtime at this point gets the extension processor. The extension
processor has in input the component, and the reader from the XML
Parser. From the XML document, the extension processor recognize the
extension type and it gets the needed factory.
For example, inside the read method of JavaImplementationProcessor we have:
JavaImplementation javaImplementation = javaFactory.createJavaImplementation();
From the CLASS attribute, the runtime understand the kind of interface.
Then it reads the policies:
At this point, the runtime adds the implementation to the component with:
and it adds the component to the composite.
Until now we're processing a MyComposite.composite like this:
Suppose now to find a service(<service>) item, what happens?
- creates a RuntimeComponentService
- sets the Contract (service contract) to RuntimeComponentService
- sets RuntimeComponentService's name
- adds RuntimeComponentService instance to Component's Services.
- it seeks for services policies.
Now a service has an interface (<interface>), and it could be a java
interface. At this point the runtime creates a
JavaInterfaceContractImpl by a JavaInterfaceFactory and sets it to the
service contract (call: contract.setInterfaceContract(...)).