Merge remote-tracking branch 'origin/master' into jetty-http2
This commit is contained in:
commit
853e020210
|
@ -1,6 +1,5 @@
|
|||
This is a source checkout of the Jetty webserver.
|
||||
|
||||
|
||||
To build, use:
|
||||
|
||||
mvn clean install
|
||||
|
|
|
@ -36,7 +36,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.servlet.ServletContainerInitializer;
|
||||
import javax.servlet.annotation.HandlesTypes;
|
||||
|
||||
|
@ -557,16 +556,16 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
|||
boolean timeout = !latch.await(getMaxScanWait(context), TimeUnit.SECONDS);
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
{
|
||||
for (ParserTask p:_parserTasks)
|
||||
LOG.debug("Scanned {} in {}ms", p.getResource(), TimeUnit.MILLISECONDS.convert(p.getStatistic().getElapsed(), TimeUnit.NANOSECONDS));
|
||||
|
||||
LOG.debug("Scanned {} container path jars, {} WEB-INF/lib jars, {} WEB-INF/classes dirs in {}ms for context {}",
|
||||
_containerPathStats.getTotal(), _webInfLibStats.getTotal(), _webInfClassesStats.getTotal(),
|
||||
(TimeUnit.MILLISECONDS.convert(System.nanoTime()-start, TimeUnit.NANOSECONDS)),
|
||||
context);
|
||||
}
|
||||
|
||||
LOG.debug("Scanned {} container path jars, {} WEB-INF/lib jars, {} WEB-INF/classes dirs in {}ms for context {}",
|
||||
_containerPathStats.getTotal(), _webInfLibStats.getTotal(), _webInfClassesStats.getTotal(),
|
||||
(TimeUnit.MILLISECONDS.convert(System.nanoTime()-start, TimeUnit.NANOSECONDS)),
|
||||
context);
|
||||
|
||||
|
||||
if (timeout)
|
||||
me.add(new Exception("Timeout scanning annotations"));
|
||||
me.ifExceptionThrow();
|
||||
|
|
|
@ -214,7 +214,8 @@ public abstract class HttpDestination implements Destination, Closeable, Dumpabl
|
|||
public void close()
|
||||
{
|
||||
abort(new AsynchronousCloseException());
|
||||
LOG.debug("Closed {}", this);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Closed {}", this);
|
||||
}
|
||||
|
||||
public void release(Connection connection)
|
||||
|
|
|
@ -205,7 +205,8 @@ public abstract class HttpReceiver
|
|||
}
|
||||
catch (IOException x)
|
||||
{
|
||||
LOG.debug(x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug(x);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -451,7 +452,10 @@ public abstract class HttpReceiver
|
|||
{
|
||||
boolean updated = responseState.compareAndSet(from, to);
|
||||
if (!updated)
|
||||
LOG.debug("State update failed: {} -> {}: {}", from, to, responseState.get());
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("State update failed: {} -> {}: {}", from, to, responseState.get());
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,8 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
LOG.debug(x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug(x);
|
||||
failAndClose(x);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -123,7 +123,8 @@ public class HttpSenderOverHTTP extends HttpSender
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
LOG.debug(x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug(x);
|
||||
callback.failed(x);
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +182,8 @@ public class HttpSenderOverHTTP extends HttpSender
|
|||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
LOG.debug(x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug(x);
|
||||
callback.failed(x);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,7 +173,8 @@ public class InputStreamContentProvider implements ContentProvider
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
LOG.debug(x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug(x);
|
||||
if (failure == null)
|
||||
{
|
||||
failure = x;
|
||||
|
|
|
@ -150,7 +150,8 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements Connec
|
|||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
LOG.debug(x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug(x);
|
||||
close(x);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.eclipse.jetty.util.log.Logger;
|
|||
|
||||
public class ParamsContentParser extends ContentParser
|
||||
{
|
||||
private static final Logger logger = Log.getLogger(ParamsContentParser.class);
|
||||
private static final Logger LOG = Log.getLogger(ParamsContentParser.class);
|
||||
|
||||
private final ServerParser.Listener listener;
|
||||
private State state = State.LENGTH;
|
||||
|
@ -212,7 +212,8 @@ public class ParamsContentParser extends ContentParser
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
logger.debug("Exception while invoking listener " + listener, x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Exception while invoking listener " + listener, x);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,7 +225,8 @@ public class ParamsContentParser extends ContentParser
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
logger.debug("Exception while invoking listener " + listener, x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Exception while invoking listener " + listener, x);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -187,7 +187,8 @@ public class ResponseContentParser extends StreamContentParser
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
logger.debug("Exception while invoking listener " + listener, x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Exception while invoking listener " + listener, x);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,7 +200,8 @@ public class ResponseContentParser extends StreamContentParser
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
logger.debug("Exception while invoking listener " + listener, x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Exception while invoking listener " + listener, x);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,7 +213,8 @@ public class ResponseContentParser extends StreamContentParser
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
logger.debug("Exception while invoking listener " + listener, x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Exception while invoking listener " + listener, x);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,7 +235,8 @@ public class ResponseContentParser extends StreamContentParser
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
logger.debug("Exception while invoking listener " + listener, x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Exception while invoking listener " + listener, x);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,7 +268,8 @@ public class ResponseContentParser extends StreamContentParser
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
logger.debug("Exception while invoking listener " + listener, x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Exception while invoking listener " + listener, x);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.eclipse.jetty.util.log.Logger;
|
|||
|
||||
public class StreamContentParser extends ContentParser
|
||||
{
|
||||
protected static final Logger logger = Log.getLogger(StreamContentParser.class);
|
||||
private static final Logger LOG = Log.getLogger(StreamContentParser.class);
|
||||
|
||||
private final FCGI.StreamType streamType;
|
||||
private final Parser.Listener listener;
|
||||
|
@ -87,7 +87,8 @@ public class StreamContentParser extends ContentParser
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
logger.debug("Exception while invoking listener " + listener, x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Exception while invoking listener " + listener, x);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +100,8 @@ public class StreamContentParser extends ContentParser
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
logger.debug("Exception while invoking listener " + listener, x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Exception while invoking listener " + listener, x);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,8 @@ public class ServerFCGIConnection extends AbstractConnection
|
|||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
LOG.debug(x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug(x);
|
||||
// TODO: fail and close ?
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
|
||||
package org.eclipse.jetty.maven.plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
|
||||
/**
|
||||
* JettyEffectiveWebXml
|
||||
*
|
||||
* @goal effective-web-xml
|
||||
* @requiresDependencyResolution test
|
||||
* @execute phase="test-compile"
|
||||
* @description Runs jetty on the unassembled webapp to generate the effective web.xml
|
||||
*/
|
||||
public class JettyEffectiveWebXml extends JettyRunMojo
|
||||
{
|
||||
/**
|
||||
* The target directory
|
||||
*
|
||||
* @parameter expression="${project.build.directory}"
|
||||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
protected File target;
|
||||
|
||||
/**
|
||||
* The target directory
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
protected File effectiveWebXml;
|
||||
|
||||
|
||||
protected boolean deleteOnExit = true;
|
||||
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.plugin.Mojo#execute()
|
||||
*/
|
||||
public void execute() throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
super.execute();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void startJetty() throws MojoExecutionException
|
||||
{
|
||||
//Only do enough setup to be able to produce a quickstart-web.xml file to
|
||||
//pass onto the forked process to run
|
||||
|
||||
//if the user didn't nominate a file to generate into, pick the name and
|
||||
//make sure that it is deleted on exit
|
||||
if (effectiveWebXml == null)
|
||||
{
|
||||
deleteOnExit = true;
|
||||
effectiveWebXml = new File(target, "effective-web.xml");
|
||||
effectiveWebXml.deleteOnExit();
|
||||
}
|
||||
|
||||
Resource descriptor = Resource.newResource(effectiveWebXml);
|
||||
|
||||
QueuedThreadPool tpool = null;
|
||||
|
||||
try
|
||||
{
|
||||
printSystemProperties();
|
||||
|
||||
//apply any config from a jetty.xml file first to our "fake" server instance
|
||||
//TODO probably not necessary
|
||||
applyJettyXml ();
|
||||
|
||||
|
||||
server.configureHandlers();
|
||||
|
||||
//ensure config of the webapp based on settings in plugin
|
||||
configureWebApplication();
|
||||
|
||||
|
||||
//set the webapp up to do very little other than generate the quickstart-web.xml
|
||||
webApp.setCopyWebDir(false);
|
||||
webApp.setCopyWebInf(false);
|
||||
webApp.setGenerateQuickStart(true);
|
||||
|
||||
if (!effectiveWebXml.getParentFile().exists())
|
||||
effectiveWebXml.getParentFile().mkdirs();
|
||||
if (!effectiveWebXml.exists())
|
||||
effectiveWebXml.createNewFile();
|
||||
|
||||
webApp.setQuickStartWebDescriptor(descriptor);
|
||||
|
||||
server.addWebApplication(webApp);
|
||||
|
||||
//if our server has a thread pool associated we can do any annotation scanning multithreaded,
|
||||
//otherwise scanning will be single threaded
|
||||
tpool = server.getBean(QueuedThreadPool.class);
|
||||
if (tpool != null)
|
||||
tpool.start();
|
||||
else
|
||||
webApp.setAttribute(AnnotationConfiguration.MULTI_THREADED, Boolean.FALSE.toString());
|
||||
|
||||
webApp.start(); //just enough to generate the quickstart
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new MojoExecutionException("Effective web.xml generation failed", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try {webApp.stop();}catch (Exception x) {};
|
||||
|
||||
try {if (tpool != null) tpool.stop();} catch (Exception x) {};
|
||||
}
|
||||
|
||||
|
||||
if (deleteOnExit)
|
||||
{
|
||||
try
|
||||
{
|
||||
//just show the result in the log
|
||||
getLog().info(IO.toString(descriptor.getInputStream()));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new MojoExecutionException("Unable to output effective web.xml", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -43,6 +43,7 @@ import org.apache.maven.plugin.MojoExecutionException;
|
|||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
||||
import org.eclipse.jetty.quickstart.QuickStartDescriptorGenerator;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.resource.ResourceCollection;
|
||||
|
@ -98,6 +99,13 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
|||
*/
|
||||
protected File target;
|
||||
|
||||
/**
|
||||
* The file into which to generate the quickstart web xml for the forked process to use
|
||||
*
|
||||
* @parameter expression="${project.build.directory}/fork-web.xml"
|
||||
*/
|
||||
protected File forkWebXml;
|
||||
|
||||
|
||||
/**
|
||||
* Arbitrary jvm args to pass to the forked process
|
||||
|
@ -229,7 +237,11 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
|||
public void startJetty() throws MojoExecutionException
|
||||
{
|
||||
//Only do enough setup to be able to produce a quickstart-web.xml file to
|
||||
//pass onto the forked process to run
|
||||
//pass onto the forked process to run
|
||||
|
||||
if (forkWebXml == null)
|
||||
forkWebXml = new File (target, "fork-web.xml");
|
||||
|
||||
try
|
||||
{
|
||||
printSystemProperties();
|
||||
|
@ -251,7 +263,13 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
|||
webApp.setCopyWebDir(false);
|
||||
webApp.setCopyWebInf(false);
|
||||
webApp.setGenerateQuickStart(true);
|
||||
webApp.setQuickStartDir(target);
|
||||
|
||||
if (!forkWebXml.getParentFile().exists())
|
||||
forkWebXml.getParentFile().mkdirs();
|
||||
if (!forkWebXml.exists())
|
||||
forkWebXml.createNewFile();
|
||||
|
||||
webApp.setQuickStartWebDescriptor(Resource.newResource(forkWebXml));
|
||||
|
||||
server.addWebApplication(webApp);
|
||||
|
||||
|
|
|
@ -55,8 +55,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
|||
* This can be used, for example, to deploy a static webapp that is not part of your maven build.
|
||||
* </p>
|
||||
* <p>
|
||||
* There is a <a href="run-mojo.html">reference guide</a> to the configuration parameters for this plugin, and more detailed information
|
||||
* with examples in the <a href="http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin">Configuration Guide</a>.
|
||||
* There is a <a href="http://www.eclipse.org/jetty/documentation/current/maven-and-jetty.html">reference guide</a> to the configuration parameters for this plugin.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.maven.plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -66,7 +67,7 @@ public class JettyWebAppContext extends WebAppContext
|
|||
|
||||
|
||||
|
||||
private static final String DEFAULT_CONTAINER_INCLUDE_JAR_PATTERN = ".*/javax.servlet-[^/]*\\.jar$|.*/servlet-api-[^/]*\\.jar$|.*javax.servlet.jsp.jstl-[^/]*\\.jar";
|
||||
private static final String DEFAULT_CONTAINER_INCLUDE_JAR_PATTERN = ".*/javax.servlet-[^/]*\\.jar$|.*/servlet-api-[^/]*\\.jar$|.*javax.servlet.jsp.jstl-[^/]*\\.jar|.*taglibs-standard-impl-.*\\.jar";
|
||||
private static final String WEB_INF_CLASSES_PREFIX = "/WEB-INF/classes";
|
||||
private static final String WEB_INF_LIB_PREFIX = "/WEB-INF/lib";
|
||||
|
||||
|
@ -125,7 +126,7 @@ public class JettyWebAppContext extends WebAppContext
|
|||
|
||||
private boolean _isGenerateQuickStart;
|
||||
private PreconfigureDescriptorProcessor _preconfigProcessor;
|
||||
private File _quickStartDir;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -274,15 +275,7 @@ public class JettyWebAppContext extends WebAppContext
|
|||
return _isGenerateQuickStart;
|
||||
}
|
||||
|
||||
public void setQuickStartDir (File dir)
|
||||
{
|
||||
_quickStartDir = dir;
|
||||
}
|
||||
|
||||
public File getQuickStartDir()
|
||||
{
|
||||
return _quickStartDir;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -290,9 +283,14 @@ public class JettyWebAppContext extends WebAppContext
|
|||
{
|
||||
if (isGenerateQuickStart())
|
||||
{
|
||||
QuickStartDescriptorGenerator generator = new QuickStartDescriptorGenerator(this, (getQuickStartDir()==null?getTempDirectory():getQuickStartDir()), _preconfigProcessor.getXML());
|
||||
File f = generator.generateQuickStartWebXml();
|
||||
setQuickStartWebDescriptor(Resource.newResource(f));
|
||||
if (getQuickStartWebDescriptor() == null)
|
||||
throw new IllegalStateException ("No location to generate quickstart descriptor");
|
||||
|
||||
QuickStartDescriptorGenerator generator = new QuickStartDescriptorGenerator(this, _preconfigProcessor.getXML());
|
||||
try (FileOutputStream fos = new FileOutputStream(getQuickStartWebDescriptor().getFile()))
|
||||
{
|
||||
generator.generateQuickStartWebXml(fos);
|
||||
}
|
||||
}
|
||||
else
|
||||
super.startWebapp();
|
||||
|
@ -303,7 +301,9 @@ public class JettyWebAppContext extends WebAppContext
|
|||
public void doStart () throws Exception
|
||||
{
|
||||
//choose if this will be a quickstart or normal start
|
||||
if (getQuickStartWebDescriptor() == null)
|
||||
if (!isGenerateQuickStart() && getQuickStartWebDescriptor() != null)
|
||||
setConfigurations(_quickStartConfigurations);
|
||||
else
|
||||
{
|
||||
setConfigurations(_defaultConfigurations);
|
||||
if (isGenerateQuickStart())
|
||||
|
@ -312,8 +312,6 @@ public class JettyWebAppContext extends WebAppContext
|
|||
getMetaData().addDescriptorProcessor(_preconfigProcessor);
|
||||
}
|
||||
}
|
||||
else
|
||||
setConfigurations(_quickStartConfigurations);
|
||||
|
||||
|
||||
//inject configurations with config from maven plugin
|
||||
|
|
|
@ -456,7 +456,8 @@ public class ConnectHandler extends HandlerWrapper
|
|||
@Override
|
||||
public Connection newConnection(SocketChannel channel, EndPoint endpoint, Object attachment) throws IOException
|
||||
{
|
||||
ConnectHandler.LOG.debug("Connected to {}", channel.getRemoteAddress());
|
||||
if (ConnectHandler.LOG.isDebugEnabled())
|
||||
ConnectHandler.LOG.debug("Connected to {}", channel.getRemoteAddress());
|
||||
ConnectContext connectContext = (ConnectContext)attachment;
|
||||
UpstreamConnection connection = newUpstreamConnection(endpoint, connectContext);
|
||||
connection.setInputBufferSize(getBufferSize());
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.io.File;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EventListener;
|
||||
|
@ -75,21 +76,21 @@ import org.eclipse.jetty.xml.XmlAppendable;
|
|||
public class QuickStartDescriptorGenerator
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(QuickStartDescriptorGenerator.class);
|
||||
|
||||
public static final String DEFAULT_QUICKSTART_DESCRIPTOR_NAME = "quickstart-web.xml";
|
||||
|
||||
protected WebAppContext _webApp;
|
||||
protected File _descriptorDir;
|
||||
protected String _extraXML;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param w the source WebAppContext
|
||||
* @param descriptorDir the directory where quickstart-web.xml should be saved
|
||||
* @param extraXML any extra xml snippet to append
|
||||
*/
|
||||
public QuickStartDescriptorGenerator (WebAppContext w, File descriptorDir, String extraXML)
|
||||
public QuickStartDescriptorGenerator (WebAppContext w, String extraXML)
|
||||
{
|
||||
_webApp = w;
|
||||
_descriptorDir = descriptorDir;
|
||||
_extraXML = extraXML;
|
||||
}
|
||||
|
||||
|
@ -100,424 +101,406 @@ public class QuickStartDescriptorGenerator
|
|||
* @throws FileNotFoundException
|
||||
* @throws Exception
|
||||
*/
|
||||
public File generateQuickStartWebXml () throws FileNotFoundException, IOException
|
||||
public void generateQuickStartWebXml (OutputStream stream) throws FileNotFoundException, IOException
|
||||
{
|
||||
if (_webApp == null)
|
||||
throw new IllegalStateException("No webapp for quickstart-web.xml");
|
||||
if (_descriptorDir == null)
|
||||
throw new IllegalStateException("No location for quickstart-web.xml");
|
||||
throw new IllegalStateException("No webapp for quickstart generation");
|
||||
if (stream == null)
|
||||
throw new IllegalStateException("No output for quickstart generation");
|
||||
|
||||
_webApp.getMetaData().getOrigins();
|
||||
|
||||
if (_webApp.getBaseResource()==null)
|
||||
throw new IllegalArgumentException("No base resource for "+this);
|
||||
|
||||
if (!_descriptorDir.exists())
|
||||
_descriptorDir.mkdirs();
|
||||
|
||||
File webXml = new File(_descriptorDir,"quickstart-web.xml");
|
||||
|
||||
LOG.info("Quickstart generate {}",webXml);
|
||||
|
||||
try (FileOutputStream fos = new FileOutputStream(webXml))
|
||||
{
|
||||
XmlAppendable out = new XmlAppendable(fos,"UTF-8");
|
||||
LOG.info("Quickstart generating");
|
||||
|
||||
MetaData md = _webApp.getMetaData();
|
||||
XmlAppendable out = new XmlAppendable(stream,"UTF-8");
|
||||
|
||||
Map<String, String> webappAttr = new HashMap<>();
|
||||
webappAttr.put("xmlns","http://xmlns.jcp.org/xml/ns/javaee");
|
||||
webappAttr.put("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance");
|
||||
webappAttr.put("xsi:schemaLocation","http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd");
|
||||
webappAttr.put("metadata-complete","true");
|
||||
webappAttr.put("version","3.1");
|
||||
MetaData md = _webApp.getMetaData();
|
||||
|
||||
out.openTag("web-app",webappAttr);
|
||||
if (_webApp.getDisplayName() != null)
|
||||
out.tag("display-name",_webApp.getDisplayName());
|
||||
Map<String, String> webappAttr = new HashMap<>();
|
||||
webappAttr.put("xmlns","http://xmlns.jcp.org/xml/ns/javaee");
|
||||
webappAttr.put("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance");
|
||||
webappAttr.put("xsi:schemaLocation","http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd");
|
||||
webappAttr.put("metadata-complete","true");
|
||||
webappAttr.put("version","3.1");
|
||||
|
||||
// Set some special context parameters
|
||||
out.openTag("web-app",webappAttr);
|
||||
if (_webApp.getDisplayName() != null)
|
||||
out.tag("display-name",_webApp.getDisplayName());
|
||||
|
||||
// The location of the war file on disk
|
||||
String resourceBase = _webApp.getBaseResource().getFile().getCanonicalFile().getAbsoluteFile().toURI().toString();
|
||||
// Set some special context parameters
|
||||
|
||||
// The library order
|
||||
addContextParamFromAttribute(out,ServletContext.ORDERED_LIBS);
|
||||
//the servlet container initializers
|
||||
addContextParamFromAttribute(out,AnnotationConfiguration.CONTAINER_INITIALIZERS);
|
||||
//the tlds discovered
|
||||
addContextParamFromAttribute(out,MetaInfConfiguration.METAINF_TLDS,resourceBase);
|
||||
//the META-INF/resources discovered
|
||||
addContextParamFromAttribute(out,MetaInfConfiguration.METAINF_RESOURCES,resourceBase);
|
||||
// The location of the war file on disk
|
||||
String resourceBase = _webApp.getBaseResource().getFile().getCanonicalFile().getAbsoluteFile().toURI().toString();
|
||||
|
||||
// The library order
|
||||
addContextParamFromAttribute(out,ServletContext.ORDERED_LIBS);
|
||||
//the servlet container initializers
|
||||
addContextParamFromAttribute(out,AnnotationConfiguration.CONTAINER_INITIALIZERS);
|
||||
//the tlds discovered
|
||||
addContextParamFromAttribute(out,MetaInfConfiguration.METAINF_TLDS,resourceBase);
|
||||
//the META-INF/resources discovered
|
||||
addContextParamFromAttribute(out,MetaInfConfiguration.METAINF_RESOURCES,resourceBase);
|
||||
|
||||
|
||||
// init params
|
||||
for (String p : _webApp.getInitParams().keySet())
|
||||
out.openTag("context-param",origin(md,"context-param." + p))
|
||||
.tag("param-name",p)
|
||||
.tag("param-value",_webApp.getInitParameter(p))
|
||||
// init params
|
||||
for (String p : _webApp.getInitParams().keySet())
|
||||
out.openTag("context-param",origin(md,"context-param." + p))
|
||||
.tag("param-name",p)
|
||||
.tag("param-value",_webApp.getInitParameter(p))
|
||||
.closeTag();
|
||||
|
||||
if (_webApp.getEventListeners() != null)
|
||||
for (EventListener e : _webApp.getEventListeners())
|
||||
out.openTag("listener",origin(md,e.getClass().getCanonicalName() + ".listener"))
|
||||
.tag("listener-class",e.getClass().getCanonicalName())
|
||||
.closeTag();
|
||||
|
||||
if (_webApp.getEventListeners() != null)
|
||||
for (EventListener e : _webApp.getEventListeners())
|
||||
out.openTag("listener",origin(md,e.getClass().getCanonicalName() + ".listener"))
|
||||
.tag("listener-class",e.getClass().getCanonicalName())
|
||||
.closeTag();
|
||||
ServletHandler servlets = _webApp.getServletHandler();
|
||||
|
||||
ServletHandler servlets = _webApp.getServletHandler();
|
||||
if (servlets.getFilters() != null)
|
||||
{
|
||||
for (FilterHolder holder : servlets.getFilters())
|
||||
outholder(out,md,"filter",holder);
|
||||
}
|
||||
|
||||
if (servlets.getFilters() != null)
|
||||
if (servlets.getFilterMappings() != null)
|
||||
{
|
||||
for (FilterMapping mapping : servlets.getFilterMappings())
|
||||
{
|
||||
for (FilterHolder holder : servlets.getFilters())
|
||||
outholder(out,md,"filter",holder);
|
||||
}
|
||||
out.openTag("filter-mapping");
|
||||
out.tag("filter-name",mapping.getFilterName());
|
||||
if (mapping.getPathSpecs() != null)
|
||||
for (String s : mapping.getPathSpecs())
|
||||
out.tag("url-pattern",s);
|
||||
if (mapping.getServletNames() != null)
|
||||
for (String n : mapping.getServletNames())
|
||||
out.tag("servlet-name",n);
|
||||
|
||||
if (servlets.getFilterMappings() != null)
|
||||
{
|
||||
for (FilterMapping mapping : servlets.getFilterMappings())
|
||||
if (!mapping.isDefaultDispatches())
|
||||
{
|
||||
out.openTag("filter-mapping");
|
||||
out.tag("filter-name",mapping.getFilterName());
|
||||
if (mapping.getPathSpecs() != null)
|
||||
for (String s : mapping.getPathSpecs())
|
||||
out.tag("url-pattern",s);
|
||||
if (mapping.getServletNames() != null)
|
||||
for (String n : mapping.getServletNames())
|
||||
out.tag("servlet-name",n);
|
||||
|
||||
if (!mapping.isDefaultDispatches())
|
||||
{
|
||||
if (mapping.appliesTo(DispatcherType.REQUEST))
|
||||
out.tag("dispatcher","REQUEST");
|
||||
if (mapping.appliesTo(DispatcherType.ASYNC))
|
||||
out.tag("dispatcher","ASYNC");
|
||||
if (mapping.appliesTo(DispatcherType.ERROR))
|
||||
out.tag("dispatcher","ERROR");
|
||||
if (mapping.appliesTo(DispatcherType.FORWARD))
|
||||
out.tag("dispatcher","FORWARD");
|
||||
if (mapping.appliesTo(DispatcherType.INCLUDE))
|
||||
out.tag("dispatcher","INCLUDE");
|
||||
}
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
if (servlets.getServlets() != null)
|
||||
{
|
||||
for (ServletHolder holder : servlets.getServlets())
|
||||
outholder(out,md,"servlet",holder);
|
||||
}
|
||||
|
||||
if (servlets.getServletMappings() != null)
|
||||
{
|
||||
for (ServletMapping mapping : servlets.getServletMappings())
|
||||
{
|
||||
out.openTag("servlet-mapping",origin(md,mapping.getServletName() + ".servlet.mappings"));
|
||||
out.tag("servlet-name",mapping.getServletName());
|
||||
if (mapping.getPathSpecs() != null)
|
||||
for (String s : mapping.getPathSpecs())
|
||||
out.tag("url-pattern",s);
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
// Security elements
|
||||
SecurityHandler security =_webApp. getSecurityHandler();
|
||||
|
||||
if (security!=null && (security.getRealmName()!=null || security.getAuthMethod()!=null))
|
||||
{
|
||||
out.openTag("login-config");
|
||||
if (security.getAuthMethod()!=null)
|
||||
out.tag("auth-method",origin(md,"auth-method"),security.getAuthMethod());
|
||||
if (security.getRealmName()!=null)
|
||||
out.tag("realm-name",origin(md,"realm-name"),security.getRealmName());
|
||||
|
||||
|
||||
if (Constraint.__FORM_AUTH.equalsIgnoreCase(security.getAuthMethod()))
|
||||
{
|
||||
out.openTag("form-login-config");
|
||||
out.tag("form-login-page",origin(md,"form-login-page"),security.getInitParameter(FormAuthenticator.__FORM_LOGIN_PAGE));
|
||||
out.tag("form-error-page",origin(md,"form-error-page"),security.getInitParameter(FormAuthenticator.__FORM_ERROR_PAGE));
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
if (security instanceof ConstraintAware)
|
||||
{
|
||||
ConstraintAware ca = (ConstraintAware)security;
|
||||
for (String r:ca.getRoles())
|
||||
out.openTag("security-role")
|
||||
.tag("role-name",r)
|
||||
.closeTag();
|
||||
|
||||
for (ConstraintMapping m : ca.getConstraintMappings())
|
||||
{
|
||||
out.openTag("security-constraint");
|
||||
|
||||
if (m.getConstraint().getAuthenticate())
|
||||
{
|
||||
out.openTag("auth-constraint");
|
||||
if (m.getConstraint().getRoles()!=null)
|
||||
for (String r : m.getConstraint().getRoles())
|
||||
out.tag("role-name",r);
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
switch (m.getConstraint().getDataConstraint())
|
||||
{
|
||||
case Constraint.DC_NONE:
|
||||
out.openTag("user-data-constraint").tag("transport-guarantee","NONE").closeTag();
|
||||
break;
|
||||
|
||||
case Constraint.DC_INTEGRAL:
|
||||
out.openTag("user-data-constraint").tag("transport-guarantee","INTEGRAL").closeTag();
|
||||
break;
|
||||
|
||||
case Constraint.DC_CONFIDENTIAL:
|
||||
out.openTag("user-data-constraint").tag("transport-guarantee","CONFIDENTIAL").closeTag();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
out.openTag("web-resource-collection");
|
||||
{
|
||||
if (m.getConstraint().getName()!=null)
|
||||
out.tag("web-resource-name",m.getConstraint().getName());
|
||||
if (m.getPathSpec()!=null)
|
||||
out.tag("url-pattern",origin(md,"constraint.url."+m.getPathSpec()),m.getPathSpec());
|
||||
if (m.getMethod()!=null)
|
||||
out.tag("http-method",m.getMethod());
|
||||
|
||||
if (m.getMethodOmissions()!=null)
|
||||
for (String o:m.getMethodOmissions())
|
||||
out.tag("http-method-omission",o);
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
out.closeTag();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (_webApp.getWelcomeFiles() != null)
|
||||
{
|
||||
out.openTag("welcome-file-list");
|
||||
for (String welcomeFile:_webApp.getWelcomeFiles())
|
||||
{
|
||||
out.tag("welcome-file", welcomeFile);
|
||||
if (mapping.appliesTo(DispatcherType.REQUEST))
|
||||
out.tag("dispatcher","REQUEST");
|
||||
if (mapping.appliesTo(DispatcherType.ASYNC))
|
||||
out.tag("dispatcher","ASYNC");
|
||||
if (mapping.appliesTo(DispatcherType.ERROR))
|
||||
out.tag("dispatcher","ERROR");
|
||||
if (mapping.appliesTo(DispatcherType.FORWARD))
|
||||
out.tag("dispatcher","FORWARD");
|
||||
if (mapping.appliesTo(DispatcherType.INCLUDE))
|
||||
out.tag("dispatcher","INCLUDE");
|
||||
}
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,String> localeEncodings = _webApp.getLocaleEncodings();
|
||||
if (localeEncodings != null && !localeEncodings.isEmpty())
|
||||
if (servlets.getServlets() != null)
|
||||
{
|
||||
for (ServletHolder holder : servlets.getServlets())
|
||||
outholder(out,md,"servlet",holder);
|
||||
}
|
||||
|
||||
if (servlets.getServletMappings() != null)
|
||||
{
|
||||
for (ServletMapping mapping : servlets.getServletMappings())
|
||||
{
|
||||
out.openTag("locale-encoding-mapping-list");
|
||||
for (Map.Entry<String, String> entry:localeEncodings.entrySet())
|
||||
{
|
||||
out.openTag("locale-encoding-mapping", origin(md,"locale-encoding."+entry.getKey()));
|
||||
out.tag("locale", entry.getKey());
|
||||
out.tag("encoding", entry.getValue());
|
||||
out.closeTag();
|
||||
}
|
||||
out.openTag("servlet-mapping",origin(md,mapping.getServletName() + ".servlet.mappings"));
|
||||
out.tag("servlet-name",mapping.getServletName());
|
||||
if (mapping.getPathSpecs() != null)
|
||||
for (String s : mapping.getPathSpecs())
|
||||
out.tag("url-pattern",s);
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
//session-config
|
||||
if (_webApp.getSessionHandler().getSessionManager() != null)
|
||||
// Security elements
|
||||
SecurityHandler security =_webApp. getSecurityHandler();
|
||||
|
||||
if (security!=null && (security.getRealmName()!=null || security.getAuthMethod()!=null))
|
||||
{
|
||||
out.openTag("login-config");
|
||||
if (security.getAuthMethod()!=null)
|
||||
out.tag("auth-method",origin(md,"auth-method"),security.getAuthMethod());
|
||||
if (security.getRealmName()!=null)
|
||||
out.tag("realm-name",origin(md,"realm-name"),security.getRealmName());
|
||||
|
||||
|
||||
if (Constraint.__FORM_AUTH.equalsIgnoreCase(security.getAuthMethod()))
|
||||
{
|
||||
out.openTag("session-config");
|
||||
int maxInactiveSec = _webApp.getSessionHandler().getSessionManager().getMaxInactiveInterval();
|
||||
out.tag("session-timeout", (maxInactiveSec==0?"0":Integer.toString(maxInactiveSec/60)));
|
||||
|
||||
Set<SessionTrackingMode> modes =_webApp. getSessionHandler().getSessionManager().getEffectiveSessionTrackingModes();
|
||||
if (modes != null)
|
||||
{
|
||||
for (SessionTrackingMode mode:modes)
|
||||
out.tag("tracking-mode", mode.toString());
|
||||
}
|
||||
|
||||
//cookie-config
|
||||
SessionCookieConfig cookieConfig = _webApp.getSessionHandler().getSessionManager().getSessionCookieConfig();
|
||||
if (cookieConfig != null)
|
||||
{
|
||||
out.openTag("cookie-config");
|
||||
if (cookieConfig.getName() != null)
|
||||
out.tag("name", origin(md,"cookie-config.name"), cookieConfig.getName());
|
||||
|
||||
if (cookieConfig.getDomain() != null)
|
||||
out.tag("domain", origin(md, "cookie-config.domain"), cookieConfig.getDomain());
|
||||
|
||||
if (cookieConfig.getPath() != null)
|
||||
out.tag("path", origin(md, "cookie-config.path"), cookieConfig.getPath());
|
||||
|
||||
if (cookieConfig.getComment() != null)
|
||||
out.tag("comment", origin(md, "cookie-config.comment"), cookieConfig.getComment());
|
||||
|
||||
out.tag("http-only", origin(md, "cookie-config.http-only"), Boolean.toString(cookieConfig.isHttpOnly()));
|
||||
out.tag("secure", origin(md, "cookie-config.secure"), Boolean.toString(cookieConfig.isSecure()));
|
||||
out.tag("max-age", origin(md, "cookie-config.max-age"), Integer.toString(cookieConfig.getMaxAge()));
|
||||
out.closeTag();
|
||||
}
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
//error-pages
|
||||
Map<String,String> errorPages = ((ErrorPageErrorHandler)_webApp.getErrorHandler()).getErrorPages();
|
||||
if (errorPages != null)
|
||||
{
|
||||
for (Map.Entry<String, String> entry:errorPages.entrySet())
|
||||
{
|
||||
out.openTag("error-page", origin(md, "error."+entry.getKey()));
|
||||
//a global or default error page has no code or exception
|
||||
if (!ErrorPageErrorHandler.GLOBAL_ERROR_PAGE.equals(entry.getKey()))
|
||||
{
|
||||
if (entry.getKey().matches("\\d{3}"))
|
||||
out.tag("error-code", entry.getKey());
|
||||
else
|
||||
out.tag("exception-type", entry.getKey());
|
||||
}
|
||||
out.tag("location", entry.getValue());
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
//mime-types
|
||||
MimeTypes mimeTypes = _webApp.getMimeTypes();
|
||||
if (mimeTypes != null)
|
||||
{
|
||||
for (Map.Entry<String, String> entry:mimeTypes.getMimeMap().entrySet())
|
||||
{
|
||||
out.openTag("mime-mapping");
|
||||
out.tag("extension", origin(md, "extension."+entry.getKey()), entry.getKey());
|
||||
out.tag("mime-type", entry.getValue());
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
//jsp-config
|
||||
JspConfig jspConfig = (JspConfig)_webApp.getServletContext().getJspConfigDescriptor();
|
||||
if (jspConfig != null)
|
||||
{
|
||||
out.openTag("jsp-config");
|
||||
Collection<TaglibDescriptor> tlds = jspConfig.getTaglibs();
|
||||
if (tlds != null && !tlds.isEmpty())
|
||||
{
|
||||
for (TaglibDescriptor tld:tlds)
|
||||
{
|
||||
out.openTag("taglib");
|
||||
out.tag("taglib-uri", tld.getTaglibURI());
|
||||
out.tag("taglib-location", tld.getTaglibLocation());
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
Collection<JspPropertyGroupDescriptor> jspPropertyGroups = jspConfig.getJspPropertyGroups();
|
||||
if (jspPropertyGroups != null && !jspPropertyGroups.isEmpty())
|
||||
{
|
||||
for (JspPropertyGroupDescriptor jspPropertyGroup:jspPropertyGroups)
|
||||
{
|
||||
out.openTag("jsp-property-group");
|
||||
Collection<String> strings = jspPropertyGroup.getUrlPatterns();
|
||||
if (strings != null && !strings.isEmpty())
|
||||
{
|
||||
for (String urlPattern:strings)
|
||||
out.tag("url-pattern", urlPattern);
|
||||
}
|
||||
|
||||
if (jspPropertyGroup.getElIgnored() != null)
|
||||
out.tag("el-ignored", jspPropertyGroup.getElIgnored());
|
||||
|
||||
if (jspPropertyGroup.getPageEncoding() != null)
|
||||
out.tag("page-encoding", jspPropertyGroup.getPageEncoding());
|
||||
|
||||
if (jspPropertyGroup.getScriptingInvalid() != null)
|
||||
out.tag("scripting-invalid", jspPropertyGroup.getScriptingInvalid());
|
||||
|
||||
if (jspPropertyGroup.getIsXml() != null)
|
||||
out.tag("is-xml", jspPropertyGroup.getIsXml());
|
||||
|
||||
if (jspPropertyGroup.getDeferredSyntaxAllowedAsLiteral() != null)
|
||||
out.tag("deferred-syntax-allowed-as-literal", jspPropertyGroup.getDeferredSyntaxAllowedAsLiteral());
|
||||
|
||||
if (jspPropertyGroup.getTrimDirectiveWhitespaces() != null)
|
||||
out.tag("trim-directive-whitespaces", jspPropertyGroup.getTrimDirectiveWhitespaces());
|
||||
|
||||
if (jspPropertyGroup.getDefaultContentType() != null)
|
||||
out.tag("default-content-type", jspPropertyGroup.getDefaultContentType());
|
||||
|
||||
if (jspPropertyGroup.getBuffer() != null)
|
||||
out.tag("buffer", jspPropertyGroup.getBuffer());
|
||||
|
||||
if (jspPropertyGroup.getErrorOnUndeclaredNamespace() != null)
|
||||
out.tag("error-on-undeclared-namespace", jspPropertyGroup.getErrorOnUndeclaredNamespace());
|
||||
|
||||
strings = jspPropertyGroup.getIncludePreludes();
|
||||
if (strings != null && !strings.isEmpty())
|
||||
{
|
||||
for (String prelude:strings)
|
||||
out.tag("include-prelude", prelude);
|
||||
}
|
||||
|
||||
strings = jspPropertyGroup.getIncludeCodas();
|
||||
if (strings != null && !strings.isEmpty())
|
||||
{
|
||||
for (String coda:strings)
|
||||
out.tag("include-coda", coda);
|
||||
}
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
out.openTag("form-login-config");
|
||||
out.tag("form-login-page",origin(md,"form-login-page"),security.getInitParameter(FormAuthenticator.__FORM_LOGIN_PAGE));
|
||||
out.tag("form-error-page",origin(md,"form-error-page"),security.getInitParameter(FormAuthenticator.__FORM_ERROR_PAGE));
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
//lifecycle: post-construct, pre-destroy
|
||||
LifeCycleCallbackCollection lifecycles = ((LifeCycleCallbackCollection)_webApp.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION));
|
||||
if (lifecycles != null)
|
||||
{
|
||||
Collection<LifeCycleCallback> tmp = lifecycles.getPostConstructCallbacks();
|
||||
|
||||
for (LifeCycleCallback c:tmp)
|
||||
{
|
||||
out.openTag("post-construct");
|
||||
out.tag("lifecycle-callback-class", c.getTargetClassName());
|
||||
out.tag("lifecycle-callback-method", c.getMethodName());
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
tmp = lifecycles.getPreDestroyCallbacks();
|
||||
for (LifeCycleCallback c:tmp)
|
||||
{
|
||||
out.openTag("pre-destroy");
|
||||
out.tag("lifecycle-callback-class", c.getTargetClassName());
|
||||
out.tag("lifecycle-callback-method", c.getMethodName());
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
out.literal(_extraXML);
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
if (security instanceof ConstraintAware)
|
||||
{
|
||||
if (e.getSuppressed() != null)
|
||||
{
|
||||
for (Throwable t:e.getSuppressed())
|
||||
t.printStackTrace();
|
||||
}
|
||||
ConstraintAware ca = (ConstraintAware)security;
|
||||
for (String r:ca.getRoles())
|
||||
out.openTag("security-role")
|
||||
.tag("role-name",r)
|
||||
.closeTag();
|
||||
|
||||
for (ConstraintMapping m : ca.getConstraintMappings())
|
||||
{
|
||||
out.openTag("security-constraint");
|
||||
|
||||
if (m.getConstraint().getAuthenticate())
|
||||
{
|
||||
out.openTag("auth-constraint");
|
||||
if (m.getConstraint().getRoles()!=null)
|
||||
for (String r : m.getConstraint().getRoles())
|
||||
out.tag("role-name",r);
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
switch (m.getConstraint().getDataConstraint())
|
||||
{
|
||||
case Constraint.DC_NONE:
|
||||
out.openTag("user-data-constraint").tag("transport-guarantee","NONE").closeTag();
|
||||
break;
|
||||
|
||||
case Constraint.DC_INTEGRAL:
|
||||
out.openTag("user-data-constraint").tag("transport-guarantee","INTEGRAL").closeTag();
|
||||
break;
|
||||
|
||||
case Constraint.DC_CONFIDENTIAL:
|
||||
out.openTag("user-data-constraint").tag("transport-guarantee","CONFIDENTIAL").closeTag();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
out.openTag("web-resource-collection");
|
||||
{
|
||||
if (m.getConstraint().getName()!=null)
|
||||
out.tag("web-resource-name",m.getConstraint().getName());
|
||||
if (m.getPathSpec()!=null)
|
||||
out.tag("url-pattern",origin(md,"constraint.url."+m.getPathSpec()),m.getPathSpec());
|
||||
if (m.getMethod()!=null)
|
||||
out.tag("http-method",m.getMethod());
|
||||
|
||||
if (m.getMethodOmissions()!=null)
|
||||
for (String o:m.getMethodOmissions())
|
||||
out.tag("http-method-omission",o);
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
out.closeTag();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return webXml;
|
||||
|
||||
if (_webApp.getWelcomeFiles() != null)
|
||||
{
|
||||
out.openTag("welcome-file-list");
|
||||
for (String welcomeFile:_webApp.getWelcomeFiles())
|
||||
{
|
||||
out.tag("welcome-file", welcomeFile);
|
||||
}
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
Map<String,String> localeEncodings = _webApp.getLocaleEncodings();
|
||||
if (localeEncodings != null && !localeEncodings.isEmpty())
|
||||
{
|
||||
out.openTag("locale-encoding-mapping-list");
|
||||
for (Map.Entry<String, String> entry:localeEncodings.entrySet())
|
||||
{
|
||||
out.openTag("locale-encoding-mapping", origin(md,"locale-encoding."+entry.getKey()));
|
||||
out.tag("locale", entry.getKey());
|
||||
out.tag("encoding", entry.getValue());
|
||||
out.closeTag();
|
||||
}
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
//session-config
|
||||
if (_webApp.getSessionHandler().getSessionManager() != null)
|
||||
{
|
||||
out.openTag("session-config");
|
||||
int maxInactiveSec = _webApp.getSessionHandler().getSessionManager().getMaxInactiveInterval();
|
||||
out.tag("session-timeout", (maxInactiveSec==0?"0":Integer.toString(maxInactiveSec/60)));
|
||||
|
||||
Set<SessionTrackingMode> modes =_webApp. getSessionHandler().getSessionManager().getEffectiveSessionTrackingModes();
|
||||
if (modes != null)
|
||||
{
|
||||
for (SessionTrackingMode mode:modes)
|
||||
out.tag("tracking-mode", mode.toString());
|
||||
}
|
||||
|
||||
//cookie-config
|
||||
SessionCookieConfig cookieConfig = _webApp.getSessionHandler().getSessionManager().getSessionCookieConfig();
|
||||
if (cookieConfig != null)
|
||||
{
|
||||
out.openTag("cookie-config");
|
||||
if (cookieConfig.getName() != null)
|
||||
out.tag("name", origin(md,"cookie-config.name"), cookieConfig.getName());
|
||||
|
||||
if (cookieConfig.getDomain() != null)
|
||||
out.tag("domain", origin(md, "cookie-config.domain"), cookieConfig.getDomain());
|
||||
|
||||
if (cookieConfig.getPath() != null)
|
||||
out.tag("path", origin(md, "cookie-config.path"), cookieConfig.getPath());
|
||||
|
||||
if (cookieConfig.getComment() != null)
|
||||
out.tag("comment", origin(md, "cookie-config.comment"), cookieConfig.getComment());
|
||||
|
||||
out.tag("http-only", origin(md, "cookie-config.http-only"), Boolean.toString(cookieConfig.isHttpOnly()));
|
||||
out.tag("secure", origin(md, "cookie-config.secure"), Boolean.toString(cookieConfig.isSecure()));
|
||||
out.tag("max-age", origin(md, "cookie-config.max-age"), Integer.toString(cookieConfig.getMaxAge()));
|
||||
out.closeTag();
|
||||
}
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
//error-pages
|
||||
Map<String,String> errorPages = ((ErrorPageErrorHandler)_webApp.getErrorHandler()).getErrorPages();
|
||||
if (errorPages != null)
|
||||
{
|
||||
for (Map.Entry<String, String> entry:errorPages.entrySet())
|
||||
{
|
||||
out.openTag("error-page", origin(md, "error."+entry.getKey()));
|
||||
//a global or default error page has no code or exception
|
||||
if (!ErrorPageErrorHandler.GLOBAL_ERROR_PAGE.equals(entry.getKey()))
|
||||
{
|
||||
if (entry.getKey().matches("\\d{3}"))
|
||||
out.tag("error-code", entry.getKey());
|
||||
else
|
||||
out.tag("exception-type", entry.getKey());
|
||||
}
|
||||
out.tag("location", entry.getValue());
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
//mime-types
|
||||
MimeTypes mimeTypes = _webApp.getMimeTypes();
|
||||
if (mimeTypes != null)
|
||||
{
|
||||
for (Map.Entry<String, String> entry:mimeTypes.getMimeMap().entrySet())
|
||||
{
|
||||
out.openTag("mime-mapping");
|
||||
out.tag("extension", origin(md, "extension."+entry.getKey()), entry.getKey());
|
||||
out.tag("mime-type", entry.getValue());
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
//jsp-config
|
||||
JspConfig jspConfig = (JspConfig)_webApp.getServletContext().getJspConfigDescriptor();
|
||||
if (jspConfig != null)
|
||||
{
|
||||
out.openTag("jsp-config");
|
||||
Collection<TaglibDescriptor> tlds = jspConfig.getTaglibs();
|
||||
if (tlds != null && !tlds.isEmpty())
|
||||
{
|
||||
for (TaglibDescriptor tld:tlds)
|
||||
{
|
||||
out.openTag("taglib");
|
||||
out.tag("taglib-uri", tld.getTaglibURI());
|
||||
out.tag("taglib-location", tld.getTaglibLocation());
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
Collection<JspPropertyGroupDescriptor> jspPropertyGroups = jspConfig.getJspPropertyGroups();
|
||||
if (jspPropertyGroups != null && !jspPropertyGroups.isEmpty())
|
||||
{
|
||||
for (JspPropertyGroupDescriptor jspPropertyGroup:jspPropertyGroups)
|
||||
{
|
||||
out.openTag("jsp-property-group");
|
||||
Collection<String> strings = jspPropertyGroup.getUrlPatterns();
|
||||
if (strings != null && !strings.isEmpty())
|
||||
{
|
||||
for (String urlPattern:strings)
|
||||
out.tag("url-pattern", urlPattern);
|
||||
}
|
||||
|
||||
if (jspPropertyGroup.getElIgnored() != null)
|
||||
out.tag("el-ignored", jspPropertyGroup.getElIgnored());
|
||||
|
||||
if (jspPropertyGroup.getPageEncoding() != null)
|
||||
out.tag("page-encoding", jspPropertyGroup.getPageEncoding());
|
||||
|
||||
if (jspPropertyGroup.getScriptingInvalid() != null)
|
||||
out.tag("scripting-invalid", jspPropertyGroup.getScriptingInvalid());
|
||||
|
||||
if (jspPropertyGroup.getIsXml() != null)
|
||||
out.tag("is-xml", jspPropertyGroup.getIsXml());
|
||||
|
||||
if (jspPropertyGroup.getDeferredSyntaxAllowedAsLiteral() != null)
|
||||
out.tag("deferred-syntax-allowed-as-literal", jspPropertyGroup.getDeferredSyntaxAllowedAsLiteral());
|
||||
|
||||
if (jspPropertyGroup.getTrimDirectiveWhitespaces() != null)
|
||||
out.tag("trim-directive-whitespaces", jspPropertyGroup.getTrimDirectiveWhitespaces());
|
||||
|
||||
if (jspPropertyGroup.getDefaultContentType() != null)
|
||||
out.tag("default-content-type", jspPropertyGroup.getDefaultContentType());
|
||||
|
||||
if (jspPropertyGroup.getBuffer() != null)
|
||||
out.tag("buffer", jspPropertyGroup.getBuffer());
|
||||
|
||||
if (jspPropertyGroup.getErrorOnUndeclaredNamespace() != null)
|
||||
out.tag("error-on-undeclared-namespace", jspPropertyGroup.getErrorOnUndeclaredNamespace());
|
||||
|
||||
strings = jspPropertyGroup.getIncludePreludes();
|
||||
if (strings != null && !strings.isEmpty())
|
||||
{
|
||||
for (String prelude:strings)
|
||||
out.tag("include-prelude", prelude);
|
||||
}
|
||||
|
||||
strings = jspPropertyGroup.getIncludeCodas();
|
||||
if (strings != null && !strings.isEmpty())
|
||||
{
|
||||
for (String coda:strings)
|
||||
out.tag("include-coda", coda);
|
||||
}
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
//lifecycle: post-construct, pre-destroy
|
||||
LifeCycleCallbackCollection lifecycles = ((LifeCycleCallbackCollection)_webApp.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION));
|
||||
if (lifecycles != null)
|
||||
{
|
||||
Collection<LifeCycleCallback> tmp = lifecycles.getPostConstructCallbacks();
|
||||
|
||||
for (LifeCycleCallback c:tmp)
|
||||
{
|
||||
out.openTag("post-construct");
|
||||
out.tag("lifecycle-callback-class", c.getTargetClassName());
|
||||
out.tag("lifecycle-callback-method", c.getMethodName());
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
tmp = lifecycles.getPreDestroyCallbacks();
|
||||
for (LifeCycleCallback c:tmp)
|
||||
{
|
||||
out.openTag("pre-destroy");
|
||||
out.tag("lifecycle-callback-class", c.getTargetClassName());
|
||||
out.tag("lifecycle-callback-method", c.getMethodName());
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
out.literal(_extraXML);
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -584,8 +567,18 @@ public class QuickStartDescriptorGenerator
|
|||
out.tag(tag + "-name",n);
|
||||
|
||||
String ot = n + "." + tag + ".";
|
||||
|
||||
if (holder instanceof FilterHolder)
|
||||
out.tag(tag + "-class",origin(md,ot + tag + "-class"),holder.getClassName());
|
||||
else if (holder instanceof ServletHolder)
|
||||
{
|
||||
ServletHolder s = (ServletHolder)holder;
|
||||
if (s.getForcedPath() != null && s.getClassName() == null)
|
||||
out.tag("jsp-file",s.getForcedPath());
|
||||
else
|
||||
out.tag(tag + "-class",origin(md,ot + tag + "-class"),s.getClassName());
|
||||
|
||||
out.tag(tag + "-class",origin(md,ot + tag + "-class"),holder.getClassName());
|
||||
}
|
||||
|
||||
for (String p : holder.getInitParameters().keySet())
|
||||
{
|
||||
|
@ -600,10 +593,7 @@ public class QuickStartDescriptorGenerator
|
|||
if (holder instanceof ServletHolder)
|
||||
{
|
||||
ServletHolder s = (ServletHolder)holder;
|
||||
if (s.getForcedPath() != null)
|
||||
out.tag("jsp-file",s.getForcedPath());
|
||||
|
||||
if (s.getInitOrder() != 0)
|
||||
if (s.getInitOrder() >= 0)
|
||||
out.tag("load-on-startup",Integer.toString(s.getInitOrder()));
|
||||
|
||||
if (s.getRunAsRole() != null)
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.quickstart;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.JarResource;
|
||||
|
@ -32,6 +34,8 @@ public class QuickStartWebApp extends WebAppContext
|
|||
{
|
||||
private static final Logger LOG = Log.getLogger(QuickStartWebApp.class);
|
||||
|
||||
|
||||
|
||||
public static final String[] __configurationClasses = new String[]
|
||||
{
|
||||
org.eclipse.jetty.quickstart.QuickStartConfiguration.class.getCanonicalName(),
|
||||
|
@ -164,8 +168,14 @@ public class QuickStartWebApp extends WebAppContext
|
|||
|
||||
public void generateQuickstartWebXml(String extraXML) throws Exception
|
||||
{
|
||||
QuickStartDescriptorGenerator generator = new QuickStartDescriptorGenerator(this, this.getWebInf().getFile(), extraXML);
|
||||
generator.generateQuickStartWebXml();
|
||||
Resource descriptor = getWebInf().addPath(QuickStartDescriptorGenerator.DEFAULT_QUICKSTART_DESCRIPTOR_NAME);
|
||||
if (!descriptor.exists())
|
||||
descriptor.getFile().createNewFile();
|
||||
QuickStartDescriptorGenerator generator = new QuickStartDescriptorGenerator(this, extraXML);
|
||||
try (FileOutputStream fos = new FileOutputStream(descriptor.getFile()))
|
||||
{
|
||||
generator.generateQuickStartWebXml(fos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,197 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.Socket;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.io.ChannelEndPoint;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ServerConnectorTest
|
||||
{
|
||||
public static class ReuseInfoHandler extends AbstractHandler
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||
{
|
||||
response.setContentType("text/plain");
|
||||
|
||||
EndPoint endPoint = baseRequest.getHttpChannel().getEndPoint();
|
||||
assertThat("Endpoint",endPoint,instanceOf(ChannelEndPoint.class));
|
||||
ChannelEndPoint channelEndPoint = (ChannelEndPoint)endPoint;
|
||||
Socket socket = channelEndPoint.getSocket();
|
||||
ServerConnector connector = (ServerConnector)baseRequest.getHttpChannel().getConnector();
|
||||
|
||||
PrintWriter out = response.getWriter();
|
||||
out.printf("connector.getReuseAddress() = %b%n",connector.getReuseAddress());
|
||||
|
||||
try
|
||||
{
|
||||
Field fld = connector.getClass().getDeclaredField("_reuseAddress");
|
||||
assertThat("Field[_reuseAddress]",fld,notNullValue());
|
||||
fld.setAccessible(true);
|
||||
Object val = fld.get(connector);
|
||||
out.printf("connector._reuseAddress() = %b%n",val);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
t.printStackTrace(out);
|
||||
}
|
||||
|
||||
out.printf("socket.getReuseAddress() = %b%n",socket.getReuseAddress());
|
||||
|
||||
baseRequest.setHandled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private URI toServerURI(ServerConnector connector) throws URISyntaxException
|
||||
{
|
||||
String host = connector.getHost();
|
||||
if (host == null)
|
||||
{
|
||||
host = "localhost";
|
||||
}
|
||||
int port = connector.getLocalPort();
|
||||
return new URI(String.format("http://%s:%d/",host,port));
|
||||
}
|
||||
|
||||
private String getResponse(URI uri) throws MalformedURLException, IOException
|
||||
{
|
||||
HttpURLConnection http = (HttpURLConnection)uri.toURL().openConnection();
|
||||
assertThat("Valid Response Code",http.getResponseCode(),anyOf(is(200),is(404)));
|
||||
|
||||
try (InputStream in = http.getInputStream())
|
||||
{
|
||||
return IO.toString(in,StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReuseAddress_Default() throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
ServerConnector connector = new ServerConnector(server);
|
||||
connector.setPort(0);
|
||||
server.addConnector(connector);
|
||||
|
||||
HandlerList handlers = new HandlerList();
|
||||
handlers.addHandler(new ReuseInfoHandler());
|
||||
handlers.addHandler(new DefaultHandler());
|
||||
|
||||
server.setHandler(handlers);
|
||||
|
||||
try
|
||||
{
|
||||
server.start();
|
||||
|
||||
URI uri = toServerURI(connector);
|
||||
String response = getResponse(uri);
|
||||
assertThat("Response",response,containsString("connector.getReuseAddress() = true"));
|
||||
assertThat("Response",response,containsString("connector._reuseAddress() = true"));
|
||||
assertThat("Response",response,containsString("socket.getReuseAddress() = true"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
server.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReuseAddress_True() throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
ServerConnector connector = new ServerConnector(server);
|
||||
connector.setPort(0);
|
||||
connector.setReuseAddress(true);
|
||||
server.addConnector(connector);
|
||||
|
||||
HandlerList handlers = new HandlerList();
|
||||
handlers.addHandler(new ReuseInfoHandler());
|
||||
handlers.addHandler(new DefaultHandler());
|
||||
|
||||
server.setHandler(handlers);
|
||||
|
||||
try
|
||||
{
|
||||
server.start();
|
||||
|
||||
URI uri = toServerURI(connector);
|
||||
String response = getResponse(uri);
|
||||
assertThat("Response",response,containsString("connector.getReuseAddress() = true"));
|
||||
assertThat("Response",response,containsString("connector._reuseAddress() = true"));
|
||||
assertThat("Response",response,containsString("socket.getReuseAddress() = true"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
server.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReuseAddress_False() throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
ServerConnector connector = new ServerConnector(server);
|
||||
connector.setPort(0);
|
||||
connector.setReuseAddress(false);
|
||||
server.addConnector(connector);
|
||||
|
||||
HandlerList handlers = new HandlerList();
|
||||
handlers.addHandler(new ReuseInfoHandler());
|
||||
handlers.addHandler(new DefaultHandler());
|
||||
|
||||
server.setHandler(handlers);
|
||||
|
||||
try
|
||||
{
|
||||
server.start();
|
||||
|
||||
URI uri = toServerURI(connector);
|
||||
String response = getResponse(uri);
|
||||
assertThat("Response",response,containsString("connector.getReuseAddress() = false"));
|
||||
assertThat("Response",response,containsString("connector._reuseAddress() = false"));
|
||||
assertThat("Response",response,containsString("socket.getReuseAddress() = false"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
server.stop();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -849,18 +849,6 @@ public class ServletHandler extends ScopedHandler
|
|||
{
|
||||
try
|
||||
{
|
||||
/* if (servlet.getClassName() == null && servlet.getForcedPath() != null)
|
||||
{
|
||||
ServletHolder forced_holder = _servletPathMap.match(servlet.getForcedPath());
|
||||
if (forced_holder == null || forced_holder.getClassName() == null)
|
||||
{
|
||||
mx.add(new IllegalStateException("No forced path servlet for " + servlet.getForcedPath()));
|
||||
continue;
|
||||
}
|
||||
System.err.println("ServletHandler setting forced path classname to "+forced_holder.getClassName()+ " for "+servlet.getForcedPath());
|
||||
servlet.setClassName(forced_holder.getClassName());
|
||||
}*/
|
||||
|
||||
servlet.start();
|
||||
servlet.initialize();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.eclipse.jetty.servlet;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
|
@ -596,7 +597,7 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
|
|||
initMultiPart();
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Filter.init {}",_servlet);
|
||||
LOG.debug("Servlet.init {}",_servlet);
|
||||
_servlet.init(_config);
|
||||
}
|
||||
catch (UnavailableException e)
|
||||
|
@ -652,6 +653,18 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
|
|||
if (classpath != null)
|
||||
setInitParameter("classpath", classpath);
|
||||
}
|
||||
|
||||
/* ensure scratch dir */
|
||||
File scratch = null;
|
||||
if (getInitParameter("scratchdir") == null)
|
||||
{
|
||||
File tmp = (File)getServletHandler().getServletContext().getAttribute(ServletContext.TEMPDIR);
|
||||
scratch = new File(tmp, "jsp");
|
||||
setInitParameter("scratchdir", scratch.getAbsolutePath());
|
||||
}
|
||||
|
||||
scratch = new File (getInitParameter("scratchdir"));
|
||||
if (!scratch.exists()) scratch.mkdir();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -283,23 +283,15 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor
|
|||
}
|
||||
|
||||
String servlet_class = node.getString("servlet-class", false, true);
|
||||
|
||||
if ("".equals(servlet_class))
|
||||
servlet_class = null;
|
||||
|
||||
//Handle the default jsp servlet instance
|
||||
if (id != null && id.equals("jsp"))
|
||||
if (id != null && id.equals("jsp") && servlet_class != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
Loader.loadClass(this.getClass(), servlet_class);
|
||||
|
||||
//Ensure there is a scratch dir
|
||||
if (holder.getInitParameter("scratchdir") == null)
|
||||
{
|
||||
File tmp = context.getTempDirectory();
|
||||
File scratch = new File(tmp, "jsp");
|
||||
if (!scratch.exists()) scratch.mkdir();
|
||||
holder.setInitParameter("scratchdir", scratch.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.websocket.jsr356;
|
|||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.websocket.Decoder;
|
||||
import javax.websocket.EndpointConfig;
|
||||
|
||||
|
@ -99,7 +98,10 @@ public class DecoderFactory implements Configurable
|
|||
|
||||
public DecoderMetadata getMetadataFor(Class<?> type)
|
||||
{
|
||||
LOG.debug("getMetadataFor({})",type);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("getMetadataFor({})",type);
|
||||
}
|
||||
DecoderMetadata metadata = metadatas.getMetadataByType(type);
|
||||
|
||||
if (metadata != null)
|
||||
|
@ -147,7 +149,10 @@ public class DecoderFactory implements Configurable
|
|||
@Override
|
||||
public void init(EndpointConfig config)
|
||||
{
|
||||
LOG.debug("init({})",config);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("init({})",config);
|
||||
}
|
||||
// Instantiate all declared decoders
|
||||
for (DecoderMetadata metadata : metadatas)
|
||||
{
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.websocket.jsr356;
|
|||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.websocket.Encoder;
|
||||
import javax.websocket.EndpointConfig;
|
||||
|
||||
|
@ -92,7 +91,10 @@ public class EncoderFactory implements Configurable
|
|||
|
||||
public EncoderMetadata getMetadataFor(Class<?> type)
|
||||
{
|
||||
LOG.debug("getMetadataFor({})",type);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("getMetadataFor({})",type);
|
||||
}
|
||||
EncoderMetadata metadata = metadatas.getMetadataByType(type);
|
||||
|
||||
if (metadata != null)
|
||||
|
@ -140,7 +142,10 @@ public class EncoderFactory implements Configurable
|
|||
@Override
|
||||
public void init(EndpointConfig config)
|
||||
{
|
||||
LOG.debug("init({})",config);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("init({})",config);
|
||||
}
|
||||
|
||||
// Instantiate all declared encoders
|
||||
for (EncoderMetadata metadata : metadatas)
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.websocket.MessageHandler;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
@ -46,7 +45,10 @@ public class MessageHandlerFactory
|
|||
|
||||
public List<MessageHandlerMetadata> getMetadata(Class<? extends MessageHandler> handler) throws IllegalStateException
|
||||
{
|
||||
LOG.debug("getMetadata({})",handler);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("getMetadata({})",handler);
|
||||
}
|
||||
List<MessageHandlerMetadata> ret = registered.get(handler);
|
||||
if (ret != null)
|
||||
{
|
||||
|
@ -64,19 +66,31 @@ public class MessageHandlerFactory
|
|||
|
||||
if (MessageHandler.Partial.class.isAssignableFrom(handler))
|
||||
{
|
||||
LOG.debug("supports Partial: {}",handler);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("supports Partial: {}",handler);
|
||||
}
|
||||
partial = true;
|
||||
Class<?> onMessageClass = ReflectUtils.findGenericClassFor(handler,MessageHandler.Partial.class);
|
||||
LOG.debug("Partial message class: {}",onMessageClass);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("Partial message class: {}",onMessageClass);
|
||||
}
|
||||
metadatas.add(new MessageHandlerMetadata(handler,onMessageClass,partial));
|
||||
}
|
||||
|
||||
if (MessageHandler.Whole.class.isAssignableFrom(handler))
|
||||
{
|
||||
LOG.debug("supports Whole: {}",handler.getName());
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("supports Whole: {}",handler.getName());
|
||||
}
|
||||
partial = false;
|
||||
Class<?> onMessageClass = ReflectUtils.findGenericClassFor(handler,MessageHandler.Whole.class);
|
||||
LOG.debug("Whole message class: {}",onMessageClass);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("Whole message class: {}",onMessageClass);
|
||||
}
|
||||
metadatas.add(new MessageHandlerMetadata(handler,onMessageClass,partial));
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.lang.annotation.Annotation;
|
|||
import java.lang.reflect.Method;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.websocket.EndpointConfig;
|
||||
import javax.websocket.OnClose;
|
||||
import javax.websocket.OnError;
|
||||
|
@ -89,7 +88,10 @@ public class AnnotatedEndpointScanner<T extends Annotation, C extends EndpointCo
|
|||
@Override
|
||||
public void onMethodAnnotation(AnnotatedEndpointMetadata<T, C> metadata, Class<?> pojo, Method method, Annotation annotation)
|
||||
{
|
||||
LOG.debug("onMethodAnnotation({}, {}, {}, {})",metadata,pojo,method,annotation);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("onMethodAnnotation({}, {}, {}, {})",metadata,pojo,method,annotation);
|
||||
}
|
||||
|
||||
if (isAnnotation(annotation,OnOpen.class))
|
||||
{
|
||||
|
@ -190,11 +192,17 @@ public class AnnotatedEndpointScanner<T extends Annotation, C extends EndpointCo
|
|||
{
|
||||
for (IJsrParamId paramId : paramIds)
|
||||
{
|
||||
LOG.debug("{}.process()",paramId);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("{}.process()",paramId);
|
||||
}
|
||||
if (paramId.process(param,callable))
|
||||
{
|
||||
// Successfully identified
|
||||
LOG.debug("Identified: {}",param);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("Identified: {}",param);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.io.Reader;
|
|||
import java.lang.annotation.Annotation;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.websocket.CloseReason;
|
||||
import javax.websocket.DecodeException;
|
||||
import javax.websocket.EndpointConfig;
|
||||
|
@ -110,7 +109,10 @@ public class JsrEvents<T extends Annotation, C extends EndpointConfig>
|
|||
Object ret = onBinary.call(websocket,buf,fin);
|
||||
if (ret != null)
|
||||
{
|
||||
LOG.debug("returning: {}",ret);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("returning: {}",ret);
|
||||
}
|
||||
endpoint.sendObject(ret);
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +127,10 @@ public class JsrEvents<T extends Annotation, C extends EndpointConfig>
|
|||
Object ret = onBinaryStream.call(websocket,stream);
|
||||
if (ret != null)
|
||||
{
|
||||
LOG.debug("returning: {}",ret);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("returning: {}",ret);
|
||||
}
|
||||
endpoint.sendObject(ret);
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +172,10 @@ public class JsrEvents<T extends Annotation, C extends EndpointConfig>
|
|||
Object ret = onPong.call(websocket,pong);
|
||||
if (ret != null)
|
||||
{
|
||||
LOG.debug("returning: {}",ret);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("returning: {}",ret);
|
||||
}
|
||||
endpoint.sendObject(ret);
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +189,10 @@ public class JsrEvents<T extends Annotation, C extends EndpointConfig>
|
|||
Object ret = onText.call(websocket,text,fin);
|
||||
if (ret != null)
|
||||
{
|
||||
LOG.debug("returning: {}",ret);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("returning: {}",ret);
|
||||
}
|
||||
endpoint.sendObject(ret);
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +206,10 @@ public class JsrEvents<T extends Annotation, C extends EndpointConfig>
|
|||
Object ret = onTextStream.call(websocket,reader);
|
||||
if (ret != null)
|
||||
{
|
||||
LOG.debug("returning: {}",ret);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("returning: {}",ret);
|
||||
}
|
||||
endpoint.sendObject(ret);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.io.InputStream;
|
|||
import java.io.Reader;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.websocket.CloseReason;
|
||||
import javax.websocket.DecodeException;
|
||||
|
||||
|
@ -83,13 +82,19 @@ public class JsrAnnotatedEventDriver extends AbstractJsrEventDriver
|
|||
if (events.isBinaryPartialSupported())
|
||||
{
|
||||
// Partial Message Support (does not use messageAppender)
|
||||
LOG.debug("Partial Binary Message: fin={}",fin);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("Partial Binary Message: fin={}",fin);
|
||||
}
|
||||
activeMessage = new BinaryPartialOnMessage(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Whole Message Support
|
||||
LOG.debug("Whole Binary Message");
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("Whole Binary Message");
|
||||
}
|
||||
activeMessage = new SimpleBinaryMessage(this);
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +106,10 @@ public class JsrAnnotatedEventDriver extends AbstractJsrEventDriver
|
|||
// Streaming Message Support
|
||||
if (activeMessage == null)
|
||||
{
|
||||
LOG.debug("Binary Message InputStream");
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("Binary Message InputStream");
|
||||
}
|
||||
final MessageInputStream stream = new MessageInputStream();
|
||||
activeMessage = stream;
|
||||
|
||||
|
@ -124,7 +132,10 @@ public class JsrAnnotatedEventDriver extends AbstractJsrEventDriver
|
|||
}
|
||||
}
|
||||
|
||||
LOG.debug("handled = {}",handled);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("handled = {}",handled);
|
||||
}
|
||||
|
||||
// Process any active MessageAppender
|
||||
if (handled && (activeMessage != null))
|
||||
|
@ -290,13 +301,19 @@ public class JsrAnnotatedEventDriver extends AbstractJsrEventDriver
|
|||
if (events.isTextPartialSupported())
|
||||
{
|
||||
// Partial Message Support
|
||||
LOG.debug("Partial Text Message: fin={}",fin);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("Partial Text Message: fin={}",fin);
|
||||
}
|
||||
activeMessage = new TextPartialOnMessage(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Whole Message Support
|
||||
LOG.debug("Whole Text Message");
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("Whole Text Message");
|
||||
}
|
||||
activeMessage = new SimpleTextMessage(this);
|
||||
}
|
||||
}
|
||||
|
@ -308,7 +325,10 @@ public class JsrAnnotatedEventDriver extends AbstractJsrEventDriver
|
|||
// Streaming Message Support
|
||||
if (activeMessage == null)
|
||||
{
|
||||
LOG.debug("Text Message Writer");
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("Text Message Writer");
|
||||
}
|
||||
|
||||
final MessageReader stream = new MessageReader(new MessageInputStream());
|
||||
activeMessage = stream;
|
||||
|
@ -332,7 +352,10 @@ public class JsrAnnotatedEventDriver extends AbstractJsrEventDriver
|
|||
}
|
||||
}
|
||||
|
||||
LOG.debug("handled = {}",handled);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("handled = {}", handled);
|
||||
}
|
||||
|
||||
// Process any active MessageAppender
|
||||
if (handled && (activeMessage != null))
|
||||
|
@ -347,7 +370,10 @@ public class JsrAnnotatedEventDriver extends AbstractJsrEventDriver
|
|||
@Override
|
||||
public void onTextMessage(String message)
|
||||
{
|
||||
LOG.debug("onText({})",message);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("onText({})",message);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.io.InputStream;
|
|||
import java.io.Reader;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.websocket.CloseReason;
|
||||
import javax.websocket.Endpoint;
|
||||
import javax.websocket.MessageHandler;
|
||||
|
@ -76,7 +75,10 @@ public class JsrEndpointEventDriver extends AbstractJsrEventDriver
|
|||
final MessageHandlerWrapper wrapper = jsrsession.getMessageHandlerWrapper(MessageType.BINARY);
|
||||
if (wrapper == null)
|
||||
{
|
||||
LOG.debug("No BINARY MessageHandler declared");
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("No BINARY MessageHandler declared");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (wrapper.wantsPartialMessages())
|
||||
|
@ -128,7 +130,10 @@ public class JsrEndpointEventDriver extends AbstractJsrEventDriver
|
|||
@Override
|
||||
public void onConnect()
|
||||
{
|
||||
LOG.debug("onConnect({}, {})",jsrsession,config);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("onConnect({}, {})",jsrsession,config);
|
||||
}
|
||||
try
|
||||
{
|
||||
endpoint.onOpen(jsrsession,config);
|
||||
|
@ -171,7 +176,10 @@ public class JsrEndpointEventDriver extends AbstractJsrEventDriver
|
|||
final MessageHandlerWrapper wrapper = jsrsession.getMessageHandlerWrapper(MessageType.TEXT);
|
||||
if (wrapper == null)
|
||||
{
|
||||
LOG.debug("No TEXT MessageHandler declared");
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("No TEXT MessageHandler declared");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (wrapper.wantsPartialMessages())
|
||||
|
@ -232,7 +240,10 @@ public class JsrEndpointEventDriver extends AbstractJsrEventDriver
|
|||
final MessageHandlerWrapper wrapper = jsrsession.getMessageHandlerWrapper(MessageType.PONG);
|
||||
if (wrapper == null)
|
||||
{
|
||||
LOG.debug("No PONG MessageHandler declared");
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("No PONG MessageHandler declared");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
|
@ -28,7 +26,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.websocket.ClientEndpointConfig;
|
||||
import javax.websocket.ContainerProvider;
|
||||
import javax.websocket.EncodeException;
|
||||
|
@ -52,6 +49,8 @@ import org.junit.Before;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
public class EncoderTest
|
||||
{
|
||||
private static class EchoServer implements Runnable
|
||||
|
@ -182,7 +181,8 @@ public class EncoderTest
|
|||
|
||||
public void write(Quotes quotes) throws IOException, EncodeException
|
||||
{
|
||||
LOG.debug("Writing Quotes: {}",quotes);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Writing Quotes: {}",quotes);
|
||||
this.session.getBasicRemote().sendObject(quotes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,10 +18,7 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356;
|
||||
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.websocket.CloseReason;
|
||||
import javax.websocket.Endpoint;
|
||||
import javax.websocket.EndpointConfig;
|
||||
|
@ -31,6 +28,8 @@ import org.eclipse.jetty.util.log.Log;
|
|||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.junit.Assert;
|
||||
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
/**
|
||||
* Basic Echo Client from extended Endpoint
|
||||
*/
|
||||
|
@ -49,7 +48,8 @@ public class EndpointEchoClient extends Endpoint
|
|||
@Override
|
||||
public void onOpen(Session session, EndpointConfig config)
|
||||
{
|
||||
LOG.debug("onOpen({}, {})",session,config);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("onOpen({}, {})",session,config);
|
||||
this.session = session;
|
||||
Assert.assertThat("Session is required",session,notNullValue());
|
||||
Assert.assertThat("EndpointConfig is required",config,notNullValue());
|
||||
|
|
|
@ -18,11 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.websocket.ContainerProvider;
|
||||
import javax.websocket.Session;
|
||||
import javax.websocket.WebSocketContainer;
|
||||
|
@ -38,6 +35,8 @@ import org.junit.Assert;
|
|||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
|
||||
public class EndpointEchoTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(EndpointEchoTest.class);
|
||||
|
@ -92,9 +91,11 @@ public class EndpointEchoTest
|
|||
Assert.assertThat(echoer,instanceOf(javax.websocket.Endpoint.class));
|
||||
// Issue connect using instance of class that extends Endpoint
|
||||
Session session = container.connectToServer(echoer,serverUri);
|
||||
LOG.debug("Client Connected: {}",session);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Client Connected: {}",session);
|
||||
session.getBasicRemote().sendText("Echo");
|
||||
LOG.debug("Client Message Sent");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Client Message Sent");
|
||||
echoer.textCapture.messageQueue.awaitMessages(1,1000,TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
|
@ -104,9 +105,11 @@ public class EndpointEchoTest
|
|||
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
|
||||
// Issue connect using class reference (class extends Endpoint)
|
||||
Session session = container.connectToServer(EndpointEchoClient.class,serverUri);
|
||||
LOG.debug("Client Connected: {}",session);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Client Connected: {}",session);
|
||||
session.getBasicRemote().sendText("Echo");
|
||||
LOG.debug("Client Message Sent");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Client Message Sent");
|
||||
// TODO: figure out echo verification.
|
||||
// echoer.textCapture.messageQueue.awaitMessages(1,1000,TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
@ -119,9 +122,11 @@ public class EndpointEchoTest
|
|||
Assert.assertThat(echoer,instanceOf(javax.websocket.Endpoint.class));
|
||||
// Issue connect using instance of class that extends abstract that extends Endpoint
|
||||
Session session = container.connectToServer(echoer,serverUri);
|
||||
LOG.debug("Client Connected: {}",session);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Client Connected: {}",session);
|
||||
session.getBasicRemote().sendText("Echo");
|
||||
LOG.debug("Client Message Sent");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Client Message Sent");
|
||||
echoer.messageQueue.awaitMessages(1,1000,TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
|
@ -131,9 +136,11 @@ public class EndpointEchoTest
|
|||
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
|
||||
// Issue connect using class reference (class that extends abstract that extends Endpoint)
|
||||
Session session = container.connectToServer(EchoStringEndpoint.class,serverUri);
|
||||
LOG.debug("Client Connected: {}",session);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Client Connected: {}",session);
|
||||
session.getBasicRemote().sendText("Echo");
|
||||
LOG.debug("Client Message Sent");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Client Message Sent");
|
||||
// TODO: figure out echo verification.
|
||||
// echoer.messageQueue.awaitMessages(1,1000,TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,10 @@ public class MessageQueue extends BlockingArrayQueue<String>
|
|||
long msDur = TimeUnit.MILLISECONDS.convert(timeoutDuration,timeoutUnit);
|
||||
long now = System.currentTimeMillis();
|
||||
long expireOn = now + msDur;
|
||||
LOG.debug("Await Message.. Now: {} - expireOn: {} ({} ms)",now,expireOn,msDur);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("Await Message.. Now: {} - expireOn: {} ({} ms)",now,expireOn,msDur);
|
||||
}
|
||||
|
||||
while (this.size() < expectedMessageCount)
|
||||
{
|
||||
|
|
|
@ -18,13 +18,10 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356.endpoints;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.websocket.ClientEndpoint;
|
||||
import javax.websocket.ClientEndpointConfig;
|
||||
import javax.websocket.DeploymentException;
|
||||
|
@ -51,6 +48,8 @@ import org.junit.runner.RunWith;
|
|||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
/**
|
||||
* Test {@link AnnotatedEndpointScanner} against various simple, 1 method, {@link ClientEndpoint} annotated classes with invalid signatures.
|
||||
*/
|
||||
|
@ -106,7 +105,8 @@ public class ClientAnnotatedEndpointScanner_InvalidSignaturesTest
|
|||
}
|
||||
catch (InvalidSignatureException e)
|
||||
{
|
||||
LOG.debug("{}:{}",e.getClass(),e.getMessage());
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("{}:{}",e.getClass(),e.getMessage());
|
||||
Assert.assertThat("Message",e.getMessage(),containsString(expectedAnnoClass.getSimpleName()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,13 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356.endpoints;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.websocket.CloseReason;
|
||||
import javax.websocket.CloseReason.CloseCode;
|
||||
|
||||
|
@ -33,6 +28,10 @@ import org.eclipse.jetty.util.log.Log;
|
|||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.junit.Assert;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
/**
|
||||
* Abstract base socket used for tracking state and events within the socket for testing reasons.
|
||||
*/
|
||||
|
@ -121,7 +120,8 @@ public abstract class TrackingSocket
|
|||
|
||||
public void waitForData(int timeoutDuration, TimeUnit timeoutUnit) throws InterruptedException
|
||||
{
|
||||
LOG.debug("Waiting for message");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Waiting for message");
|
||||
Assert.assertThat("Data Received",dataLatch.await(timeoutDuration,timeoutUnit),is(true));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,8 @@ public abstract class AbstractStringEndpoint extends Endpoint implements Message
|
|||
@Override
|
||||
public void onOpen(Session session, EndpointConfig config)
|
||||
{
|
||||
LOG.debug("onOpen({}, {})",session,config);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("onOpen({}, {})",session,config);
|
||||
session.addMessageHandler(this);
|
||||
this.session = session;
|
||||
this.config = config;
|
||||
|
@ -47,7 +48,8 @@ public abstract class AbstractStringEndpoint extends Endpoint implements Message
|
|||
|
||||
public void onClose(Session session, CloseReason closeReason)
|
||||
{
|
||||
LOG.debug("onClose({}, {})",session,closeReason);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("onClose({}, {})",session,closeReason);
|
||||
this.session = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.eclipse.jetty.websocket.jsr356.server;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.websocket.Extension;
|
||||
import javax.websocket.HandshakeResponse;
|
||||
import javax.websocket.server.HandshakeRequest;
|
||||
|
@ -44,7 +43,10 @@ public class BasicServerEndpointConfigurator extends ServerEndpointConfig.Config
|
|||
@Override
|
||||
public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException
|
||||
{
|
||||
LOG.debug(".getEndpointInstance({})",endpointClass);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug(".getEndpointInstance({})",endpointClass);
|
||||
}
|
||||
try
|
||||
{
|
||||
return endpointClass.newInstance();
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.eclipse.jetty.websocket.jsr356.server;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.websocket.Extension;
|
||||
import javax.websocket.Extension.Parameter;
|
||||
import javax.websocket.server.ServerEndpointConfig;
|
||||
|
@ -73,7 +72,8 @@ public class JsrCreator implements WebSocketCreator
|
|||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOG.debug("Unable to send error response",e);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Unable to send error response",e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -132,7 +132,8 @@ public class JsrCreator implements WebSocketCreator
|
|||
}
|
||||
catch (InstantiationException e)
|
||||
{
|
||||
LOG.debug("Unable to create websocket: " + config.getEndpointClass().getName(),e);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Unable to create websocket: " + config.getEndpointClass().getName(),e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.websocket.jsr356.server.deploy;
|
|||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletContainerInitializer;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
|
@ -74,16 +73,26 @@ public class WebSocketServerContainerInitializer implements ServletContainerInit
|
|||
if (TypeUtil.isFalse(enable))
|
||||
{
|
||||
if (c.isEmpty())
|
||||
LOG.debug("JSR-356 support disabled via attribute on context {} - {}",context.getContextPath(),context);
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("JSR-356 support disabled via attribute on context {} - {}",context.getContextPath(),context);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG.warn("JSR-356 support disabled via attribute on context {} - {}",context.getContextPath(),context);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Disabled if not explicitly enabled and there are no discovered annotations or interfaces
|
||||
if (!TypeUtil.isTrue(enable) && c.isEmpty())
|
||||
{
|
||||
LOG.debug("No JSR-356 annotations or interfaces discovered. JSR-356 support disabled",context.getContextPath(),context);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("No JSR-356 annotations or interfaces discovered. JSR-356 support disabled",context.getContextPath(),context);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -107,7 +116,10 @@ public class WebSocketServerContainerInitializer implements ServletContainerInit
|
|||
// Store a reference to the ServerContainer per javax.websocket spec 1.0 final section 6.4 Programmatic Server Deployment
|
||||
context.setAttribute(javax.websocket.server.ServerContainer.class.getName(),jettyContainer);
|
||||
|
||||
LOG.debug("Found {} classes",c.size());
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("Found {} classes",c.size());
|
||||
}
|
||||
|
||||
// Now process the incoming classes
|
||||
Set<Class<? extends Endpoint>> discoveredExtendedEndpoints = new HashSet<>();
|
||||
|
@ -116,9 +128,12 @@ public class WebSocketServerContainerInitializer implements ServletContainerInit
|
|||
|
||||
filterClasses(c,discoveredExtendedEndpoints,discoveredAnnotatedEndpoints,serverAppConfigs);
|
||||
|
||||
LOG.debug("Discovered {} extends Endpoint classes",discoveredExtendedEndpoints.size());
|
||||
LOG.debug("Discovered {} @ServerEndpoint classes",discoveredAnnotatedEndpoints.size());
|
||||
LOG.debug("Discovered {} ServerApplicationConfig classes",serverAppConfigs.size());
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("Discovered {} extends Endpoint classes",discoveredExtendedEndpoints.size());
|
||||
LOG.debug("Discovered {} @ServerEndpoint classes",discoveredAnnotatedEndpoints.size());
|
||||
LOG.debug("Discovered {} ServerApplicationConfig classes",serverAppConfigs.size());
|
||||
}
|
||||
|
||||
// Process the server app configs to determine endpoint filtering
|
||||
boolean wasFiltered = false;
|
||||
|
@ -127,7 +142,10 @@ public class WebSocketServerContainerInitializer implements ServletContainerInit
|
|||
|
||||
for (Class<? extends ServerApplicationConfig> clazz : serverAppConfigs)
|
||||
{
|
||||
LOG.debug("Found ServerApplicationConfig: {}",clazz);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("Found ServerApplicationConfig: {}",clazz);
|
||||
}
|
||||
try
|
||||
{
|
||||
ServerApplicationConfig config = clazz.newInstance();
|
||||
|
@ -160,8 +178,11 @@ public class WebSocketServerContainerInitializer implements ServletContainerInit
|
|||
deployableExtendedEndpointConfigs = new HashSet<>();
|
||||
}
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("Deploying {} ServerEndpointConfig(s)",deployableExtendedEndpointConfigs.size());
|
||||
}
|
||||
// Deploy what should be deployed.
|
||||
LOG.debug("Deploying {} ServerEndpointConfig(s)",deployableExtendedEndpointConfigs.size());
|
||||
for (ServerEndpointConfig config : deployableExtendedEndpointConfigs)
|
||||
{
|
||||
try
|
||||
|
@ -174,7 +195,10 @@ public class WebSocketServerContainerInitializer implements ServletContainerInit
|
|||
}
|
||||
}
|
||||
|
||||
LOG.debug("Deploying {} @ServerEndpoint(s)",deployableAnnotatedEndpoints.size());
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("Deploying {} @ServerEndpoint(s)",deployableAnnotatedEndpoints.size());
|
||||
}
|
||||
for (Class<?> annotatedClass : deployableAnnotatedEndpoints)
|
||||
{
|
||||
try
|
||||
|
|
|
@ -18,15 +18,12 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356.server;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.websocket.Extension;
|
||||
import javax.websocket.HandshakeResponse;
|
||||
import javax.websocket.OnMessage;
|
||||
|
@ -52,6 +49,9 @@ import org.junit.Assert;
|
|||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
||||
public class ConfiguratorTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ConfiguratorTest.class);
|
||||
|
@ -191,7 +191,8 @@ public class ConfiguratorTest
|
|||
}
|
||||
int port = connector.getLocalPort();
|
||||
baseServerUri = new URI(String.format("ws://%s:%d/",host,port));
|
||||
LOG.debug("Server started on {}",baseServerUri);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Server started on {}",baseServerUri);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
|
|
@ -145,7 +145,8 @@ public class DummyConnection implements LogicalConnection
|
|||
@Override
|
||||
public void setNextIncomingFrames(IncomingFrames incoming)
|
||||
{
|
||||
LOG.debug("setNextIncomingFrames({})",incoming);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("setNextIncomingFrames({})",incoming);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,9 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356.server;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Queue;
|
||||
|
@ -46,6 +43,10 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class IdleTimeoutTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(IdleTimeoutTest.class);
|
||||
|
@ -90,15 +91,19 @@ public class IdleTimeoutTest
|
|||
{
|
||||
client.start();
|
||||
JettyEchoSocket clientEcho = new JettyEchoSocket();
|
||||
LOG.debug("Client Attempting to connnect");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Client Attempting to connnect");
|
||||
Future<Session> future = client.connect(clientEcho,uri);
|
||||
// wait for connect
|
||||
future.get(1,TimeUnit.SECONDS);
|
||||
LOG.debug("Client Connected");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Client Connected");
|
||||
// wait 1 second
|
||||
LOG.debug("Waiting 1 second");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Waiting 1 second");
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
LOG.debug("Waited 1 second");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Waited 1 second");
|
||||
if (clientEcho.getClosed() == false)
|
||||
{
|
||||
// Try to write
|
||||
|
|
|
@ -18,13 +18,10 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356.server;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.websocket.DeploymentException;
|
||||
import javax.websocket.OnClose;
|
||||
import javax.websocket.OnError;
|
||||
|
@ -49,6 +46,8 @@ import org.junit.runner.RunWith;
|
|||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
/**
|
||||
* Test {@link AnnotatedEndpointScanner} against various simple, 1 method {@link ServerEndpoint} annotated classes with invalid signatures.
|
||||
*/
|
||||
|
@ -104,7 +103,8 @@ public class ServerAnnotatedEndpointScanner_InvalidSignaturesTest
|
|||
}
|
||||
catch (InvalidSignatureException e)
|
||||
{
|
||||
LOG.debug("{}:{}",e.getClass(),e.getMessage());
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("{}:{}",e.getClass(),e.getMessage());
|
||||
Assert.assertThat("Message",e.getMessage(),containsString(expectedAnnoClass.getSimpleName()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356.server;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
|
@ -34,7 +32,6 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.websocket.ClientEndpoint;
|
||||
import javax.websocket.CloseReason;
|
||||
import javax.websocket.CloseReason.CloseCode;
|
||||
|
@ -71,6 +68,9 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.equalToIgnoringCase;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
public class StreamTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(StreamTest.class);
|
||||
|
@ -114,7 +114,8 @@ public class StreamTest
|
|||
}
|
||||
int port = connector.getLocalPort();
|
||||
serverUri = new URI(String.format("ws://%s:%d/",host,port));
|
||||
LOG.debug("Server started on {}",serverUri);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Server started on {}",serverUri);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -290,7 +291,8 @@ public class StreamTest
|
|||
if (outputFile.exists())
|
||||
{
|
||||
closeReason = String.format("Received %,d bytes",outputFile.length());
|
||||
LOG.debug(closeReason);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug(closeReason);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -18,13 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356.server;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.websocket.CloseReason;
|
||||
import javax.websocket.CloseReason.CloseCode;
|
||||
|
||||
|
@ -33,6 +28,10 @@ import org.eclipse.jetty.util.log.Log;
|
|||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.junit.Assert;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
/**
|
||||
* Abstract base socket used for tracking state and events within the socket for testing reasons.
|
||||
*/
|
||||
|
@ -121,7 +120,8 @@ public abstract class TrackingSocket
|
|||
|
||||
public void waitForData(int timeoutDuration, TimeUnit timeoutUnit) throws InterruptedException
|
||||
{
|
||||
LOG.debug("Waiting for message");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Waiting for message");
|
||||
Assert.assertThat("Data Received",dataLatch.await(timeoutDuration,timeoutUnit),is(true));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356.server;
|
||||
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
|
@ -49,6 +47,8 @@ import org.eclipse.jetty.webapp.WebInfConfiguration;
|
|||
import org.eclipse.jetty.webapp.WebXmlConfiguration;
|
||||
import org.junit.Assert;
|
||||
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
/**
|
||||
* Utility to build out exploded directory WebApps, in the /target/tests/ directory, for testing out servers that use javax.websocket endpoints.
|
||||
* <p>
|
||||
|
@ -178,8 +178,8 @@ public class WSServer
|
|||
}
|
||||
int port = connector.getLocalPort();
|
||||
serverUri = new URI(String.format("ws://%s:%d%s/",host,port,contextPath));
|
||||
LOG.debug("Server started on {}",serverUri);
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Server started on {}",serverUri);
|
||||
}
|
||||
|
||||
public void stop()
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.websocket.CloseReason;
|
||||
import javax.websocket.OnClose;
|
||||
import javax.websocket.OnMessage;
|
||||
|
@ -206,13 +205,15 @@ public class JsrBrowserSocket
|
|||
{
|
||||
if (this.session == null)
|
||||
{
|
||||
LOG.debug("Not connected");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Not connected");
|
||||
return;
|
||||
}
|
||||
|
||||
if (session.isOpen() == false)
|
||||
{
|
||||
LOG.debug("Not open");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Not open");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.eclipse.jetty.websocket.jsr356.server.samples.pong;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import javax.websocket.EndpointConfig;
|
||||
import javax.websocket.OnMessage;
|
||||
import javax.websocket.OnOpen;
|
||||
|
@ -48,7 +47,8 @@ public class PongSocket
|
|||
@OnMessage
|
||||
public void onPong(PongMessage pong)
|
||||
{
|
||||
LOG.debug("onPong(): PongMessage.appData={}",BufferUtil.toDetailString(pong.getApplicationData()));
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("onPong(): PongMessage.appData={}",BufferUtil.toDetailString(pong.getApplicationData()));
|
||||
byte buf[] = BufferUtil.toArray(pong.getApplicationData());
|
||||
String message = new String(buf,StandardCharsets.UTF_8);
|
||||
this.session.getAsyncRemote().sendText("@OnMessage(PongMessage)[" + path + "]:" + message);
|
||||
|
|
|
@ -180,8 +180,8 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
|
|||
}
|
||||
}
|
||||
|
||||
// Validate websocket URI
|
||||
LOG.debug("connect websocket {} to {}",websocket,toUri);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("connect websocket {} to {}",websocket,toUri);
|
||||
|
||||
// Grab Connection Manager
|
||||
initialiseClient();
|
||||
|
@ -213,7 +213,8 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
|
|||
promise.setUpgradeListener(upgradeListener);
|
||||
}
|
||||
|
||||
LOG.debug("Connect Promise: {}",promise);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Connect Promise: {}",promise);
|
||||
|
||||
// Execute the connection on the executor thread
|
||||
executor.execute(promise);
|
||||
|
@ -225,7 +226,8 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
|
|||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
LOG.debug("Starting {}",this);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Starting {}",this);
|
||||
|
||||
if (sslContextFactory != null)
|
||||
{
|
||||
|
@ -253,13 +255,15 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
|
|||
|
||||
super.doStart();
|
||||
|
||||
LOG.debug("Started {}",this);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Started {}",this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() throws Exception
|
||||
{
|
||||
LOG.debug("Stopping {}",this);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Stopping {}",this);
|
||||
|
||||
if (cookieStore != null)
|
||||
{
|
||||
|
@ -268,7 +272,9 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
|
|||
}
|
||||
|
||||
super.doStop();
|
||||
LOG.debug("Stopped {}",this);
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Stopped {}",this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -418,10 +424,12 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
|
|||
continue;
|
||||
}
|
||||
|
||||
LOG.debug("added {}",extension);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("added {}",extension);
|
||||
extensions.add(extension);
|
||||
}
|
||||
LOG.debug("extensions={}",extensions);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("extensions={}",extensions);
|
||||
return extensions;
|
||||
}
|
||||
|
||||
|
@ -463,14 +471,16 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
|
|||
@Override
|
||||
public void onSessionClosed(WebSocketSession session)
|
||||
{
|
||||
LOG.debug("Session Closed: {}",session);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Session Closed: {}",session);
|
||||
removeBean(session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSessionOpened(WebSocketSession session)
|
||||
{
|
||||
LOG.debug("Session Opened: {}",session);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Session Opened: {}",session);
|
||||
}
|
||||
|
||||
public void setAsyncWriteTimeout(long ms)
|
||||
|
|
|
@ -117,11 +117,13 @@ public class UpgradeConnection extends AbstractConnection
|
|||
EndPoint endPoint = getEndPoint();
|
||||
// We need to gently close first, to allow
|
||||
// SSL close alerts to be sent by Jetty
|
||||
LOG.debug("Shutting down output {}",endPoint);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Shutting down output {}",endPoint);
|
||||
endPoint.shutdownOutput();
|
||||
if (!onlyOutput)
|
||||
{
|
||||
LOG.debug("Closing {}",endPoint);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Closing {}",endPoint);
|
||||
endPoint.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.io.IOException;
|
|||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
|
@ -54,7 +53,8 @@ public class WebSocketClientSelectorManager extends SelectorManager
|
|||
@Override
|
||||
protected void connectionFailed(SocketChannel channel, Throwable ex, Object attachment)
|
||||
{
|
||||
LOG.debug("Connection Failed",ex);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Connection Failed",ex);
|
||||
ConnectPromise connect = (ConnectPromise)attachment;
|
||||
connect.failed(ex);
|
||||
}
|
||||
|
@ -67,7 +67,8 @@ public class WebSocketClientSelectorManager extends SelectorManager
|
|||
@Override
|
||||
public Connection newConnection(final SocketChannel channel, EndPoint endPoint, final Object attachment) throws IOException
|
||||
{
|
||||
LOG.debug("newConnection({},{},{})",channel,endPoint,attachment);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("newConnection({},{},{})",channel,endPoint,attachment);
|
||||
ConnectPromise connectPromise = (ConnectPromise)attachment;
|
||||
|
||||
try
|
||||
|
@ -114,7 +115,8 @@ public class WebSocketClientSelectorManager extends SelectorManager
|
|||
@Override
|
||||
protected EndPoint newEndPoint(SocketChannel channel, ManagedSelector selectSet, SelectionKey selectionKey) throws IOException
|
||||
{
|
||||
LOG.debug("newEndPoint({}, {}, {})",channel,selectSet,selectionKey);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("newEndPoint({}, {}, {})",channel,selectSet,selectionKey);
|
||||
return new SelectChannelEndPoint(channel,selectSet,selectionKey,getScheduler(),policy.getIdleTimeout());
|
||||
}
|
||||
|
||||
|
|
|
@ -352,7 +352,8 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
|
|||
{
|
||||
try
|
||||
{
|
||||
LOG.debug("{}.onSessionClosed()",listener.getClass().getSimpleName());
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("{}.onSessionClosed()",listener.getClass().getSimpleName());
|
||||
listener.onSessionClosed(this);
|
||||
}
|
||||
catch (Throwable t)
|
||||
|
|
|
@ -167,7 +167,8 @@ public abstract class AbstractEventDriver implements IncomingFrames, EventDriver
|
|||
}
|
||||
default:
|
||||
{
|
||||
LOG.debug("Unhandled OpCode: {}",opcode);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Unhandled OpCode: {}",opcode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -211,7 +212,8 @@ public abstract class AbstractEventDriver implements IncomingFrames, EventDriver
|
|||
@Override
|
||||
public void openSession(WebSocketSession session)
|
||||
{
|
||||
LOG.debug("openSession({})",session);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("openSession({})",session);
|
||||
this.session = session;
|
||||
try
|
||||
{
|
||||
|
@ -226,7 +228,8 @@ public abstract class AbstractEventDriver implements IncomingFrames, EventDriver
|
|||
|
||||
protected void terminateConnection(int statusCode, String rawreason)
|
||||
{
|
||||
LOG.debug("terminateConnection({},{})",statusCode,rawreason);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("terminateConnection({},{})",statusCode,rawreason);
|
||||
session.close(statusCode,CloseFrame.truncate(rawreason));
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,8 @@ public class JettyAnnotatedScanner extends AbstractMethodAnnotationScanner<Jetty
|
|||
@Override
|
||||
public void onMethodAnnotation(JettyAnnotatedMetadata metadata, Class<?> pojo, Method method, Annotation annotation)
|
||||
{
|
||||
LOG.debug("onMethodAnnotation({}, {}, {}, {})",metadata,pojo,method,annotation);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("onMethodAnnotation({}, {}, {}, {})",metadata,pojo,method,annotation);
|
||||
|
||||
if (isAnnotation(annotation,OnWebSocketConnect.class))
|
||||
{
|
||||
|
|
|
@ -82,7 +82,8 @@ public class JettyListenerEventDriver extends AbstractEventDriver
|
|||
@Override
|
||||
public void onConnect()
|
||||
{
|
||||
LOG.debug("onConnect()");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("onConnect()");
|
||||
listener.onWebSocketConnect(session);
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,6 @@ public class ExtensionStack extends ContainerLifeCycle implements IncomingFrames
|
|||
protected void doStart() throws Exception
|
||||
{
|
||||
super.doStart();
|
||||
LOG.debug("doStart");
|
||||
|
||||
// Wire up Extensions
|
||||
if ((extensions != null) && (extensions.size() > 0))
|
||||
|
@ -225,7 +224,9 @@ public class ExtensionStack extends ContainerLifeCycle implements IncomingFrames
|
|||
*/
|
||||
public void negotiate(List<ExtensionConfig> configs)
|
||||
{
|
||||
LOG.debug("Extension Configs={}",configs);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Extension Configs={}",configs);
|
||||
|
||||
this.extensions = new ArrayList<>();
|
||||
|
||||
String rsvClaims[] = new String[3];
|
||||
|
@ -260,7 +261,8 @@ public class ExtensionStack extends ContainerLifeCycle implements IncomingFrames
|
|||
extensions.add(ext);
|
||||
addBean(ext);
|
||||
|
||||
LOG.debug("Adding Extension: {}",config);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Adding Extension: {}",config);
|
||||
|
||||
// Record RSV Claims
|
||||
if (ext.isRsv1User())
|
||||
|
@ -282,7 +284,8 @@ public class ExtensionStack extends ContainerLifeCycle implements IncomingFrames
|
|||
public void outgoingFrame(Frame frame, WriteCallback callback, BatchMode batchMode)
|
||||
{
|
||||
FrameEntry entry = new FrameEntry(frame,callback,batchMode);
|
||||
LOG.debug("Queuing {}",entry);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Queuing {}",entry);
|
||||
entries.offer(entry);
|
||||
flusher.iterate();
|
||||
}
|
||||
|
@ -377,10 +380,12 @@ public class ExtensionStack extends ContainerLifeCycle implements IncomingFrames
|
|||
current = entries.poll();
|
||||
if (current == null)
|
||||
{
|
||||
LOG.debug("Entering IDLE");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Entering IDLE");
|
||||
return Action.IDLE;
|
||||
}
|
||||
LOG.debug("Processing {}",current);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Processing {}",current);
|
||||
nextOutgoing.outgoingFrame(current.frame,this,current.batchMode);
|
||||
return Action.SCHEDULED;
|
||||
}
|
||||
|
|
|
@ -135,7 +135,9 @@ public abstract class CompressExtension extends AbstractExtension
|
|||
ByteAccumulator accumulator = new ByteAccumulator(maxSize);
|
||||
|
||||
decompressor.setInput(input, 0, input.length);
|
||||
LOG.debug("Decompressing {} bytes", input.length);
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Decompressing {} bytes", input.length);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -164,7 +166,8 @@ public abstract class CompressExtension extends AbstractExtension
|
|||
accumulator.addChunk(output, 0, decompressed);
|
||||
}
|
||||
}
|
||||
LOG.debug("Decompressed {}->{} bytes", input.length, accumulator.getLength());
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Decompressed {}->{} bytes", input.length, accumulator.getLength());
|
||||
return accumulator;
|
||||
}
|
||||
catch (DataFormatException x)
|
||||
|
@ -187,7 +190,8 @@ public abstract class CompressExtension extends AbstractExtension
|
|||
}
|
||||
|
||||
FrameEntry entry = new FrameEntry(frame, callback, batchMode);
|
||||
LOG.debug("Queuing {}", entry);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Queuing {}", entry);
|
||||
entries.offer(entry);
|
||||
flusher.iterate();
|
||||
}
|
||||
|
@ -201,7 +205,8 @@ public abstract class CompressExtension extends AbstractExtension
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
LOG.debug("Exception while notifying success of callback " + callback, x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Exception while notifying success of callback " + callback, x);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,7 +219,8 @@ public abstract class CompressExtension extends AbstractExtension
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
LOG.debug("Exception while notifying failure of callback " + callback, x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Exception while notifying failure of callback " + callback, x);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -290,7 +296,8 @@ public abstract class CompressExtension extends AbstractExtension
|
|||
ByteBuffer data = frame.getPayload();
|
||||
int remaining = data.remaining();
|
||||
int inputLength = Math.min(remaining, INPUT_BUFSIZE);
|
||||
LOG.debug("Compressing {}: {} bytes in {} bytes chunk", entry, remaining, inputLength);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Compressing {}: {} bytes in {} bytes chunk", entry, remaining, inputLength);
|
||||
|
||||
// Avoid to copy the bytes if the ByteBuffer
|
||||
// is backed by an array.
|
||||
|
|
|
@ -69,7 +69,8 @@ public class FragmentExtension extends AbstractExtension
|
|||
}
|
||||
|
||||
FrameEntry entry = new FrameEntry(frame, callback, batchMode);
|
||||
LOG.debug("Queuing {}", entry);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Queuing {}", entry);
|
||||
entries.offer(entry);
|
||||
flusher.iterate();
|
||||
}
|
||||
|
@ -143,7 +144,8 @@ public class FragmentExtension extends AbstractExtension
|
|||
ByteBuffer payloadFragment = payload.slice();
|
||||
payload.limit(limit);
|
||||
fragment.setPayload(payloadFragment);
|
||||
LOG.debug("Fragmented {}->{}", frame, fragment);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Fragmented {}->{}", frame, fragment);
|
||||
payload.position(newLimit);
|
||||
|
||||
nextOutgoingFrame(fragment, this, entry.batchMode);
|
||||
|
@ -193,7 +195,8 @@ public class FragmentExtension extends AbstractExtension
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
LOG.debug("Exception while notifying success of callback " + callback, x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Exception while notifying success of callback " + callback, x);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,7 +209,8 @@ public class FragmentExtension extends AbstractExtension
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
LOG.debug("Exception while notifying failure of callback " + callback, x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Exception while notifying failure of callback " + callback, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,8 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
|
|||
return;
|
||||
}
|
||||
|
||||
LOG.debug("Write flush failure",x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Write flush failure",x);
|
||||
ioState.onWriteFailure(x);
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +156,8 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
|
|||
|
||||
private void onLocalClose()
|
||||
{
|
||||
LOG.debug("Local Close Confirmed {}",close);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Local Close Confirmed {}",close);
|
||||
if (close.isAbnormal())
|
||||
{
|
||||
ioState.onAbnormalClose(close);
|
||||
|
@ -260,7 +262,8 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
|
|||
@Override
|
||||
public void close(int statusCode, String reason)
|
||||
{
|
||||
LOG.debug("close({},{})",statusCode,reason);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("close({},{})",statusCode,reason);
|
||||
CloseInfo close = new CloseInfo(statusCode,reason);
|
||||
this.outgoingFrame(close.asFrame(),new OnCloseLocalCallback(close),BatchMode.OFF);
|
||||
}
|
||||
|
@ -273,13 +276,15 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
|
|||
|
||||
private void disconnect(boolean onlyOutput)
|
||||
{
|
||||
LOG.debug("{} disconnect({})",policy.getBehavior(),onlyOutput?"outputOnly":"both");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("{} disconnect({})",policy.getBehavior(),onlyOutput?"outputOnly":"both");
|
||||
// close FrameFlusher, we cannot write anymore at this point.
|
||||
flusher.close();
|
||||
EndPoint endPoint = getEndPoint();
|
||||
// We need to gently close first, to allow
|
||||
// SSL close alerts to be sent by Jetty
|
||||
LOG.debug("Shutting down output {}",endPoint);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Shutting down output {}",endPoint);
|
||||
endPoint.shutdownOutput();
|
||||
if (!onlyOutput)
|
||||
{
|
||||
|
@ -296,7 +301,8 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
|
|||
}
|
||||
catch (RejectedExecutionException e)
|
||||
{
|
||||
LOG.debug("Job not dispatched: {}",task);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Job not dispatched: {}",task);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -401,7 +407,8 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
|
|||
@Override
|
||||
public void onClose()
|
||||
{
|
||||
LOG.debug("{} onClose()",policy.getBehavior());
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("{} onClose()",policy.getBehavior());
|
||||
super.onClose();
|
||||
// ioState.onDisconnected();
|
||||
flusher.close();
|
||||
|
@ -410,11 +417,13 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
|
|||
@Override
|
||||
public void onConnectionStateChange(ConnectionState state)
|
||||
{
|
||||
LOG.debug("{} Connection State Change: {}",policy.getBehavior(),state);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("{} Connection State Change: {}",policy.getBehavior(),state);
|
||||
switch (state)
|
||||
{
|
||||
case OPEN:
|
||||
LOG.debug("fillInterested");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("fillInterested");
|
||||
fillInterested();
|
||||
break;
|
||||
case CLOSED:
|
||||
|
@ -446,7 +455,8 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
|
|||
@Override
|
||||
public void onFillable()
|
||||
{
|
||||
LOG.debug("{} onFillable()",policy.getBehavior());
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("{} onFillable()",policy.getBehavior());
|
||||
stats.countOnFillableEvents.incrementAndGet();
|
||||
ByteBuffer buffer = bufferPool.acquire(getInputBufferSize(),true);
|
||||
try
|
||||
|
@ -501,7 +511,8 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
|
|||
{
|
||||
IOState state = getIOState();
|
||||
ConnectionState cstate = state.getConnectionState();
|
||||
LOG.debug("{} Read Timeout - {}",policy.getBehavior(),cstate);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("{} Read Timeout - {}",policy.getBehavior(),cstate);
|
||||
|
||||
if (cstate == ConnectionState.CLOSED)
|
||||
{
|
||||
|
|
|
@ -392,7 +392,8 @@ public class FrameFlusher
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
LOG.debug("Exception while notifying failure of callback " + callback,x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Exception while notifying failure of callback " + callback,x);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -407,7 +408,8 @@ public class FrameFlusher
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
LOG.debug("Exception while notifying success of callback " + callback,x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Exception while notifying success of callback " + callback,x);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,14 +33,16 @@ public class FutureWriteCallback extends FutureCallback implements WriteCallback
|
|||
@Override
|
||||
public void writeFailed(Throwable cause)
|
||||
{
|
||||
LOG.debug(".writeFailed",cause);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug(".writeFailed",cause);
|
||||
failed(cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSuccess()
|
||||
{
|
||||
LOG.debug(".writeSuccess");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug(".writeSuccess");
|
||||
succeeded();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,7 +174,8 @@ public class IOState
|
|||
|
||||
private void notifyStateListeners(ConnectionState state)
|
||||
{
|
||||
LOG.debug("Notify State Listeners: {}",state);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Notify State Listeners: {}",state);
|
||||
for (ConnectionStateListener listener : listeners)
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
|
@ -192,7 +193,8 @@ public class IOState
|
|||
*/
|
||||
public void onAbnormalClose(CloseInfo close)
|
||||
{
|
||||
LOG.debug("onAbnormalClose({})",close);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("onAbnormalClose({})",close);
|
||||
ConnectionState event = null;
|
||||
synchronized (this)
|
||||
{
|
||||
|
@ -225,7 +227,8 @@ public class IOState
|
|||
ConnectionState event = null;
|
||||
ConnectionState abnormalEvent = null;
|
||||
ConnectionState initialState = this.state;
|
||||
LOG.debug("onCloseLocal({}) : {}",close,initialState);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("onCloseLocal({}) : {}",close,initialState);
|
||||
if (initialState == ConnectionState.CLOSED)
|
||||
{
|
||||
// already closed
|
||||
|
@ -239,7 +242,8 @@ public class IOState
|
|||
LOG.debug("FastClose in CONNECTED detected");
|
||||
// Force the state open (to allow read/write to endpoint)
|
||||
onOpened();
|
||||
LOG.debug("FastClose continuing with Closure");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("FastClose continuing with Closure");
|
||||
}
|
||||
|
||||
synchronized (this)
|
||||
|
@ -300,7 +304,8 @@ public class IOState
|
|||
*/
|
||||
public void onCloseRemote(CloseInfo close)
|
||||
{
|
||||
LOG.debug("onCloseRemote({})",close);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("onCloseRemote({})",close);
|
||||
ConnectionState event = null;
|
||||
synchronized (this)
|
||||
{
|
||||
|
@ -321,7 +326,8 @@ public class IOState
|
|||
in = false;
|
||||
inputAvailable = false;
|
||||
|
||||
LOG.debug("onCloseRemote(), input={}, output={}",in,out);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("onCloseRemote(), input={}, output={}",in,out);
|
||||
|
||||
if (!in && !out)
|
||||
{
|
||||
|
|
|
@ -129,7 +129,8 @@ public class MessageInputStream extends InputStream implements MessageAppender
|
|||
@Override
|
||||
public void messageComplete()
|
||||
{
|
||||
LOG.debug("Message completed");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Message completed");
|
||||
buffers.offer(EOF);
|
||||
}
|
||||
|
||||
|
@ -140,7 +141,8 @@ public class MessageInputStream extends InputStream implements MessageAppender
|
|||
{
|
||||
if (closed.get())
|
||||
{
|
||||
LOG.debug("Stream closed");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Stream closed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -166,7 +168,8 @@ public class MessageInputStream extends InputStream implements MessageAppender
|
|||
|
||||
if (activeBuffer == EOF)
|
||||
{
|
||||
LOG.debug("Reached EOF");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Reached EOF");
|
||||
// Be sure that this stream cannot be reused.
|
||||
closed.set(true);
|
||||
// Removed buffers that may have remained in the queue.
|
||||
|
@ -179,7 +182,8 @@ public class MessageInputStream extends InputStream implements MessageAppender
|
|||
}
|
||||
catch (InterruptedException x)
|
||||
{
|
||||
LOG.debug("Interrupted while waiting to read", x);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Interrupted while waiting to read", x);
|
||||
closed.set(true);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ import org.eclipse.jetty.websocket.api.BatchMode;
|
|||
import org.eclipse.jetty.websocket.api.WriteCallback;
|
||||
import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
|
||||
import org.eclipse.jetty.websocket.common.BlockingWriteCallback;
|
||||
import org.eclipse.jetty.websocket.common.WebSocketSession;
|
||||
import org.eclipse.jetty.websocket.common.BlockingWriteCallback.WriteBlocker;
|
||||
import org.eclipse.jetty.websocket.common.WebSocketSession;
|
||||
import org.eclipse.jetty.websocket.common.frames.BinaryFrame;
|
||||
|
||||
/**
|
||||
|
@ -117,7 +117,8 @@ public class MessageOutputStream extends OutputStream
|
|||
{
|
||||
flush(true);
|
||||
bufferPool.release(buffer);
|
||||
LOG.debug("Stream closed, {} frames sent", frameCount);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Stream closed, {} frames sent", frameCount);
|
||||
// Notify without holding locks.
|
||||
notifySuccess();
|
||||
}
|
||||
|
@ -139,7 +140,8 @@ public class MessageOutputStream extends OutputStream
|
|||
closed = fin;
|
||||
|
||||
BufferUtil.flipToFlush(buffer, 0);
|
||||
LOG.debug("flush({}): {}", fin, BufferUtil.toDetailString(buffer));
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("flush({}): {}", fin, BufferUtil.toDetailString(buffer));
|
||||
frame.setPayload(buffer);
|
||||
frame.setFin(fin);
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ import org.eclipse.jetty.websocket.api.BatchMode;
|
|||
import org.eclipse.jetty.websocket.api.WriteCallback;
|
||||
import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
|
||||
import org.eclipse.jetty.websocket.common.BlockingWriteCallback;
|
||||
import org.eclipse.jetty.websocket.common.WebSocketSession;
|
||||
import org.eclipse.jetty.websocket.common.BlockingWriteCallback.WriteBlocker;
|
||||
import org.eclipse.jetty.websocket.common.WebSocketSession;
|
||||
import org.eclipse.jetty.websocket.common.frames.TextFrame;
|
||||
|
||||
/**
|
||||
|
@ -121,7 +121,8 @@ public class MessageWriter extends Writer
|
|||
{
|
||||
flush(true);
|
||||
bufferPool.release(buffer);
|
||||
LOG.debug("Stream closed, {} frames sent", frameCount);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Stream closed, {} frames sent", frameCount);
|
||||
// Notify without holding locks.
|
||||
notifySuccess();
|
||||
}
|
||||
|
@ -143,7 +144,8 @@ public class MessageWriter extends Writer
|
|||
closed = fin;
|
||||
|
||||
ByteBuffer data = utf.getByteBuffer();
|
||||
LOG.debug("flush({}): {}", fin, BufferUtil.toDetailString(buffer));
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("flush({}): {}", fin, BufferUtil.toDetailString(buffer));
|
||||
frame.setPayload(data);
|
||||
frame.setFin(fin);
|
||||
|
||||
|
|
|
@ -18,10 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.common.events;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.jetty.toolchain.test.EventQueue;
|
||||
|
@ -29,6 +25,10 @@ import org.eclipse.jetty.util.log.Log;
|
|||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.junit.Assert;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class EventCapture extends EventQueue<String>
|
||||
{
|
||||
|
@ -67,7 +67,8 @@ public class EventCapture extends EventQueue<String>
|
|||
public void add(String format, Object... args)
|
||||
{
|
||||
String msg = String.format(format,args);
|
||||
LOG.debug("EVENT: {}",msg);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("EVENT: {}",msg);
|
||||
super.offer(msg);
|
||||
}
|
||||
|
||||
|
|
|
@ -82,21 +82,24 @@ public class LocalWebSocketConnection implements LogicalConnection, IncomingFram
|
|||
@Override
|
||||
public void close(int statusCode, String reason)
|
||||
{
|
||||
LOG.debug("close({}, {})",statusCode,reason);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("close({}, {})",statusCode,reason);
|
||||
CloseInfo close = new CloseInfo(statusCode,reason);
|
||||
ioState.onCloseLocal(close);
|
||||
}
|
||||
|
||||
public void connect()
|
||||
{
|
||||
LOG.debug("connect()");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("connect()");
|
||||
ioState.onConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect()
|
||||
{
|
||||
LOG.debug("disconnect()");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("disconnect()");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -179,7 +182,8 @@ public class LocalWebSocketConnection implements LogicalConnection, IncomingFram
|
|||
@Override
|
||||
public void onConnectionStateChange(ConnectionState state)
|
||||
{
|
||||
LOG.debug("Connection State Change: {}",state);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Connection State Change: {}",state);
|
||||
switch (state)
|
||||
{
|
||||
case CLOSED:
|
||||
|
@ -200,7 +204,8 @@ public class LocalWebSocketConnection implements LogicalConnection, IncomingFram
|
|||
|
||||
public void open()
|
||||
{
|
||||
LOG.debug("open()");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("open()");
|
||||
ioState.onOpened();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.common.message;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.jetty.io.MappedByteBufferPool;
|
||||
|
@ -40,6 +38,8 @@ import org.junit.Rule;
|
|||
import org.junit.Test;
|
||||
import org.junit.rules.TestName;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
public class MessageWriterTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(MessageWriterTest.class);
|
||||
|
@ -122,7 +122,8 @@ public class MessageWriterTest
|
|||
{
|
||||
int bufsize = (int)(policy.getMaxTextMessageBufferSize() * 2.5);
|
||||
char buf[] = new char[bufsize];
|
||||
LOG.debug("Buffer size: {}",bufsize);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Buffer size: {}",bufsize);
|
||||
Arrays.fill(buf,'x');
|
||||
buf[bufsize - 1] = 'o'; // mark last entry for debugging
|
||||
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.common.message;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
@ -35,6 +33,8 @@ import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
|
|||
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
|
||||
import org.junit.Assert;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
@WebSocket
|
||||
public class TrackingInputStreamSocket
|
||||
{
|
||||
|
@ -76,7 +76,8 @@ public class TrackingInputStreamSocket
|
|||
@OnWebSocketClose
|
||||
public void onClose(int statusCode, String reason)
|
||||
{
|
||||
LOG.debug("{} onClose({},{})",id,statusCode,reason);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("{} onClose({},{})",id,statusCode,reason);
|
||||
closeCode = statusCode;
|
||||
closeMessage.append(reason);
|
||||
closeLatch.countDown();
|
||||
|
@ -91,7 +92,8 @@ public class TrackingInputStreamSocket
|
|||
@OnWebSocketMessage
|
||||
public void onInputStream(InputStream stream)
|
||||
{
|
||||
LOG.debug("{} onInputStream({})",id,stream);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("{} onInputStream({})",id,stream);
|
||||
try
|
||||
{
|
||||
String msg = IO.toString(stream);
|
||||
|
|
|
@ -512,8 +512,11 @@ public class WebSocketServerFactory extends ContainerLifeCycle implements WebSoc
|
|||
extensionStack.configure(wsConnection.getParser());
|
||||
extensionStack.configure(wsConnection.getGenerator());
|
||||
|
||||
LOG.debug("HttpConnection: {}", http);
|
||||
LOG.debug("WebSocketConnection: {}", wsConnection);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("HttpConnection: {}", http);
|
||||
LOG.debug("WebSocketConnection: {}", wsConnection);
|
||||
}
|
||||
|
||||
// Setup Session
|
||||
WebSocketSession session = createSession(request.getRequestURI(), driver, wsConnection);
|
||||
|
@ -553,11 +556,15 @@ public class WebSocketServerFactory extends ContainerLifeCycle implements WebSoc
|
|||
// Tell jetty about the new upgraded connection
|
||||
request.setServletAttribute(HttpConnection.UPGRADE_CONNECTION_ATTRIBUTE, wsConnection);
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Handshake Response: {}", handshaker);
|
||||
|
||||
// Process (version specific) handshake response
|
||||
LOG.debug("Handshake Response: {}", handshaker);
|
||||
handshaker.doHandshakeResponse(request, response);
|
||||
|
||||
LOG.debug("Websocket upgrade {} {} {} {}", request.getRequestURI(), version, response.getAcceptedSubProtocol(), wsConnection);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Websocket upgrade {} {} {} {}", request.getRequestURI(), version, response.getAcceptedSubProtocol(), wsConnection);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.websocket.server;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
|
@ -66,7 +65,9 @@ public class WebSocketUpgradeFilter extends ContainerLifeCycle implements Filter
|
|||
fholder.setDisplayName("WebSocket Upgrade Filter");
|
||||
String pathSpec = "/*";
|
||||
context.addFilter(fholder,pathSpec,EnumSet.of(DispatcherType.REQUEST));
|
||||
LOG.debug("Adding {} mapped to {} to {}",filter,pathSpec,context);
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Adding {} mapped to {} to {}",filter,pathSpec,context);
|
||||
|
||||
// Store reference to the WebSocketUpgradeFilter
|
||||
context.setAttribute(WebSocketUpgradeFilter.class.getName(),filter);
|
||||
|
|
|
@ -177,7 +177,8 @@ public class PathMappings<E> implements Iterable<MappedResource<E>>, Dumpable
|
|||
}
|
||||
// TODO: warning on replacement of existing mapping?
|
||||
mappings.add(entry);
|
||||
LOG.debug("Added {} to {}",entry,this);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Added {} to {}",entry,this);
|
||||
Collections.sort(mappings);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue