Adding Code for BAEL-394 (#1163)
* Code for evaluation article Article : Field vs. Constructor Injection * Correct typo in attribute name * Delete EbookRepositiry.java * Add corrected class * Update LibraryUtils.java * Update Member.java * Update Reservation.java * Adding new file AccountServlet * Adding new files for BAEL-394 * Add new files for BAEL-394 * Add new file for BAEL-394 * Indentation of annotations fixed * Indentation of annotations fixed * Indentation of annotations fixed * Removing this class since it is not relevant * New example added for @WebListener
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package com.baeldung;
|
||||
|
||||
public class Ebook {
|
||||
|
||||
private int bookId;
|
||||
private String bookTitle;
|
||||
|
||||
public int getBookId() {
|
||||
return bookId;
|
||||
}
|
||||
public void setBookId(int bookId) {
|
||||
this.bookId = bookId;
|
||||
}
|
||||
public String getBookTitle() {
|
||||
return bookTitle;
|
||||
}
|
||||
public void setBookTitle(String bookTitle) {
|
||||
this.bookTitle = bookTitle;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.baeldung;
|
||||
|
||||
public interface EbookRepository {
|
||||
String titleById(int id);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.baeldung;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class LibraryUtils {
|
||||
@Autowired
|
||||
private EbookRepository eBookRepository;
|
||||
|
||||
public String findBook(int id) {
|
||||
return eBookRepository.titleById(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.baeldung;
|
||||
|
||||
public class Member {
|
||||
|
||||
private int memberId;
|
||||
private String memberName;
|
||||
|
||||
public int getMemberId() {
|
||||
return memberId;
|
||||
}
|
||||
public void setMemberId(int memberId) {
|
||||
this.memberId = memberId;
|
||||
}
|
||||
public String getMemberName() {
|
||||
return memberName;
|
||||
}
|
||||
public void setMemberName(String memberName) {
|
||||
this.memberName = memberName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.baeldung;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class Reservation {
|
||||
private Member member;
|
||||
private Ebook eBook;
|
||||
|
||||
@Autowired
|
||||
public Reservation(Member member, Ebook eBook) {
|
||||
this.member = member;
|
||||
this.eBook = eBook;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user