本文整理汇总了Java中io.bootique.jetty.MappedFilter类的典型用法代码示例。如果您正苦于以下问题:Java MappedFilter类的具体用法?Java MappedFilter怎么用?Java MappedFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MappedFilter类属于io.bootique.jetty包,在下文中一共展示了MappedFilter类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toMappedFilter
import io.bootique.jetty.MappedFilter; //导入依赖的package包/类
public MappedFilter toMappedFilter(Filter filter, int order) {
WebFilter wfAnnotation = filter.getClass().getAnnotation(WebFilter.class);
if (wfAnnotation == null) {
throw new IllegalArgumentException(
"Filter contains no @WebFilter annotation and can not be mapped directly. Wrap it in a MappedFilter instead.");
}
String name = wfAnnotation.filterName() != null && wfAnnotation.filterName().length() > 0
? wfAnnotation.filterName() : null;
Set<String> urlPatterns = new HashSet<>(asList(wfAnnotation.urlPatterns()));
Map<String, String> initParams = new HashMap<>();
WebInitParam[] paramsArray = wfAnnotation.initParams();
if (paramsArray != null) {
asList(paramsArray).forEach(p -> initParams.put(p.name(), p.value()));
}
return new MappedFilter(filter, urlPatterns, name, initParams, order);
}
示例2: provideMappedShiroFilter
import io.bootique.jetty.MappedFilter; //导入依赖的package包/类
@Singleton
@Provides
MappedFilter<ShiroFilter> provideMappedShiroFilter(ConfigurationFactory configFactory,
Injector injector,
WebSecurityManager securityManager,
@ShiroFilterBinding Map<String, Filter> chainFilters) {
return configFactory
.config(MappedShiroFilterFactory.class, configPrefix)
.createShiroFilter(injector, securityManager, chainFilters);
}
示例3: createShiroFilter
import io.bootique.jetty.MappedFilter; //导入依赖的package包/类
public MappedFilter<ShiroFilter> createShiroFilter(
Injector injector,
WebSecurityManager securityManager,
Map<String, Filter> chainFilters) {
FilterChainResolver chainResolver = createChainResolver(chainFilters);
ShiroFilter shiroFilter = createShiroFilter(securityManager, chainResolver);
return createMappedShiroFilter(shiroFilter);
}
示例4: testCustomFactory
import io.bootique.jetty.MappedFilter; //导入依赖的package包/类
@Test
public void testCustomFactory() {
BQRuntime runtime = TEST_FACTORY
.app("-c", "classpath:CustomShiroFilterIT.yml")
.autoLoadModules()
.module(b -> ShiroModule.extend(b).addRealm(mock(Realm.class)))
.createRuntime();
TypeLiteral<MappedFilter<ShiroFilter>> filterKey = new TypeLiteral<MappedFilter<ShiroFilter>>() {
};
MappedFilter<ShiroFilter> mappedFilter = runtime.getInstance(Key.get(filterKey));
Assert.assertTrue(mappedFilter.getFilter() instanceof CustomFilter);
}
示例5: configure
import io.bootique.jetty.MappedFilter; //导入依赖的package包/类
@Override
public void configure(Binder binder) {
TapestryModule.extend(binder).initAllExtensions().addTapestryModule(GuiceTapestryModule.class);
TypeLiteral<MappedFilter<BQTapestryFilter>> tf = new TypeLiteral<MappedFilter<BQTapestryFilter>>() {
};
JettyModule.extend(binder).addMappedFilter(tf);
// decrease default verbosity...
BQCoreModule.extend(binder)
.setLogLevel("org.apache.tapestry5.modules.TapestryModule.ComponentClassResolver", Level.WARNING)
.setLogLevel("io.bootique.tapestry.filter.BQTapestryFilter", Level.WARNING);
}
示例6: createTapestryFilter
import io.bootique.jetty.MappedFilter; //导入依赖的package包/类
@Singleton
@Provides
MappedFilter<BQTapestryFilter> createTapestryFilter(
ConfigurationFactory configurationFactory,
Injector injector,
@Symbols Map<String, String> diSymbols,
@TapestryModuleBinding Set<Class<?>> moduleTypes) {
return configurationFactory
.config(BQTapestryFilterFactory.class, configPrefix)
.createTapestryFilter(injector, diSymbols, moduleTypes);
}
示例7: createAndAddJettyFilter
import io.bootique.jetty.MappedFilter; //导入依赖的package包/类
public Optional<FilterHolder> createAndAddJettyFilter(ServletContextHandler handler, MappedFilter mappedFilter) {
Objects.requireNonNull(mappedFilter.getFilter());
Set<String> urlPatterns = getUrlPatterns(mappedFilter.getUrlPatterns());
if (urlPatterns.isEmpty()) {
// TODO: old Java anti-pattern is to use filters for the sake
// of their "init" method, so perhaps we do need to add unmapped
// filter after all?
LOGGER.info("Skipping unmapped filter {}", mappedFilter.getFilter().getClass().getName());
return Optional.empty();
}
FilterHolder holder = new FilterHolder(mappedFilter.getFilter());
if (mappedFilter.getName() != null) {
holder.setName(mappedFilter.getName());
}
Map<String, String> params = getParams(mappedFilter.getParams());
if (params != null) {
params.forEach((k, v) -> holder.setInitParameter(k, v));
}
EnumSet<DispatcherType> dispatches = EnumSet.of(DispatcherType.REQUEST);
urlPatterns.forEach(urlPattern -> {
if (LOGGER.isInfoEnabled()) {
String name = mappedFilter.getName() != null ? mappedFilter.getName() : "?";
LOGGER.info("Adding filter '{}' mapped to {}", name, urlPattern);
}
handler.addFilter(holder, urlPattern, dispatches);
});
return Optional.of(holder);
}
示例8: createServer
import io.bootique.jetty.MappedFilter; //导入依赖的package包/类
public Server createServer(Set<MappedServlet> servlets, Set<MappedFilter> filters, Set<MappedListener> listeners) {
ThreadPool threadPool = createThreadPool();
Server server = new Server(threadPool);
server.setStopAtShutdown(true);
server.setStopTimeout(1000L);
server.setHandler(createHandler(servlets, filters, listeners));
if (maxFormContentSize > 0) {
server.setAttribute("org.eclipse.jetty.server.Request.maxFormContentSize", maxFormContentSize);
}
if (maxFormKeys > 0) {
server.setAttribute("org.eclipse.jetty.server.Request.maxFormKeys", maxFormKeys);
}
createRequestLog(server);
Collection<ConnectorFactory> connectorFactories = connectorFactories(server);
Collection<ConnectorDescriptor> connectorDescriptors = new ArrayList<>(2);
if (connectorFactories.isEmpty()) {
LOGGER.warn("Jetty starts with no connectors configured. Is that expected?");
} else {
connectorFactories.forEach(cf -> {
NetworkConnector connector = cf.createConnector(server);
server.addConnector(connector);
connectorDescriptors.add(new ConnectorDescriptor(connector));
});
}
server.addLifeCycleListener(new ServerLifecycleLogger(connectorDescriptors, context));
return server;
}
示例9: createHandler
import io.bootique.jetty.MappedFilter; //导入依赖的package包/类
protected Handler createHandler(Set<MappedServlet> servlets,
Set<MappedFilter> filters,
Set<MappedListener> listeners) {
int options = 0;
if (sessions) {
options |= ServletContextHandler.SESSIONS;
}
ServletContextHandler handler = new ServletContextHandler(options);
handler.setContextPath(context);
if (params != null) {
params.forEach((k, v) -> handler.setInitParameter(k, v));
}
if (staticResourceBase != null) {
handler.setResourceBase(staticResourceBase.getUrl().toExternalForm());
}
if (compression) {
handler.setGzipHandler(createGzipHandler());
}
if (errorPages != null) {
ErrorPageErrorHandler errorHandler = new ErrorPageErrorHandler();
errorPages.forEach((statusCode, location) -> errorHandler.addErrorPage(statusCode, location));
handler.setErrorHandler(errorHandler);
}
installListeners(handler, listeners);
installServlets(handler, servlets);
installFilters(handler, filters);
return handler;
}
示例10: configure
import io.bootique.jetty.MappedFilter; //导入依赖的package包/类
@Override
public void configure(Binder binder) {
extend(binder).initAllExtensions();
JettyModule.extend(binder).addMappedFilter(new TypeLiteral<MappedFilter<ShiroFilter>>() {
});
}
示例11: createMappedShiroFilter
import io.bootique.jetty.MappedFilter; //导入依赖的package包/类
protected MappedFilter<ShiroFilter> createMappedShiroFilter(ShiroFilter shiroFilter) {
Set<String> urlPatterns = this.urlPatterns != null ? this.urlPatterns : Collections.singleton("/*");
return new MappedFilter<>(shiroFilter, urlPatterns, "bootiqueShiro", 0);
}
示例12: createTapestryFilter
import io.bootique.jetty.MappedFilter; //导入依赖的package包/类
public MappedFilter<BQTapestryFilter> createTapestryFilter(Injector injector, Map<String, String> diSymbols, Set<Class<?>> customModules) {
SymbolProvider symbolProvider = createSymbolProvider(diSymbols);
BQTapestryFilter filter = new BQTapestryFilter(name, symbolProvider, toModuleArray(customModules), extraModuleDefs(injector));
return new MappedFilter(filter, Collections.singleton(urlPattern), name, filterOrder);
}
示例13: installFilters
import io.bootique.jetty.MappedFilter; //导入依赖的package包/类
protected void installFilters(ServletContextHandler handler, Set<MappedFilter> filters) {
sortedFilters(filters).forEach(mappedFilter -> getFilterFactory(mappedFilter.getName())
.createAndAddJettyFilter(handler, mappedFilter));
}
示例14: sortedFilters
import io.bootique.jetty.MappedFilter; //导入依赖的package包/类
private List<MappedFilter> sortedFilters(Set<MappedFilter> unsorted) {
List<MappedFilter> sorted = new ArrayList<>(unsorted);
Collections.sort(sorted, Comparator.comparing(MappedFilter::getOrder));
return sorted;
}