incorporate few review comments for bael-603 (#1429)

This commit is contained in:
Mohamed Sanaulla 2017-03-18 10:18:04 +03:00 committed by maibin
parent 99bebe806c
commit dc90aace68
8 changed files with 50 additions and 43 deletions

View File

@ -4,13 +4,13 @@ import com.baeldung.student.service.StudentService;
import com.baeldung.student.service.dbimpl.StudentDbService; import com.baeldung.student.service.dbimpl.StudentDbService;
import com.baeldung.student.model.Student; import com.baeldung.student.model.Student;
public class StudentClient{ public class StudentClient {
public static void main(String[] args) { public static void main(String[] args) {
StudentService service = new StudentDbService(); StudentService service = new StudentDbService();
service.create(new Student()); service.create(new Student());
service.read("17SS0001"); service.read("17SS0001");
service.update(new Student()); service.update(new Student());
service.delete("17SS0001"); service.delete("17SS0001");
} }
} }

View File

@ -1,3 +1,3 @@
module com.baeldung.student.client{ module com.baeldung.student.client{
requires com.baeldung.student.service.dbimpl; requires com.baeldung.student.service.dbimpl;
} }

View File

@ -2,11 +2,14 @@ package com.baeldung.student.model;
import java.util.Date; import java.util.Date;
public class Student{ public class Student {
public String registrationId; private String registrationId;
public String firstName;
public String lastName; public String getRegistrationId() {
public Date dateOfBirth; return registrationId;
public String city; }
public String country;
public void setRegistrationId(String registrationId) {
this.registrationId = registrationId;
}
} }

View File

@ -1,3 +1,3 @@
module com.baeldung.student.model{ module com.baeldung.student.model{
exports com.baeldung.student.model; exports com.baeldung.student.model;
} }

View File

@ -2,26 +2,29 @@ package com.baeldung.student.service.dbimpl;
import com.baeldung.student.service.StudentService; import com.baeldung.student.service.StudentService;
import com.baeldung.student.model.Student; import com.baeldung.student.model.Student;
import java.util.logging.*;
public class StudentDbService implements StudentService{ public class StudentDbService implements StudentService {
public String create(Student student){ private static Logger logger = Logger.getLogger("StudentDbService");
System.out.println("Creating student in DB...");
return student.registrationId;
}
public Student read(String registrationId){ public String create(Student student) {
System.out.println("Reading student from DB..."); logger.log(Level.INFO, "Creating student in DB...");
return new Student(); return student.getRegistrationId();
} }
public Student update(Student student){ public Student read(String registrationId) {
System.out.println("Updating sutdent in DB..."); logger.log(Level.INFO, "Reading student from DB...");
return student; return new Student();
} }
public String delete(String registrationId){ public Student update(Student student) {
System.out.println("Deleteing sutdent in DB..."); logger.log(Level.INFO, "Updating sutdent in DB...");
return registrationId; return student;
} }
public String delete(String registrationId) {
logger.log(Level.INFO, "Deleteing sutdent in DB...");
return registrationId;
}
} }

View File

@ -1,4 +1,5 @@
module com.baeldung.student.service.dbimpl{ module com.baeldung.student.service.dbimpl{
requires transitive com.baeldung.student.service; requires transitive com.baeldung.student.service;
exports com.baeldung.student.service.dbimpl; exports com.baeldung.student.service.dbimpl;
requires java.logging;
} }

View File

@ -2,13 +2,13 @@ package com.baeldung.student.service;
import com.baeldung.student.model.Student; import com.baeldung.student.model.Student;
public interface StudentService{ public interface StudentService {
public String create(Student student); public String create(Student student);
public Student read(String registrationId); public Student read(String registrationId);
public Student update(Student student); public Student update(Student student);
public String delete(String registrationId); public String delete(String registrationId);
} }

View File

@ -1,4 +1,4 @@
module com.baeldung.student.service{ module com.baeldung.student.service{
requires transitive com.baeldung.student.model; requires transitive com.baeldung.student.model;
exports com.baeldung.student.service; exports com.baeldung.student.service;
} }