|
ozone API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ozoneDB.AbstractFactory
Abstract base class for all ozone-compatible factories. Normally such factories are generated by OPP and you need not bother with them. A factory has a bit of a schizophrenic nature: on the client-side it 'links' to an ExternalDatabase, while on the server-side it does so to the Database that holds the instances that the factory creates. Note however that a factory running inside an Ozone server can also be linked to an External database outside that server (userclient -> server A -> server B). In that case such a factory would be 'linked' an ExternalDatabase.
The idea behind factories is fourfold:
getDefault()
returns a factory that is
creates its objects inside that same server database and on the client side
it returns a factory that creates its objects in the default databasegetDefault() on the client side, you need to
call setDefaultDatabaseUrl(String)
to specify the default
database.
setDefaultDatabaseUrl(String)
on the client only
once, and for the rest of the programs lifespan call
xxxFactory.getDefault().create()
methods both on the server and
client sides to create objects.
Note: if you do not have a clue what factories are and how they work, you should probably brush up on your knowledge of design patterns.
Method Summary | |
void |
closeDatabase()
Closes the connection to the database this instance creates its objects in. |
boolean |
getAutoClose()
Gets current autoClose setting for this and all other factories linked to the same database. |
OzoneInterface |
getDatabase()
Returns the database this instance creates its objects in. |
static java.lang.String |
getDefaultDatabaseUrl()
|
void |
setAutoClose(boolean autoClose)
Sets current autoClose setting for this and all other factories linked to the same database. |
static void |
setDefaultDatabaseUrl(java.lang.String url)
Sets the url to identify the default database. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static void setDefaultDatabaseUrl(java.lang.String url)
Sets the url to identify the default database. This method can
only be called from a client; a call from within the server will surely
result in an exception, because in the server the default database is
the server itself. Note that after challing this method all
XxxFactory.getDefault()
methods return a different factory
than before.
This method calls both System.gc()
and System.runFinalization()
,
which usually means that if you have no references to factories linked
to the database identified by the former value of getDefaultDatabaseUrl
,
that the link to that database will be closed automatically (if
setAutoClose()
is true
).
url
- identifies the default database that factories created without
specifying a database URL (i.e. their default constructor) will create
their objects inpublic static java.lang.String getDefaultDatabaseUrl()
public final void closeDatabase() throws java.lang.Exception
Closes the connection to the database this instance creates its objects in. Closing happens at once, unlike the autoClose property.
Note: when you call this method, you close the connection to the database FOR ALL OTHER FACTORIES that link to the same database as this instance as well!
java.lang.Exception
getAutoClose()
,
setAutoClose(boolean)
public final OzoneInterface getDatabase()
Returns the database this instance creates its objects in.
public final boolean getAutoClose()
Gets current autoClose setting for this and all other factories
linked to the same database. When true
the connection to the
database this instance creates its objects in is closed when all
factories connected to that database are garbage collected.
public final void setAutoClose(boolean autoClose)
Sets current autoClose setting for this and all other factories
linked to the same database. When autoClose is true
the
connection to the database this instance creates its objects in is closed
when all factories connected to that database are garbage collected.
Note: when you call this method, change the auto-close settings for all other factories that link to the same database as this instance as well!
|
ozone API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |