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


Java ClassList类代码示例

本文整理汇总了Java中org.eclipse.jetty.webapp.Configuration.ClassList的典型用法代码示例。如果您正苦于以下问题:Java ClassList类的具体用法?Java ClassList怎么用?Java ClassList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ClassList类属于org.eclipse.jetty.webapp.Configuration包,在下文中一共展示了ClassList类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.eclipse.jetty.webapp.Configuration.ClassList; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();
    Server server = new Server(9090);
    ClassList classlist = Configuration.ClassList.setServerDefault(server);
    classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration");
    WebAppContext webapp = new WebAppContext();
    webapp.setParentLoaderPriority(true);
    webapp.setConfigurationDiscovered(true);
    webapp.setContextPath("/");
    webapp.setResourceBase("src/main/webapp");
    webapp.setWar("src/main/webapp");       
    ServletHolder servletHolder = webapp.addServlet(DemoUIServlet.class, "/*");
    servletHolder.setAsyncSupported(true);
    servletHolder.setInitParameter("org.atmosphere.cpr.asyncSupport", JSR356AsyncSupport.class.getName());
    server.setHandler(webapp);
    ServerContainer webSocketServer = WebSocketServerContainerInitializer.configureContext(webapp);
    webSocketServer.setDefaultMaxSessionIdleTimeout(10000000);        
    server.start();
    log.info("Browse http://localhost:9090 to see the demo");
    server.join();
}
 
开发者ID:JumpMind,项目名称:sqlexplorer-vaadin,代码行数:23,代码来源:DemoUI.java

示例2: main

import org.eclipse.jetty.webapp.Configuration.ClassList; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    
    System.out.println(IOUtils.toString(new FileInputStream("../metl-server/src/main/resources/Metl.asciiart")));

    new File(System.getProperty("java.io.tmpdir")).mkdirs();
    new File("working").mkdirs();
    System.setProperty("org.jumpmind.metl.ui.init.config.dir","working");
    
    Server server = new Server(42000);
    ClassList classlist = Configuration.ClassList.setServerDefault(server);
    classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration");

    WebAppContext webapp = new WebAppContext();
    webapp.setParentLoaderPriority(true);
    webapp.setConfigurationDiscovered(true);
    webapp.setContextPath("/metl");
    webapp.setWar("../metl-war/src/main/webapp");
    webapp.setResourceBase("../metl-war/src/main/webapp");

    ConcurrentHashMap<String, ConcurrentHashSet<String>> map = new ClassInheritanceMap();
    ConcurrentHashSet<String> set = new ConcurrentHashSet<>();
    set.add("org.jumpmind.metl.ui.init.AppInitializer");
    map.put("org.springframework.web.WebApplicationInitializer", set);
    webapp.setAttribute(AnnotationConfiguration.CLASS_INHERITANCE_MAP, map);

    server.setHandler(webapp);
    
    ServerContainer webSocketServer = WebSocketServerContainerInitializer.configureContext(webapp);
    webSocketServer.setDefaultMaxSessionIdleTimeout(10000000);        
    
    server.start();
    server.join();

}
 
开发者ID:JumpMind,项目名称:metl,代码行数:35,代码来源:Develop.java

示例3: main

import org.eclipse.jetty.webapp.Configuration.ClassList; //导入依赖的package包/类
/**
 * Launcher and program main method.
 * 
 * @param args program arguments
 * @throws Exception thrown by Jetty
 */
public static void main(final String[] args) throws Exception {

	LOG.entry((Object[]) args);

	// Jetty server
	final Server server = new Server();

	// Add Jetty Web XML and annotation configuration
	final ClassList classList = ClassList.setServerDefault(server);
	classList.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$

	// Add a connector to open a port
	try (final NetworkTrafficServerConnector connector = new NetworkTrafficServerConnector(server)) {

		connector.setPort(8080);
		server.addConnector(connector);

		// Get the current class URL to add the current packaged war
		final ProtectionDomain mainDomain = Main.class.getProtectionDomain();
		final URL location = mainDomain.getCodeSource().getLocation();

		// Add the war location to the context, the default context path is /
		final WebAppContext webAppContext = new WebAppContext();
		webAppContext.setWar(location.toExternalForm());
		server.setHandler(webAppContext);

		// Start the Jetty server
		server.start();
		server.join();
	}

	LOG.exit();
}
 
