summaryrefslogtreecommitdiffstats
path: root/tags/java/sca/1.5.1/samples/loanapplication/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java/sca/1.5.1/samples/loanapplication/src/main/java')
-rw-r--r--tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanApplication.java36
-rw-r--r--tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanApplicationClient.java37
-rw-r--r--tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanClient.java29
-rw-r--r--tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanClientImpl.java64
-rw-r--r--tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanService.java43
-rw-r--r--tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanServiceImpl.java63
6 files changed, 272 insertions, 0 deletions
diff --git a/tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanApplication.java b/tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanApplication.java
new file mode 100644
index 0000000000..4fedb70782
--- /dev/null
+++ b/tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanApplication.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 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/tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanApplicationClient.java b/tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanApplicationClient.java
new file mode 100644
index 0000000000..5183ece867
--- /dev/null
+++ b/tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanApplicationClient.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 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/tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanClient.java b/tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanClient.java
new file mode 100644
index 0000000000..7e4438bbff
--- /dev/null
+++ b/tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanClient.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 loanapplication;
+
+public interface LoanClient {
+
+ void applyForLoan(String customerName, float amount);
+ boolean isApproved();
+ boolean isCancelled();
+ String displayLoan();
+ void cancelLoan();
+ void closeLoan();
+}
diff --git a/tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanClientImpl.java b/tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanClientImpl.java
new file mode 100644
index 0000000000..b06d9465a2
--- /dev/null
+++ b/tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanClientImpl.java
@@ -0,0 +1,64 @@
+/*
+ * 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.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.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/tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanService.java b/tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanService.java
new file mode 100644
index 0000000000..9dfd8b42fe
--- /dev/null
+++ b/tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanService.java
@@ -0,0 +1,43 @@
+/*
+ * 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.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.EndsConversation;
+import org.osoa.sca.annotations.OneWay;
+import org.osoa.sca.annotations.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/tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanServiceImpl.java b/tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanServiceImpl.java
new file mode 100644
index 0000000000..76a53323bd
--- /dev/null
+++ b/tags/java/sca/1.5.1/samples/loanapplication/src/main/java/loanapplication/LoanServiceImpl.java
@@ -0,0 +1,63 @@
+/*
+ * 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.osoa.sca.annotations.AllowsPassByReference;
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.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";
+ }
+}