1 20 package com.presumo.jms.persistence; 21 22 import com.presumo.jms.resources.Resources; 23 import com.presumo.util.log.Logger; 24 import com.presumo.util.log.LoggerFactory; 25 26 import java.io.DataInput ; 27 import java.io.DataOutput ; 28 import java.io.EOFException ; 29 import java.io.IOException ; 30 31 import java.util.HashSet ; 32 import java.util.LinkedList ; 33 34 38 abstract class LogFileEntry 39 { 40 abstract boolean writeAndProcess(LinkedList mainQueue, 41 LinkedList pendingDelete, 42 HashSet persistentDelete, 43 DataOutput out) throws IOException ; 44 45 abstract void read(DataInput in) throws IOException , EOFException ; 46 47 48 abstract void restore(LinkedList mainQueue, 49 LinkedList pendingDelete, 50 HashSet persistentDelete); 51 52 53 static final int INSERT = 0; 54 static final int DELETE = 1; 55 static final int GET_NEXT = 2; 56 57 60 static LogFileEntry deserialize(DataInput in) 61 throws IOException , EOFException 62 { 63 try { 64 logger.entry("deserialize"); 65 66 int type = in.readInt(); 67 LogFileEntry result = null; 68 switch (type) { 69 case INSERT: 70 result = new LogFileEntryInsert(); 71 break; 72 case DELETE: 73 result = new LogFileEntryDelete(); 74 break; 75 case GET_NEXT: 76 result = new LogFileEntryGetNext(); 77 break; 78 default: 79 IllegalArgumentException temp = new IllegalArgumentException ("Unknown log entry type: "+type); 80 logger.exception(temp); 81 throw temp; 82 } 83 result.read(in); 84 return result; 85 } 86 finally { 87 logger.exit("deserialize"); 88 } 89 } 90 91 private static Logger logger = 93 LoggerFactory.getLogger(LogFileEntry.class, Resources.getBundle()); 94 } 96 97 | Popular Tags |