开发者ID:Sylvain-Bugat,项目名称:standalone-jetty-war-skeleton,代码行数:40,代码来源:Main.java

示例4: runWebServer

import org.eclipse.jetty.webapp.Configuration.ClassList; //导入依赖的package包/类
public static void runWebServer(String[] args) throws Exception {
    disableJettyLogging();

    new File(System.getProperty("java.io.tmpdir")).mkdirs();

    System.out.println(IOUtils.toString(StartWebServer.class.getResource("/Metl.asciiart")));

    Server server = new Server();
    Connector[] connectors = getConnectors(args, server); 
    server.setConnectors(connectors);

    ClassList classlist = Configuration.ClassList.setServerDefault(server);
    classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration");

    MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
    server.addBean(mbContainer);

    ProtectionDomain protectionDomain = StartWebServer.class.getProtectionDomain();
    URL location = protectionDomain.getCodeSource().getLocation();

    String allowDirListing = System.getProperty(SERVER_ALLOW_DIR_LISTING, "false");
    String allowedMethods = System.getProperty(SERVER_ALLOW_HTTP_METHODS, "");
    String disallowedMethods = System.getProperty(SERVER_DISALLOW_HTTP_METHODS, "OPTIONS");

    WebAppContext webapp = new WebAppContext();
    webapp.setContextPath("/metl");
    webapp.setWar(location.toExternalForm());
    webapp.addAliasCheck(new AllowSymLinkAliasChecker());
    webapp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", allowDirListing);

    FilterHolder filterHolder = new FilterHolder(HttpMethodFilter.class);
    filterHolder.setInitParameter("server.allow.http.methods", allowedMethods);
    filterHolder.setInitParameter("server.disallow.http.methods", disallowedMethods);
    webapp.addFilter(filterHolder, "/*", EnumSet.of(DispatcherType.REQUEST));

    String extraClasspath = getPluginClasspath(new File(Wrapper.getConfigDir(null, false)));
    webapp.setExtraClasspath(extraClasspath);
    if (extraClasspath.length() > 0) {
        getLogger().info("Adding extra classpath of: " + extraClasspath.toString());
    }

    server.setHandler(webapp);

    ServerContainer webSocketServer = WebSocketServerContainerInitializer.configureContext(webapp);

    webSocketServer.setDefaultMaxSessionIdleTimeout(10000000);

    server.start();
    
    server.join();
}
 
开发者ID:JumpMind,项目名称:metl,代码行数:52,代码来源:StartWebServer.java

示例5: main

import org.eclipse.jetty.webapp.Configuration.ClassList; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        logger.info("Starting ZKEditUI!");
        Properties globalProps = new Properties();
        File f = new File("config.properties");
        if (f.exists()) {
            globalProps.load(new FileInputStream("config.properties"));
        } else {
            System.out.println("Please create config.properties properties file and then execute the program!");
            System.exit(1);
        }

        globalProps.setProperty("uptime", new Date().toString());
        new Dao(globalProps).checkNCreate();

        String webFolder = "webapp";
        Server server = new Server(Integer.parseInt(globalProps.getProperty("serverPort")));

        WebAppContext servletContextHandler = new WebAppContext();
        servletContextHandler.setContextPath("/");
        servletContextHandler.setResourceBase("src/main/resources/" + webFolder);
        ClassList clist = ClassList.setServerDefault(server);
        clist.addBefore(JettyWebXmlConfiguration.class.getName(), AnnotationConfiguration.class.getName());
        servletContextHandler.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*(/target/classes/|.*.jar)");
        servletContextHandler.setParentLoaderPriority(true);
        servletContextHandler.setInitParameter("useFileMappedBuffer", "false");
        servletContextHandler.setAttribute("globalProps", globalProps);

        ResourceHandler staticResourceHandler = new ResourceHandler();
        staticResourceHandler.setDirectoriesListed(false);
        Resource staticResources = Resource.newClassPathResource(webFolder);
        staticResourceHandler.setBaseResource(staticResources);
        staticResourceHandler.setWelcomeFiles(new String[]{"html/index.html"});

        HandlerList handlers = new HandlerList();
        handlers.setHandlers(new Handler[]{staticResourceHandler, servletContextHandler});

        server.setHandler(handlers);

        server.start();
        server.join();
    }
 
