1 // **********************************************************************
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
8 // **********************************************************************
12 class BookI
extends Book
15 // No read/write mutexes in Java - hence use native
19 synchronized public BookDescription
20 getBookDescription(Ice
.Current current
)
24 throw new Ice
.ObjectNotExistException();
33 synchronized public String
34 getRenterName(Ice
.Current current
)
35 throws BookNotRentedException
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
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
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
87 throw new Ice
.ObjectNotExistException();
94 _library
.remove(description
);
96 catch(Freeze
.DatabaseException ex
)
98 DatabaseException e
= new DatabaseException();
99 e
.message
= ex
.message
;
104 BookI(LibraryI library
)
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
;