Spring Tightly Coupled Application Example
Contest.java
package com.jtc;
public interface Contest {
public String promptQuestion();
}
package com.jtc;
public class StrutsContest implements Contest {
@Override
public String promptQuestion() {
return "Who invented Struts?";
}
}
package com.jtc;
public class SpringContest implements Contest {
@Override
public String promptQuestion() {
return "Who invented Spring?";
}
}
package com.jtc;
public class ContestService {
//here you need to create the object for which class.
private Contest contest = new StrutsContest();
public void askQuestion() {
System.out.println(contest.promptQuestion());
}
}
package com.jtc;
public class ContestApplication {
public static void main(String[] args) {
ContestService contestService = new ContestService();
contestService.askQuestion();
}
}
nblibraries.properties
org.springframework.beans-3.1.0.RC1
org.springframework.context.support-3.1.0.RC1
org.springframework.context-3.1.0.RC1
org.springframework.core-3.1.0.RC1
org.springframework.expression-3.1.0.RC1
org-netbeans-modules-java-j2seproject-copylibstask
If you will change object to SpringContest then output will be:
Who invented Spring?