Author: richard.opalka(a)jboss.com
Date: 2008-04-23 11:57:09 -0400 (Wed, 23 Apr 2008)
New Revision: 6635
Removed:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/injection/
Modified:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/log/DumpPipe.java
Log:
optimization + removing useless JBossWS Injection class
Modified: stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/log/DumpPipe.java
===================================================================
--- stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/log/DumpPipe.java 2008-04-23
15:27:15 UTC (rev 6634)
+++ stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/log/DumpPipe.java 2008-04-23
15:57:09 UTC (rev 6635)
@@ -41,14 +41,12 @@
* @author Kohsuke Kawaguchi
* @author Heiko Braun
*/
-public class DumpPipe extends AbstractFilterPipeImpl {
-
+public class DumpPipe extends AbstractFilterPipeImpl
+{
private static Logger msgLog =
Logger.getLogger("org.jboss.wsf.spi.MessageTrace");
private final String name;
-
private final PrintStream out;
-
private final XMLOutputFactory staxOut;
/**
@@ -58,114 +56,112 @@
* dumps messages, and allows people to distinguish which
* pipe instance is dumping a message when multiple
* {@link DumpPipe}s print messages out.
- * @param out
- * The output to send dumps to.
- * @param next
- * The next {@link Pipe} in the pipeline.
+ * @param out the output to send dumps to.
+ * @param next the next {@link Pipe} in the pipeline.
*/
- public DumpPipe(String name, PrintStream out, Pipe next) {
+ public DumpPipe(String name, PrintStream out, Pipe next)
+ {
super(next);
this.name = name;
this.out = out;
this.staxOut = XMLOutputFactory.newInstance();
- //staxOut.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES,true);
}
/**
- * @param out
- * The output to send dumps to.
- * @param next
- * The next {@link Pipe} in the pipeline.
- *
- * @deprecated
- * use {@link #DumpPipe(String, PrintStream, Pipe)}
+ * @param out the output to send dumps to.
+ * @param next the next {@link Pipe} in the pipeline.
+ * @deprecated use {@link #DumpPipe(String, PrintStream, Pipe)} instead
*/
- public DumpPipe(PrintStream out, Pipe next) {
+ public DumpPipe(PrintStream out, Pipe next)
+ {
this("DumpPipe",out,next);
}
/**
* Copy constructor.
*/
- private DumpPipe(DumpPipe that, PipeCloner cloner) {
+ private DumpPipe(DumpPipe that, PipeCloner cloner)
+ {
super(that,cloner);
this.name = that.name;
this.out = that.out;
this.staxOut = that.staxOut;
}
- public Packet process(Packet packet) {
+ public Packet process(Packet packet)
+ {
dump("request",packet);
Packet reply = next.process(packet);
dump("response",reply);
return reply;
}
- private void dump(String header, Packet packet) {
-
+ private void dump(String header, Packet packet)
+ {
if(!msgLog.isTraceEnabled())
return;
- msgLog.trace("====["+name+":"+header+"]====");
- if(packet.getMessage()==null)
+ msgLog.trace("====[" + name + ":" + header +
"]====");
+ if(packet.getMessage() == null)
{
msgLog.trace("(none)");
}
else
{
ByteArrayOutputStream bout = new ByteArrayOutputStream();
-
- try {
-
- XMLStreamWriter writer = staxOut.createXMLStreamWriter(new PrintStream(bout)
{
- public void close() {
- // noop
+ try
+ {
+ XMLStreamWriter writer = staxOut.createXMLStreamWriter(new PrintStream(bout)
+ {
+ public void close()
+ {
+ // does nothing
}
});
writer = createIndenter(writer);
packet.getMessage().copy().writeTo(writer);
writer.close();
-
- } catch (XMLStreamException e) {
+ }
+ catch (XMLStreamException e)
+ {
e.printStackTrace(new PrintStream(bout));
}
msgLog.trace(new String(bout.toByteArray()));
}
-
msgLog.trace("============");
}
/**
- * Wraps {@link XMLStreamWriter} by an indentation engine if possible.
- *
+ * Wraps {@link XMLStreamWriter} by an indentation engine if available.
* <p>
- * We can do this only when we have <tt>stax-utils.jar</tt> in the
classpath.
+ * We can do this only if we have <tt>stax-utils.jar</tt> on the
classpath.
+ * </p>
*/
- private XMLStreamWriter createIndenter(XMLStreamWriter writer) {
- try {
+ @SuppressWarnings("unchecked")
+ private XMLStreamWriter createIndenter(XMLStreamWriter writer)
+ {
+ try
+ {
Class clazz =
getClass().getClassLoader().loadClass("javanet.staxutils.IndentingXMLStreamWriter");
Constructor c = clazz.getConstructor(XMLStreamWriter.class);
writer = (XMLStreamWriter)c.newInstance(writer);
- } catch (Exception e) {
- // if stax-utils.jar is not in the classpath, this will fail
- // so, we'll just have to do without indentation
- if(!warnStaxUtils) {
- warnStaxUtils = true;
- msgLog.warn("WARNING: put stax-utils.jar to the classpath to indent the
dump output");
- }
}
+ catch (Exception e)
+ {
+ msgLog.warn("WARNING: put stax-utils.jar to the classpath to indent dumped
output");
+ }
return writer;
}
-
- public Pipe copy(PipeCloner cloner) {
- return new DumpPipe(this,cloner);
+ public Pipe copy(PipeCloner cloner)
+ {
+ return new DumpPipe(this, cloner);
}
- public void preDestroy() {
- // noop
+ public void preDestroy()
+ {
+ // does nothing
}
- private static boolean warnStaxUtils;
}
Show replies by date