Professional Documents
Culture Documents
package com.module.model;
//this class is created for 003 docs...message service stub
import java.util.Date;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Profile {
public Profile(){
2. Let us create a sample database class, we are just creating a hashmap and not really inserting
into database here
package com.module.database;
import java.util.HashMap;
import java.util.Map;
import com.module.model.Message;
import com.module.model.Profile;
package com.module.service;
import java.sql.DatabaseMetaData;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.module.database.SampleDatabase;
import com.module.model.Message;
public MessageService(){
//creating a new messages with ID=> 1L for HashMap<Long,
Message>
messages.put(1L,new Message(1,"GOOD MORNING","GITESH MORE"));
messages.put(2L,new Message(2, "GOOD AFTERNOON","SHAILESH"));
messages.put(3L,new Message(3,"GOOD EVENING","KIRAN"));
}
// now next is we need a service that returns list of messages
public List<Message> getAllMessages(){
//deleted previous stuff
//we are going to have list of all messages...and this we
want as list so done as follows
return new ArrayList<Message>(messages.values());
//passing a collection to the arraylist constructor
initialized List with those elements
}