1 18 package org.apache.activemq.openwire; 19 20 import org.apache.activemq.command.WireFormatInfo; 21 import org.apache.activemq.wireformat.WireFormat; 22 import org.apache.activemq.wireformat.WireFormatFactory; 23 24 27 public class OpenWireFormatFactory implements WireFormatFactory { 28 29 33 private int version=OpenWireFormat.DEFAULT_VERSION; 34 private boolean stackTraceEnabled=true; 35 private boolean tcpNoDelayEnabled=true; 36 private boolean cacheEnabled=true; 37 private boolean tightEncodingEnabled=true; 38 private boolean sizePrefixDisabled=false; 39 private long maxInactivityDuration=30*1000; 40 private int cacheSize=1024; 41 42 public WireFormat createWireFormat() { 43 WireFormatInfo info = new WireFormatInfo(); 44 info.setVersion(version); 45 46 try { 47 info.setStackTraceEnabled(stackTraceEnabled); 48 info.setCacheEnabled(cacheEnabled); 49 info.setTcpNoDelayEnabled(tcpNoDelayEnabled); 50 info.setTightEncodingEnabled(tightEncodingEnabled); 51 info.setSizePrefixDisabled(sizePrefixDisabled); 52 info.seMaxInactivityDuration(maxInactivityDuration); 53 info.setCacheSize(cacheSize); 54 } catch (Exception e) { 55 IllegalStateException ise = new IllegalStateException ("Could not configure WireFormatInfo"); 56 ise.initCause(e); 57 throw ise; 58 } 59 60 OpenWireFormat f = new OpenWireFormat(); 61 f.setPreferedWireFormatInfo(info); 62 return f; 63 } 64 65 public boolean isStackTraceEnabled() { 66 return stackTraceEnabled; 67 } 68 69 public void setStackTraceEnabled(boolean stackTraceEnabled) { 70 this.stackTraceEnabled = stackTraceEnabled; 71 } 72 73 public boolean isTcpNoDelayEnabled() { 74 return tcpNoDelayEnabled; 75 } 76 77 public void setTcpNoDelayEnabled(boolean tcpNoDelayEnabled) { 78 this.tcpNoDelayEnabled = tcpNoDelayEnabled; 79 } 80 81 public int getVersion() { 82 return version; 83 } 84 85 public void setVersion(int version) { 86 this.version = version; 87 } 88 89 public boolean isCacheEnabled() { 90 return cacheEnabled; 91 } 92 93 public void setCacheEnabled(boolean cacheEnabled) { 94 this.cacheEnabled = cacheEnabled; 95 } 96 97 public boolean isTightEncodingEnabled() { 98 return tightEncodingEnabled; 99 } 100 101 public void setTightEncodingEnabled(boolean tightEncodingEnabled) { 102 this.tightEncodingEnabled = tightEncodingEnabled; 103 } 104 105 public boolean isSizePrefixDisabled() { 106 return sizePrefixDisabled; 107 } 108 109 public void setSizePrefixDisabled(boolean sizePrefixDisabled) { 110 this.sizePrefixDisabled = sizePrefixDisabled; 111 } 112 113 public long getMaxInactivityDuration() { 114 return maxInactivityDuration; 115 } 116 117 public void setMaxInactivityDuration(long maxInactivityDuration) { 118 this.maxInactivityDuration = maxInactivityDuration; 119 } 120 121 public int getCacheSize() { 122 return cacheSize; 123 } 124 125 public void setCacheSize(int cacheSize) { 126 this.cacheSize = cacheSize; 127 } 128 } 129 | Popular Tags |