C:\Documents and Settings\Gijs\Desktop\src\client\Client.java dinsdag 3 november :50

Size: px
Start display at page:

Download "C:\Documents and Settings\Gijs\Desktop\src\client\Client.java dinsdag 3 november 2009 10:50"

Transcription

1 C:\Documents and Settings\Gijs\Desktop\src\client\Client.java dinsdag 3 november :50 package client; import hotel.bookingconstraints; import hotel.bookingexception; import hotel.costumersessionremote; import hotel.hotel; import hotel.managersessionremote; import hotel.room; import hotel.ihotel; import java.rmi.remoteexception; import java.rmi.server.unicastremoteobject; import java.util.calendar; import java.util.date; public class Client { public static void main(string[] args) throws RemoteException { TravelAgency agency = new TravelAgency(); CostumerSessionRemote session = agency.getcostumersession(0); Calendar c = Calendar.getInstance(); c.set(2009, Calendar.OCTOBER, 11, 0, 0, 0); Date day1 = c.gettime(); c.set(2009, Calendar.OCTOBER, 12, 0, 0, 0); Date day2 = c.gettime(); c.set(2009, Calendar.OCTOBER, 13, 0, 0, 0); Date day3 = c.gettime(); c.set(2009, Calendar.OCTOBER, 6, 0, 0, 0); Date day4 = c.gettime(); BookingConstraints constraints1 = new BookingConstraints(day4, day3, 3, 150.0, false); BookingConstraints constraints2 = new BookingConstraints(day1, day2, 1, 150.0, false); try { session.createbooking(constraints1, "Frans Guelinckx", "Fawlty_Towers"); session.createbooking(constraints2, "Gijs Vanderhoydonk", "Fawlty_Towers"); session.finalizebookings(); session.createbooking(constraints1, "Frans Guelinckx", "Fawlty_Towers"); session.createbooking(constraints2, "Gijs Vanderhoydonk", "Fawlty_Towers"); session.finalizebookings(); session.createbooking(constraints1, "Frans Guelinckx", "Rilton"); session.createbooking(constraints2, "Gijs Vanderhoydonk", "Rilton"); session.finalizebookings(); session.createbooking(constraints1, "Frans Guelinckx", "Rilton"); session.createbooking(constraints2, "Gijs Vanderhoydonk", "Rilton"); session.finalizebookings(); // session = agency.getcostumersession(1); System.out.println(); catch (BookingException e) { System.out.println("One or more of the tentative bookings could not be finalized."); -1-

2 C:\Documents and Settings\Gijs\Desktop\src\client\Client.java dinsdag 3 november :50 ManagerSessionRemote managersession = agency.getmanagersession(1); System.out.println(managerSession.getRooms("Fawlty_Towers")); System.out.println(managerSession.getHotels()); Hotel hotel = new Hotel("Den houten lepel", new Room[0]); ihotel ihotel = (ihotel) UnicastRemoteObject.exportObject(hotel, 0); managersession.registerhotel("den houten lepel", ihotel); System.out.println(managerSession.getHotels()); -2-

3 C:\Documents and Settings\Gijs\Desktop\src\client\TravelAgency.java dinsdag 3 november :51 package client; import hotel.costumersession; import hotel.costumersessionremote; import hotel.managersession; import hotel.managersessionremote; import java.rmi.remote; import java.util.hashmap; public class TravelAgency implements Remote { private HashMap<Integer, CostumerSessionRemote> costumersessions = new HashMap<Integer, CostumerSessionRemote>(); private HashMap<Integer, ManagerSessionRemote> managersessions = new HashMap<Integer, ManagerSessionRemote>(); public CostumerSessionRemote getcostumersession(int id) { if (costumersessions.get(id) == null) { return this.createcostumersession(id); else { return this.costumersessions.get(id); private CostumerSessionRemote createcostumersession(int id) { CostumerSession session = new CostumerSession(); this.costumersessions.put(id, session); return session; public ManagerSessionRemote getmanagersession(int id) { if (managersessions.get(id) == null) { return this.createmanagersession(id); else { return this.managersessions.get(id); private ManagerSessionRemote createmanagersession(int id) { ManagerSession session = new ManagerSession(); this.managersessions.put(id, session); return session; -1-

4 C:\Documents and Settings\Gijs\Desktop\src\hotel\BookingConstraints.java dinsdag 3 november :54 package hotel; import java.io.serializable; import java.util.date; * A class representing booking constraints. It containt all sorts of * requirements to which a real booking should adhere. public class BookingConstraints implements Serializable { private static final long serialversionuid = L; * De starting date of the tentative booking. private Date from; * The maximum cost per night a booking should have. private double maxcostpernight; * The number of beds requested. private int nbofbeds; * A boolean indicating whether smoking should be allowed or not. private boolean smoking; * The end date of the tentative booking. private Date to; * A constructor setting all the desired requirements. * from * The date on which the reservation should start. to * The date on which the reservation should end. nbofbeds * The desired number of beds. maxcost * The maximum cost per night. smoking * A boolean indicating whether smoking should be allowed or not. public BookingConstraints(Date from, Date to, int nbofbeds, double maxcost, boolean smoking) { setbegin(from); setend(to); setmaxcostpernight(maxcost); setnbofbeds(nbofbeds); -1-

5 C:\Documents and Settings\Gijs\Desktop\src\hotel\BookingConstraints.java dinsdag 3 november :54 setsmoking(smoking); public Date getbegin() { return from; public Date getend() { return to; public double getmaxcostpernight() { return maxcostpernight; public int getnbofbeds() { return nbofbeds; public void setbegin(date from) { this.from = from; public void setend(date to) { this.to = to; public void setmaxcostpernight(double cost) { this.maxcostpernight = cost; public void setnbofbeds(int nbofbeds) { this.nbofbeds = nbofbeds; public void setsmoking(boolean smoking) { this.smoking = smoking; public boolean smokingallowed() { return public String tostring() { return "From: " + this.getbegin() + " To: " + this.getend() + " Max cost per night: " + this.getmaxcostpernight() + " Nb of beds: " + this.getnbofbeds() + " Smoking: " + this.smokingallowed(); -2-

6 C:\Documents and Settings\Gijs\Desktop\src\hotel\BookingDetails.java dinsdag 3 november :54 package hotel; import java.io.serializable; import java.util.date; * A class representing an actual booking. public class BookingDetails implements Serializable { private static final long serialversionuid = L; * The name of the person who made the reservation. private String booker; * The total cost of the booking. private double cost; * The date on which the reservation starts. private Date from; * The name of the hotel in which the booking is made.. private String hotel; * The number of the booked room. private int roomnb; * The date on which the reservation ends. private Date to; * Returns true if a given instance of BookingDetails is equal to this * instance. This means that all attributes (requirements) are the public boolean equals(object o) { if (this == o) return true; if (o instanceof BookingDetails) { BookingDetails other = (BookingDetails) o; if (other.getbegin().equals(getbegin()) && other.getend().equals(getend()) && other.getnameofbooker().equals(getnameofbooker()) && other.gethotelname().equals(gethotelname()) && (other.gettotalcost() == gettotalcost()) && (other.getroomnb() == getroomnb())) -1-

7 C:\Documents and Settings\Gijs\Desktop\src\hotel\BookingDetails.java dinsdag 3 november :54 return true; return false; public Date getbegin() { return from; public Date getend() { return to; public String gethotelname() { return hotel; public String getnameofbooker() { return booker; public int getroomnb() { return roomnb; public double gettotalcost() { return public int hashcode() { int hash = 7; hash = 43 * hash + (this.from!= null? this.from.hashcode() : 0); hash = 43 * hash + (this.to!= null? this.to.hashcode() : 0); hash = 43 * hash + (this.booker!= null? this.booker.hashcode() : 0); hash = 43 * hash + (this.hotel!= null? this.hotel.hashcode() : 0); hash = 43 * hash + this.roomnb; hash = 43 * hash + (int) (Double.doubleToLongBits(this.cost) ^ (Double.doubleToLongBits(this.cost) >>> 32)); return hash; void setbegin(date from) { this.from = from; void setbooker(string booker) { this.booker = booker; void setend(date to) { this.to = to; void sethotelname(string hotel) { this.hotel = hotel; -2-

8 C:\Documents and Settings\Gijs\Desktop\src\hotel\BookingDetails.java dinsdag 3 november :54 void setroomnb(int roomnb) { this.roomnb = roomnb; void settotalcost(double cost) { this.cost = public String tostring() { return "Booking for " + getnameofbooker() + " from " + getbegin() + " to " + getend() + "\n" + "Room: " + getroomnb() + "\ttotal cost: " + gettotalcost(); -3-

9 C:\Documents and Settings\Gijs\Desktop\src\hotel\BookingException.java dinsdag 3 november :52 package hotel; public class BookingException extends Exception { private static final long serialversionuid = L; public BookingException(String string) { super(string); -1-

10 C:\Documents and Settings\Gijs\Desktop\src\hotel\CostumerSession.java dinsdag 3 november :52 package hotel; import java.rmi.remoteexception; import java.util.arraylist; * A costumer session, used by costumers for creating, finalizing en reading the * current bookings. public class CostumerSession extends Session implements CostumerSessionRemote { * An {@link ArrayList containing all tentative bookings. ArrayList<BookingDetails> bookings = new ArrayList<BookingDetails>(); public CostumerSession() { super(); * Creates a tantative booking in the given hotel and for a given person, * which satisfies the given booking public BookingDetails createbooking(bookingconstraints constraints, String bookername, String hotelname) throws BookingException, RemoteException { BookingDetails result = this.gethotelinstance(hotelname).createbooking( constraints, bookername); bookings.add(result); return result; * Finalizes the list of tentative bookings. Of one or more bookings fail, * all bookings are cancelled and public void finalizebookings() throws BookingException, RemoteException { try { for (BookingDetails details : this.bookings) { ihotel hotel = this.gethotelinstance(details.gethotelname()); hotel.finalizebooking(details); this.bookings.clear(); catch (RuntimeException e) { for (BookingDetails details : this.bookings) { this.gethotelinstance(details.gethotelname()).cancelbooking( details); this.bookings.clear(); throw new BookingException( "One or more of the reservations cannot be finalized."); -1-

11 C:\Documents and Settings\Gijs\Desktop\src\hotel\CostumerSession.java dinsdag 3 november :52 * Returns the list of tentative public ArrayList<BookingDetails> getcurrentbookings() throws RemoteException { return bookings; -2-

12 C:\Documents and Settings\Gijs\Desktop\src\hotel\CostumerSessionRemote.java dinsdag 3 november :52 package hotel; import java.rmi.remote; import java.rmi.remoteexception; import java.util.arraylist; * An interface for a costumer session, extending the remote interface for * distributed use. public interface CostumerSessionRemote extends Remote { * Creates a tantative booking in the given hotel and for a given person, * which satisfies the given booking constraints. * constraints * The constraints that have to be satistied. bookername * The name of the person that makes the reservation. hotelname * The name of the hotel in which the reservation should be made. An instance of {@link BookingDetails, containing all the info of * the tentative booking. BookingException * Thrown when one or more of the constraints cannot be * satisfied. public BookingDetails createbooking(bookingconstraints constraints, String bookername, String hotelname) throws BookingException, RemoteException; * Finalizes all tentative bookings. * BookingException * Thrown when one or more of the bookings cannot be finalized. * All tentative bookings are also cancelled and deleted. public void finalizebookings() throws BookingException, RemoteException; * Returns a list of all tentative bookings. public ArrayList<BookingDetails> getcurrentbookings() throws RemoteException; -1-

13 C:\Documents and Settings\Gijs\Desktop\src\hotel\Hotel.java dinsdag 3 november :52 package hotel; import java.util.arraylist; import java.util.calendar; import java.util.date; * A class representing a hotel. public class Hotel implements ihotel { * private static final long serialversionuid = L; * The name of the hotel. private String name; * The rooms in this hotel. private Room[] rooms; * Constructs a hotel with a given name and rooms. public Hotel(String name, Room[] rooms) { System.out.println("<" + name + "> Hotel " + name + " starting up..."); setname(name); this.rooms = rooms; * Cancels a given booking. public void cancelbooking(bookingdetails booking) { System.out.println("<" + name + "> Cancelling booking " + booking.tostring()); for (Room r : this.rooms) { if (r.getdetails().getroomnb() == booking.getroomnb()) { r.removebooking(booking); * Creates an instance of BookingDetails that satisfies the given * constraints for the given person. If the constraints cannot be met, no * tentative reservation is made. public BookingDetails createbooking(bookingconstraints constraints, String person) throws BookingException { System.out.println("<" + name + "> Creating bookingdetails for " + person + " with constraints " + constraints.tostring()); for (RoomDetails r : this.getfreerooms(constraints.getbegin(), -1-

14 C:\Documents and Settings\Gijs\Desktop\src\hotel\Hotel.java dinsdag 3 november :52 constraints.getend())) { if (constraints.getnbofbeds() <= r.getnbofbeds() && constraints.smokingallowed() == r.smokingallowed() && constraints.getmaxcostpernight() >= r.getcostpernight()) { return createbooking(r.getroomnb(), constraints.getbegin(), constraints.getend(), person); throw new BookingException("<" + name + "> No rooms left to satisfy constraints."); * Creates an actual tentative reservation. * roomnb * The number of rooms needed. begin * The start date for the reservation. end * The end date. person * The name of the person that makes the booking. An instance of BookingDetails, containing all the details of the * tentative booking. BookingException * Thrown when the room is not free during the given period. private BookingDetails createbooking(int roomnb, Date begin, Date end, String person) throws BookingException { if (rooms[roomnb].isfree(begin, end)) { BookingDetails b = new BookingDetails(); b.setbooker(person); b.setbegin(begin); b.setend(end); b.setroomnb(roomnb); b.sethotelname(getname()); b.settotalcost(rooms[roomnb].getdetails().getcostpernight() * (Math.ceil(end.getTime() - begin.gettime()) / (1000 * 60 * 60 * 24))); return b; else { throw new BookingException("<" + name + "> Room is not free during that period."); * Finalizes a given tentative booking. public void finalizebooking(bookingdetails b) { System.out.println("<" + name + "> Booking " + b.tostring()); getroom(b.getroomnb()).book(b); * Returns a list of all bookings of all the rooms in this hotel. -2-

15 C:\Documents and Settings\Gijs\Desktop\src\hotel\Hotel.java dinsdag 3 november :52 public ArrayList<BookingDetails> getbookings() { ArrayList<BookingDetails> result = new ArrayList<BookingDetails>(); for (Room room : rooms) { result.addall(room.getbookings()); return result; * Returns a list of rooms that are free during a given period. public ArrayList<RoomDetails> getfreerooms(date begin, Date end) { ArrayList<RoomDetails> freerooms = new ArrayList<RoomDetails>(); for (int i = 0; i < rooms.length; i++) { Room room = rooms[i]; if (room.isfree(begin, end)) { freerooms.add(room.getdetails()); return freerooms; public String getname() { return name; public Room getroom(int roomnb) { for (Room r : rooms) { if (r.getdetails().getroomnb() == roomnb) return r; throw new IllegalArgumentException("<" + name + "> No such room, " + roomnb); * Returns a list of {@link RoomDetails of all the rooms in this hotel. public ArrayList<RoomDetails> getrooms() { ArrayList<RoomDetails> result = new ArrayList<RoomDetails>(); for (Room room : rooms) { result.add(room.getdetails()); return result; * Returns a list of all the rooms that are booked today. * public ArrayList<Room> getroomsbookedtoday() { ArrayList<Room> result = new ArrayList<Room>(); Date date = Calendar.getInstance().getTime(); for (Room room : rooms) { if (!room.isbooked(date)) result.add(room); -3-

16 C:\Documents and Settings\Gijs\Desktop\src\hotel\Hotel.java dinsdag 3 november :52 return result; * Indicates whether a room is free during a given period. * roomid * The number of the room that has to be checked. begin * The beginning of the desired period. end * The end of the desired period. True if the room is free, false otherwise. public boolean isfree(int roomid, Date begin, Date end) { System.out.println("<" + name + "> Checking availability for room " + roomid); return this.rooms[roomid].isfree(begin, end); private void setname(string name) { this.name = name; -4-

17 C:\Documents and Settings\Gijs\Desktop\src\hotel\HotelServer1.java dinsdag 3 november :53 package hotel; import java.rmi.notboundexception; import java.rmi.remoteexception; import java.rmi.registry.locateregistry; import java.rmi.registry.registry; import java.rmi.server.unicastremoteobject; import java.util.arraylist; import naming.namingserviceremote; public class HotelServer1 { public static void main(string[] args) { System.setSecurityManager(null); ArrayList<Hotel> hotels = createhotels(); try { ihotel stub; Registry registry = LocateRegistry.getRegistry(); NamingServiceRemote service = (NamingServiceRemote) registry.lookup("namingservice"); for (Hotel hotel : hotels) { stub = (ihotel) UnicastRemoteObject.exportObject(hotel, 0); service.register(hotel.getname(), stub); catch (RemoteException e) { e.printstacktrace(); catch (NotBoundException e) { e.printstacktrace(); public static ArrayList<Hotel> createhotels() { ArrayList<Hotel> result = new ArrayList<Hotel>(); Room[] rooms1 = new Room[5]; rooms1[0] = new Room(new RoomDetails(0, 2, 50.0, false)); rooms1[1] = new Room(new RoomDetails(1, 2, 50.0, false)); rooms1[2] = new Room(new RoomDetails(2, 4, 90.0, false)); rooms1[3] = new Room(new RoomDetails(3, 4, 95.0, true)); rooms1[4] = new Room(new RoomDetails(4, 5, 150.0, false)); result.add(new Hotel("Fawlty_Towers", rooms1)); return result; -1-

18 C:\Documents and Settings\Gijs\Desktop\src\hotel\HotelServer2.java dinsdag 3 november :53 package hotel; import java.rmi.notboundexception; import java.rmi.remoteexception; import java.rmi.registry.locateregistry; import java.rmi.registry.registry; import java.rmi.server.unicastremoteobject; import java.util.arraylist; import naming.namingserviceremote; public class HotelServer2 { args public static void main(string[] args) { System.setSecurityManager(null); ArrayList<Hotel> hotels = createhotels(); try { ihotel stub; Registry registry = LocateRegistry.getRegistry(); NamingServiceRemote service = (NamingServiceRemote) registry.lookup("namingservice"); for (Hotel hotel : hotels) { stub = (ihotel) UnicastRemoteObject.exportObject(hotel, 0); service.register(hotel.getname(), stub); catch (RemoteException e) { e.printstacktrace(); catch (NotBoundException e) { e.printstacktrace(); public static ArrayList<Hotel> createhotels() { ArrayList<Hotel> result = new ArrayList<Hotel>(); Room[] rooms2 = new Room[4]; rooms2[0] = new Room(new RoomDetails(1, 2, 90.0, false)); rooms2[1] = new Room(new RoomDetails(2, 1, 100.0, false)); rooms2[2] = new Room(new RoomDetails(3, 4, 150.0, false)); rooms2[3] = new Room(new RoomDetails(4, 3, 120.0, true)); result.add(new Hotel("Rilton", rooms2)); return result; -1-

19 C:\Documents and Settings\Gijs\Desktop\src\hotel\iHotel.java dinsdag 3 november :53 package hotel; import java.rmi.remote; import java.rmi.remoteexception; import java.util.arraylist; import java.util.date; public interface ihotel extends Remote { public void cancelbooking(bookingdetails details) throws RemoteException; public BookingDetails createbooking(bookingconstraints constraints, String person) throws BookingException, RemoteException; public void finalizebooking(bookingdetails b) throws RemoteException; public ArrayList<BookingDetails> getbookings() throws RemoteException; public ArrayList<RoomDetails> getfreerooms(date begin, Date end) throws RemoteException; public ArrayList<RoomDetails> getrooms() throws RemoteException; -1-

20 C:\Documents and Settings\Gijs\Desktop\src\hotel\ManagerSession.java dinsdag 3 november :53 package hotel; import java.rmi.notboundexception; import java.rmi.remoteexception; import java.rmi.registry.locateregistry; import java.rmi.registry.registry; import java.util.arraylist; import java.util.date; import naming.namingserviceremote; public class ManagerSession extends Session implements ManagerSessionRemote { * Returns a list of rooms that are free in a given public ArrayList<RoomDetails> getfreerooms(date begin, Date end, String hotelname) throws RemoteException { return this.gethotelinstance(hotelname).getfreerooms(begin, end); * Returns a list of names of all the public ArrayList<String> gethotels() throws RemoteException { ArrayList<String> result = null; System.setSecurityManager(null); Registry registry; try { registry = LocateRegistry.getRegistry("localhost", 1099); NamingServiceRemote namingservice; namingservice = (NamingServiceRemote) registry.lookup("namingservice"); result = namingservice.gethotels(); catch (RemoteException e) { e.printstacktrace(); catch (NotBoundException e) { e.printstacktrace(); return result; * Returns a list of rooms of a given public ArrayList<RoomDetails> getrooms(string hotelname) throws RemoteException { return this.gethotelinstance(hotelname).getrooms(); * Registers a new hotel in the naming public void registerhotel(string name, ihotel hotel) throws RemoteException { -1-

21 C:\Documents and Settings\Gijs\Desktop\src\hotel\ManagerSession.java dinsdag 3 november :53 System.setSecurityManager(null); Registry registry; try { registry = LocateRegistry.getRegistry("localhost", 1099); NamingServiceRemote namingservice; namingservice = (NamingServiceRemote) registry.lookup("namingservice"); namingservice.register(name, hotel); catch (RemoteException e) { e.printstacktrace(); catch (NotBoundException e) { e.printstacktrace(); * Unregisters a hotel at the naming public void unregisterhotel(string name) throws RemoteException { System.setSecurityManager(null); Registry registry; try { registry = LocateRegistry.getRegistry("localhost", 1099); NamingServiceRemote namingservice; namingservice = (NamingServiceRemote) registry.lookup("namingservice"); namingservice.remove(name); catch (RemoteException e) { e.printstacktrace(); catch (NotBoundException e) { e.printstacktrace(); -2-

22 C:\Documents and Settings\Gijs\Desktop\src\hotel\ManagerSessionRemote.java dinsdag 3 november :53 package hotel; import java.rmi.remote; import java.rmi.remoteexception; import java.util.arraylist; import java.util.date; public interface ManagerSessionRemote extends Remote { public ArrayList<RoomDetails> getfreerooms(date begin, Date end, String hotelname) throws RemoteException; public ArrayList<String> gethotels() throws RemoteException; public ArrayList<RoomDetails> getrooms(string hotelname) throws RemoteException; public void registerhotel(string name, ihotel stub) throws RemoteException; public void unregisterhotel(string name) throws RemoteException; -1-

23 C:\Documents and Settings\Gijs\Desktop\src\hotel\Room.java dinsdag 3 november :53 package hotel; import java.util.arraylist; import java.util.date; public class Room { public ArrayList<BookingDetails> bookings = new ArrayList<BookingDetails>(); private RoomDetails details; public Room(RoomDetails details) { this.setdetails(details); public void book(bookingdetails b) { synchronized (this) { if (isfree(b.getbegin(), b.getend())) { bookings.add(b); System.out.println(); else throw new RuntimeException("Booking failed, room " + b.getroomnb() + " is unavailable from " + b.getbegin() + " to " + b.getend()); public ArrayList<BookingDetails> getbookings() { return this.bookings; public RoomDetails getdetails() { return details; public boolean isbooked(date date) { boolean result = false; for (BookingDetails booking : this.bookings) { if (date.after(booking.getbegin()) && date.before(booking.getend())) result = true; return result; public boolean isfree(date begin, Date end) { if (begin.compareto(end) == 0) { throw new RuntimeException("illegal period"); boolean free = true; for (BookingDetails booking : bookings) { if (booking.getbegin().equals(begin) booking.getend().equals(end)) free = false; else if (!booking.getbegin().after(end) &&!booking.getend().before(begin)) free = false; // for (int i = 0; i < bookings.size(); i++) { // BookingDetails booking = bookings.get(i); -1-

24 C:\Documents and Settings\Gijs\Desktop\src\hotel\Room.java dinsdag 3 november :53 // // if (!booking.getbegin().before(begin) // &&!booking.getbegin().before(end)) { // continue; // // if (!booking.getend().after(begin) &&!booking.getend().after(end)) { // continue; // // return false; // // return true; return free; public void removebooking(bookingdetails booking) { synchronized (this) { for (BookingDetails b : this.bookings) { if (b.getbegin().equals(booking.getbegin()) && b.getend().equals(booking.getend()) && b.getnameofbooker().equals(booking.getnameofbooker())) { bookings.remove(b); return; private void setdetails(roomdetails details) { this.details = public String tostring() { return "Room: " + this.getdetails().getroomnb(); -2-

25 C:\Documents and Settings\Gijs\Desktop\src\hotel\RoomDetails.java dinsdag 3 november :54 package hotel; import java.io.serializable; public class RoomDetails implements Serializable { private static final long serialversionuid = L; private double costpernight; private int nbofbeds; private int roomnb; private boolean smoking; public RoomDetails(int roomnb, int nbofbeds, double costpernight, boolean smoking) { this.setcostpernight(costpernight); this.setnbofbeds(nbofbeds); this.setroomnb(roomnb); this.setsmokingallowed(smoking); public double getcostpernight() { return costpernight; public int getnbofbeds() { return nbofbeds; public int getroomnb() { return roomnb; public void setcostpernight(double costpernight) { this.costpernight = costpernight; public void setnbofbeds(int nbofbeds) { this.nbofbeds = nbofbeds; public void setroomnb(int roomnb) { this.roomnb = roomnb; public void setsmokingallowed(boolean smoking) { this.smoking = smoking; public boolean smokingallowed() { return public String tostring() { String r = "Room " + getroomnb() + ", " + getnbofbeds() + " beds, " + getcostpernight() + " euro per night, "; if (smokingallowed()) r += "smoking allowed."; -1-

26 C:\Documents and Settings\Gijs\Desktop\src\hotel\RoomDetails.java dinsdag 3 november :54 else r += "non-smoking."; return r; -2-

27 C:\Documents and Settings\Gijs\Desktop\src\hotel\Session.java dinsdag 3 november :54 package hotel; import java.rmi.notboundexception; import java.rmi.remoteexception; import java.rmi.registry.locateregistry; import java.rmi.registry.registry; import java.util.arraylist; import naming.namingserviceremote; public class Session { * Returns a hotel instance of a given hotel. protected ihotel gethotelinstance(string name) { Registry registry; ihotel result = null; try { registry = LocateRegistry.getRegistry(); NamingServiceRemote service = (NamingServiceRemote) registry.lookup("namingservice"); result = (ihotel) service.gethotelinstance(name); catch (RemoteException e) { e.printstacktrace(); catch (NotBoundException e) { e.printstacktrace(); return result; * Returns a list of the names of all the hotels. protected ArrayList<String> gethotelnames() { ArrayList<String> result = new ArrayList<String>(); System.setSecurityManager(null); Registry registry; try { registry = LocateRegistry.getRegistry("localhost", 1099); NamingServiceRemote namingservice; namingservice = (NamingServiceRemote) registry.lookup("namingservice"); result = namingservice.gethotels(); catch (RemoteException e) { e.printstacktrace(); catch (NotBoundException e) { e.printstacktrace(); return result; -1-

28 C:\Documents and Settings\Gijs\Desktop\src\naming\NamingServer.java dinsdag 3 november :54 package naming; import java.rmi.remoteexception; import java.rmi.registry.locateregistry; import java.rmi.registry.registry; import java.rmi.server.unicastremoteobject; public class NamingServer { * Creates a naming service and registers it. public static void main(string[] args) { System.setSecurityManager(null); NamingService service = new NamingService(); try { NamingServiceRemote stub; Registry registry = LocateRegistry.getRegistry(); stub = (NamingServiceRemote) UnicastRemoteObject.exportObject( service, 0); registry.rebind("namingservice", stub); catch (RemoteException e) { e.printstacktrace(); System.out.println("Naming Service Running!"); -1-

29 C:\Documents and Settings\Gijs\Desktop\src\naming\NamingService.java dinsdag 3 november :54 package naming; import hotel.ihotel; import java.rmi.notboundexception; import java.rmi.remoteexception; import java.rmi.registry.locateregistry; import java.rmi.registry.registry; import java.util.arraylist; import java.util.hashmap; public class NamingService implements NamingServiceRemote { HashMap<String, ihotel> hotels = new HashMap<String, public ArrayList<String> gethotels() throws RemoteException { return new ArrayList<String>(hotels.keySet()); * Registers a hotel stub with a given public void register(string name, ihotel stub) throws RemoteException { System.setSecurityManager(null); Registry registry; try { registry = LocateRegistry.getRegistry(); registry.rebind(name, stub); catch (RemoteException e) { e.printstacktrace(); hotels.put(name, stub); * Removes a given hotel from the naming public void remove(string name) throws RemoteException { System.setSecurityManager(null); Registry registry; try { registry = LocateRegistry.getRegistry(); registry.unbind(name); catch (RemoteException e) { e.printstacktrace(); catch (NotBoundException e) { e.printstacktrace(); hotels.remove(name); * Returns the hotel instance of a given -1-

30 C:\Documents and Settings\Gijs\Desktop\src\naming\NamingService.java dinsdag 3 november :54 public ihotel gethotelinstance(string name) throws RemoteException { return this.hotels.get(name); -2-

31 C:\Documents and Settings\Gijs\Desktop\src\naming\NamingServiceRemote.java dinsdag 3 november :51 package naming; import hotel.ihotel; import java.rmi.remote; import java.rmi.remoteexception; import java.util.arraylist; public interface NamingServiceRemote extends Remote { void register(string name, ihotel stub) throws RemoteException; void remove(string name) throws RemoteException; ArrayList<String> gethotels() throws RemoteException; ihotel gethotelinstance(string name) throws RemoteException; -1-

32 !"#$%&'$()""'#"*%+%&","-. /"'%012*3141*567*81(9*:*;*<!""#$%&'($)*+,-#."/,"+0$1$2#*+($%3-4&+5067$89$"0:";-#$<99=! "#$%&'($'))#!*! +,-..(/0&-1#-2!"#$%&#'()**%"+,)-.)/#0,1"#2#3%.*4$,((%"+%#)55(,4)6%*#&%#0,%"7#8.#,*#%%"#!"#$%&9#+%0%#')"#*%**,%*# 0)(#+%0%#*%**,%#))"/)'%"#>5#))"3.))-#3)"#+%#4(,%"&#%"#3%.3>(-%"*#%%"#=",%'%#,+%"6C%.#&%.=-*&=.%"7#?%#4(,%"&#')"#3,)#+%0%#,+%"6C%.#0,1"#%,-%"#*%**,%#>5#+%#*%.3%.#:%$%.%"7?%#*%.3%.#/))'&#-%:.=,'#3)"#%%"#.)/#%,0$(*$(7#?%0%#*%.3%.#+,%"&#)((%#3%.*4$,((%"+%#$>&%(*#&%# :%3)D%"9#+%0%#'=""%"#3,)#%%"#B)")-%.A%**,>"#3)"#+%#E.)3%(F-%"4G#-%.%-,*&.%%.+#;>.+%"7#?%# H)/,"-A%.3%.#')"#%%"#$>&%("))/#'.,1-%"#%"#-%%I#3%.3>(-%"*#$%&#1=,*&%#)+.%*#&%.=-7 J,)#%%"#*%**,%#')"#$%&#12&$"9#;)).3)"#$%&#)+.%*#3,)#+%#H)/,"-A%.3%.#3%.'.%-%"#;>.+&9#3)">5#)<*&)"+# :%$%%.+#;>.+%"9#3,)#%%"#,K>&%(#,"&%.<)4%7#K%&#$>&%(#:%3)&#3%.*4$,((%"+%#,"*&)"6%*#3)"#$%&#&G5%#L>>/9# ;%('%#%('#%%"#*%.,)(,*%%.:).%#,"*&)"6%#L>>/?%&),(*#:%3)&7#J,)#+%#*%.,)(,*%%.:).%#'()**%#3)"#$%&#&G5%# N/#&%#0>.-%"#+)&#%.#-%%"#4>"O,4&%"#&=**%"#+%#3%.*4$,((%"+%#-%:.=,'%.*#'=""%"#3>>.'>/%"#:,1#$%&# &%-%(,1'#:>%'%"#3)"#%%"#')/%.9#0,1"#%.#3%.*4$,((%"+%#<="46%*#*G"4$.>",0%+#-%/))'&7#K%&#&%)/#$%%I# %.3>>.#-%'>0%"#>/#+%#*G"4$.>",*)6%#>5#$%&#())-*&%#",3%)=#&>%#&%#5)**%"7#?,&#$>=+&#,"#+)&#+%#<="46%*# :>>'PQ#%"#.%/>3%M>>',"-PQ#,"#+%#'()**%#L>>/#-%*G"4$.>",*%%.+#0,1"7!*3 4(#.$%&,,(/52('567#&1(56(#.&( K%&#&%)/#,*#%.,"#-%*())-+#$%&#>>.*5.>"'%(,1'%#+%*,-"#&%#:%$>=+%"7#8.#/>%*&%"#-%%"#-.>&%# 3%.)"+%.,"-%"#-%:%=.%"7#K%&#&>%3>%-%"#3)"#,"&%.<)4%*#>/#.%/>&%#)44%**#&%#-).)"+%.%"#;>.+&# -%0,%"#)(*#%%"#(>-,*4$%#&>%3>%-,"-9#-%%"#3%.)"+%.,"-#3)"#$%&#>>.*5.>"'%(,1'%#'()**%"+,)-.)/7 E,1+%"*#+%#,/5(%/%"&)6%#';)/%"#%.#;%(#%"'%(%#5.>:(%/%"#))"#$%&#(,4$&#+,%#",%&#3>>.0,%"#;).%"# 61+%"*#+%#+%*,-"<)*%7#8R"#3)"#+%0%#5.>:(%/%"#$%%I#&%#/)'%"#/%&#+%#H)/,"-A%.3%.#+,%#>3%.)(# :%*4$,':)).#+,%"&#&%#0,1"7#?,&#;%.+#>5-%(>*&#+>>.#+%#H)/,"-A%.3%.#&%#.%-,*&%.%"#,"#$%&#LB!#.%-,*&.G9# ;%('%#>3%.)(#>5-%3.))-+#')"#;>.+%"7

33 8(9)(/'&(0&-1#-22-:. # =$-10$>"*?99@$-2%!"&*%"%%$9-

34

35

36 C01%%"#$12'1,*D*E,$##"-*(94"-F

37 C01%%"#$12'1,*D*E'"BG&%*(94"-F C01%%"#$12'1,*:

38 H"I09+","-&#$12'1,

! "# $%&'( ) * ).) "%&' 1* ( %&' ! "%&'2 (! ""$ 1! ""3($

! # $%&'( ) * ).) %&' 1* ( %&' ! %&'2 (! $ 1! 3($ ! "# $%&'( ) * +,'-( ).) /"0'" 1 %&' 1* ( %&' "%&'! "%&'2 (! ""$ 1! ""3($ 2 ', '%&' 2 , 3, 4( 4 %&'( 2(! ""$ -5%&'* -2%&'(* ) * %&' 2! ""$ -*! " 4 , - %&' 3( #5! " 5, '56! "* * 4(%&'(! ""$ 3(#! " 42/7'89.:&!

More information

When the transport layer tries to establish a connection with the server, it is blocked by the firewall. When this happens, the RMI transport layer

When the transport layer tries to establish a connection with the server, it is blocked by the firewall. When this happens, the RMI transport layer Firewall Issues Firewalls are inevitably encountered by any networked enterprise application that has to operate beyond the sheltering confines of an Intranet Typically, firewalls block all network traffic,

More information

Remote Method Invocation

Remote Method Invocation Remote Method Invocation The network is the computer Consider the following program organization: method call SomeClass AnotherClass returned object computer 1 computer 2 If the network is the computer,

More information

DHBW Karlsruhe, Vorlesung Programmieren, Remote Musterlösungen

DHBW Karlsruhe, Vorlesung Programmieren, Remote Musterlösungen DHBW Karlsruhe, Vorlesung Programmieren, Remote Musterlösungen Aufgabe 1 RMI - TimeService public interface TimeServerInterface extends Remote { public String gettime() throws RemoteException; import java.util.date;

More information

Remote Method Invocation in JAVA

Remote Method Invocation in JAVA Remote Method Invocation in JAVA Philippe Laroque Philippe.Laroque@dept-info.u-cergy.fr $Id: rmi.lyx,v 1.2 2003/10/23 07:10:46 root Exp $ Abstract This small document describes the mechanisms involved

More information

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013 Masters programmes in Computer Science and Information Systems Object-Oriented Design and Programming Sample module entry test xxth December 2013 This sample paper has more questions than the real paper

More information

Overview of Web Services API

Overview of Web Services API 1 CHAPTER The Cisco IP Interoperability and Collaboration System (IPICS) 4.5(x) application programming interface (API) provides a web services-based API that enables the management and control of various

More information

Inheritance, overloading and overriding

Inheritance, overloading and overriding Inheritance, overloading and overriding Recall with inheritance the behavior and data associated with the child classes are always an extension of the behavior and data associated with the parent class

More information

ExempleRMI.java. // Fichier de defintion des droits et proprietes // System.setProperty("java.security.policy","../server.java.

ExempleRMI.java. // Fichier de defintion des droits et proprietes // System.setProperty(java.security.policy,../server.java. ExempleRMI.java import java.lang.*; import java.rmi.registry.*; import java.rmi.server.*; import java.io.*; import java.util.*; ExempleRMI.java import pkgexemple.*; public class ExempleRMI public static

More information

Licensed for viewing only. Printing is prohibited. For hard copies, please purchase from www.agileskills.org

Licensed for viewing only. Printing is prohibited. For hard copies, please purchase from www.agileskills.org Unit Test 301 CHAPTER 12Unit Test Unit test Suppose that you are writing a CourseCatalog class to record the information of some courses: class CourseCatalog { CourseCatalog() { void add(course course)

More information

Remote Method Invocation (RMI)

Remote Method Invocation (RMI) Remote Method Invocation (RMI) Remote Method Invocation (RMI) allows us to get a reference to an object on a remote host and use it as if it were on our virtual machine. We can invoke methods on the remote

More information

Web Service Caching Using Command Cache

Web Service Caching Using Command Cache Web Service Caching Using Command Cache Introduction Caching can be done at Server Side or Client Side. This article focuses on server side caching of web services using command cache. This article will

More information

CS 111 Classes I 1. Software Organization View to this point:

CS 111 Classes I 1. Software Organization View to this point: CS 111 Classes I 1 Software Organization View to this point: Data Objects and primitive types Primitive types operators (+, /,,*, %). int, float, double, char, boolean Memory location holds the data Objects

More information

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca

More information

Network Communication

Network Communication Network Communication Outline Sockets Datagrams TCP/IP Client-Server model OSI Model Sockets Endpoint for bidirectional communication between two machines. To connect with each other, each of the client

More information

Lecture 7: Java RMI. CS178: Programming Parallel and Distributed Systems. February 14, 2001 Steven P. Reiss

Lecture 7: Java RMI. CS178: Programming Parallel and Distributed Systems. February 14, 2001 Steven P. Reiss Lecture 7: Java RMI CS178: Programming Parallel and Distributed Systems February 14, 2001 Steven P. Reiss I. Overview A. Last time we started looking at multiple process programming 1. How to do interprocess

More information

Preet raj Core Java and Databases CS4PR. Time Allotted: 3 Hours. Final Exam: Total Possible Points 75

Preet raj Core Java and Databases CS4PR. Time Allotted: 3 Hours. Final Exam: Total Possible Points 75 Preet raj Core Java and Databases CS4PR Time Allotted: 3 Hours Final Exam: Total Possible Points 75 Q1. What is difference between overloading and overriding? 10 points a) In overloading, there is a relationship

More information

public void setusername(string username) { this.username = username; } public void setname(string name) { this.name = name; }

public void setusername(string username) { this.username = username; } public void setname(string name) { this.name = name; } User-klassen package domain; import dk.au.hum.imv.persistence.db.databasepersistent; public class User extends DatabasePersistent { private String username; private String name; private String address;

More information

UNIT TESTING. Written by Patrick Kua Oracle Australian Development Centre Oracle Corporation

UNIT TESTING. Written by Patrick Kua Oracle Australian Development Centre Oracle Corporation UNIT TESTING Written by Patrick Kua Oracle Australian Development Centre Oracle Corporation TABLE OF CONTENTS 1 Overview..1 1.1 Document Purpose..1 1.2 Target Audience1 1.3 References.1 2 Testing..2 2.1

More information

ECE 122. Engineering Problem Solving with Java

ECE 122. Engineering Problem Solving with Java ECE 122 Engineering Problem Solving with Java Introduction to Electrical and Computer Engineering II Lecture 1 Course Overview Welcome! What is this class about? Java programming somewhat software somewhat

More information

!"#$%&'()*+,-&#.-*%(/*0'//1#2%$#3*+4""5$&'()*65(&$511#/*7(&#$%8&'5( 9,*0%:*;%'1"#$'(

!#$%&'()*+,-&#.-*%(/*0'//1#2%$#3*+45$&'()*65(&$511#/*7(&#$%8&'5( 9,*0%:*;%'1#$'( !"#$%&'()*+,-&#.-*%(/*0'//1#2%$#3*+4""5$&'()*65(&$511#/*7(&#$%8&'5( 9,*0%:*;%'1"#$'( #$-'5(*5?*&='-*25$@*A7+BC*DEFGHEHIGJKELM*2%-*65",$')=&*N*IDDO*9,*

More information

Author: Sascha Wolski Sebastian Hennebrueder http://www.laliluna.de/tutorials.html Tutorials for Struts, EJB, xdoclet and eclipse.

Author: Sascha Wolski Sebastian Hennebrueder http://www.laliluna.de/tutorials.html Tutorials for Struts, EJB, xdoclet and eclipse. JUnit Testing JUnit is a simple Java testing framework to write tests for you Java application. This tutorial gives you an overview of the features of JUnit and shows a little example how you can write

More information

Intruduction to Groovy & Grails programming languages beyond Java

Intruduction to Groovy & Grails programming languages beyond Java Intruduction to Groovy & Grails programming languages beyond Java 1 Groovy, what is it? Groovy is a relatively new agile dynamic language for the Java platform exists since 2004 belongs to the family of

More information

AP Computer Science Java Subset

AP Computer Science Java Subset APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall

More information

API for java.util.iterator. ! hasnext() Are there more items in the list? ! next() Return the next item in the list.

API for java.util.iterator. ! hasnext() Are there more items in the list? ! next() Return the next item in the list. Sequences and Urns 2.7 Lists and Iterators Sequence. Ordered collection of items. Key operations. Insert an item, iterate over the items. Design challenge. Support iteration by client, without revealing

More information

RMI Client Application Programming Interface

RMI Client Application Programming Interface RMI Client Application Programming Interface Java Card 2.2 Java 2 Platform, Micro Edition Sun Microsystems, Inc. 901 San Antonio Road Palo Alto, CA 94303 U.S.A. 650-960-1300 June, 2002 Copyright 2002 Sun

More information

Chapter 2 Introduction to Java programming

Chapter 2 Introduction to Java programming Chapter 2 Introduction to Java programming 1 Keywords boolean if interface class true char else package volatile false byte final switch while throws float private case return native void protected break

More information

CSE 308. Coding Conventions. Reference

CSE 308. Coding Conventions. Reference CSE 308 Coding Conventions Reference Java Coding Conventions googlestyleguide.googlecode.com/svn/trunk/javaguide.html Java Naming Conventions www.ibm.com/developerworks/library/ws-tipnamingconv.html 2

More information

Java Interview Questions and Answers

Java Interview Questions and Answers 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java

More information

public class Autenticador { private static final ThreadLocal<UsuarioInterface> threadusuario = new ThreadLocal<UsuarioInterface>();

public class Autenticador { private static final ThreadLocal<UsuarioInterface> threadusuario = new ThreadLocal<UsuarioInterface>(); JBook Shadowing - Oracle Source folder: src/main/java Main package: br.com.infowaypi.jbook. Actual package: autenticacao Java file: Autenticador.java package br.com.infowaypi.jbook.autenticacao; public

More information

Email API Document. 2012 Webaroo Technology India Pvt. Ltd.

Email API Document. 2012 Webaroo Technology India Pvt. Ltd. Email API Document 2012 Webaroo Technology India Pvt. Ltd. All rights reserved. No parts of this work may be reproduced in any form or by any means - graphic, electronic, or mechanical, including photocopying,

More information

Problem 1 (1.5 points)

Problem 1 (1.5 points) Leganés, June 17th, 2014 Time: 120 min Systems Programming Extraordinary Call (Problems) Grade: 5 points out of 10 from the exam Problem 1 (1.5 points) City councils apply two types of municipal taxes

More information

Aufgabenstellung. Aufgabenstellung

Aufgabenstellung. Aufgabenstellung Aufgabenstellung Konto: Kontonummer, Inhaber, PIN, Guthaben, Zinssatz, Kreditrahmen Funktionsumfang: 1. Bankangestellte: - Einrichten neuer Konten - Änderung Kreditrahmen und Verzinsung für ein Konto Aufgabenstellung

More information

Developer's Guide: Driving Tivoli Workload Automation

Developer's Guide: Driving Tivoli Workload Automation IBM Tivoli Workload Automation Developer's Guide: Driving Tivoli Workload Automation Version 9 Release 1 SC23-9608-02 IBM Tivoli Workload Automation Developer's Guide: Driving Tivoli Workload Automation

More information

e ag u g an L g ter lvin v E ram Neal G g ro va P Ja

e ag u g an L g ter lvin v E ram Neal G g ro va P Ja Evolving the Java Programming Language Neal Gafter Overview The Challenge of Evolving a Language Design Principles Design Goals JDK7 and JDK8 Challenge: Evolving a Language What is it like trying to extend

More information

AdFalcon Android SDK 2.1.4 Developer's Guide. AdFalcon Mobile Ad Network Product of Noqoush Mobile Media Group

AdFalcon Android SDK 2.1.4 Developer's Guide. AdFalcon Mobile Ad Network Product of Noqoush Mobile Media Group AdFalcon Android SDK 214 Developer's Guide AdFalcon Mobile Ad Network Product of Noqoush Mobile Media Group Table of Contents 1 Introduction 3 Supported Android version 3 2 Project Configurations 4 Step

More information

Java Programming Language

Java Programming Language Lecture 1 Part II Java Programming Language Additional Features and Constructs Topics in Quantitative Finance: Numerical Solutions of Partial Differential Equations Instructor: Iraj Kani Subclasses and

More information

J a v a Quiz (Unit 3, Test 0 Practice)

J a v a Quiz (Unit 3, Test 0 Practice) Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points

More information

Brekeke PBX Web Service

Brekeke PBX Web Service Brekeke PBX Web Service User Guide Brekeke Software, Inc. Version Brekeke PBX Web Service User Guide Revised October 16, 2006 Copyright This document is copyrighted by Brekeke Software, Inc. Copyright

More information

European Access Point for Truck Parking Data

European Access Point for Truck Parking Data Delegated Regulation (EU) N 885/2013 of 15 May 2013 with regard to the provision of information services for safe and secure parking places for trucks and commercial vehicles European Access Point for

More information

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 The Java Type System By now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language,

More information

Project 4 DB A Simple database program

Project 4 DB A Simple database program Project 4 DB A Simple database program Due Date April (Friday) Before Starting the Project Read this entire project description before starting Learning Objectives After completing this project you should

More information

Java Cheatsheet. http://introcs.cs.princeton.edu/java/11cheatsheet/ Tim Coppieters Laure Philips Elisa Gonzalez Boix

Java Cheatsheet. http://introcs.cs.princeton.edu/java/11cheatsheet/ Tim Coppieters Laure Philips Elisa Gonzalez Boix Java Cheatsheet http://introcs.cs.princeton.edu/java/11cheatsheet/ Tim Coppieters Laure Philips Elisa Gonzalez Boix Hello World bestand genaamd HelloWorld.java naam klasse main methode public class HelloWorld

More information

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2015 The third

More information

Exception Handling. Overloaded methods Interfaces Inheritance hierarchies Constructors. OOP: Exception Handling 1

Exception Handling. Overloaded methods Interfaces Inheritance hierarchies Constructors. OOP: Exception Handling 1 Exception Handling Error handling in general Java's exception handling mechanism The catch-or-specify priciple Checked and unchecked exceptions Exceptions impact/usage Overloaded methods Interfaces Inheritance

More information

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2014 Jill Seaman

More information

Application Development with TCP/IP. Brian S. Mitchell Drexel University

Application Development with TCP/IP. Brian S. Mitchell Drexel University Application Development with TCP/IP Brian S. Mitchell Drexel University Agenda TCP/IP Application Development Environment Client/Server Computing with TCP/IP Sockets Port Numbers The TCP/IP Application

More information

Grundlæggende Programmering IT-C, Forår 2001. Model solutions to. Written exam in Introductory Programming

Grundlæggende Programmering IT-C, Forår 2001. Model solutions to. Written exam in Introductory Programming Question 1 Question 1.1 The program prints the following four lines: 8 14 18 2 Question 1.2 The program prints the following six lines: 2 7 16 Question 1.3 The problem is solved using two for-loops: static

More information

OTN Developer Day Enterprise Java. Hands on Lab Manual JPA 2.0 and Object Relational Mapping Basics

OTN Developer Day Enterprise Java. Hands on Lab Manual JPA 2.0 and Object Relational Mapping Basics OTN Developer Day Enterprise Java Hands on Lab Manual JPA 2.0 and Object Relational Mapping Basics I want to improve the performance of my application... Can I copy Java code to an HTML Extension? I coded

More information

Remote Method Invocation

Remote Method Invocation Goal of RMI Remote Method Invocation Implement distributed objects. Have a program running on one machine invoke a method belonging to an object whose execution is performed on another machine. Remote

More information

CS 1302 Ch 19, Binary I/O

CS 1302 Ch 19, Binary I/O CS 1302 Ch 19, Binary I/O Sections Pages Review Questions Programming Exercises 19.1-19.4.1, 19.6-19.6 710-715, 724-729 Liang s Site any Sections 19.1 Introduction 1. An important part of programming is

More information

Lecture J - Exceptions

Lecture J - Exceptions Lecture J - Exceptions Slide 1 of 107. Exceptions in Java Java uses the notion of exception for 3 related (but different) purposes: Errors: an internal Java implementation error was discovered E.g: out

More information

GridWorld AP Computer Science Case Study. Solutions Manual

GridWorld AP Computer Science Case Study. Solutions Manual GridWorld AP Computer Science Case Study Solutions Manual The AP Program wishes to acknowledge and to thank Judith Hromcik of Arlington High School in Arlington, Texas. Part 1 Answers: Do You Know? Set

More information

16.1 DataFlavor. 16.1.1 DataFlavor Methods. Variables

16.1 DataFlavor. 16.1.1 DataFlavor Methods. Variables In this chapter: DataFlavor Transferable Interface ClipboardOwner Interface Clipboard StringSelection UnsupportedFlavorException Reading and Writing the Clipboard 16 Data Transfer One feature that was

More information

CSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus

CSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus CSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus 1. Purpose This assignment exercises how to write a peer-to-peer communicating program using non-blocking

More information

Distributed Embedded Systems

Distributed Embedded Systems Distributed Embedded Systems Computer Architecture and Operating Systems 2 Content 1. Motivation 2. An Overview of Distributed Software Architecture Approaches 2.1 Pro & Contra Middleware 2.2 Message-Based

More information

EJB 3.0 and IIOP.NET. Table of contents. Stefan Jäger / stefanjaeger@bluewin.ch 2007-10-10

EJB 3.0 and IIOP.NET. Table of contents. Stefan Jäger / stefanjaeger@bluewin.ch 2007-10-10 Stefan Jäger / stefanjaeger@bluewin.ch EJB 3.0 and IIOP.NET 2007-10-10 Table of contents 1. Introduction... 2 2. Building the EJB Sessionbean... 3 3. External Standard Java Client... 4 4. Java Client with

More information

Software Development with UML and Java 2 SDJ I2, Spring 2010

Software Development with UML and Java 2 SDJ I2, Spring 2010 Software Development with UML and Java 2 SDJ I2, Spring 2010 Agenda week 7, 2010 Pakages Looking back Looking forward Packages Interfaces Page 1 Spring 2010 Download, Install/Setup 1. Java SE SDK (http://java.sun.com/javase/downloads)

More information

Java Remote Method Invocation Specification

Java Remote Method Invocation Specification Java Remote Method Invocation Specification Java Remote Method Invocation (RMI) is a distributed object model for the Java programming language that retains the semantics of the Java platform s object

More information

Lecture 7: Class design for security

Lecture 7: Class design for security Lecture topics Class design for security Visibility of classes, fields, and methods Implications of using inner classes Mutability Design for sending objects across JVMs (serialization) Visibility modifiers

More information

Mobile App Sensor Documentation (English Version)

Mobile App Sensor Documentation (English Version) Mobile App Sensor Documentation (English Version) Mobile App Sensor Documentation (English Version) Version: 1.2.1 Date: 2015-03-25 Author: email: Kantar Media spring support@spring.de Content Mobile App

More information

public void creditaccount(string accountnumber, float amount) { this.accounts.get(accountnumber).credit(amount); }

public void creditaccount(string accountnumber, float amount) { this.accounts.get(accountnumber).credit(amount); } package bank; //... public class Bank { private Map accounts; public Bank() { this.accounts = new HashMap(); public void addaccount(bankaccount account) { this.accounts.put(account.getnumber(),

More information

File class in Java. Scanner reminder. Files 10/19/2012. File Input and Output (Savitch, Chapter 10)

File class in Java. Scanner reminder. Files 10/19/2012. File Input and Output (Savitch, Chapter 10) File class in Java File Input and Output (Savitch, Chapter 10) TOPICS File Input Exception Handling File Output Programmers refer to input/output as "I/O". The File class represents files as objects. The

More information

Unit Testing and JUnit

Unit Testing and JUnit Unit Testing and JUnit Testing Objectives Tests intended to find errors Errors should be found quickly Good test cases have high p for finding a yet undiscovered error Successful tests cause program failure,

More information

Configure a SOAScheduler for a composite in SOA Suite 11g. By Robert Baumgartner, Senior Solution Architect ORACLE

Configure a SOAScheduler for a composite in SOA Suite 11g. By Robert Baumgartner, Senior Solution Architect ORACLE Configure a SOAScheduler for a composite in SOA Suite 11g By Robert Baumgartner, Senior Solution Architect ORACLE November 2010 Scheduler for the Oracle SOA Suite 11g: SOAScheduler Page 1 Prerequisite

More information

The Sun Certified Associate for the Java Platform, Standard Edition, Exam Version 1.0

The Sun Certified Associate for the Java Platform, Standard Edition, Exam Version 1.0 The following applies to all exams: Once exam vouchers are purchased you have up to one year from the date of purchase to use it. Each voucher is valid for one exam and may only be used at an Authorized

More information

CSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O

CSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O CSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O 1 Sending Output to a (Text) File import java.util.scanner; import java.io.*; public class TextFileOutputDemo1 public static void

More information

matsimj An Overview of the new MATSim Implementation in Java Marcel Rieser VSP, TU Berlin 2.10.2006 rieser@vsp.tu-berlin.de

matsimj An Overview of the new MATSim Implementation in Java Marcel Rieser VSP, TU Berlin 2.10.2006 rieser@vsp.tu-berlin.de matsimj An Overview of the new MATSim Implementation in Java Marcel Rieser VSP, TU Berlin rieser@vsp.tu-berlin.de 2.10.2006 MATSim Seminar 2006 Villa Garbald 1. 6.10.2006 What we will talk about 2 Overview

More information

Realizing Enterprise Integration Patterns in WebSphere

Realizing Enterprise Integration Patterns in WebSphere Universität Stuttgart Fakultät Informatik, Elektrotechnik und Informationstechnik Realizing Enterprise Integration Patterns in WebSphere Thorsten Scheibler, Frank Leymann Report 2005/09 October 20, 2005

More information

RPC over XML. Web services with Java. How to install it? Reference implementation. Setting the environment variables. Preparing the system

RPC over XML. Web services with Java. How to install it? Reference implementation. Setting the environment variables. Preparing the system RPC over XML Web services with Java Distributed Systems SS03 Layered architecture based on TCP Bottommost layer is HTTP SOAP (XML) sits above it LOT of W3C standards and W3C drafts describe it. Reference

More information

D06 PROGRAMMING with JAVA

D06 PROGRAMMING with JAVA Cicles Formatius de Grau Superior Desenvolupament d Aplicacions Informàtiques D06 PROGRAMMING with JAVA Ch13 Inheritance PowerPoint presentation, created by Angel A. Juan - ajuanp(@)gmail.com, for accompanying

More information

Programming by Contract. Programming by Contract: Motivation. Programming by Contract: Preconditions and Postconditions

Programming by Contract. Programming by Contract: Motivation. Programming by Contract: Preconditions and Postconditions COMP209 Object Oriented Programming Designing Classes 2 Mark Hall Programming by Contract (adapted from slides by Mark Utting) Preconditions Postconditions Class invariants Programming by Contract An agreement

More information

Ready, Set, Go Getting started with Tuscany

Ready, Set, Go Getting started with Tuscany Ready, Set, Go Getting started with Tuscany Install the Tuscany Distribution The first thing you do is to create a folder on you disk into which you will download the TUSCANY distribution. Next you download

More information

Massachusetts Institute of Technology 6.005: Elements of Software Construction Fall 2011 Quiz 1 October 14, 2011. Instructions

Massachusetts Institute of Technology 6.005: Elements of Software Construction Fall 2011 Quiz 1 October 14, 2011. Instructions Massachusetts Institute of Technology 6.005: Elements of Software Construction Fall 2011 Quiz 1 October 14, 2011 Name: Athena* User Name: Instructions This quiz is 50 minutes long. It contains 1 pages

More information

SOAP RPC. SimpleObjectAccessProtocol. RemoteProcedureCall mittels XML über Port 80. Sascha Sadikni BPS Präsentation

SOAP RPC. SimpleObjectAccessProtocol. RemoteProcedureCall mittels XML über Port 80. Sascha Sadikni BPS Präsentation SOAP RPC SimpleObjectAccessProtocol RemoteProcedureCall mittels XML über Port 80 Sascha Sadikni BPS Präsentation Übersicht SOAP im Überblick ApacheSOAP SOAP-Client XML Beispiel SOAP-Client Web (Apache)

More information

Yosemite National Park, California. CSE 114 Computer Science I Inheritance

Yosemite National Park, California. CSE 114 Computer Science I Inheritance Yosemite National Park, California CSE 114 Computer Science I Inheritance Containment A class contains another class if it instantiates an object of that class HAS-A also called aggregation PairOfDice

More information

Sample CSE8A midterm Multiple Choice (circle one)

Sample CSE8A midterm Multiple Choice (circle one) Sample midterm Multiple Choice (circle one) (2 pts) Evaluate the following Boolean expressions and indicate whether short-circuiting happened during evaluation: Assume variables with the following names

More information

The Java Series Introduction to Java RMI and CORBA. The Java Series. Java RMI and CORBA Raul RAMOS / CERN-IT User Support Slide 1

The Java Series Introduction to Java RMI and CORBA. The Java Series. Java RMI and CORBA Raul RAMOS / CERN-IT User Support Slide 1 The Java Series Introduction to Java RMI and CORBA Raul RAMOS / CERN-IT User Support Slide 1 What are RMI and CORBA for? Usually, in your application, once you instantiate objects, you can invoke methods

More information

Scheduling recurring tasks in Java applications

Scheduling recurring tasks in Java applications Introducing a simple generalisation of the Java language's Timer class Skill Level: Intermediate Tom White Lead Java Developer Kizoom 04 Nov 2003 All manner of Java applications commonly need to schedule

More information

Manual. Programmer's Guide for Java API

Manual. Programmer's Guide for Java API 2013-02-01 1 (15) Programmer's Guide for Java API Description This document describes how to develop Content Gateway services with Java API. TS1209243890 1.0 Company information TeliaSonera Finland Oyj

More information

Prof. Edwar Saliba Júnior

Prof. Edwar Saliba Júnior package Conexao; 2 3 /** 4 * 5 * @author Cynthia Lopes 6 * @author Edwar Saliba Júnior 7 */ 8 import java.io.filenotfoundexception; 9 import java.io.ioexception; 10 import java.sql.sqlexception; 11 import

More information

ICOM 4015: Advanced Programming

ICOM 4015: Advanced Programming ICOM 4015: Advanced Programming Lecture 10 Reading: Chapter Ten: Inheritance Copyright 2009 by John Wiley & Sons. All rights reserved. Chapter 10 Inheritance Chapter Goals To learn about inheritance To

More information

WRITING DATA TO A BINARY FILE

WRITING DATA TO A BINARY FILE WRITING DATA TO A BINARY FILE TEXT FILES VS. BINARY FILES Up to now, we have looked at how to write and read characters to and from a text file. Text files are files that contain sequences of characters.

More information

Java CPD (I) Frans Coenen Department of Computer Science

Java CPD (I) Frans Coenen Department of Computer Science Java CPD (I) Frans Coenen Department of Computer Science Content Session 1, 12:45-14:30 (First Java Programme, Inheritance, Arithmetic) Session 2, 14:45-16:45 (Input and Programme Constructs) Materials

More information

Crash Course in Java

Crash Course in Java Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network Programming and Distributed Computing Netprog 2002 Java Intro 1 What is

More information

Collections.sort(population); // Método de ordenamiento

Collections.sort(population); // Método de ordenamiento import java.util.collections; import java.util.linkedlist; import java.util.random; public class GeneticAlgorithms static long BEGIN; static final boolean _DEBUG = true; LinkedList population

More information

http://algs4.cs.princeton.edu dictionary find definition word definition book index find relevant pages term list of page numbers

http://algs4.cs.princeton.edu dictionary find definition word definition book index find relevant pages term list of page numbers ROBERT SEDGEWICK KEVI WAYE F O U R T H E D I T I O ROBERT SEDGEWICK KEVI WAYE ROBERT SEDGEWICK KEVI WAYE Symbol tables Symbol table applications Key-value pair abstraction. Insert a value with specified.

More information

Enabling Grids for E-sciencE. Web services tools. David Fergusson. www.eu-egee.org INFSO-RI-508833

Enabling Grids for E-sciencE. Web services tools. David Fergusson. www.eu-egee.org INFSO-RI-508833 Web services tools David Fergusson www.eu-egee.org Web services tools Java based ANT JWSDP/J2EE/Java Beans Axis Tomcat C based.net gsoap Perl based SOAP::Lite SOAP::Lite Collection of Perl modules which

More information

JAVA - EXCEPTIONS. An exception can occur for many different reasons, below given are some scenarios where exception occurs.

JAVA - EXCEPTIONS. An exception can occur for many different reasons, below given are some scenarios where exception occurs. http://www.tutorialspoint.com/java/java_exceptions.htm JAVA - EXCEPTIONS Copyright tutorialspoint.com An exception orexceptionalevent is a problem that arises during the execution of a program. When an

More information

Sophos Mobile Control Web service guide

Sophos Mobile Control Web service guide Sophos Mobile Control Web service guide Product version: 3.5 Document date: July 2013 Contents 1 About Sophos Mobile Control... 3 2 Prerequisites... 4 3 Server-side implementation... 5 4 Client-side implementation...

More information

CS5233 Components Models and Engineering

CS5233 Components Models and Engineering Prof. Dr. Th. Letschert CS5233 Components Models and Engineering - Komponententechnologien Master of Science (Informatik) Java Management Extensions: JMX Seite 1 JMX http://download.oracle.com/javase/tutorial/jmx/index.html

More information

LINKED DATA STRUCTURES

LINKED DATA STRUCTURES LINKED DATA STRUCTURES 1 Linked Lists A linked list is a structure in which objects refer to the same kind of object, and where: the objects, called nodes, are linked in a linear sequence. we keep a reference

More information

Using the Monitoring and Report Viewer Web Services

Using the Monitoring and Report Viewer Web Services CHAPTER 3 Using the Monitoring and Report Viewer Web Services This chapter describes the environment that you must set up to use the web services provided by the Monitoring and Report Viewer component

More information

Capario B2B EDI Transaction Connection. Technical Specification for B2B Clients

Capario B2B EDI Transaction Connection. Technical Specification for B2B Clients Capario B2B EDI Transaction Connection Technical Specification for B2B Clients Revision History Date Version Description Author 02/03/2006 Draft Explanation for external B2B clients on how to develop a

More information

Chapter 1 Java Program Design and Development

Chapter 1 Java Program Design and Development presentation slides for JAVA, JAVA, JAVA Object-Oriented Problem Solving Third Edition Ralph Morelli Ralph Walde Trinity College Hartford, CT published by Prentice Hall Java, Java, Java Object Oriented

More information

Brekeke PBX Version 3 Web Service Developer s Guide Brekeke Software, Inc.

Brekeke PBX Version 3 Web Service Developer s Guide Brekeke Software, Inc. Brekeke PBX Version 3 Web Service Developer s Guide Brekeke Software, Inc. Version Brekeke PBX Version 3 Web Service Developer s Guide Revised August 2013 Copyright This document is copyrighted by Brekeke

More information

Agenda. What is and Why Polymorphism? Examples of Polymorphism in Java programs 3 forms of Polymorphism

Agenda. What is and Why Polymorphism? Examples of Polymorphism in Java programs 3 forms of Polymorphism Polymorphism 1 Agenda What is and Why Polymorphism? Examples of Polymorphism in Java programs 3 forms of Polymorphism 2 What is & Why Polymorphism? 3 What is Polymorphism? Generally, polymorphism refers

More information

cs2010: algorithms and data structures

cs2010: algorithms and data structures cs2010: algorithms and data structures Lecture 11: Symbol Table ADT. Vasileios Koutavas 28 Oct 2015 School of Computer Science and Statistics Trinity College Dublin Algorithms ROBERT SEDGEWICK KEVIN WAYNE

More information

Java E-Commerce Martin Cooke, 2002 1

Java E-Commerce Martin Cooke, 2002 1 Java E-Commerce Martin Cooke, 2002 1 Enterprise Java Beans: an introduction Today s lecture Why is enterprise computing so complex? Component models and containers Session beans Entity beans Why is enterprise

More information