io.undertow.util.PathTemplate Java Examples

The following examples show how to use io.undertow.util.PathTemplate. 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: RoutingHandler.java    From quarkus-http with Apache License 2.0 6 votes vote down vote up
public synchronized RoutingHandler addAll(RoutingHandler routingHandler) {
    for (Entry<String, PathTemplateMatcher<RoutingMatch>> entry : routingHandler.getMatches().entrySet()) {
        String method = entry.getKey();
        PathTemplateMatcher<RoutingMatch> matcher = matches.get(method);
        if (matcher == null) {
            matches.put(method, matcher = new PathTemplateMatcher<>());
        }
        matcher.addAll(entry.getValue());
        // If we use allMethodsMatcher.addAll() we can have duplicate
        // PathTemplates which we want to ignore here so it does not crash.
        for (PathTemplate template : entry.getValue().getPathTemplates()) {
            if (allMethodsMatcher.get(template.getTemplateString()) == null) {
                allMethodsMatcher.add(template, new RoutingMatch());
            }
        }
    }
    return this;
}
 
Example #2
Source File: RoutingHandler.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public synchronized RoutingHandler addAll(RoutingHandler routingHandler) {
    for (Entry<HttpString, PathTemplateMatcher<RoutingMatch>> entry : routingHandler.getMatches().entrySet()) {
        HttpString method = entry.getKey();
        PathTemplateMatcher<RoutingMatch> matcher = matches.get(method);
        if (matcher == null) {
            matches.put(method, matcher = new PathTemplateMatcher<>());
        }
        matcher.addAll(entry.getValue());
        // If we use allMethodsMatcher.addAll() we can have duplicate
        // PathTemplates which we want to ignore here so it does not crash.
        for (PathTemplate template : entry.getValue().getPathTemplates()) {
            if (allMethodsMatcher.get(template.getTemplateString()) == null) {
                allMethodsMatcher.add(template, new RoutingMatch());
            }
        }
    }
    return this;
}
 
Example #3
Source File: ServerWebSocketContainer.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
@Override
public void addEndpoint(final ServerEndpointConfig endpoint) throws DeploymentException {
    if (deploymentComplete) {
        throw JsrWebSocketMessages.MESSAGES.cannotAddEndpointAfterDeployment();
    }
    JsrWebSocketLogger.ROOT_LOGGER.addingProgramaticEndpoint(endpoint.getEndpointClass(), endpoint.getPath());
    final PathTemplate template = PathTemplate.create(endpoint.getPath());
    if (seenPaths.contains(template)) {
        PathTemplate existing = null;
        for (PathTemplate p : seenPaths) {
            if (p.compareTo(template) == 0) {
                existing = p;
                break;
            }
        }
        throw JsrWebSocketMessages.MESSAGES.multipleEndpointsWithOverlappingPaths(template, existing);
    }
    seenPaths.add(template);
    EncodingFactory encodingFactory = EncodingFactory.createFactory(classIntrospecter, endpoint.getDecoders(), endpoint.getEncoders());

    AnnotatedEndpointFactory annotatedEndpointFactory = null;
    if (!Endpoint.class.isAssignableFrom(endpoint.getEndpointClass())) {
        // We may want to check that the path in @ServerEndpoint matches the specified path, and throw if they are not equivalent
        annotatedEndpointFactory = AnnotatedEndpointFactory.create(endpoint.getEndpointClass(), encodingFactory, template.getParameterNames());
    }
    ConfiguredServerEndpoint confguredServerEndpoint = new ConfiguredServerEndpoint(endpoint, null, template, encodingFactory, annotatedEndpointFactory, endpoint.getExtensions());
    configuredServerEndpoints.add(confguredServerEndpoint);
    handleAddingFilterMapping();
}
 
Example #4
Source File: ConfiguredServerEndpoint.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public ConfiguredServerEndpoint(final ServerEndpointConfig endpointConfiguration, final InstanceFactory<?> endpointFactory, final PathTemplate pathTemplate, final EncodingFactory encodingFactory, AnnotatedEndpointFactory annotatedEndpointFactory, List<Extension> installed) {
    this.endpointConfiguration = endpointConfiguration;
    this.endpointFactory = endpointFactory;
    this.pathTemplate = pathTemplate;
    this.encodingFactory = encodingFactory;
    this.annotatedEndpointFactory = annotatedEndpointFactory;
    this.extensions = installed;
}
 
Example #5
Source File: ConfiguredServerEndpoint.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public ConfiguredServerEndpoint(final ServerEndpointConfig endpointConfiguration, final InstanceFactory<?> endpointFactory, final PathTemplate pathTemplate, final EncodingFactory encodingFactory) {
    this.endpointConfiguration = endpointConfiguration;
    this.endpointFactory = endpointFactory;
    this.pathTemplate = pathTemplate;
    this.encodingFactory = encodingFactory;
    this.annotatedEndpointFactory = null;
    this.extensions = endpointConfiguration.getExtensions();
}
 
Example #6
Source File: CamelUndertowHostService.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
private String getBasePath(URI httpURI) {
    String path = httpURI.getPath();
    if (path.contains(REST_PATH_PLACEHOLDER)) {
        path = PathTemplate.create(path).getBase();
    }
    return URLUtils.normalizeSlashes(path);
}
 
Example #7
Source File: JsrWebSocketMessages.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
@Message(id = 3023, value = "Multiple endpoints with the same logical mapping %s and %s")
DeploymentException multipleEndpointsWithOverlappingPaths(PathTemplate template, PathTemplate existing);
 
Example #8
Source File: ConfiguredServerEndpoint.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
public PathTemplate getPathTemplate() {
    return pathTemplate;
}
 
Example #9
Source File: PathTemplatePredicate.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
public PathTemplatePredicate(final String template, final ExchangeAttribute attribute) {
    this.attribute = attribute;
    this.value = PathTemplate.create(template);
}
 
Example #10
Source File: PathTemplatePredicate.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public PathTemplatePredicate(final String template, final ExchangeAttribute attribute) {
    this.attribute = attribute;
    this.value = PathTemplate.create(template);
}