当前位置: 首页>>代码示例>>Java>>正文


Java ServletHandler.getServlets方法代码示例

本文整理汇总了Java中org.eclipse.jetty.servlet.ServletHandler.getServlets方法的典型用法代码示例。如果您正苦于以下问题:Java ServletHandler.getServlets方法的具体用法?Java ServletHandler.getServlets怎么用?Java ServletHandler.getServlets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jetty.servlet.ServletHandler的用法示例。


在下文中一共展示了ServletHandler.getServlets方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeServlet

import org.eclipse.jetty.servlet.ServletHandler; //导入方法依赖的package包/类
/**
 * Removes the previously registered servlets of the specified class
 * 
 * @param servlet
 *            the servlet class
 * @throws WebServerException
 *             if an error occurs
 */
public synchronized static void removeServlet(Class<? extends Servlet> servlet) throws WebServerException {
	if (contexts != null) {
		ServletHandler handler = contexts.getServletHandler();
		if (handler != null) {
			for (ServletHolder sh : handler.getServlets()) {
				Servlet s;
				try {
					s = sh.getServlet();
				} catch (ServletException e) {
					throw new WebServerException(e);
				}
				if (servlet.isInstance(s)) {
					removeServlet(sh);
				}
			}
		}
	}
}
 
开发者ID:sfera-labs,项目名称:sfera,代码行数:27,代码来源:WebServer.java

示例2: unregisterHandler

import org.eclipse.jetty.servlet.ServletHandler; //导入方法依赖的package包/类
@Override
public void unregisterHandler(ServletHolder servlet) {
    synchronized(lock) {
        ServletHandler servletHandler = rootContextHandler.getServletHandler();

        ServletHolder[] curServlets = servletHandler.getServlets();
        List<ServletHolder> newServlets = new ArrayList<>();
        newServlets.addAll(Arrays.asList(curServlets));
        if(!newServlets.remove(servlet)) {
            throw new IllegalArgumentException("Servlet not registered");
        }

        List<ServletMapping> newMappings = new ArrayList<>();
        newMappings.addAll(Arrays.asList(servletHandler.getServletMappings()));
        for(Iterator<ServletMapping> it = newMappings.iterator(); it.hasNext(); ) {
            ServletMapping m = it.next();
            if(servlet.getName().equals(m.getServletName())) {
                for(String path : m.getPathSpecs()) {
                    registeredPaths.remove(path);
                }
                it.remove();
                break;
            }
        }

        servletHandler.setServlets(newServlets.toArray(new ServletHolder[newServlets.size()]));
        servletHandler.setServletMappings(newMappings.toArray(new ServletMapping[newMappings.size()]));

        if(!servlet.isStopped()) {
            try {
                servlet.stop();
            }
            catch(Exception e) {
                throw new HttpConductorException(e);
            }
        }
    }
}
 
开发者ID:jaytaylor,项目名称:sql-layer,代码行数:39,代码来源:HttpConductorImpl.java

示例3: undeployServlet

import org.eclipse.jetty.servlet.ServletHandler; //导入方法依赖的package包/类
public synchronized void undeployServlet(HttpServlet servlet)
{
    try
    {
        // there is no removeServlet method so we need to do it manually
        ServletHandler handler = servletHandler.getServletHandler();
        
        // first collect servlets we want to keep
        List<ServletHolder> servlets = new ArrayList<ServletHolder>();
        String nameToRemove = null;
        for( ServletHolder holder : handler.getServlets() )
        {
            if (holder.getServlet() != servlet)
                servlets.add(holder);
            else
                nameToRemove = holder.getName();
        }

        if (nameToRemove == null)
            return;
        
        // also update servlet path mappings
        List<ServletMapping> mappings = new ArrayList<ServletMapping>();
        for (ServletMapping mapping : handler.getServletMappings())
        {
            if (!nameToRemove.contains(mapping.getServletName()))
                mappings.add(mapping);
        }

        // set the new configuration
        handler.setServletMappings( mappings.toArray(new ServletMapping[0]) );
        handler.setServlets( servlets.toArray(new ServletHolder[0]) );
    }
    catch (ServletException e)
    {
        log.error("Error while undeploying servlet", e);
    }       
}
 
开发者ID:sensiasoft,项目名称:sensorhub,代码行数:39,代码来源:HttpServer.java


注:本文中的org.eclipse.jetty.servlet.ServletHandler.getServlets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。