use of com.bradmcevoy.http.http11.Http11Protocol in project bamboobsc by billchen198318.
the class HostUtils method getHttpPort.
public static int getHttpPort() {
int port = 8080;
MBeanServer mBeanServer = MBeanServerFactory.findMBeanServer(null).get(0);
ObjectName name;
try {
name = new ObjectName("Catalina", "type", "Server");
try {
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 || protocolHandler instanceof Http11AprProtocol || protocolHandler instanceof Http11NioProtocol) {
port = connector.getPort();
}
}
}
} catch (AttributeNotFoundException e) {
e.printStackTrace();
} catch (InstanceNotFoundException e) {
e.printStackTrace();
} catch (MBeanException e) {
e.printStackTrace();
} catch (ReflectionException e) {
e.printStackTrace();
}
} catch (MalformedObjectNameException e) {
e.printStackTrace();
}
return port;
}
use of com.bradmcevoy.http.http11.Http11Protocol in project tomcat70 by apache.
the class MBeanUtils method destroyMBean.
/**
* 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);
}
}
use of com.bradmcevoy.http.http11.Http11Protocol in project v7files by thiloplanz.
the class MiltonServlet method init.
@Override
public void init(ServletConfig config) throws ServletException {
String endpoint = config.getInitParameter("webdav.endpoint");
Properties ep = Configuration.getEndpointProperties(endpoint);
dbName = ep.getProperty("mongo.db");
try {
endpointProperties.set(ep);
super.init(config);
} finally {
endpointProperties.remove();
}
// http://stackoverflow.com/questions/8380324/
httpManager.getHandlers().setEnableExpectContinue(false);
handlers: for (HttpExtension x : httpManager.getHandlers()) {
if (x instanceof Http11Protocol) {
Http11Protocol p = (Http11Protocol) x;
for (Handler h : x.getHandlers()) {
if (h instanceof com.bradmcevoy.http.http11.GetHandler) {
httpManager.addFilter(0, new GetHandler(new DefaultWebDavResponseHandler(new AuthenticationService()), p.getHandlerHelper()));
break handlers;
}
}
}
}
}
Aggregations