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.impl;
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.Record;
15: import com.completex.objective.components.persistency.core.DatabasePolicy;
16: import com.completex.objective.components.persistency.transact.Transaction;
17:
18: /**
19: * Example of key generator section:
20: * <br>
21: * <PRE>
22: * keyGenerator = {
23: * class = com.completex.objective.components.persistency.key.impl.SimpleSequenceKeyGeneratorImpl
24: * staticAttributes = {
25: * name = CONTACT_SEQ
26: * }
27: * }
28: * </PRE>
29: * @author Gennady Krizhevsky
30: */
31: public class SimpleSequenceKeyGeneratorImpl extends
32: AbstractSimpleSequenceKeyGenerator {
33:
34: public SimpleSequenceKeyGeneratorImpl(
35: DatabasePolicy databasePolicy, String seqName, Log logger) {
36: setDatabasePolicy(databasePolicy);
37: setSeqName(seqName);
38: setLogger(logger);
39: }
40:
41: public SimpleSequenceKeyGeneratorImpl() {
42: }
43:
44: /**
45: * Generate next key value
46: *
47: * @param transaction
48: * @param persistency
49: * @return next key value
50: * @throws OdalPersistencyException
51: */
52: public Object getNextKey(Transaction transaction,
53: Persistency persistency) throws OdalPersistencyException {
54: return getNextKey(transaction, persistency, null, getSeqName());
55: }
56:
57: /**
58: * @see AbstractKeyGenerator#getNextKey(Transaction transaction, Persistency persistency, Record record)
59: */
60: public Object getNextKey(Transaction transaction,
61: Persistency persistency, Record record)
62: throws OdalPersistencyException {
63: return getNextKey(transaction, persistency, null, getSeqName());
64: }
65:
66: /**
67: * @see AbstractKeyGenerator#getNextKey(Transaction transaction, Persistency persistency, Record record, Object object)
68: */
69: public Object getNextKey(Transaction transaction,
70: Persistency persistency, Record record, Object object)
71: throws OdalPersistencyException {
72: return getNextKeyPlain(transaction, persistency,
73: (String) object);
74: }
75:
76: }
|