Issue #1514 - fixing bad websocket dump output
This commit is contained in:
parent
8ca70c691c
commit
0f98e607e8
|
@ -61,7 +61,8 @@ public class PathMappings<E> implements Iterable<MappedResource<E>>, Dumpable
|
|||
@Override
|
||||
public void dump(Appendable out, String indent) throws IOException
|
||||
{
|
||||
ContainerLifeCycle.dump(out,indent,_mappings);
|
||||
out.append("PathMappings[size=").append(Integer.toString(_mappings.size())).append("]\n");
|
||||
ContainerLifeCycle.dump(out, indent, _mappings);
|
||||
}
|
||||
|
||||
@ManagedAttribute(value = "mappings", readonly = true)
|
||||
|
|
|
@ -41,6 +41,7 @@ import javax.websocket.WebSocketContainer;
|
|||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
@ -72,6 +73,7 @@ import org.eclipse.jetty.websocket.jsr356.metadata.EndpointMetadata;
|
|||
* <p>
|
||||
* This should be specific to a JVM if run in a standalone mode. or specific to a WebAppContext if running on the Jetty server.
|
||||
*/
|
||||
@ManagedObject("JSR356 Client Container")
|
||||
public class ClientContainer extends ContainerLifeCycle implements WebSocketContainer, WebSocketContainerScope
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ClientContainer.class);
|
||||
|
|
|
@ -34,6 +34,7 @@ import javax.websocket.server.ServerEndpointConfig;
|
|||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.common.WebSocketSession;
|
||||
|
@ -46,6 +47,7 @@ import org.eclipse.jetty.websocket.jsr356.metadata.EndpointMetadata;
|
|||
import org.eclipse.jetty.websocket.server.NativeWebSocketConfiguration;
|
||||
import org.eclipse.jetty.websocket.server.WebSocketServerFactory;
|
||||
|
||||
@ManagedObject("JSR356 Server Container")
|
||||
public class ServerContainer extends ClientContainer implements javax.websocket.server.ServerContainer
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ServerContainer.class);
|
||||
|
|
|
@ -67,7 +67,10 @@ public class JsrBrowserDebugTool
|
|||
{
|
||||
JsrBrowserDebugTool tool = new JsrBrowserDebugTool();
|
||||
tool.setupServer(port);
|
||||
tool.runForever();
|
||||
tool.server.start();
|
||||
tool.server.dumpStdErr();
|
||||
LOG.info("Server available at {}", tool.server.getURI());
|
||||
tool.server.join();
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
|
@ -77,18 +80,12 @@ public class JsrBrowserDebugTool
|
|||
|
||||
private Server server;
|
||||
|
||||
private void runForever() throws Exception
|
||||
{
|
||||
server.start();
|
||||
server.dumpStdErr();
|
||||
LOG.info("Server available.");
|
||||
server.join();
|
||||
}
|
||||
|
||||
private void setupServer(int port) throws DeploymentException, ServletException, URISyntaxException, MalformedURLException, IOException
|
||||
private ServerContainer setupServer(int port) throws DeploymentException, ServletException, URISyntaxException, MalformedURLException, IOException
|
||||
{
|
||||
server = new Server();
|
||||
|
||||
server.setDumpAfterStart(true);
|
||||
|
||||
HttpConfiguration httpConf = new HttpConfiguration();
|
||||
httpConf.setSendServerVersion(true);
|
||||
|
||||
|
@ -113,5 +110,6 @@ public class JsrBrowserDebugTool
|
|||
container.addEndpoint(JsrBrowserSocket.class);
|
||||
|
||||
LOG.info("{} setup on port {}",this.getClass().getName(),port);
|
||||
return container;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
@ -30,7 +29,6 @@ import org.eclipse.jetty.http.pathmap.RegexPathSpec;
|
|||
import org.eclipse.jetty.http.pathmap.ServletPathSpec;
|
||||
import org.eclipse.jetty.http.pathmap.UriTemplatePathSpec;
|
||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
|
||||
import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
|
||||
|
@ -43,7 +41,7 @@ import org.eclipse.jetty.websocket.servlet.WebSocketCreator;
|
|||
* Only applicable if using {@link WebSocketUpgradeFilter}
|
||||
* </p>
|
||||
*/
|
||||
public class NativeWebSocketConfiguration extends ContainerLifeCycle implements MappedWebSocketCreator, Dumpable
|
||||
public class NativeWebSocketConfiguration extends ContainerLifeCycle implements MappedWebSocketCreator
|
||||
{
|
||||
private final WebSocketServerFactory factory;
|
||||
private final PathMappings<WebSocketCreator> mappings = new PathMappings<>();
|
||||
|
@ -57,6 +55,7 @@ public class NativeWebSocketConfiguration extends ContainerLifeCycle implements
|
|||
{
|
||||
this.factory = webSocketServerFactory;
|
||||
addBean(this.factory);
|
||||
addBean(this.mappings);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,19 +65,6 @@ public class NativeWebSocketConfiguration extends ContainerLifeCycle implements
|
|||
super.doStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String dump()
|
||||
{
|
||||
return ContainerLifeCycle.dump(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(Appendable out, String indent) throws IOException
|
||||
{
|
||||
// TODO: show factory/mappings ?
|
||||
mappings.dump(out, indent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get WebSocketServerFactory being used.
|
||||
*
|
||||
|
|
|
@ -631,4 +631,15 @@ public class WebSocketServerFactory extends ContainerLifeCycle implements WebSoc
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder(this.getClass().getSimpleName());
|
||||
sb.append('@').append(Integer.toHexString(hashCode()));
|
||||
sb.append("[defaultPolicy=").append(defaultPolicy);
|
||||
sb.append(",creator=").append(creator.getClass().getName());
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue