01: // You can redistribute this software and/or modify it under the terms of
02: // the Ozone Core License version 1 published by ozone-db.org.
03: //
04: // The original code and portions created by SMB are
05: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
06: //
07: // $Id: DbModTimes.java,v 1.2 2002/06/08 00:49:38 mediumnet Exp $
08:
09: package org.ozoneDB.core.DbRemote;
10:
11: import java.io.*;
12: import org.ozoneDB.DxLib.*;
13: import org.ozoneDB.*;
14: import org.ozoneDB.core.*;
15: import org.ozoneDB.util.*;
16:
17: /**
18: * Determine the modification times of the specified database objects.
19: *
20: *
21: * @author <a href="http://www.softwarebuero.de/">SMB</a>
22: * @version $Revision: 1.2 $Date: 2002/06/08 00:49:38 $
23: */
24: public final class DbModTimes extends DbCommand implements
25: Externalizable {
26:
27: private DxArrayBag objectIDs;
28:
29: public DbModTimes() {
30: objectIDs = new DxArrayBag();
31: }
32:
33: public void addObjectID(ObjectID id) {
34: objectIDs.add(id);
35: }
36:
37: public void perform(Transaction ta) throws Exception {
38: env.logWriter.newEntry(this , "DbModTimes.perform()",
39: LogWriter.DEBUG);
40:
41: // check (and wait) if a thread runs exclusively; because no
42: // transaction is involved we have to do this here
43: env.transactionManager.checkExclusion();
44:
45: DxMap map = new DxHashMap(objectIDs.count());
46: for (int i = 0; i < objectIDs.count(); i++) {
47: ObjectID id = (ObjectID) objectIDs.elementAtIndex(i);
48:
49: env.logWriter.newEntry(this , " id:" + id,
50: LogWriter.DEBUG);
51:
52: ObjectContainer container = env.storeManager
53: .containerForIDAndPin(ta, id);
54: if (container == null) {
55: throw new ObjectNotFoundExc("No such object.");
56: }
57:
58: try {
59: Long modTime = new Long(container.modTime());
60:
61: map.addForKey(modTime, id);
62: } finally {
63: container.unpin();
64: }
65: }
66:
67: result = map;
68: }
69:
70: public void writeExternal(ObjectOutput out) throws IOException {
71: out.writeObject(objectIDs);
72: }
73:
74: public synchronized void readExternal(ObjectInput in)
75: throws IOException, ClassNotFoundException {
76: objectIDs = (DxArrayBag) in.readObject();
77: }
78:
79: }
|