本文整理汇总了Java中org.eclipse.jetty.util.resource.Resource.newClassPathResource方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.newClassPathResource方法的具体用法?Java Resource.newClassPathResource怎么用?Java Resource.newClassPathResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.util.resource.Resource
的用法示例。
在下文中一共展示了Resource.newClassPathResource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
private void start() throws Exception {
resourcesExample();
ResourceHandler resourceHandler = new ResourceHandler();
Resource resource = Resource.newClassPathResource(PUBLIC_HTML);
resourceHandler.setBaseResource(resource);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.addServlet(new ServletHolder(new TimerServlet()), "/timer");
Server server = new Server(PORT);
server.setHandler(new HandlerList(resourceHandler, context));
server.start();
server.join();
}
示例2: get
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
@Override
public OutPutModel get() {
LoggerFactory.getLogger(RunHoverCrawl.class).info(
"Running the hover crawl");
Resource hoverSiteBase =
Resource.newClassPathResource("hover-test-site");
BaseCrawler hoverSiteCrawl = new BaseCrawler(hoverSiteBase, "") {
@Override
protected CrawljaxConfigurationBuilder newCrawlConfigurationBuilder() {
CrawljaxConfigurationBuilder builder =
super.newCrawlConfigurationBuilder().setOutputDirectory(
getTempDir());
return builder;
};
};
CrawlOverview plugin = new CrawlOverview();
hoverSiteCrawl.crawlWith(plugin);
return plugin.getResult();
}
示例3: DefaultHttpsServerConfig
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
public DefaultHttpsServerConfig() {
String httpsServerPortProperty = System.getProperty("https.server.port");
String httpsServerKeyStorePathProperty = System.getProperty("https.server.key.store.path");
String httpsServerKeyStorePasswordProperty = System.getProperty("https.server.key.store.password");
if (httpsServerPortProperty == null) {
throw new IllegalArgumentException("Must have HTTPS Server port defined as system property 'https.server.port'.");
}
if (httpsServerKeyStorePathProperty == null) {
throw new IllegalArgumentException("Must have key store resource/file defined as system property 'https.server.key.store.path'.");
}
if (httpsServerKeyStorePasswordProperty == null) {
throw new IllegalArgumentException("Must have key store password defined as system property 'https.server.key.store.password'.");
}
httpsServerPort = Integer.valueOf(httpsServerPortProperty);
httpsServerKeyStoreResource = Resource.newClassPathResource(httpsServerKeyStorePathProperty);
httpsServerKeyStorePassword = httpsServerKeyStorePasswordProperty;
protocols = DEFAULT_PROTOCOLS;
}
示例4: DefaultClientAuthHttpsServerConfig
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
public DefaultClientAuthHttpsServerConfig() {
super();
String httpsServerTrustStorePathProperty = System.getProperty("https.server.trust.store.path");
String httpsServerTrustStorePasswordProperty = System.getProperty("https.server.trust.store.password");
if (httpsServerTrustStorePathProperty == null) { throw new IllegalArgumentException("Must have trust store resource/file defined as system property 'https.server.trust.store.path'."); }
if (httpsServerTrustStorePasswordProperty == null) { throw new IllegalArgumentException("Must have trust store password defined as system property 'https.server.trust.store.password'."); }
httpsServerTrustStoreResource = Resource.newClassPathResource(httpsServerTrustStorePathProperty);
httpsServerTrustStorePassword = httpsServerTrustStorePasswordProperty;
String httpsServerClientCertificateRequiredProperty = System.getProperty("https.server.client.certificate.required");
// Default is that client cert IS required.
if (httpsServerClientCertificateRequiredProperty != null) {
if (httpsServerClientCertificateRequiredProperty.equalsIgnoreCase("no") || httpsServerClientCertificateRequiredProperty.equalsIgnoreCase("false")) {
httpsServerClientCertificateRequired = false;
}
}
}
示例5: getSSLConnectionFactory
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
private SslConnectionFactory getSSLConnectionFactory() {
Resource keyStoreResource = null;
try {
keyStoreResource = Resource.newClassPathResource("localhost");
System.out.println(keyStoreResource);
} catch (Exception ex) {
Logger.getLogger(EventServer.class.getName()).log(Level.SEVERE, null, ex);
}
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStoreResource(keyStoreResource);
sslContextFactory.setKeyStorePassword(keyStorePassword);
sslContextFactory.setKeyManagerPassword(keyManagerPassword);
return new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString());
}
示例6: newResourcesHandler
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
private ResourceHandler newResourcesHandler() throws MalformedURLException {
final ResourceHandler resources = new ResourceHandler();
final Resource location =
config.getBoolean("web.static.resources.embedded") ?
Resource.newClassPathResource("web", false, false)
: Resource.newResource("src/main/resources/web", false);
resources.setBaseResource(location);
resources.setCacheControl("no-store");
return resources;
}
示例7: getStaticResources
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
@Override
public ResourceCollection getStaticResources() {
if (enableQuickstartPage) {
return new ResourceCollection(Resource.newClassPathResource("/io/confluent/ksql/rest/"));
} else {
return super.getStaticResources();
}
}
示例8: webBrowserWindowOpensItIsIgnored
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
@Test
public void webBrowserWindowOpensItIsIgnored() {
BaseCrawler crawler =
new BaseCrawler(Resource.newClassPathResource("/site"), "download/download.html");
CrawlSession crawl = crawler.crawl();
assertThat(crawl.getStateFlowGraph(), hasStates(2));
}
示例9: main
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
int timeout = (int) Duration.ONE_HOUR.getMilliseconds();
Server server = new Server();
SocketConnector connector = new SocketConnector();
// Set some timeout options to make debugging easier.
connector.setMaxIdleTime(timeout);
connector.setSoLingerTime(-1);
connector.setPort(8080);
server.addConnector(connector);
Resource keystore = Resource.newClassPathResource("/keystore");
if (keystore != null && keystore.exists()) {
// if a keystore for a SSL certificate is available, start a SSL
// connector on port 8443.
// By default, the quickstart comes with a Apache Wicket Quickstart
// Certificate that expires about half way september 2021. Do not
// use this certificate anywhere important as the passwords are
// available in the source.
connector.setConfidentialPort(8443);
SslContextFactory factory = new SslContextFactory();
factory.setKeyStoreResource(keystore);
factory.setKeyStorePassword("wicket");
factory.setTrustStoreResource(keystore);
factory.setKeyManagerPassword("wicket");
SslSocketConnector sslConnector = new SslSocketConnector(factory);
sslConnector.setMaxIdleTime(timeout);
sslConnector.setPort(8443);
sslConnector.setAcceptors(4);
server.addConnector(sslConnector);
System.out.println("SSL access to the quickstart has been enabled on port 8443");
System.out.println("You can access the application using SSL on https://localhost:8443");
System.out.println();
}
WebAppContext bb = new WebAppContext();
bb.setServer(server);
bb.setContextPath("/");
bb.setWar("src/main/webapp");
// START JMX SERVER
// MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
// MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
// server.getContainer().addEventListener(mBeanContainer);
// mBeanContainer.start();
server.setHandler(bb);
try {
System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
server.start();
System.in.read();
System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
server.stop();
server.join();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
示例10: main
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
ResourceHandler resourceHandler = new ResourceHandler();
//Main.class.getResource(PUBLIC_HTML + "index.html");
Resource resource = Resource.newClassPathResource(PUBLIC_HTML);
resourceHandler.setBaseResource(resource);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.addServlet(new ServletHolder(new TimerServlet()), "/timer");
Server server = new Server(PORT);
server.setHandler(new HandlerList(resourceHandler, context));
server.start();
server.join();
}
示例11: main
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
/**
* Main function, starts the jetty server.
*
* @param args
*/
public static void main(String[] args)
{
System.setProperty("wicket.configuration", "development");
Server server = new Server();
HttpConfiguration http_config = new HttpConfiguration();
http_config.setSecureScheme("https");
http_config.setSecurePort(8443);
http_config.setOutputBufferSize(32768);
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config));
http.setPort(8080);
http.setIdleTimeout(1000 * 60 * 60);
server.addConnector(http);
Resource keystore = Resource.newClassPathResource("/keystore");
if (keystore != null && keystore.exists())
{
// if a keystore for a SSL certificate is available, start a SSL
// connector on port 8443.
// By default, the quickstart comes with a Apache Wicket Quickstart
// Certificate that expires about half way september 2021. Do not
// use this certificate anywhere important as the passwords are
// available in the source.
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStoreResource(keystore);
sslContextFactory.setKeyStorePassword("wicket");
sslContextFactory.setKeyManagerPassword("wicket");
HttpConfiguration https_config = new HttpConfiguration(http_config);
https_config.addCustomizer(new SecureRequestCustomizer());
ServerConnector https = new ServerConnector(server, new SslConnectionFactory(
sslContextFactory, "http/1.1"), new HttpConnectionFactory(https_config));
https.setPort(8443);
https.setIdleTimeout(500000);
server.addConnector(https);
System.out.println("SSL access to the examples has been enabled on port 8443");
System.out
.println("You can access the application using SSL on https://localhost:8443");
System.out.println();
}
WebAppContext bb = new WebAppContext();
bb.setServer(server);
bb.setContextPath("/");
bb.setWar("src/main/webapp");
// uncomment next line if you want to test with JSESSIONID encoded in the urls
// ((AbstractSessionManager)
// bb.getSessionHandler().getSessionManager()).setUsingCookies(false);
server.setHandler(bb);
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
server.addEventListener(mBeanContainer);
server.addBean(mBeanContainer);
try
{
server.start();
server.join();
}
catch (Exception e)
{
e.printStackTrace();
System.exit(100);
}
}
示例12: main
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
int timeout = (int) Duration.ONE_HOUR.getMilliseconds();
Server server = new Server();
SocketConnector connector = new SocketConnector();
// Set some timeout options to make debugging easier.
connector.setMaxIdleTime(timeout);
connector.setSoLingerTime(-1);
connector.setPort(8090);
server.addConnector(connector);
Resource keystore = Resource.newClassPathResource("/keystore");
if (keystore != null && keystore.exists()) {
// if a keystore for a SSL certificate is available, start a SSL
// connector on port 8443.
// By default, the quickstart comes with a Apache Wicket Quickstart
// Certificate that expires about half way september 2021. Do not
// use this certificate anywhere important as the passwords are
// available in the source.
connector.setConfidentialPort(8443);
SslContextFactory factory = new SslContextFactory();
factory.setKeyStoreResource(keystore);
factory.setKeyStorePassword("wicket");
factory.setTrustStoreResource(keystore);
factory.setKeyManagerPassword("wicket");
SslSocketConnector sslConnector = new SslSocketConnector(factory);
sslConnector.setMaxIdleTime(timeout);
sslConnector.setPort(8443);
sslConnector.setAcceptors(4);
server.addConnector(sslConnector);
System.out.println("SSL access to the quickstart has been enabled on port 8443");
System.out.println("You can access the application using SSL on https://localhost:8443");
System.out.println();
}
WebAppContext bb = new WebAppContext();
bb.setServer(server);
bb.setContextPath("/");
bb.setWar("src/main/webapp");
// START JMX SERVER
// MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
// MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
// server.getContainer().addEventListener(mBeanContainer);
// mBeanContainer.start();
server.setHandler(bb);
try {
System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
server.start();
System.in.read();
System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
server.stop();
server.join();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
示例13: SimpleJsSiteCrawl
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
public SimpleJsSiteCrawl() {
super(Resource.newClassPathResource("sites"), "simple-js-site");
}
示例14: SimpleXpathCrawl
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
public SimpleXpathCrawl() {
super(Resource.newClassPathResource("sites"), "simple-xpath-site");
}
示例15: SimpleSiteCrawl
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
public SimpleSiteCrawl() {
super(Resource.newClassPathResource("sites"), "simple-site");
}