Skip to content

Commit

Permalink
Autowire
Browse files Browse the repository at this point in the history
  • Loading branch information
Telusko authored and Telusko committed Aug 30, 2019
1 parent 65c9480 commit 114b8f9
Show file tree
Hide file tree
Showing 24 changed files with 333 additions and 0 deletions.
27 changes: 27 additions & 0 deletions 10 SpringDemo/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?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"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<attributes>
<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="output" path="target/classes"/>
</classpath>
34 changes: 34 additions & 0 deletions 10 SpringDemo/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>10 SpringDemo</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>
<buildCommand>
<name>org.springframework.ide.eclipse.boot.validation.springbootbuilder</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>
4 changes: 4 additions & 0 deletions 10 SpringDemo/.settings/org.eclipse.core.resources.prefs
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
8 changes: 8 additions & 0 deletions 10 SpringDemo/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.5
4 changes: 4 additions & 0 deletions 10 SpringDemo/.settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
15 changes: 15 additions & 0 deletions 10 SpringDemo/.springBeans
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<beansProjectDescription>
<version>1</version>
<pluginVersion><![CDATA[3.9.9.201906180643-RELEASE]]></pluginVersion>
<configSuffixes>
<configSuffix><![CDATA[xml]]></configSuffix>
</configSuffixes>
<enableImports><![CDATA[false]]></enableImports>
<configs>
</configs>
<autoconfigs>
</autoconfigs>
<configSets>
</configSets>
</beansProjectDescription>
34 changes: 34 additions & 0 deletions 10 SpringDemo/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<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.telusko</groupId>
<artifactId>SpringDemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>SpringDemo</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>

<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.1.3.RELEASE</version>
</dependency>


</dependencies>
</project>
40 changes: 40 additions & 0 deletions 10 SpringDemo/src/main/java/com/telusko/SpringDemo/Alien.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.telusko.SpringDemo;

public class Alien
{
private int age;
private Computer com;

public Alien() {
System.out.println("Alien Object Created..");
}



public Computer getCom() {
return com;
}



public void setCom(Computer com) {
this.com = com;
}



public int getAge() {
return age;
}
public void setAge(int age) {
System.out.println("Age Assigned");
this.age = age;
}


public void code()
{
System.out.println("Im Coding..");
com.compile();
}
}
21 changes: 21 additions & 0 deletions 10 SpringDemo/src/main/java/com/telusko/SpringDemo/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.telusko.SpringDemo;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App
{
public static void main( String[] args )
{

ApplicationContext factory = new ClassPathXmlApplicationContext("spring.xml");

Alien obj1 = (Alien)factory.getBean("alien");
obj1.code();

System.out.println(obj1.getAge());



}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.telusko.SpringDemo;

public interface Computer
{
void compile();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.telusko.SpringDemo;

public class Desktop implements Computer
{
public void compile()
{
System.out.println("Code Compiled in a Desktop");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.telusko.SpringDemo;

public class Laptop implements Computer
{
public void compile()
{
System.out.println("Code Compiled in a Laptop");
}
}
19 changes: 19 additions & 0 deletions 10 SpringDemo/src/main/java/spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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 id="alien" class="com.telusko.SpringDemo.Alien" autowire="byType">
<property name="age" value="10"></property>

</bean>

<bean id="com" class="com.telusko.SpringDemo.Laptop">

</bean>

<bean id="desktop" class="com.telusko.SpringDemo.Desktop">

</bean>

</beans>
38 changes: 38 additions & 0 deletions 10 SpringDemo/src/test/java/com/telusko/SpringDemo/AppTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.telusko.SpringDemo;

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 );
}
}
5 changes: 5 additions & 0 deletions 10 SpringDemo/target/classes/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Manifest-Version: 1.0
Built-By: Telusko
Build-Jdk: 12.0.2
Created-By: Maven Integration for Eclipse

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#Generated by Maven Integration for Eclipse
#Fri Aug 30 15:30:02 IST 2019
m2e.projectLocation=C\:\\Users\\Telusko\\Desktop\\Spring Course udemy\\Course\\Autowire_17\\SpringDemo
m2e.projectName=10 SpringDemo
groupId=com.telusko
artifactId=SpringDemo
version=0.0.1-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<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.telusko</groupId>
<artifactId>SpringDemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>SpringDemo</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>

<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.1.3.RELEASE</version>
</dependency>


</dependencies>
</project>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
19 changes: 19 additions & 0 deletions 10 SpringDemo/target/classes/spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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 id="alien" class="com.telusko.SpringDemo.Alien" autowire="byType">
<property name="age" value="10"></property>

</bean>

<bean id="com" class="com.telusko.SpringDemo.Laptop">

</bean>

<bean id="desktop" class="com.telusko.SpringDemo.Desktop">

</bean>

</beans>
Binary file not shown.

0 comments on commit 114b8f9

Please sign in to comment.