⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ajpaprprotocol.java

📁 业界著名的tomcat服务器的最新6.0的源代码。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    }
    
    public int getThreadPriority() {
        return ep.getThreadPriority();
    }
    

    public int getBacklog() {
        return ep.getBacklog();
    }


    public void setBacklog( int i ) {
        ep.setBacklog(i);
        setAttribute("backlog", "" + i);
    }


    public int getPort() {
        return ep.getPort();
    }


    public void setPort( int port ) {
        ep.setPort(port);
        setAttribute("port", "" + port);
    }


    public boolean getUseSendfile() {
        return ep.getUseSendfile();
    }


    public void setUseSendfile(boolean useSendfile) {
        // No sendfile for AJP
    }


    public InetAddress getAddress() {
        return ep.getAddress();
    }


    public void setAddress(InetAddress ia) {
        ep.setAddress(ia);
        setAttribute("address", "" + ia);
    }


    public String getName() {
        String encodedAddr = "";
        if (getAddress() != null) {
            encodedAddr = "" + getAddress();
            if (encodedAddr.startsWith("/"))
                encodedAddr = encodedAddr.substring(1);
            encodedAddr = URLEncoder.encode(encodedAddr) + "-";
        }
        return ("ajp-" + encodedAddr + ep.getPort());
    }


    public boolean getTcpNoDelay() {
        return ep.getTcpNoDelay();
    }


    public void setTcpNoDelay(boolean b) {
        ep.setTcpNoDelay(b);
        setAttribute("tcpNoDelay", "" + b);
    }


    public boolean getTomcatAuthentication() {
        return tomcatAuthentication;
    }


    public void setTomcatAuthentication(boolean tomcatAuthentication) {
        this.tomcatAuthentication = tomcatAuthentication;
    }


    public int getFirstReadTimeout() {
        return ep.getFirstReadTimeout();
    }


    public void setFirstReadTimeout(int i) {
        ep.setFirstReadTimeout(i);
        setAttribute("firstReadTimeout", "" + i);
    }


    public int getPollTime() {
        return ep.getPollTime();
    }


    public void setPollTime(int i) {
        ep.setPollTime(i);
        setAttribute("pollTime", "" + i);
    }


    public void setPollerSize(int i) {
        ep.setPollerSize(i); 
        setAttribute("pollerSize", "" + i);
    }


    public int getPollerSize() {
        return ep.getPollerSize();
    }


    public int getSoLinger() {
        return ep.getSoLinger();
    }


    public void setSoLinger(int i) {
        ep.setSoLinger(i);
        setAttribute("soLinger", "" + i);
    }


    public int getSoTimeout() {
        return ep.getSoTimeout();
    }


    public void setSoTimeout( int i ) {
        ep.setSoTimeout(i);
        setAttribute("soTimeout", "" + i);
    }

    
    public void setRequiredSecret(String requiredSecret) {
        this.requiredSecret = requiredSecret;
    }
    
    
    public int getPacketSize() {
        return packetSize;
    }


    public void setPacketSize(int i) {
        packetSize = i;
    }

    public int getKeepAliveTimeout() {
        return ep.getKeepAliveTimeout();
    }


    public void setKeepAliveTimeout( int i ) {
        ep.setKeepAliveTimeout(i);
        setAttribute("keepAliveTimeout", "" + i);
    }


    // --------------------------------------  AjpConnectionHandler Inner Class


    protected static class AjpConnectionHandler implements Handler {
        protected AjpAprProtocol proto;
        protected static int count = 0;
        protected RequestGroupInfo global=new RequestGroupInfo();
        protected ThreadLocal<AjpAprProcessor> localProcessor = new ThreadLocal<AjpAprProcessor>();

        public AjpConnectionHandler(AjpAprProtocol proto) {
            this.proto = proto;
        }

        // FIXME: Support for this could be added in AJP as well
        public SocketState event(long socket, SocketStatus status) {
            return SocketState.CLOSED;
        }
        
        public SocketState process(long socket) {
            AjpAprProcessor processor = null;
            try {
                processor = localProcessor.get();
                if (processor == null) {
                    processor = new AjpAprProcessor(proto.packetSize, proto.ep);
                    processor.setAdapter(proto.adapter);
                    processor.setTomcatAuthentication(proto.tomcatAuthentication);
                    processor.setRequiredSecret(proto.requiredSecret);
                    localProcessor.set(processor);
                    if (proto.getDomain() != null) {
                        synchronized (this) {
                            try {
                                RequestInfo rp = processor.getRequest().getRequestProcessor();
                                rp.setGlobalProcessor(global);
                                ObjectName rpName = new ObjectName
                                    (proto.getDomain() + ":type=RequestProcessor,worker="
                                        + proto.getName() + ",name=AjpRequest" + count++ );
                                Registry.getRegistry(null, null)
                                    .registerComponent(rp, rpName, null);
                            } catch (Exception ex) {
                                log.warn(sm.getString("ajpprotocol.request.register"));
                            }
                        }
                    }
                }

                if (processor instanceof ActionHook) {
                    ((ActionHook) processor).action(ActionCode.ACTION_START, null);
                }

                if (processor.process(socket)) {
                    return SocketState.OPEN;
                } else {
                    return SocketState.CLOSED;
                }

            } catch(java.net.SocketException e) {
                // SocketExceptions are normal
                AjpAprProtocol.log.debug
                    (sm.getString
                     ("ajpprotocol.proto.socketexception.debug"), e);
            } catch (java.io.IOException e) {
                // IOExceptions are normal
                AjpAprProtocol.log.debug
                    (sm.getString
                     ("ajpprotocol.proto.ioexception.debug"), e);
            }
            // Future developers: if you discover any other
            // rare-but-nonfatal exceptions, catch them here, and log as
            // above.
            catch (Throwable e) {
                // any other exception or error is odd. Here we log it
                // with "ERROR" level, so it will show up even on
                // less-than-verbose logs.
                AjpAprProtocol.log.error
                    (sm.getString("ajpprotocol.proto.error"), e);
            } finally {
                if (processor instanceof ActionHook) {
                    ((ActionHook) processor).action(ActionCode.ACTION_STOP, null);
                }
            }
            return SocketState.CLOSED;
        }
    }


    // -------------------- Various implementation classes --------------------


    protected String domain;
    protected ObjectName oname;
    protected MBeanServer mserver;

    public ObjectName getObjectName() {
        return oname;
    }

    public String getDomain() {
        return domain;
    }

    public ObjectName preRegister(MBeanServer server,
                                  ObjectName name) throws Exception {
        oname=name;
        mserver=server;
        domain=name.getDomain();
        return name;
    }

    public void postRegister(Boolean registrationDone) {
    }

    public void preDeregister() throws Exception {
    }

    public void postDeregister() {
    }
    
 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -