Author: heiko.braun(a)jboss.com
Date: 2007-10-24 06:39:21 -0400 (Wed, 24 Oct 2007)
New Revision: 4876
Added:
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/log/DumpPipe.java
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/log/MessageLogPipelineHook.java
Modified:
stack/metro/branches/hbraun/metro_b_hbraun.iml
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/RequestHandlerImpl.java
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/metadata/RuntimeModelDeploymentAspect.java
Log:
Message trace, first cut
Modified: stack/metro/branches/hbraun/metro_b_hbraun.iml
===================================================================
--- stack/metro/branches/hbraun/metro_b_hbraun.iml 2007-10-24 10:27:49 UTC (rev 4875)
+++ stack/metro/branches/hbraun/metro_b_hbraun.iml 2007-10-24 10:39:21 UTC (rev 4876)
@@ -289,6 +289,24 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/junit.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/activation.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
<orderEntryProperties />
</component>
</module>
Modified:
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/RequestHandlerImpl.java
===================================================================
---
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/RequestHandlerImpl.java 2007-10-24
10:27:49 UTC (rev 4875)
+++
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/RequestHandlerImpl.java 2007-10-24
10:39:21 UTC (rev 4876)
@@ -132,11 +132,11 @@
public void handleRequest(Endpoint endpoint, InputStream inStream, OutputStream
outStream, InvocationContext context)
{
- throw new IllegalArgumentException("Not implemented");
+ throw new IllegalArgumentException("JBWS-1869: Not implemented");
}
public void handleWSDLRequest(Endpoint endpoint, OutputStream outStream,
InvocationContext context)
{
- throw new IllegalArgumentException("Not implemented");
+ throw new IllegalArgumentException("JBWS-1869: Not implemented");
}
}
Added:
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/log/DumpPipe.java
===================================================================
--- stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/log/DumpPipe.java
(rev 0)
+++
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/log/DumpPipe.java 2007-10-24
10:39:21 UTC (rev 4876)
@@ -0,0 +1,171 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.sunri.log;
+
+import com.sun.xml.ws.api.message.Packet;
+import com.sun.xml.ws.api.pipe.Pipe;
+import com.sun.xml.ws.api.pipe.PipeCloner;
+import com.sun.xml.ws.api.pipe.helper.AbstractFilterPipeImpl;
+import org.jboss.logging.Logger;
+
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.lang.reflect.Constructor;
+
+/**
+ * {@link Pipe} that dumps messages that pass through.
+ * Borrowed from the SUN-RI sources.
+ *
+ * @author Kohsuke Kawaguchi
+ * @author Heiko Braun
+ */
+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;
+
+ /**
+ * @param name
+ * Specify the name that identifies this {@link DumpPipe}
+ * instance. This string will be printed when this pipe
+ * 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.
+ */
+ 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)}
+ */
+ public DumpPipe(PrintStream out, Pipe next) {
+ this("DumpPipe",out,next);
+ }
+
+ /**
+ * Copy constructor.
+ */
+ 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) {
+ dump("request",packet);
+ Packet reply = next.process(packet);
+ dump("response",reply);
+ return reply;
+ }
+
+ private void dump(String header, Packet packet) {
+
+ if(!msgLog.isTraceEnabled())
+ return;
+
+ 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
+ }
+ });
+ writer = createIndenter(writer);
+ packet.getMessage().copy().writeTo(writer);
+ writer.close();
+
+ } 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.
+ *
+ * <p>
+ * We can do this only when we have <tt>stax-utils.jar</tt> in the
classpath.
+ */
+ 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");
+ }
+ }
+ return writer;
+ }
+
+
+ public Pipe copy(PipeCloner cloner) {
+ return new DumpPipe(this,cloner);
+ }
+
+ public void preDestroy() {
+ // noop
+ }
+
+ private static boolean warnStaxUtils;
+}
Property changes on:
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/log/DumpPipe.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/log/MessageLogPipelineHook.java
===================================================================
---
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/log/MessageLogPipelineHook.java
(rev 0)
+++
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/log/MessageLogPipelineHook.java 2007-10-24
10:39:21 UTC (rev 4876)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.sunri.log;
+
+import com.sun.xml.ws.api.server.ServerPipelineHook;
+import com.sun.xml.ws.api.pipe.Pipe;
+import com.sun.xml.ws.api.pipe.ServerPipeAssemblerContext;
+import com.sun.istack.NotNull;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ * @version $Revision$
+ */
+public class MessageLogPipelineHook extends ServerPipelineHook
+{
+
+ public
+ @NotNull
+ Pipe createMonitoringPipe(ServerPipeAssemblerContext ctxt, @NotNull Pipe tail)
+ {
+ return new DumpPipe("Message Log", System.out, tail);
+ }
+}
Property changes on:
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/log/MessageLogPipelineHook.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/metadata/RuntimeModelDeploymentAspect.java
===================================================================
---
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/metadata/RuntimeModelDeploymentAspect.java 2007-10-24
10:27:49 UTC (rev 4875)
+++
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/metadata/RuntimeModelDeploymentAspect.java 2007-10-24
10:39:21 UTC (rev 4876)
@@ -26,6 +26,7 @@
import com.sun.xml.ws.api.server.Container;
import com.sun.xml.ws.api.server.Module;
import com.sun.xml.ws.api.server.ResourceInjector;
+import com.sun.xml.ws.api.server.ServerPipelineHook;
import com.sun.xml.ws.transport.http.DeploymentDescriptorParser;
import com.sun.xml.ws.transport.http.ResourceLoader;
import com.sun.xml.ws.transport.http.servlet.ServletAdapter;
@@ -37,6 +38,7 @@
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
import org.jboss.wsf.stack.sunri.DeploymentDescriptorParserExt;
+import org.jboss.wsf.stack.sunri.log.MessageLogPipelineHook;
import javax.xml.ws.WebServiceException;
import java.io.IOException;
@@ -186,6 +188,10 @@
{
return (T)ResourceInjector.STANDALONE;
}
+ else if (spiType == ServerPipelineHook.class)
+ {
+ return (T)new MessageLogPipelineHook();
+ }
log.warn("Unable to resolve SPI for type: " + spiType);
return null;