开发者ID:zhoushineyoung,项目名称:zookeeper-edit,代码行数:43,代码来源:ZKEditUIMain.java

示例6: main

import org.eclipse.jetty.webapp.Configuration.ClassList; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        logger.debug("Starting ZKUI!");
        Properties globalProps = new Properties();
        File f = new File("config.cfg");
        if (f.exists()) {
            globalProps.load(new FileInputStream("config.cfg"));
        } else {
            System.out.println("Please create config.cfg properties file and then execute the program!");
            System.exit(1);
        }

        globalProps.setProperty("uptime", new Date().toString());
        new Dao(globalProps).checkNCreate();

        String webFolder = "webapp";
        Server server = new Server();

        WebAppContext servletContextHandler = new WebAppContext();
        servletContextHandler.setContextPath("/");
        servletContextHandler.setResourceBase("src/main/resources/" + webFolder);
        ClassList clist = ClassList.setServerDefault(server);
        clist.addBefore(JettyWebXmlConfiguration.class.getName(), AnnotationConfiguration.class.getName());
        servletContextHandler.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*(/target/classes/|.*.jar)");
        servletContextHandler.setParentLoaderPriority(true);
        servletContextHandler.setInitParameter("useFileMappedBuffer", "false");
        servletContextHandler.setAttribute("globalProps", globalProps);

        ResourceHandler staticResourceHandler = new ResourceHandler();
        staticResourceHandler.setDirectoriesListed(false);
        Resource staticResources = Resource.newClassPathResource(webFolder);
        staticResourceHandler.setBaseResource(staticResources);
        staticResourceHandler.setWelcomeFiles(new String[]{"html/index.html"});

        HandlerList handlers = new HandlerList();
        handlers.setHandlers(new Handler[]{staticResourceHandler, servletContextHandler});

        server.setHandler(handlers);
        HttpConfiguration http_config = new HttpConfiguration();
        http_config.setSecureScheme("https");
        http_config.setSecurePort(Integer.parseInt(globalProps.getProperty("serverPort")));
        
        if (globalProps.getProperty("https").equals("true")) {
            File keystoreFile = new File(globalProps.getProperty("keystoreFile"));
            SslContextFactory sslContextFactory = new SslContextFactory();
            sslContextFactory.setKeyStorePath(keystoreFile.getAbsolutePath());
            sslContextFactory.setKeyStorePassword(globalProps.getProperty("keystorePwd"));
            sslContextFactory.setKeyManagerPassword(globalProps.getProperty("keystoreManagerPwd"));
            HttpConfiguration https_config = new HttpConfiguration(http_config);
            https_config.addCustomizer(new SecureRequestCustomizer());

            ServerConnector https = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(https_config));
            https.setPort(Integer.parseInt(globalProps.getProperty("serverPort")));
            server.setConnectors(new Connector[]{https});
        } else {
            if(globalProps.getProperty("X-Forwarded-For").equals("true")) {
                http_config.addCustomizer(new org.eclipse.jetty.server.ForwardedRequestCustomizer());
            }
            ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config));
            http.setPort(Integer.parseInt(globalProps.getProperty("serverPort")));
            server.setConnectors(new Connector[]{http});
        }

        server.start();
        server.join();
    }
 
开发者ID:DeemOpen,项目名称:zkui,代码行数:67,代码来源:Main.java


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