use of org.eclipse.jetty.servlet.ServletMapping in project processdash by dtuma.
the class WebAppContextDashboard method initializeTinyCgiSupport.
private void initializeTinyCgiSupport() {
List<String> linkFiles = listFilesWithSuffixes(true, TinyCGIHandlerServlet.LINK_SUFFIX);
if (linkFiles.isEmpty())
return;
// strip the ".link" suffix off each filename to produce a URI
for (int i = linkFiles.size(); i-- > 0; ) {
String oneLink = linkFiles.get(i);
String oneUri = oneLink.substring(0, oneLink.length() - TinyCGIHandlerServlet.LINK_SUFFIX.length());
linkFiles.set(i, oneUri);
}
// register a servlet to handle those URIs
ServletHolder holder = new ServletHolder(new TinyCGIHandlerServlet());
getServletHandler().addServlet(holder);
ServletMapping map = new ServletMapping();
map.setServletName(holder.getName());
map.setPathSpecs(linkFiles.toArray(new String[linkFiles.size()]));
try {
PathMap.setPathSpecSeparators("!");
getServletHandler().addServletMapping(map);
} finally {
PathMap.setPathSpecSeparators(":,");
}
}
use of org.eclipse.jetty.servlet.ServletMapping in project oozie by apache.
the class ServletMapper method mapOozieServlets.
/**
* Maps Oozie servlets to path specs. Make sure it is in sync with FilterMapper when making changes.
*/
void mapOozieServlets() {
mapServlet(VersionServlet.class, "/versions");
mapServlet(V0AdminServlet.class, "/v0/admin/*");
mapServlet(V1AdminServlet.class, "/v1/admin/*");
mapServlet(V2AdminServlet.class, "/v2/admin/*");
mapServlet(CallbackServlet.class, "/callback/*");
ServletHandler servletHandler = servletContextHandler.getServletHandler();
String v0JobsServletName = V0JobsServlet.class.getSimpleName();
servletHandler.addServlet(new ServletHolder(v0JobsServletName, new V0JobsServlet()));
ServletMapping jobServletMappingV0 = new ServletMapping();
jobServletMappingV0.setPathSpec("/v0/jobs");
jobServletMappingV0.setServletName(v0JobsServletName);
String v1JobsServletName = V1JobsServlet.class.getSimpleName();
servletHandler.addServlet(new ServletHolder(v1JobsServletName, new V1JobsServlet()));
ServletMapping jobServletMappingV1 = new ServletMapping();
jobServletMappingV1.setPathSpec("/v1/jobs");
jobServletMappingV1.setServletName(v1JobsServletName);
// v1 and v2 version for the jobs API are same.
ServletMapping jobServletMappingV2 = new ServletMapping();
jobServletMappingV2.setPathSpec("/v2/jobs");
jobServletMappingV2.setServletName(v1JobsServletName);
servletHandler.addServletMapping(jobServletMappingV0);
servletHandler.addServletMapping(jobServletMappingV1);
servletHandler.addServletMapping(jobServletMappingV2);
mapServlet(V0JobServlet.class, "/v0/job/*");
mapServlet(V1JobServlet.class, "/v1/job/*");
mapServlet(V2JobServlet.class, "/v2/job/*");
mapServlet(SLAServlet.class, "/v1/sla/*");
mapServlet(V2SLAServlet.class, "/v2/sla/*");
mapServlet(V2ValidateServlet.class, "/v2/validate/*");
mapServlet(ErrorServlet.class, "/error/*");
}
use of org.eclipse.jetty.servlet.ServletMapping in project spring-boot by spring-projects.
the class JettyServletWebServerFactory method addJspServlet.
/**
* Add Jetty's {@code JspServlet} to the given {@link WebAppContext}.
* @param context the jetty {@link WebAppContext}
*/
protected final void addJspServlet(WebAppContext context) {
Assert.notNull(context, "Context must not be null");
ServletHolder holder = new ServletHolder();
holder.setName("jsp");
holder.setClassName(getJsp().getClassName());
holder.setInitParameter("fork", "false");
holder.setInitParameters(getJsp().getInitParameters());
holder.setInitOrder(3);
context.getServletHandler().addServlet(holder);
ServletMapping mapping = new ServletMapping();
mapping.setServletName("jsp");
mapping.setPathSpecs(new String[] { "*.jsp", "*.jspx" });
context.getServletHandler().addServletMapping(mapping);
}
use of org.eclipse.jetty.servlet.ServletMapping in project goodies by sonatype.
the class JettyServerProvider method addServlet.
public void addServlet(String pathSpec, ServletHolder servletHolder) {
if (webappContext == null) {
try {
initServer();
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
// Jetty 9.2 is sensitive to overlapping mappings, so remove it pathSpec already exists
if (webappContext.getServletHandler().getServletMapping(pathSpec) != null) {
final ServletMapping[] servletMappings = webappContext.getServletHandler().getServletMappings();
final String oldServletName = webappContext.getServletHandler().getServletMapping(pathSpec).getServletName();
ServletMapping oldServletMapping = null;
for (ServletMapping servletMapping : servletMappings) {
if (servletMapping.getServletName().equals(oldServletName)) {
oldServletMapping = servletMapping;
break;
}
}
final ServletMapping[] servletMappingsOldRemoved = ArrayUtil.removeFromArray(servletMappings, oldServletMapping);
webappContext.getServletHandler().setServletMappings(servletMappingsOldRemoved);
}
webappContext.getServletHandler().addServletWithMapping(servletHolder, pathSpec);
}
use of org.eclipse.jetty.servlet.ServletMapping in project keycloak by keycloak.
the class JettyAppServer method deploy.
@Override
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
log.info("Deploying archive " + archive.getName());
if (!(archive instanceof WebArchive)) {
throw new IllegalArgumentException("JettyContainer only supports WebArchives.");
}
WebArchive webArchive = (WebArchive) archive;
try {
KeycloakAdapterApp app = appProvider.createApp(webArchive);
WebAppContext webAppContext = (WebAppContext) app.getContextHandler();
addAdditionalConfigurations(webAppContext);
setContextRoot(webArchive, app, webAppContext);
if (app.usesOIDCAuthenticator()) {
addOIDCAuthenticator(webAppContext);
}
if (app.usesSAMLAuthenticator()) {
addSAMLAuthenticator(webAppContext);
}
if (app.usesJaxrs()) {
addRestEasyServlet(webArchive, webAppContext);
}
setEmbeddedClassloaderForDeployment(webAppContext);
deployer.addApp(app);
deployer.requestAppGoal(app, AppLifeCycle.STARTED);
deployedApps.put(archive.getId(), app);
HTTPContext httpContext = new HTTPContext(configuration.getBindAddress(), configuration.getBindHttpPort());
ServletHandler servletHandler = webAppContext.getServletHandler();
for (ServletHolder servlet : servletHandler.getServlets()) {
log.debugf("Servlet context mapping: %s => %s", servlet.getName(), servlet.getContextPath());
httpContext.add(new Servlet(servlet.getName(), servlet.getContextPath()));
}
if (log.isInfoEnabled()) {
for (ServletMapping mapping : server.getChildHandlerByClass(ServletHandler.class).getServletMappings()) {
log.debugf("Servlet mapping: %s => %s", mapping.getServletName(), Arrays.toString(mapping.getPathSpecs()));
}
}
return new ProtocolMetaData().addContext(httpContext);
} catch (Exception e) {
throw new DeploymentException("Unable to deploy archive", e);
}
}
Aggregations