server.java

来自「RESIN 3.2 最新源码」· Java 代码 · 共 1,876 行 · 第 1/3 页

JAVA
1,876
字号
  {    _clusterServer.setSocketTimeout(period);  }  /**   * Gets the read timeout for the request sockets.   */  public long getSocketTimeout()  {    return _clusterServer.getSocketTimeout();  }  /**   * Sets the maximum thread-based keepalive   */  public void setThreadMax(int max)  {    if (max < 0)      throw new ConfigException(L.l("<thread-max> ({0}) must be greater than zero.",				    max));        _threadMax = max;  }  /**   * Sets the maximum executor (background) thread.   */  public void setThreadExecutorTaskMax(int max)  {    _threadExecutorTaskMax = max;  }  /**   * Sets the minimum number of idle threads in the thread pool.   */  public void setThreadIdleMin(int min)  {    _threadIdleMin = min;  }  /**   * Sets the maximum number of idle threads in the thread pool.   */  public void setThreadIdleMax(int max)  {    _threadIdleMax = max;  }  //  // Configuration from <cluster>  //  /**   * Sets the connection error page.   */  public void setConnectionErrorPage(String errorPage)  {    _connectionErrorPage = errorPage;  }  /**   * Gets the connection error page.   */  public String getConnectionErrorPage()  {    return _connectionErrorPage;  }  /**   * Return true if idle.   */  public boolean isDeployError()  {    return _configException != null;  }  /**   * Returns the relax schema.   */  public String getSchema()  {    return "com/caucho/server/resin/cluster.rnc";  }  /**   * Returns the id.   */  public String getServerId()  {    return _clusterServer.getId();  }  /**   * Sets the root directory.   */  public void setRootDirectory(Path path)  {    _hostContainer.setRootDirectory(path);    Vfs.setPwd(path, _classLoader);  }  /**   * Sets the root directory.   */  public Path getRootDirectory()  {    return _hostContainer.getRootDirectory();  }  /**   * Sets the root directory.   */  public void setRootDir(Path path)  {    setRootDirectory(path);  }  /**   * Sets the server header.   */  public void setServerHeader(String server)  {    _serverHeader = server;  }  /**   * Gets the server header.   */  public String getServerHeader()  {    return _serverHeader;  }  /**   * Sets the url-length-max   */  public void setUrlLengthMax(int max)  {    _urlLengthMax = max;  }  /**   * Gets the url-length-max   */  public int getUrlLengthMax()  {    return _urlLengthMax;  }  /**   * Adds a WebAppDefault.   */  public void addWebAppDefault(WebAppConfig init)  {    _hostContainer.addWebAppDefault(init);  }  /**   * Adds an EarDefault   */  public void addEarDefault(EarConfig config)  {    _hostContainer.addEarDefault(config);  }  /**   * Adds a HostDefault.   */  public void addHostDefault(HostConfig init)  {    _hostContainer.addHostDefault(init);  }  /**   * Adds a HostDeploy.   */  public HostExpandDeployGenerator createHostDeploy()  {    return _hostContainer.createHostDeploy();  }  /**   * Adds a HostDeploy.   */  public void addHostDeploy(HostExpandDeployGenerator deploy)  {    _hostContainer.addHostDeploy(deploy);  }  /**   * Adds the host.   */  public void addHost(HostConfig host)    throws Exception  {    _hostContainer.addHost(host);  }  /**   * Returns the cluster.   */  public Cluster getCluster()  {    return _clusterServer.getCluster();  }  /**   * Adds rewrite-dispatch.   */  public RewriteDispatch createRewriteDispatch()  {    return _hostContainer.createRewriteDispatch();  }  /**   * Adds the cache.   */  public AbstractCache createCache()    throws ConfigException  {    log.warning(L.l("<cache> requires Resin Professional.  Please see http://www.caucho.com for Resin Professional information and licensing."));        return new AbstractCache();  }  /**   * Sets the access log.   */  public void setAccessLog(AccessLog log)  {    _accessLog = log;    Environment.setAttribute("caucho.server.access-log", log);  }  /**   * Returns the dependency check interval.   */  public long getDependencyCheckInterval()  {    return Environment.getDependencyCheckInterval(getClassLoader());  }  /**   * Sets the session cookie   */  public void setSessionCookie(String cookie)  {    getInvocationDecoder().setSessionCookie(cookie);  }  /**   * Gets the session cookie   */  public String getSessionCookie()  {    return getInvocationDecoder().getSessionCookie();  }  /**   * Sets the ssl session cookie   */  public void setSSLSessionCookie(String cookie)  {    getInvocationDecoder().setSSLSessionCookie(cookie);  }  /**   * Gets the ssl session cookie   */  public String getSSLSessionCookie()  {    return getInvocationDecoder().getSSLSessionCookie();  }  /**   * Sets the session url prefix.   */  public void setSessionURLPrefix(String urlPrefix)  {    getInvocationDecoder().setSessionURLPrefix(urlPrefix);  }  /**   * Gets the session url prefix.   */  public String getSessionURLPrefix()  {    return getInvocationDecoder().getSessionURLPrefix();  }  /**   * Sets the alternate session url prefix.   */  public void setAlternateSessionURLPrefix(String urlPrefix)    throws ConfigException  {    getInvocationDecoder().setAlternateSessionURLPrefix(urlPrefix);  }  /**   * Gets the alternate session url prefix.   */  public String getAlternateSessionURLPrefix()  {    return getInvocationDecoder().getAlternateSessionURLPrefix();  }  /**   * Sets URL encoding.   */  public void setURLCharacterEncoding(String encoding)    throws ConfigException  {    getInvocationDecoder().setEncoding(encoding);  }  /**   * Creates the ping.   */  public Object createPing()    throws ConfigException  {    return createManagement().createPing();  }  /**   * Adds the ping.   */  public void addPing(Object ping)    throws ConfigException  {    createManagement().addPing(ping);  }  /**   * Sets true if the select manager should be enabled   */  @Override  public boolean isSelectManagerEnabled()  {    return getSelectManager() != null;  }  public void addSelectManager(SelectManagerCompat selectManager)  {  }  /**   * Returns the number of select keepalives available.   */  public int getFreeKeepaliveSelect()  {    AbstractSelectManager selectManager = getSelectManager();    if (selectManager != null)      return selectManager.getFreeKeepalive();    else      return Integer.MAX_VALUE / 2;  }  /**   * Adds an error page   */  public void addErrorPage(ErrorPage errorPage)  {    getErrorWebApp().addErrorPage(errorPage);  }  //  // cluster server information  //  public int getServerIndex()  {    return _clusterServer.getIndex();  }  //  // statistics  //  /**   * Returns the time the server started in ms.   */  public long getStartTime()  {    return _startTime;  }  /**   * Returns the lifecycle state   */  public String getState()  {    return _lifecycle.getStateName();  }  /**   * Returns the select keepalive count.   */  public int getKeepaliveSelectCount()  {    AbstractSelectManager selectManager = getSelectManager();    if (selectManager != null)      return selectManager.getSelectCount();    else      return -1;  }  /**   * Returns the cache stuff.   */  public ArrayList<CacheItem> getCacheStatistics()  {    ArrayList<Invocation> invocationList = getInvocations();    if (invocationList == null)      return null;    HashMap<String,CacheItem> itemMap = new HashMap<String,CacheItem>();    for (int i = 0; i < invocationList.size(); i++) {      Invocation inv = (Invocation) invocationList.get(i);      String uri = inv.getURI();      int p = uri.indexOf('?');      if (p >= 0)        uri = uri.substring(0, p);      CacheItem item = itemMap.get(uri);      if (item == null) {        item = new CacheItem();        item.setUrl(uri);        itemMap.put(uri, item);      }    }    return null;  }  //  // runtime operations  //  /**   * Sets the invocation   */  public Invocation buildInvocation(Invocation invocation)    throws Throwable  {    if (_configException != null) {      invocation.setFilterChain(new ExceptionFilterChain(_configException));      invocation.setWebApp(getErrorWebApp());      invocation.setDependency(AlwaysModified.create());            return invocation;    }    else if (_lifecycle.waitForActive(_waitForActiveTime)) {      return _hostContainer.buildInvocation(invocation);    }    else {      int code = HttpServletResponse.SC_SERVICE_UNAVAILABLE;      invocation.setFilterChain(new ErrorFilterChain(code));      invocation.setWebApp(getErrorWebApp());      invocation.setDependency(AlwaysModified.create());      return invocation;    }  }  /**   * Returns the matching servlet pattern for a URL.   */  public String getServletPattern(String hostName, int port, String url)  {    try {      Host host = _hostContainer.getHost(hostName, port);      if (host == null)        return null;      WebApp app = host.findWebAppByURI(url);      if (app == null)        return null;      String pattern = app.getServletPattern(url);      return pattern;    } catch (Throwable e) {      log.log(Level.WARNING, e.toString(), e);      return null;    }  }  /**   * Returns the admin.   */  public ServerMXBean getAdmin()  {    return _admin;  }  /**   * Returns the default web-app or error web-app for top-level errors   */  public WebApp getDefaultWebApp()  {    WebApp webApp = getWebApp("", 80, "");    if (webApp != null)      return webApp;    else      return getErrorWebApp();  }    /**   * Returns the matching web-app for a URL.   */  public WebApp getWebApp(String hostName, int port, String url)  {    try {      HostContainer hostContainer = _hostContainer;      if (hostContainer == null)        return null;      Host host = hostContainer.getHost(hostName, port);      if (host == null)        return null;      return host.findWebAppByURI(url);    } catch (Throwable e) {      log.log(Level.WARNING, e.toString(), e);      return null;    }  }  /**   * Returns the error webApp during startup.   */  public WebApp getErrorWebApp()  {    HostContainer hostContainer = _hostContainer;    if (hostContainer != null)      return hostContainer.getErrorWebApp();    else      return null;  }  /**   * Returns the host controllers.   */  public Collection<HostController> getHostControllers()  {    HostContainer hostContainer = _hostContainer;    if (hostContainer == null)      return Collections.emptyList();    return Collections.unmodifiableList(hostContainer.getHostList());  }  /**   * Returns the matching servlet pattern for a URL.   */  public Host getHost(String hostName, int port)  {    try {      return _hostContainer.getHost(hostName, port);    } catch (Throwable e) {      log.log(Level.WARNING, e.toString(), e);      return null;    }  }  /**   * If true, ports are bound at end.   */  public void setBindPortsAfterStart(boolean bindAtEnd)  {    _isBindPortsAtEnd = bindAtEnd;  }  /**   * If true, ports are bound at end.   */  public boolean isBindPortsAfterStart()  {    return _isBindPortsAtEnd;  }  /**   * Returns the {@link Port}s for this server.   */  public Collection<Port> getPorts()  {    return Collections.unmodifiableList(_clusterServer.getPorts());  }  /**   * Handles the case where a class loader is activated.   */  public void classLoaderInit(DynamicClassLoader loader)  {    try {      //Jmx.register(_controller.getThreadPool(), "resin:type=ThreadPool");    } catch (Exception e) {      log.log(Level.WARNING, e.toString(), e);    }  }  /**   * Handles the case where a class loader is dropped.   */

⌨️ 快捷键说明

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