1 16 package org.directwebremoting.extend; 17 18 import java.io.IOException ; 19 20 import javax.servlet.ServletOutputStream ; 21 22 import org.directwebremoting.ScriptBuffer; 23 import org.directwebremoting.util.LocalUtil; 24 25 32 public abstract class ScriptConduit implements Comparable 33 { 34 38 public ScriptConduit(int rank) 39 { 40 this.rank = rank; 41 } 42 43 53 public int getRank() 54 { 55 return rank; 56 } 57 58 63 public static final int RANK_PROCEDURAL = 10; 64 65 69 public static final int RANK_FAST = 5; 70 71 75 public static final int RANK_SLOW = 1; 76 77 91 public abstract boolean addScript(ScriptBuffer script) throws IOException , MarshallException; 92 93 96 public int compareTo(Object obj) 97 { 98 ScriptConduit that = (ScriptConduit) obj; 99 100 int rankdiff = this.getRank() - that.getRank(); 101 if (rankdiff != 0) 102 { 103 return rankdiff; 104 } 105 106 return (int) (this.id - that.id); 107 } 108 109 112 public String toString() 113 { 114 if (classname == null) 115 { 116 classname = LocalUtil.getShortClassName(getClass()); 117 } 118 119 return classname + "[id=" + id + "]"; 120 } 121 122 125 private static String classname = null; 126 127 130 private int rank; 131 132 135 private final long id = getNextId(); 136 137 141 private static synchronized long getNextId() 142 { 143 return nextId++; 144 } 145 146 149 private static long nextId = 0L; 150 } 151 | Popular Tags |