An update on where I've got to with this....

I've created a new class, called ModelBuilderImpl, in assembly to run
a new build process. You can turn this on by switching round the
comments in the file

modules\assembly\src\main\resources\META-INF\services\org.apache.tuscany.sca.assembly.builder.CompositeBuilder

This new builder does the following

        try {
            // Collect and fuse includes. Copy all of the components
            // out of the included composite into the including composite
            // and discards the included composite
            compositeIncludeBuilder.build(composite, definitions, monitor);

            // need to apply policy external attachment

            // Expand nested composites. Clone any composite model that
            // is acting as a component implementation and connects the cloned
            // model to the component implementation in question
            compositeCloneBuilder.build(composite, definitions, monitor);

            // Process the implementation hierarchy by calculating the
component type
            // for the top level implementation (composite). This has
the effect of
            // recursively calculating component types and configuring the
            // components that depend on them
            compositeComponentTypeBuilder.createComponentType(composite);

            // create the runtime model by updating the static model
we have just
            // created. This involves things like creating
            //  component URIs
            //  binding URIs
            //  binding specific build processing
            //  callback references - currently done in static pass
            //  callback services - currently done in static pass
            //  Endpoints
            //  Endoint References
            //  Policies
            // TODO - called here at the moment but we could have a
separate build phase
            //        to call these. Also we need to re-org these builders
            bindingURIBuilder.configureBindingURIsAndNames(composite,
definitions, monitor);
            componentServiceBindingBuilder.build(composite,
definitions, monitor); // binding specific build
            componentReferenceBindingBuilder.build(composite,
definitions, monitor); // binding specific build
            endpointBuilder.build(composite, definitions, monitor);
            endpointReferenceBuilder.build(composite, definitions, monitor);
            componentReferencePromotionBuilder.build(composite,
definitions, monitor); // move into the static build?
            compositePolicyBuilder.build(composite, definitions,
monitor); // the rest of the policy processing?

        } catch (Exception e) {
            throw new CompositeBuilderException("Exception while
building model " + composite.getName(), e);
        }

The important line here is compositeComponentTypeBuilder(...) which
calculates the component type for the composite it is given. It does
this by asking all child components to configure themselves based on
thier components type. Hence they aske for their component types to be
created, and so it goes. The component configuration code is in the
ComponentBuilder so there are two piece of code of interest.

CompositeComponentTypeBuilderImpl - create the component type of a composite
ComponentBuilderImpl - build a component based on its component type

Now each of these files is self contained. They have no base classes
and use no utilities. This is on purpose so please avoid the
temptation to "optimize" them if you can. At least for the time being.
If find it very comfortable to have all of the code for performing
these functions in the file that performs the function. This feels
like an improvement over the various different builders we had for
this and their associated base classes and utilites.

Now the next thing to sort out is the runtime building that follows
the creating of the component type. You will see that I've added back
in the steps that currently live in this section so that the Tuscany
build works. I also created new Enpoint and EndpointReference builders
so that I could see the wood for the trees in that area.  However I'd
like to reorganize all of these builders. Thoughts to follow but any
comments are most welcome.

I haven't actually turned the new builder on just yet although I do
get a clean build. Just want to run the assembly otests before
flipping the switch and haven't go to that yet.

Regards

Simon

Reply via email to