Search in sources :

Example 1 with Http11Protocol

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;
}
Also used : Connector(org.apache.catalina.connector.Connector) ReflectionException(javax.management.ReflectionException) AttributeNotFoundException(javax.management.AttributeNotFoundException) MalformedObjectNameException(javax.management.MalformedObjectNameException) Http11NioProtocol(org.apache.coyote.http11.Http11NioProtocol) MBeanServer(javax.management.MBeanServer) Server(org.apache.catalina.Server) InstanceNotFoundException(javax.management.InstanceNotFoundException) Service(org.apache.catalina.Service) Http11AprProtocol(org.apache.coyote.http11.Http11AprProtocol) ObjectName(javax.management.ObjectName) ProtocolHandler(org.apache.coyote.ProtocolHandler) Http11Protocol(org.apache.coyote.http11.Http11Protocol) MBeanException(javax.management.MBeanException) MBeanServer(javax.management.MBeanServer)

Example 2 with Http11Protocol

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);
    }
}
Also used : ProtocolHandler(org.apache.coyote.ProtocolHandler) AjpProtocol(org.apache.coyote.ajp.AjpProtocol) Http11NioProtocol(org.apache.coyote.http11.Http11NioProtocol) Http11Protocol(org.apache.coyote.http11.Http11Protocol) Http11AprProtocol(org.apache.coyote.http11.Http11AprProtocol) AjpAprProtocol(org.apache.coyote.ajp.AjpAprProtocol) ObjectName(javax.management.ObjectName)

Example 3 with Http11Protocol

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;
                }
            }
        }
    }
}
Also used : DefaultWebDavResponseHandler(com.bradmcevoy.http.webdav.DefaultWebDavResponseHandler) Http11Protocol(com.bradmcevoy.http.http11.Http11Protocol) DefaultWebDavResponseHandler(com.bradmcevoy.http.webdav.DefaultWebDavResponseHandler) Handler(com.bradmcevoy.http.Handler) Properties(java.util.Properties) HttpExtension(com.bradmcevoy.http.HttpExtension) AuthenticationService(com.bradmcevoy.http.AuthenticationService)

Aggregations

ObjectName (javax.management.ObjectName)2 ProtocolHandler (org.apache.coyote.ProtocolHandler)2 Http11AprProtocol (org.apache.coyote.http11.Http11AprProtocol)2 Http11NioProtocol (org.apache.coyote.http11.Http11NioProtocol)2 Http11Protocol (org.apache.coyote.http11.Http11Protocol)2 AuthenticationService (com.bradmcevoy.http.AuthenticationService)1 Handler (com.bradmcevoy.http.Handler)1 HttpExtension (com.bradmcevoy.http.HttpExtension)1 Http11Protocol (com.bradmcevoy.http.http11.Http11Protocol)1 DefaultWebDavResponseHandler (com.bradmcevoy.http.webdav.DefaultWebDavResponseHandler)1 Properties (java.util.Properties)1 AttributeNotFoundException (javax.management.AttributeNotFoundException)1 InstanceNotFoundException (javax.management.InstanceNotFoundException)1 MBeanException (javax.management.MBeanException)1 MBeanServer (javax.management.MBeanServer)1 MalformedObjectNameException (javax.management.MalformedObjectNameException)1 ReflectionException (javax.management.ReflectionException)1 Server (org.apache.catalina.Server)1 Service (org.apache.catalina.Service)1 Connector (org.apache.catalina.connector.Connector)1