1 5 package com.tc.objectserver.context; 6 7 import com.tc.async.api.Sink; 8 import com.tc.net.protocol.tcm.ChannelID; 9 import com.tc.object.ObjectRequestID; 10 import com.tc.objectserver.api.ObjectManagerLookupResults; 11 import com.tc.text.PrettyPrintable; 12 import com.tc.text.PrettyPrinter; 13 14 import java.util.Collection ; 15 import java.util.Collections ; 16 import java.util.Date ; 17 import java.util.Map ; 18 import java.util.Set ; 19 20 23 public class ManagedObjectRequestContext implements ObjectManagerResultsContext, PrettyPrintable { 24 private final long timestamp; 25 private final ChannelID channelID; 26 private final Set requestedObjectIDs; 27 private Map objects; 28 private final ObjectRequestID requestID; 29 private boolean moreObjects = false; 30 private int batchCount = 0; 31 private Set lookupPendingObjectIDs; 32 private final int maxRequestDepth; 33 private final Sink sink; 34 35 public ManagedObjectRequestContext(ChannelID channelID, ObjectRequestID requestID, Set ids, int maxRequestDepth, 36 Sink sink) { 37 this.maxRequestDepth = maxRequestDepth; 38 this.sink = sink; 39 this.timestamp = System.currentTimeMillis(); 40 this.channelID = channelID; 41 this.requestID = requestID; 42 this.requestedObjectIDs = ids; 43 } 44 45 public int getMaxRequestDepth() { 46 return this.maxRequestDepth; 47 } 48 49 public boolean hasMoreObjects() { 50 return moreObjects; 51 } 52 53 public ChannelID getChannelID() { 54 return channelID; 55 } 56 57 public int getBatchCount() { 58 return batchCount; 59 } 60 61 public ObjectRequestID getRequestID() { 62 return this.requestID; 63 } 64 65 public Set getLookupIDs() { 66 return requestedObjectIDs; 67 } 68 69 public Collection getObjects() { 70 return objects.values(); 71 } 72 73 public Set getLookupPendingObjectIDs() { 74 return this.lookupPendingObjectIDs; 75 } 76 77 public PrettyPrinter prettyPrint(PrettyPrinter out) { 78 out.println("ManagedObjectRequestContext"); 79 PrettyPrinter rv = out; 80 out = out.duplicateAndIndent(); 81 out.indent().println(new Date (timestamp)); 82 out.indent().println("channelID: " + channelID); 83 out.indent().println("requestID: " + requestID); 84 out.indent().print("requestedObjectIDs: ").println(requestedObjectIDs); 85 return rv; 86 } 87 88 public void setResults(ObjectManagerLookupResults results) { 89 this.objects = results.getObjects(); 90 this.lookupPendingObjectIDs = results.getLookupPendingObjectIDs(); 91 this.sink.add(this); } 93 94 public Sink getSink() { 95 return this.sink; 96 } 97 98 public Set getNewObjectIDs() { 99 return Collections.EMPTY_SET; 100 } 101 102 } 103 | Popular Tags |