当前位置: 首页>>代码示例>>Java>>正文


Java MimeTypes.addMimeMapping方法代码示例

本文整理汇总了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());
			}
		}
	};
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:17,代码来源:JettyEmbeddedServletContainerFactory.java

示例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;
}
 
开发者ID:fusepoolP3,项目名称:p3-batchrefine,代码行数:28,代码来源:TestSupport.java

示例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);
}
 
开发者ID:uwolfer,项目名称:gerrit-rest-java-client,代码行数:35,代码来源:GerritRestClientTest.java

示例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();
}
 
开发者ID:beckchr,项目名称:musicmount,代码行数:40,代码来源:MusicMountServerJetty.java

示例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();

}
 
开发者ID:vaadin,项目名称:touchkit,代码行数:60,代码来源:TestServer.java


注:本文中的org.eclipse.jetty.http.MimeTypes.addMimeMapping方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。