📄 coyoteconnector.java
字号:
* @param enableLookups The new "enable DNS lookups" flag value */ public void setEnableLookups(boolean enableLookups) { this.enableLookups = enableLookups; } /** * Return the server socket factory used by this Container. */ public ServerSocketFactory getFactory() { if (this.factory == null) { synchronized (this) { this.factory = new DefaultServerSocketFactory(); } } return (this.factory); } /** * Set the server socket factory used by this Container. * * @param factory The new server socket factory */ public void setFactory(ServerSocketFactory factory) { this.factory = factory; } /** * Return descriptive information about this Connector implementation. */ public String getInfo() { return (info); } /** * Return the minimum number of processors to start at initialization. */ public int getMinProcessors() { return (minProcessors); } /** * Set the minimum number of processors to start at initialization. * * @param minProcessors The new minimum processors */ public void setMinProcessors(int minProcessors) { this.minProcessors = minProcessors; } /** * Return the maximum number of processors allowed, or <0 for unlimited. */ public int getMaxProcessors() { return (maxProcessors); } /** * Set the maximum number of processors allowed, or <0 for unlimited. * * @param maxProcessors The new maximum processors */ public void setMaxProcessors(int maxProcessors) { this.maxProcessors = maxProcessors; } /** * Return the port number on which we listen for requests. */ public int getPort() { return (this.port); } /** * Set the port number on which we listen for requests. * * @param port The new port number */ public void setPort(int port) { this.port = port; } /** * Return the class name of the Coyote protocol handler in use. */ public String getProtocolHandlerClassName() { return (this.protocolHandlerClassName); } /** * Set the class name of the Coyote protocol handler which will be used * by the connector. * * @param protocolHandlerClassName The new class name */ public void setProtocolHandlerClassName(String protocolHandlerClassName) { this.protocolHandlerClassName = protocolHandlerClassName; } /** * Return the proxy server name for this Connector. */ public String getProxyName() { return (this.proxyName); } /** * Set the proxy server name for this Connector. * * @param proxyName The new proxy server name */ public void setProxyName(String proxyName) { if(! "".equals(proxyName) ) { this.proxyName = proxyName; } else { this.proxyName = null; } } /** * Return the proxy server port for this Connector. */ public int getProxyPort() { return (this.proxyPort); } /** * Set the proxy server port for this Connector. * * @param proxyPort The new proxy server port */ public void setProxyPort(int proxyPort) { this.proxyPort = proxyPort; } /** * Return the port number to which a request should be redirected if * it comes in on a non-SSL port and is subject to a security constraint * with a transport guarantee that requires SSL. */ public int getRedirectPort() { return (this.redirectPort); } /** * Set the redirect port number. * * @param redirectPort The redirect port number (non-SSL to SSL) */ public void setRedirectPort(int redirectPort) { this.redirectPort = redirectPort; } /** * Return the flag that specifies upload time-out behavior. */ public boolean getDisableUploadTimeout() { return disableUploadTimeout; } /** * Set the flag to specify upload time-out behavior. * * @param isDisabled If <code>true</code>, then the <code>timeout</code> * parameter is ignored. If <code>false</code>, then the * <code>timeout</code> parameter is used to control uploads. */ public void setDisableUploadTimeout( boolean isDisabled ) { disableUploadTimeout = isDisabled; } /** * Return the maximum number of Keep-Alive requests to honor per connection. */ public int getMaxKeepAliveRequests() { return maxKeepAliveRequests; } /** * Set the maximum number of Keep-Alive requests to honor per connection. */ public void setMaxKeepAliveRequests(int mkar) { maxKeepAliveRequests = mkar; } /** * Return the scheme that will be assigned to requests received * through this connector. Default value is "http". */ public String getScheme() { return (this.scheme); } /** * Set the scheme that will be assigned to requests received through * this connector. * * @param scheme The new scheme */ public void setScheme(String scheme) { this.scheme = scheme; } /** * Return the secure connection flag that will be assigned to requests * received through this connector. Default value is "false". */ public boolean getSecure() { return (this.secure); } /** * Set the secure connection flag that will be assigned to requests * received through this connector. * * @param secure The new secure connection flag */ public void setSecure(boolean secure) { this.secure = secure; } /** * Return the TCP no delay flag value. */ public boolean getTcpNoDelay() { return (this.tcpNoDelay); } /** * Set the TCP no delay flag which will be set on the socket after * accepting a connection. * * @param tcpNoDelay The new TCP no delay flag */ public void setTcpNoDelay(boolean tcpNoDelay) { this.tcpNoDelay = tcpNoDelay; } /** * Return the value of the Uri validation flag. */ public boolean getUseURIValidationHack() { return (this.useURIValidationHack); } /** * Set the value of the Uri validation flag. * * @param useURIValidationHack The new flag value */ public void setUseURIValidationHack(boolean useURIValidationHack) { this.useURIValidationHack = useURIValidationHack; } // --------------------------------------------------------- Public Methods /** * Create (or allocate) and return a Request object suitable for * specifying the contents of a Request to the responsible Container. */ public Request createRequest() { CoyoteRequest request = new CoyoteRequest(); request.setConnector(this); return (request); } /** * Create (or allocate) and return a Response object suitable for * receiving the contents of a Response from the responsible Container. */ public Response createResponse() { CoyoteResponse response = new CoyoteResponse(); response.setConnector(this); return (response); } // -------------------------------------------------------- Private Methods /** * Log a message on the Logger associated with our Container (if any). * * @param message Message to be logged */ private void log(String message) { Logger logger = container.getLogger(); String localName = "CoyoteConnector"; if (logger != null) logger.log(localName + " " + message); else System.out.println(localName + " " + message); } /** * Log a message on the Logger associated with our Container (if any). * * @param message Message to be logged * @param throwable Associated exception */ private void log(String message, Throwable throwable) { Logger logger = container.getLogger(); String localName = "CoyoteConnector"; if (logger != null) logger.log(localName + " " + message, throwable); else { System.out.println(localName + " " + message); throwable.printStackTrace(System.out); } } // ------------------------------------------------------ Lifecycle Methods /** * Add a lifecycle event listener to this component. * * @param listener The listener to add */ public void addLifecycleListener(LifecycleListener listener) { lifecycle.addLifecycleListener(listener); } /** * Get the lifecycle listeners associated with this lifecycle. If this * Lifecycle has no listeners registered, a zero-length array is returned. */ public LifecycleListener[] findLifecycleListeners() { return null;//lifecycle.findLifecycleListeners(); } /** * Remove a lifecycle event listener from this component. * * @param listener The listener to add */ public void removeLifecycleListener(LifecycleListener listener) { lifecycle.removeLifecycleListener(listener); } /** * Initialize this connector (create ServerSocket here!) */ public void initialize() throws LifecycleException { if (initialized) throw new LifecycleException (sm.getString("coyoteConnector.alreadyInitialized")); this.initialized = true; // Initializa adapter adapter = new CoyoteAdapter(this); // Instantiate protocol handler try { Class clazz = Class.forName(protocolHandlerClassName); protocolHandler = (ProtocolHandler) clazz.newInstance(); } catch (Exception e) { e.printStackTrace(); throw new LifecycleException (sm.getString ("coyoteConnector.protocolHandlerInstantiationFailed", e)); } protocolHandler.setAdapter(adapter); IntrospectionUtils.setProperty(protocolHandler, "jkHome", System.getProperty("catalina.base")); // Set attributes IntrospectionUtils.setProperty(protocolHandler, "port", "" + port); IntrospectionUtils.setProperty(protocolHandler, "maxThreads", "" + maxProcessors); IntrospectionUtils.setProperty(protocolHandler, "backlog", "" + acceptCount); IntrospectionUtils.setProperty(protocolHandler, "tcpNoDelay", "" + tcpNoDelay); IntrospectionUtils.setProperty(protocolHandler, "soLinger", "" + connectionLinger); IntrospectionUtils.setProperty(protocolHandler, "soTimeout", "" + connectionTimeout); IntrospectionUtils.setProperty(protocolHandler, "timeout", "" + connectionTimeout); IntrospectionUtils.setProperty(protocolHandler, "disableUploadTimeout", "" + disableUploadTimeout); IntrospectionUtils.setProperty(protocolHandler, "maxKeepAliveRequests", "" + maxKeepAliveRequests); IntrospectionUtils.setProperty(protocolHandler, "compression", compression); if (address != null) { IntrospectionUtils.setProperty(protocolHandler, "address", address); } // Configure secure socket factory if (factory instanceof CoyoteServerSocketFactory) { IntrospectionUtils.setProperty(protocolHandler, "secure", "" + true); CoyoteServerSocketFactory ssf = (CoyoteServerSocketFactory) factory; IntrospectionUtils.setProperty(protocolHandler, "algorithm", ssf.getAlgorithm()); if (ssf.getClientAuth()) { IntrospectionUtils.setProperty(protocolHandler, "clientauth", "" + ssf.getClientAuth()); } IntrospectionUtils.setProperty(protocolHandler, "keystore", ssf.getKeystoreFile()); IntrospectionUtils.setProperty(protocolHandler, "randomfile", ssf.getRandomFile()); IntrospectionUtils.setProperty(protocolHandler, "rootfile", ssf.getRootFile()); IntrospectionUtils.setProperty(protocolHandler, "keypass", ssf.getKeystorePass()); IntrospectionUtils.setProperty(protocolHandler, "keytype", ssf.getKeystoreType()); IntrospectionUtils.setProperty(protocolHandler, "protocol", ssf.getProtocol()); IntrospectionUtils.setProperty(protocolHandler, "sSLImplementation", ssf.getSSLImplementation()); } else { IntrospectionUtils.setProperty(protocolHandler, "secure", "" + false); } try { protocolHandler.init(); } catch (Exception e) { throw new LifecycleException (sm.getString ("coyoteConnector.protocolHandlerInitializationFailed", e)); } } /** * Begin processing requests via this Connector. * * @exception LifecycleException if a fatal startup error occurs */ public void start() throws LifecycleException { // Validate and update our current state if (started) throw new LifecycleException (sm.getString("coyoteConnector.alreadyStarted")); lifecycle.fireLifecycleEvent(START_EVENT, null); started = true; try { protocolHandler.start(); } catch (Exception e) { throw new LifecycleException (sm.getString ("coyoteConnector.protocolHandlerStartFailed", e)); } } /** * Terminate processing requests via this Connector. * * @exception LifecycleException if a fatal shutdown error occurs */ public void stop() throws LifecycleException { // Validate and update our current state if (!started) throw new LifecycleException (sm.getString("coyoteConnector.notStarted")); lifecycle.fireLifecycleEvent(STOP_EVENT, null); started = false; try { protocolHandler.destroy(); } catch (Exception e) { throw new LifecycleException (sm.getString ("coyoteConnector.protocolHandlerDestroyFailed", e)); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -