diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-12 21:54:50 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-12 21:54:50 +0000 |
commit | d232b6a46e4225ff35a0123a5f5597da7592fc38 (patch) | |
tree | 0c607d86a472ccbdd5587eb3ae53f535b6aa36f2 /branches/sca-equinox/demos/bigbank/src | |
parent | 2e48ecc0ea43d7b859c578080c72e4c739717487 (diff) |
Creating a branch for the equinox work.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@694816 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-equinox/demos/bigbank/src')
17 files changed, 922 insertions, 0 deletions
diff --git a/branches/sca-equinox/demos/bigbank/src/main/java/bigbank/account/AccountService.java b/branches/sca-equinox/demos/bigbank/src/main/java/bigbank/account/AccountService.java new file mode 100644 index 0000000000..2cb8027874 --- /dev/null +++ b/branches/sca-equinox/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-equinox/demos/bigbank/src/main/java/bigbank/account/AccountServiceImpl.java b/branches/sca-equinox/demos/bigbank/src/main/java/bigbank/account/AccountServiceImpl.java new file mode 100644 index 0000000000..4f0e3879dc --- /dev/null +++ b/branches/sca-equinox/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-equinox/demos/bigbank/src/main/java/bigbank/account/feed/AccountFeedImpl.java b/branches/sca-equinox/demos/bigbank/src/main/java/bigbank/account/feed/AccountFeedImpl.java new file mode 100644 index 0000000000..13d79a9c33 --- /dev/null +++ b/branches/sca-equinox/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<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 + 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<String, String>[] query(String queryString) { + return null; + } +} diff --git a/branches/sca-equinox/demos/bigbank/src/main/java/bigbank/client/BigBankClient.java b/branches/sca-equinox/demos/bigbank/src/main/java/bigbank/client/BigBankClient.java new file mode 100644 index 0000000000..a7fa5ecc22 --- /dev/null +++ b/branches/sca-equinox/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-equinox/demos/bigbank/src/main/java/bigbank/demo/BigBankServer.java b/branches/sca-equinox/demos/bigbank/src/main/java/bigbank/demo/BigBankServer.java new file mode 100644 index 0000000000..05360e07a5 --- /dev/null +++ b/branches/sca-equinox/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-equinox/demos/bigbank/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java b/branches/sca-equinox/demos/bigbank/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java new file mode 100644 index 0000000000..6d3b547939 --- /dev/null +++ b/branches/sca-equinox/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-equinox/demos/bigbank/src/main/java/calculator/CalculatorService.java b/branches/sca-equinox/demos/bigbank/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..c89043276e --- /dev/null +++ b/branches/sca-equinox/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-equinox/demos/bigbank/src/main/java/stockquote/StockQuoteService.java b/branches/sca-equinox/demos/bigbank/src/main/java/stockquote/StockQuoteService.java new file mode 100644 index 0000000000..749b8ee2f4 --- /dev/null +++ b/branches/sca-equinox/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-equinox/demos/bigbank/src/main/resources/BigBank.composite b/branches/sca-equinox/demos/bigbank/src/main/resources/BigBank.composite new file mode 100644 index 0000000000..11591308b4 --- /dev/null +++ b/branches/sca-equinox/demos/bigbank/src/main/resources/BigBank.composite @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" + xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" + targetNamespace="http://bigbank" + xmlns:bb="http://bigbank" + xmlns:bbsv="http://bigbank/savings" + xmlns:bbst="http://bigbank/stock" + xmlns:bbck="http://bigbank/checkings" + name="BigBank"> + + <component name="AccountServiceComponent"> + <implementation.java class="bigbank.account.AccountServiceImpl"/> + + <service name="AccountService"> + <tuscany:binding.jsonrpc uri="http://localhost:8085/AccountJSONService"/> + <binding.ws wsdlElement="http://bigbank#wsdl.port(AccountService/AccountServiceSoap)"/> + <binding.sca/> + </service> + + <reference name="savingsAcService" target="SavingsAccountServiceComponent"/> + + <reference name="checkingAcService" requires="authentication"> + <binding.ws uri="http://localhost:8085/services/CheckingAcWebService"/> + </reference> + + <reference name="stockAcService" target="StockAccountServiceComponent"/> + + <reference name="calculatorService"> + <tuscany:binding.rmi host="localhost" port="8099" serviceName="CalculatorRMIService"/> + </reference> + <reference name="stockQuoteService" requires="integrity"> + <binding.ws uri="http://localhost:8081/services/StockQuoteWebService"/> + </reference> + + <property name="currency">EURO</property> + </component> + + <component name="SavingsAccountServiceComponent"> + <implementation.composite name="bbsv:SavingsAccountDept"/> + </component> + + <component name="CheckingAccountServiceComponent"> + <implementation.composite name="bbck:CheckingsAccountDept"/> + </component> + + <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/branches/sca-equinox/demos/bigbank/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-equinox/demos/bigbank/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..154992c843 --- /dev/null +++ b/branches/sca-equinox/demos/bigbank/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0" + xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" + targetNamespace="http://bigbank" + xmlns:bb="http://bigbank"> + + <deployable composite="bb:BigBank"/> + + <import.java package="bigbank.account.checking"/> + <import.java package="bigbank.account.savings"/> + <import.java package="bigbank.account.stock"/> + + <import namespace="http://bigbank/checkings"/> + <import namespace="http://bigbank/savings"/> + <import namespace="http://bigbank/stock"/> + + <import.resource uri="definitions.xml"/> +</contribution>
\ No newline at end of file diff --git a/branches/sca-equinox/demos/bigbank/src/main/resources/bigbank.jks b/branches/sca-equinox/demos/bigbank/src/main/resources/bigbank.jks Binary files differnew file mode 100644 index 0000000000..e6294d85f7 --- /dev/null +++ b/branches/sca-equinox/demos/bigbank/src/main/resources/bigbank.jks diff --git a/branches/sca-equinox/demos/bigbank/src/main/resources/definitions.xml b/branches/sca-equinox/demos/bigbank/src/main/resources/definitions.xml new file mode 100644 index 0000000000..8654151d82 --- /dev/null +++ b/branches/sca-equinox/demos/bigbank/src/main/resources/definitions.xml @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="ASCII"?> +<!-- + * 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. +--> +<sca:definitions xmlns="http://www.osoa.org/xmlns/sca/1.0" + targetNamespace="http://bigbank" + xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" + xmlns:chk="http://bigbank/checkings" + xmlns:bb="http://bigbank"> + + <!-- WS Security POLICY SETS --> + <sca:policySet name="wsIntegrityPolicy" + provides="integrity" + appliesTo="sca:binding.ws"> + <tuscany:wsConfigParam> + <parameter name="InflowSecurity"> + <action> + <items>Timestamp Signature</items> + <signaturePropFile>security.properties</signaturePropFile> + </action> + </parameter> + <parameter name="OutflowSecurity"> + <action> + <items>Timestamp Signature</items> + <user>bbservice</user> + <signaturePropFile>security.properties</signaturePropFile> + <passwordCallbackClass>bigbank.security.BigbankPasswordCallbackHandler</passwordCallbackClass> + <signatureKeyIdentifier>DirectReference</signatureKeyIdentifier> + </action> + </parameter> + </tuscany:wsConfigParam> + </sca:policySet> + + <sca:policySet name="wsClientAuthenticationPolicy" + provides="authentication" + appliesTo="sca:reference/sca:binding.ws"> + <tuscany:wsConfigParam> + <parameter name="OutflowSecurity"> + <action> + <items>UsernameToken</items> + <user>bbaservice</user> + <passwordCallbackClass>bigbank.security.BigbankPasswordCallbackHandler</passwordCallbackClass> + <passwordType>PasswordText</passwordType> + </action> + </parameter> + </tuscany:wsConfigParam> + </sca:policySet> +</sca:definitions>
\ No newline at end of file diff --git a/branches/sca-equinox/demos/bigbank/src/main/resources/security.properties b/branches/sca-equinox/demos/bigbank/src/main/resources/security.properties new file mode 100644 index 0000000000..762d0523d9 --- /dev/null +++ b/branches/sca-equinox/demos/bigbank/src/main/resources/security.properties @@ -0,0 +1,4 @@ +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
\ No newline at end of file diff --git a/branches/sca-equinox/demos/bigbank/src/main/resources/web/AccountJSON.html b/branches/sca-equinox/demos/bigbank/src/main/resources/web/AccountJSON.html new file mode 100644 index 0000000000..9f4368443f --- /dev/null +++ b/branches/sca-equinox/demos/bigbank/src/main/resources/web/AccountJSON.html @@ -0,0 +1,92 @@ +<html> +<!-- + * 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. + --> +<head> +<title>Tuscany JSON-RPC BigBank Client</TITLE> + +<script type="text/javascript"> + var djConfig = {isDebug: true,debugContainerId: "dojoDebug" }; + djConfig.usePlainJson=true ; + //djConfig.debugAtAllCosts = true; + </script> +<script type="text/javascript" src="dojo/dojo/dojo.js"> + </script> +<script type="text/javascript" src="dojo/dijit/dijit.js"> + </script> + +<script type="text/javascript"> + dojo.require("dijit.form.Button"); + dojo.require("dojo.rpc.JsonService"); + </script> + +<link rel="stylesheet" type="text/css" href="style.css" /> +</head> + +<body> + +<table> + <tr> + <th colspan="2">Tuscany JSON-RPC BigBank Client</th> + </tr> + <tr> + <td colspan="2"> + <p>This example uses the <a href="http://dojotoolkit.org/">Dojo + Toolkit</a> to create a JavaScript object <code>accountService</code> for + the service at <b>http://localhost:8080/AccountJSONService</b> using <a + href="http://manual.dojotoolkit.org/WikiHome/DojoDotBook/Book9">Dojo's + RPC classes</a> and providing them with <a href="AccountJSONService?smd">http://localhost:8080/AccountJSONService?smd</a> + for <a href="http://dojo.jot.com/SMD">Simple Method Description + (SMD)</a> input.</p> + <p>It then creates a Dojo button that will envoke the <code>getAccountReport</code> + method of the <code>accountService</code> object.</p> + </tr> + <tr> + <td>Request</td> + <td>Response</td> + </tr> + <tr> + <td><br> + <button id="myaccount" dojoType="dijit.form.Button" + onClick='accountService.getAccountReport("Customer_01").addCallback(contentCallBack);'>getAccountReport("Customer_01")</button> + <br> + </td> + <td> + <div id="ReturnedContent">None Yet.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div id="dojoDebug">Dojo Debug:</div> + </td> + </tr> +</table> + +<script type="text/javascript"> + + function contentCallBack(result) { + var handlerNode = document.getElementById("ReturnedContent"); + handlerNode.innerHTML = "<p>" + result + "</p>" ; + } + + var accountService = new dojo.rpc.JsonService("AccountJSONService?smd"); + + </script> + +</body> +</html> diff --git a/branches/sca-equinox/demos/bigbank/src/main/resources/web/style.css b/branches/sca-equinox/demos/bigbank/src/main/resources/web/style.css new file mode 100644 index 0000000000..1071583264 --- /dev/null +++ b/branches/sca-equinox/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-equinox/demos/bigbank/src/main/resources/wsdl/AccountService.wsdl b/branches/sca-equinox/demos/bigbank/src/main/resources/wsdl/AccountService.wsdl new file mode 100644 index 0000000000..ac4d987a57 --- /dev/null +++ b/branches/sca-equinox/demos/bigbank/src/main/resources/wsdl/AccountService.wsdl @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> + +<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:tns="http://bigbank" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://bigbank" + name="AccountService"> + + <wsdl:types> + <xsd:schema + targetNamespace="http://bigbank" + xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <xsd:element name="getAccountReport"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="customerID" type="xsd:string" /> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + + <xsd:element name="getAccountReportResponse"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="balance" type="xsd:double" /> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + + </xsd:schema> + </wsdl:types> + + <wsdl:message name="getAccountReportRequest"> + <wsdl:part element="tns:getAccountReport" + name="getAccountReportRequest" /> + </wsdl:message> + + <wsdl:message name="getAccountReportResponse"> + <wsdl:part element="tns:getAccountReportResponse" + name="getAccountReportResponse" /> + </wsdl:message> + + <wsdl:portType name="AccountService"> + <wsdl:operation name="getAccountReport"> + <wsdl:input message="tns:getAccountReportRequest" /> + <wsdl:output message="tns:getAccountReportResponse" /> + </wsdl:operation> + </wsdl:portType> + + <wsdl:binding name="AccountServiceSoap" type="tns:AccountService"> + <soap:binding style="document" + transport="http://schemas.xmlsoap.org/soap/http" /> + <wsdl:operation name="getAccountReport"> + <soap:operation + soapAction="" /> + <wsdl:input> + <soap:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + + <wsdl:service name="AccountService"> + <wsdl:port binding="tns:AccountServiceSoap" + name="AccountServiceSoap"> + <soap:address + location="http://localhost:8082/services/AccountWebService" /> + </wsdl:port> + </wsdl:service> +</wsdl:definitions> diff --git a/branches/sca-equinox/demos/bigbank/src/test/java/test/BigBankTestCase.java b/branches/sca-equinox/demos/bigbank/src/test/java/test/BigBankTestCase.java new file mode 100644 index 0000000000..3b7c5ef2ad --- /dev/null +++ b/branches/sca-equinox/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"}); + } +} |