1 18 package org.apache.activemq.console.formatter; 19 20 import javax.management.ObjectInstance ; 21 import javax.management.ObjectName ; 22 import javax.management.AttributeList ; 23 import javax.jms.Message ; 24 import java.util.Map ; 25 import java.util.Collection ; 26 import java.io.OutputStream ; 27 28 public class GlobalWriter { 29 private static OutputFormatter formatter; 30 31 34 private GlobalWriter() { 35 } 36 37 41 public static void instantiate(OutputFormatter formatter) { 42 GlobalWriter.formatter = formatter; 43 } 44 45 49 public static OutputStream getOutputStream() { 50 if (formatter == null) { 51 throw new IllegalStateException ("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter)."); 52 } 53 return formatter.getOutputStream(); 54 } 55 56 60 public static void printMBean(ObjectInstance mbean) { 61 if (formatter == null) { 62 throw new IllegalStateException ("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter)."); 63 } 64 formatter.printMBean(mbean); 65 } 66 67 71 public static void printMBean(ObjectName mbean) { 72 if (formatter == null) { 73 throw new IllegalStateException ("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter)."); 74 } 75 formatter.printMBean(mbean); 76 } 77 78 82 public static void printMBean(AttributeList mbean) { 83 if (formatter == null) { 84 throw new IllegalStateException ("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter)."); 85 } 86 formatter.printMBean(mbean); 87 } 88 89 93 public static void printMBean(Map mbean) { 94 if (formatter == null) { 95 throw new IllegalStateException ("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter)."); 96 } 97 formatter.printMBean(mbean); 98 } 99 100 104 public static void printMBean(Collection mbean) { 105 if (formatter == null) { 106 throw new IllegalStateException ("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter)."); 107 } 108 formatter.printMBean(mbean); 109 } 110 111 115 public static void printMessage(Map msg) { 116 if (formatter == null) { 117 throw new IllegalStateException ("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter)."); 118 } 119 formatter.printMessage(msg); 120 } 121 122 126 public static void printMessage(Message msg) { 127 if (formatter == null) { 128 throw new IllegalStateException ("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter)."); 129 } 130 formatter.printMessage(msg); 131 } 132 133 137 public static void printMessage(Collection msg) { 138 if (formatter == null) { 139 throw new IllegalStateException ("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter)."); 140 } 141 formatter.printMessage(msg); 142 } 143 144 148 public static void printHelp(String [] helpMsgs) { 149 if (formatter == null) { 150 throw new IllegalStateException ("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter)."); 151 } 152 formatter.printHelp(helpMsgs); 153 } 154 155 159 public static void printInfo(String info) { 160 if (formatter == null) { 161 throw new IllegalStateException ("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter)."); 162 } 163 formatter.printInfo(info); 164 } 165 166 170 public static void printException(Exception e) { 171 if (formatter == null) { 172 throw new IllegalStateException ("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter)."); 173 } 174 formatter.printException(e); 175 } 176 177 181 public static void printVersion(String version) { 182 if (formatter == null) { 183 throw new IllegalStateException ("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter)."); 184 } 185 formatter.printVersion(version); 186 } 187 188 192 public static void print(Map map) { 193 if (formatter == null) { 194 throw new IllegalStateException ("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter)."); 195 } 196 formatter.print(map); 197 } 198 199 203 public static void print(String [] strings) { 204 if (formatter == null) { 205 throw new IllegalStateException ("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter)."); 206 } 207 formatter.print(strings); 208 } 209 210 214 public static void print(Collection collection) { 215 if (formatter == null) { 216 throw new IllegalStateException ("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter)."); 217 } 218 formatter.print(collection); 219 } 220 221 225 public static void print(String string) { 226 if (formatter == null) { 227 throw new IllegalStateException ("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter)."); 228 } 229 formatter.print(string); 230 } 231 } 232 | Popular Tags |