KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > core > DbRemote > DbModTimes


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Core License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: DbModTimes.java,v 1.6 2002/12/29 11:15:56 per_nyfelt Exp $
8

9 package org.ozoneDB.core.DbRemote;
10
11 import org.ozoneDB.DxLib.*;
12 import org.ozoneDB.ObjectNotFoundException;
13 import org.ozoneDB.core.*;
14 import org.ozoneDB.util.LogWriter;
15
16 import java.io.*;
17
18
19 /**
20  * Determine the modification times of the specified database objects.
21  *
22  *
23  * @author <a HREF="http://www.softwarebuero.de/">SMB</a>
24  * @version $Revision: 1.6 $Date: 2002/12/29 11:15:56 $
25  */

26 public final class DbModTimes extends DbCommand implements Externalizable {
27
28     private DxArrayBag objectIDs;
29
30
31     public DbModTimes() {
32         objectIDs = new DxArrayBag();
33     }
34
35
36     public void addObjectID( ObjectID id ) {
37         objectIDs.add( id );
38     }
39
40
41     public void perform( Transaction ta ) throws Exception JavaDoc {
42         env.logWriter.newEntry( this, "DbModTimes.perform()", LogWriter.DEBUG );
43
44         // check (and wait) if a thread runs exclusively; because no
45
// transaction is involved we have to do this here
46
env.transactionManager.checkExclusion();
47
48         DxMap map = new DxHashMap( objectIDs.count() );
49         for (int i = 0; i < objectIDs.count(); i++) {
50             ObjectID id = (ObjectID)objectIDs.elementAtIndex( i );
51
52             env.logWriter.newEntry( this, " id:" + id, LogWriter.DEBUG );
53
54             ObjectContainer container = env.storeManager.containerForID( ta, id );
55             if (container == null) {
56                 throw new ObjectNotFoundException( "No such object." );
57             }
58
59             try {
60             Long JavaDoc modTime = new Long JavaDoc( container.modTime() );
61
62             map.addForKey( modTime, id );
63             } finally {
64                 container.unpin();
65             }
66         }
67
68         result = map;
69     }
70
71
72     public void writeExternal( ObjectOutput out ) throws IOException {
73         out.writeObject( objectIDs );
74     }
75
76
77     public synchronized void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException JavaDoc {
78         objectIDs = (DxArrayBag)in.readObject();
79     }
80
81 }
82
Popular Tags