Merge pull request #7058 from eclipse/jetty-10.0.x-2504-WebSocketDump

Issue #2504 - expose more WebSocket details in jetty server dump
This commit is contained in:
Lachlan 2021-12-02 19:55:50 +11:00 committed by GitHub
commit 33c9536d12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 51 additions and 14 deletions

View File

@ -238,5 +238,15 @@ public interface Configuration
if (maxOutgoingFrames != null)
configurable.setMaxOutgoingFrames(maxOutgoingFrames);
}
@Override
public String toString()
{
return String.format("%s@%x{idleTimeout=%s, writeTimeout=%s, autoFragment=%s, maxFrameSize=%s, " +
"inputBufferSize=%s, outputBufferSize=%s, maxBinaryMessageSize=%s, maxTextMessageSize=%s, maxOutgoingFrames=%s}",
getClass().getSimpleName(), hashCode(),
idleTimeout, writeTimeout, autoFragment, maxFrameSize, inputBufferSize, outputBufferSize,
maxBinaryMessageSize, maxTextMessageSize, maxOutgoingFrames);
}
}
}

View File

@ -141,12 +141,6 @@ public class WebSocketMappings implements Dumpable, LifeCycle.Listener
}
}
@Override
public String dump()
{
return Dumpable.dump(this);
}
@Override
public void dump(Appendable out, String indent) throws IOException
{

View File

@ -112,6 +112,12 @@ public class WebSocketServerComponents extends WebSocketComponents
contextHandler.removeBean(serverComponents);
contextHandler.removeEventListener(this);
}
@Override
public String toString()
{
return String.format("%sCleanupListener", WebSocketServerComponents.class.getSimpleName());
}
});
servletContext.setAttribute(WEBSOCKET_COMPONENTS_ATTRIBUTE, serverComponents);

View File

@ -13,6 +13,7 @@
package org.eclipse.jetty.websocket.javax.common;
import java.io.IOException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashSet;
@ -26,13 +27,14 @@ import javax.websocket.WebSocketContainer;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.DecoratedObjectFactory;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.websocket.core.Configuration;
import org.eclipse.jetty.websocket.core.WebSocketComponents;
import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class JavaxWebSocketContainer extends ContainerLifeCycle implements javax.websocket.WebSocketContainer
public abstract class JavaxWebSocketContainer extends ContainerLifeCycle implements javax.websocket.WebSocketContainer, Dumpable
{
private static final Logger LOG = LoggerFactory.getLogger(JavaxWebSocketContainer.class);
private final List<JavaxWebSocketSessionListener> sessionListeners = new ArrayList<>();
@ -198,4 +200,10 @@ public abstract class JavaxWebSocketContainer extends ContainerLifeCycle impleme
}
}
}
@Override
public void dump(Appendable out, String indent) throws IOException
{
Dumpable.dumpObjects(out, indent, this, defaultCustomizer);
}
}

View File

@ -113,6 +113,12 @@ public class JavaxWebSocketServerContainer extends JavaxWebSocketClientContainer
contextHandler.removeEventListener(container);
contextHandler.removeEventListener(this);
}
@Override
public String toString()
{
return String.format("%sCleanupListener", JavaxWebSocketServerContainer.class.getSimpleName());
}
});
// Store a reference to the ServerContainer per - javax.websocket spec 1.0 final - section 6.4: Programmatic Server Deployment

View File

@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.http.pathmap.PathSpec;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.WebSocketBehavior;
@ -94,6 +95,12 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements
contextHandler.removeEventListener(container);
contextHandler.removeEventListener(this);
}
@Override
public String toString()
{
return String.format("%sCleanupListener", JettyWebSocketServerContainer.class.getSimpleName());
}
});
servletContext.setAttribute(JETTY_WEBSOCKET_CONTAINER_ATTRIBUTE, container);
@ -306,4 +313,10 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements
{
customizer.setAutoFragment(autoFragment);
}
@Override
public void dump(Appendable out, String indent) throws IOException
{
Dumpable.dumpObjects(out, indent, this, customizer);
}
}

View File

@ -134,6 +134,12 @@ public class WebSocketUpgradeFilter implements Filter, Dumpable
servletHandler.removeFilterMapping(mapping);
contextHandler.removeEventListener(this);
}
@Override
public String toString()
{
return String.format("%sCleanupListener", WebSocketUpgradeFilter.class.getSimpleName());
}
});
if (LOG.isDebugEnabled())
@ -164,16 +170,10 @@ public class WebSocketUpgradeFilter implements Filter, Dumpable
chain.doFilter(request, response);
}
@Override
public String dump()
{
return Dumpable.dump(this);
}
@Override
public void dump(Appendable out, String indent) throws IOException
{
Dumpable.dumpObjects(out, indent, this, mappings);
Dumpable.dumpObjects(out, indent, this, defaultCustomizer, mappings);
}
@Override