Java Code Examples for io.undertow.attribute.ExchangeAttributes#parser()

The following examples show how to use io.undertow.attribute.ExchangeAttributes#parser() . 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: JsonLogFormatter.java    From digdag with Apache License 2.0 6 votes vote down vote up
public static ExchangeAttribute buildExchangeAttribute(String pattern, ClassLoader classLoader)
{
    if (pattern.equals("json")) {
        pattern = DEFAULT_PATTERN;
    }

    String body = pattern.substring("json{".length(), pattern.length() - "}".length());

    Map<String, ExchangeAttribute> map = new LinkedHashMap<>();
    ExchangeAttributeParser parser = ExchangeAttributes.parser(classLoader);

    String[] kvs = body.split(" ");
    for (String kv : kvs) {
        String[] fragments = kv.split(":", 2);
        if (fragments.length != 2) {
            throw new IllegalArgumentException("JSON access log pattern includes an invalid fragment: " + kv);
        }
        String key = fragments[0];
        String value = fragments[1];

        map.put(key, parser.parse(value));
    }

    return new JsonExchangeAttribute(map);
}
 
Example 2
Source File: SetAttributeHandler.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public SetAttributeHandler(HttpHandler next, final String attribute, final String value) {
    this.next = next;
    ExchangeAttributeParser parser = ExchangeAttributes.parser(getClass().getClassLoader());
    this.attribute = parser.parseSingleToken(attribute);
    this.value = parser.parse(value);
    this.preCommit = false;
}
 
Example 3
Source File: PredicatedHandlersParser.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public static HandlerWrapper parseHandler(String string, ClassLoader classLoader) {
    Deque<Token> tokens = tokenize(string);
    Node node = parse(string, tokens);
    Map<String, HandlerBuilder> handlerBuilders = loadHandlerBuilders(classLoader);
    final ExchangeAttributeParser attributeParser = ExchangeAttributes.parser(classLoader);
    return handleHandlerNode(string, (ExpressionNode)node, handlerBuilders, attributeParser);
}
 
Example 4
Source File: PredicatedHandlersParser.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public static List<PredicatedHandler> parse(final String contents, final ClassLoader classLoader) {
    Deque<Token> tokens = tokenize(contents);

    Node node = parse(contents, tokens);
    Map<String, PredicateBuilder> predicateBuilders = loadPredicateBuilders(classLoader);
    Map<String, HandlerBuilder> handlerBuilders = loadHandlerBuilders(classLoader);

    final ExchangeAttributeParser attributeParser = ExchangeAttributes.parser(classLoader);
    return handleNode(contents, node, predicateBuilders, handlerBuilders, attributeParser);
}
 
Example 5
Source File: SetAttributeHandler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public SetAttributeHandler(HttpHandler next, final String attribute, final String value, final ClassLoader classLoader, boolean preCommit) {
    this.next = next;
    this.preCommit = preCommit;
    ExchangeAttributeParser parser = ExchangeAttributes.parser(classLoader);
    this.attribute = parser.parseSingleToken(attribute);
    this.value = parser.parse(value);
}
 
Example 6
Source File: SetAttributeHandler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public SetAttributeHandler(HttpHandler next, final String attribute, final String value, boolean preCommit) {
    this.next = next;
    this.preCommit = preCommit;
    ExchangeAttributeParser parser = ExchangeAttributes.parser(getClass().getClassLoader());
    this.attribute = parser.parseSingleToken(attribute);
    this.value = parser.parse(value);
}
 
Example 7
Source File: SetAttributeHandler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public SetAttributeHandler(HttpHandler next, final String attribute, final String value, final ClassLoader classLoader) {
    this.next = next;
    ExchangeAttributeParser parser = ExchangeAttributes.parser(classLoader);
    this.attribute = parser.parseSingleToken(attribute);
    this.value = parser.parse(value);
    this.preCommit = false;
}
 
Example 8
Source File: SetAttributeHandler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public SetAttributeHandler(HttpHandler next, final String attribute, final String value) {
    this.next = next;
    ExchangeAttributeParser parser = ExchangeAttributes.parser(getClass().getClassLoader());
    this.attribute = parser.parseSingleToken(attribute);
    this.value = parser.parse(value);
    this.preCommit = false;
}
 
Example 9
Source File: PredicatedHandlersParser.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public static HandlerWrapper parseHandler(String string, ClassLoader classLoader) {
    Deque<Token> tokens = tokenize(string);
    Node node = parse(string, tokens);
    Map<String, HandlerBuilder> handlerBuilders = loadHandlerBuilders(classLoader);
    final ExchangeAttributeParser attributeParser = ExchangeAttributes.parser(classLoader);
    return handleHandlerNode(string, (ExpressionNode)node, handlerBuilders, attributeParser);
}
 
Example 10
Source File: PredicatedHandlersParser.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public static Predicate parsePredicate(String string, ClassLoader classLoader) {
    Deque<Token> tokens = tokenize(string);
    Node node = parse(string, tokens);
    Map<String, PredicateBuilder> predicateBuilders = loadPredicateBuilders(classLoader);
    final ExchangeAttributeParser attributeParser = ExchangeAttributes.parser(classLoader);
    return handlePredicateNode(string, node, predicateBuilders, attributeParser);
}
 
Example 11
Source File: PredicatedHandlersParser.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public static List<PredicatedHandler> parse(final String contents, final ClassLoader classLoader) {
    Deque<Token> tokens = tokenize(contents);

    Node node = parse(contents, tokens);
    Map<String, PredicateBuilder> predicateBuilders = loadPredicateBuilders(classLoader);
    Map<String, HandlerBuilder> handlerBuilders = loadHandlerBuilders(classLoader);

    final ExchangeAttributeParser attributeParser = ExchangeAttributes.parser(classLoader);
    return handleNode(contents, node, predicateBuilders, handlerBuilders, attributeParser);
}
 
Example 12
Source File: SetAttributeHandler.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public SetAttributeHandler(HttpHandler next, final String attribute, final String value, final ClassLoader classLoader, boolean preCommit) {
    this.next = next;
    this.preCommit = preCommit;
    ExchangeAttributeParser parser = ExchangeAttributes.parser(classLoader);
    this.attribute = parser.parseSingleToken(attribute);
    this.value = parser.parse(value);
}
 
Example 13
Source File: SetAttributeHandler.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public SetAttributeHandler(HttpHandler next, final String attribute, final String value, boolean preCommit) {
    this.next = next;
    this.preCommit = preCommit;
    ExchangeAttributeParser parser = ExchangeAttributes.parser(getClass().getClassLoader());
    this.attribute = parser.parseSingleToken(attribute);
    this.value = parser.parse(value);
}
 
Example 14
Source File: SetAttributeHandler.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public SetAttributeHandler(HttpHandler next, final String attribute, final String value, final ClassLoader classLoader) {
    this.next = next;
    ExchangeAttributeParser parser = ExchangeAttributes.parser(classLoader);
    this.attribute = parser.parseSingleToken(attribute);
    this.value = parser.parse(value);
    this.preCommit = false;
}
 
Example 15
Source File: ExtendedAccessLogParser.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public ExtendedAccessLogParser(ClassLoader classLoader) {
    this.parser = ExchangeAttributes.parser(classLoader, QuotingExchangeAttribute.WRAPPER);
}
 
Example 16
Source File: RedirectHandler.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
public RedirectHandler(final String location, final ClassLoader classLoader) {
    ExchangeAttributeParser parser = ExchangeAttributes.parser(classLoader);
    attribute = parser.parse(location);
}
 
Example 17
Source File: RedirectHandler.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
public RedirectHandler(final String location) {
    ExchangeAttributeParser parser = ExchangeAttributes.parser(getClass().getClassLoader());
    attribute = parser.parse(location);
}
 
Example 18
Source File: RedirectHandler.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public RedirectHandler(final String location) {
    ExchangeAttributeParser parser = ExchangeAttributes.parser(getClass().getClassLoader());
    attribute = parser.parse(location);
}
 
Example 19
Source File: RedirectHandler.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public RedirectHandler(final String location, final ClassLoader classLoader) {
    ExchangeAttributeParser parser = ExchangeAttributes.parser(classLoader);
    attribute = parser.parse(location);
}
 
Example 20
Source File: ExtendedAccessLogParser.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
public ExtendedAccessLogParser(ClassLoader classLoader) {
    this.parser = ExchangeAttributes.parser(classLoader, QuotingExchangeAttribute.WRAPPER);
}