本文整理汇总了Java中org.eclipse.jetty.server.ssl.SslSocketConnector.setMaxIdleTime方法的典型用法代码示例。如果您正苦于以下问题:Java SslSocketConnector.setMaxIdleTime方法的具体用法?Java SslSocketConnector.setMaxIdleTime怎么用?Java SslSocketConnector.setMaxIdleTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.server.ssl.SslSocketConnector
的用法示例。
在下文中一共展示了SslSocketConnector.setMaxIdleTime方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: enableSSL
import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
/**
* Enables SSL
*
*/
private void enableSSL() {
String keyStorePath = this.getFile().getParent() + "/data/" + keystoreFile;
try (FileInputStream keyStoreInputStream = new FileInputStream(keyStorePath)) {
KeyStore keyStore = KeyStore.getInstance(keystoreType);
keyStore.load(keyStoreInputStream, keystorePassword.toCharArray());
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStore(keyStore);
sslContextFactory.setKeyStorePassword(keystorePassword);
sslContextFactory.setKeyStoreType(keystoreType);
SslSocketConnector sslConnector = new SslSocketConnector(sslContextFactory);
sslConnector.setPort(sslPort);
sslConnector.setMaxIdleTime(30000);
LOG.info("Webserver now listens on SSL port {}", sslPort);
server.addConnector(sslConnector);
} catch (Exception ex) {
LOG.error("Cannot load java keystore for reason: ", Freedomotic.getStackTraceInfo(ex));
}
}
示例2: main
import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的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);
}
}
示例3: main
import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的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);
}
}
示例4: startWebServer
import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
/**
* Creates and starts an embedded web server on JVM-assigned HTTP and HTTPS ports.
* Each response has a body that indicates how many bytes were received with a message like
* "Received x bytes\n".
*
* @param enableHttps if true, an HTTPS connector will be added to the web server
* @return Instance of Server
*/
public static Server startWebServer(boolean enableHttps) {
final Server httpServer = new Server(0);
httpServer.setHandler(new AbstractHandler() {
public void handle(String target, Request baseRequest,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
if (request.getRequestURI().contains("hang")) {
System.out.println("Hanging as requested");
try {
Thread.sleep(90000);
} catch (InterruptedException ie) {
System.out.println("Stopped hanging due to interruption");
}
}
long numberOfBytesRead = 0;
InputStream in = new BufferedInputStream(request
.getInputStream());
while (in.read() != -1) {
numberOfBytesRead += 1;
}
System.out.println("Done reading # of bytes: "
+ numberOfBytesRead);
response.setStatus(HttpServletResponse.SC_OK);
baseRequest.setHandled(true);
byte[] content = ("Received " + numberOfBytesRead + " bytes\n").getBytes();
response.addHeader("Content-Length", Integer.toString(content.length));
response.getOutputStream().write(content);
}
});
if (enableHttps) {
// Add SSL connector
org.eclipse.jetty.util.ssl.SslContextFactory sslContextFactory = new org.eclipse.jetty.util.ssl.SslContextFactory();
SelfSignedSslEngineSource contextSource = new SelfSignedSslEngineSource();
SSLContext sslContext = contextSource.getSslContext();
sslContextFactory.setSslContext(sslContext);
SslSocketConnector connector = new SslSocketConnector(
sslContextFactory);
connector.setPort(0);
/*
* <p>Ox: For some reason, on OS X, a non-zero timeout can causes
* sporadic issues. <a href="http://stackoverflow.com/questions
* /16191236/tomcat-startup-fails
* -due-to-java-net-socketexception-invalid-argument-on-mac-o">This
* StackOverflow thread</a> has some insights into it, but I don't
* quite get it.</p>
*
* <p>This can cause problems with Jetty's SSL handshaking, so I
* have to set the handshake timeout and the maxIdleTime to 0 so
* that the SSLSocket has an infinite timeout.</p>
*/
connector.setHandshakeTimeout(0);
connector.setMaxIdleTime(0);
httpServer.addConnector(connector);
}
try {
httpServer.start();
} catch (Exception e) {
throw new RuntimeException("Error starting Jetty web server", e);
}
return httpServer;
}
示例5: startWebServerWithResponse
import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
/**
* Creates and starts an embedded web server on JVM-assigned HTTP and HTTPS ports.
* Each response has a body that contains the specified contents.
*
* @param enableHttps if true, an HTTPS connector will be added to the web server
* @param content The response the server will return
* @return Instance of Server
*/
public static Server startWebServerWithResponse(boolean enableHttps, final byte[] content) {
final Server httpServer = new Server(0);
httpServer.setHandler(new AbstractHandler() {
public void handle(String target, Request baseRequest,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
if (request.getRequestURI().contains("hang")) {
System.out.println("Hanging as requested");
try {
Thread.sleep(90000);
} catch (InterruptedException ie) {
System.out.println("Stopped hanging due to interruption");
}
}
long numberOfBytesRead = 0;
InputStream in = new BufferedInputStream(request
.getInputStream());
while (in.read() != -1) {
numberOfBytesRead += 1;
}
System.out.println("Done reading # of bytes: "
+ numberOfBytesRead);
response.setStatus(HttpServletResponse.SC_OK);
baseRequest.setHandled(true);
response.addHeader("Content-Length", Integer.toString(content.length));
response.getOutputStream().write(content);
}
});
if (enableHttps) {
// Add SSL connector
org.eclipse.jetty.util.ssl.SslContextFactory sslContextFactory = new org.eclipse.jetty.util.ssl.SslContextFactory();
SelfSignedSslEngineSource contextSource = new SelfSignedSslEngineSource();
SSLContext sslContext = contextSource.getSslContext();
sslContextFactory.setSslContext(sslContext);
SslSocketConnector connector = new SslSocketConnector(
sslContextFactory);
connector.setPort(0);
/*
* <p>Ox: For some reason, on OS X, a non-zero timeout can causes
* sporadic issues. <a href="http://stackoverflow.com/questions
* /16191236/tomcat-startup-fails
* -due-to-java-net-socketexception-invalid-argument-on-mac-o">This
* StackOverflow thread</a> has some insights into it, but I don't
* quite get it.</p>
*
* <p>This can cause problems with Jetty's SSL handshaking, so I
* have to set the handshake timeout and the maxIdleTime to 0 so
* that the SSLSocket has an infinite timeout.</p>
*/
connector.setHandshakeTimeout(0);
connector.setMaxIdleTime(0);
httpServer.addConnector(connector);
}
try {
httpServer.start();
} catch (Exception e) {
throw new RuntimeException("Error starting Jetty web server", e);
}
return httpServer;
}
示例6: startWebServer
import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
/**
* Creates and starts embedded web server that is running on given port,
* including an SSL connector on the other given port. Each response has a
* body that indicates how many bytes were received with a message like
* "Received x bytes\n".
*
* @param port
* The port
* @param sslPort
* (optional) The ssl port
* @return Instance of Server
* @throws Exception
* if failed to start
*/
public static Server startWebServer(final int port, final Integer sslPort)
throws Exception {
final Server httpServer = new Server(port);
httpServer.setHandler(new AbstractHandler() {
public void handle(String target, Request baseRequest,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
if (request.getRequestURI().contains("hang")) {
System.out.println("Hanging as requested");
try {
Thread.sleep(90000);
} catch (InterruptedException ie) {
System.out.println("Stopped hanging due to interruption");
}
}
long numberOfBytesRead = 0;
InputStream in = new BufferedInputStream(request
.getInputStream());
while (in.read() != -1) {
numberOfBytesRead += 1;
}
System.out.println("Done reading # of bytes: "
+ numberOfBytesRead);
response.setStatus(HttpServletResponse.SC_OK);
baseRequest.setHandled(true);
byte[] content = ("Received " + numberOfBytesRead + " bytes\n").getBytes();
response.addHeader("Content-Length", Integer.toString(content.length));
response.getOutputStream().write(content);
}
});
if (sslPort != null) {
// Add SSL connector
org.eclipse.jetty.util.ssl.SslContextFactory sslContextFactory = new org.eclipse.jetty.util.ssl.SslContextFactory();
SelfSignedSslEngineSource contextSource = new SelfSignedSslEngineSource();
SSLContext sslContext = contextSource.getSslContext();
sslContextFactory.setSslContext(sslContext);
SslSocketConnector connector = new SslSocketConnector(
sslContextFactory);
connector.setPort(sslPort);
/*
* <p>Ox: For some reason, on OS X, a non-zero timeout can causes
* sporadic issues. <a href="http://stackoverflow.com/questions
* /16191236/tomcat-startup-fails
* -due-to-java-net-socketexception-invalid-argument-on-mac-o">This
* StackOverflow thread</a> has some insights into it, but I don't
* quite get it.</p>
*
* <p>This can cause problems with Jetty's SSL handshaking, so I
* have to set the handshake timeout and the maxIdleTime to 0 so
* that the SSLSocket has an infinite timeout.</p>
*/
connector.setHandshakeTimeout(0);
connector.setMaxIdleTime(0);
httpServer.addConnector(connector);
}
httpServer.start();
return httpServer;
}
示例7: startWebServerWithResponse
import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
/**
* Creates and starts embedded web server that is running on given port,
* including an SSL connector on the other given port. Each response has a
* body that contains the specified contents.
*
* @param port
* The port
* @param sslPort
* (optional) The ssl port
* @param content
* The response the server will return
* @return Instance of Server
* @throws Exception
* if failed to start
*/
public static Server startWebServerWithResponse(final int port, final Integer sslPort, final byte[] content)
throws Exception {
final Server httpServer = new Server(port);
httpServer.setHandler(new AbstractHandler() {
public void handle(String target, Request baseRequest,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
if (request.getRequestURI().contains("hang")) {
System.out.println("Hanging as requested");
try {
Thread.sleep(90000);
} catch (InterruptedException ie) {
System.out.println("Stopped hanging due to interruption");
}
}
long numberOfBytesRead = 0;
InputStream in = new BufferedInputStream(request
.getInputStream());
while (in.read() != -1) {
numberOfBytesRead += 1;
}
System.out.println("Done reading # of bytes: "
+ numberOfBytesRead);
response.setStatus(HttpServletResponse.SC_OK);
baseRequest.setHandled(true);
response.addHeader("Content-Length", Integer.toString(content.length));
response.getOutputStream().write(content);
}
});
if (sslPort != null) {
// Add SSL connector
org.eclipse.jetty.util.ssl.SslContextFactory sslContextFactory = new org.eclipse.jetty.util.ssl.SslContextFactory();
SelfSignedSslEngineSource contextSource = new SelfSignedSslEngineSource();
SSLContext sslContext = contextSource.getSslContext();
sslContextFactory.setSslContext(sslContext);
SslSocketConnector connector = new SslSocketConnector(
sslContextFactory);
connector.setPort(sslPort);
/*
* <p>Ox: For some reason, on OS X, a non-zero timeout can causes
* sporadic issues. <a href="http://stackoverflow.com/questions
* /16191236/tomcat-startup-fails
* -due-to-java-net-socketexception-invalid-argument-on-mac-o">This
* StackOverflow thread</a> has some insights into it, but I don't
* quite get it.</p>
*
* <p>This can cause problems with Jetty's SSL handshaking, so I
* have to set the handshake timeout and the maxIdleTime to 0 so
* that the SSLSocket has an infinite timeout.</p>
*/
connector.setHandshakeTimeout(0);
connector.setMaxIdleTime(0);
httpServer.addConnector(connector);
}
httpServer.start();
return httpServer;
}
示例8: deployWebApp
import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
private void deployWebApp() {
try {
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
connector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
connector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
connector.setHost(getHost());
connector.setPort(getPort());
if (isHttpsEnabled()) {
connector.setConfidentialPort(getHttpsPort());
}
server.addConnector(connector);
if (isHttpsEnabled()) {
SslSocketConnector sslConnector = new SslSocketConnector();
sslConnector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
sslConnector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
sslConnector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
sslConnector.setHost(getHost());
sslConnector.setPort(getHttpsPort());
sslConnector.setKeystore(System.getProperty("subsonic.ssl.keystore", getClass().getResource("/subsonic.keystore").toExternalForm()));
sslConnector.setPassword(System.getProperty("subsonic.ssl.password", "subsonic"));
server.addConnector(sslConnector);
}
WebAppContext context = new WebAppContext();
context.setTempDirectory(getJettyDirectory());
context.setContextPath(getContextPath());
context.setWar(getWar());
if (isHttpsEnabled()) {
ConstraintMapping constraintMapping = new ConstraintMapping();
Constraint constraint = new Constraint();
constraint.setDataConstraint(Constraint.DC_CONFIDENTIAL);
constraintMapping.setPathSpec("/");
constraintMapping.setConstraint(constraint);
ConstraintSecurityHandler csh = (ConstraintSecurityHandler) context.getSecurityHandler();
csh.setConstraintMappings(new ConstraintMapping[]{constraintMapping});
}
server.setHandler(context);
server.start();
System.err.println("FutureSonic running on: " + getUrl());
if (isHttpsEnabled()) {
System.err.println(" and: " + getHttpsUrl());
}
} catch (Throwable x) {
x.printStackTrace();
exception = x;
}
}
示例9: deployWebApp
import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void deployWebApp() {
try {
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
connector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
connector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
connector.setHost(getHost());
connector.setPort(getPort());
if (isHttpsEnabled()) {
connector.setConfidentialPort(getHttpsPort());
}
server.addConnector(connector);
if (isHttpsEnabled()) {
SslSocketConnector sslConnector = new SslSocketConnector();
SslContextFactory sslContextFactory = sslConnector.getSslContextFactory();
sslContextFactory = sslConnector.getSslContextFactory();
sslContextFactory.setExcludeCipherSuites(
new String[] {
"SSL_RSA_WITH_DES_CBC_SHA",
"SSL_DHE_RSA_WITH_DES_CBC_SHA",
"SSL_DHE_DSS_WITH_DES_CBC_SHA",
"SSL_RSA_EXPORT_WITH_RC4_40_MD5",
"SSL_RSA_EXPORT_WITH_DES40_CBC_SHA",
"SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA",
"SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA"
});
sslContextFactory.addExcludeProtocols(new String[]{"SSLv3","SSLv2Hello"});
sslConnector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
sslConnector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
sslConnector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
sslConnector.setHost(getHost());
sslConnector.setPort(getHttpsPort());
sslConnector.setKeystore(System.getProperty("subsonic.ssl.keystore", getClass().getResource("/subsonic.keystore").toExternalForm()));
sslConnector.setPassword(System.getProperty("subsonic.ssl.password", "subsonic"));
server.addConnector(sslConnector);
}
WebAppContext context = new WebAppContext();
context.setTempDirectory(getJettyDirectory());
context.setContextPath(getContextPath());
context.setWar(getWar());
context.setOverrideDescriptor("/web-jetty.xml");
if (isHttpsEnabled()) {
// Allow non-https for streaming and cover art (for Chromecast, UPnP etc)
((ConstraintSecurityHandler) context.getSecurityHandler()).setConstraintMappings(new ConstraintMapping[]{
createConstraintMapping("/stream", Constraint.DC_NONE),
createConstraintMapping("/coverArt.view", Constraint.DC_NONE),
createConstraintMapping("/", Constraint.DC_CONFIDENTIAL)
});
}
server.setHandler(context);
server.start();
System.err.println("Madsonic running on: " + getUrl());
if (isHttpsEnabled()) {
System.err.println(" and: " + getHttpsUrl());
}
} catch (Throwable x) {
x.printStackTrace();
exception = x;
}
}
示例10: deployWebApp
import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
private void deployWebApp() {
try {
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
connector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
connector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
connector.setHost(getHost());
connector.setPort(getPort());
if (isHttpsEnabled()) {
connector.setConfidentialPort(getHttpsPort());
}
server.addConnector(connector);
if (isHttpsEnabled()) {
SslSocketConnector sslConnector = new SslSocketConnector();
sslConnector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
sslConnector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
sslConnector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
sslConnector.setHost(getHost());
sslConnector.setPort(getHttpsPort());
sslConnector.setKeystore(System.getProperty("subsonic.ssl.keystore", getClass().getResource("/subsonic.keystore").toExternalForm()));
sslConnector.setPassword(System.getProperty("subsonic.ssl.password", "subsonic"));
server.addConnector(sslConnector);
}
WebAppContext context = new WebAppContext();
context.setTempDirectory(getJettyDirectory());
context.setContextPath(getContextPath());
context.setWar(getWar());
if (isHttpsEnabled()) {
ConstraintMapping constraintMapping = new ConstraintMapping();
Constraint constraint = new Constraint();
constraint.setDataConstraint(Constraint.DC_CONFIDENTIAL);
constraintMapping.setPathSpec("/");
constraintMapping.setConstraint(constraint);
ConstraintSecurityHandler csh = (ConstraintSecurityHandler) context.getSecurityHandler();
csh.setConstraintMappings(new ConstraintMapping[]{constraintMapping});
}
server.setHandler(context);
server.start();
System.err.println("Madsonic running on: " + getUrl());
if (isHttpsEnabled()) {
System.err.println(" and: " + getHttpsUrl());
}
} catch (Throwable x) {
x.printStackTrace();
exception = x;
}
}
示例11: main
import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的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/test/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);
}
}
示例12: main
import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的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("/examples-java-wicket");
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: main
import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的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(8081);
server.addConnector(connector);
// check if a keystore for a SSL certificate is available, and
// if so, 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.
Resource keystore = Resource.newClassPathResource("/keystore");
if (keystore != null && keystore.exists()) {
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/test/webapp");
// START JMX SERVER
// MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
// MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
// server.getContainer().addEventListener(mBeanContainer);
// mBeanContainer.start();
server.setHandler(bb);
//TOGGLE between these two method to experiment different reloading strategies
// Autoreload builds and reload the classes automatically
setAutoReloadProperties();
// WatchClasses watch the target dir for reloading (build with your IDE or maven)
//setWatchClassesProperties();
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);
}
}
示例14: main
import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Server server = new Server();
SocketConnector connector = new SocketConnector();
// Set some timeout options to make debugging easier.
connector.setMaxIdleTime(3600000);
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("jettyjetty");
factory.setTrustStoreResource(keystore);
factory.setKeyManagerPassword("jettyjetty");
SslSocketConnector sslConnector = new SslSocketConnector(factory);
sslConnector.setMaxIdleTime(3600000);
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();
}
String includeJarPattern =
".*/.*jsp-api-[^/]*\\.jar$|.*/.*jsp-[^/]*\\.jar$|.*/.*taglibs[^/]*\\.jar$";
// includeJarPattern =
// ".*/org\\.apache\\.taglibs\\.standard\\.glassfish-1\\.2\\.0\\.v201112081803\\.jar";
ResourceCollection resources = new ResourceCollection(new String[]{
"src/main/webapp", "target/webapp",
});
WebAppContext webCtx = new WebAppContext();
webCtx.setServer(server);
webCtx.setContextPath("/");
webCtx.setDescriptor("src/test/resources/web/test-web.xml");
webCtx.setBaseResource(resources);
webCtx.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
includeJarPattern);
server.setHandler(webCtx);
// BrowserListener gwtBrowserListener = new BrowserListener(null, "0.0.0.0", 9997, null);
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);
}
}