Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
267 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>springtutorial04</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.springframework.ide.eclipse.core.springbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.springframework.ide.eclipse.core.springnature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
eclipse.preferences.version=1 | ||
encoding//src/main/java=UTF-8 | ||
encoding//src/test/java=UTF-8 | ||
encoding/<project>=UTF-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 | ||
org.eclipse.jdt.core.compiler.compliance=1.5 | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
org.eclipse.jdt.core.compiler.source=1.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
resolveWorkspaceProjects=true | ||
version=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beansProjectDescription> | ||
<version>1</version> | ||
<pluginVersion><![CDATA[3.6.2.201410090854-RELEASE]]></pluginVersion> | ||
<configSuffixes> | ||
<configSuffix><![CDATA[xml]]></configSuffix> | ||
</configSuffixes> | ||
<enableImports><![CDATA[false]]></enableImports> | ||
<configs> | ||
<config>src/main/java/com/livingoncodes/spring/springtutorial/beans/beans.xml</config> | ||
</configs> | ||
<autoconfigs> | ||
</autoconfigs> | ||
<configSets> | ||
</configSets> | ||
</beansProjectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.livingoncodes.spring</groupId> | ||
<artifactId>springtutorial04</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>springtutorial04</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>3.8.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-core</artifactId> | ||
<version>3.2.11.RELEASE</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-beans</artifactId> | ||
<version>3.2.11.RELEASE</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context</artifactId> | ||
<version>3.2.11.RELEASE</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
26 changes: 26 additions & 0 deletions
26
springtutorial21/src/main/java/com/livingoncodes/spring/springtutorial/App.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.livingoncodes.spring.springtutorial; | ||
|
||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.support.ClassPathXmlApplicationContext; | ||
import org.springframework.context.support.FileSystemXmlApplicationContext; | ||
|
||
/** | ||
* Hello world! | ||
* | ||
*/ | ||
public class App | ||
{ | ||
public static void main( String[] args ) | ||
{ | ||
|
||
ApplicationContext context = new ClassPathXmlApplicationContext("com/livingoncodes/spring/springtutorial/beans/beans.xml"); | ||
|
||
Logger logger = (Logger) context.getBean("logger"); | ||
|
||
logger.writeConsole("Hello there"); | ||
logger.writeFile("Hi there"); | ||
|
||
|
||
((ClassPathXmlApplicationContext) context).close(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
springtutorial21/src/main/java/com/livingoncodes/spring/springtutorial/ConsoleWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.livingoncodes.spring.springtutorial; | ||
|
||
public class ConsoleWriter implements LogWriter { | ||
|
||
public void write(String text) { | ||
System.out.println(text); | ||
|
||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
springtutorial21/src/main/java/com/livingoncodes/spring/springtutorial/FileWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.livingoncodes.spring.springtutorial; | ||
|
||
public class FileWriter implements LogWriter { | ||
|
||
public void write(String text) { | ||
System.out.println("Log to file: " + text); | ||
|
||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
springtutorial21/src/main/java/com/livingoncodes/spring/springtutorial/LogWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.livingoncodes.spring.springtutorial; | ||
|
||
public interface LogWriter { | ||
public void write(String text); | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
springtutorial21/src/main/java/com/livingoncodes/spring/springtutorial/Logger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.livingoncodes.spring.springtutorial; | ||
|
||
public class Logger { | ||
|
||
private LogWriter consoleWriter; | ||
private LogWriter fileWriter; | ||
|
||
|
||
public Logger(ConsoleWriter consoleWriter, FileWriter fileWriter) { | ||
this.consoleWriter = consoleWriter; | ||
this.fileWriter = fileWriter; | ||
} | ||
|
||
public LogWriter getConsoleWriter() { | ||
return consoleWriter; | ||
} | ||
|
||
public void setConsoleWriter(LogWriter consoleWriter) { | ||
this.consoleWriter = consoleWriter; | ||
} | ||
|
||
public LogWriter getFileWriter() { | ||
return fileWriter; | ||
} | ||
|
||
public void setFileWriter(LogWriter fileWriter) { | ||
this.fileWriter = fileWriter; | ||
} | ||
|
||
public void writeFile(String text) { | ||
fileWriter.write(text); | ||
} | ||
|
||
public void writeConsole(String text) { | ||
consoleWriter.write(text); | ||
|
||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
springtutorial21/src/main/java/com/livingoncodes/spring/springtutorial/beans/beans.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> | ||
|
||
|
||
<bean name="consoleWriter" class="com.livingoncodes.spring.springtutorial.ConsoleWriter"> | ||
</bean> | ||
|
||
|
||
<bean id="fileWriter" class="com.livingoncodes.spring.springtutorial.FileWriter"> | ||
</bean> | ||
|
||
<bean id="logger" | ||
class="com.livingoncodes.spring.springtutorial.Logger" | ||
autowire="constructor"> | ||
</bean> | ||
</beans> |
38 changes: 38 additions & 0 deletions
38
springtutorial21/src/test/java/com/livingoncodes/spring/springtutorial/AppTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.livingoncodes.spring.springtutorial; | ||
|
||
import junit.framework.Test; | ||
import junit.framework.TestCase; | ||
import junit.framework.TestSuite; | ||
|
||
/** | ||
* Unit test for simple App. | ||
*/ | ||
public class AppTest | ||
extends TestCase | ||
{ | ||
/** | ||
* Create the test case | ||
* | ||
* @param testName name of the test case | ||
*/ | ||
public AppTest( String testName ) | ||
{ | ||
super( testName ); | ||
} | ||
|
||
/** | ||
* @return the suite of tests being tested | ||
*/ | ||
public static Test suite() | ||
{ | ||
return new TestSuite( AppTest.class ); | ||
} | ||
|
||
/** | ||
* Rigourous Test :-) | ||
*/ | ||
public void testApp() | ||
{ | ||
assertTrue( true ); | ||
} | ||
} |