You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by "Antollini, Mario" <ma...@intel.com> on 2008/04/03 12:38:31 UTC

RE: Tutorial: Adding a Markeplace Scenario

Hello,

I have modified the composite for the store-market module. I had never
worked with multiplicity before. Thus, I need to some help to check if
this code is OK.

What I did was to modify the StoreMarketCatalog component from

<component name="StoreMarketCatalog">
...
	<reference name="fruitsCatalog"
target="StoreSupplierFruitsCatalog"/>	<reference
name="vegetablesCatalog" 	target="VegetablesCatalogWebService">
		<binding.ws/>
	</reference>	
...
</component>

To 

<component name="StoreMarketCatalog">
...
	<reference name="GoodsCatalog" multiplicity="0..n"
target="StoreMarketFruitsCatalog01 VegetablesCatalogWebService01"/>
...
</component>

So, the relevant parts of the composite look like this now:

...
<component name="StoreMarketCatalog">
	<implementation.java class="services.market.MarketCatalogImpl"/>

	<property name="currencyCode">USD</property>
	<service name="Catalog">
		<t:binding.jsonrpc/>
   	</service>
	<reference name="GoodsCatalog" multiplicity="0..n"
target="StoreMarketFruitsCatalog01 VegetablesCatalogWebService01"/>	
	<reference name="currencyConverter"
target="StoreMarketCurrencyConverter"/>	
</component>
 	
<component name="StoreMarketFruitsCatalog01">
	<implementation.java class="services.FruitsCatalogImpl"/> 
	<property name="currencyCode">USD</property>
	<reference name="currencyConverter"
target="StoreMarketCurrencyConverter"/>	
</component> 
	
<component name="VegetablesCatalogWebService01">
	<binding.ws/>
</component>
...


Jean-Sebastien mentioned that the approach of hard-coding the components
in the composite would not be needed when using multiplicity. However,
the way I used multiplicity here still requires new stores to be added
to the composite whenever the store wants to add its catalog to the
marketplace.

Jean-Sebastien, is this what you had in mind when you mentioned
multiplicity or am I doing something wrong?

Regards,
Mario


-----Original Message-----
From: Antollini, Mario [mailto:mario.antollini@intel.com] 
Sent: Thursday, March 27, 2008 6:28 PM
To: tuscany-dev@ws.apache.org
Subject: RE: Tutorial: Adding a Markeplace Scenario

Hello,

I have created the new module and called it "store-market" (I uploaded
it to JIRA: https://issues.apache.org/jira/browse/TUSCANY-2163)

As Jean-Sebastien suggested I took "store-merger" and modified it.

I now need to start working on the multiplicity 0..n instead of the 
currently hardcoded references to two catalogs.

Regards,
Mario


-----Original Message-----
From: Jean-Sebastien Delfino [mailto:jsdelfino@apache.org] 
Sent: Thursday, March 13, 2008 3:51 PM
To: tuscany-dev@ws.apache.org
Subject: Re: Tutorial: Adding a Markeplace Scenario

Antollini, Mario wrote:
> Hello jean-Sebastien,
> 
>  
> 
> I was thinking about adding a Marketplace scenario to the Tutorial we
> will be presenting at JavaOne. By Marketplace I mean doing something
> similar to what Amazon does: offering third party retailers' products
> via Amazon's site.
> 
>  
> 
> I think we can do that by offering multiple catalogs via a proxy
catalog
> which consolidates all of them (i.e. data federation).
> 
>  
> 
> What do you think? I will be looking the tutorial in detail in order
to
> see how I can implement it.
> 
>  
> 
> Regards,
> 
> Mario
> 
> 

Good idea!

This could be a new module addition under java/sca/tutorial.

You could wire a list of catalogs to a catalog aggregator service 
component for example, similar to what the current store-merger module 
does but with a reference with multiplicity 0..n instead of the 
currently hardcoded references to two catalogs.

The easiest is probably to copy one of the modules (store-merger for 
example) into a new store-market or something like that as a starting 
point, adjust the POM etc, submit that in a JIRA and then start making 
the changes to turn it into a marketplace store.

Let us know if have any questions, issues, or need any help when you do 
that.

Thanks!
-- 
Jean-Sebastien

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


RE: Tutorial: Adding a Markeplace Scenario

Posted by "Antollini, Mario" <ma...@intel.com>.
Hi Raymond,

Thanks for your comments...

If I understood correctly, the composite is OK but I need to modify the
java implementation in order to be compatible with what the composite
expresses, right?

I have created a new class in the assets/services/market/ directory
called MarketCatalogImpl.java (I took the
assets/services/merger/MergedCatalogImpl.java class as the starting
point).

It looks like this now:


package services.market;

import org.osoa.sca.annotations.Property;
import org.osoa.sca.annotations.Reference;

import services.Catalog;
import services.CurrencyConverter;
import services.Item;


public class MarketCatalogImpl implements Catalog {

    @Property
    public String currencyCode = "USD";
    
    @Reference
    public CurrencyConverter currencyConverter;
    
    @Reference(required=false)
    protected Catalog[] goodsCatalog;

    
    public Item[] get() {
        String currencySymbol =
currencyConverter.getCurrencySymbol(currencyCode);
        
        long length = 0;
        
        for(Catalog goods: goodsCatalog) {
        	length += goods.get().length;
        }
        
        Item[] catalog = new Item[length];
        
        int i = 0;
        for (Catalog goods: goodsCatalog) {
        	Item[] items = goods.get();
        	for(Item item: items) {
        		double price =
Double.valueOf(item.getPrice().substring(1));  
        		price = currencyConverter.getConversion("USD",
currencyCode, price);
        		catalog[i++] = new Item(item.getName(),
currencySymbol + price);
        	}
        }
               
        return catalog;
    }

}


Besides, I modified the first letter of the catalog name in the
composite in order for it to start with lowercase. It is this way now:

...
<reference name="goodsCatalog" multiplicity="0..n"
target="StoreMarketFruitsCatalog01 VegetablesCatalogWebService01"/>

...


I will upload the whole store-market code to Jira now and the
MarketCatalogImpl class later on.

Regards,
Mario



-----Original Message-----
From: Raymond Feng [mailto:enjoyjava@gmail.com] 
Sent: Thursday, April 03, 2008 1:11 PM
To: tuscany-dev@ws.apache.org
Subject: Re: Tutorial: Adding a Markeplace Scenario

Hi,

The following snippet doesn't not change the reference multiplicity to
be 
0..n.

> <component name="StoreMarketCatalog">
> ...
> <reference name="GoodsCatalog" multiplicity="0..n"
> target="StoreMarketFruitsCatalog01 VegetablesCatalogWebService01"/>
> ...
> </component>

<reference name="GoodsCatalog" multiplicity="0..n" ..> further
configures 
the reference GoodsCatalog from the componentType (introspected from
java 
impl class). But it has to be compatible. For example, you can change
the 
multiplicity from 0..n (defined in componentTpype) to 1..n, 0..1 or
1..1, 
but you cannot change it from 1..1 to 0..1, 0..n, or 1..n.

What matters is in the componentType. For example, if you have a java
impl:

public class StoreMarketCatalogImpl ... {

    @Reference(name="GoodsCatalog", required=false)
    protected Catalog[] goodsCatalog; // or protected
Collection<Catalog> 
goodsCatalog;
}

required=false and Catalog[] (or Collection<Catalog>) makes the
multiplicity 
of GoodsCatalog reference "0..n".

Thanks,
Raymond

--------------------------------------------------
From: "Antollini, Mario" <ma...@intel.com>
Sent: Thursday, April 03, 2008 3:38 AM
To: <tu...@ws.apache.org>
Subject: RE: Tutorial: Adding a Markeplace Scenario

> Hello,
>
> I have modified the composite for the store-market module. I had never
> worked with multiplicity before. Thus, I need to some help to check if
> this code is OK.
>
> What I did was to modify the StoreMarketCatalog component from
>
> <component name="StoreMarketCatalog">
> ...
> <reference name="fruitsCatalog"
> target="StoreSupplierFruitsCatalog"/> <reference
> name="vegetablesCatalog" target="VegetablesCatalogWebService">
> <binding.ws/>
> </reference>
> ...
> </component>
>
> To
>
> <component name="StoreMarketCatalog">
> ...
> <reference name="GoodsCatalog" multiplicity="0..n"
> target="StoreMarketFruitsCatalog01 VegetablesCatalogWebService01"/>
> ...
> </component>
>
> So, the relevant parts of the composite look like this now:
>
> ...
> <component name="StoreMarketCatalog">
> <implementation.java class="services.market.MarketCatalogImpl"/>
>
> <property name="currencyCode">USD</property>
> <service name="Catalog">
> <t:binding.jsonrpc/>
>   </service>
> <reference name="GoodsCatalog" multiplicity="0..n"
> target="StoreMarketFruitsCatalog01 VegetablesCatalogWebService01"/>
> <reference name="currencyConverter"
> target="StoreMarketCurrencyConverter"/>
> </component>
>
> <component name="StoreMarketFruitsCatalog01">
> <implementation.java class="services.FruitsCatalogImpl"/>
> <property name="currencyCode">USD</property>
> <reference name="currencyConverter"
> target="StoreMarketCurrencyConverter"/>
> </component>
>
> <component name="VegetablesCatalogWebService01">
> <binding.ws/>
> </component>
> ...
>
>
> Jean-Sebastien mentioned that the approach of hard-coding the
components
> in the composite would not be needed when using multiplicity. However,
> the way I used multiplicity here still requires new stores to be added
> to the composite whenever the store wants to add its catalog to the
> marketplace.
>
> Jean-Sebastien, is this what you had in mind when you mentioned
> multiplicity or am I doing something wrong?
>
> Regards,
> Mario
>
>
> -----Original Message-----
> From: Antollini, Mario [mailto:mario.antollini@intel.com]
> Sent: Thursday, March 27, 2008 6:28 PM
> To: tuscany-dev@ws.apache.org
> Subject: RE: Tutorial: Adding a Markeplace Scenario
>
> Hello,
>
> I have created the new module and called it "store-market" (I uploaded
> it to JIRA: https://issues.apache.org/jira/browse/TUSCANY-2163)
>
> As Jean-Sebastien suggested I took "store-merger" and modified it.
>
> I now need to start working on the multiplicity 0..n instead of the
> currently hardcoded references to two catalogs.
>
> Regards,
> Mario
>
>
> -----Original Message-----
> From: Jean-Sebastien Delfino [mailto:jsdelfino@apache.org]
> Sent: Thursday, March 13, 2008 3:51 PM
> To: tuscany-dev@ws.apache.org
> Subject: Re: Tutorial: Adding a Markeplace Scenario
>
> Antollini, Mario wrote:
>> Hello jean-Sebastien,
>>
>>
>>
>> I was thinking about adding a Marketplace scenario to the Tutorial we
>> will be presenting at JavaOne. By Marketplace I mean doing something
>> similar to what Amazon does: offering third party retailers' products
>> via Amazon's site.
>>
>>
>>
>> I think we can do that by offering multiple catalogs via a proxy
> catalog
>> which consolidates all of them (i.e. data federation).
>>
>>
>>
>> What do you think? I will be looking the tutorial in detail in order
> to
>> see how I can implement it.
>>
>>
>>
>> Regards,
>>
>> Mario
>>
>>
>
> Good idea!
>
> This could be a new module addition under java/sca/tutorial.
>
> You could wire a list of catalogs to a catalog aggregator service
> component for example, similar to what the current store-merger module
> does but with a reference with multiplicity 0..n instead of the
> currently hardcoded references to two catalogs.
>
> The easiest is probably to copy one of the modules (store-merger for
> example) into a new store-market or something like that as a starting
> point, adjust the POM etc, submit that in a JIRA and then start making
> the changes to turn it into a marketplace store.
>
> Let us know if have any questions, issues, or need any help when you
do
> that.
>
> Thanks!
> -- 
> Jean-Sebastien
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: Tutorial: Adding a Markeplace Scenario

Posted by Raymond Feng <en...@gmail.com>.
Hi,

The following snippet doesn't not change the reference multiplicity to be 
0..n.

> <component name="StoreMarketCatalog">
> ...
> <reference name="GoodsCatalog" multiplicity="0..n"
> target="StoreMarketFruitsCatalog01 VegetablesCatalogWebService01"/>
> ...
> </component>

<reference name="GoodsCatalog" multiplicity="0..n" ..> further configures 
the reference GoodsCatalog from the componentType (introspected from java 
impl class). But it has to be compatible. For example, you can change the 
multiplicity from 0..n (defined in componentTpype) to 1..n, 0..1 or 1..1, 
but you cannot change it from 1..1 to 0..1, 0..n, or 1..n.

What matters is in the componentType. For example, if you have a java impl:

public class StoreMarketCatalogImpl ... {

    @Reference(name="GoodsCatalog", required=false)
    protected Catalog[] goodsCatalog; // or protected Collection<Catalog> 
goodsCatalog;
}

required=false and Catalog[] (or Collection<Catalog>) makes the multiplicity 
of GoodsCatalog reference "0..n".

Thanks,
Raymond

--------------------------------------------------
From: "Antollini, Mario" <ma...@intel.com>
Sent: Thursday, April 03, 2008 3:38 AM
To: <tu...@ws.apache.org>
Subject: RE: Tutorial: Adding a Markeplace Scenario

> Hello,
>
> I have modified the composite for the store-market module. I had never
> worked with multiplicity before. Thus, I need to some help to check if
> this code is OK.
>
> What I did was to modify the StoreMarketCatalog component from
>
> <component name="StoreMarketCatalog">
> ...
> <reference name="fruitsCatalog"
> target="StoreSupplierFruitsCatalog"/> <reference
> name="vegetablesCatalog" target="VegetablesCatalogWebService">
> <binding.ws/>
> </reference>
> ...
> </component>
>
> To
>
> <component name="StoreMarketCatalog">
> ...
> <reference name="GoodsCatalog" multiplicity="0..n"
> target="StoreMarketFruitsCatalog01 VegetablesCatalogWebService01"/>
> ...
> </component>
>
> So, the relevant parts of the composite look like this now:
>
> ...
> <component name="StoreMarketCatalog">
> <implementation.java class="services.market.MarketCatalogImpl"/>
>
> <property name="currencyCode">USD</property>
> <service name="Catalog">
> <t:binding.jsonrpc/>
>   </service>
> <reference name="GoodsCatalog" multiplicity="0..n"
> target="StoreMarketFruitsCatalog01 VegetablesCatalogWebService01"/>
> <reference name="currencyConverter"
> target="StoreMarketCurrencyConverter"/>
> </component>
>
> <component name="StoreMarketFruitsCatalog01">
> <implementation.java class="services.FruitsCatalogImpl"/>
> <property name="currencyCode">USD</property>
> <reference name="currencyConverter"
> target="StoreMarketCurrencyConverter"/>
> </component>
>
> <component name="VegetablesCatalogWebService01">
> <binding.ws/>
> </component>
> ...
>
>
> Jean-Sebastien mentioned that the approach of hard-coding the components
> in the composite would not be needed when using multiplicity. However,
> the way I used multiplicity here still requires new stores to be added
> to the composite whenever the store wants to add its catalog to the
> marketplace.
>
> Jean-Sebastien, is this what you had in mind when you mentioned
> multiplicity or am I doing something wrong?
>
> Regards,
> Mario
>
>
> -----Original Message-----
> From: Antollini, Mario [mailto:mario.antollini@intel.com]
> Sent: Thursday, March 27, 2008 6:28 PM
> To: tuscany-dev@ws.apache.org
> Subject: RE: Tutorial: Adding a Markeplace Scenario
>
> Hello,
>
> I have created the new module and called it "store-market" (I uploaded
> it to JIRA: https://issues.apache.org/jira/browse/TUSCANY-2163)
>
> As Jean-Sebastien suggested I took "store-merger" and modified it.
>
> I now need to start working on the multiplicity 0..n instead of the
> currently hardcoded references to two catalogs.
>
> Regards,
> Mario
>
>
> -----Original Message-----
> From: Jean-Sebastien Delfino [mailto:jsdelfino@apache.org]
> Sent: Thursday, March 13, 2008 3:51 PM
> To: tuscany-dev@ws.apache.org
> Subject: Re: Tutorial: Adding a Markeplace Scenario
>
> Antollini, Mario wrote:
>> Hello jean-Sebastien,
>>
>>
>>
>> I was thinking about adding a Marketplace scenario to the Tutorial we
>> will be presenting at JavaOne. By Marketplace I mean doing something
>> similar to what Amazon does: offering third party retailers' products
>> via Amazon's site.
>>
>>
>>
>> I think we can do that by offering multiple catalogs via a proxy
> catalog
>> which consolidates all of them (i.e. data federation).
>>
>>
>>
>> What do you think? I will be looking the tutorial in detail in order
> to
>> see how I can implement it.
>>
>>
>>
>> Regards,
>>
>> Mario
>>
>>
>
> Good idea!
>
> This could be a new module addition under java/sca/tutorial.
>
> You could wire a list of catalogs to a catalog aggregator service
> component for example, similar to what the current store-merger module
> does but with a reference with multiplicity 0..n instead of the
> currently hardcoded references to two catalogs.
>
> The easiest is probably to copy one of the modules (store-merger for
> example) into a new store-market or something like that as a starting
> point, adjust the POM etc, submit that in a JIRA and then start making
> the changes to turn it into a marketplace store.
>
> Let us know if have any questions, issues, or need any help when you do
> that.
>
> Thanks!
> -- 
> Jean-Sebastien
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org