01: /**********************************************************************
02: Copyright (c) 2004 Ralf Ullrich and others. All rights reserved.
03: Licensed under the Apache License, Version 2.0 (the "License");
04: you may not use this file except in compliance with the License.
05: You may obtain a copy of the License at
06:
07: http://www.apache.org/licenses/LICENSE-2.0
08:
09: Unless required by applicable law or agreed to in writing, software
10: distributed under the License is distributed on an "AS IS" BASIS,
11: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: See the License for the specific language governing permissions and
13: limitations under the License.
14:
15:
16: Contributors:
17: ...
18: **********************************************************************/package org.jpox.store.poid;
19:
20: import java.util.Properties;
21:
22: /**
23: * This generator uses a Java implementation of DCE UUIDs to create unique
24: * identifiers without the overhead of additional database transactions or even
25: * an open database connection. The identifiers are Strings of the form
26: * "LLLLLLLL-MMMM-HHHH-CCCC-NNNNNNNNNNNN" where 'L', 'M', 'H', 'C' and 'N' are
27: * the DCE UUID fields named time low, time mid, time high, clock sequence and
28: * node.
29: *
30: * This generator can be used in concurrent applications. It is especially
31: * useful in situations where large numbers of transactions within a certain
32: * amount of time have to be made, and the additional overhead of synchronizing
33: * the concurrent creation of unique identifiers through the database would
34: * break performance limits.
35: *
36: * There are no properties for this PoidGenerator.
37: *
38: * Note: Due to limitations of the available Java API there is a chance of less
39: * than 1:2^62 that two concurrently running JVMs will produce the same
40: * identifiers, which is in practical terms never, because your database server
41: * will have crashed a million times before this happens.
42: *
43: * @version $Revision: 1.4 $
44: */
45: public class AUIDPoidGenerator extends AbstractUIDPoidGenerator {
46: /**
47: * Constructor.
48: */
49: public AUIDPoidGenerator(String name, Properties props) {
50: super (name, props);
51: allocationSize = 1;
52: }
53:
54: /**
55: * Accessor for a new identifier.
56: * @return The identifier
57: */
58: protected String getIdentifier() {
59: return new AUID().toString();
60: }
61: }
|