Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Apress committed Oct 13, 2016
0 parents commit 1972a94
Show file tree
Hide file tree
Showing 126 changed files with 3,902 additions and 0 deletions.
Binary file added 4164.pdf
Binary file not shown.
Binary file added 4165.pdf
Binary file not shown.
Binary file added 9781430216247.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
625 changes: 625 additions & 0 deletions Chapter09/springbank/Spring Bank.jmx

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions Chapter09/springbank/build.xml
@@ -0,0 +1,15 @@
<?xml version="1.0"?>

<project name="springbank" default="dist">

<property file="build.properties"/>
<property file="project.properties"/>
<property file="${common.build.dir}/build.properties"/>
<property file="${common.build.dir}/project.properties"/>
<property file="${user.home}/build.properties"/>

<property name="build.web" value="true"/>

<import file="${common.build.dir}/common-targets.xml"/>

</project>
34 changes: 34 additions & 0 deletions Chapter09/springbank/ivy.xml
@@ -0,0 +1,34 @@
<ivy-module version="1.1">
<info organisation="com.ervacon" module="springbank"/>

<configurations>
<conf name="global" visibility="private"/>
<conf name="buildtime" visibility="private"/>
<conf name="test" visibility="private"/>

<conf name="default" extends="global"/>
</configurations>

<dependencies defaultconf="global->default">
<!-- buildtime dependencies -->
<dependency org="javax.servlet" name="servlet-api" rev="2.4" conf="buildtime->default" />

<!-- global dependencies -->
<dependency org="log4j" name="log4j" rev="1.2.14"/>
<dependency org="taglibs" name="standard" rev="1.1.2"/>
<dependency org="jstl" name="jstl" rev="1.1.2"/>
<dependency org="opensymphony" name="sitemesh" rev="2.3"/>
<dependency org="displaytag" name="displaytag" rev="1.1"/>
<dependency org="commons-beanutils" name="commons-beanutils" rev="1.7.0"/>
<dependency org="commons-lang" name="commons-lang" rev="2.4"/>
<dependency org="commons-collections" name="commons-collections" rev="3.2.1"/>
<dependency org="com.lowagie" name="itext" rev="1.4.8"/>
<dependency org="org.springframework" name="spring-webflow" rev="1.0.5"/>
<dependency org="org.springframework.security" name="spring-security-core" rev="2.0.3"/>
<dependency org="org.springframework" name="spring-aop" rev="2.0.7"/>

<!-- test-time only dependencies -->
<dependency org="junit" name="junit" rev="3.8.2" conf="test->default"/>
<dependency org="org.easymock" name="easymock" rev="2.2" conf="test->default" />
</dependencies>
</ivy-module>
13 changes: 13 additions & 0 deletions Chapter09/springbank/project.properties
@@ -0,0 +1,13 @@
# properties defined in this file are overridable by a local build.properties in this project dir

# The location of the common build system
common.build.dir=C:/java/spring-webflow-1.0.5/projects/common-build

# Do not publish built artifacts to the integration repository
do.publish=false

javac.source=1.5
javac.target=1.5

project.name=springbank
project.webapp.name=springbank
@@ -0,0 +1,36 @@
package com.ervacon.springbank.domain;

import java.io.Serializable;
import java.math.BigDecimal;

public abstract class Account implements Serializable {

private AccountNumber number;
private BigDecimal balance = new BigDecimal(0);

public AccountNumber getNumber() {
return number;
}

protected void setNumber(AccountNumber number) {
this.number = number;
}

public BigDecimal getBalance() {
return balance;
}

protected void setBalance(BigDecimal balance) {
this.balance = balance;
}

public boolean empty() {
return balance.compareTo(new BigDecimal(0)) == 0;
}

public abstract void debit(Transaction transaction);

public abstract void credit(Transaction transaction);

public abstract AccountHolder getHolder();
}
@@ -0,0 +1,26 @@
package com.ervacon.springbank.domain;

import java.io.Serializable;

public class AccountHolder implements Serializable {

private String name;

private Address address = new Address();

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Address getAddress() {
return address;
}

public void setAddress(Address address) {
this.address = address;
}
}
@@ -0,0 +1,36 @@
package com.ervacon.springbank.domain;

import java.io.Serializable;

import org.springframework.util.Assert;

public class AccountNumber implements Serializable {

private String number;

public AccountNumber(String number) {
Assert.hasText(number, "The account number cannot be blank");
this.number = number;
}

@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj == this) return true;
if (obj.getClass().equals(this.getClass())) {
AccountNumber other = (AccountNumber)obj;
return this.number.equals(other.number);
}
return false;
}

