javax.servlet.Filter.destroy()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(377)

本文整理了Java中javax.servlet.Filter.destroy()方法的一些代码示例,展示了Filter.destroy()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Filter.destroy()方法的具体详情如下:
包路径:javax.servlet.Filter
类名称:Filter
方法名:destroy

Filter.destroy介绍

[英]Called by the web container to indicate to a filter that it is being taken out of service.

This method is only called once all threads within the filter's doFilter method have exited or after a timeout period has passed. After the web container calls this method, it will not call the doFilter method again on this instance of the filter.

This method gives the filter an opportunity to clean up any resources that are being held (for example, memory, file handles, threads) and make sure that any persistent state is synchronized with the filter's current state in memory.
[中]由web容器调用,以向筛选器指示它正在停止服务。
只有当过滤器的doFilter方法中的所有线程都已退出或超过超时时间后,才会调用此方法。在web容器调用此方法之后,它将不再对筛选器的此实例调用doFilter方法。
此方法使筛选器有机会清理所持有的任何资源(例如,内存、文件句柄、线程),并确保任何持久状态都与内存中筛选器的当前状态同步。

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
public void destroy() {
  this.delegate.destroy();
}

代码示例来源:origin: jenkinsci/jenkins

public void destroy() {
  // the filter can be null if the filter is not initialized yet.
  if(filter != null)
    filter.destroy();
}

代码示例来源:origin: jenkinsci/jenkins

public void destroy() {
  for (Filter f : filters)
    f.destroy();
}

代码示例来源:origin: apache/incubator-druid

@Override
 public void destroy()
 {
  delegate.destroy();
 }
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Clean up all the filters supplied, calling each one's destroy method in turn, but in reverse order.
 * @see Filter#init(FilterConfig)
 */
@Override
public void destroy() {
  for (int i = this.filters.size(); i-- > 0;) {
    Filter filter = this.filters.get(i);
    filter.destroy();
  }
}

代码示例来源:origin: Atmosphere/atmosphere

/**
 * Release the Filter instance associated with this FilterConfig,
 * if there is one.
 */
public void recycle() {
  if (this.filter != null) {
    filter.destroy();
  }
  this.filter = null;
}

代码示例来源:origin: jenkinsci/jenkins

public void destroy() {
  for (Filter f : list) {
    f.destroy();
  }
  list.clear();
}

代码示例来源:origin: geoserver/geoserver

public void destroy() {
  if (filters != null) {
    for (Filter f : filters) {
      f.destroy();
    }
    filters = null;
  }
}

代码示例来源:origin: nutzam/nutz

public void destroy() {
  if (proxy != null)
    proxy.destroy();
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Destroy the Filter delegate.
 * Default implementation simply calls {@code Filter.destroy} on it.
 * @param delegate the Filter delegate (never {@code null})
 * @see #isTargetFilterLifecycle()
 * @see javax.servlet.Filter#destroy()
 */
protected void destroyDelegate(Filter delegate) {
  if (isTargetFilterLifecycle()) {
    delegate.destroy();
  }
}

代码示例来源:origin: org.springframework/spring-web

/**
 * Clean up all the filters supplied, calling each one's destroy method in turn, but in reverse order.
 * @see Filter#init(FilterConfig)
 */
@Override
public void destroy() {
  for (int i = this.filters.size(); i-- > 0;) {
    Filter filter = this.filters.get(i);
    filter.destroy();
  }
}

代码示例来源:origin: org.springframework/spring-web

/**
 * Destroy the Filter delegate.
 * Default implementation simply calls {@code Filter.destroy} on it.
 * @param delegate the Filter delegate (never {@code null})
 * @see #isTargetFilterLifecycle()
 * @see javax.servlet.Filter#destroy()
 */
protected void destroyDelegate(Filter delegate) {
  if (isTargetFilterLifecycle()) {
    delegate.destroy();
  }
}

代码示例来源:origin: jenkinsci/jenkins

f.destroy();
} catch (RuntimeException e) {
  LOGGER.log(Level.WARNING, "Filter " + f + " propagated an exception from its destroy method",

代码示例来源:origin: igniterealtime/Openfire

filter.destroy();

代码示例来源:origin: jenkinsci/jenkins

/**
 * Reset the proxies and filter for a change in {@link SecurityRealm}.
 */
public void reset(SecurityRealm securityRealm) throws ServletException {
  if (securityRealm != null) {
    SecurityRealm.SecurityComponents sc = securityRealm.getSecurityComponents();
    AUTHENTICATION_MANAGER.setDelegate(sc.manager);
    USER_DETAILS_SERVICE_PROXY.setDelegate(sc.userDetails);
    REMEMBER_ME_SERVICES_PROXY.setDelegate(sc.rememberMe);
    // make sure this.filter is always a valid filter.
    Filter oldf = this.filter;
    Filter newf = securityRealm.createFilter(this.filterConfig);
    newf.init(this.filterConfig);
    this.filter = newf;
    if(oldf!=null)
      oldf.destroy();
  } else {
    // no security related filter needed.
    AUTHENTICATION_MANAGER.setDelegate(null);
    USER_DETAILS_SERVICE_PROXY.setDelegate(null);
    REMEMBER_ME_SERVICES_PROXY.setDelegate(null);
    filter = null;
  }
}

代码示例来源:origin: geoserver/geoserver

for (SecurityFilterChain chain : proxy.getFilterChains()) {
  for (Filter filter : chain.getFilters()) {
    filter.destroy();

代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel

@Override
protected void doPortalDestroy() {
  Thread currentThread = Thread.currentThread();
  ClassLoader contextClassLoader = currentThread.getContextClassLoader();
  try {
    currentThread.setContextClassLoader(
      PortalClassLoaderUtil.getClassLoader());
    _filter.destroy();
  }
  finally {
    currentThread.setContextClassLoader(contextClassLoader);
  }
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testLifeCycle() throws ServletException {
  Filter filter = makeFilter();
  try {
    filter.init(makeFilterConfig());
  }
  finally {
    filter.destroy();
  }
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testFilterBasic() throws ServletException, IOException {
  Filter filter = makeFilter();
  try {
    filter.init(makeFilterConfig());
    filter.doFilter(makeRequest(), makeResponse(), makeFilterChain());
  }
  finally {
    filter.destroy();
  }
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testInit() {
  Filter filter = makeFilter();
  try {
    filter.init(makeFilterConfig());
  }
  catch (ServletException e) {
    assertNotNull(e.getMessage());
  }
  finally {
    filter.destroy();
  }
}

相关文章

微信公众号

最新文章

更多