本文整理汇总了Java中org.eclipse.jetty.http.MimeTypes.addMimeMapping方法的典型用法代码示例。如果您正苦于以下问题:Java MimeTypes.addMimeMapping方法的具体用法?Java MimeTypes.addMimeMapping怎么用?Java MimeTypes.addMimeMapping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.http.MimeTypes
的用法示例。
在下文中一共展示了MimeTypes.addMimeMapping方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMimeTypeConfiguration
import org.eclipse.jetty.http.MimeTypes; //导入方法依赖的package包/类
/**
* Create a configuration object that adds mime type mappings.
* @return a configuration object for adding mime type mappings
*/
private Configuration getMimeTypeConfiguration() {
return new AbstractConfiguration() {
@Override
public void configure(WebAppContext context) throws Exception {
MimeTypes mimeTypes = context.getMimeTypes();
for (MimeMappings.Mapping mapping : getMimeMappings()) {
mimeTypes.addMimeMapping(mapping.getExtension(),
mapping.getMimeType());
}
}
};
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:JettyEmbeddedServletContainerFactory.java
示例2: getMimeTypeConfiguration
import org.eclipse.jetty.http.MimeTypes; //导入方法依赖的package包/类
/**
* Create a configuration object that adds mime type mappings.
* @return a configuration object for adding mime type mappings
*/
private Configuration getMimeTypeConfiguration() {
return new AbstractConfiguration() {
@Override
public void configure(WebAppContext context) throws Exception {
MimeTypes mimeTypes = context.getMimeTypes();
for (MimeMappings.Mapping mapping : getMimeMappings()) {
mimeTypes.addMimeMapping(mapping.getExtension(),
mapping.getMimeType());
}
}
};
}
示例3: startTransformServer
import org.eclipse.jetty.http.MimeTypes; //导入方法依赖的package包/类
private int startTransformServer() throws Exception {
URL transforms = EngineTest.class.getClassLoader().getResource(
"transforms");
if (transforms == null) {
Assert.fail();
}
int port = findFreePort();
Server fileServer = new Server(port);
ResourceHandler handler = new ResourceHandler();
MimeTypes mimeTypes = handler.getMimeTypes();
mimeTypes.addMimeMapping("json", "application/json; charset=UTF-8");
handler.setDirectoriesListed(true);
handler.setBaseResource(JarResource.newResource(transforms));
HandlerList handlers = new HandlerList();
handlers.addHandler(handler);
handlers.addHandler(new DefaultHandler());
fileServer.setHandler(handlers);
fileServer.start();
return port;
}
示例4: startJetty
import org.eclipse.jetty.http.MimeTypes; //导入方法依赖的package包/类
@BeforeClass
public void startJetty() throws Exception {
Server server = new Server(0);
ResourceHandler resourceHandler = new ResourceHandler();
MimeTypes mimeTypes = new MimeTypes();
mimeTypes.addMimeMapping("json", "application/json");
resourceHandler.setMimeTypes(mimeTypes);
URL url = this.getClass().getResource(".");
resourceHandler.setBaseResource(new FileResource(url));
resourceHandler.setWelcomeFiles(new String[] {"changes.json", "projects.json", "account.json"});
ServletContextHandler servletContextHandler = new ServletContextHandler();
servletContextHandler.addServlet(LoginSimulationServlet.class, "/login/");
ServletContextHandler basicAuthContextHandler = new ServletContextHandler(ServletContextHandler.SECURITY);
basicAuthContextHandler.setSecurityHandler(basicAuth("foo", "bar", "Gerrit Auth"));
basicAuthContextHandler.setContextPath("/a");
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] {
servletContextHandler,
resourceHandler,
basicAuthContextHandler
});
server.setHandler(handlers);
server.start();
Connector connector = server.getConnectors()[0];
String host = "localhost";
int port = connector.getLocalPort();
jettyUrl = String.format("http://%s:%s", host, port);
}
示例5: start
import org.eclipse.jetty.http.MimeTypes; //导入方法依赖的package包/类
@Override
public void start(FolderContext music, MountContext mount, int port, String user, String password) throws Exception {
ServletContextHandler mountContext = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
mountContext.setContextPath(mount.getPath());
mountContext.setSecurityHandler(user == null ? null : basicAuthentication("MusicMount", user, password));
ServletHolder mountServlet = new ServletHolder(mount.getServlet());
mountContext.addServlet(mountServlet, "/*");
ServletContextHandler musicContext = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
musicContext.setContextPath(music.getPath());
musicContext.setSecurityHandler(user == null ? null : basicAuthentication("MusicMount", user, password));
musicContext.setBaseResource(Resource.newResource(music.getFolder()));
MimeTypes musicTypes = new MimeTypes();
musicTypes.addMimeMapping("m4a", "audio/mp4");
musicTypes.addMimeMapping("mp3", "audio/mpeg");
musicContext.setMimeTypes(musicTypes);
ServletHolder musicServlet = new ServletHolder(new DefaultServlet());
musicServlet.setInitParameter("dirAllowed", "false");
musicContext.addServlet(musicServlet, "/*");
GzipHandler gzipMountContext = new GzipHandler();
gzipMountContext.setMimeTypes(MimeTypes.TEXT_JSON);
gzipMountContext.setHandler(mountContext);
ContextHandlerCollection contexHandlers = new ContextHandlerCollection();
contexHandlers.setHandlers(new Handler[] { gzipMountContext, musicContext });
RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLogHandler.setRequestLog(new ConsoleRequestLog());
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[]{ contexHandlers, new DefaultHandler(), requestLogHandler });
server = new Server(port);
server.setHandler(handlers);
server.setGracefulShutdown(1000);
server.setStopAtShutdown(true);
server.start();
}
示例6: main
import org.eclipse.jetty.http.MimeTypes; //导入方法依赖的package包/类
/**
*
* Test server for the addon.
*
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
Server server = new Server();
final ServerConnector connector = new ServerConnector(server);
connector.setPort(7777);
server.setConnectors(new Connector[] { connector });
WebAppContext context = new WebAppContext();
ServletHolder servletHolder = new ServletHolder(TouchKitServlet.class);
servletHolder.setInitParameter("UI", TouchkitTestUI.class.getName());
servletHolder.setInitParameter("widgetset",
"org.vaadin.touchkit.gwt.TouchKitWidgetSet");
// check for production mode argument
for (String arg : args) {
if ("productionMode".equalsIgnoreCase(arg)) {
servletHolder.setInitParameter("productionMode", "true");
}
}
MimeTypes mimeTypes = context.getMimeTypes();
mimeTypes.addMimeMapping("appcache", "text/cache-manifest");
mimeTypes.addMimeMapping("manifest", "text/cache-manifest");
context.setMimeTypes(mimeTypes);
// // test fallback app and widgetset
// servletHolder.setInitParameter("fallbackApplication",
// FallbackApplication.class.getName());
// servletHolder.setInitParameter("fallbackWidgetset",
// Constants.DEFAULT_WIDGETSET);
File file = new File("./target/classes");
if (!file.isDirectory() || !new File(file, "VAADIN").isDirectory()) {
System.err.println(
"Oops: " + file + "/VAADIN does not seem to exist!");
System.err.println("Did you remember to mvn vaadin:compile?");
return;
}
context.setWar(file.getPath());
context.setContextPath("/");
context.addServlet(servletHolder, "/*");
servletHolder = new ServletHolder(RemoteLogger.class);
context.addServlet(servletHolder, "/remotelog");
server.setHandler(context);
server.start();
server.join();
}