From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../integration/loanratesejb/LoanRates.java | 9 +++++ .../integration/loanratesejb/LoanRatesBean.java | 46 ++++++++++++++++++++++ .../integration/loanratesejb/LoanRatesClient.java | 18 +++++++++ 3 files changed, 73 insertions(+) create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRates.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRatesBean.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRatesClient.java (limited to 'Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb') diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRates.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRates.java new file mode 100644 index 0000000..39efddd --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRates.java @@ -0,0 +1,9 @@ +package examples.integration.loanratesejb; + +public interface LoanRates{ + + public float getHomeEquityRate(); +} + + + diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRatesBean.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRatesBean.java new file mode 100644 index 0000000..f01f25e --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRatesBean.java @@ -0,0 +1,46 @@ +package examples.integration.loanratesejb; + +import javax.resource.cci.*; + +import javax.ejb.Stateless; +import javax.ejb.Remote; +import javax.ejb.TransactionManagement; +import javax.ejb.TransactionManagementType; +import javax.annotation.*; + +@Stateless +@Remote(LoanRates.class) +@TransactionManagement(TransactionManagementType.BEAN) +public class LoanRatesBean implements LoanRates{ + + @Resource (name="OutboundLoanJNDIName") + public javax.resource.cci.ConnectionFactory connFactory; + + public float getHomeEquityRate() { + float retVal=0; + + System.out.println("LoanRatesBean.getHomeEquityRate() called"); + + try { + javax.resource.cci.Connection myCon = connFactory.getConnection(); + javax.resource.cci.Interaction interaction = myCon.createInteraction(); + javax.resource.cci.MappedRecord recordIn = connFactory.getRecordFactory().createMappedRecord(""); + + recordIn.put("HomeEquityRate",""); + + javax.resource.cci.MappedRecord recordOut = + (javax.resource.cci.MappedRecord)interaction.execute(null, (javax.resource.cci.Record)recordIn); + + myCon.close(); + + Object result = recordOut.get("HomeEquityRate"); + retVal = ((Float)result).floatValue(); + + } catch(Exception e) { + + e.printStackTrace(); + } + + return retVal; + } +} \ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRatesClient.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRatesClient.java new file mode 100644 index 0000000..8a10952 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRatesClient.java @@ -0,0 +1,18 @@ +package examples.integration.loanratesejb; + +import javax.naming.Context; +import javax.naming.InitialContext; +import java.util.Hashtable; +import javax.naming.*; + +public class LoanRatesClient { + + public static void main(String[] args) throws Exception{ + + Context ctx = new InitialContext(); + + LoanRates loanRates = (LoanRates) ctx.lookup("examples.integration.loanratesejb.LoanRates"); + + System.out.println("getHomeEquityRate() returned: " + loanRates.getHomeEquityRate() + ". Take a look at application server log or console for messages from LoanRatesEJB and OutboundLoanRA."); + } +} \ No newline at end of file -- cgit v1.2.3