KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > OzoneCompatible


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: OzoneCompatible.java,v 1.11 2003/04/11 13:38:53 per_nyfelt Exp $
8

9 package org.ozoneDB;
10
11 import org.ozoneDB.core.*;
12 import java.io.*;
13
14 import org.xml.sax.ContentHandler JavaDoc;
15 import org.xml.sax.SAXException JavaDoc;
16
17
18 /**
19  * All objects that are stored in ozone have to implement this interface.
20  * The easiest way to build database objects is to extend the OzoneObject class,
21  * which implements OzoneCompatible already.
22  *
23  *
24  * @author <a HREF="http://www.softwarebuero.de/">SMB</a>
25  * @author Per Nyfelt
26  * @version $Revision: 1.11 $Date: 2003/04/11 13:38:53 $
27  */

28 public interface OzoneCompatible extends Serializable,OzoneCompatibleOrProxy {
29
30
31     /**
32      * Set the container of the receiver. The member that holds the actual
33      * reference must be <i>transient</i>.
34      */

35     public void setContainer( ObjectContainer _container );
36
37
38     /**
39      * Return the container of the receiver.
40      */

41     public ObjectContainer container();
42
43
44     /**
45      * Return a proxy for the receiver.
46      */

47     public OzoneProxy self();
48
49
50     /**
51      * Return the database link
52      */

53     public OzoneInterface database();
54
55     // callback methods
56

57
58     /**
59      * This method will be automaticly called when this object is created
60      * using createObject().
61      */

62     public void onCreate();
63
64     /**
65         This method will be automatically called after this object is
66         loaded (deserialized) from storage.
67
68         <DIV>
69             Note that there is currently a race condition: If another transaction tries to invoke
70             a method on this object as well, it may succeed before this method completes.
71             Thus, it is likely, but not guaranteed, that onActivate() is called before any other
72             method of the object. This may be fixed in the future.
73         </DIV>
74
75         <DIV>
76             This method may be called with this object being read-locked. That means, that you may
77             not, by default, change any member of this object (more precisely: of any object being member
78             of this {@link ObjectContainer}). If you detect within onActivate() that you need to change something,
79             you need to call {@link org.ozoneDB.OzoneObject#requireWriteLocking} before the first change.
80             Then, the lock is upgraded to write-locking.
81         </DIV>
82
83         You may not throw declared exceptions, because the method which tries to access you does not know that you do so.
84      */

85     public void onActivate();
86
87     /**
88         This method will be automaticly called emediately before this object is
89         stored (serialized) to storage.
90
91         This method will currently not be called.
92      */

93     public void onPassivate();
94
95     /**
96      * This method will be automaticly called when this object is deleted
97      * using deleteObject(). It should delete all database objects that depend
98      * on it and that are not otherwise reachable. In other words, this is the
99      * persistent destructor of the object.
100      */

101     public void onDelete();
102
103
104     // This Method is not needed anymore, because it is only used in ClassicStore
105
/**
106      * This method is automatically called by the ozone server to get an idea
107      * of the size of this object. The method should not return the actual
108      * current size of the object but the size the object will probably reach
109      * during its life time.
110      *
111      * @return The to be expected size of the object or -1 if a default value
112      * should be used.
113      *
114     public int size() throws Exception;
115     */

116
117
118     public boolean toXML( ContentHandler JavaDoc ch ) throws SAXException JavaDoc;
119
120 }
121 // :indentSize=4:tabSize=4:noTabs=true:
122
Popular Tags