summaryrefslogtreecommitdiffstats
path: root/sandbox/lresende/sca-1.x/samples/store-secure-webapp/src/main/java/services/FruitsCatalogImpl.java
blob: 4cac4ac21debd9d2a6625ef6041fe5ed2bb9bda9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package services;

import java.util.ArrayList;
import java.util.List;

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

public class FruitsCatalogImpl implements Catalog {
	@Property
	public String currencyCode = "USD";
	@Reference
	public CurrencyConverter currencyConverter;

	private List<Item> catalog = new ArrayList<Item>();

	@Init
	public void init() {
		String currencySymbol = currencyConverter
				.getCurrencySymbol(currencyCode);
		catalog.add(new Item("Apple", currencySymbol
				+ currencyConverter.getConversion("USD", currencyCode, 2.99)));
		catalog.add(new Item("Orange", currencySymbol
				+ currencyConverter.getConversion("USD", currencyCode, 3.55)));
		catalog.add(new Item("Pear", currencySymbol
				+ currencyConverter.getConversion("USD", currencyCode, 1.55)));
	}

	public Item[] get() {
		Item[] catalogArray = new Item[catalog.size()];
		catalog.toArray(catalogArray);
		return catalogArray;
	}
}