You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Simon Laws <si...@googlemail.com> on 2009/09/22 18:41:55 UTC

Re: [2.x] builder woes

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

Re: [2.x] builder woes

Posted by Simon Laws <si...@googlemail.com>.
Ok, Raymond.

I'll update and take a look.

Simon

Re: [2.x] builder woes

Posted by Raymond Feng <en...@gmail.com>.
FYI: I have refactored the builder implementation classes into 
"tuscany-builder" module under [1]. The builder interfaces are left in 
"assembly" module for now.

[1] http://svn.apache.org/viewvc?rev=819680&view=rev

Thanks,
Raymond
--------------------------------------------------
From: "Simon Laws" <si...@googlemail.com>
Sent: Friday, September 25, 2009 2:41 AM
To: <de...@tuscany.apache.org>
Subject: Re: [2.x] builder woes

> Hi Raymond.
>
> Replies in line...
>
>> There is one more static builder: PolicyAttachmentBuilder. This builder 
>> will
>> apply the @attachTo xpath of the policySets to the domain composite as 
>> well
>> as the composites used by implementation.composite. It should be called
>> right after the include/clone is finished on the domain composite.
>>
>>> Thoughts on the runtime part of the build which involves...
>>>
>>> bindingURIBuilder
>>>  I think this can stay as is as it's fairly isolated
>>
>> Is BindingURIBuilder calculating the structural URIs? This could be 
>> merged
>> into the builder that set the component URI. We can name the builder
>> something like StructuralURIBuilder. If the @uri of a binding is not set,
>> the binding extension may choose to derive the protocol URI from the
>> structural URI. Where should this kind of behavior be plugged in? In the
>> component service/reference binding builder?
>
> Ok so I think this breaks down into two pieces then...
>
> 1/ Calculation of the structure URI for each reference or service in
> the static model
> 2/ Extend the binding specific builders to take the static uri and
> combine it with the binding specific endpoint configuration. The
> binding specific build phase comes next. If
>
>>
>>>
>>> componentServiceBindingBuilder
>>> componentReferenceBindingBuilder
>>>   binding specific builders. I think they have to come after the
>>> service binding URIs have been calculated. Not clear to me that
>>> service and reference need to remain separate. In the previous
>>> builders the componentReferenceBindingBuilder was called at the end
>>> after endpoint references were created. In OASIS though the reference
>>> either has a binding, in which case it has been manually configured,
>>> or it adopts the binding from the service, which will have already
>>> been configured by the service.
>>>   I am tempted to combine these two and the bindingURIBuilder into a
>>> single bindingBuilder.
>>
>> At this moment, the component service/reference binding builders just 
>> call
>> the BindingBuidler extensions. +1 to merge them. I'm also wondering if 
>> these
>> builders should work against the Endpoint/EndpointReference instead of
>> (Component/Contract/Binding tuples). If so, should we align them against 
>> the
>> EndpointReference/EndpointBuilder? It's related to the decision on 
>> whether
>> we treat Endpoint/EndpointReference as runtime model or static model.
>
> In my mind EndpointReferences are runtime artifacts. Endpoints feel
> more static as their configuration can be established and is stable
> while a composite is assigned to a node. Overall though I'd says this
> notion of static and runtime builders is just a convenience for giving
> some structure to the build process. It probably doesn't make that
> much material difference. It may make a difference in future dynamic
> scenarios where we want to be able to build and rebuild
> EndpointReferences independently of the static model. However we need
> to put all of our domain scenarios back on the table and review them
> before we put too much store in that.
>
>>
>>>
>>> endpointBuilder
>>>  fairly isolated again
>>>
>>> endpointReferenceBuilder
>>>  this is interesting as there is another endpointReferenceBuilder in
>>> the endpoint module. There are two things going on.
>>>  1/ creation of endpoint references based on the local composite
>>> configuration
>>>  2/ resolution/matching of cross composite endpoint references in
>>> the distributed case.
>>>
>>>  The first builder does step 1 and the second builder does step 2. I
>>> would like to at least combine the code into one file and just call
>>> the separate phases from different places.
>>>  I'd also like to do the runtime matching for those endpoints
>>> resolved in step 1 so that all local composite errors are reported are
>>> load time
>>>  There is some rationalization we could do here by relying on the
>>> endpoint registry as the registry of available endpoints when endpoint
>>> references are actually created. The problem I have with this though
>>> is that endpoints are not added to the registry until the composite is
>>> activated and to populate it earlier would detract from this. So I'll
>>> leave this alone for now.
>>
>> Should we limit the builder responsibility to configuration only? The
>> resolution seems to be in a different phase than build.
>> In use cases like the SCA Domain Manager that provisions the composite
>> applications, no EndpointRegistry is available.
>
> A domain manager could be made a available as the model is build but I
> agree that it is probably useful to consider these as separate phases.
> If only because then we have the endpoint registry populated with
> deployed and active endpoints against which endpoint references can be
> resolved.
>
>>
>>>
>>> componentReferencePromotionBuilder
>>>  This currently deals in endpoint references and hence has to go
>>> here. However it's really a static model building phase so I'd like to
>>> rephrase this logic in terms of reference targets and bindings and
>>> move it into the componentype/componentConfig build process.
>>>
>>> compositePolicyBuilder
>>>   This also currently deals in endpoints and endpoint references but
>>> is really static model configuration. So need to discuss if this could
>>> be moved back up to the static phase. I don't have  a problem if it
>>> needs to stay here for whatever reason.
>>>
>>
>> Maybe we can use a criteria as follows to determine if the static model
>> needs to be updated or the information goes only to the runtime model:
>>
>> * Is the information useful for deployment/provisioning without running 
>> the
>> composite application?
>>
>
> +1
>
> Simon
> 

Re: [2.x] builder woes

Posted by Simon Laws <si...@googlemail.com>.
Hi Raymond.

Replies in line...

> There is one more static builder: PolicyAttachmentBuilder. This builder will
> apply the @attachTo xpath of the policySets to the domain composite as well
> as the composites used by implementation.composite. It should be called
> right after the include/clone is finished on the domain composite.
>
>> Thoughts on the runtime part of the build which involves...
>>
>> bindingURIBuilder
>>  I think this can stay as is as it's fairly isolated
>
> Is BindingURIBuilder calculating the structural URIs? This could be merged
> into the builder that set the component URI. We can name the builder
> something like StructuralURIBuilder. If the @uri of a binding is not set,
> the binding extension may choose to derive the protocol URI from the
> structural URI. Where should this kind of behavior be plugged in? In the
> component service/reference binding builder?

Ok so I think this breaks down into two pieces then...

1/ Calculation of the structure URI for each reference or service in
the static model
2/ Extend the binding specific builders to take the static uri and
combine it with the binding specific endpoint configuration. The
binding specific build phase comes next. If

>
>>
>> componentServiceBindingBuilder
>> componentReferenceBindingBuilder
>>   binding specific builders. I think they have to come after the
>> service binding URIs have been calculated. Not clear to me that
>> service and reference need to remain separate. In the previous
>> builders the componentReferenceBindingBuilder was called at the end
>> after endpoint references were created. In OASIS though the reference
>> either has a binding, in which case it has been manually configured,
>> or it adopts the binding from the service, which will have already
>> been configured by the service.
>>   I am tempted to combine these two and the bindingURIBuilder into a
>> single bindingBuilder.
>
> At this moment, the component service/reference binding builders just call
> the BindingBuidler extensions. +1 to merge them. I'm also wondering if these
> builders should work against the Endpoint/EndpointReference instead of
> (Component/Contract/Binding tuples). If so, should we align them against the
> EndpointReference/EndpointBuilder? It's related to the decision on whether
> we treat Endpoint/EndpointReference as runtime model or static model.

In my mind EndpointReferences are runtime artifacts. Endpoints feel
more static as their configuration can be established and is stable
while a composite is assigned to a node. Overall though I'd says this
notion of static and runtime builders is just a convenience for giving
some structure to the build process. It probably doesn't make that
much material difference. It may make a difference in future dynamic
scenarios where we want to be able to build and rebuild
EndpointReferences independently of the static model. However we need
to put all of our domain scenarios back on the table and review them
before we put too much store in that.

>
>>
>> endpointBuilder
>>  fairly isolated again
>>
>> endpointReferenceBuilder
>>  this is interesting as there is another endpointReferenceBuilder in
>> the endpoint module. There are two things going on.
>>  1/ creation of endpoint references based on the local composite
>> configuration
>>  2/ resolution/matching of cross composite endpoint references in
>> the distributed case.
>>
>>  The first builder does step 1 and the second builder does step 2. I
>> would like to at least combine the code into one file and just call
>> the separate phases from different places.
>>  I'd also like to do the runtime matching for those endpoints
>> resolved in step 1 so that all local composite errors are reported are
>> load time
>>  There is some rationalization we could do here by relying on the
>> endpoint registry as the registry of available endpoints when endpoint
>> references are actually created. The problem I have with this though
>> is that endpoints are not added to the registry until the composite is
>> activated and to populate it earlier would detract from this. So I'll
>> leave this alone for now.
>
> Should we limit the builder responsibility to configuration only? The
> resolution seems to be in a different phase than build.
> In use cases like the SCA Domain Manager that provisions the composite
> applications, no EndpointRegistry is available.

A domain manager could be made a available as the model is build but I
agree that it is probably useful to consider these as separate phases.
If only because then we have the endpoint registry populated with
deployed and active endpoints against which endpoint references can be
resolved.

>
>>
>> componentReferencePromotionBuilder
>>  This currently deals in endpoint references and hence has to go
>> here. However it's really a static model building phase so I'd like to
>> rephrase this logic in terms of reference targets and bindings and
>> move it into the componentype/componentConfig build process.
>>
>> compositePolicyBuilder
>>   This also currently deals in endpoints and endpoint references but
>> is really static model configuration. So need to discuss if this could
>> be moved back up to the static phase. I don't have  a problem if it
>> needs to stay here for whatever reason.
>>
>
> Maybe we can use a criteria as follows to determine if the static model
> needs to be updated or the information goes only to the runtime model:
>
> * Is the information useful for deployment/provisioning without running the
> composite application?
>

+1

Simon

Re: [2.x] builder woes

Posted by Raymond Feng <en...@gmail.com>.
See my comments inline.

Thanks,
Raymond
--------------------------------------------------
From: "Simon Laws" <si...@googlemail.com>
Sent: Wednesday, September 23, 2009 8:44 AM
To: <de...@tuscany.apache.org>
Subject: Re: [2.x] builder woes

There is one more static builder: PolicyAttachmentBuilder. This builder will 
apply the @attachTo xpath of the policySets to the domain composite as well 
as the composites used by implementation.composite. It should be called 
right after the include/clone is finished on the domain composite.

> Thoughts on the runtime part of the build which involves...
>
> bindingURIBuilder
>   I think this can stay as is as it's fairly isolated

Is BindingURIBuilder calculating the structural URIs? This could be merged 
into the builder that set the component URI. We can name the builder 
something like StructuralURIBuilder. If the @uri of a binding is not set, 
the binding extension may choose to derive the protocol URI from the 
structural URI. Where should this kind of behavior be plugged in? In the 
component service/reference binding builder?

>
> componentServiceBindingBuilder
> componentReferenceBindingBuilder
>    binding specific builders. I think they have to come after the
> service binding URIs have been calculated. Not clear to me that
> service and reference need to remain separate. In the previous
> builders the componentReferenceBindingBuilder was called at the end
> after endpoint references were created. In OASIS though the reference
> either has a binding, in which case it has been manually configured,
> or it adopts the binding from the service, which will have already
> been configured by the service.
>    I am tempted to combine these two and the bindingURIBuilder into a
> single bindingBuilder.

At this moment, the component service/reference binding builders just call 
the BindingBuidler extensions. +1 to merge them. I'm also wondering if these 
builders should work against the Endpoint/EndpointReference instead of 
(Component/Contract/Binding tuples). If so, should we align them against the 
EndpointReference/EndpointBuilder? It's related to the decision on whether 
we treat Endpoint/EndpointReference as runtime model or static model.

