Assignment 3: RMI + Hibernate – See Brightspace for due date.
Read the requirements carefully, if your program does not meet the requirements expect a loss of marks for the assignment, even though your program code runs without errors.
Refer to the Course Section Information (CSI) document posted in Brightspace under Course Information for additional requirements common to all assignments.
Lab Partner: Optional
For this lab, you may work with a lab partner.
Your lab professor must be notified via email of partners with names before the due date. Please include lab section number. Both members must be registered in the same lab section.
Both partners must demonstrate their program in lab together as a pair, all code files and other documents must have both members full names.
Both partners need to submit the assignment in full to Brightspace, your lab professor will select one student’s submission and use it as the grade for both partners. Ensure that both submissions are the same.
You are to develop an RMI-Hibernate-based 3-tier (Console User Interfaces, Client, Server, Database) networked multi-user version of Assignment 2.
RMI will be used instead of Network socket communications, using only Tuna objects as transfer objects.
The data access layer logic will have JDBC replaced with Hibernate.
Create an Assignment 3 project in Eclipse
Add the Hibernate and ConnectorJ external Jar files as seen in lecture.
Copy the starter code into your project
Reference the Hibernate demo 2 from lecture – EchoClient & EchoServer with RMI and Hibernate
Log into MySQL and create a user account ‘assignment3’ with password ‘password’ as well as a database ‘assignment3’ (examine the hibernate.cfg.xml file to ensure it matches your settings).
There is no database script, your annotated Tuna Entity should permit Hibernate to create the database tables for you when your project runs.
Entity, with table name “tunas”
primary key should be generated by MySQL and not left up to Hibernate
String fields should be represented by database columns with sizes of 42 characters.
isLastTuna should be annotated as @Transient
Note: Older Hibernate used a mapping file, do not do this, use Annotations in your Entity class.
ToDo: dataaccesslayer. TunaDaoImpl
This is an enum, with one constant inside named INSTANCE. i.e. Singleton design pattern.
Using Safari Books in the Library, look up: Joshua Bloch. (2008). Effective Java, Second Edition. Addison-Wesley Professional. ISBN-13: 978-0-321-
35668-0 and See Item 3: Enforce the singleton property with a private constructor or an enum type.
The private constructor should construct the SessionFactory
The insert method should use a Hibernate Session to insert a Tuna into the database
The findByUUID should accept a String based uuid, to lookup a Tuna in the database, and return it.
Make sure that Hibernate sessions are closed in their respective methods, and that the shutdown method closes the session factory and destroys the registry.
ToDo: server. TunaServiceImpl
This implements the remoteinterface.TunaService (which in turn extends java.rmi.Remote).
Each method (insert, findByUUID) should use the TunaDaoImpl.INSTANCE to either insert or findBy as needed. (There really should not be much code here.)
Note: The shutdown method is provided to you, there is no mistake that it is missing from the TunaService interface, and that there is no @Override on it either. We do not want to permit any clients to call shutdown(), only the server-side code should be able to call the shutdown() method.
Typical RMI startup, should instantiate a TunaServiceImpl and export it to the registry, then bind it as “TunaService”
See comments in the main method for instructions.
You can use either the Hibernate Demo 2 client, or your Assignment 2 client as starter code.
Obtain a connection to the RMI server, to the remote TunaService
Ask the user for the data for a Tuna, then ask the remote object to insert it, then ask for a Tuna back with the generated primary key value (the client should send the UUID as a String).
Ask the user if they want to continue, or shutdown if an Exception is generated by the server.
Note: There is no Message object, no String commands, use RMI to make method calls against the remote object.
Demonstration in lab
Demonstrate that the server runs, a client runs, and the client can insert a record into the database
Demonstrate that if the MySQL service is shutdown, while your server and client are running, that the client shuts down gracefully when the server encounters exceptions.
All classes, interfaces, and class/interface members need Javadoc comments in code files
Place your name(s) at the top of each source code file.
There is no need to generate html using the Javadoc tool.
UML Sequence Diagram
Diagram the sequence of client requesting a Tuna to be created.
Diagram the sequence of client requesting a Tuna based on UUID.
You may use the one diagram to show both sequences.
I am not requesting a test plan for Assignment 3.
Short Answer Questions
What are some advantages and drawbacks of using RMI versus network sockets for a client-server application?
What are some advantages and disadvantages of using Hibernate instead of JDBC for a data-connected application?
Note on Short Answer Questions
You are free to research online, can use a bullet list if you want or a paragraph, looking for about 1⁄2 page single- line-spacing per question.
Make sure you cite source(s) using IEEE format.
Place these items into a zip archive, the zip file-name should have your name in it:
Your Java Project Folder with *.java files and *.xml file.
See the documentation section above
Short answer question
Your answers to the short answer question
Grading Criteria (out of 10)
Demonstration in lab of server and client inserting record into database (1 point)
Demonstration in lab of graceful client shutdown if server encounters problem (1 point)
Code – has given package structure, code matches instructions, uses RMI and Hibernate 5.x (3 points)
Javadoc comments (1point)
UML Sequence (2points)
Questions – answers the two questions, sources are cited (2 points)
Appendix – Optional UML Editor
What is UMLet?
A free lightweight UML editor I like using is UMLet. I find that it is easy to use and creates very nice diagrams.
Using UMLet isn’t a requirement, if you have an alternative tool that generates UML 2.x diagrams feel free to use it. However, note that diagrams generated by eclipse plugins are not UML 2.x so will be awarded scores of zero.
Website and Download for UMLet
See: UMLet 14.2 stand-alone
Tutorials from the internet:
Sequence Video 1:
Sequence Video 2: (fast forward to about 5:50)
Hidden Features Video:
Please download the attached document including starter code and pdf..