ICE 3.4.2
[php5-ice-freebsdport.git] / java / demo / Freeze / library / BookI.java
blob91581ff14fb3755850d80fbc49ae81ca3f11a01f
1 // **********************************************************************
2 //
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
4 //
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
7 //
8 // **********************************************************************
10 import Demo.*;
12 class BookI extends Book
15 // No read/write mutexes in Java - hence use native
16 // synchronization.
19 synchronized public BookDescription
20 getBookDescription(Ice.Current current)
22 if(_destroyed)
24 throw new Ice.ObjectNotExistException();
28 // Immutable.
30 return description;
33 synchronized public String
34 getRenterName(Ice.Current current)
35 throws BookNotRentedException
37 if(_destroyed)
39 throw new Ice.ObjectNotExistException();
42 if(rentalCustomerName.length() == 0)
44 throw new BookNotRentedException();
46 return rentalCustomerName;
49 synchronized public void
50 rentBook(String name, Ice.Current current)
51 throws BookRentedException
53 if(_destroyed)
55 throw new Ice.ObjectNotExistException();
58 if(rentalCustomerName.length() != 0)
60 throw new BookRentedException();
62 rentalCustomerName = name;
65 synchronized public void
66 returnBook(Ice.Current current)
67 throws BookNotRentedException
69 if(_destroyed)
71 throw new Ice.ObjectNotExistException();
74 if(rentalCustomerName.length() == 0)
76 throw new BookNotRentedException();
78 rentalCustomerName = new String();;
81 synchronized public void
82 destroy(Ice.Current current)
83 throws DatabaseException
85 if(_destroyed)
87 throw new Ice.ObjectNotExistException();
90 _destroyed = true;
92 try
94 _library.remove(description);
96 catch(Freeze.DatabaseException ex)
98 DatabaseException e = new DatabaseException();
99 e.message = ex.message;
100 throw e;
104 BookI(LibraryI library)
106 _library = library;
107 _destroyed = false;
110 // This could be avoided by having two constructors (one for
111 // new creation of a book, and the other for restoring a
112 // previously saved book).
114 rentalCustomerName = new String();
117 private LibraryI _library;
118 private boolean _destroyed;