01: /**
02: * Objective Database Abstraction Layer (ODAL)
03: * Copyright (c) 2004, The ODAL Development Group
04: * All rights reserved.
05: * For definition of the ODAL Development Group please refer to LICENCE.txt file
06: *
07: * Distributable under LGPL license.
08: * See terms of license at gnu.org.
09: */package com.completex.objective.components.persistency.key;
10:
11: import com.completex.objective.components.log.Log;
12: import com.completex.objective.components.persistency.OdalPersistencyException;
13: import com.completex.objective.components.persistency.Persistency;
14: import com.completex.objective.components.persistency.PersistentEntry;
15: import com.completex.objective.components.persistency.core.DatabasePolicy;
16: import com.completex.objective.components.persistency.transact.Transaction;
17:
18: /**
19: * Interface to be implemented by Automatic Key Generators
20: *
21: * @author Gennady Krizhevsky
22: */
23: public interface AutoKeyGenerator {
24:
25: /**
26: * Set initial parameters (static in sense that once set they should never change)
27: *
28: * @param staticParameters
29: */
30: void setStaticParameters(Object staticParameters);
31:
32: /**
33: * Get initial parameters
34: *
35: * @return static Parameters
36: */
37: Object getStaticParameters();
38:
39: /**
40: * Setter for Database Policy
41: * @see DatabasePolicy
42: *
43: * @param databasePolicy
44: */
45: void setDatabasePolicy(DatabasePolicy databasePolicy);
46:
47: /**
48: * Setter for Log
49: * @see Log
50: *
51: * @param log
52: */
53: void setLogger(Log log);
54:
55: /**
56: * Implementing class should populate persistentEntry with value on insert of the record but only
57: * if not persistentEntry.isDirty() or if the entry is set to the value that is considered empty
58: * (0 or null, for example)
59: *
60: * @param transaction current transaction
61: * @param persistency persistency instance
62: * @param persistentEntry persistent entry to populate
63: * @throws OdalPersistencyException
64: */
65: void insertValue(Transaction transaction, Persistency persistency,
66: PersistentEntry persistentEntry)
67: throws OdalPersistencyException;
68:
69: /**
70: * Implementing class should normally populate persistentEntry with value on update of the record and only
71: * if persistentEntry.getRecord().isDirty() == true or complexDirty == true. Concrete implementation though
72: * may deviate from this recommended behaviour.
73: *
74: * @param transaction current transaction
75: * @param persistency persistency instance
76: * @param persistentEntry persistent entry to populate
77: * @param complexDirty true if object itself or any of its children is dirty
78: * @throws OdalPersistencyException
79: */
80: void updateValue(Transaction transaction, Persistency persistency,
81: PersistentEntry persistentEntry, boolean complexDirty)
82: throws OdalPersistencyException;
83:
84: }
|