You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by "Mario Antollini (JIRA)" <tu...@ws.apache.org> on 2008/04/19 21:28:22 UTC

[jira] Issue Comment Edited: (TUSCANY-2224) Tutorial Marketplace scenario ready

    [ https://issues.apache.org/jira/browse/TUSCANY-2224?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12590721#action_12590721 ] 

antollinim edited comment on TUSCANY-2224 at 4/19/08 12:27 PM:
--------------------------------------------------------------------

Hello,

I have improved the implementation of the file services.market.MarketCatalogImpl (under tutorial/assets). It loops only once over goodsCatalog now.

To add it to the tutorial, just copy and paste all the code I have copied here.

Regards,
Mario


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.    
 */

package services.market;

import java.util.Vector;

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);
	    Vector<Item> catalog = new Vector<Item>();
	    
	    for (int i = 0; i < goodsCatalog.length; i++) {
        	Item[] items = goodsCatalog[i].get();
        	
        	for(Item item: items) {
        		double price = Double.valueOf(item.getPrice().substring(1));  
        		price = currencyConverter.getConversion("USD", currencyCode, price);
        		catalog.addElement(new Item(item.getName(), currencySymbol + price));
        	}
        }
	    
	    Item[] catalogArray = new Item[catalog.size()];
	    catalog.copyInto(catalogArray);
	    
	    
        return catalogArray;
    }

}


      was (Author: antollinim):
    Hello,

I have improved the implementation of the file services.market.MarketCatalogImpl (under tutorial/assets).

This is the all the code (just copy and paste all of it)

Regards,
Mario


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.    
 */

package services.market;

import java.util.Vector;

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);
	    Vector<Item> catalog = new Vector<Item>();
	    
	    for (int i = 0; i < goodsCatalog.length; i++) {
        	Item[] items = goodsCatalog[i].get();
        	
        	for(Item item: items) {
        		double price = Double.valueOf(item.getPrice().substring(1));  
        		price = currencyConverter.getConversion("USD", currencyCode, price);
        		catalog.addElement(new Item(item.getName(), currencySymbol + price));
        	}
        }
	    
	    Item[] catalogArray = new Item[catalog.size()];
	    catalog.copyInto(catalogArray);
	    
	    
        return catalogArray;
    }

}

  
> Tutorial Marketplace scenario ready
> -----------------------------------
>
>                 Key: TUSCANY-2224
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-2224
>             Project: Tuscany
>          Issue Type: New Feature
>          Components: Java SCA Tutorial
>    Affects Versions: Java-SCA-Next
>            Reporter: Mario Antollini
>            Assignee: Luciano Resende
>             Fix For: Java-SCA-Next
>
>         Attachments: LaunchStoreMarketNode.zip, market.zip, store-market.zip, StoreMarketNode.zip
>
>
> Hello,
> I have finished coding the tutorial marketplace scenario.
> I have attached all the necessary files in here. 
> Please, follow these steps in order to add it as another module of the tutorial:
> market.zip -> contains the logic to obtain the MarketPlace catalog. Its content must be placed under tutorial\assets\services
> StoreMarketNode.zip -> Its content must be placed under tutorial\domain\cloud
> LaunchStoreMarketNode.zip -> Its content must be placed under tutorial\domain\launch
> store-market.zip -> this is the store-market module. This file must be uncompressed under \tutorial
> Besides, add the following lines:
> 1 - Into tutorial\assets\META-INF\sca-contribution.xml: <export.java package="services.market"/>
> 2 - Into tutorial\assets\tutorial.html: <h2><a href="http://localhost:8105/ui/store.html">Online Store - Marketplace</a>
> 3 - Into tutorial\domain\cloud.composite: <include name="ns2:StoreMarketNode" uri="http://tuscany.apache.org/cloud" xmlns:ns2="http://tuscany.apache.org/cloud"/>
> 4 - Into tutorial\domain\domain.composite: <include name="ns2:store-market" uri="store-market" xmlns:ns2="http://store"/>
> 4 - Into tutorial\domain\workspace.xml: <contribution location="file:../store-market/target/tutorial-store-market.jar" uri="store-market"/>
> 5 - Into tutorial\pom.xml: <module>store-market</module>
> How to run it?
> 1 - Compile tutorial\domain, tutorial\store-market, tutorial\assets
> 2 - # cd <tuscany_home>\tutorial\domain
> 3 - # java -jar <tuscany_home>\modules\tuscany-node2-launcher-1.2-incubating.jar domain
> 4 - Open this url in your browser: http://localhost:9990/ui/cloud/
> 5 - Start these Nodes in the listed order:
> 5.1 - CurrencyNode
> 5.2 - CatalogsNode
> 5.3 - StoreMarketNode
> 6 - Open <tuscany_home>\tutorial\assets\tutorial.html in your browser
> 7 - Click the link "Online Store - Marketplace"
> 8 - That is all... you should see some fruits and vegetables in the catalog
> If there is any problem, please let me know.
> Thanks and regards,
> Mario

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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