001: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
002:
003: This file is part of the db4o open source object database.
004:
005: db4o is free software; you can redistribute it and/or modify it under
006: the terms of version 2 of the GNU General Public License as published
007: by the Free Software Foundation and as clarified by db4objects' GPL
008: interpretation policy, available at
009: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
010: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
011: Suite 350, San Mateo, CA 94403, USA.
012:
013: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
014: WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: for more details.
017:
018: You should have received a copy of the GNU General Public License along
019: with this program; if not, write to the Free Software Foundation, Inc.,
020: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
021: package com.db4o.events;
022:
023: /**
024: * Provides the interface to register event handlers for
025: * {@link com.db4o.ObjectContainer} events.<br>
026: * EventRegistry methods represent events available for registering callbacks.
027: * An EventRegistry instance can be obtained from the {@link EventRegistryFactory}.
028: * <code>EventRegistry registry = EventRegistryFactory.forObjectContainer(container);</code>
029: * A new callback can be registered for an event with the following code:
030: * <code>registry.created().addListener(new EventListener4(){...});</code>
031: * @see EventRegistryFactory
032: * @see EventListener4
033: */
034: public interface EventRegistry {
035:
036: /**
037: * This event is fired upon a query start and can be used to gather
038: * query statistics.
039: * The query object is available from {@link QueryEventArgs}
040: * event parameter.<br>
041: * @sharpen.event com.db4o.events.QueryEventArgs
042: * @return event
043: * @see QueryEventArgs
044: */
045: public Event4 queryStarted();
046:
047: /**
048: * This event is fired upon a query end and can be used to gather
049: * query statistics.
050: * The query object is available from {@link QueryEventArgs}
051: * event parameter.<br>
052: * @sharpen.event com.db4o.events.QueryEventArgs
053: * @return event
054: * @see QueryEventArgs
055: */
056: public Event4 queryFinished();
057:
058: /**
059: * This event is fired before an object is saved for the first time.
060: * The object can be obtained from {@link CancellableObjectEventArgs}
061: * event parameter. The action can be cancelled using
062: * {@link CancellableObjectEventArgs#cancel()}
063: * @sharpen.event com.db4o.events.CancellableObjectEventArgs
064: * @return event
065: * @see CancellableObjectEventArgs
066: * @see com.db4o.ObjectContainer#set(Object)
067: */
068: public Event4 creating();
069:
070: /**
071: * This event is fired before an object is activated.
072: * The object can be obtained from {@link CancellableObjectEventArgs}
073: * event parameter. The action can be cancelled using
074: * {@link CancellableObjectEventArgs#cancel()}
075: * @sharpen.event com.db4o.events.CancellableObjectEventArgs
076: * @return event
077: * @see CancellableObjectEventArgs
078: * @see com.db4o.ObjectContainer#activate(Object, int)
079: */
080: public Event4 activating();
081:
082: /**
083: * This event is fired before an object is updated.
084: * The object can be obtained from {@link CancellableObjectEventArgs}
085: * event parameter. The action can be cancelled using
086: * {@link CancellableObjectEventArgs#cancel()}
087: *
088: * @sharpen.event com.db4o.events.CancellableObjectEventArgs
089: * @return event
090: * @see CancellableObjectEventArgs
091: * @see com.db4o.ObjectContainer#set(Object)
092: */
093: public Event4 updating();
094:
095: /**
096: * This event is fired before an object is deleted.
097: * The object can be obtained from {@link CancellableObjectEventArgs}
098: * event parameter. The action can be cancelled using
099: * {@link CancellableObjectEventArgs#cancel()}
100: *
101: * @sharpen.event com.db4o.events.CancellableObjectEventArgs
102: * @return event
103: * @see CancellableObjectEventArgs
104: * @see com.db4o.ObjectContainer#delete(Object)
105: */
106: public Event4 deleting();
107:
108: /**
109: * This event is fired before an object is deactivated.
110: * The object can be obtained from {@link CancellableObjectEventArgs}
111: * event parameter. The action can be cancelled using
112: * {@link CancellableObjectEventArgs#cancel()}
113: *
114: * @sharpen.event com.db4o.events.CancellableObjectEventArgs
115: * @return event
116: * @see CancellableObjectEventArgs
117: * @see com.db4o.ObjectContainer#deactivate(Object, int)
118: */
119: public Event4 deactivating();
120:
121: /**
122: * This event is fired after an object is activated.
123: * The object can be obtained from the {@link ObjectEventArgs}
124: * event parameter. <br><br>
125: * The event can be used to trigger some post-activation
126: * functionality.
127: *
128: * @sharpen.event com.db4o.events.ObjectEventArgs
129: * @return event
130: * @see ObjectEventArgs
131: * @see com.db4o.ObjectContainer#activate(Object, int)
132: */
133: public Event4 activated();
134:
135: /**
136: * This event is fired after an object is created (saved for the first time).
137: * The object can be obtained from the {@link ObjectEventArgs}
138: * event parameter.<br><br>
139: * The event can be used to trigger some post-creation
140: * functionality.
141: *
142: * @sharpen.event com.db4o.events.ObjectEventArgs
143: * @return event
144: * @see ObjectEventArgs
145: * @see com.db4o.ObjectContainer#set(Object)
146: */
147: public Event4 created();
148:
149: /**
150: * This event is fired after an object is updated.
151: * The object can be obtained from the {@link ObjectEventArgs}
152: * event parameter.<br><br>
153: * The event can be used to trigger some post-update
154: * functionality.
155: *
156: * @sharpen.event com.db4o.events.ObjectEventArgs
157: * @return event
158: * @see ObjectEventArgs
159: * @see com.db4o.ObjectContainer#set(Object)
160: */
161: public Event4 updated();
162:
163: /**
164: * This event is fired after an object is deleted.
165: * The object can be obtained from the {@link ObjectEventArgs}
166: * event parameter.<br><br>
167: * The event can be used to trigger some post-deletion
168: * functionality.
169: *
170: * @sharpen.event com.db4o.events.ObjectEventArgs
171: * @return event
172: * @see ObjectEventArgs
173: * @see com.db4o.ObjectContainer#delete(Object)
174: */
175: public Event4 deleted();
176:
177: /**
178: * This event is fired after an object is deactivated.
179: * The object can be obtained from the {@link ObjectEventArgs}
180: * event parameter.<br><br>
181: * The event can be used to trigger some post-deactivation
182: * functionality.
183: *
184: * @sharpen.event com.db4o.events.ObjectEventArgs
185: * @return event
186: * @see ObjectEventArgs
187: * @see com.db4o.ObjectContainer#delete(Object)
188: */
189: public Event4 deactivated();
190:
191: /**
192: * This event is fired after a transaction has been committed.
193: * The transaction and a list of the modified objects can
194: * be obtained from the {@link CommitEventArgs}
195: * event parameter.<br><br>
196: * Committing event gives a user a chance to interrupt the commit
197: * and rollback the transaction.
198: *
199: * @sharpen.event com.db4o.events.CommitEventArgs
200: * @return event
201: * @see CommitEventArgs
202: * @see com.db4o.ObjectContainer#commit()
203: */
204: public Event4 committing();
205:
206: /**
207: * This event is fired after a transaction has been committed.
208: * The transaction and a list of the modified objects can
209: * be obtained from the {@link CommitEventArgs}
210: * event parameter.<br><br>
211: * The event can be used to trigger some post-commit functionality.
212: *
213: * @sharpen.event com.db4o.events.CommitEventArgs
214: * @return event
215: * @see CommitEventArgs
216: * @see com.db4o.ObjectContainer#commit()
217: */
218: public Event4 committed();
219:
220: /**
221: * This event is fired when a persistent object is instantiated.
222: * The object can be obtained from the {@link ObjectEventArgs}
223: * event parameter.
224: *
225: * @sharpen.event com.db4o.events.ObjectEventArgs
226: * @return event
227: * @see ObjectEventArgs
228: */
229: public Event4 instantiated();
230:
231: /**
232: * This event is fired when a new class is registered with metadata.
233: * The class information can be obtained from {@link ClassEventArgs}
234: * event parameter.
235: *
236: * @sharpen.event com.db4o.events.ClassEventArgs
237: * @return event
238: * @see ClassEventArgs
239: */
240: public Event4 classRegistered();
241:
242: }
|