Java Code Examples for org.eclipse.jetty.servlet.FilterMapping#getServletNames()

The following examples show how to use org.eclipse.jetty.servlet.FilterMapping#getServletNames() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebMappingsRenderer.java    From dropwizard-guicey with MIT License 5 votes vote down vote up
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
private Multimap<String, FilterReference> renderContextFilters(final MappingsConfig config,
                                                               final MutableServletContextHandler handler,
                                                               final TreeNode root) throws Exception {
    final Multimap<String, FilterReference> servletFilters = LinkedHashMultimap.create();
    for (FilterMapping mapping : handler.getServletHandler().getFilterMappings()) {
        final FilterHolder holder = handler.getServletHandler().getFilter(mapping.getFilterName());
        // single filter instance used for both contexts and so the name is also the same
        final boolean isGuiceFilter = mapping.getFilterName().equals(GuiceWebModule.GUICE_FILTER);
        if ((isGuiceFilter && !config.isGuiceMappings())
                || !isAllowed(holder.getClassName(), config)) {
            continue;
        }
        if (mapping.getServletNames() != null && mapping.getServletNames().length > 0) {
            // filters targeting exact servlet are only remembered to be shown below target servlet
            for (String servlet : mapping.getServletNames()) {
                servletFilters.put(servlet, new FilterReference(mapping, holder));
            }
        } else {
            final TreeNode filter = renderFilter(mapping, holder, root);
            if (isGuiceFilter) {
                renderGuiceWeb(filter);
            }
        }
    }
    return servletFilters;
}
 
Example 2
Source File: WebMappingsRenderer.java    From dropwizard-guicey with MIT License 5 votes vote down vote up
private TreeNode renderFilter(final FilterMapping mapping,
                              final FilterHolder holder,
                              final TreeNode root) throws Exception {
    // required only guice filter
    TreeNode last = null;
    boolean first = true;
    final boolean servletMapping = mapping.getPathSpecs() == null || mapping.getPathSpecs().length == 0;
    for (String path : servletMapping ? mapping.getServletNames() : mapping.getPathSpecs()) {
        // indicate multiple urls or servlets mapping
        String type = IDEM;
        String async = "";
        String stopped = "";
        String dispatches = "";
        String name = "";
        if (first) {
            type = RenderUtils.renderClassLine(Class.forName(holder.getClassName()));
            if (holder.isStopped()) {
                stopped = STOPPED;
            }
            if (holder.isAsyncSupported()) {
                async = ASYNC;
            }
            dispatches = mapping.getDispatcherTypes().toString();
            name = mapping.getFilterName();
        }
        last = root.child("filter     %-20s %-7s %-70s %-10s    %-15s %s",
                servletMapping ? "" : path, async, type, stopped, dispatches, name);
        first = false;
    }
    return last;
}