+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml b/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..0bc67c4c98
--- /dev/null
+++ b/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml b/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml
new file mode 100644
index 0000000000..6126c01eb3
--- /dev/null
+++ b/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+ org.apache.tuscany.sca
+ demo-alert-aggregator-webapp
+ 1.4-SNAPSHOT
+ war
+
+
+
+ org.apache.axiom
+ org.apache.axis2
+ org.apache.commons
+ org.jdom
+
+
+
diff --git a/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/web.xml b/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..a81165e1b4
--- /dev/null
+++ b/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+ Apache Tuscany Alert Aggregator Demo
+
+
+ tuscany
+ org.apache.tuscany.sca.host.webapp.TuscanyServletFilter
+
+
+
+ tuscany
+ /*
+
+
+
+ AlertAggregator.html
+
+
+
diff --git a/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/pop.png b/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/pop.png
new file mode 100644
index 0000000000..1cf1df24a7
Binary files /dev/null and b/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/pop.png differ
diff --git a/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/rss.png b/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/rss.png
new file mode 100644
index 0000000000..b3c949d224
Binary files /dev/null and b/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/rss.png differ
diff --git a/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/service.smd b/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/service.smd
new file mode 100644
index 0000000000..3c6b6c9b12
--- /dev/null
+++ b/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/service.smd
@@ -0,0 +1 @@
+{"SMDVersion":".1","objectName":"AlertsService","serviceType":"JSON-RPC","serviceURL":"http://localhost:8085/sample-feed-aggregator/services/AlertsServiceJSONRPC","methods":[{"name":"getAllNewAlerts","parameters":[{"name":"param0","type":"STRING"}]}]}
diff --git a/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/sources.smd b/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/sources.smd
new file mode 100644
index 0000000000..b5f1824363
--- /dev/null
+++ b/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/sources.smd
@@ -0,0 +1 @@
+{"SMDVersion":".1","objectName":"AlertsSourcesService","serviceType":"JSON-RPC","serviceURL":"http://localhost:8081/sample-feed-aggregator/services/AlertsSourcesServiceJSONRPC","methods":[{"name":"getAlertSources","parameters":[{"name":"param0","type":"STRING"}]},{"name":"getAlertSource","parameters":[{"name":"param0","type":"STRING"}]},{"name":"updateAlertSource","parameters":[{"name":"param0","type":"STRING"}]},{"name":"addAlertSource","parameters":[{"name":"param0","type":"STRING"}]},{"name":"removeAlertSource","parameters":[{"name":"param0","type":"STRING"}]}]}
diff --git a/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/style.css b/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/style.css
new file mode 100644
index 0000000000..f5bbf23379
--- /dev/null
+++ b/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/main/webapp/style.css
@@ -0,0 +1,176 @@
+/*
+ * 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.
+ */
+
+p,table,li,h1,h2,h3
+{
+font-family: verdana, arial, 'sans serif';
+}
+
+p, h1, h2, h3, table, li, hr
+{
+margin-left: 10pt;
+}
+
+table
+{
+border-color: black;
+border-collapse: separate;
+border-spacing: 0px 1px;
+
+margin-right: 10pt;
+margin-left: 10pt;
+width: 800px;
+}
+
+.sourceDetailsTable
+{
+width: 600px;
+}
+
+tr, td
+{
+margin-left: 0pt;
+margin-right: 0pt;
+padding-left: 10pt;
+font-size: 90%;
+}
+
+p,li,th
+{
+font-size: 90%;
+margin-left: 10pt;
+}
+
+pre
+{
+margin-left: 10pt;
+}
+
+body
+{
+#ffffff;
+}
+
+h1,h2,h3,hr
+{
+color: firebrick;
+}
+
+a:link {COLOR: firebrick;}
+a:visited {COLOR: firebrick;}
+a:active {COLOR: navy;}
+
+.link
+{
+COLOR: firebrick;
+text-decoration: underline;
+}
+
+.clickable
+{
+cursor: pointer
+}
+
+.unread_title
+{
+font-weight: bold;
+}
+
+.read_title
+{
+font-weight: normal;
+}
+
+.summary
+{
+color: DimGrey;
+}
+
+.hidden
+{
+display: none;
+}
+
+.source_name
+{
+width: 600px;
+}
+
+.alert_text
+{
+width: 600px;
+}
+
+.alert_data
+{
+margin-left: 10px;
+width: 800px;
+height: 800px;
+}
+
+.source_0
+{
+background-color: LightGreen;
+}
+
+.source_1
+{
+background-color: LightSkyBlue;
+}
+
+.source_2
+{
+background-color: Khaki;
+}
+
+.source_3
+{
+background-color: LightPink;
+}
+
+.source_4
+{
+background-color: Orange;
+}
+
+.source_5
+{
+background-color: LightCoral;
+}
+
+.source_6
+{
+background-color: Orchid;
+}
+
+.source_7
+{
+background-color: Peru;
+}
+
+.source_8
+{
+background-color: SpringGreen;
+}
+
+.source_9
+{
+background-color: LightGrey;
+}
+
diff --git a/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/test/java/org/apache/tuscany/sca/demos/aggregator/AlertsIntegrationTest.java b/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/test/java/org/apache/tuscany/sca/demos/aggregator/AlertsIntegrationTest.java
new file mode 100644
index 0000000000..f0cb9ecfcb
--- /dev/null
+++ b/branches/sca-java-1.4/demos/alert-aggregator-webapp/src/test/java/org/apache/tuscany/sca/demos/aggregator/AlertsIntegrationTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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 org.apache.tuscany.sca.demos.aggregator;
+
+import java.io.ByteArrayInputStream;
+
+import junit.framework.Assert;
+
+import org.json.JSONObject;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.meterware.httpunit.PostMethodWebRequest;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+
+/**
+ */
+public class AlertsIntegrationTest {
+ //private static SCADomain scaDomain;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ //scaDomain = SCADomain.newInstance("alerts.composite");
+ }
+
+ /**
+ * Runs after each test method
+ */
+ @AfterClass
+ public static void tearDown() {
+ //scaDomain.close();
+ }
+
+/* Use this if you want to test locally without deploying to a web container
+ public void testWait() throws Exception {
+ System.out.println("Feed aggregator server started (press enter to shutdown)");
+ System.in.read();
+ System.out.println("Feed aggregator server stopped");
+ }
+*/
+
+ @Test
+ public void testGetAllNewAlerts() throws Exception {
+ JSONObject jsonRequest = new JSONObject("{\"params\":[\"sometext\"],\"method\":\"getAllNewAlerts\",\"id\":2}");
+ JSONObject jsonResp = callService ("http://localhost:8085/demo-alert-aggregator-webapp/AlertsServiceJSONRPC",
+ jsonRequest);
+ Assert.assertNotNull(jsonResp);
+ }
+
+ @Test
+ public void testAddAlertSources() throws Exception {
+ JSONObject jsonRequest = new JSONObject("{\"params\":[{\"name\":\"news\",\"id\":\"2\",\"address\":\"www.news.com\",\"feedAddress\":\"http://news.com.com/2547-1_3-0-20.xml\",\"feedType\":\"rss\",\"lastChecked\":\"lastChecked\",\"javaClass\":\"org.apache.tuscany.sca.demos.aggregator.types.impl.SourceTypeImpl\"}],\"method\":\"addAlertSource\",\"id\":2}");
+ JSONObject jsonResp = callService ("http://localhost:8085/demo-alert-aggregator-webapp/AlertsSourcesServiceJSONRPC",
+ jsonRequest);
+ Assert.assertNotNull(jsonResp);
+ }
+
+ @Test
+ public void testGetAlertSources() throws Exception {
+ JSONObject jsonRequest = new JSONObject("{\"params\":[\"sometext\"],\"method\":\"getAlertSources\",\"id\":2}");
+ JSONObject jsonResp = callService ("http://localhost:8085/demo-alert-aggregator-webapp/AlertsSourcesServiceJSONRPC",
+ jsonRequest);
+ Assert.assertEquals("BBC News", jsonResp.getJSONObject("result").getJSONObject("source").optJSONArray("list").getJSONObject(0).getString("name"));
+ }
+
+ public JSONObject callService(String url, JSONObject jsonRequest) throws Exception {
+ System.out.println("Request = " + jsonRequest.toString());
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest( url,
+ new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")),"application/json");
+ WebResponse response = wc.getResource(request);
+ System.out.println("Response= " + response.getText());
+ Assert.assertEquals(200, response.getResponseCode());
+ return new JSONObject(response.getText());
+ }
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-account/README b/branches/sca-java-1.4/demos/bigbank-account/README
new file mode 100644
index 0000000000..5c0d850c5e
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/README
@@ -0,0 +1,4 @@
+bigbank-account is part of a larger demo called bigbank.
+Please see the Readme file under bigbank to understand how bigbank-account fits into the overall demo.
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank-account/bigbank.png b/branches/sca-java-1.4/demos/bigbank-account/bigbank.png
new file mode 100644
index 0000000000..985cc6bd05
Binary files /dev/null and b/branches/sca-java-1.4/demos/bigbank-account/bigbank.png differ
diff --git a/branches/sca-java-1.4/demos/bigbank-account/bigbank.svg b/branches/sca-java-1.4/demos/bigbank-account/bigbank.svg
new file mode 100644
index 0000000000..0650075d48
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/bigbank.svg
@@ -0,0 +1,537 @@
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank-account/build-dojo.xml b/branches/sca-java-1.4/demos/bigbank-account/build-dojo.xml
new file mode 100644
index 0000000000..0e029c6335
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/build-dojo.xml
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank-account/build.xml b/branches/sca-java-1.4/demos/bigbank-account/build.xml
new file mode 100644
index 0000000000..f7ebe32968
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/build.xml
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank-account/pom.xml b/branches/sca-java-1.4/demos/bigbank-account/pom.xml
new file mode 100644
index 0000000000..8ae35dbf3e
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/pom.xml
@@ -0,0 +1,76 @@
+
+
+
+ 4.0.0
+
+ org.apache.tuscany.sca
+ tuscany-demos
+ 1.4-SNAPSHOT
+ ../pom.xml
+
+ demo-bigbank-account
+ jar
+ Apache Tuscany SCA Demo BigBank Account
+
+
+
+ apache.incubator
+ http://people.apache.org/repo/m2-incubating-repository
+
+
+
+
+
+ org.apache.tuscany.sca
+ tuscany-core-spi
+ 1.4-SNAPSHOT
+
+
+
+ org.apache.tuscany.sca
+ tuscany-policy-security
+ 1.4-SNAPSHOT
+
+
+
+ org.apache.ws.security
+ wss4j
+ 1.5.3
+
+
+
+
+ demo-bigbank-account
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+
+
+
+ ant
+ ant-trax
+ 1.6.5
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountDetails.java b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountDetails.java
new file mode 100644
index 0000000000..57c1adcba0
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountDetails.java
@@ -0,0 +1,50 @@
+/*
+ * 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 bigbank.account.checking;
+
+/**
+ * @version $$Rev$$ $$Date: 2007-04-09 12:03:34 -0700 (Mon, 09 Apr
+ * 2007) $$
+ */
+
+public class CheckingAccountDetails {
+ private String accountNumber;
+ private double balance;
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String n) {
+ this.accountNumber = n;
+ }
+
+ public double getBalance() {
+ return balance;
+ }
+
+ public void setBalance(double b) {
+ this.balance = b;
+ }
+
+ @Override
+ public String toString() {
+ return accountNumber + ", balance:" + balance;
+ }
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountService.java b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountService.java
new file mode 100644
index 0000000000..bf919525c4
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountService.java
@@ -0,0 +1,37 @@
+/*
+ * 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 bigbank.account.checking;
+
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+@Service
+@Remotable
+public interface CheckingAccountService {
+
+ public CheckingAccountDetails getAccountDetails(String customerID);
+
+ public double deposit(String accountNo, double depositAmt);
+
+ public double withdraw(String accountNo, double withdrawalAmount);
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountServiceImpl.java b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountServiceImpl.java
new file mode 100644
index 0000000000..0ed4b1dd2e
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountServiceImpl.java
@@ -0,0 +1,66 @@
+/*
+ * 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 bigbank.account.checking;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ *
+ * */
+
+@Service(CheckingAccountService.class)
+public class CheckingAccountServiceImpl implements CheckingAccountService {
+ private Map custAcctMap = new HashMap();
+ private Map checkingAccts = new HashMap();
+
+ public CheckingAccountServiceImpl() {
+ custAcctMap.put("Customer_01", "CHA_Customer_01");
+ custAcctMap.put("Customer_02", "CHA_Customer_02");
+ custAcctMap.put("Customer_03", "CHA_Customer_03");
+
+ checkingAccts.put("CHA_Customer_01", new Double(1000));
+ checkingAccts.put("CHA_Customer_02", new Double(1500));
+ checkingAccts.put("CHA_Customer_03", new Double(2000));
+ }
+
+ public double deposit(String accountNo, double depositAmt) {
+ checkingAccts.put(accountNo, new Double(checkingAccts.get(accountNo).doubleValue() + depositAmt));
+ return checkingAccts.get(accountNo).doubleValue();
+ }
+
+ public CheckingAccountDetails getAccountDetails(String customerID) {
+ CheckingAccountDetails checkingAccount = new CheckingAccountDetails();
+ checkingAccount.setAccountNumber(custAcctMap.get(customerID));
+ checkingAccount.setBalance(checkingAccts.get(checkingAccount.getAccountNumber()).doubleValue());
+
+ return checkingAccount;
+ }
+
+ public double withdraw(String accountNo, double withdrawalAmount) {
+ double balance = checkingAccts.get(accountNo).doubleValue();
+ if ( balance - withdrawalAmount > 0 ) {
+ balance = balance - withdrawalAmount;
+ checkingAccts.put(accountNo, balance);
+ }
+ return balance;
+ }
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountDetails.java b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountDetails.java
new file mode 100644
index 0000000000..cc9023da60
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountDetails.java
@@ -0,0 +1,52 @@
+/*
+ * 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 bigbank.account.savings;
+
+import java.io.Serializable;
+
+/**
+ * @version $$Rev$$ $$Date: 2007-04-09 12:03:34 -0700 (Mon, 09 Apr
+ * 2007) $$
+ */
+
+public class SavingsAccountDetails implements Serializable {
+ private String accountNumber;
+ private double balance;
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String n) {
+ this.accountNumber = n;
+ }
+
+ public double getBalance() {
+ return balance;
+ }
+
+ public void setBalance(double b) {
+ this.balance = b;
+ }
+
+ @Override
+ public String toString() {
+ return accountNumber + ", balance:" + balance;
+ }
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountService.java b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountService.java
new file mode 100644
index 0000000000..5bf6e6d26b
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountService.java
@@ -0,0 +1,35 @@
+/*
+ * 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 bigbank.account.savings;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+@Remotable
+public interface SavingsAccountService {
+
+ public SavingsAccountDetails getAccountDetails(String customerID);
+
+ public double deposit(String accountNo, double depositAmt);
+
+ public double withdraw(String accountNo, double withdrawalAmount);
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.java b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.java
new file mode 100644
index 0000000000..1f4f02ea6d
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.java
@@ -0,0 +1,66 @@
+/*
+ * 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 bigbank.account.savings;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ *
+ * */
+
+@Service(SavingsAccountService.class)
+public class SavingsAccountServiceImpl implements SavingsAccountService {
+ private Map custAcctMap = new HashMap();
+ private Map savingsAccts = new HashMap();
+
+ public SavingsAccountServiceImpl() {
+ custAcctMap.put("Customer_01", "SVA_Customer_01");
+ custAcctMap.put("Customer_02", "SVA_Customer_02");
+ custAcctMap.put("Customer_03", "SVA_Customer_03");
+
+ savingsAccts.put("SVA_Customer_01", new Double(1000));
+ savingsAccts.put("SVA_Customer_02", new Double(1500));
+ savingsAccts.put("SVA_Customer_03", new Double(2000));
+ }
+
+ public double deposit(String accountNo, double depositAmt) {
+ savingsAccts.put(accountNo, new Double(savingsAccts.get(accountNo).doubleValue() + depositAmt));
+ return savingsAccts.get(accountNo).doubleValue();
+ }
+
+ public SavingsAccountDetails getAccountDetails(String customerID) {
+ SavingsAccountDetails savingsAccount = new SavingsAccountDetails();
+ savingsAccount.setAccountNumber(custAcctMap.get(customerID));
+ savingsAccount.setBalance(savingsAccts.get(savingsAccount.getAccountNumber()).doubleValue());
+
+ return savingsAccount;
+ }
+
+ public double withdraw(String accountNo, double withdrawalAmount) {
+ double balance = savingsAccts.get(accountNo).doubleValue();
+ if ( balance - withdrawalAmount > 0 ) {
+ balance = balance - withdrawalAmount;
+ savingsAccts.put(accountNo, balance);
+ }
+ return balance;
+ }
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/AccountsDataPasswordCallbackHandler.java b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/AccountsDataPasswordCallbackHandler.java
new file mode 100644
index 0000000000..579b4ee64b
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/AccountsDataPasswordCallbackHandler.java
@@ -0,0 +1,54 @@
+/*
+ * 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 bigbank.account.security;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class
+ */
+public class AccountsDataPasswordCallbackHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+ if ( pwcb.getUsage() == WSPasswordCallback.SIGNATURE ) {
+ System.out.println(" Usage is SIGNATURE ... ");
+ pwcb.setPassword("bbservice");
+ } else if ( pwcb.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN ) {
+ System.out.println("*** Calling ACCOUNTS-DATA Passwd Handler for AUTHENTICATING userID = "
+ + pwcb.getIdentifer() + " and password = " + pwcb.getPassword() );
+ if ( pwcb.getIdentifer().equals("bbaservice") && pwcb.getPassword().equals("bbaservice")) {
+ System.out.println("AUTHENTICATION SUCCESSFUL!");
+ } else {
+ System.out.println("AUTHENTICATION FAILED!");
+ throw new UnsupportedCallbackException(pwcb, "UserId - Password Authentication Failed!");
+ }
+ }
+ }
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/BigbankCheckingsAcl.java b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/BigbankCheckingsAcl.java
new file mode 100644
index 0000000000..5c64e11d10
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/BigbankCheckingsAcl.java
@@ -0,0 +1,48 @@
+/*
+ * 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 bigbank.account.security;
+
+import java.security.Principal;
+import java.util.Hashtable;
+import java.util.Map;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BigbankCheckingsAcl {
+ private static MapcheckingsAcl = new Hashtable();
+
+ static {
+ checkingsAcl.put("bbaservice", "Customer_01");
+ checkingsAcl.put("bbUser01", "Customer_01");
+ }
+
+
+ public static void authorize(Principal principal, String resource) {
+ if ( checkingsAcl.get(principal.getName()) == null ||
+ !checkingsAcl.get(principal.getName()).equals(resource) ) {
+ throw new RuntimeException("User - " + principal.getName() + " not authorized to access account " +
+ resource);
+ } else {
+ System.out.println("Successfully Authorized '" + principal.getName() + " to access accounts of " + resource);
+ }
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthImplementationPolicyProvider.java b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthImplementationPolicyProvider.java
new file mode 100644
index 0000000000..c98dcacbf3
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthImplementationPolicyProvider.java
@@ -0,0 +1,90 @@
+/*
+ * 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 bigbank.account.security;
+
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.OperationsConfigurator;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CheckingsDeptAuthImplementationPolicyProvider implements PolicyProvider {
+ private RuntimeComponent component;
+ private Implementation implementation;
+
+ public CheckingsDeptAuthImplementationPolicyProvider(RuntimeComponent component, Implementation implementation) {
+ super();
+ this.component = component;
+ this.implementation = implementation;
+ }
+
+ private String getContext() {
+ return "component.implementation: " + component.getURI() + "(" + implementation.getClass().getName() + ")";
+ }
+
+ private PolicySet findPolicySet(Operation operation) {
+ for (PolicySet ps : component.getPolicySets()) {
+ for (Object p : ps.getPolicies()) {
+ if (CheckingsDeptAuthPolicy.class.isInstance(p)) {
+ return ps;
+ }
+ }
+ }
+
+ if ( component instanceof OperationsConfigurator ) {
+ for ( ConfiguredOperation confOp : ((OperationsConfigurator)component).getConfiguredOperations() ) {
+ if ( confOp.getName().equals(operation.getName())) {
+ for (PolicySet ps : confOp.getPolicySets()) {
+ for (Object p : ps.getPolicies()) {
+ if (CheckingsDeptAuthPolicy.class.isInstance(p)) {
+ return ps;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation)
+ */
+ public Interceptor createInterceptor(Operation operation) {
+ PolicySet ps = findPolicySet(operation);
+ return ps == null ? null : new CheckingsDeptAuthPolicyInterceptor(getContext(), operation, ps);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase()
+ */
+ public String getPhase() {
+ return Phase.IMPLEMENTATION_POLICY;
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicy.java b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicy.java
new file mode 100644
index 0000000000..121ee9a3f8
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicy.java
@@ -0,0 +1,46 @@
+/*
+ * 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 bigbank.account.security;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.Policy;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CheckingsDeptAuthPolicy implements Policy {
+
+ public QName getSchemaName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isUnresolved() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyInterceptor.java b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyInterceptor.java
new file mode 100644
index 0000000000..1d565f7ca1
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyInterceptor.java
@@ -0,0 +1,79 @@
+package bigbank.account.security;
+
+import java.security.Principal;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.SecurityUtil;
+
+/*
+ * 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.
+ */
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy
+ */
+public class CheckingsDeptAuthPolicyInterceptor implements Interceptor {
+ private Invoker next;
+
+ public CheckingsDeptAuthPolicyInterceptor(String context, Operation operation, PolicySet policySet) {
+ super();
+ init();
+ }
+
+ private final void init() {
+ }
+
+ public Message invoke(Message msg) {
+ Object msgBody = msg.getBody();
+ if (msgBody instanceof Object[]) {
+ Object args[] = (Object[])msg.getBody();
+ Principal principal = SecurityUtil.getPrincipal(msg);
+ if (principal != null){
+ BigbankCheckingsAcl.authorize(principal,
+ (String)args[0]);
+ }
+ }
+
+ Message responseMsg = null;
+ try {
+ responseMsg = getNext().invoke(msg);
+ return responseMsg;
+ } catch (RuntimeException e) {
+ throw e;
+ }
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyProviderFactory.java b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyProviderFactory.java
new file mode 100644
index 0000000000..5fecef691e
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyProviderFactory.java
@@ -0,0 +1,75 @@
+/*
+ * 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 bigbank.account.security;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CheckingsDeptAuthPolicyProviderFactory implements PolicyProviderFactory {
+ private ExtensionPointRegistry registry;
+
+ public CheckingsDeptAuthPolicyProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createImplementationPolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.assembly.Implementation)
+ */
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component, Implementation implementation) {
+ return new CheckingsDeptAuthImplementationPolicyProvider(component, implementation);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createReferencePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentReference, org.apache.tuscany.sca.assembly.Binding)
+ */
+ public PolicyProvider createReferencePolicyProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding) {
+ return null;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createServicePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentService, org.apache.tuscany.sca.assembly.Binding)
+ */
+ public PolicyProvider createServicePolicyProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding) {
+ return null;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyHandler.java b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyHandler.java
new file mode 100644
index 0000000000..6667a4ba53
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyHandler.java
@@ -0,0 +1,67 @@
+/*
+ * 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 bigbank.account.security;
+
+import java.security.Principal;
+
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.SecurityUtil;
+import org.apache.tuscany.sca.policy.util.PolicyHandler;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CheckingsDeptAuthorizationPolicyHandler implements PolicyHandler {
+ private PolicySet applicablePolicySet = null;
+
+ public void afterInvoke(Object... context) {
+ }
+
+ public void beforeInvoke(Object... context) {
+ for ( int count = 0 ; count < context.length ; ++count ) {
+ if ( context[count] instanceof Message ) {
+ Message msg = (Message)context[count];
+ Object args[] = (Object[])msg.getBody();
+ Principal principal = SecurityUtil.getPrincipal(msg);
+ if (principal != null){
+ BigbankCheckingsAcl.authorize(principal,
+ (String)args[0]);
+ }
+ }
+ }
+ }
+
+ public void cleanUp(Object... arg0) {
+ }
+
+ public PolicySet getApplicablePolicySet() {
+ return this.applicablePolicySet;
+ }
+
+ public void setApplicablePolicySet(PolicySet policySet) {
+ this.applicablePolicySet = policySet;
+ }
+
+ public void setUp(Object... arg0) {
+
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyProcessor.java b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyProcessor.java
new file mode 100644
index 0000000000..da1b6e1d06
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyProcessor.java
@@ -0,0 +1,72 @@
+/*
+ * 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 bigbank.account.security;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
+
+/**
+ * Implementation of a Policy Processor
+ *
+ */
+public class CheckingsDeptAuthorizationPolicyProcessor implements StAXArtifactProcessor {
+ private static final QName CHECKINGS_DEPT_AUTHORIZATION_POLICY_QNAME = new QName("http://bigbank/checkings", "AuthPolicy");
+ public QName getArtifactType() {
+ return CHECKINGS_DEPT_AUTHORIZATION_POLICY_QNAME;
+ }
+
+ public CheckingsDeptAuthorizationPolicyProcessor(ModelFactoryExtensionPoint modelFactories) {
+ }
+
+
+ public CheckingsDeptAuthPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+ CheckingsDeptAuthPolicy policy = new CheckingsDeptAuthPolicy();
+ return policy;
+ }
+
+ public void write(CheckingsDeptAuthPolicy policy, XMLStreamWriter writer) throws ContributionWriteException,
+ XMLStreamException {
+ String prefix = "tuscany";
+ writer.writeStartElement(prefix,
+ CHECKINGS_DEPT_AUTHORIZATION_POLICY_QNAME.getLocalPart(),
+ CHECKINGS_DEPT_AUTHORIZATION_POLICY_QNAME.getNamespaceURI());
+ writer.writeNamespace("chk", "http://bigbank/checkings");
+
+
+ writer.writeEndElement();
+ }
+
+ public Class getModelType() {
+ return CheckingsDeptAuthPolicy.class;
+ }
+
+ public void resolve(CheckingsDeptAuthPolicy arg0, ModelResolver arg1) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountDetails.java b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountDetails.java
new file mode 100644
index 0000000000..1473436000
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountDetails.java
@@ -0,0 +1,68 @@
+/*
+ * 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 bigbank.account.stock;
+
+/**
+ * @version $$Rev$$ $$Date: 2007-04-09 12:03:34 -0700 (Mon, 09 Apr
+ * 2007) $$
+ */
+
+public class StockAccountDetails {
+ private String accountNumber;
+ private String symbol;
+ private int quantity;
+
+ public StockAccountDetails() {
+ }
+
+ public StockAccountDetails(String acNo, String symbol, int qty) {
+ this.accountNumber = acNo;
+ this.symbol = symbol;
+ this.quantity = qty;
+ }
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String n) {
+ this.accountNumber = n;
+ }
+
+ public int getQuantity() {
+ return quantity;
+ }
+
+ public void setQuantity(int a) {
+ this.quantity = a;
+ }
+
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public void setSymbol(String s) {
+ this.symbol = s;
+ }
+
+ @Override
+ public String toString() {
+ return accountNumber + ", symbol:" + symbol + ", quantity:" + quantity;
+ }
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountService.java b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountService.java
new file mode 100644
index 0000000000..fcbf8a4831
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountService.java
@@ -0,0 +1,36 @@
+/*
+ * 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 bigbank.account.stock;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ *
+ */
+@Remotable
+public interface StockAccountService {
+
+ public StockAccountDetails getAccountDetails(String customerID);
+
+ public StockAccountDetails buy(String accountNo, String symbol, int quantity);
+
+ public StockAccountDetails sell(String accountNo, String symbol, int quantity);
+
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountServiceImpl.java b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountServiceImpl.java
new file mode 100644
index 0000000000..28101a1986
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountServiceImpl.java
@@ -0,0 +1,60 @@
+/*
+ * 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 bigbank.account.stock;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ *
+ * */
+
+@Service(StockAccountService.class)
+public class StockAccountServiceImpl implements StockAccountService {
+ private Map custAcctMap = new HashMap();
+ private Map stockAccts = new HashMap();
+
+ public StockAccountServiceImpl() {
+ custAcctMap.put("Customer_01", "STA_Customer_01");
+ custAcctMap.put("Customer_02", "STA_Customer_02");
+ custAcctMap.put("Customer_03", "STA_Customer_03");
+
+ stockAccts.put("STA_Customer_01", new StockAccountDetails("STA_Customer_01", "IBM", 100));
+ stockAccts.put("STA_Customer_02", new StockAccountDetails("STA_Customer_02", "IBM", 200));
+ stockAccts.put("STA_Customer_03", new StockAccountDetails("STA_Customer_03", "SYM_3", 125));
+ }
+
+
+ public StockAccountDetails buy(String accountNo, String symbol, int quantity) {
+ return null;
+ }
+
+ public StockAccountDetails getAccountDetails(String customerID) {
+ return stockAccts.get(custAcctMap.get(customerID));
+ }
+
+ public StockAccountDetails sell(String accountNo, String symbol, int quantity) {
+ return null;
+ }
+
+
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/CheckingsAccount.composite b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/CheckingsAccount.composite
new file mode 100644
index 0000000000..cc76e30a75
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/CheckingsAccount.composite
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..c5532b879d
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..6491a0d326
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,19 @@
+# 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.
+
+# Implementation class for the artifact processor extension
+bigbank.account.security.CheckingsDeptAuthorizationPolicyProcessor;qname=http://bigbank/checkings#AuthPolicy,model=bigbank.account.security.CheckingsDeptAuthPolicy
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler
new file mode 100644
index 0000000000..b1bce4339d
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler
@@ -0,0 +1,20 @@
+# 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.
+#
+# PolicyHandlerClasses to interpret specific PolicyModels against specific QoS infrastructures
+# handler classname;qname=;model=
+bigbank.account.security.CheckingsDeptAuthorizationPolicyHandler;intent=http://bigbankAccount#authorization,model=bigbank.account.security.CheckingsDeptAuthPolicy
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
new file mode 100644
index 0000000000..d6bfe2167e
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
@@ -0,0 +1,19 @@
+# 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.
+
+# Implementation class for the policy extension
+bigbank.account.security.CheckingsDeptAuthPolicyProviderFactory;model=bigbank.account.security.CheckingsDeptAuthPolicy
\ No newline at end of file
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/SavingsAccount.composite b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/SavingsAccount.composite
new file mode 100644
index 0000000000..696b96d6e6
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/SavingsAccount.composite
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/StockAccount.composite b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/StockAccount.composite
new file mode 100644
index 0000000000..62c0b63003
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/StockAccount.composite
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/definitions.xml b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/definitions.xml
new file mode 100644
index 0000000000..31a8798f8b
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/definitions.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+ Authorization Intent
+
+
+
+
+
+
+
+
+ UsernameToken
+ bigbank.account.security.AccountsDataPasswordCallbackHandler
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/web/AccountJSON.html b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/web/AccountJSON.html
new file mode 100644
index 0000000000..1609bf4b43
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/web/AccountJSON.html
@@ -0,0 +1,92 @@
+
+
+
+Tuscany JSON-RPC BigBank Client
+
+
+
+
+
+
+
+
+
+
+
+
+
It then creates a Dojo button that will envoke the getAccountReport
+ method of the accountService object.
+
+
+
Request
+
Response
+
+
+
+
+
+
+
+
None Yet.
+
+
+
+
+
Dojo Debug:
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/web/style.css b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/web/style.css
new file mode 100644
index 0000000000..1071583264
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/web/style.css
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+* { font-family: arial; }
+
+table, th, td { border: 2px solid blue; border-collapse: collapse; }
+th { color: white; background-color: blue; }
diff --git a/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/wsdl/AccountService.wsdl b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/wsdl/AccountService.wsdl
new file mode 100644
index 0000000000..ac4d987a57
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-account/src/main/resources/wsdl/AccountService.wsdl
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank-calculator/README b/branches/sca-java-1.4/demos/bigbank-calculator/README
new file mode 100644
index 0000000000..e8ff28fc0f
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-calculator/README
@@ -0,0 +1,2 @@
+bigbank-calculator is part of a larger demo called bigbank.
+Please see the Readme file under bigbank to understand how bigbank-calculator fits into the overall demo.
diff --git a/branches/sca-java-1.4/demos/bigbank-calculator/build.xml b/branches/sca-java-1.4/demos/bigbank-calculator/build.xml
new file mode 100644
index 0000000000..1b91f6b842
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-calculator/build.xml
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank-calculator/pom.xml b/branches/sca-java-1.4/demos/bigbank-calculator/pom.xml
new file mode 100644
index 0000000000..134ccfacb2
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-calculator/pom.xml
@@ -0,0 +1,78 @@
+
+
+
+ 4.0.0
+
+ org.apache.tuscany.sca
+ tuscany-demos
+ 1.4-SNAPSHOT
+ ../pom.xml
+
+ demo-bigbank-calculator
+ Apache Tuscany SCA Demo BigBank Calculator
+
+
+
+ apache.incubator
+ http://people.apache.org/repo/m2-incubating-repository
+
+
+
+
+
+ org.apache.tuscany.sca
+ tuscany-host-embedded
+ 1.4-SNAPSHOT
+
+
+
+ org.apache.tuscany.sca
+ tuscany-implementation-java-runtime
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ org.apache.tuscany.sca
+ tuscany-implementation-script
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ org.apache.tuscany.sca
+ tuscany-binding-rmi-runtime
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ junit
+ junit
+ 4.5
+ test
+
+
+
+
+
+ ${artifactId}
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/AddService.java b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..4eeb30a9c2
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/AddService.java
@@ -0,0 +1,25 @@
+/*
+ * 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 calculator;
+
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/CalculatorService.java b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..c89043276e
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/CalculatorService.java
@@ -0,0 +1,34 @@
+/*
+ * 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 calculator;
+
+/**
+ * The Calculator service interface.
+ */
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/CalculatorServiceImpl.java b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..ed7bee0f4e
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/CalculatorServiceImpl.java
@@ -0,0 +1,72 @@
+/*
+ * 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 calculator;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * An implementation of the Calculator service.
+ */
+@Service(CalculatorService.class)
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ System.err.println("Multiply");
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/DivideService.java b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..131c5a8014
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/DivideService.java
@@ -0,0 +1,25 @@
+/*
+ * 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 calculator;
+
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/MultiplyService.java b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..a917896aeb
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/MultiplyService.java
@@ -0,0 +1,25 @@
+/*
+ * 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 calculator;
+
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/SubtractService.java b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..e328f024ea
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/SubtractService.java
@@ -0,0 +1,25 @@
+/*
+ * 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 calculator;
+
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/demo/CalculatorServer.java b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/demo/CalculatorServer.java
new file mode 100644
index 0000000000..b1861daafc
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/java/calculator/demo/CalculatorServer.java
@@ -0,0 +1,44 @@
+/*
+ * 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 calculator.demo;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CalculatorServer {
+
+ public static void main(String[] args) throws Exception {
+
+ System.out.println("Starting the Sample SCA Calculator...");
+
+ SCADomain domain = SCADomain.newInstance("Calculator.composite");
+
+ System.out.println("Press Enter to Exit...");
+ System.in.read();
+
+ domain.close();
+
+ System.out.println("Bye");
+ System.exit(0);
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-calculator/src/main/resources/Calculator.composite b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/resources/Calculator.composite
new file mode 100644
index 0000000000..851813d31f
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/resources/Calculator.composite
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank-calculator/src/main/resources/calculator/AddServiceImpl.js b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/resources/calculator/AddServiceImpl.js
new file mode 100644
index 0000000000..1d4d221364
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/resources/calculator/AddServiceImpl.js
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+function add(n1, n2) {
+ return n1 + n2;
+}
\ No newline at end of file
diff --git a/branches/sca-java-1.4/demos/bigbank-calculator/src/main/resources/calculator/DivideServiceImpl.groovy b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/resources/calculator/DivideServiceImpl.groovy
new file mode 100644
index 0000000000..c31c1e8fd6
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/resources/calculator/DivideServiceImpl.groovy
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+def divide(n1, n2) {
+ return n1 / n2
+}
\ No newline at end of file
diff --git a/branches/sca-java-1.4/demos/bigbank-calculator/src/main/resources/calculator/MultiplyServiceImpl.py b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/resources/calculator/MultiplyServiceImpl.py
new file mode 100644
index 0000000000..dd56af0ad8
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/resources/calculator/MultiplyServiceImpl.py
@@ -0,0 +1,21 @@
+# 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.
+#
+
+def multiply(n1, n2):
+ print "Python Calculator component: multiply(", n1, ",", n2, ")"
+ return n1 * n2
\ No newline at end of file
diff --git a/branches/sca-java-1.4/demos/bigbank-calculator/src/main/resources/calculator/SubtractServiceImpl.rb b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/resources/calculator/SubtractServiceImpl.rb
new file mode 100644
index 0000000000..08fa310f46
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-calculator/src/main/resources/calculator/SubtractServiceImpl.rb
@@ -0,0 +1,22 @@
+# 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.
+#
+
+def subtract(n1, n2)
+ print "Ruby Calculator subtract(", n1, ",", n2, ")\n"
+ return n1 - n2
+end
\ No newline at end of file
diff --git a/branches/sca-java-1.4/demos/bigbank-stockquote/README b/branches/sca-java-1.4/demos/bigbank-stockquote/README
new file mode 100644
index 0000000000..2ea98d020c
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-stockquote/README
@@ -0,0 +1,4 @@
+bigbank-stockquote is a part of a larger demo called bigbank.
+Please see the Readme file under bigbank to understand how bigbank-stockquote fits into the overall demo.
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank-stockquote/build.xml b/branches/sca-java-1.4/demos/bigbank-stockquote/build.xml
new file mode 100644
index 0000000000..798dcba605
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-stockquote/build.xml
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank-stockquote/pom.xml b/branches/sca-java-1.4/demos/bigbank-stockquote/pom.xml
new file mode 100644
index 0000000000..a92b1d42f7
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-stockquote/pom.xml
@@ -0,0 +1,85 @@
+
+
+
+ 4.0.0
+
+ org.apache.tuscany.sca
+ tuscany-demos
+ 1.4-SNAPSHOT
+ ../pom.xml
+
+ demo-bigbank-stockquote
+ Apache Tuscany SCA Demo BigBank StockQuote
+
+
+
+ apache.incubator
+ http://people.apache.org/repo/m2-incubating-repository
+
+
+
+
+
+ org.apache.tuscany.sca
+ tuscany-host-embedded
+ 1.4-SNAPSHOT
+
+
+
+ org.apache.ws.security
+ wss4j
+ 1.5.3
+
+
+
+ org.apache.tuscany.sca
+ tuscany-implementation-java-runtime
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ org.apache.tuscany.sca
+ tuscany-binding-ws-axis2
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ org.apache.tuscany.sca
+ tuscany-host-tomcat
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ junit
+ junit
+ 4.5
+ test
+
+
+
+
+
+ ${artifactId}
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/java/stockquote/PasswordCallbackHandler.java b/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/java/stockquote/PasswordCallbackHandler.java
new file mode 100644
index 0000000000..2d7821171d
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/java/stockquote/PasswordCallbackHandler.java
@@ -0,0 +1,47 @@
+/*
+ * 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 stockquote;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class
+ */
+public class PasswordCallbackHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ System.out.println("*** Calling Server User/Passwd Handler...." );
+ WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+ System.out.println("*** Getting password for user ...." + pwcb.getIdentifer() + " & " + pwcb.getKey());
+ if ( pwcb.getUsage() == WSPasswordCallback.SIGNATURE ) {
+ System.out.println(" Usage is SIGNATURE ... ");
+ pwcb.setPassword("sqservice");
+ }
+ }
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/java/stockquote/StockQuoteImpl.java b/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/java/stockquote/StockQuoteImpl.java
new file mode 100644
index 0000000000..2a0801f9b8
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/java/stockquote/StockQuoteImpl.java
@@ -0,0 +1,38 @@
+/*
+ * 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 stockquote;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the StockQuote service.
+ */
+@Service(StockQuoteService.class)
+public class StockQuoteImpl implements StockQuoteService {
+
+ public double getQuote(String symbol) {
+ double price = 104.0 + Math.random();
+ price = ((int)(price * 100)) / 100.0;
+
+ System.out.println("Getting stock quote for: " + symbol + ", value: "+ price);
+
+ return price;
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/java/stockquote/StockQuoteService.java b/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/java/stockquote/StockQuoteService.java
new file mode 100644
index 0000000000..9d128657eb
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/java/stockquote/StockQuoteService.java
@@ -0,0 +1,30 @@
+/*
+ * 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 stockquote;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * This is the business interface of the StockQuote service.
+ */
+@Remotable
+public interface StockQuoteService {
+
+ public double getQuote(String symbol);
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/java/stockquote/demo/StockQuoteServer.java b/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/java/stockquote/demo/StockQuoteServer.java
new file mode 100644
index 0000000000..04ed762602
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/java/stockquote/demo/StockQuoteServer.java
@@ -0,0 +1,42 @@
+/*
+ * 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 stockquote.demo;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+/**
+ * This server program shows how to bootstrap SCA from a simple J2SE program
+ * and start it which activates the StockQuote Web service endpoint.
+ */
+public class StockQuoteServer {
+
+ public static void main(String[] args) throws Exception {
+
+ System.out.println("Starting the Sample SCA StockQuote Service...");
+
+ SCADomain domain = SCADomain.newInstance("StockQuote.composite");
+
+ System.out.println("Press Enter to Exit...");
+ System.in.read();
+
+ domain.close();
+ System.out.println("Bye");
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/resources/StockQuote.composite b/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/resources/StockQuote.composite
new file mode 100644
index 0000000000..aaad92c861
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/resources/StockQuote.composite
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/resources/definitions.xml b/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/resources/definitions.xml
new file mode 100644
index 0000000000..7e1f51304e
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/resources/definitions.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+ Timestamp Signature
+ security.properties
+
+
+
+
+ Timestamp Signature
+ sqservice
+ security.properties
+ stockquote.PasswordCallbackHandler
+ DirectReference
+
+
+
+
+
\ No newline at end of file
diff --git a/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/resources/security.properties b/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/resources/security.properties
new file mode 100644
index 0000000000..a5b889c269
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/resources/security.properties
@@ -0,0 +1,20 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
+org.apache.ws.security.crypto.merlin.keystore.type=jks
+org.apache.ws.security.crypto.merlin.keystore.password=sqkeystore
+org.apache.ws.security.crypto.merlin.file=stockQuote.jks
diff --git a/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/resources/stockQuote.jks b/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/resources/stockQuote.jks
new file mode 100644
index 0000000000..d53d32c4ef
Binary files /dev/null and b/branches/sca-java-1.4/demos/bigbank-stockquote/src/main/resources/stockQuote.jks differ
diff --git a/branches/sca-java-1.4/demos/bigbank/README b/branches/sca-java-1.4/demos/bigbank/README
new file mode 100644
index 0000000000..5ec796db60
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/README
@@ -0,0 +1,127 @@
+BigBank Demo
+============
+
+This application is made of 3 modules that represent the different aspects
+of a fictitious banking application. Please see bigbank.png in the bigbank-account directory for a diagram of this demo.
+
+To run the bigbank-account demo you need to first run bigbank-calculator and bigbank-stockquote composites. This will bring up Tuscany runtime and load the two applications and make them available as services. Bigbank-account is dependent on these services.
+
+This demo uses ant. This is just one way of running this demo.
+
+Start Bigbank-calculator composite
+----------------------------------
+
+Bigbank-calculator is a calculator application which handles add, subtract, multiply and divide operations. Each of these operations is implemented in a different language, including JavaScript, groovy, Ruby and Python.
+
+To run the bigbank-calculator composite and make it available as a service for this demo do the following:
+
+cd bigbank-calculator
+ant compile
+ant run
+
+.. Leave the server running
+
+Note that 'ant compile' needs to be done the first time you run this demo out of the binary distribution. No need to do 'ant compile' from there on.
+
+Start Bigbank-stockquote
+------------------------
+
+A very simple web services based stock quote application which returns random
+stock quotes on request. Please note that the stockquote service is not live and is implemented instead to allow for this application to always run without dependency on the availability of a webservice.
+
+cd bigbank-stockquote
+ant compile
+ant run
+
+.. Leave the server running
+
+Note that 'ant compile' needs to be done the first time you run this demo out of the binary distribution. No need to do 'ant compile' from there on.
+
+Start Bigbank
+-------------
+The BigBank comprises of two subsystems that are built from two distinct contributions coming from ...
+1) bigbank
+ This contains all artifacts that make up the bigbank application. This is the application that the
+ end user interacts with
+
+2) bigbank-account
+ This contains all artifacts that deal with the account management within the bigbank. The services
+ offered by the bigbank-account module are used by the bigbank. The end user never gets to directly
+ interact with bigbank account
+
+Besides the bigbank-account the bigbank composite application calls into bigbank-stockquote and
+bigbank-calculator services.
+
+Start bigbank-account in the following way:
+
+i ) Compile the bigbank-account as follows :
+
+ cd bigbank-account
+ ant compile
+
+ii) Now start the bigbank service as follows :
+
+ cd bigbank
+ ant compile
+ ant run
+
+ .. Leave the server running
+
+Note that 'ant compile' needs to be done the first time you run this demo out ofthe binary distribution.
+No need to do 'ant compile' from there on.
+
+Bigbank and the SCA Policies
+----------------------------
+The Bigbank demo uses the Tuscany PolicyFramework to enforce security in the following ways:
+
+Authentication
+--------------
+ The bigbank-account subsystem enforces authentication as a required security characteristic for
+ all interactions with its CheckingAccountService. Hence the 'bigbank' application which is a client
+ to this service authenticates itself for every interaction with the CheckingAccountService. The interaction
+ between the bigbank and the CheckingAccountService is over the ws binding.
+
+Integrity
+---------
+ All interactions of the bigbank application with the StockQuoteService are guarded with message integrity.
+ These interactions use the ws binding.
+
+Authorization
+-------------
+ Within the bigbank-account subsystem the CheckingAccountService implementation enforces authorization on
+ its operations. This is an instance of a custom policy enforcement i.e. the CheckingAccountService
+ component's implementation has defined its own customized way of authorizing access to its services.
+
+Demonstrated features
+---------------------
+This demo is to illustrate the following : -
+- composition of an application using artifacts belonging to multiple contributions (here two)
+- usage of sca policies in composite definitions with specific emphasis on enabling security
+
+
+Run the demo
+-------------
+The front end of this demo application is a web app which users Json/RPC to communicate with the backend for retrieving account information.
+
+To try the app out point you browser at:
+
+http://localhost:8080/AccountJSON.html
+
+This should display an interface with a single button that goes and retrieves
+a single set of account details exercising services across the three running
+SCA applications.
+
+If you press on getAccountReport, you'll see a response posted,
+but the detail of the data will be displayed in the console where you started bigbank. Among other
+things you will note messages that confirm the enforecement of AUTHENTICATION, AUTHORIZATION and
+SIGNING of messages exchaged.
+
+On the console where you have started the StockQuote Service you should again be able to see messages
+that confirm the signing of messages exchanged.
+
+Stop the demo
+-------------
+Go to each of the corresponding command line screens and hit 'enter'.
+This will stop each of the applications.
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank/bigbank.png b/branches/sca-java-1.4/demos/bigbank/bigbank.png
new file mode 100644
index 0000000000..985cc6bd05
Binary files /dev/null and b/branches/sca-java-1.4/demos/bigbank/bigbank.png differ
diff --git a/branches/sca-java-1.4/demos/bigbank/bigbank.svg b/branches/sca-java-1.4/demos/bigbank/bigbank.svg
new file mode 100644
index 0000000000..30aa0eab6d
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/bigbank.svg
@@ -0,0 +1,537 @@
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank/build-dojo.xml b/branches/sca-java-1.4/demos/bigbank/build-dojo.xml
new file mode 100644
index 0000000000..9d282c2dd2
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/build-dojo.xml
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank/build.xml b/branches/sca-java-1.4/demos/bigbank/build.xml
new file mode 100644
index 0000000000..81fb704d4d
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/build.xml
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank/pom.xml b/branches/sca-java-1.4/demos/bigbank/pom.xml
new file mode 100644
index 0000000000..b6a448cff2
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/pom.xml
@@ -0,0 +1,201 @@
+
+
+
+ 4.0.0
+
+ org.apache.tuscany.sca
+ tuscany-demos
+ 1.4-SNAPSHOT
+ ../pom.xml
+
+ demo-bigbank
+ jar
+ Apache Tuscany SCA Demo BigBank
+
+
+
+ apache.incubator
+ http://people.apache.org/repo/m2-incubating-repository
+
+
+
+
+
+ org.apache.tuscany.sca
+ tuscany-host-embedded
+ 1.4-SNAPSHOT
+
+
+
+ org.apache.tuscany.sca
+ tuscany-data-api
+ 1.4-SNAPSHOT
+
+
+
+ org.apache.ws.security
+ wss4j
+ 1.5.3
+
+
+
+ org.apache.tuscany.sca
+ demo-bigbank-account
+ 1.4-SNAPSHOT
+
+
+
+ org.apache.tuscany.sca
+ tuscany-implementation-java-runtime
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ org.apache.tuscany.sca
+ tuscany-binding-atom-abdera
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ org.apache.tuscany.sca
+ tuscany-binding-rss-rome
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ org.apache.tuscany.sca
+ tuscany-binding-ws-axis2
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ org.apache.tuscany.sca
+ tuscany-binding-jsonrpc-runtime
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ org.apache.tuscany.sca
+ tuscany-binding-rmi-runtime
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ org.apache.tuscany.sca
+ tuscany-implementation-resource-runtime
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ org.apache.tuscany.sca
+ tuscany-binding-http-runtime
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ org.apache.tuscany.sca
+ tuscany-host-jetty
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ junit
+ junit
+ 4.5
+ test
+
+
+
+
+
+ demo-bigbank
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+
+
+
+ ant
+ ant-trax
+ 1.6.5
+
+
+
+
+
+ install-dojo
+ validate
+
+ run
+
+
+
+
+
+
+
+
+
+
+ copy-dojo-files
+ generate-resources
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+ clean-dojo-files
+ clean
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank/src/main/java/bigbank/account/AccountService.java b/branches/sca-java-1.4/demos/bigbank/src/main/java/bigbank/account/AccountService.java
new file mode 100644
index 0000000000..2cb8027874
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/src/main/java/bigbank/account/AccountService.java
@@ -0,0 +1,32 @@
+/*
+ * 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 bigbank.account;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+
+@Remotable
+public interface AccountService {
+
+ public double getAccountReport(String customerID);
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank/src/main/java/bigbank/account/AccountServiceImpl.java b/branches/sca-java-1.4/demos/bigbank/src/main/java/bigbank/account/AccountServiceImpl.java
new file mode 100644
index 0000000000..4f0e3879dc
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/src/main/java/bigbank/account/AccountServiceImpl.java
@@ -0,0 +1,99 @@
+/*
+ * 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 bigbank.account;
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+import stockquote.StockQuoteService;
+import bigbank.account.checking.CheckingAccountDetails;
+import bigbank.account.checking.CheckingAccountService;
+import bigbank.account.savings.SavingsAccountDetails;
+import bigbank.account.savings.SavingsAccountService;
+import bigbank.account.stock.StockAccountDetails;
+import bigbank.account.stock.StockAccountService;
+import calculator.CalculatorService;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+
+@Service(AccountService.class)
+public class AccountServiceImpl implements AccountService {
+
+ @Reference
+ protected SavingsAccountService savingsAcService;
+
+ @Reference
+ protected CheckingAccountService checkingAcService;
+
+ @Reference
+ protected StockAccountService stockAcService;
+
+ @Reference
+ protected StockQuoteService stockQuoteService;
+
+ @Reference
+ protected CalculatorService calculatorService;
+
+ @Property
+ protected String currency;
+
+ public double getAccountReport(String customerID) {
+
+ // Get the checking, savings and stock accounts from the AccountData
+ // service component
+ CheckingAccountDetails checking = null;
+ try {
+ checking = checkingAcService.getAccountDetails(customerID);
+ System.out.println("Checking account: " + checking);
+
+ SavingsAccountDetails savings = savingsAcService.getAccountDetails(customerID);
+ System.out.println("Savings account: " + savings);
+
+ StockAccountDetails stock = stockAcService.getAccountDetails(customerID);
+ System.out.println("Stock account: " + stock);
+
+ // Get the stock price in USD
+ double price = stockQuoteService.getQuote(stock.getSymbol());
+ System.out.println("Stock price for " + stock.getSymbol() + ": " + price);
+
+ // Convert to the configured currency
+ if (currency.equals("EURO")) {
+
+ // Use our fancy calculator service to convert to the target currency
+ price = calculatorService.multiply(price, 0.70);
+
+ System.out.println("Converted to " + currency + ": " + price);
+ }
+
+ // Calculate the value of the stock account
+ double stockValue = price * stock.getQuantity();
+
+ // Calculate the total balance of all accounts and return it
+ double balance = checking.getBalance() + savings.getBalance() + stockValue;
+
+ return balance;
+ } catch ( Throwable e ) {
+ e.printStackTrace();
+ return 0;
+ }
+ }
+}
diff --git a/branches/sca-java-1.4/demos/bigbank/src/main/java/bigbank/account/feed/AccountFeedImpl.java b/branches/sca-java-1.4/demos/bigbank/src/main/java/bigbank/account/feed/AccountFeedImpl.java
new file mode 100644
index 0000000000..13d79a9c33
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/src/main/java/bigbank/account/feed/AccountFeedImpl.java
@@ -0,0 +1,70 @@
+/*
+ * 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 bigbank.account.feed;
+
+import org.apache.tuscany.sca.data.collection.Collection;
+import org.apache.tuscany.sca.data.collection.Entry;
+import org.apache.tuscany.sca.data.collection.NotFoundException;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+import bigbank.account.AccountService;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+
+@Service(Collection.class)
+public class AccountFeedImpl implements Collection {
+
+ @Reference
+ protected AccountService accountService;
+
+ public Entry[] getAll() {
+
+ // Add the Account report entry
+ String report = get("1234");
+ Entry entry = new Entry("1234", report);
+
+ return new Entry[] { entry } ;
+ }
+
+ public String get(String id) {
+
+ // Get the account report for the specified customer ID
+ double balance = accountService.getAccountReport(id);
+ String report = Double.toString(balance);
+
+ return report;
+ }
+
+ public void delete(String key) throws NotFoundException {
+ }
+
+ public String post(String key, String item) {
+ return null;
+ }
+
+ public void put(String key, String item) throws NotFoundException {
+ }
+
+ public Entry[] query(String queryString) {
+ return null;
+ }
+}
diff --git a/branches/sca-java-1.4/demos/bigbank/src/main/java/bigbank/client/BigBankClient.java b/branches/sca-java-1.4/demos/bigbank/src/main/java/bigbank/client/BigBankClient.java
new file mode 100644
index 0000000000..a7fa5ecc22
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/src/main/java/bigbank/client/BigBankClient.java
@@ -0,0 +1,50 @@
+/*
+ * 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 bigbank.client;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+import bigbank.account.AccountService;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+public class BigBankClient {
+
+ public static void main(String[] args) throws Exception {
+
+ SCADomain domain = SCADomain.newInstance("BigBank.composite");
+
+ AccountService accountService = domain.getService(AccountService.class, "AccountServiceComponent");
+
+ String customerID = "1234";
+
+ System.out.println("Calling account service for customer: " + customerID);
+ System.out.println();
+ double balance = accountService.getAccountReport(customerID);
+
+ System.out.println();
+ System.out.println("Balance: " + balance);
+
+ domain.close();
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank/src/main/java/bigbank/demo/BigBankServer.java b/branches/sca-java-1.4/demos/bigbank/src/main/java/bigbank/demo/BigBankServer.java
new file mode 100644
index 0000000000..05360e07a5
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/src/main/java/bigbank/demo/BigBankServer.java
@@ -0,0 +1,130 @@
+/*
+ * 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 bigbank.demo;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.service.ContributionService;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain;
+
+import bigbank.account.savings.SavingsAccountService;
+
+
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+public class BigBankServer {
+
+ public static void main(String[] args) throws Exception {
+ long timeout = -1L;
+ if (args.length > 0) {
+ timeout = Long.parseLong(args[0]);
+ }
+
+ System.out.println("Starting the Sample SCA BigBank server...");
+ ClassLoader cl = BigBankServer.class.getClassLoader();
+ EmbeddedSCADomain domain = new EmbeddedSCADomain(cl, "http://localhost");
+
+ //Start the domain
+ domain.start();
+
+ // Contribute the SCA contribution
+ ContributionService contributionService = domain.getContributionService();
+
+ URL javaContribURL = getContributionURL(SavingsAccountService.class);
+ Contribution bigbankAcContribution = contributionService.contribute("http://bigbank-account", javaContribURL, false);
+ for (Composite deployable : bigbankAcContribution.getDeployables()) {
+ domain.getDomainComposite().getIncludes().add(deployable);
+ domain.buildComposite(deployable);
+ }
+
+ URL bigbankContribUrl = getContributionURL(BigBankServer.class);
+ Contribution bigbankContribution = contributionService.contribute("http://bigbank", bigbankContribUrl, false);
+ for (Composite deployable : bigbankContribution.getDeployables()) {
+ domain.getDomainComposite().getIncludes().add(deployable);
+ domain.buildComposite(deployable);
+ }
+
+
+ //Start Components from composite
+ for (Composite deployable : bigbankAcContribution.getDeployables()) {
+ domain.getCompositeActivator().activate(deployable);
+ domain.getCompositeActivator().start(deployable);
+ }
+
+ for (Composite deployable : bigbankContribution.getDeployables()) {
+ domain.getCompositeActivator().activate(deployable);
+ domain.getCompositeActivator().start(deployable);
+ }
+
+ if (timeout < 0) {
+ System.out.println("Press Enter to Exit...");
+ System.in.read();
+ } else {
+ Thread.sleep(timeout);
+ }
+
+ contributionService.remove("http://bigbank-account");
+ contributionService.remove("http://bigbank");
+
+ // Stop Components from composite
+ for (Composite deployable : bigbankContribution.getDeployables()) {
+ domain.getCompositeActivator().stop(deployable);
+ domain.getCompositeActivator().deactivate(deployable);
+ }
+
+ domain.stop();
+
+ domain.close();
+
+
+ /*SCADomain domain = SCADomain.newInstance("BigBank.composite");
+
+ if (timeout < 0) {
+ System.out.println("Press Enter to Exit...");
+ System.in.read();
+ } else {
+ Thread.sleep(timeout);
+ }
+
+ domain.close();*/
+
+ System.out.println("Bye");
+ }
+
+ private static URL getContributionURL(Class> cls) throws MalformedURLException {
+ String flag = "/" + cls.getName().replace('.', '/') + ".class";
+ URL url = cls.getResource(flag);
+ String root = url.toExternalForm();
+ root = root.substring(0, root.length() - flag.length() + 1);
+ if (root.startsWith("jar:") && root.endsWith("!/")) {
+ root = root.substring(4, root.length() - 2);
+ }
+ url = new URL(root);
+ return url;
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java b/branches/sca-java-1.4/demos/bigbank/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java
new file mode 100644
index 0000000000..6d3b547939
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java
@@ -0,0 +1,51 @@
+/*
+ * 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 bigbank.security;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class
+ */
+public class BigbankPasswordCallbackHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+ //System.out.println("*** Getting password for user ...." + pwcb.getIdentifer() + " & " + pwcb.getKey());
+ if ( pwcb.getUsage() == WSPasswordCallback.SIGNATURE ) {
+ System.out.println("*** Calling BIG-BANK Passwd Handler for SIGNING...." );
+ pwcb.setPassword("bbservice");
+ } else if ( pwcb.getUsage() == WSPasswordCallback.USERNAME_TOKEN ) {
+ if ( pwcb.getIdentifer().equals("bbaservice")) {
+ System.out.println("*** Calling BIG-BANK Passwd Handler for setting AUTHENTICATION password...." );
+ pwcb.setPassword("bbaservice");
+ }
+ }
+ }
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank/src/main/java/calculator/CalculatorService.java b/branches/sca-java-1.4/demos/bigbank/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..c89043276e
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/src/main/java/calculator/CalculatorService.java
@@ -0,0 +1,34 @@
+/*
+ * 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 calculator;
+
+/**
+ * The Calculator service interface.
+ */
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/branches/sca-java-1.4/demos/bigbank/src/main/java/stockquote/StockQuoteService.java b/branches/sca-java-1.4/demos/bigbank/src/main/java/stockquote/StockQuoteService.java
new file mode 100644
index 0000000000..749b8ee2f4
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/src/main/java/stockquote/StockQuoteService.java
@@ -0,0 +1,29 @@
+/*
+ * 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 stockquote;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * This is the business interface of the StockQuote service.
+ */
+@Remotable
+public interface StockQuoteService {
+ public double getQuote(String symbol);
+}
diff --git a/branches/sca-java-1.4/demos/bigbank/src/main/resources/BigBank.composite b/branches/sca-java-1.4/demos/bigbank/src/main/resources/BigBank.composite
new file mode 100644
index 0000000000..11591308b4
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/src/main/resources/BigBank.composite
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ EURO
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-1.4/demos/bigbank/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..154992c843
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/branches/sca-java-1.4/demos/bigbank/src/main/resources/bigbank.jks b/branches/sca-java-1.4/demos/bigbank/src/main/resources/bigbank.jks
new file mode 100644
index 0000000000..e6294d85f7
Binary files /dev/null and b/branches/sca-java-1.4/demos/bigbank/src/main/resources/bigbank.jks differ
diff --git a/branches/sca-java-1.4/demos/bigbank/src/main/resources/definitions.xml b/branches/sca-java-1.4/demos/bigbank/src/main/resources/definitions.xml
new file mode 100644
index 0000000000..8654151d82
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/src/main/resources/definitions.xml
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+ Timestamp Signature
+ security.properties
+
+
+
+
+ Timestamp Signature
+ bbservice
+ security.properties
+ bigbank.security.BigbankPasswordCallbackHandler
+ DirectReference
+
+
+
+
+
+
+
+
+
+ UsernameToken
+ bbaservice
+ bigbank.security.BigbankPasswordCallbackHandler
+ PasswordText
+
+
+
+
+
\ No newline at end of file
diff --git a/branches/sca-java-1.4/demos/bigbank/src/main/resources/security.properties b/branches/sca-java-1.4/demos/bigbank/src/main/resources/security.properties
new file mode 100644
index 0000000000..d1b489acbb
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/src/main/resources/security.properties
@@ -0,0 +1,20 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
+org.apache.ws.security.crypto.merlin.keystore.type=jks
+org.apache.ws.security.crypto.merlin.keystore.password=bbakeystore
+org.apache.ws.security.crypto.merlin.file=bigbank.jks
diff --git a/branches/sca-java-1.4/demos/bigbank/src/main/resources/web/AccountJSON.html b/branches/sca-java-1.4/demos/bigbank/src/main/resources/web/AccountJSON.html
new file mode 100644
index 0000000000..9f4368443f
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/src/main/resources/web/AccountJSON.html
@@ -0,0 +1,92 @@
+
+
+
+Tuscany JSON-RPC BigBank Client
+
+
+
+
+
+
+
+
+
+
+
+
+
It then creates a Dojo button that will envoke the getAccountReport
+ method of the accountService object.
+
+
+
Request
+
Response
+
+
+
+
+
+
+
+
None Yet.
+
+
+
+
+
Dojo Debug:
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank/src/main/resources/web/style.css b/branches/sca-java-1.4/demos/bigbank/src/main/resources/web/style.css
new file mode 100644
index 0000000000..1071583264
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/src/main/resources/web/style.css
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+* { font-family: arial; }
+
+table, th, td { border: 2px solid blue; border-collapse: collapse; }
+th { color: white; background-color: blue; }
diff --git a/branches/sca-java-1.4/demos/bigbank/src/main/resources/wsdl/AccountService.wsdl b/branches/sca-java-1.4/demos/bigbank/src/main/resources/wsdl/AccountService.wsdl
new file mode 100644
index 0000000000..ac4d987a57
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/src/main/resources/wsdl/AccountService.wsdl
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/bigbank/src/test/java/test/BigBankTestCase.java b/branches/sca-java-1.4/demos/bigbank/src/test/java/test/BigBankTestCase.java
new file mode 100644
index 0000000000..3b7c5ef2ad
--- /dev/null
+++ b/branches/sca-java-1.4/demos/bigbank/src/test/java/test/BigBankTestCase.java
@@ -0,0 +1,33 @@
+/*
+ * 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 test;
+
+import junit.framework.TestCase;
+
+import bigbank.demo.BigBankServer;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BigBankTestCase extends TestCase {
+
+ public void testServer() throws Exception {
+ BigBankServer.main(new String[] {"1000"});
+ }
+}
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/LICENSE b/branches/sca-java-1.4/demos/load-balancing-webapp/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/LICENSE
@@ -0,0 +1,205 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
+
+
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/NOTICE b/branches/sca-java-1.4/demos/load-balancing-webapp/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/README b/branches/sca-java-1.4/demos/load-balancing-webapp/README
new file mode 100644
index 0000000000..b7bbb64b1a
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/README
@@ -0,0 +1,76 @@
+WebApp Load Balancing Demo
+===========================
+
+Demonstrates balancing load acoss SCA services by deploying an SCA composite
+to two tomcat servers in a cluster. The tomcat servers sit behind an Apache
+server which directs load to one or other tomcat server based on a set of rules.
+
+The mvn pom distributed with this sample will download, install and configure
+two Tomcat servers automatically to act as workers. You need to install the
+Apache web server and configure it manually.
+
+1 - Install and configure the Tomcat workers
+
+mvn
+
+This results in two tomcat servers at
+
+target/tomcat-8085
+target/tomcat-8086
+
+2 - Install and configure the Apache server to balance load
+
+In this case we've chosen to use the native JK connector. There are several
+resources that tell you how to configure Apache for load balancing Tomcat with
+the JK connector. For example,
+
+http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html
+http://www.crazysquirrel.com/computing/debian/servers/tomcat55.jspx
+
+Here is a high level summary
+
+Download the latest version of Apache 2.2 (this demo was built with Apache 2.2.6)
+ http://httpd.apache.org/
+ Install in a local director called, say, apache
+
+Download the mod_jk module (in binary form if you can)
+ http://tomcat.apache.org/download-connectors.cgi
+ Install it in apache/modules
+
+Configure the mod_jk module
+ Copy src/test/resources/apache-80/conf/workers.properties to apache/conf
+ Append the contents of src/test/resources/apache-80/conf/httpd.conf to apache/conf/httpf.conf
+
+3 - Start the apache and tomcat servers
+
+In three command prompts
+
+cd target/tomcat-8085
+bin/catalina run
+
+cd target/tomcat-8086
+bin/catalina run
+
+cd apache
+bin/httpd
+
+4 - Run the client
+
+run the LanchClient program - TBD - need a script
+
+5 - Result
+
+The client will make 10 calls to the SCA service described in the helloworldws.composite that
+is part of the webapp deployed to the tomcat servers. You will see the result of this
+service call reported at the client in the form
+
+Called getGreetings
+Hello World 6
+
+If you look at the Tomcat consoles you will see that each server deals with half the requests
+as the load is balanced equally between the two of them.
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/build-tomcat.xml b/branches/sca-java-1.4/demos/load-balancing-webapp/build-tomcat.xml
new file mode 100644
index 0000000000..7e1dc4b0e9
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/build-tomcat.xml
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/build.xml b/branches/sca-java-1.4/demos/load-balancing-webapp/build.xml
new file mode 100644
index 0000000000..b84f85616e
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/build.xml
@@ -0,0 +1,125 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/pom.xml b/branches/sca-java-1.4/demos/load-balancing-webapp/pom.xml
new file mode 100644
index 0000000000..daaed32001
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/pom.xml
@@ -0,0 +1,349 @@
+
+
+
+ 4.0.0
+
+ org.apache.tuscany.sca
+ tuscany-demos
+ 1.4-SNAPSHOT
+ ../pom.xml
+
+ demo-load-balancing-webapp
+ war
+ Apache Tuscany SCA WebApp Load Balancing Demo
+ A sample SCA application that is deployed as a webapp to a cluster of tomcat servers
+
+
+
+ org.apache.tuscany.sca
+ tuscany-host-webapp
+ 1.4-SNAPSHOT
+
+
+
+ org.apache.tuscany.sca
+ tuscany-implementation-java-runtime
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ org.apache.tuscany.sca
+ tuscany-binding-ws-axis2
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ org.apache.tuscany.sca
+ tuscany-monitor
+ 1.4-SNAPSHOT
+
+
+
+ org.apache.tuscany.sca
+ tuscany-node2-impl
+ 1.4-SNAPSHOT
+
+
+
+ tomcat
+ catalina-balancer
+ 5.5.12
+
+
+
+ javax.servlet
+ servlet-api
+ 2.4
+ provided
+
+
+
+ junit
+ junit
+ 4.2
+ test
+
+
+
+
+
+ 8085
+ http://127.0.0.1:${http.port}
+ ${env.CATALINA_HOME}
+
+
+
+ ${artifactId}
+
+
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+ 1.1
+
+
+
+ ant
+ ant-trax
+ 1.6.5
+
+
+
+
+
+ download-tomcat
+ validate
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+ unpack-tomcat-8086
+ generate-resources
+
+ run
+
+
+
+
+
+
+
+
+
+
+ unpack-tomcat-8087
+ generate-resources
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+ configure-tomcat-8086
+ pre-integration-test
+
+ run
+
+
+
+
+
+
+
+
+
+
+ configure-tomcat-8087
+ pre-integration-test
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+ copy-webapp-8086
+ pre-integration-test
+
+ run
+
+
+
+
+
+
+
+
+
+
+ copy-webapp-8087
+ pre-integration-test
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/java/client/LaunchClient.java b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/java/client/LaunchClient.java
new file mode 100644
index 0000000000..efa89b4fe9
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/java/client/LaunchClient.java
@@ -0,0 +1,57 @@
+/*
+ * 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 client;
+
+import java.io.File;
+
+import helloworld.HelloWorldService;
+
+import org.apache.tuscany.sca.node.SCAClient;
+import org.apache.tuscany.sca.node.SCANode2;
+import org.apache.tuscany.sca.node.SCANode2Factory;
+import org.apache.tuscany.sca.node.SCANode2Factory.SCAContribution;
+import org.osoa.sca.ServiceRuntimeException;
+
+public class LaunchClient {
+ public static void main(String[] args) throws Exception {
+
+ SCANode2 node = null;
+ try {
+
+ SCANode2Factory nodeFactory = SCANode2Factory.newInstance();
+ node = nodeFactory.createSCANode(new File("src/main/resources/client-contribution/helloworldwsclient.composite").toURL().toString(),
+ new SCAContribution("TestContribution",
+ new File("src/main/resources/client-contribution").toURL().toString()));
+
+ node.start();
+ HelloWorldService helloWorldService = ((SCAClient)node).getService(HelloWorldService.class, "HelloWorldClientComponent");
+
+
+ for (int i=0; i < 10; i++){
+ System.out.println(helloWorldService.getGreetings("World " + i));
+ }
+
+ node.stop();
+
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+}
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/java/domain/LaunchDomain.java b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/java/domain/LaunchDomain.java
new file mode 100644
index 0000000000..33c37869a3
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/java/domain/LaunchDomain.java
@@ -0,0 +1,33 @@
+/*
+ * 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 domain;
+
+//import org.apache.tuscany.sca.node.launcher.DomainManagerLauncher;
+
+/**
+ * This server program that loads a composite to provide simple registry function.
+ * This server can be replaced with any registry that is appropriate but the components
+ * in each node that talk to the registry should be replaced also.
+ */
+public class LaunchDomain {
+ public static void main(String[] args) throws Exception {
+ // DomainManagerLauncher.main(args);
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/java/helloworld/HelloWorldImpl.java b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..65dc030d89
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/java/helloworld/HelloWorldImpl.java
@@ -0,0 +1,35 @@
+/*
+ * 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 helloworld;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldImpl implements HelloWorldService {
+
+ public String getGreetings(String name) {
+ String message = "Hello " + name;
+ System.err.println(message);
+ return message;
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/java/helloworld/HelloWorldService.java b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..7245513b2a
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/java/helloworld/HelloWorldService.java
@@ -0,0 +1,31 @@
+/*
+ * 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 helloworld;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public String getGreetings(String name);
+}
+
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/java/helloworld/HelloWorldServiceClient.java b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/java/helloworld/HelloWorldServiceClient.java
new file mode 100644
index 0000000000..f3d2fdb2ed
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/java/helloworld/HelloWorldServiceClient.java
@@ -0,0 +1,42 @@
+/*
+ * 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 helloworld;
+
+/**
+ * The HelloWorld service implementation
+ */
+public class HelloWorldServiceClient implements HelloWorldService {
+
+ HelloWorldService helloWorldService;
+
+ public String getGreetings(String name) {
+ System.out.println("Called getGreetings");
+ return helloWorldService.getGreetings(name);
+ }
+
+ public HelloWorldService getHelloWorldService() {
+ System.out.println("Got Injected helloWorldService");
+ return helloWorldService;
+ }
+
+ public void setHelloWorldService(HelloWorldService helloWorldService) {
+ System.out.println("Injected helloWorldService");
+ this.helloWorldService = helloWorldService;
+ }
+}
\ No newline at end of file
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/java/org/apache/tuscany/sca/demos/loadbalancer/rule/RoundRobinRule.java b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/java/org/apache/tuscany/sca/demos/loadbalancer/rule/RoundRobinRule.java
new file mode 100644
index 0000000000..5dc1b6671b
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/java/org/apache/tuscany/sca/demos/loadbalancer/rule/RoundRobinRule.java
@@ -0,0 +1,96 @@
+/*
+ * 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 org.apache.tuscany.sca.demos.loadbalancer.rule;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.webapp.balancer.rules.BaseRule;
+
+
+public class RoundRobinRule extends BaseRule {
+ /**
+ * The number of worker nodes that load will
+ * be balanced across
+ */
+ private int workerCount;
+
+ private int currentCount = 1;
+
+
+ /**
+ * Sets the worker count.
+ *
+ * @param workerCount The worker count
+ */
+ public void setWorkerCount(int workerCount) {
+ if (workerCount == 0) {
+ throw new IllegalArgumentException(
+ "worker count cannot be 0.");
+ } else {
+ this.workerCount = workerCount;
+ }
+ }
+
+ /**
+ * Returns the worker count.
+ *
+ * @return int The worker count
+ */
+ protected int getWorkerCount() {
+ return workerCount;
+ }
+
+
+
+ /**
+ * @see org.apache.webapp.balancer.Rule#matches(HttpServletRequest)
+ */
+ public boolean matches(HttpServletRequest request) {
+
+ if (currentCount == workerCount){
+ currentCount = 1;
+ return true;
+ } else {
+ currentCount++;
+ return false;
+ }
+ }
+
+ /**
+ * Returns a String representation of this object.
+ *
+ * @return String
+ */
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append("[");
+ buffer.append(getClass().getName());
+ buffer.append(": ");
+
+ buffer.append("Worker count: ");
+ buffer.append(getWorkerCount());
+ buffer.append(" / ");
+
+ buffer.append("Redirect URL: ");
+ buffer.append(getRedirectUrl());
+
+ buffer.append("]");
+
+ return buffer.toString();
+ }
+}
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/resources/client-contribution/helloworldwsclient.composite b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/resources/client-contribution/helloworldwsclient.composite
new file mode 100644
index 0000000000..9b6052741e
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/resources/client-contribution/helloworldwsclient.composite
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/webapp/META-INF/sca-contribution.xml b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/webapp/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..11347004f9
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/webapp/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/webapp/META-INF/sca-deployables/helloworldws.composite b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/webapp/META-INF/sca-deployables/helloworldws.composite
new file mode 100644
index 0000000000..1ab78d802d
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/webapp/META-INF/sca-deployables/helloworldws.composite
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/webapp/WEB-INF/web.xml b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..8d47ae2207
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+ Apache Tuscany Load Balancing Demo
+
+
+ tuscany
+ org.apache.tuscany.sca.host.webapp.TuscanyServletFilter
+
+
+
+ tuscany
+ /*
+
+
+
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/src/test/resources/apache-80/conf/httpd.conf b/branches/sca-java-1.4/demos/load-balancing-webapp/src/test/resources/apache-80/conf/httpd.conf
new file mode 100644
index 0000000000..37cf284d35
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/src/test/resources/apache-80/conf/httpd.conf
@@ -0,0 +1,28 @@
+# Load mod_jk module
+# Update this path to match your modules location
+LoadModule jk_module modules/mod_jk.so
+
+# Declare the module for (remove this line on Apache 2.x)
+# AddModule mod_jk.c
+# Where to find workers.properties
+# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
+JkWorkersFile conf/workers.properties
+
+# Where to put jk shared memory
+# Update this path to match your local state directory or logs directory
+JkShmFile logs/mod_jk.shm
+
+# Where to put jk logs
+# Update this path to match your logs directory location (put mod_jk.log next to access_log)
+JkLogFile logs/mod_jk.log
+
+# Set the jk log level [debug/error/info]
+JkLogLevel info
+
+# Select the timestamp log format
+JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
+
+# Send everything for context /examples to worker named worker1 (ajp13)
+# JkMount /examples/* worker1
+# Send everything for context /* to the router
+JkMount /* router
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/src/test/resources/apache-80/conf/workers.properties b/branches/sca-java-1.4/demos/load-balancing-webapp/src/test/resources/apache-80/conf/workers.properties
new file mode 100644
index 0000000000..9228c4fd8e
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/src/test/resources/apache-80/conf/workers.properties
@@ -0,0 +1,18 @@
+ # Load balancer looks after the workers
+ worker.list=router
+
+ # The load balacer
+ worker.router.type=lb
+ worker.router.balance_workers=worker1,worker2
+
+ # Set properties for worker1 (ajp13)
+ worker.worker1.type=ajp13
+ worker.worker1.host=localhost
+ worker.worker1.port=8010
+ worker.worker1.lbfactor=1
+
+ # Set properties for worker1 (ajp13)
+ worker.worker2.type=ajp13
+ worker.worker2.host=localhost
+ worker.worker2.port=8011
+ worker.worker2.lbfactor=1
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/src/test/resources/tomcat-8085/conf/server.xml b/branches/sca-java-1.4/demos/load-balancing-webapp/src/test/resources/tomcat-8085/conf/server.xml
new file mode 100644
index 0000000000..920fa7b037
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/src/test/resources/tomcat-8085/conf/server.xml
@@ -0,0 +1,391 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/src/test/resources/tomcat-8085/webapps/balancer/WEB-INF/config/rules.xml b/branches/sca-java-1.4/demos/load-balancing-webapp/src/test/resources/tomcat-8085/webapps/balancer/WEB-INF/config/rules.xml
new file mode 100644
index 0000000000..7486dc8148
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/src/test/resources/tomcat-8085/webapps/balancer/WEB-INF/config/rules.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/src/test/resources/tomcat-8086/conf/server.xml b/branches/sca-java-1.4/demos/load-balancing-webapp/src/test/resources/tomcat-8086/conf/server.xml
new file mode 100644
index 0000000000..5ecb8fe5c4
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/src/test/resources/tomcat-8086/conf/server.xml
@@ -0,0 +1,391 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/load-balancing-webapp/src/test/resources/tomcat-8087/conf/server.xml b/branches/sca-java-1.4/demos/load-balancing-webapp/src/test/resources/tomcat-8087/conf/server.xml
new file mode 100644
index 0000000000..f83c68191c
--- /dev/null
+++ b/branches/sca-java-1.4/demos/load-balancing-webapp/src/test/resources/tomcat-8087/conf/server.xml
@@ -0,0 +1,391 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/mortgage-creditcheck/README b/branches/sca-java-1.4/demos/mortgage-creditcheck/README
new file mode 100644
index 0000000000..b785802920
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-creditcheck/README
@@ -0,0 +1,6 @@
+Mortgage Loan Approval Demo
+===========================
+Please refer to the README under mortgage-loanapproval for information on how to run this demo.
+
+Mortgage-creditcheck is part of a larger demo that is explained there.
+
diff --git a/branches/sca-java-1.4/demos/mortgage-creditcheck/build.xml b/branches/sca-java-1.4/demos/mortgage-creditcheck/build.xml
new file mode 100644
index 0000000000..59f1342276
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-creditcheck/build.xml
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/mortgage-creditcheck/pom.xml b/branches/sca-java-1.4/demos/mortgage-creditcheck/pom.xml
new file mode 100644
index 0000000000..3a42b620ec
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-creditcheck/pom.xml
@@ -0,0 +1,75 @@
+
+
+
+ 4.0.0
+
+ org.apache.tuscany.sca
+ tuscany-demos
+ 1.4-SNAPSHOT
+ ../pom.xml
+
+ demo-mortgage-creditcheck
+ jar
+ Apache Tuscany SCA Demo Mortgage Credit Check
+ A sample Mortgage application made of several SCA components wired together.
+
+
+
+ org.apache.tuscany.sca
+ tuscany-host-embedded
+ 1.4-SNAPSHOT
+
+
+
+ org.apache.tuscany.sca
+ tuscany-implementation-java-runtime
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ org.apache.tuscany.sca
+ tuscany-binding-ws-axis2
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ org.apache.tuscany.sca
+ tuscany-host-jetty
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ junit
+ junit
+ 4.5
+ test
+
+
+
+
+
+ ${artifactId}
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheck.java b/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheck.java
new file mode 100644
index 0000000000..ec95a60227
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheck.java
@@ -0,0 +1,26 @@
+/*
+ * 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 credit;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface CreditCheck {
+ int getCreditScore(String ssn);
+}
diff --git a/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheckImpl.java b/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheckImpl.java
new file mode 100644
index 0000000000..f19e8a1250
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheckImpl.java
@@ -0,0 +1,34 @@
+/*
+ * 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 credit;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * An implementation of the CreditReportService service
+ */
+@Service(CreditCheck.class)
+public class CreditCheckImpl implements CreditCheck {
+
+ public int getCreditScore(String ssn) {
+ int score = (int)(700 + (Math.random() - 0.5) * 100);
+ System.out.println("Credit score for " + ssn + ": " + score);
+ return score;
+ }
+}
diff --git a/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheckServer.java b/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheckServer.java
new file mode 100644
index 0000000000..870ea1941d
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheckServer.java
@@ -0,0 +1,40 @@
+/*
+ * 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 credit;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CreditCheckServer {
+ public static void main(String[] args) throws Exception {
+
+ System.out.println("Starting the CreditCheck Service...");
+
+ SCADomain domain = SCADomain.newInstance("http://localhost", "/", "CreditCheck.composite");
+
+ System.out.println("Press Enter to Exit...");
+ System.in.read();
+
+ domain.close();
+ System.out.println("Bye");
+ }
+}
diff --git a/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/resources/CreditCheck.composite b/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/resources/CreditCheck.composite
new file mode 100644
index 0000000000..5c828f5a39
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/resources/CreditCheck.composite
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/resources/wsdl/credit.wsdl b/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/resources/wsdl/credit.wsdl
new file mode 100644
index 0000000000..9c2acc96d3
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/resources/wsdl/credit.wsdl
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/webapp/META-INF/sca-contribution.xml b/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/webapp/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..aea009292a
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/webapp/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/webapp/WEB-INF/web.xml b/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..d7b2e32dd1
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-creditcheck/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+ Apache Tuscany Credit Check Demo
+
+
+ tuscany
+ org.apache.tuscany.sca.host.webapp.TuscanyServletFilter
+
+
+
+ tuscany
+ /*
+
+
+
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/README b/branches/sca-java-1.4/demos/mortgage-loanapproval/README
new file mode 100644
index 0000000000..dbf3829a20
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/README
@@ -0,0 +1,60 @@
+Mortgage Loan Approval Demo
+===========================
+
+This demo was used as an example in the java developer journal article: http://jdj.sys-con.com/read/325183.htm.
+
+The demo consists of two modules:
+
+mortgage-loanapproval: provides the business logic for loan approval.
+mortgage-creditcheck: handles credit check requests. This is a java component exposed as a webservice running on the embedded Tomcat.
+
+Please check mortgage_assembly.png file that is located in this directory for a high level view of the demo.
+
+Here is what happens when you run the demo. A loan approval request for customer with id 111-222-3333
+gets initiated when mortgage-loanapproval application is run. Depending on what the 'imaginary' credit
+ status of this person is, the loan gets approved or diapproved.
+
+You would need two command windows to run mortgage loan approval composite. The order in which the
+applications are run is important. Run mortgage-creditcheck first since mortgage-loanapproval is dependent on
+it's service.
+
+In the first command window
+---------------------------
+1) go to mortgage-creditcheck directory
+2) ant compile
+3) ant run
+You should see the following displayed:
+Buildfile: build.xml
+
+run:
+ [java] Starting the CreditCheck Service...
+ [java] 14-Jan-2008 14:14:20 org.apache.tuscany.sca.http.jetty.JettyServer a
+ddServletMapping
+ [java] INFO: Added Servlet mapping: http://L3AW203:8085/CreditCheckServiceC
+omponent
+ [java] Press Enter to Exit...
+
+In the second command window
+----------------------------
+1) go to mortgage-loanapproval directory
+2) ant compile
+3) ant run
+
+If the loan is approved, you will see the following displayed in the command screen where
+mortgage-loanapproval is run:
+
+Buildfile: build.xml
+run:
+ [java] Interest rate for a 30-year loan of $200000.0 in CA: 6.5%
+ [java] Approved: John Smith[111-22-3333]
+
+If the loan is disapproved, you will see the following displayed in the command screen where
+mortgage-loanapproval is run:
+
+Buildfile: build.xml
+run:
+ [java] Credit score for 111-22-3333: 708
+ [java] Interest rate for a 30-year loan of $200000.0 in CA: 6.5%
+ [java] Debt/Income ratio 0.2528272093971861 is too high.
+ [java] Rejected: John Smith[111-22-3333]
+
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/build.xml b/branches/sca-java-1.4/demos/mortgage-loanapproval/build.xml
new file mode 100644
index 0000000000..9a0a83bf1d
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/build.xml
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/credit_composite.jpg b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/credit_composite.jpg
new file mode 100644
index 0000000000..e28ed63cfb
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/credit_composite.jpg differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/credit_composite.png b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/credit_composite.png
new file mode 100644
index 0000000000..0bfce0078d
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/credit_composite.png differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/loan_approval.jpg b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/loan_approval.jpg
new file mode 100644
index 0000000000..3f00557c7f
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/loan_approval.jpg differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/loan_approval.png b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/loan_approval.png
new file mode 100644
index 0000000000..9d5f829fe5
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/loan_approval.png differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_assembly0.jpg b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_assembly0.jpg
new file mode 100644
index 0000000000..515b6ecde7
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_assembly0.jpg differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_assembly0.png b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_assembly0.png
new file mode 100644
index 0000000000..4b815a4b82
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_assembly0.png differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_assembly1.jpg b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_assembly1.jpg
new file mode 100644
index 0000000000..01a7c55a14
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_assembly1.jpg differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_assembly1.png b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_assembly1.png
new file mode 100644
index 0000000000..07422c4f45
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_assembly1.png differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_assembly2.jpg b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_assembly2.jpg
new file mode 100644
index 0000000000..992c048684
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_assembly2.jpg differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_assembly2.png b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_assembly2.png
new file mode 100644
index 0000000000..4667956ed0
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_assembly2.png differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_composite.jpg b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_composite.jpg
new file mode 100644
index 0000000000..5021f6a317
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_composite.jpg differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_composite.png b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_composite.png
new file mode 100644
index 0000000000..1398c50ded
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_composite.png differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_diagrams.doc b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_diagrams.doc
new file mode 100644
index 0000000000..32a0b72907
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_diagrams.doc differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_package1.jpg b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_package1.jpg
new file mode 100644
index 0000000000..e91c5f1bbd
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_package1.jpg differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_package1.png b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_package1.png
new file mode 100644
index 0000000000..db304a4c28
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_package1.png differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_package2.jpg b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_package2.jpg
new file mode 100644
index 0000000000..e8c2865e4a
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_package2.jpg differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_package2.png b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_package2.png
new file mode 100644
index 0000000000..502e538e94
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_package2.png differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_scenario.jpg b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_scenario.jpg
new file mode 100644
index 0000000000..fccf2e35c3
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_scenario.jpg differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_scenario.png b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_scenario.png
new file mode 100644
index 0000000000..b8f42ad318
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/doc/mortgage_scenario.png differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/mortgage_assembly.png b/branches/sca-java-1.4/demos/mortgage-loanapproval/mortgage_assembly.png
new file mode 100644
index 0000000000..4667956ed0
Binary files /dev/null and b/branches/sca-java-1.4/demos/mortgage-loanapproval/mortgage_assembly.png differ
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/pom.xml b/branches/sca-java-1.4/demos/mortgage-loanapproval/pom.xml
new file mode 100644
index 0000000000..4145cdb38a
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/pom.xml
@@ -0,0 +1,83 @@
+
+
+
+ 4.0.0
+
+ org.apache.tuscany.sca
+ tuscany-demos
+ 1.4-SNAPSHOT
+ ../pom.xml
+
+ demo-mortgage-loanapproval
+ jar
+ Apache Tuscany SCA Demo Mortgage Loan Approval
+ A sample Mortgage application made of several SCA components wired together.
+
+
+ 1.4-SNAPSHOT
+
+
+
+
+ org.apache.tuscany.sca
+ tuscany-host-embedded
+ 1.4-SNAPSHOT
+
+
+
+ org.apache.tuscany.sca
+ tuscany-implementation-java-runtime
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ org.apache.tuscany.sca
+ tuscany-binding-ws-axis2
+ 1.4-SNAPSHOT
+ runtime
+
+
+ org.apache.tuscany.sca
+ tuscany-implementation-script
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+
+
+ install
+ ${artifactId}
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ mortgage.MortgageClient
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheck.java b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheck.java
new file mode 100644
index 0000000000..c5787b7819
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheck.java
@@ -0,0 +1,29 @@
+/*
+ * 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 mortgage;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * CreditCheck interface
+ */
+@Remotable
+public interface CreditCheck {
+ int getCreditScore(String ssn);
+}
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheckImpl.java b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheckImpl.java
new file mode 100644
index 0000000000..dc803d9688
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheckImpl.java
@@ -0,0 +1,34 @@
+/*
+ * 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 mortgage;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * A pojo implementation of the CreditCheck service
+ */
+@Service(CreditCheck.class)
+public class CreditCheckImpl implements CreditCheck {
+
+ public int getCreditScore(String ssn) {
+ int score = (int)(700 + (Math.random() - 0.5) * 100);
+ System.out.println("Credit score for " + ssn + ": " + score);
+ return score;
+ }
+}
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/Customer.java b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/Customer.java
new file mode 100644
index 0000000000..66a486d516
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/Customer.java
@@ -0,0 +1,76 @@
+/*
+ * 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 mortgage;
+
+/**
+ * A simple Customer object
+ */
+public class Customer {
+ private String ssn;
+ private String firstName;
+ private String lastName;
+ private double monthlyIncome;
+ private String state;
+
+ public double getMonthlyIncome() {
+ return monthlyIncome;
+ }
+
+ public void setMonthlyIncome(double monthlyIncome) {
+ this.monthlyIncome = monthlyIncome;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getSsn() {
+ return ssn;
+ }
+
+ public void setSsn(String ssn) {
+ this.ssn = ssn;
+ }
+
+ @Override
+ public String toString() {
+ return firstName + " " + lastName + "[" + ssn + "]";
+ }
+}
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuote.java b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuote.java
new file mode 100644
index 0000000000..b5bafeb204
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuote.java
@@ -0,0 +1,23 @@
+/*
+ * 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 mortgage;
+
+public interface InterestRateQuote {
+ public float getRate(String state, double loanAmount, int termInYears);
+}
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuoteImpl.java b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuoteImpl.java
new file mode 100644
index 0000000000..8c642667f1
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuoteImpl.java
@@ -0,0 +1,42 @@
+/*
+ * 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 mortgage;
+
+import org.osoa.sca.annotations.Service;
+
+@Service(InterestRateQuote.class)
+public class InterestRateQuoteImpl implements InterestRateQuote {
+ public float getRate(String state, double loanAmount, int termInYears) {
+ float rate = 6.0f;
+ if (termInYears == 5) {
+ rate = 5.5f;
+ } else {
+ rate = 6.5f;
+ }
+ System.out.println("Interest rate for a " + termInYears
+ + "-year loan of $"
+ + loanAmount
+ + " in "
+ + state
+ + ": "
+ + rate
+ + "%");
+ return rate;
+ }
+}
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApproval.java b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApproval.java
new file mode 100644
index 0000000000..dcdad18496
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApproval.java
@@ -0,0 +1,27 @@
+/*
+ * 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 mortgage;
+
+/**
+ * Loan Approval interface
+ */
+public interface LoanApproval {
+ public boolean approve(Customer customer, double loanAmount, int years);
+}
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApprovalImpl.java b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApprovalImpl.java
new file mode 100644
index 0000000000..40bfdc4a1d
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApprovalImpl.java
@@ -0,0 +1,84 @@
+/*
+ * 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 mortgage;
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * An implementation of the LoanApproval service.
+ */
+@Service(LoanApproval.class)
+// Service declaration
+public class LoanApprovalImpl implements LoanApproval {
+ private CreditCheck[] creditCheck;
+ private MortgageCalculator mortgageCalculator;
+ private InterestRateQuote interestRateQuote;
+
+ // Reference declaration using a protected or public field
+ @Reference
+ public RiskAssessment riskAssessment;
+
+ private int minimumCreditScore = 650;
+
+ // Property declaration using a setter method
+ @Property(name = "minimumCreditScore")
+ public void setMinimumCreditScore(int minimumCreditScore) {
+ this.minimumCreditScore = minimumCreditScore;
+ }
+
+ // Reference declaration using a setter method
+ @Reference
+ public void setCreditCheck(CreditCheck[] creditCheck) {
+ this.creditCheck = creditCheck;
+ }
+
+ @Reference
+ public void setInterestRateQuote(InterestRateQuote interestRateQuote) {
+ this.interestRateQuote = interestRateQuote;
+ }
+
+ @Reference
+ public void setMortgageCalculator(MortgageCalculator mortgageCalculator) {
+ this.mortgageCalculator = mortgageCalculator;
+ }
+
+ public boolean approve(Customer customer, double loanAmount, int years) {
+ int score = 0;
+ for (int i = 0; i < creditCheck.length; i++) {
+ score += creditCheck[i].getCreditScore(customer.getSsn());
+ }
+ if (score != 0) {
+ score = score / creditCheck.length;
+ }
+ if (score < minimumCreditScore) {
+ System.err.println("Credit score " + score + " is below the minimum " + minimumCreditScore + ".");
+ return false;
+ }
+ float rate = interestRateQuote.getRate(customer.getState(), loanAmount, years);
+ double monthlyPayment = mortgageCalculator.getMonthlyPayment(loanAmount, years, rate);
+ double ratio = monthlyPayment / customer.getMonthlyIncome();
+ boolean approved = riskAssessment.assess(score, ratio);
+ if (!approved) {
+ System.err.println("Debt/Income ratio " + ratio + " is too high.");
+ }
+ return approved;
+ }
+}
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculator.java b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculator.java
new file mode 100644
index 0000000000..cacd8694de
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculator.java
@@ -0,0 +1,29 @@
+/*
+ * 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 mortgage;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * The Mortgage Calculator service interface.
+ */
+@Remotable
+public interface MortgageCalculator {
+ public double getMonthlyPayment(double principal, int years, float interestRate);
+}
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculatorImpl.java b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculatorImpl.java
new file mode 100644
index 0000000000..015f1bae98
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculatorImpl.java
@@ -0,0 +1,38 @@
+/*
+ * 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 mortgage;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * An implementation of the Calculator service.
+ */
+@Service(MortgageCalculator.class)
+public class MortgageCalculatorImpl implements MortgageCalculator {
+
+ public double getMonthlyPayment(double principal, int years, float interestRate) {
+ double monthlyRate = interestRate / 12.0 / 100.0;
+ double p = Math.pow(1 + monthlyRate, years * 12);
+ double q = p / (p - 1);
+ double monthlyPayment = principal * monthlyRate * q;
+ System.out.println("Monthly payment for a " + years + "-year loan of $" + principal + ": " + monthlyPayment);
+ return monthlyPayment;
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageClient.java b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageClient.java
new file mode 100644
index 0000000000..d69f0a1163
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageClient.java
@@ -0,0 +1,44 @@
+/*
+ * 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 mortgage;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+/**
+ * This client program to invoke the Mortgage LoanApproval service
+ */
+public class MortgageClient {
+ public static void main(String[] args) throws Exception {
+
+ SCADomain domain = SCADomain.newInstance("Mortgage1.composite");
+ LoanApproval loanApplication = domain.getService(LoanApproval.class, "LoanApprovalComponent");
+
+ // Create the customer
+ Customer customer = new Customer();
+ customer.setSsn("111-22-3333");
+ customer.setFirstName("John");
+ customer.setLastName("Smith");
+ customer.setMonthlyIncome(5000.0d);
+ customer.setState("CA");
+
+ // Invoke the service
+ boolean result = loanApplication.approve(customer, 200000d, 30);
+ System.out.println((result ? "Approved: " : "Rejected: ") + customer);
+ }
+}
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessment.java b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessment.java
new file mode 100644
index 0000000000..23c9589e85
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessment.java
@@ -0,0 +1,27 @@
+/*
+ * 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 mortgage;
+
+/**
+ * Risk Assessment interface
+ */
+public interface RiskAssessment {
+ public boolean assess(int creditScore, double ratio);
+}
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessmentImpl.java b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessmentImpl.java
new file mode 100644
index 0000000000..c2116366ec
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessmentImpl.java
@@ -0,0 +1,38 @@
+/*
+ * 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 mortgage;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * A pojo implementation of RiskAssessment service
+ */
+@Service(RiskAssessment.class)
+public class RiskAssessmentImpl implements RiskAssessment {
+ public boolean assess(int creditScore, double ratio) {
+ if (creditScore >= 750) {
+ return ratio < 0.35;
+ } else if (creditScore >= 700) {
+ return ratio < 0.30;
+ } else {
+ return ratio < 0.25;
+ }
+ }
+}
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/resources/Mortgage.composite b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/resources/Mortgage.composite
new file mode 100644
index 0000000000..d1128b9907
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/resources/Mortgage.composite
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+ 600
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/resources/Mortgage1.composite b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/resources/Mortgage1.composite
new file mode 100644
index 0000000000..4cad6c7223
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/resources/Mortgage1.composite
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+ 600
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.componentType b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.componentType
new file mode 100644
index 0000000000..bf7b10e0f7
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.componentType
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.js b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.js
new file mode 100644
index 0000000000..b25af1d039
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.js
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+function getMonthlyPayment(principal, years, interestRate) {
+ var monthlyRate = interestRate / 12.0 / 100.0;
+ var p = Math.pow(1 + monthlyRate, years * 12);
+ var q = p / (p - 1);
+ var monthlyPayment = principal * monthlyRate * q;
+ return monthlyPayment;
+}
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/resources/wsdl/credit.wsdl b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/resources/wsdl/credit.wsdl
new file mode 100644
index 0000000000..9c2acc96d3
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/main/resources/wsdl/credit.wsdl
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/mortgage-loanapproval/src/test/java/mortgage/MortgageClientTestCase.java b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/test/java/mortgage/MortgageClientTestCase.java
new file mode 100644
index 0000000000..285cc72515
--- /dev/null
+++ b/branches/sca-java-1.4/demos/mortgage-loanapproval/src/test/java/mortgage/MortgageClientTestCase.java
@@ -0,0 +1,56 @@
+/*
+ * 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 mortgage;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class MortgageClientTestCase extends TestCase {
+ private SCADomain domain;
+ private LoanApproval loanApproval;
+
+ @Override
+ protected void setUp() throws Exception {
+ domain = SCADomain.newInstance("Mortgage.composite");
+ loanApproval = domain.getService(LoanApproval.class, "LoanApprovalComponent");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ if (domain != null) {
+ domain.close();
+ }
+ }
+
+ public void testApprove() throws Exception {
+ Customer customer = new Customer();
+ customer.setSsn("111-22-3333");
+ customer.setFirstName("John");
+ customer.setLastName("Smith");
+ customer.setMonthlyIncome(5000.0d);
+ customer.setState("CA");
+
+ boolean approved = loanApproval.approve(customer, 200000d, 30);
+ System.out.println((approved ? "Approved: " : "Rejected: ") + customer);
+ }
+}
diff --git a/branches/sca-java-1.4/demos/pom.xml b/branches/sca-java-1.4/demos/pom.xml
new file mode 100644
index 0000000000..420ad92c52
--- /dev/null
+++ b/branches/sca-java-1.4/demos/pom.xml
@@ -0,0 +1,52 @@
+
+
+
+ 4.0.0
+
+ org.apache.tuscany.sca
+ tuscany-sca
+ 1.4-SNAPSHOT
+ ../pom.xml
+
+ tuscany-demos
+ pom
+ Apache Tuscany SCA Demos
+
+
+
+ default
+
+ true
+
+
+ alert-aggregator-webapp
+ bigbank
+ bigbank-account
+ bigbank-calculator
+ bigbank-stockquote
+ mortgage-creditcheck
+ mortgage-loanapproval
+ xml-bigbank
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/workpool-distributed/LICENSE b/branches/sca-java-1.4/demos/workpool-distributed/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/branches/sca-java-1.4/demos/workpool-distributed/LICENSE
@@ -0,0 +1,205 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
+
+
diff --git a/branches/sca-java-1.4/demos/workpool-distributed/NOTICE b/branches/sca-java-1.4/demos/workpool-distributed/NOTICE
new file mode 100644
index 0000000000..94481d6cfa
--- /dev/null
+++ b/branches/sca-java-1.4/demos/workpool-distributed/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2007 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/branches/sca-java-1.4/demos/workpool-distributed/build.xml b/branches/sca-java-1.4/demos/workpool-distributed/build.xml
new file mode 100644
index 0000000000..9e10e8ec91
--- /dev/null
+++ b/branches/sca-java-1.4/demos/workpool-distributed/build.xml
@@ -0,0 +1,446 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.4/demos/workpool-distributed/pom.xml b/branches/sca-java-1.4/demos/workpool-distributed/pom.xml
new file mode 100644
index 0000000000..01a8900d52
--- /dev/null
+++ b/branches/sca-java-1.4/demos/workpool-distributed/pom.xml
@@ -0,0 +1,148 @@
+
+
+
+ 4.0.0
+
+ org.apache.tuscany.sca
+ tuscany-sca
+ 1.4-SNAPSHOT
+ ../../pom.xml
+
+ demo-workpool-distributed
+ Apache Tuscany SCA Distributed Job Workpool Demo
+
+
+
+ apache.incubator
+
+ http://people.apache.org/repo/m2-incubating-repository
+
+
+
+ org.drools
+ http://repository.jboss.com/maven2/org/drools/
+
+
+
+
+
+ org.apache.tuscany.sca
+ tuscany-host-embedded
+ 1.4-SNAPSHOT
+
+
+
+ org.drools
+ drools
+ 4.0.4
+
+
+
+ antlr
+ antlr
+ 2.7.1
+
+
+ commons-daemon
+ commons-daemon
+ 1.0.1
+
+
+
+ antlr
+ stringtemplate
+ 2.3b6
+
+
+
+ org.apache.tuscany.sca
+ tuscany-node-impl
+ 1.4-SNAPSHOT
+
+
+
+ org.apache.tuscany.sca
+ tuscany-domain-impl
+ 1.4-SNAPSHOT
+
+
+
+ org.apache.tuscany.sca
+ tuscany-binding-sca-axis2
+ 1.4-SNAPSHOT
+
+
+
+ org.apache.tuscany.sca
+ tuscany-binding-jsonrpc-runtime
+ 1.4-SNAPSHOT
+
+
+
+ org.apache.tuscany.sca
+ tuscany-binding-http-runtime
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ org.apache.tuscany.sca
+ tuscany-databinding-job
+ 1.4-SNAPSHOT
+
+
+ org.apache.tuscany.sca
+ tuscany-contribution-updater
+ 1.4-SNAPSHOT
+
+
+
+ org.apache.tuscany.sca
+ tuscany-databinding-xstream
+ 1.4-SNAPSHOT
+
+
+
+ org.apache.tuscany.sca
+ tuscany-implementation-resource-runtime
+ 1.4-SNAPSHOT
+ runtime
+
+
+
+ org.apache.tuscany.sca
+ tuscany-host-tomcat
+ 1.4-SNAPSHOT
+ test
+
+
+
+ junit
+ junit
+ 4.2
+ test
+
+
+
+
+
+ ${artifactId}
+
+
diff --git a/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/node/DomainNode.java b/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/node/DomainNode.java
new file mode 100644
index 0000000000..a278499aae
--- /dev/null
+++ b/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/node/DomainNode.java
@@ -0,0 +1,57 @@
+/*
+ * 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 node;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.tuscany.sca.domain.SCADomain;
+import org.apache.tuscany.sca.domain.SCADomainFactory;
+
+/**
+ * This server program that loads a composite to provide simple registry
+ * function. This server can be replaced with any registry that is appropriate
+ * but the components in each node that talk to the registry should be replaced
+ * also.
+ */
+public class DomainNode {
+
+ private static String DEFAULT_DOMAIN_URI = "http://u12:8877";
+ private boolean stopped = true;
+
+ public static void main(String[] args) {
+
+ try {
+
+ SCADomainFactory domainFactory = SCADomainFactory.newInstance();
+ SCADomain domain = domainFactory
+ .createSCADomain(DEFAULT_DOMAIN_URI);
+
+ System.out.println("Domain started (press enter to shutdown)");
+ System.in.read();
+ // waitForever();
+ domain.destroy();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("Domain stopped");
+ }
+}
diff --git a/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/node/DomainNodeDaemon.java b/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/node/DomainNodeDaemon.java
new file mode 100644
index 0000000000..9d05761ad6
--- /dev/null
+++ b/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/node/DomainNodeDaemon.java
@@ -0,0 +1,79 @@
+/*
+ * 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 node;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.commons.daemon.Daemon;
+import org.apache.commons.daemon.DaemonContext;
+import org.apache.tuscany.sca.domain.SCADomain;
+import org.apache.tuscany.sca.domain.SCADomainFactory;
+
+/**
+ * This server program that loads a composite to provide simple registry
+ * function. This server can be replaced with any registry that is appropriate
+ * but the components in each node that talk to the registry should be replaced
+ * also.
+ */
+public class DomainNodeDaemon implements Daemon {
+
+ private SCADomain domain;
+ private static String DEFAULT_DOMAIN_URI = "http://u12:8877";
+ private boolean stopped = true;
+
+ private synchronized void waitForever() {
+ while (!stopped) {
+ try {
+ wait();
+ } catch (InterruptedException ex) {
+ stopped = true;
+ return;
+ }
+ }
+
+ }
+
+ public void destroy() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void init(DaemonContext arg0) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void start() throws Exception {
+
+ SCADomainFactory domainFactory = SCADomainFactory.newInstance();
+ domain = domainFactory.createSCADomain(DEFAULT_DOMAIN_URI);
+
+ System.out.println("Domain started (press enter to shutdown)");
+ waitForever();
+
+ }
+
+ public void stop() throws Exception {
+ // TODO Auto-generated method stub
+ Thread.currentThread().interrupt();
+ domain.destroy();
+ }
+}
\ No newline at end of file
diff --git a/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/node/TestJob.java b/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/node/TestJob.java
new file mode 100644
index 0000000000..f48e647bd6
--- /dev/null
+++ b/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/node/TestJob.java
@@ -0,0 +1,82 @@
+/*
+ * 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 node;
+
+import org.apache.tuscany.sca.databinding.job.Job;
+import org.apache.tuscany.sca.databinding.job.JobDataMap;
+import org.apache.tuscany.sca.databinding.job.JobExecutionContext;
+import org.apache.tuscany.sca.databinding.job.RemoteJob;
+
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver;
+
+public class TestJob extends RemoteJob implements java.io.Serializable {
+ private boolean EOS = false;
+ private Double value;
+
+ public TestJob(Double x, long iterations, int[] items) {
+ JobDataMap map = new JobDataMap();
+ map.addJobData("value", x);
+ map.addJobData("iterations", iterations);
+ map.addJobData("items", items);
+ context.setJobData(map);
+ }
+
+ public TestJob(Double i, boolean eos) {
+ value = i;
+ this.EOS = eos;
+ }
+
+ public TestJob(String jsonData) {
+ JobExecutionContext ctxt = new JobExecutionContext();
+ ctxt.storeJSONData(jsonData);
+ }
+
+ public int getType() {
+ return Job.REGULAR_JOB;
+ }
+
+ public void setEOS() {
+ EOS = true;
+ }
+
+ public boolean eos() {
+ return EOS;
+ }
+
+ @Override
+ public Double compute(JobExecutionContext context) {
+ JobDataMap contextMap = context.getJobData();
+ Long iterations = (Long) contextMap.getJobDataObject("iterations");
+ Double value = (Double) contextMap.getJobDataObject("value");
+ double x = value.doubleValue();
+ System.out.println("Computing sinx for " + value + " for "
+ + iterations.intValue() + " times");
+ long computing_start = System.currentTimeMillis();
+ for (long i = 0; i < iterations.longValue(); ++i) {
+ x = Math.sin(x);
+ }
+ long computing_end = System.currentTimeMillis();
+ System.out.println("Computing time= "
+ + (computing_end - computing_start));
+ System.out.println("Send result = " + x);
+ return new Double(x);
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/node/WorkpoolDaemon.java b/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/node/WorkpoolDaemon.java
new file mode 100644
index 0000000000..1f2a4d1f9a
--- /dev/null
+++ b/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/node/WorkpoolDaemon.java
@@ -0,0 +1,271 @@
+/*
+ * 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 node;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.daemon.Daemon;
+import org.apache.commons.daemon.DaemonContext;
+import org.apache.commons.daemon.DaemonController;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.DeployedArtifact;
+import org.apache.tuscany.sca.contribution.service.impl.ContributionServiceImpl;
+import org.apache.tuscany.sca.domain.SCADomain;
+import org.apache.tuscany.sca.node.NodeException;
+import org.apache.tuscany.sca.node.NodeManagerInitService;
+import org.apache.tuscany.sca.node.SCANode;
+import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.impl.SCANodeImpl;
+import org.apache.tuscany.sca.node.management.SCANodeManagerInitService;
+
+import java.net.URI;
+
+import workpool.WorkerManager;
+import workpool.WorkerManagerImpl;
+import workpool.WorkpoolManager;
+import workpool.WorkpoolService;
+import workpool.WorkpoolServiceImpl;
+
+/**
+ * This client program shows how to run a distributed SCA node. In this case a
+ * calculator node has been constructed specifically for running the calculator
+ * composite. Internally it creates a representation of a node and associates a
+ * distributed domain with the node. This separation is made different
+ * implementations of the distributed domain can be provided.
+ */
+public class WorkpoolDaemon implements Daemon, Runnable {
+ private String domainName;
+ private String nodeName;
+ private long iterations;
+ private long jobsNo;
+ private long workerNo;
+ private SCANode node;
+ private boolean stopped = false;
+ private DaemonController controller = null;
+ private Thread thread = null;
+ private String ruleFile = "workerRules.drl";
+
+ /*
+ * public static void main(String[] args) throws Exception {
+ * // Check that the correct arguments have been provided if (null == args ||
+ * args.length < 4) { System.err.println("Usage: java WorkpoolNode
+ * domainname nodename iterTest workerNo"); System.exit(1); }
+ *
+ * try { String domainName = args[0]; String nodeName = args[1]; long
+ * iterations = Long.parseLong(args[2]); long jobsNo =
+ * Long.parseLong(args[3]); long workerNo = Long.parseLong(args[4]);
+ * ClassLoader cl = WorkpoolDaemon.class.getClassLoader();
+ *
+ * SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); node =
+ * nodeFactory.createSCANode(null, domainName);
+ * node.addContribution(nodeName, cl.getResource(nodeName + "/"));
+ * node.addToDomainLevelComposite(new QName("http://sample", "Workpool"));
+ * node.start(); // nodeA is the head node and runs some tests while all
+ * other nodes // simply listen for incoming messages
+ *
+ * FileReader rules = new FileReader("workerRules.drl"); StringBuffer buffer =
+ * new StringBuffer();
+ *
+ * BufferedReader br = new BufferedReader(rules); String ruleString; do {
+ * ruleString = br.readLine(); if (ruleString!=null) {
+ * buffer.append(ruleString);} } while (ruleString!=null);
+ *
+ * if ( nodeName.equals("nodeA") ) { // do some application stuff
+ * WorkpoolService workpoolService =
+ * node.getDomain().getService(WorkpoolService.class,
+ * "WorkpoolServiceComponent"); workpoolService.start();
+ * NodeManagerInitService nodeInit =
+ * node.getDomain().getService(NodeManagerInitService.class,
+ * "WorkpoolManagerComponent/NodeManagerInitService");
+ * nodeInit.setNode(node); WorkpoolManager workpoolManager =
+ * node.getDomain().getService(WorkpoolManager.class,
+ * "WorkpoolManagerComponent/WorkpoolManager");
+ * workpoolManager.setWorkpoolReference(node.getDomain().getServiceReference(WorkpoolService.class,
+ * "WorkpoolServiceComponent"));
+ * workpoolManager.acceptRules(buffer.toString()); workpoolManager.start();
+ * int items[] = {3,4,5,6,3,6,3,5,9,5,6};
+ *
+ * double x = 398349; for (int i = 0; i < jobsNo; ++i)
+ * workpoolService.submit(new TestJob(x,iterations,items));
+ *
+ * TestJob j = new TestJob(-1.0,true); for (int i = 0; i < workerNo+1; ++i){
+ * j.setEOS(); workpoolService.submit(j); } } try { if
+ * (nodeName.equals("nodeB")) { NodeManagerInitService serviceNodeB =
+ * node.getDomain().getService(NodeManagerInitService.class,"WorkerManagerNodeBComponent/NodeManagerInitService");
+ * serviceNodeB.setNode(node); } if (nodeName.equals("nodeC")) {
+ * NodeManagerInitService workerManagerC =
+ * node.getDomain().getService(NodeManagerInitService.class,"WorkerManagerNodeCComponent/NodeManagerInitService");
+ * workerManagerC.setNode(node); } if (nodeName.equals("nodeD")) {
+ * NodeManagerInitService workerManagerD =
+ * node.getDomain().getService(NodeManagerInitService.class,"WorkerManagerNodeDComponent/NodeManagerInitService");
+ * workerManagerD.setNode(node); } if (nodeName.equals("nodeE")) {
+ * NodeManagerInitService workerManagerE =
+ * node.getDomain().getService(NodeManagerInitService.class,"WorkerManagerNodeEComponent/NodeManagerInitService");
+ * workerManagerE.setNode(node); }
+ *
+ * System.out.println("Node started (press enter to shutdown)");
+ * System.in.read(); } catch (IOException e) { e.printStackTrace(); } //
+ * stop the node and all the domains in it node.stop(); node.destroy();
+ * System.exit(0); } catch(Exception ex) { System.err.println("Exception in
+ * node - " + ex.getMessage()); ex.printStackTrace(System.err); } }
+ */
+ public void destroy() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void init(DaemonContext arg0) throws Exception {
+ String[] args = arg0.getArguments();
+ domainName = args[0];
+ nodeName = args[1];
+ iterations = Long.parseLong(args[2]);
+ jobsNo = Long.parseLong(args[3]);
+ workerNo = Long.parseLong(args[4]);
+ if (args.length == 6) {
+ ruleFile = args[5];
+ }
+ this.controller = arg0.getController();
+ // this.thread=new Thread(this);
+ }
+
+ public void start() throws Exception {
+
+ ClassLoader cl = WorkpoolDaemon.class.getClassLoader();
+
+ SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
+ node = nodeFactory.createSCANode(null, domainName);
+ node.addContribution(nodeName, cl.getResource(nodeName + "/"));
+ node.addToDomainLevelComposite(new QName("http://sample", "Workpool"));
+ node.start();
+ // nodeA is the head node and runs some tests while all other nodes
+ // simply listen for incoming messages
+
+ FileReader rules = new FileReader(ruleFile);
+ StringBuffer buffer = new StringBuffer();
+
+ BufferedReader br = new BufferedReader(rules);
+ String ruleString;
+ do {
+ ruleString = br.readLine();
+ if (ruleString != null) {
+ buffer.append(ruleString + "\n");
+ }
+ } while (ruleString != null);
+
+ if (nodeName.equals("nodeA")) {
+ // do some application stuff
+ WorkpoolService workpoolService = node.getDomain().getService(
+ WorkpoolService.class, "WorkpoolServiceComponent");
+ workpoolService.start();
+ SCANodeManagerInitService nodeInit = node.getDomain().getService(
+ SCANodeManagerInitService.class,
+ "WorkpoolManagerComponent/NodeManagerInitService");
+ nodeInit.setNode(node);
+ WorkpoolManager workpoolManager = node.getDomain().getService(
+ WorkpoolManager.class,
+ "WorkpoolManagerComponent/WorkpoolManager");
+ workpoolManager.setWorkpoolReference(node.getDomain()
+ .getServiceReference(WorkpoolService.class,
+ "WorkpoolServiceComponent"));
+ workpoolManager.acceptRules(buffer.toString());
+ workpoolManager.start();
+
+ int items[] = { 3, 4, 5, 6, 3, 6, 3, 5, 9, 5, 6 };
+
+ double x = 398349;
+ for (int i = 0; i < jobsNo; ++i) {
+ workpoolService.submit(new TestJob(x, iterations, items));
+ }
+ TestJob j = new TestJob(-1.0, true);
+ for (int i = 0; i < workerNo + 1; ++i) {
+ j.setEOS();
+ workpoolService.submit(j);
+ }
+
+ }
+ if (nodeName.equals("nodeB")) {
+ SCANodeManagerInitService workerManagerNodeB = node
+ .getDomain()
+ .getService(SCANodeManagerInitService.class,
+ "WorkerManagerNodeBComponent/NodeManagerInitService");
+ workerManagerNodeB.setNode(node);
+ }
+
+ if (nodeName.equals("nodeC")) {
+ SCANodeManagerInitService workerManagerNodeC = node
+ .getDomain()
+ .getService(SCANodeManagerInitService.class,
+ "WorkerManagerNodeCComponent/NodeManagerInitService");
+ workerManagerNodeC.setNode(node);
+ }
+
+ if (nodeName.equals("nodeD")) {
+ SCANodeManagerInitService workerManagerNodeD = node
+ .getDomain()
+ .getService(SCANodeManagerInitService.class,
+ "WorkerManagerNodeDComponent/NodeManagerInitService");
+ workerManagerNodeD.setNode(node);
+ }
+
+ if (nodeName.equals("nodeE")) {
+ SCANodeManagerInitService workerManagerNodeE = node
+ .getDomain()
+ .getService(SCANodeManagerInitService.class,
+ "WorkerManagerNodeEComponent/NodeManagerInitService");
+ workerManagerNodeE.setNode(node);
+ }
+
+ this.waitForever();
+ // this.thread.start();
+ }
+
+ public void stop() throws Exception {
+ Thread.currentThread().interrupt();
+ // thread.interrupt();
+ node.stop();
+ node.destroy();
+ }
+
+ private synchronized void waitForever() {
+ while (!stopped) {
+ try {
+ wait();
+ } catch (InterruptedException ex) {
+ stopped = true;
+ return;
+ }
+ }
+ }
+
+ public void run() {
+ waitForever();
+ }
+}
diff --git a/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/node/WorkpoolNode.java b/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/node/WorkpoolNode.java
new file mode 100644
index 0000000000..86557548af
--- /dev/null
+++ b/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/node/WorkpoolNode.java
@@ -0,0 +1,179 @@
+/*
+ * 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 node;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.DeployedArtifact;
+import org.apache.tuscany.sca.contribution.service.impl.ContributionServiceImpl;
+import org.apache.tuscany.sca.domain.SCADomain;
+import org.apache.tuscany.sca.node.NodeManagerInitService;
+import org.apache.tuscany.sca.node.SCANode;
+import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.impl.SCANodeImpl;
+import java.net.URI;
+
+import workpool.WorkerManager;
+import workpool.WorkerManagerImpl;
+import workpool.WorkpoolManager;
+import workpool.WorkpoolService;
+import workpool.WorkpoolServiceImpl;
+
+/**
+ * This client program shows how to run a distributed SCA node. In this case a
+ * calculator node has been constructed specifically for running the calculator
+ * composite. Internally it creates a representation of a node and associates a
+ * distributed domain with the node. This separation is made different
+ * implementations of the distributed domain can be provided.
+ */
+public class WorkpoolNode {
+
+ public static void main(String[] args) throws Exception {
+
+ // Check that the correct arguments have been provided
+ if (null == args || args.length < 4) {
+ System.err
+ .println("Useage: java WorkpoolNode domainname nodename iterTest workerNo");
+ System.exit(1);
+ }
+ BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+ String domainName = args[0];
+ String nodeName = args[1];
+ long iterations = Long.parseLong(args[2]);
+ long jobsNo = Long.parseLong(args[3]);
+ long workerNo = Long.parseLong(args[4]);
+ ClassLoader cl = WorkpoolNode.class.getClassLoader();
+
+ SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
+ SCANode node = nodeFactory.createSCANode(null, domainName);
+ node.addContribution(nodeName, cl.getResource(nodeName + "/"));
+ node.addToDomainLevelComposite(new QName("http://sample", "Workpool"));
+ node.start();
+ // nodeA is the head node and runs some tests while all other nodes
+ // simply listen for incoming messages
+
+ FileReader rules = new FileReader("workerRules.drl");
+ StringBuffer buffer = new StringBuffer();
+
+ BufferedReader br = new BufferedReader(rules);
+ String ruleString;
+ do {
+ ruleString = br.readLine();
+ if (ruleString != null) {
+ buffer.append(ruleString + "\n");
+ }
+ } while (ruleString != null);
+
+ if (nodeName.equals("nodeA")) {
+ // do some application stuff
+ WorkpoolService workpoolService = node.getDomain().getService(
+ WorkpoolService.class, "WorkpoolServiceComponent");
+ workpoolService.start();
+ NodeManagerInitService nodeInit = node.getDomain().getService(
+ NodeManagerInitService.class,
+ "WorkpoolManagerComponent/NodeManagerInitService");
+ nodeInit.setNode(node);
+ WorkpoolManager workpoolManager = node.getDomain().getService(
+ WorkpoolManager.class,
+ "WorkpoolManagerComponent/WorkpoolManager");
+ workpoolManager.setWorkpoolReference(node.getDomain()
+ .getServiceReference(WorkpoolService.class,
+ "WorkpoolServiceComponent"));
+ workpoolManager.setCycleTime(8000);
+ workpoolManager.acceptRules(buffer.toString());
+ workpoolManager.start();
+ int items[] = { 3, 4, 5, 6, 3, 6, 3, 5, 9, 5, 6 };
+
+ double x = 398349;
+
+ for (int i = 0; i < jobsNo; ++i)
+ workpoolService.submit(new TestJob(x, iterations, items));
+
+ TestJob j = new TestJob(-1.0, true);
+ for (int i = 0; i < workerNo + 1; ++i) {
+ j.setEOS();
+ workpoolService.submit(j);
+ }
+
+ }
+ try {
+ if (nodeName.equals("nodeB")) {
+ NodeManagerInitService serviceNodeB = node
+ .getDomain()
+ .getService(NodeManagerInitService.class,
+ "WorkerManagerNodeBComponent/NodeManagerInitService");
+ serviceNodeB.setNode(node);
+ }
+ if (nodeName.equals("nodeC")) {
+ NodeManagerInitService workerManagerC = node
+ .getDomain()
+ .getService(NodeManagerInitService.class,
+ "WorkerManagerNodeCComponent/NodeManagerInitService");
+ workerManagerC.setNode(node);
+ }
+ if (nodeName.equals("nodeD")) {
+ NodeManagerInitService workerManagerD = node
+ .getDomain()
+ .getService(NodeManagerInitService.class,
+ "WorkerManagerNodeDComponent/NodeManagerInitService");
+ workerManagerD.setNode(node);
+ }
+ if (nodeName.equals("nodeE")) {
+ NodeManagerInitService workerManagerE = node
+ .getDomain()
+ .getService(NodeManagerInitService.class,
+ "WorkerManagerNodeEComponent/NodeManagerInitService");
+ workerManagerE.setNode(node);
+ }
+
+ System.out.println("Node started (press enter to shutdown)");
+ String buff;
+ for (;;) {
+ try {
+ buff = in.readLine();
+ if (buff == null)
+ break;
+ System.out.print(in.readLine());
+ } catch (IOException ex) {
+ break; // Exit thread.
+ }
+ }
+ // stop the node and all the domains in it
+ node.stop();
+ node.destroy();
+ System.exit(0);
+ } catch (Exception ex) {
+ System.err.println("Exception in node - " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ }
+ }
+}
diff --git a/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/node/workerRules1.drl b/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/node/workerRules1.drl
new file mode 100644
index 0000000000..9c5a5d1b7f
--- /dev/null
+++ b/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/node/workerRules1.drl
@@ -0,0 +1,13 @@
+package workpool
+import workpool.*;
+rule "WorkerAdder1"
+ when
+ $workerBean: WorkpoolBean(singleAction == false && (jobComputed > 500))
+ then
+ $workerBean.setSingleAction()
+ $workerBean.addWorkerToNode("nodeB")
+ $workerBean.addWorkerToNode("nodeC")
+ $workerBean.addWorkerToNode("nodeD")
+ $workerBean.addWorkerToNode("nodeE")
+end
+
\ No newline at end of file
diff --git a/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/workpool/MetaComponentWorker.java b/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/workpool/MetaComponentWorker.java
new file mode 100644
index 0000000000..cdd0f30b34
--- /dev/null
+++ b/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/workpool/MetaComponentWorker.java
@@ -0,0 +1,85 @@
+/*
+ * 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 workpool;
+
+import java.io.StringReader;
+import java.net.URI;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.util.logging.Logger;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.MetaComponent;
+import org.apache.tuscany.sca.assembly.impl.DefaultMetaComponent;
+
+public class MetaComponentWorker extends DefaultMetaComponent {
+
+ private SecureRandom prng;
+ private String componentName;
+ private String scdl;
+ private String javaClass;
+ private boolean loadedFromString = false;
+ private Logger log = Logger.getLogger(MetaComponentWorker.class.getName());
+
+ public MetaComponentWorker() {
+ componentName = "WorkerComponent"
+ + java.util.UUID.randomUUID().toString();
+ }
+
+ public void setWorkerName(String componentName) {
+ this.componentName = componentName;
+ }
+
+ public void setWorkerClass(String javaClass) {
+ this.javaClass = javaClass;
+ }
+
+ private String generateSCDL() {
+ StringBuffer buffer = new StringBuffer(512);
+ buffer
+ .append("\n");
+ buffer.append("");
+ buffer.append("");
+ buffer.append(this.componentName);
+ buffer.append("\n");
+ return buffer.toString();
+ }
+
+ @Override
+ public XMLStreamReader build() throws Exception {
+ XMLInputFactory factory = XMLInputFactory.newInstance();
+ if (!loadedFromString)
+ scdl = generateSCDL();
+ return factory.createXMLStreamReader(new StringReader(scdl));
+
+ }
+
+ public String getName() {
+
+ return componentName;
+ }
+
+}
diff --git a/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/workpool/MyWorker.java b/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/workpool/MyWorker.java
new file mode 100644
index 0000000000..c45696e3cf
--- /dev/null
+++ b/branches/sca-java-1.4/demos/workpool-distributed/src/main/java/workpool/MyWorker.java
@@ -0,0 +1,46 @@
+/*
+ * 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 workpool;
+
+import org.apache.tuscany.sca.core.context.CallableReferenceImpl;
+import org.apache.tuscany.sca.databinding.job.Job;
+import org.apache.tuscany.sca.databinding.job.JobDataMap;
+import org.apache.tuscany.sca.databinding.job.JobExecutionContext;
+import org.apache.tuscany.sca.databinding.job.RemoteJob;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("COMPOSITE")
+public class MyWorker extends WorkerServiceImpl