@Override public boolean test(String s) { return specs.getMatch(s)!=null; }
@Override public Iterator<String> iterator() { final Iterator<MappedResource<Boolean>> iterator = specs.iterator(); return new Iterator<String>() { @Override public boolean hasNext() { return iterator.hasNext(); } @Override public String next() { return iterator.next().getPathSpec().getDeclaration(); } }; } }
@Override public boolean add(String s) { return specs.put(PathMappings.asPathSpec(s),Boolean.TRUE); }
/** * Set up request logging and open log file. * * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart() */ @Override protected synchronized void doStart() throws Exception { if (_logDateFormat != null) { _logDateCache = new DateCache(_logDateFormat, _logLocale ,_logTimeZone); } if (_ignorePaths != null && _ignorePaths.length > 0) { _ignorePathMap = new PathMappings<>(); for (int i = 0; i < _ignorePaths.length; i++) _ignorePathMap.put(_ignorePaths[i], _ignorePaths[i]); } else _ignorePathMap = null; super.doStart(); }
/** * Manually add a WebSocket mapping. * * @param pathSpec the pathspec to respond on * @param endpointClass the endpoint class to use for new upgrade requests on the provided * pathspec (can be an {@link org.eclipse.jetty.websocket.api.annotations.WebSocket} annotated * POJO, or implementing {@link org.eclipse.jetty.websocket.api.WebSocketListener}) */ public void addMapping(PathSpec pathSpec, final Class<?> endpointClass) { mappings.put(pathSpec, (req, resp) -> { try { return endpointClass.getDeclaredConstructor().newInstance(); } catch (Exception e) { throw new WebSocketException("Unable to create instance of " + endpointClass.getName(), e); } }); }
@Override public void clear() { specs.reset(); }
@Override public int size() { return specs.size(); }
@Override public boolean remove(Object o) { return specs.remove(asPathSpec(o)); }
private PathSpec asPathSpec(Object o) { if (o == null) { return null; } if (o instanceof PathSpec) { return (PathSpec)o; } if (o instanceof String) { return PathMappings.asPathSpec((String)o); } return PathMappings.asPathSpec(o.toString()); }
@Override public void doStop() throws Exception { mappings.removeIf((mapped) -> !(mapped.getResource() instanceof PersistedWebSocketCreator)); super.doStop(); }
PathMappings<ServletHolder> pm = new PathMappings<>(); Map<String,ServletMapping> servletPathMappings = new HashMap<>(); pm.put(new ServletPathSpec(pathSpec),_servletNameMap.get(finalMapping.getServletName()));
/** * Manually add a WebSocket mapping. * <p> * If mapping is added before this configuration is started, then it is persisted through * stop/start of this configuration's lifecycle. Otherwise it will be removed when * this configuration is stopped. * </p> * * @param pathSpec the pathspec to respond on * @param creator the websocket creator to activate on the provided mapping. */ @Override public void addMapping(PathSpec pathSpec, WebSocketCreator creator) { WebSocketCreator wsCreator = creator; if (!isRunning()) { wsCreator = new PersistedWebSocketCreator(creator); } mappings.put(pathSpec, wsCreator); }
@Override public void clear() { specs.reset(); }
@Override public int size() { return specs.size(); }
@Override public boolean remove(Object o) { return specs.remove(asPathSpec(o)); }
private PathSpec asPathSpec(Object o) { if (o == null) { return null; } if (o instanceof PathSpec) { return (PathSpec)o; } if (o instanceof String) { return PathMappings.asPathSpec((String)o); } return PathMappings.asPathSpec(o.toString()); }
public boolean put(String pathSpecString, E resource) { return put(asPathSpec(pathSpecString),resource); }
/** * Get the matching {@link MappedResource} for the provided target. * * @param target the target path * @return the matching resource, or null if no match. */ public MappedResource<WebSocketCreator> getMatch(String target) { return this.mappings.getMatch(target); }
@Override public Iterator<String> iterator() { final Iterator<MappedResource<Boolean>> iterator = specs.iterator(); return new Iterator<String>() { @Override public boolean hasNext() { return iterator.hasNext(); } @Override public String next() { return iterator.next().getPathSpec().getDeclaration(); } }; } }
@Override public boolean add(String s) { return specs.put(PathMappings.asPathSpec(s),Boolean.TRUE); }