mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-02 20:09:21 +00:00
Merge remote-tracking branch 'origin/jetty-9.4.x'
This commit is contained in:
commit
5e04d8160b
@ -28,6 +28,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jetty.deploy.bindings.StandardDeployer;
|
||||
import org.eclipse.jetty.deploy.bindings.StandardStarter;
|
||||
@ -311,7 +312,7 @@ public class DeploymentManager extends ContainerLifeCycle
|
||||
*/
|
||||
public Collection<App> getApps(Node node)
|
||||
{
|
||||
List<App> ret = new ArrayList<App>();
|
||||
List<App> ret = new ArrayList<>();
|
||||
for (AppEntry entry : _apps)
|
||||
{
|
||||
if (entry.lifecyleNode == node)
|
||||
@ -592,13 +593,40 @@ public class DeploymentManager extends ContainerLifeCycle
|
||||
{
|
||||
return _lifecycle.getNodes();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ManagedOperation(value="list nodes that are tracked by DeploymentManager", impact="INFO")
|
||||
public Collection<String> getNodeNames()
|
||||
{
|
||||
return _lifecycle.getNodes().stream().map(Node::getName).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@ManagedOperation(value="list apps that are located at specified App LifeCycle nodes", impact="ACTION")
|
||||
public Collection<App> getApps(@Name("nodeName") String nodeName)
|
||||
{
|
||||
return getApps(_lifecycle.getNodeByName(nodeName));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ManagedOperation(value="list apps that are located at specified App LifeCycle nodes", impact="ACTION")
|
||||
public Collection<String> getAppNames(@Name("nodeName") String nodeName)
|
||||
{
|
||||
Node node = _lifecycle.getNodeByName(nodeName);
|
||||
if(node == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Unable to find node [" + nodeName + "]");
|
||||
}
|
||||
|
||||
List<String> ret = new ArrayList<>();
|
||||
for (AppEntry entry : _apps)
|
||||
{
|
||||
if (entry.lifecyleNode == node)
|
||||
{
|
||||
ret.add(String.format("contextPath=%s,originId=%s,appProvider=%s", entry.app.getContextPath(), entry.app.getOriginId(), entry.app.getAppProvider().getClass().getName()));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void scope(XmlConfiguration xmlc, Resource webapp)
|
||||
throws IOException
|
||||
{
|
||||
|
@ -40,13 +40,13 @@ public class TestHelloServlet
|
||||
|
||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
System.out.println( "httpResponse hello annotation servlet:" + response );
|
||||
|
||||
Assert.assertEquals( "hello beer", response.trim() );
|
||||
|
||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
System.out.println( "httpResponse ping fragment servlet:" + response );
|
||||
|
||||
Assert.assertEquals( "pong beer", response.trim() );
|
||||
}
|
||||
|
@ -21,6 +21,11 @@
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
|
@ -41,13 +41,13 @@ public class TestHelloServlet
|
||||
|
||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
System.out.println( "httpResponse hello annotation servlet:" + response );
|
||||
|
||||
Assert.assertEquals( "hello beer", response.trim() );
|
||||
|
||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
System.out.println( "httpResponse ping fragment servlet:" + response );
|
||||
|
||||
Assert.assertEquals( "pong beer", response.trim() );
|
||||
}
|
||||
|
@ -46,6 +46,12 @@
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
|
@ -151,7 +151,7 @@ public class JettyEffectiveWebXml extends JettyRunMojo
|
||||
//just show the result in the log
|
||||
getLog().info(IO.toString(webApp.getQuickStartWebDescriptor().getInputStream()));
|
||||
}
|
||||
catch (IOException e)
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new MojoExecutionException("Unable to output effective web.xml", e);
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
||||
//leave everything unpacked for the forked process to use
|
||||
webApp.setPersistTempDirectory(true);
|
||||
|
||||
webApp.start(); //just enough to generate the quickstart
|
||||
webApp.start(); //just enough to generate the quickstart
|
||||
|
||||
//save config of the webapp BEFORE we stop
|
||||
File props = prepareConfiguration();
|
||||
@ -424,7 +424,6 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
||||
{
|
||||
if (forkedProcess != null && waitForChild)
|
||||
forkedProcess.destroy();
|
||||
|
||||
throw new MojoExecutionException("Failed to create Jetty process", ex);
|
||||
}
|
||||
}
|
||||
@ -458,7 +457,7 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
||||
public File prepareConfiguration() throws MojoExecutionException
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
//work out the configuration based on what is configured in the pom
|
||||
File propsFile = new File (target, "fork.props");
|
||||
if (propsFile.exists())
|
||||
@ -468,8 +467,6 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
||||
//propsFile.deleteOnExit();
|
||||
|
||||
Properties props = new Properties();
|
||||
|
||||
|
||||
//web.xml
|
||||
if (webApp.getDescriptor() != null)
|
||||
{
|
||||
@ -484,7 +481,7 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
||||
//sort out the context path
|
||||
if (webApp.getContextPath() != null)
|
||||
{
|
||||
props.put("context.path", webApp.getContextPath());
|
||||
props.put("context.path", webApp.getContextPath());
|
||||
}
|
||||
|
||||
//tmp dir
|
||||
@ -504,7 +501,6 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
||||
props.put("base.dirs", toCSV(((ResourceCollection)postOverlayResources).getResources()));
|
||||
else
|
||||
props.put("base.dirs", postOverlayResources.toString());
|
||||
|
||||
|
||||
//web-inf classes
|
||||
if (webApp.getClasses() != null)
|
||||
|
@ -21,6 +21,7 @@ package org.eclipse.jetty.maven.plugin;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -281,14 +282,13 @@ public class JettyRunMojo extends AbstractJettyMojo
|
||||
if (useTestScope && (testClassesDirectory != null))
|
||||
webApp.setTestClasses (testClassesDirectory);
|
||||
|
||||
webApp.getClassPathFiles().addAll( getDependencyProjects() );
|
||||
webApp.setWebInfLib (getDependencyFiles());
|
||||
webApp.setWebInfLib(getDependencyFiles());
|
||||
|
||||
//get copy of a list of war artifacts
|
||||
Set<Artifact> matchedWarArtifacts = new HashSet<Artifact>();
|
||||
|
||||
//process any overlays and the war type artifacts
|
||||
List<Overlay> overlays = new ArrayList<Overlay>();
|
||||
List<Overlay> overlays = new ArrayList<>();
|
||||
for (OverlayConfig config:warPluginInfo.getMavenWarOverlayConfigs())
|
||||
{
|
||||
//overlays can be individually skipped
|
||||
@ -584,8 +584,12 @@ public class JettyRunMojo extends AbstractJettyMojo
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (getProjectReferences( artifact, project )!=null)
|
||||
MavenProject mavenProject = getProjectReferences( artifact, project );
|
||||
if (mavenProject != null)
|
||||
{
|
||||
File projectPath = Paths.get(mavenProject.getBuild().getOutputDirectory()).toFile();
|
||||
getLog().debug( "Adding project directory " + projectPath.toString() );
|
||||
dependencyFiles.add( projectPath );
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -602,38 +606,6 @@ public class JettyRunMojo extends AbstractJettyMojo
|
||||
return dependencyFiles;
|
||||
}
|
||||
|
||||
private List<File> getDependencyProjects()
|
||||
{
|
||||
List<File> dependencyFiles = new ArrayList<>();
|
||||
for ( Iterator<Artifact> iter = projectArtifacts.iterator(); iter.hasNext(); )
|
||||
{
|
||||
Artifact artifact = iter.next();
|
||||
|
||||
// Include runtime and compile time libraries, and possibly test libs too
|
||||
if(artifact.getType().equals("war"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()))
|
||||
continue; //never add dependencies of scope=provided to the webapp's classpath (see also <useProvidedScope> param)
|
||||
|
||||
if (Artifact.SCOPE_TEST.equals(artifact.getScope()) && !useTestScope)
|
||||
continue; //only add dependencies of scope=test if explicitly required
|
||||
|
||||
MavenProject mavenProject = getProjectReferences( artifact, project );
|
||||
if (mavenProject != null)
|
||||
{
|
||||
dependencyFiles.add( Paths.get(mavenProject.getBuild().getOutputDirectory()).toFile() );
|
||||
getLog().debug( "Adding project reference " + mavenProject.getBuild().getOutputDirectory()
|
||||
+ " for WEB-INF/classes " );
|
||||
}
|
||||
}
|
||||
|
||||
return dependencyFiles;
|
||||
}
|
||||
|
||||
|
||||
protected MavenProject getProjectReferences( Artifact artifact, MavenProject project )
|
||||
{
|
||||
if ( project.getProjectReferences() == null || project.getProjectReferences().isEmpty() )
|
||||
|
@ -266,8 +266,15 @@ public class JettyWebAppContext extends WebAppContext
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public Resource getQuickStartWebDescriptor ()
|
||||
throws Exception
|
||||
{
|
||||
return (Resource)getAttribute(QuickStartConfiguration.QUICKSTART_WEB_XML);
|
||||
Object o = getAttribute(QuickStartConfiguration.QUICKSTART_WEB_XML);
|
||||
if (o == null)
|
||||
return null;
|
||||
else if (o instanceof Resource)
|
||||
return (Resource)o;
|
||||
else
|
||||
return Resource.newResource((String)o);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -295,6 +302,12 @@ public class JettyWebAppContext extends WebAppContext
|
||||
return _webInfJars;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public List<File> getWebInfClasses()
|
||||
{
|
||||
return _webInfClasses;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void setGenerateQuickStart (boolean quickStart)
|
||||
{
|
||||
@ -306,7 +319,7 @@ public class JettyWebAppContext extends WebAppContext
|
||||
{
|
||||
return _isGenerateQuickStart;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -385,6 +398,8 @@ public class JettyWebAppContext extends WebAppContext
|
||||
{
|
||||
if (c instanceof EnvConfiguration && getJettyEnvXml() != null)
|
||||
((EnvConfiguration)c).setJettyEnvXml(Resource.toURL(new File(getJettyEnvXml())));
|
||||
else if (c instanceof MavenQuickStartConfiguration && getQuickStartWebDescriptor() != null)
|
||||
((MavenQuickStartConfiguration)c).setQuickStartWebXml(getQuickStartWebDescriptor());
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
|
@ -61,62 +61,64 @@ public class MavenMetaInfConfiguration extends MetaInfConfiguration
|
||||
protected List<Resource> findJars (WebAppContext context)
|
||||
throws Exception
|
||||
{
|
||||
List<Resource> list = new ArrayList<Resource>();
|
||||
List<Resource> list = new ArrayList<>();
|
||||
JettyWebAppContext jwac = (JettyWebAppContext)context;
|
||||
if (jwac.getClassPathFiles() != null)
|
||||
List<File> files = jwac.getWebInfLib();
|
||||
if (files != null)
|
||||
{
|
||||
for (File f: jwac.getClassPathFiles())
|
||||
{
|
||||
if (f.getName().toLowerCase(Locale.ENGLISH).endsWith(".jar"))
|
||||
files.forEach( file -> {
|
||||
if (file.getName().toLowerCase(Locale.ENGLISH).endsWith(".jar")
|
||||
|| file.isDirectory())
|
||||
{
|
||||
try
|
||||
{
|
||||
list.add(Resource.newResource(f.toURI()));
|
||||
LOG.debug( " add resource to resources to examine {}", file );
|
||||
list.add(Resource.newResource(file.toURI()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.warn("Bad url ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
List<Resource> superList = super.findJars(context);
|
||||
if (superList != null)
|
||||
list.addAll(superList);
|
||||
return list;
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add in the classes dirs from test/classes and target/classes
|
||||
* @see org.eclipse.jetty.webapp.MetaInfConfiguration#findClassDirs(org.eclipse.jetty.webapp.WebAppContext)
|
||||
*/
|
||||
@Override
|
||||
protected List<Resource> findClassDirs(WebAppContext context) throws Exception
|
||||
{
|
||||
List<Resource> list = new ArrayList<Resource>();
|
||||
{
|
||||
List<Resource> list = new ArrayList<>();
|
||||
|
||||
JettyWebAppContext jwac = (JettyWebAppContext)context;
|
||||
if (jwac.getClassPathFiles() != null)
|
||||
List<File> files = jwac.getWebInfClasses();
|
||||
if (files != null)
|
||||
{
|
||||
for (File f: jwac.getClassPathFiles())
|
||||
{
|
||||
if (f.exists() && f.isDirectory())
|
||||
files.forEach( file -> {
|
||||
if (file.exists() && file.isDirectory())
|
||||
{
|
||||
try
|
||||
{
|
||||
list.add(Resource.newResource(f.toURI()));
|
||||
list.add(Resource.newResource(file.toURI()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.warn("Bad url ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
List<Resource> classesDirs = super.findClassDirs(context);
|
||||
|
@ -39,6 +39,23 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
||||
public class MavenQuickStartConfiguration extends QuickStartConfiguration
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(QuickStartConfiguration.class);
|
||||
|
||||
private Resource _quickStartWebXml; //the descriptor to use for starting/generating quickstart
|
||||
|
||||
public void setQuickStartWebXml(Resource quickStartWebXml)
|
||||
{
|
||||
_quickStartWebXml = quickStartWebXml;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Resource getQuickStartWebXml(WebAppContext context) throws Exception
|
||||
{
|
||||
if (_quickStartWebXml == null)
|
||||
return super.getQuickStartWebXml(context);
|
||||
|
||||
return _quickStartWebXml;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preConfigure(WebAppContext context) throws Exception
|
||||
|
@ -84,10 +84,6 @@ public class MavenWebInfConfiguration extends WebInfConfiguration
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -165,6 +161,7 @@ public class MavenWebInfConfiguration extends WebInfConfiguration
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected Resource unpackOverlay (WebAppContext context, Overlay overlay)
|
||||
throws IOException
|
||||
{
|
||||
|
@ -163,7 +163,7 @@ public class RuleContainer extends Rule
|
||||
|
||||
if (_rules==null)
|
||||
return target;
|
||||
|
||||
|
||||
for (Rule rule : _rules)
|
||||
{
|
||||
String applied=rule.matchAndApply(target,request, response);
|
||||
@ -179,26 +179,29 @@ public class RuleContainer extends Rule
|
||||
String query = request.getQueryString();
|
||||
if (query != null)
|
||||
request.setAttribute(_originalQueryStringAttribute,query);
|
||||
}
|
||||
}
|
||||
|
||||
// Ugly hack, we should just pass baseRequest into the API from RewriteHandler itself.
|
||||
Request baseRequest = Request.getBaseRequest(request);
|
||||
|
||||
if (_rewriteRequestURI)
|
||||
{
|
||||
String encoded=URIUtil.encodePath(applied);
|
||||
if (rule instanceof Rule.ApplyURI)
|
||||
((Rule.ApplyURI)rule).applyURI((Request)request,((Request)request).getRequestURI(), encoded);
|
||||
((Rule.ApplyURI)rule).applyURI(baseRequest, baseRequest.getRequestURI(), encoded);
|
||||
else
|
||||
((Request)request).setURIPathQuery(encoded);
|
||||
baseRequest.setURIPathQuery(encoded);
|
||||
}
|
||||
|
||||
if (_rewritePathInfo)
|
||||
((Request)request).setPathInfo(applied);
|
||||
baseRequest.setPathInfo(applied);
|
||||
|
||||
target=applied;
|
||||
|
||||
if (rule.isHandling())
|
||||
{
|
||||
LOG.debug("handling {}",rule);
|
||||
Request.getBaseRequest(request).setHandled(true);
|
||||
baseRequest.setHandled(true);
|
||||
}
|
||||
|
||||
if (rule.isTerminating())
|
||||
|
Loading…
x
Reference in New Issue
Block a user