On 7/13/07, Peizhao Hu <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> Sorry for any confusion, here are an abstract example of what I am
> trying to do.
>
> I would like to treat each component as a function as the followings:
>
> ComponentA(x) :=> x + 2
> ComponentB(y) :=> y * 3
>
> and I would like a composite file to dynamically compose them, for
> example:
>
> ComponentB(ComponentA(100)) you get (100+2)*3
> where
> ComponentA(ComponentB(100)) you get (100*3)+2
>
> In my actually design, each component is a data processing module for
> computing raw sensor data, so I want the SCA to dynamically compose
> these component for me according to a description similar to the
> composite. I won't need to autowire option.
>
> many thanks
>
>
> Raymond Feng wrote:
> > Hi,
> >
> > Please see my comments inline.
> >
> > Thanks,
> > Raymond
> >
> > ----- Original Message ----- From: "Peizhao Hu" <[EMAIL PROTECTED]>
> > To: <[email protected]>
> > Sent: Thursday, July 12, 2007 7:44 PM
> > Subject: Can anyone show me example of a simple scenario?
> >
> >
> >> Hi,
> >>
> >> I want to achieve the following tasks in Tuscany. However, not quite
> >> sure which sample I really should look into. Can anyone point me to
> >> the right direction?
> >>
> >> I want to write implementation for two components where each
> >> component take one input and generate one output. Imagine that these
> >> components are generic function, therefore, composition of these
> >> components is done by writing the composite file, which wires
> >> component's service(as output) and reference(as input) together.
> >
> > It seems that you want implement some mediation logic, am I right? You
> > could define a generic interface or take advantage of the "any"
> > interface (org.apache.tuscany.sca.interfacedef.Interface, if
> > isDynamic() returns true).
> >
> >>
> >> is there any simple example for this scenario?
> >>
> >> In the Tuscany samples, such as bigbank, it seems to me that
> >> composite service needs to have knowledge about the component service
> >> they are going to reference. but in my case, I want all component to
> >> be generic, and be able to dynamically compose by defining the
> >> composite file of what components to use.
> >>
> >
> > What are the criteria for your composition? SCA spec defines the
> > wiring between a component reference and component service by the
> > interface compatibility. Components can also be autowired by the
> > runtime. Do you just want to programatically wire the components
> > together or do you expect the Tuscany runtime to wire things based on
> > the metadata (such as business semantics, service-level agreement)?
> >
> >> not sure whether the SCA is a better way to do this? any idea or
> >> comment?
> >>
> >> --
> >> regards;
> >>
> >> Peizhao
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >
>
> --
> regards;
>
> Peizhao
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> Hi, doing a bit of mail tidying an notice you didn't get an answer to
this. The secret to what you need is to ensure that the interfaces of the
components you are building are composable in any order. In the real world,
with sensor data the physical interface is the air or a wire but you have to
understand the signals going through the wire/air in order that each
processor can successfully process them.
In your expression example the fundamental interface you have is
interface MathComponent {
int process(int number);
}
Assuming you wanted the result to be returned. The component implementations
could then look something like
class AddComponent implements MathComponent {
@Reference
protected nextComponent;
int process(int number){
if ( nextComponent != null) {
return nextComponent.process(number) + 2;
} else {
return number + 2;
}
}
}
and of course you would write a multiply component along the same lines
(Note. I just typed this code in here so don't expect it tocompile :-). Then
you can wire them together as you please.
<component name="AddComponent>
<implemenation.java class="AddComponent"/>
<reference name="nextComponent" target="MultipleComponent"/>
</component>
<component name="MultipleComponent>
<implemenation.java class="MultiplyComponent"/>
</component>
It would make a great sample for Tuscany if you were happy to make these
classes for real and contribute them.
Regards
Simon