summaryrefslogtreecommitdiffstats
path: root/java/sca/samples/simple-bigbank-spring/src
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-08-19 16:26:34 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-08-19 16:26:34 +0000
commit0d45e3ed781fd306d0ee24995648a74666d1bec6 (patch)
tree1196682b7871d515b813314d927d22df226d2e73 /java/sca/samples/simple-bigbank-spring/src
parenteb0c44c3a43aa1f5dd58487d2b0ed95197992c46 (diff)
TUSCANY-2550 - Adding more bindings to the spring bigbank sample. Convert the sample from SCADomain to Node APIs. Thanks for the patch Ram
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@687088 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/samples/simple-bigbank-spring/src')
-rw-r--r--java/sca/samples/simple-bigbank-spring/src/main/java/bigbank/account/feed/AccountFeedImpl.java71
-rw-r--r--java/sca/samples/simple-bigbank-spring/src/main/java/bigbank/client/BigBankClient.java13
-rw-r--r--java/sca/samples/simple-bigbank-spring/src/main/java/bigbank/server/BigBankServer.java153
-rw-r--r--java/sca/samples/simple-bigbank-spring/src/main/resources/BigBank.composite18
-rw-r--r--java/sca/samples/simple-bigbank-spring/src/main/resources/web/style.css22
5 files changed, 173 insertions, 104 deletions
diff --git a/java/sca/samples/simple-bigbank-spring/src/main/java/bigbank/account/feed/AccountFeedImpl.java b/java/sca/samples/simple-bigbank-spring/src/main/java/bigbank/account/feed/AccountFeedImpl.java
new file mode 100644
index 0000000000..386f7bb90d
--- /dev/null
+++ b/java/sca/samples/simple-bigbank-spring/src/main/java/bigbank/account/feed/AccountFeedImpl.java
@@ -0,0 +1,71 @@
+/*
+ * 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;
+import bigbank.account.AccountReport;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+
+@Service(Collection.class)
+public class AccountFeedImpl implements Collection<String, String> {
+
+ @Reference
+ protected AccountService accountService;
+
+ public Entry<String, String>[] getAll() {
+
+ // Add the Account report entry
+ String report = get("1234");
+ Entry<String, String> entry = new Entry<String, String>("1234", report);
+
+ return new Entry[] { entry } ;
+ }
+
+ public String get(String id) {
+
+ // Get the account report for the specified customer ID
+ AccountReport accreport = accountService.getAccountReport(id);
+ String report = accreport.getCurrency();
+
+ 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<String, String>[] query(String queryString) {
+ return null;
+ }
+}
diff --git a/java/sca/samples/simple-bigbank-spring/src/main/java/bigbank/client/BigBankClient.java b/java/sca/samples/simple-bigbank-spring/src/main/java/bigbank/client/BigBankClient.java
index a033c54ebb..1ad5a3f7b3 100644
--- a/java/sca/samples/simple-bigbank-spring/src/main/java/bigbank/client/BigBankClient.java
+++ b/java/sca/samples/simple-bigbank-spring/src/main/java/bigbank/client/BigBankClient.java
@@ -19,7 +19,9 @@
package bigbank.client;
-import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.node.SCAClient;
+import org.apache.tuscany.sca.node.SCANode2;
+import org.apache.tuscany.sca.node.SCANode2Factory;
import bigbank.account.AccountService;
@@ -30,14 +32,15 @@ import bigbank.account.AccountService;
public class BigBankClient {
public static void main(String[] args) throws Exception {
- SCADomain scaDomain = SCADomain.newInstance("BigBank.composite");
+ SCANode2Factory factory = SCANode2Factory.newInstance();
+ SCANode2 node = factory.createSCANodeFromClassLoader("BigBank.composite", BigBankClient.class.getClassLoader());
+ node.start();
- AccountService accountService = scaDomain.getService(AccountService.class,
- "AccountServiceComponent");
+ AccountService accountService = ((SCAClient)node).getService(AccountService.class, "AccountServiceComponent");
System.out.println("Account summary: " + accountService.getAccountReport("Customer_01") );
- scaDomain.close();
+ node.stop();
}
}
diff --git a/java/sca/samples/simple-bigbank-spring/src/main/java/bigbank/server/BigBankServer.java b/java/sca/samples/simple-bigbank-spring/src/main/java/bigbank/server/BigBankServer.java
index 281d829275..cb86b9162d 100644
--- a/java/sca/samples/simple-bigbank-spring/src/main/java/bigbank/server/BigBankServer.java
+++ b/java/sca/samples/simple-bigbank-spring/src/main/java/bigbank/server/BigBankServer.java
@@ -1,99 +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.server;
-
-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.impl.EmbeddedSCADomain;
-
-/**
- * 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 Spring 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 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 : 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");
-
- // Stop Components from composite
- for (Composite deployable : bigbankContribution.getDeployables()) {
- domain.getCompositeActivator().stop(deployable);
- domain.getCompositeActivator().deactivate(deployable);
- }
-
- domain.stop();
-
- 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;
- }
-
-}
+/*
+ * 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.server;
+
+import org.apache.tuscany.sca.node.SCANode2;
+import org.apache.tuscany.sca.node.SCANode2Factory;
+
+/**
+ * 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 Spring BigBank server...");
+
+ SCANode2Factory factory = SCANode2Factory.newInstance();
+ SCANode2 node = factory.createSCANodeFromClassLoader("BigBank.composite", BigBankServer.class.getClassLoader());
+ node.start();
+
+ if (timeout < 0) {
+ System.out.println("Press Enter to Exit...");
+ System.in.read();
+ } else {
+ Thread.sleep(timeout);
+ }
+
+ node.stop();
+
+ System.out.println("Bye");
+ }
+}
diff --git a/java/sca/samples/simple-bigbank-spring/src/main/resources/BigBank.composite b/java/sca/samples/simple-bigbank-spring/src/main/resources/BigBank.composite
index a7624235d8..ea2dbc7e1c 100644
--- a/java/sca/samples/simple-bigbank-spring/src/main/resources/BigBank.composite
+++ b/java/sca/samples/simple-bigbank-spring/src/main/resources/BigBank.composite
@@ -33,6 +33,8 @@
<service name="AccountService">
<interface.java interface="bigbank.account.AccountService"/>
+ <tuscany:binding.jsonrpc uri="http://localhost:8085/SpringAccountJSONService"/>
+ <binding.sca/>
</service>
<reference name="savingsAccountService" target="SavingsAccountServiceComponent"/>
@@ -66,5 +68,21 @@
<component name="StockAccountServiceComponent">
<implementation.composite name="bbst:StockAccountDept"/>
</component>
+
+ <component name="AccountFeedComponent">
+ <implementation.java class="bigbank.account.feed.AccountFeedImpl"/>
+ <service name="Collection">
+ <tuscany:binding.rss uri="http://localhost:8085/rss"/>
+ <tuscany:binding.atom uri="http://localhost:8085/atom"/>
+ </service>
+ <reference name="accountService" target="AccountServiceComponent"/>
+ </component>
+
+ <component name="WebResourceComponent">
+ <tuscany:implementation.resource location="web"/>
+ <service name="Resource">
+ <tuscany:binding.http uri="http://localhost:8085/"/>
+ </service>
+ </component>
</composite>
diff --git a/java/sca/samples/simple-bigbank-spring/src/main/resources/web/style.css b/java/sca/samples/simple-bigbank-spring/src/main/resources/web/style.css
new file mode 100644
index 0000000000..1071583264
--- /dev/null
+++ b/java/sca/samples/simple-bigbank-spring/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; }