@Override
public int hashCode() {
return number.hashCode();
}

@Override
public String toString() {
return number;
}
}
@@ -0,0 +1,16 @@
package com.ervacon.springbank.domain;

import java.beans.PropertyEditorSupport;

import org.springframework.util.StringUtils;

public class AccountNumberEditor extends PropertyEditorSupport {

public void setAsText(String text) throws IllegalArgumentException {
setValue(StringUtils.hasText(text) ? new AccountNumber(text) : null);
}

public String getAsText() {
return getValue() == null ? "" : getValue().toString();
}
}
@@ -0,0 +1,19 @@
package com.ervacon.springbank.domain;

import java.util.List;

public interface AccountRepository {

public AccountNumber openAccount(Long clientId);
public void closeAccount(AccountNumber accountNumber);

public List<Account> getAccounts(Long clientId);
public Account getAccount(AccountNumber accountNumber);
public Account getAccount(String accountNumber);

public List<Entry> getAccountEntries(AccountNumber accountNumber);

public List<Account> getBeneficiaries(Long clientId);
public void addBeneficiary(Long clientId, Account beneficiary);
public void removeBeneficiary(Long clientId, AccountNumber accountNumber);
}
@@ -0,0 +1,53 @@
package com.ervacon.springbank.domain;

import java.io.Serializable;

public class Address implements Serializable {

private String street;
private String poBox;
private String zipCode;
private String city;

public Address() {
}

public Address(String street, String poBox, String zipCode, String city) {
this.street = street;
this.poBox = poBox;
this.zipCode = zipCode;
this.city = city;
}

public String getStreet() {
return street;
}

public void setStreet(String street) {
this.street = street;
}

public String getPoBox() {
return poBox;
}

public void setPoBox(String poBox) {
this.poBox = poBox;
}

public String getZipCode() {
return zipCode;
}

public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}

public String getCity() {
return city;
}

public void setCity(String city) {
this.city = city;
}
}
@@ -0,0 +1,36 @@
package com.ervacon.springbank.domain;

public class Beneficiary extends Account {

AccountHolder holder = new AccountHolder();

public Beneficiary() {
}

public Beneficiary(String name, String accountNumber) {
this(name, new Address(), accountNumber);
}

public Beneficiary(String name, Address address, String accountNumber) {
holder.setName(name);
holder.setAddress(address);
setNumber(new AccountNumber(accountNumber));
}

public void setNumber(AccountNumber number) {
super.setNumber(number);
}

public void debit(Transaction transaction) {
// communicate with other bank
}

public void credit(Transaction transaction) {
// communicate with other bank
}

public AccountHolder getHolder() {
return holder;
}

}
@@ -0,0 +1,60 @@
package com.ervacon.springbank.domain;

import java.io.Serializable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

public class Client implements Serializable {

private long clientId;
private String firstName;
private String lastName;
private Address address;
private Set<AccountNumber> accountNumbers = new HashSet<AccountNumber>();

public Client(String firstName, String lastName, Address address) {
this.firstName = firstName;
this.lastName = lastName;
this.address = address;
}

public Client(long clientId, String firstName, String lastName, Address address) {
this.clientId = clientId;
this.firstName = firstName;
this.lastName = lastName;
this.address = address;
}

public long getClientId() {
return clientId;
}

public String getFirstName() {
return firstName;
}

public String getLastName() {
return lastName;
}

public String getDisplayName() {
return firstName + " " + lastName;
}

public Address getAddress() {
return address;
}

public Set<AccountNumber> getAccountNumbers() {
return Collections.unmodifiableSet(accountNumbers);
}

protected void addAccountNumber(AccountNumber number) {
accountNumbers.add(number);
}

protected void removeAccountNumber(AccountNumber number) {
accountNumbers.remove(number);
}
}
@@ -0,0 +1,9 @@
package com.ervacon.springbank.domain;

public interface ClientRepository {

public Client createClient(Client clientData);

public Client getClient(long clientId);

}
@@ -0,0 +1,28 @@
package com.ervacon.springbank.domain;

import java.math.BigDecimal;
import java.util.Date;

public class Deposit extends Transaction {

private Account creditAccount;

public Deposit(BigDecimal amount, String message, Account creditAccount) {
setDate(new Date());
setAmount(amount);
setMessage(message);
this.creditAccount = creditAccount;
}

public Deposit(double amount, String message, Account creditAccount) {
this(new BigDecimal(amount), message, creditAccount);
}

public Account getCreditAccount() {
return creditAccount;
}

public void execute() {
creditAccount.credit(this);
}
}

0 comments on commit 1972a94

Please sign in to comment.