本文整理汇总了Java中org.apache.coyote.http11.Http11Protocol类的典型用法代码示例。如果您正苦于以下问题:Java Http11Protocol类的具体用法?Java Http11Protocol怎么用?Java Http11Protocol使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Http11Protocol类属于org.apache.coyote.http11包,在下文中一共展示了Http11Protocol类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTomcat7Port
import org.apache.coyote.http11.Http11Protocol; //导入依赖的package包/类
/**
* Gets my listen port in Tomcat 7. Returns zero if not possible
*/
public static int getTomcat7Port() {
try {
MBeanServer mBeanServer = MBeanServerFactory.findMBeanServer(null).get(0);
ObjectName name = new ObjectName("Catalina", "type", "Server");
Server server = (Server) mBeanServer.getAttribute(name, "managedResource");
Service[] services = server.findServices();
for (Service service : services) {
for (Connector connector : service.findConnectors()) {
ProtocolHandler protocolHandler = connector.getProtocolHandler();
if (protocolHandler instanceof Http11Protocol) {
return connector.getPort();
}
}
}
return 0;
} catch(Exception ex) {
ex.printStackTrace(System.err);
return 0;
}
}
示例2: destroyMBean
import org.apache.coyote.http11.Http11Protocol; //导入依赖的package包/类
/**
* Deregister the MBean for this
* <code>Connector</code> object.
*
* @param connector The Connector to be managed
*
* @exception Exception if an MBean cannot be deregistered
* @deprecated Unused. Will be removed in Tomcat 8.0.x
*/
@Deprecated
static void destroyMBean(Connector connector, Service service)
throws Exception {
// domain is engine name
String domain = service.getContainer().getName();
if (domain == null)
domain = mserver.getDefaultDomain();
ObjectName oname = createObjectName(domain, connector);
if( mserver.isRegistered( oname )) {
mserver.unregisterMBean(oname);
}
// Unregister associated request processor
String worker = null;
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof Http11Protocol) {
worker = ((Http11Protocol)handler).getName();
} else if (handler instanceof Http11NioProtocol) {
worker = ((Http11NioProtocol)handler).getName();
} else if (handler instanceof Http11AprProtocol) {
worker = ((Http11AprProtocol)handler).getName();
} else if (handler instanceof AjpProtocol) {
worker = ((AjpProtocol)handler).getName();
} else if (handler instanceof AjpAprProtocol) {
worker = ((AjpAprProtocol)handler).getName();
}
ObjectName query = new ObjectName(
domain + ":type=RequestProcessor,worker=" + worker + ",*");
Set<ObjectName> results = mserver.queryNames(query, null);
for(ObjectName result : results) {
mserver.unregisterMBean(result);
}
}
示例3: destroyMBean
import org.apache.coyote.http11.Http11Protocol; //导入依赖的package包/类
/**
* Deregister the MBean for this <code>Connector</code> object.
*
* @param connector
* The Connector to be managed
*
* @exception Exception
* if an MBean cannot be deregistered
* @deprecated Unused. Will be removed in Tomcat 8.0.x
*/
@Deprecated
static void destroyMBean(Connector connector, Service service) throws Exception {
// domain is engine name
String domain = service.getContainer().getName();
if (domain == null)
domain = mserver.getDefaultDomain();
ObjectName oname = createObjectName(domain, connector);
if (mserver.isRegistered(oname)) {
mserver.unregisterMBean(oname);
}
// Unregister associated request processor
String worker = null;
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof Http11Protocol) {
worker = ((Http11Protocol) handler).getName();
} else if (handler instanceof Http11NioProtocol) {
worker = ((Http11NioProtocol) handler).getName();
} else if (handler instanceof Http11AprProtocol) {
worker = ((Http11AprProtocol) handler).getName();
} else if (handler instanceof AjpProtocol) {
worker = ((AjpProtocol) handler).getName();
} else if (handler instanceof AjpAprProtocol) {
worker = ((AjpAprProtocol) handler).getName();
}
ObjectName query = new ObjectName(domain + ":type=RequestProcessor,worker=" + worker + ",*");
Set<ObjectName> results = mserver.queryNames(query, null);
for (ObjectName result : results) {
mserver.unregisterMBean(result);
}
}
示例4: getAddress
import org.apache.coyote.http11.Http11Protocol; //导入依赖的package包/类
/**
* Return the address.
*
* @return An address string
*/
public String getAddress() {
String hostAddress = null;
Connector connector = ServerUtil.getDefaultConnector();
if (connector.getProtocolHandler() instanceof Http11Protocol) {
Http11Protocol protocol = (Http11Protocol) connector.getProtocolHandler();
InetAddress address = protocol.getAddress();
hostAddress = address.getHostAddress();
} else {
ExtensionLogger.ROOT_LOGGER.unableToDetermineHostAddress();
hostAddress = ServerUtil.getDefaultHost().getHost().findAliases()[0];
}
return connector.getScheme() + "://" + hostAddress + ":" + connector.getPort() + "/" + _contextName;
}
示例5: start
import org.apache.coyote.http11.Http11Protocol; //导入依赖的package包/类
public boolean start() throws ContainerException {
// Start the Tomcat server
try {
tomcat.getServer().start();
} catch (LifecycleException e) {
throw new ContainerException(e);
}
// load the web applications
loadComponents();
for (Connector con: tomcat.getService().findConnectors()) {
ProtocolHandler ph = con.getProtocolHandler();
int port = con.getPort();
con.setAttribute("port", port);
if (ph instanceof Http11Protocol) {
Http11Protocol hph = (Http11Protocol) ph;
Debug.logInfo("Connector " + hph.getName() + " @ " + hph.getPort() + " - " +
(hph.getSecure() ? "secure" : "not-secure") + " [" + con.getProtocolHandlerClassName() + "] started.", module);
} else {
Debug.logInfo("Connector " + con.getProtocol() + " @ " + con.getPort() + " - " +
(con.getSecure() ? "secure" : "not-secure") + " [" + con.getProtocolHandlerClassName() + "] started.", module);
}
}
Debug.logInfo("Started " + ServerInfo.getServerInfo(), module);
return true;
}
示例6: destroyMBean
import org.apache.coyote.http11.Http11Protocol; //导入依赖的package包/类
/**
* Deregister the MBean for this
* <code>Connector</code> object.
*
* @param connector The Connector to be managed
*
* @exception Exception if an MBean cannot be deregistered
*/
static void destroyMBean(Connector connector, Service service)
throws Exception {
// domain is engine name
String domain = service.getContainer().getName();
if (domain == null)
domain = mserver.getDefaultDomain();
ObjectName oname = createObjectName(domain, connector);
connector.setService(null);
if( mserver.isRegistered( oname )) {
mserver.unregisterMBean(oname);
}
// Unregister associated request processor
String worker = null;
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof Http11Protocol) {
worker = ((Http11Protocol)handler).getName();
} else if (handler instanceof Http11NioProtocol) {
worker = ((Http11NioProtocol)handler).getName();
} else if (handler instanceof Http11AprProtocol) {
worker = ((Http11AprProtocol)handler).getName();
} else if (handler instanceof AjpProtocol) {
worker = ((AjpProtocol)handler).getName();
} else if (handler instanceof AjpAprProtocol) {
worker = ((AjpAprProtocol)handler).getName();
}
ObjectName query = new ObjectName(
domain + ":type=RequestProcessor,worker=" + worker + ",*");
Set<ObjectName> results = mserver.queryNames(query, null);
for(ObjectName result : results) {
mserver.unregisterMBean(result);
}
}
示例7: doTestWriteTimeoutServer
import org.apache.coyote.http11.Http11Protocol; //导入依赖的package包/类
private void doTestWriteTimeoutServer(boolean setTimeoutOnContainer)
throws Exception {
// This will never work for BIO
Assume.assumeFalse(
"Skipping test. This feature will never work for BIO connector.",
getProtocol().equals(Http11Protocol.class.getName()));
/*
* Note: There are all sorts of horrible uses of statics in this test
* because the API uses classes and the tests really need access
* to the instances which simply isn't possible.
*/
timeoutOnContainer = setTimeoutOnContainer;
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
Context ctx = tomcat.addContext("", null);
ctx.addApplicationListener(ConstantTxConfig.class.getName());
Tomcat.addServlet(ctx, "default", new DefaultServlet());
ctx.addServletMapping("/", "default");
WebSocketContainer wsContainer =
ContainerProvider.getWebSocketContainer();
tomcat.start();
Session wsSession = wsContainer.connectToServer(
TesterProgrammaticEndpoint.class,
ClientEndpointConfig.Builder.create().build(),
new URI("ws://" + getHostName() + ":" + getPort() +
ConstantTxConfig.PATH));
wsSession.addMessageHandler(new BlockingBinaryHandler());
int loops = 0;
while (loops < 15) {
Thread.sleep(1000);
if (!ConstantTxEndpoint.getRunning()) {
break;
}
loops++;
}
// Close the client session, primarily to allow the
// BackgroundProcessManager to shut down.
wsSession.close();
// Check the right exception was thrown
Assert.assertNotNull(ConstantTxEndpoint.getException());
Assert.assertEquals(ExecutionException.class,
ConstantTxEndpoint.getException().getClass());
Assert.assertNotNull(ConstantTxEndpoint.getException().getCause());
Assert.assertEquals(SocketTimeoutException.class,
ConstantTxEndpoint.getException().getCause().getClass());
// Check correct time passed
Assert.assertTrue(ConstantTxEndpoint.getTimeout() >= TIMEOUT_MS);
// Check the timeout wasn't too long
Assert.assertTrue(ConstantTxEndpoint.getTimeout() < TIMEOUT_MS*2);
}
示例8: getHttp11Protocol
import org.apache.coyote.http11.Http11Protocol; //导入依赖的package包/类
protected Http11Protocol getHttp11Protocol()
{
return (Http11Protocol) getProtocolHandler();
}
示例9: doTestWriteTimeoutServer
import org.apache.coyote.http11.Http11Protocol; //导入依赖的package包/类
private void doTestWriteTimeoutServer(boolean setTimeoutOnContainer)
throws Exception {
// This will never work for BIO
Assume.assumeFalse(
"Skipping test. This feature will never work for BIO connector.",
getProtocol().equals(Http11Protocol.class.getName()));
/*
* Note: There are all sorts of horrible uses of statics in this test
* because the API uses classes and the tests really need access
* to the instances which simply isn't possible.
*/
timoutOnContainer = setTimeoutOnContainer;
Tomcat tomcat = getTomcatInstance();
// Must have a real docBase - just use temp
Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
ctx.addApplicationListener(new ApplicationListener(
ConstantTxConfig.class.getName(), false));
Tomcat.addServlet(ctx, "default", new DefaultServlet());
ctx.addServletMapping("/", "default");
WebSocketContainer wsContainer =
ContainerProvider.getWebSocketContainer();
tomcat.start();
Session wsSession = wsContainer.connectToServer(
TesterProgrammaticEndpoint.class,
ClientEndpointConfig.Builder.create().build(),
new URI("ws://localhost:" + getPort() +
ConstantTxConfig.PATH));
wsSession.addMessageHandler(new BlockingBinaryHandler());
int loops = 0;
while (loops < 15) {
Thread.sleep(1000);
if (!ConstantTxEndpoint.getRunning()) {
break;
}
loops++;
}
// Check the right exception was thrown
Assert.assertNotNull(ConstantTxEndpoint.getException());
Assert.assertEquals(ExecutionException.class,
ConstantTxEndpoint.getException().getClass());
Assert.assertNotNull(ConstantTxEndpoint.getException().getCause());
Assert.assertEquals(SocketTimeoutException.class,
ConstantTxEndpoint.getException().getCause().getClass());
// Check correct time passed
Assert.assertTrue(ConstantTxEndpoint.getTimeout() >= TIMEOUT_MS);
// Check the timeout wasn't too long
Assert.assertTrue(ConstantTxEndpoint.getTimeout() < TIMEOUT_MS*2);
}
示例10: doTestWriteTimeoutServer
import org.apache.coyote.http11.Http11Protocol; //导入依赖的package包/类
private void doTestWriteTimeoutServer(boolean setTimeoutOnContainer)
throws Exception {
// This will never work for BIO
Assume.assumeFalse(
"Skipping test. This feature will never work for BIO connector.",
getProtocol().equals(Http11Protocol.class.getName()));
/*
* Note: There are all sorts of horrible uses of statics in this test
* because the API uses classes and the tests really need access
* to the instances which simply isn't possible.
*/
timoutOnContainer = setTimeoutOnContainer;
Tomcat tomcat = getTomcatInstance();
// Must have a real docBase - just use temp
Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
ctx.addApplicationListener(ConstantTxConfig.class.getName());
Tomcat.addServlet(ctx, "default", new DefaultServlet());
ctx.addServletMapping("/", "default");
WebSocketContainer wsContainer =
ContainerProvider.getWebSocketContainer();
tomcat.start();
Session wsSession = wsContainer.connectToServer(
TesterProgrammaticEndpoint.class,
ClientEndpointConfig.Builder.create().build(),
new URI("ws://localhost:" + getPort() +
ConstantTxConfig.PATH));
wsSession.addMessageHandler(new BlockingBinaryHandler());
int loops = 0;
while (loops < 15) {
Thread.sleep(1000);
if (!ConstantTxEndpoint.getRunning()) {
break;
}
loops++;
}
// Check the right exception was thrown
Assert.assertNotNull(ConstantTxEndpoint.getException());
Assert.assertEquals(ExecutionException.class,
ConstantTxEndpoint.getException().getClass());
Assert.assertNotNull(ConstantTxEndpoint.getException().getCause());
Assert.assertEquals(SocketTimeoutException.class,
ConstantTxEndpoint.getException().getCause().getClass());
// Check correct time passed
Assert.assertTrue(ConstantTxEndpoint.getTimeout() >= TIMEOUT_MS);
// Check the timeout wasn't too long
Assert.assertTrue(ConstantTxEndpoint.getTimeout() < TIMEOUT_MS*2);
}