KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > ext > ObjectCallbacks


1 /* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com
2
3 This file is part of the db4o open source object database.
4
5 db4o is free software; you can redistribute it and/or modify it under
6 the terms of version 2 of the GNU General Public License as published
7 by the Free Software Foundation and as clarified by db4objects' GPL
8 interpretation policy, available at
9 http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
10 Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
11 Suite 350, San Mateo, CA 94403, USA.
12
13 db4o is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

21 package com.db4o.ext;
22
23 import com.db4o.*;
24
25 /**
26  * callback methods.
27  * <br><br><b>Examples: ../com/db4o/samples/callbacks.</b><br><br>
28  * This interface only serves as a lists of all available callback methods.
29  * Every method is called individually, independant of implementing this interface.<br><br>
30  * <b>Using callbacks</b><br>
31  * Simply implement one or more of the listed methods in your application classes to
32  * do tasks before activation, deactivation, delete, new or update, to cancel the
33  * action about to be performed and to respond to the performed task.
34  * <br><br>Callback methods are typically used for:
35  * <br>- cascaded delete
36  * <br>- cascaded update
37  * <br>- cascaded activation
38  * <br>- restoring transient members on instantiation
39  * <br><br>Callback methods follow regular calling conventions. Methods in superclasses
40  * need to be called explicitely.
41  * <br><br>All method calls are implemented to occur only once, upon one event.
42  */

43 public interface ObjectCallbacks {
44
45     /**
46      * called before an Object is activated.
47      * @param container the <code>ObjectContainer</code> the object is stored in.
48      * @return false to prevent activation.
49      */

50     public boolean objectCanActivate(ObjectContainer container);
51
52     /**
53      * called before an Object is deactivated.
54      * @param container the <code>ObjectContainer</code> the object is stored in.
55      * @return false to prevent deactivation.
56      */

57     public boolean objectCanDeactivate(ObjectContainer container);
58
59     /**
60      * called before an Object is deleted.
61      * <br><br>In a client/server setup this callback method will be executed on
62      * the server.
63      * @param container the <code>ObjectContainer</code> the object is stored in.
64      * @return false to prevent the object from being deleted.
65      */

66     public boolean objectCanDelete(ObjectContainer container);
67
68     /**
69      * called before an Object is stored the first time.
70      * @param container the <code>ObjectContainer</code> is about to be stored to.
71      * @return false to prevent the object from being stored.
72      */

73     public boolean objectCanNew(ObjectContainer container);
74
75     /**
76      * called before a persisted Object is updated.
77      * @param container the <code>ObjectContainer</code> the object is stored in.
78      * @return false to prevent the object from being updated.
79      */

80     public boolean objectCanUpdate(ObjectContainer container);
81     
82     /**
83      * called upon activation of an object.
84      * @param container the <code>ObjectContainer</code> the object is stored in.
85      */

86     public void objectOnActivate(ObjectContainer container);
87
88     /**
89      * called upon deactivation of an object.
90      * @param container the <code>ObjectContainer</code> the object is stored in.
91      */

92     public void objectOnDeactivate(ObjectContainer container);
93
94     /**
95      * called after an object was deleted.
96      * <br><br>In a client/server setup this callback method will be executed on
97      * the server.
98      * @param container the <code>ObjectContainer</code> the object was stored in.
99      */

100     public void objectOnDelete(ObjectContainer container);
101
102     /**
103      * called after a new object was stored.
104      * @param container the <code>ObjectContainer</code> the object is stored to.
105      */

106     public void objectOnNew(ObjectContainer container);
107
108     /**
109      * called after an object was updated.
110      * @param container the <code>ObjectContainer</code> the object is stored in.
111      */

112     public void objectOnUpdate(ObjectContainer container);
113 }
Popular Tags