Created
December 7, 2017 22:16
-
-
Save darbyluv2code/3ee8ab317b3557be8ed081ed1a45256f to your computer and use it in GitHub Desktop.
communicating with casts
This file contains hidden or 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
| package vikram; | |
| import org.springframework.beans.factory.annotation.Autowired; | |
| import org.springframework.beans.factory.annotation.Qualifier; | |
| import org.springframework.stereotype.Component; | |
| @Component | |
| public class Cast implements employee | |
| { | |
| //Field injection through annotation ensures that there is no need for setter methods to be defined. | |
| @Autowired | |
| // luv2code: commented out this line @Qualifier("randomWeather") | |
| private Breif b; | |
| @Autowired | |
| @Qualifier("randomWeather") // luv2code: added this line | |
| private Weather w; | |
| //default constructor | |
| public Cast() | |
| { | |
| System.out.println("Cast: inside default constructor"); | |
| } | |
| /* | |
| //define a setter method... Setter injection using Annotation | |
| @Autowired | |
| public void Upti(Breif br) | |
| { | |
| System.out.println("Cast: inside Upti()"); | |
| b=br; | |
| } | |
| //Constructor injection using annotation | |
| //if the class has only one constructor defined then it does not need an Autowire annotation as a part of Spring4.3 | |
| @Autowired | |
| public Cast(Breif br) | |
| { | |
| b=br; | |
| } | |
| */ | |
| @Override | |
| public String getDailyGreeting() | |
| { | |
| System.out.println("Cast: inside getDailyGreeting()"); | |
| return "Hi Team ...Welcome for the day"; | |
| } | |
| @Override | |
| public String getBreifing() | |
| { | |
| System.out.println("Cast: inside getBreifing()"); | |
| return b.getBreifing(); | |
| } | |
| @Override | |
| public String getWeather() | |
| { | |
| System.out.println("Cast: inside getWeather()"); | |
| return w.getWeather(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment