01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/util/tags/sakai_2-4-1/util-impl/impl/src/java/org/sakaiproject/id/impl/UuidV4IdComponent.java $
03: * $Id: UuidV4IdComponent.java 6832 2006-03-21 20:43:34Z ggolden@umich.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.id.impl;
21:
22: import org.apache.commons.id.uuid.VersionFourGenerator;
23: import org.apache.commons.logging.Log;
24: import org.apache.commons.logging.LogFactory;
25: import org.sakaiproject.id.api.IdManager;
26:
27: /**
28: * <p>
29: * UuidV4IdComponent implements the IdManager with a version 4 UUID generator from apache commons.
30: * </p>
31: */
32: public class UuidV4IdComponent implements IdManager {
33: /** Our log (commons). */
34: private static Log M_log = LogFactory
35: .getLog(UuidV4IdComponent.class);
36:
37: /** Our Id Generator. */
38: protected static final VersionFourGenerator VFG = new VersionFourGenerator();
39:
40: /**********************************************************************************************************************************************************************************************************************************************************
41: * Dependencies and their setter methods
42: *********************************************************************************************************************************************************************************************************************************************************/
43:
44: /**********************************************************************************************************************************************************************************************************************************************************
45: * Init and Destroy
46: *********************************************************************************************************************************************************************************************************************************************************/
47:
48: /**
49: * Final initialization, once all dependencies are set.
50: */
51: public void init() {
52: M_log.info("init()");
53: }
54:
55: /**
56: * Final cleanup.
57: */
58: public void destroy() {
59: M_log.info("destroy()");
60: }
61:
62: /**********************************************************************************************************************************************************************************************************************************************************
63: * Work interface methods: IdManager
64: *********************************************************************************************************************************************************************************************************************************************************/
65:
66: /**
67: * @inheritDoc
68: */
69: public String createUuid() {
70: String id = VFG.nextIdentifier().toString();
71:
72: return id;
73: }
74: }
|