summaryrefslogtreecommitdiffstats
path: root/java/sca-contrib/samples/loanapplication/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/sca-contrib/samples/loanapplication/src')
-rw-r--r--java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanApplication.java36
-rw-r--r--java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanApplicationClient.java37
-rw-r--r--java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanClient.java29
-rw-r--r--java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanClientImpl.java64
-rw-r--r--java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanService.java43
-rw-r--r--java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanServiceImpl.java63
-rw-r--r--java/sca-contrib/samples/loanapplication/src/main/resources/loanapplication.composite34
-rw-r--r--java/sca-contrib/samples/loanapplication/src/test/java/loanapplication/LoanApplicationTestCase.java83
8 files changed, 0 insertions, 389 deletions
diff --git a/java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanApplication.java b/java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanApplication.java
deleted file mode 100644
index 4fedb70782..0000000000
--- a/java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanApplication.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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 loanapplication;
-
-public class LoanApplication {
-
- private String customerName;
- private float loanAmount;
-
- public LoanApplication(String customerName, float loanAmount) {
- this.customerName = customerName;
- this.loanAmount = loanAmount;
- }
-
- @Override
- public String toString() {
- return "[Customer: " + customerName + ", loan amount: "
- + loanAmount + "]";
- }
-}
diff --git a/java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanApplicationClient.java b/java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanApplicationClient.java
deleted file mode 100644
index 5183ece867..0000000000
--- a/java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanApplicationClient.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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 loanapplication;
-
-import org.apache.tuscany.sca.host.embedded.SCADomain;
-
-
-public class LoanApplicationClient {
-
- public static void main(String[] args) throws Exception {
- SCADomain domain = SCADomain.newInstance("loanapplication.composite");
-
- // Locate the MyClient component and invoke it
- LoanClient loanClient = domain.getService(LoanClient.class, "LoanClientComponent");
- loanClient.applyForLoan("John Doe", 1000.0f);
- System.out.println(loanClient.displayLoan());
- System.out.println("Loan approved: " + loanClient.isApproved());
-
- domain.close();
- }
-}
diff --git a/java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanClient.java b/java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanClient.java
deleted file mode 100644
index 7e4438bbff..0000000000
--- a/java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanClient.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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 loanapplication;
-
-public interface LoanClient {
-
- void applyForLoan(String customerName, float amount);
- boolean isApproved();
- boolean isCancelled();
- String displayLoan();
- void cancelLoan();
- void closeLoan();
-}
diff --git a/java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanClientImpl.java b/java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanClientImpl.java
deleted file mode 100644
index 023199b14b..0000000000
--- a/java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanClientImpl.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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 loanapplication;
-
-
-import org.oasisopen.sca.annotation.Reference;
-import org.oasisopen.sca.annotation.Scope;
-
-@Scope("COMPOSITE")
-public class LoanClientImpl implements LoanClient {
-
- private LoanService loanService;
-
- @Reference
- public void setLoanService(LoanService loanService) {
- this.loanService = loanService;
- }
-
- public void applyForLoan(String customerName, float amount) {
- loanService.apply(new LoanApplication(customerName, amount));
- }
-
- public boolean isApproved() {
- if (loanService.getLoanStatus() == null) {
- return false;
- }
- return loanService.getLoanStatus().equals("approved");
- }
-
- public boolean isCancelled() {
- if (loanService.getLoanStatus() == null) {
- return false;
- }
- return loanService.getLoanStatus().equals("cancelled");
- }
-
- public String displayLoan() {
- return loanService.display();
- }
-
- public void cancelLoan() {
- loanService.cancelApplication();
- }
-
- public void closeLoan() {
- loanService.close();
- }
-}
diff --git a/java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanService.java b/java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanService.java
deleted file mode 100644
index 8d16b04caf..0000000000
--- a/java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanService.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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 loanapplication;
-
-import org.oasisopen.sca.annotation.Conversational;
-import org.oasisopen.sca.annotation.EndsConversation;
-import org.oasisopen.sca.annotation.OneWay;
-import org.oasisopen.sca.annotation.Remotable;
-
-@Conversational
-@Remotable
-public interface LoanService {
-
- void apply(LoanApplication application);
-
- void lockCurrentRate(int termInYears);
-
- @OneWay
- void cancelApplication();
-
- String getLoanStatus();
-
- String display();
-
- @EndsConversation
- void close();
-}
diff --git a/java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanServiceImpl.java b/java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanServiceImpl.java
deleted file mode 100644
index a88dc0b56b..0000000000
--- a/java/sca-contrib/samples/loanapplication/src/main/java/loanapplication/LoanServiceImpl.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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 loanapplication;
-
-import org.oasisopen.sca.annotation.AllowsPassByReference;
-import org.oasisopen.sca.annotation.ConversationID;
-import org.oasisopen.sca.annotation.Scope;
-
-@Scope("CONVERSATION")
-@AllowsPassByReference
-public class LoanServiceImpl implements LoanService {
-
- private LoanApplication application;
- private String status;
- private int termLocked = 0;
- @ConversationID
- protected String conversationID;
-
- public void apply(LoanApplication application) {
- this.application = application;
- status = "open";
- }
-
- public void lockCurrentRate(int termInYears) {
- termLocked = termInYears;
- status = "locked";
- }
-
- public void cancelApplication() {
- status = "cancelled";
- }
-
- public String getLoanStatus() {
- return status;
- }
-
- public String display() {
- return "Loan application: " + application + ", term: "
- + termLocked + ", status: " + status
- + ", conversationID: " + conversationID;
- }
-
- public void close() {
- this.application = null;
- this.status = "closed";
- }
-}
diff --git a/java/sca-contrib/samples/loanapplication/src/main/resources/loanapplication.composite b/java/sca-contrib/samples/loanapplication/src/main/resources/loanapplication.composite
deleted file mode 100644
index 3aa8d030b7..0000000000
--- a/java/sca-contrib/samples/loanapplication/src/main/resources/loanapplication.composite
+++ /dev/null
@@ -1,34 +0,0 @@
-<?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"
- targetNamespace="http://loanapplication"
- xmlns:la="http://loanapplication"
- name="loanapplication">
-
- <component name="LoanClientComponent">
- <implementation.java class="loanapplication.LoanClientImpl"/>
- <reference name="loanService" target="LoanServiceComponent"/>
- </component>
-
- <component name="LoanServiceComponent">
- <implementation.java class="loanapplication.LoanServiceImpl"/>
- </component>
-
-</composite>
diff --git a/java/sca-contrib/samples/loanapplication/src/test/java/loanapplication/LoanApplicationTestCase.java b/java/sca-contrib/samples/loanapplication/src/test/java/loanapplication/LoanApplicationTestCase.java
deleted file mode 100644
index e88e48a53a..0000000000
--- a/java/sca-contrib/samples/loanapplication/src/test/java/loanapplication/LoanApplicationTestCase.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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 loanapplication;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sca.host.embedded.SCADomain;
-
-public class LoanApplicationTestCase extends TestCase {
-
- private LoanClient loanClient;
- private SCADomain domain;
-
- @Override
- protected void setUp() throws Exception {
- domain = SCADomain.newInstance("loanapplication.composite");
-
- loanClient = domain.getService(LoanClient.class, "LoanClientComponent");
- }
-
- @Override
- protected void tearDown() throws Exception {
- domain.close();
- }
-
- public void test() throws Exception {
- try {
- loanClient.applyForLoan("John Doe", 1000.0f);
- System.out.println("Applied: " + loanClient.displayLoan());
- System.out.println("Loan approved: " + loanClient.isApproved());
- loanClient.cancelLoan();
- System.out.println("Sleeping to let cancel complete ...");
- Thread.sleep(500);
- if (!loanClient.isCancelled()) {
- fail("Loan should be cancelled");
- }
- System.out.println("Cancelled: " + loanClient.displayLoan());
- loanClient.closeLoan();
-
- /* This is a mistake, after @EndsConversation, a new conversation is
- * started automatically, so we should not get TargetNotFoundException.
- * Keep this for the timeout case, where we should get the exception
- try {
- System.out.println("Trying to use the closed loan in the ended conversation ...");
- System.out.println("Closed: " + loanClient.displayLoan());
- fail("Target should not be found");
- } catch(TargetNotFoundException e) {
- System.out.println("Target not found as expected");
- }
- */
-
- // Now check that a new conversation's loan is not cancelled
-
- if (loanClient.isCancelled()) {
- fail("Loan should not be cancelled");
- }
- } catch(Throwable e) {
- e.printStackTrace();
- if (e instanceof Exception) {
- throw (Exception)e;
- }
- if (e instanceof Error) {
- throw (Error)e;
- }
- }
- }
-}