>
> endpointBuilder
>   fairly isolated again
>
> endpointReferenceBuilder
>   this is interesting as there is another endpointReferenceBuilder in
> the endpoint module. There are two things going on.
>   1/ creation of endpoint references based on the local composite
> configuration
>   2/ resolution/matching of cross composite endpoint references in
> the distributed case.
>
>   The first builder does step 1 and the second builder does step 2. I
> would like to at least combine the code into one file and just call
> the separate phases from different places.
>   I'd also like to do the runtime matching for those endpoints
> resolved in step 1 so that all local composite errors are reported are
> load time
>   There is some rationalization we could do here by relying on the
> endpoint registry as the registry of available endpoints when endpoint
> references are actually created. The problem I have with this though
> is that endpoints are not added to the registry until the composite is
> activated and to populate it earlier would detract from this. So I'll
> leave this alone for now.

Should we limit the builder responsibility to configuration only? The 
resolution seems to be in a different phase than build.
In use cases like the SCA Domain Manager that provisions the composite 
applications, no EndpointRegistry is available.

>
> componentReferencePromotionBuilder
>   This currently deals in endpoint references and hence has to go
> here. However it's really a static model building phase so I'd like to
> rephrase this logic in terms of reference targets and bindings and
> move it into the componentype/componentConfig build process.
>
> compositePolicyBuilder
>    This also currently deals in endpoints and endpoint references but
> is really static model configuration. So need to discuss if this could
> be moved back up to the static phase. I don't have  a problem if it
> needs to stay here for whatever reason.
>

Maybe we can use a criteria as follows to determine if the static model 
needs to be updated or the information goes only to the runtime model:

* Is the information useful for deployment/provisioning without running the 
composite application?

>
> I think all of these runtime builders could live outside of assembly
> and be called in a separate group by the node to allow for this move.
> This overlaps with Raymond's discussion about where the builders
> should be more generally.
>
> Simon 


Re: [2.x] builder woes

Posted by Simon Laws <si...@googlemail.com>.
Thoughts on the runtime part of the build which involves...

bindingURIBuilder
   I think this can stay as is as it's fairly isolated

componentServiceBindingBuilder
componentReferenceBindingBuilder
    binding specific builders. I think they have to come after the
service binding URIs have been calculated. Not clear to me that
service and reference need to remain separate. In the previous
builders the componentReferenceBindingBuilder was called at the end
after endpoint references were created. In OASIS though the reference
either has a binding, in which case it has been manually configured,
or it adopts the binding from the service, which will have already
been configured by the service.
    I am tempted to combine these two and the bindingURIBuilder into a
single bindingBuilder.

endpointBuilder
   fairly isolated again

endpointReferenceBuilder
   this is interesting as there is another endpointReferenceBuilder in
the endpoint module. There are two things going on.
   1/ creation of endpoint references based on the local composite
configuration
   2/ resolution/matching of cross composite endpoint references in
the distributed case.

   The first builder does step 1 and the second builder does step 2. I
would like to at least combine the code into one file and just call
the separate phases from different places.
   I'd also like to do the runtime matching for those endpoints
resolved in step 1 so that all local composite errors are reported are
load time
   There is some rationalization we could do here by relying on the
endpoint registry as the registry of available endpoints when endpoint
references are actually created. The problem I have with this though
is that endpoints are not added to the registry until the composite is
activated and to populate it earlier would detract from this. So I'll
leave this alone for now.

componentReferencePromotionBuilder
   This currently deals in endpoint references and hence has to go
here. However it's really a static model building phase so I'd like to
rephrase this logic in terms of reference targets and bindings and
move it into the componentype/componentConfig build process.

compositePolicyBuilder
    This also currently deals in endpoints and endpoint references but
is really static model configuration. So need to discuss if this could
be moved back up to the static phase. I don't have  a problem if it
needs to stay here for whatever reason.


I think all of these runtime builders could live outside of assembly
and be called in a separate group by the node to allow for this move.
This overlaps with Raymond's discussion about where the builders
should be more generally.

Simon

Re: [2.x] builder woes

Posted by Simon Laws <si...@googlemail.com>.
I get the same results for the otests regardless of which version of
the builders I use so as of r818033 I've switched over to the new
ones. Very easy to revert if there are problems.

Regards

Simon