Skip to content

Commit be980cd

Browse files
committed
adding examples for Chapter 4 & 5
1 parent 16f467f commit be980cd

File tree

268 files changed

+6158
-3046
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

268 files changed

+6158
-3046
lines changed

.metadata/.log

Lines changed: 1778 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:c="http://www.springframework.org/schema/c"
5+
xmlns:context="http://www.springframework.org/schema/context"
6+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
7+
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
8+
9+
<context:annotation-config/>
10+
11+
<bean id="transferService" class="com.packt.patterninspring.chapter5.bankapp.service.TransferService">
12+
<constructor-arg ref="accountRepository"/>
13+
</bean>
14+
<bean id="accountRepository" class="com.packt.patterninspring.chapter5.bankapp.repository.JdbcAccountRepository"/>
15+
</beans>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.packt.patterninspring.chapter5.bankapp.service;
2+
3+
import com.packt.patterninspring.chapter4.bankapp.repository.IAccountRepository;
4+
5+
/**
6+
* @author Dinesh Rajput
7+
*
8+
*/
9+
public class TransferService {
10+
11+
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
package com.packt.patterninspring.chapter3.bankapp.config;
1+
package com.packt.patterninspring.chapter5.bankapp.config;
22

33
import org.springframework.context.annotation.ComponentScan;
44
import org.springframework.context.annotation.Configuration;
55

6+
/**
7+
* @author Dinesh.Rajput
8+
*
9+
*/
610
@Configuration
7-
@ComponentScan
11+
@ComponentScan("com.packt.patterninspring.chapter5.bankapp")
812
public class AppConfig {
9-
13+
1014
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.packt.patterninspring.chapter5.bankapp.repository;
2+
3+
import org.springframework.stereotype.Repository;
4+
5+
import com.packt.patterninspring.chapter5.bankapp.model.Account;
6+
import com.packt.patterninspring.chapter5.bankapp.model.Amount;
7+
import com.packt.patterninspring.chapter5.bankapp.repository.AccountRepository;
8+
@Repository
9+
public class JdbcAccountRepository implements AccountRepository {
10+
11+
@Override
12+
public Account findByAccountId(Long accountId) {
13+
return new Account(accountId, "Arnav Rajput", new Amount(3000.0));
14+
}
15+
16+
void populateCache(){
17+
System.out.println("Called populateCache() method");
18+
}
19+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.8
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
*
3+
*/
4+
package com.doj.app.test;
5+
6+
import org.springframework.context.ConfigurableApplicationContext;
7+
import org.springframework.context.support.ClassPathXmlApplicationContext;
8+
9+
import com.doj.app.bean.MyBean;
10+
11+
/**
12+
* @author Dinesh.Rajput
13+
*
14+
*/
15+
public class Main {
16+
/**
17+
* @param args
18+
*/
19+
public static void main(String[] args) {
20+
ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
21+
MyBean myBean = applicationContext.getBean(MyBean.class);
22+
System.out.println(myBean.getName());
23+
System.out.println("All registered Scopes are : ");
24+
for(String scope : applicationContext.getBeanFactory().getRegisteredScopeNames()){
25+
System.out.println(scope);
26+
}
27+
applicationContext.close();
28+
}
29+
30+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.packt.patterninspring.chapter5.bankapp.repository;
2+
3+
import com.packt.patterninspring.chapter3.bankapp.model.Account;
4+
import com.packt.patterninspring.chapter3.bankapp.model.Amount;
5+
6+
public interface TransferRepository {
7+
8+
void transfer(Account accountA, Account accountB, Amount amount);
9+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
*
3+
*/
4+
package com.packt.patterninspring.chapter5.bankapp.bean;
5+
6+
/**
7+
* @author Dinesh.Rajput
8+
*
9+
*/
10+
11+
public class MyBean {
12+
String name;
13+
14+
public String getName() {
15+
return name;
16+
}
17+
18+
public void setName(String name) {
19+
this.name = name;
20+
}
21+
22+
}

.metadata/.plugins/org.eclipse.core.resources/.history/29/b06188f30d58001715c2dd0dc1a02b70

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)