01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2003-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.data;
17:
18: /**
19: * Used to lock features when used with LockingDataSource.
20: * <p>
21: * This class is responsible for supplying a unique Authorization ID and
22: * expirery date for LockingDataSource locking operations.
23: * </p>
24: * Example:
25: * <table border=1, bgcolor="lightgray", width="100%"><tr><td><code><pre>
26: * FeatureLock lock1 = FeatureLockFactory.generate( 18*60*60 ); // expire in 18 min
27: * FeatureLock lock3 = FeatureLockFactory.generate( "MyLock", 30*60*60 ); // expire in 30 min
28: * </pre></code></td></tr></table>
29: * <p>
30: * Although it is tempting to have these FeatureLock objects stored in a static
31: * repository in the manner of GeoServer's TypeRepository.InternalLock -
32: * that decision should be left to the individual DataSources.
33: * </p>
34: * <p>An AbstractLockingDataSource with appropriate overrideable callbacks
35: * may be an elegent way to acomplish this.</p>
36: *
37: * @see <a href="http://vwfs.refractions.net/docs/Database_Research.pdf">Database_Research.pdf</a>
38: * @see <a href="http://vwfs.refractions.net/docs/Transactional_WFS_Design.pdf">Transactional_WFS_Design.pdf</a>
39: * @see <a href="http://vwfs.refractions.net/docs/Design_Implications.pdf">Design_Implications.pdf</a>
40: * @author jgarnett, Refractions Research, Inc.
41: * </p>
42: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/data/DefaultFeatureLock.java $
43: */
44: public class DefaultFeatureLock implements FeatureLock {
45: private final String authorization;
46: private final long duration;
47:
48: /**
49: * Package private constructor - use DefaultFeatureLockFactory methods.
50: * @see DefaultFeatureLockFactory.
51: */
52: DefaultFeatureLock(String id, long duration) {
53: this .authorization = id;
54: this .duration = duration;
55: }
56:
57: /** LockId used for transaction authorization. */
58: public String getAuthorization() {
59: return authorization;
60: }
61:
62: /** Time from now the lock will expire */
63: public long getDuration() {
64: return duration;
65: }
66: }
|