• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Predicate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.undertow.predicate.Predicate的典型用法代码示例。如果您正苦于以下问题:Java Predicate类的具体用法?Java Predicate怎么用?Java Predicate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Predicate类属于io.undertow.predicate包,在下文中一共展示了Predicate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addTo

import io.undertow.predicate.Predicate; //导入依赖的package包/类
public void addTo(RoutingHandler rh, OptionMap config) {
	List<Predicate> list = new ArrayList<>();
	list.add(this.predicate);
	list.add(this.matches);
	Route route = this.route;
	if (this.type != null && this.type.isEmpty() == false) {
		list.add(MIMEPredicate.accept(type));
		route = (req, res) -> {
			Object result = this.route.handle(req, res);
			res.type(this.type);
			return result;
		};
	}
	this.accepts.stream().filter(s -> s.isEmpty() == false)
			.map(s -> MIMEPredicate.contentType(s)).forEach(list::add);
	rh.add(Predicates.and(list.toArray(new Predicate[list.size()])), route,
			this.renderer);
}
 
开发者ID:taichi,项目名称:siden,代码行数:19,代码来源:RoutingDef.java


示例2: readAttribute

import io.undertow.predicate.Predicate; //导入依赖的package包/类
@Override
public String readAttribute(final HttpServerExchange exchange) {
    Map<String, Object> context = exchange.getAttachment(Predicate.PREDICATE_CONTEXT);
    if (context != null) {
        Object object = context.get(name);
        return object == null ? null : object.toString();
    }
    return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:PredicateContextAttribute.java


示例3: writeAttribute

import io.undertow.predicate.Predicate; //导入依赖的package包/类
@Override
public void writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException {
    Map<String, Object> context = exchange.getAttachment(Predicate.PREDICATE_CONTEXT);
    if (context != null) {
        context.put(name, newValue);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:PredicateContextAttribute.java


示例4: ContentEncodedResourceManager

import io.undertow.predicate.Predicate; //导入依赖的package包/类
public ContentEncodedResourceManager(File encodedResourcesRoot, CachingResourceManager encodedResourceManager, ContentEncodingRepository contentEncodingRepository, int minResourceSize, int maxResourceSize, Predicate encodingAllowed) {
    this.encodedResourcesRoot = encodedResourcesRoot;
    this.encoded = encodedResourceManager;
    this.contentEncodingRepository = contentEncodingRepository;
    this.minResourceSize = minResourceSize;
    this.maxResourceSize = maxResourceSize;
    this.encodingAllowed = encodingAllowed;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:ContentEncodedResourceManager.java


示例5: parse

import io.undertow.predicate.Predicate; //导入依赖的package包/类
public static List<PredicatedHandler> parse(final String contents, final ClassLoader classLoader) {
    String[] lines = contents.split("\\n");
    final List<PredicatedHandler> wrappers = new ArrayList<>();

    for (String line : lines) {
        if (line.trim().length() > 0) {
            Predicate predicate;
            HandlerWrapper handler;
            String[] parts = line.split("->");
            if (parts.length == 2) {
                predicate = PredicateParser.parse(parts[0], classLoader);
                handler = HandlerParser.parse(parts[1], classLoader);
            } else if (parts.length == 1) {
                predicate = Predicates.truePredicate();
                handler = HandlerParser.parse(parts[0], classLoader);
            } else {
                predicate = PredicateParser.parse(parts[0], classLoader);
                HandlerWrapper[] handlers = new HandlerWrapper[parts.length -1];
                for(int i = 0; i < handlers.length; ++i) {
                    handlers[i] = HandlerParser.parse(parts[i + 1], classLoader);
                }
                handler = new ChaninedHandlerWrapper(Arrays.asList(handlers));
            }
            wrappers.add(new PredicatedHandler(predicate, handler));
        }
    }
    return wrappers;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:PredicatedHandlersParser.java


示例6: add

import io.undertow.predicate.Predicate; //导入依赖的package包/类
public synchronized RoutingHandler add(HttpString method, String template, Predicate predicate, HttpHandler handler) {
    PathTemplateMatcher<RoutingMatch> matcher = matches.get(method);
    if (matcher == null) {
        matches.put(method, matcher = new PathTemplateMatcher<>());
    }
    RoutingMatch res = matcher.get(template);
    if (res == null) {
        matcher.add(template, res = new RoutingMatch());
    }
    if (allMethodsMatcher.get(template) == null) {
        allMethodsMatcher.add(template, res);
    }
    res.predicatedHandlers.add(new HandlerHolder(predicate, handler));
    return this;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:RoutingHandler.java


示例7: getCompressionPredicates

import io.undertow.predicate.Predicate; //导入依赖的package包/类
private Predicate[] getCompressionPredicates(Compression compression) {
	List<Predicate> predicates = new ArrayList<Predicate>();
	predicates.add(new MaxSizePredicate(compression.getMinResponseSize()));
	predicates.add(new CompressibleMimeTypePredicate(compression.getMimeTypes()));
	if (compression.getExcludedUserAgents() != null) {
		for (String agent : compression.getExcludedUserAgents()) {
			RequestHeaderAttribute agentHeader = new RequestHeaderAttribute(
					new HttpString(HttpHeaders.USER_AGENT));
			predicates.add(Predicates.not(Predicates.regex(agentHeader, agent)));
		}
	}
	return predicates.toArray(new Predicate[predicates.size()]);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:UndertowEmbeddedServletContainer.java


示例8: getCompressionPredicates

import io.undertow.predicate.Predicate; //导入依赖的package包/类
private Predicate[] getCompressionPredicates(Compression compression) {
	List<Predicate> predicates = new ArrayList<Predicate>();
	predicates.add(Predicates.maxContentSize(compression.getMinResponseSize()));
	predicates.add(new CompressibleMimeTypePredicate(compression.getMimeTypes()));
	if (compression.getExcludedUserAgents() != null) {
		for (String agent : compression.getExcludedUserAgents()) {
			RequestHeaderAttribute agentHeader = new RequestHeaderAttribute(
					new HttpString(HttpHeaders.USER_AGENT));
			predicates.add(Predicates.not(Predicates.regex(agentHeader, agent)));
		}
	}
	return predicates.toArray(new Predicate[predicates.size()]);
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:14,代码来源:UndertowEmbeddedServletContainer.java


示例9: addPredicate

import io.undertow.predicate.Predicate; //导入依赖的package包/类
@Override
public void addPredicate(int priority, Predicate predicate, HttpHandler truePredicate) {
  if(priority < 0) {
    throw new IllegalStateException("The priority must be > 0");
  }

  conditionalHandlers.push(new ConditionalHandlerHolder(priority, predicate, truePredicate));
}
 
开发者ID:vvergnolle,项目名称:vas,代码行数:9,代码来源:BootContextImpl.java


示例10: add

import io.undertow.predicate.Predicate; //导入依赖的package包/类
public synchronized RoutingHandler add(HttpString method, String template, Predicate predicate, HttpHandler handler) {
  CustomPathTemplateMatcher<RoutingMatch> matcher = matches.get(method);
  if (matcher == null) {
    matches.put(method, matcher = new CustomPathTemplateMatcher<>());
  }
  RoutingMatch res = matcher.get(template);
  if (res == null) {
    matcher.add(template, res = new RoutingMatch());
  }
  if (allMethodsMatcher.get(template) == null) {
    allMethodsMatcher.add(template, res);
  }
  res.predicatedHandlers.add(new HandlerHolder(predicate, handler));
  return this;
}
 
开发者ID:EsmerilProgramming,项目名称:overtown,代码行数:16,代码来源:CustomRoutingHandler.java


示例11: WebSocketDef

import io.undertow.predicate.Predicate; //导入依赖的package包/类
public WebSocketDef(String template, Predicate predicate,
		WebSocketFactory factory) {
	super();
	this.template = template;
	this.predicate = predicate;
	this.factory = factory;
}
 
开发者ID:taichi,项目名称:siden,代码行数:8,代码来源:WebSocketDef.java


示例12: RoutingDef

import io.undertow.predicate.Predicate; //导入依赖的package包/类
public RoutingDef(String template, Predicate predicate, HttpMethod method,
		Route route) {
	this.template = template;
	this.predicate = predicate;
	this.method = method;
	this.route = route;
}
 
开发者ID:taichi,项目名称:siden,代码行数:8,代码来源:RoutingDef.java


示例13: consumeConfiguration

import io.undertow.predicate.Predicate; //导入依赖的package包/类
@Override
Consumer<? super Map<String, Object>> consumeConfiguration() {
    return u -> {
        Object _role = u.get("role");
        Object _predicate = u.get("predicate");

        if (_role == null || !(_role instanceof String)) {
            throw new IllegalArgumentException("wrong configuration file format. a permission entry is missing the role");
        }

        String role = (String) _role;

        if (_predicate == null || !(_predicate instanceof String)) {
            throw new IllegalArgumentException("wrong configuration file format. a permission entry is missing the predicate");
        }

        Predicate predicate = null;

        try {
            predicate = PredicateParser.parse((String) _predicate, this.getClass().getClassLoader());
        } catch (Throwable t) {
            throw new IllegalArgumentException("wrong configuration file format. wrong predicate " + _predicate, t);
        }

        aclForRole(role).add(predicate);
    };
}
 
开发者ID:SoftInstigate,项目名称:restheart,代码行数:28,代码来源:SimpleAccessManager.java


示例14: isAuthenticationRequired

import io.undertow.predicate.Predicate; //导入依赖的package包/类
@Override
public boolean isAuthenticationRequired(final HttpServerExchange exchange) {
    if (getAcl() == null) {
        return true;
    }

    Set<Predicate> ps = getAcl().get("$unauthenticated");
    return ps == null ? true : !ps.stream().anyMatch(p -> p.resolve(exchange));
}
 
开发者ID:SoftInstigate,项目名称:restheart,代码行数:10,代码来源:SimpleAccessManager.java


示例15: aclForRole

import io.undertow.predicate.Predicate; //导入依赖的package包/类
private Set<Predicate> aclForRole(String role) {
    Set<Predicate> predicates = getAcl().get(role);
    if (predicates == null) {
        predicates = newHashSet();
        getAcl().put(role, predicates);
    }

    return predicates;
}
 
开发者ID:SoftInstigate,项目名称:restheart,代码行数:10,代码来源:SimpleAccessManager.java


示例16: wrapWithStaticHandler

import io.undertow.predicate.Predicate; //导入依赖的package包/类
protected HttpHandler wrapWithStaticHandler(HttpHandler baseHandler, String path) {
    // static path is given relative to application root
    if (!new File(path).isAbsolute()) {
        path = WunderBoss.options().get("root", "").toString() + File.separator + path;
    }
    if (!new File(path).exists()) {
        log.debug("Not adding static handler for nonexistent directory {}", path);
        return baseHandler;
    }
    log.debug("Adding static handler for {}", path);
    final ResourceManager resourceManager =
            new CachingResourceManager(1000, 1L, null,
                                       new FileResourceManager(new File(path), 1 * 1024 * 1024), 250);
    String[] welcomeFiles = new String[] { "index.html", "index.html", "default.html", "default.htm" };
    final List<String> welcomeFileList = new CopyOnWriteArrayList<>(welcomeFiles);
    final ResourceHandler resourceHandler = new ResourceHandler()
            .setResourceManager(resourceManager)
            .setWelcomeFiles(welcomeFiles)
            .setDirectoryListingEnabled(false);

    return new PredicateHandler(new Predicate() {
            @Override
            public boolean resolve(HttpServerExchange value) {
                try {
                    Resource resource = resourceManager.getResource(value.getRelativePath());
                    if (resource == null) {
                        return false;
                    }
                    if (resource.isDirectory()) {
                        Resource indexResource = getIndexFiles(resourceManager, resource.getPath(), welcomeFileList);
                        return indexResource != null;
                    }
                    return true;
                } catch (IOException ex) {
                    return false;
                }
            }
    }, resourceHandler, baseHandler);
}
 
开发者ID:projectodd,项目名称:wunderboss,代码行数:40,代码来源:UndertowWeb.java


示例17: build

import io.undertow.predicate.Predicate; //导入依赖的package包/类
@Override
public Predicate build(final Map<String, Object> config) {
    String value = (String) config.get("value");
    return new DispatcherTypePredicate(DispatcherType.valueOf(value));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:DispatcherTypePredicate.java


示例18: HttpContinueAcceptingHandler

import io.undertow.predicate.Predicate; //导入依赖的package包/类
public HttpContinueAcceptingHandler(HttpHandler next, Predicate accept) {
    this.next = next;
    this.accept = accept;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:HttpContinueAcceptingHandler.java


示例19: getCachable

import io.undertow.predicate.Predicate; //导入依赖的package包/类
public Predicate getCachable() {
    return cachable;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:ResourceHandler.java


示例20: setCachable

import io.undertow.predicate.Predicate; //导入依赖的package包/类
public ResourceHandler setCachable(final Predicate cachable) {
    this.cachable = cachable;
    return this;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:ResourceHandler.java



注:本文中的io.undertow.predicate.Predicate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ChecksumTypeProto类代码示例发布时间:2022-05-22
下一篇:
Java PreparedBatch类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap