01: ///////////////////////////////////////////////////////////////////////////////
02: //
03: // Copyright (C) 2003-@year@ by Thomas M. Hazel, MyOODB (www.myoodb.org)
04: //
05: // All Rights Reserved
06: //
07: // This program is free software; you can redistribute it and/or modify
08: // it under the terms of the GNU General Public License and GNU Library
09: // General Public License as published by the Free Software Foundation;
10: // either version 2, or (at your option) any later version.
11: //
12: // This program is distributed in the hope that it will be useful,
13: // but WITHOUT ANY WARRANTY; without even the implied warranty of
14: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: // GNU General Public License and GNU Library General Public License
16: // for more details.
17: //
18: // You should have received a copy of the GNU General Public License
19: // and GNU Library General Public License along with this program; if
20: // not, write to the Free Software Foundation, 675 Mass Ave, Cambridge,
21: // MA 02139, USA.
22: //
23: ///////////////////////////////////////////////////////////////////////////////
24: package org.myoodb.event;
25:
26: import org.myoodb.collectable.*;
27:
28: public class EventDbImpl extends LogObjectDbImpl implements Event {
29: private org.myoodb.core.Identifier m_identifier;
30:
31: public EventDbImpl() {
32: m_identifier = null;
33: }
34:
35: private void updateLogTime(boolean remove) {
36: EventLog eventLog = (EventLog) getLogStore();
37:
38: if (eventLog == null) {
39: throw new org.myoodb.exception.PermissionException(
40: "Event notification failed: no associated EventLog");
41: }
42:
43: if (remove == true) {
44: eventLog.removeEvent(this );
45: }
46:
47: setTime(LogObjectDbImpl.getSynchronizedLocalTime());
48: eventLog.addEvent(this );
49: }
50:
51: public void reNotify() {
52: if (m_identifier == null) {
53: throw new org.myoodb.exception.PermissionException(
54: "Re-Notify failed: event has not yet been posted");
55: }
56:
57: updateLogTime(true);
58: }
59:
60: public void notify(Collectable collectable) {
61: if (m_identifier != null) {
62: throw new org.myoodb.exception.PermissionException(
63: "Notify failed: event has already been posted");
64: }
65:
66: m_identifier = collectable.getDatabaseHandle();
67:
68: updateLogTime(false);
69: }
70:
71: public org.myoodb.core.Identifier getCollectableHandle() {
72: return m_identifier;
73: }
74: }
|