本文整理汇总了Java中io.undertow.servlet.api.ServletInfo类的典型用法代码示例。如果您正苦于以下问题:Java ServletInfo类的具体用法?Java ServletInfo怎么用?Java ServletInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServletInfo类属于io.undertow.servlet.api包,在下文中一共展示了ServletInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addServlet
import io.undertow.servlet.api.ServletInfo; //导入依赖的package包/类
@Override
public ServletRegistration.Dynamic addServlet(final String servletName, final String className) {
ensureNotProgramaticListener();
ensureNotInitialized();
try {
if (deploymentInfo.getServlets().containsKey(servletName)) {
return null;
}
ServletInfo servlet = new ServletInfo(servletName, (Class<? extends Servlet>) deploymentInfo.getClassLoader().loadClass(className));
readServletAnnotations(servlet);
deploymentInfo.addServlet(servlet);
ServletHandler handler = deployment.getServlets().addServlet(servlet);
return new ServletRegistrationImpl(servlet, handler.getManagedServlet(), deployment);
} catch (ClassNotFoundException e) {
throw UndertowServletMessages.MESSAGES.cannotLoadClass(className, e);
}
}
示例2: isUserInRole
import io.undertow.servlet.api.ServletInfo; //导入依赖的package包/类
@Override
public boolean isUserInRole(String role, Account account, ServletInfo servletInfo, HttpServletRequest request, Deployment deployment) {
final Map<String, Set<String>> principalVersusRolesMap = deployment.getDeploymentInfo().getPrincipalVersusRolesMap();
final Set<String> roles = principalVersusRolesMap.get(account.getPrincipal().getName());
//TODO: a more efficient imple
for (SecurityRoleRef ref : servletInfo.getSecurityRoleRefs()) {
if (ref.getRole().equals(role)) {
if (roles != null && roles.contains(ref.getLinkedRole())) {
return true;
}
return account.getRoles().contains(ref.getLinkedRole());
}
}
if (roles != null && roles.contains(role)) {
return true;
}
return account.getRoles().contains(role);
}
示例3: undertowDeployment
import io.undertow.servlet.api.ServletInfo; //导入依赖的package包/类
static DeploymentInfo undertowDeployment(ResteasyDeployment deployment, String mapping) {
if (mapping == null) {
mapping = "/";
}
if (!mapping.startsWith("/")) {
mapping = '/' + mapping;
}
if (!mapping.endsWith("/")) {
mapping = mapping + '/';
}
mapping = mapping + '*';
String prefix = null;
if (!mapping.equals("/*")) {
prefix = mapping.substring(0, mapping.length() - 2);
}
ServletInfo resteasyServlet = Servlets.servlet("ResteasyServlet", HttpServlet30Dispatcher.class).setAsyncSupported(true).setLoadOnStartup(1).addMapping(mapping);
if (prefix != null) {
resteasyServlet.addInitParam("resteasy.servlet.mapping.prefix", prefix);
}
return (new DeploymentInfo()).addServletContextAttribute(ResteasyDeployment.class.getName(), deployment).addServlet(resteasyServlet);
}
示例4: testConversion
import io.undertow.servlet.api.ServletInfo; //导入依赖的package包/类
@Test
public void testConversion() {
Class<? extends HttpServlet> servletClass = DefaultServlet.class;
String name = "name";
String[] value = new String[]{"a"};
String[] urlPatterns = new String[]{"/b"};
int loadOnStartup = 2;
WebInitParam[] initParams = new WebInitParam[]{new WebParam("name","value")};
boolean asyncSupported = true;
ServletDescriptor servletDescriptor = new ServletDescriptor(name, value, urlPatterns, loadOnStartup,
initParams, asyncSupported, servletClass);
ServletInfo servletInfo = mapper.apply(servletDescriptor);
assertThat(servletInfo.getName()).isEqualTo(name);
assertThat(servletInfo.getServletClass()).isEqualTo(servletClass);
assertThat(servletInfo.getMappings()).isEqualTo(asList(urlPatterns));
assertThat(servletInfo.getLoadOnStartup()).isEqualTo(loadOnStartup);
assertThat(servletInfo.isAsyncSupported()).isEqualTo(asyncSupported);
assertThat(servletInfo.getInitParams()).isEqualTo(singletonMap("name","value"));
}
示例5: readServletAnnotations
import io.undertow.servlet.api.ServletInfo; //导入依赖的package包/类
private void readServletAnnotations(ServletInfo servlet) {
if (System.getSecurityManager() == null) {
new ReadServletAnnotationsTask(servlet, deploymentInfo).run();
} else {
AccessController.doPrivileged(new ReadServletAnnotationsTask(servlet, deploymentInfo));
}
}
示例6: LifecyleInterceptorInvocation
import io.undertow.servlet.api.ServletInfo; //导入依赖的package包/类
LifecyleInterceptorInvocation(List<LifecycleInterceptor> list, ServletInfo servletInfo, Servlet servlet, ServletConfig servletConfig) {
this.list = list;
this.servletInfo = servletInfo;
this.servlet = servlet;
this.servletConfig = servletConfig;
this.filter = null;
this.filterConfig = null;
this.filterInfo = null;
i = list.size();
}
示例7: handleRequest
import io.undertow.servlet.api.ServletInfo; //导入依赖的package包/类
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
ServletInfo servletInfo = context.getCurrentServlet().getManagedServlet().getServletInfo();
MetricsHandler handler = servletHandlers.get(servletInfo.getName());
if(handler != null) {
handler.handleRequest(exchange);
} else {
next.handleRequest(exchange);
}
}
示例8: canAccessResource
import io.undertow.servlet.api.ServletInfo; //导入依赖的package包/类
@Override
public boolean canAccessResource(List<SingleConstraintMatch> constraints, Account account, ServletInfo servletInfo, HttpServletRequest request, Deployment deployment) {
if (constraints == null || constraints.isEmpty()) {
return true;
}
for (final SingleConstraintMatch constraint : constraints) {
boolean found = false;
Set<String> roleSet = constraint.getRequiredRoles();
if (roleSet.isEmpty() && constraint.getEmptyRoleSemantic() != SecurityInfo.EmptyRoleSemantic.DENY) {
/*
* The EmptyRoleSemantic was either PERMIT or AUTHENTICATE, either way a roles check is not needed.
*/
found = true;
} else if (account != null) {
final Set<String> roles = deployment.getDeploymentInfo().getPrincipalVersusRolesMap().get(account.getPrincipal().getName());
for (String role : roleSet) {
if (roles != null) {
if (roles.contains(role)) {
found = true;
break;
}
}
if (account.getRoles().contains(role)) {
found = true;
break;
}
}
}
if (!found) {
return false;
}
}
return true;
}
示例9: ManagedServlet
import io.undertow.servlet.api.ServletInfo; //导入依赖的package包/类
public ManagedServlet(final ServletInfo servletInfo, final ServletContextImpl servletContext) {
this.servletInfo = servletInfo;
this.servletContext = servletContext;
if (SingleThreadModel.class.isAssignableFrom(servletInfo.getServletClass())) {
instanceStrategy = new SingleThreadModelPoolStrategy(servletInfo.getInstanceFactory(), servletInfo, servletContext);
} else {
instanceStrategy = new DefaultInstanceStrategy(servletInfo.getInstanceFactory(), servletInfo, servletContext);
}
setupMultipart(servletContext);
}
示例10: createServletsAndFilters
import io.undertow.servlet.api.ServletInfo; //导入依赖的package包/类
private void createServletsAndFilters(final DeploymentImpl deployment, final DeploymentInfo deploymentInfo) {
for (Map.Entry<String, ServletInfo> servlet : deploymentInfo.getServlets().entrySet()) {
deployment.getServlets().addServlet(servlet.getValue());
}
for (Map.Entry<String, FilterInfo> filter : deploymentInfo.getFilters().entrySet()) {
deployment.getFilters().addFilter(filter.getValue());
}
}
示例11: addServlet
import io.undertow.servlet.api.ServletInfo; //导入依赖的package包/类
public ServletHandler addServlet(final ServletInfo servletInfo) {
ManagedServlet managedServlet = new ManagedServlet(servletInfo, deployment.getServletContext());
ServletHandler servletHandler = new ServletHandler(managedServlet);
managedServletMap.put(servletInfo.getName(), servletHandler);
deployment.addLifecycleObjects(managedServlet);
this.servletPaths.invalidate();
return servletHandler;
}
示例12: createServletInfo
import io.undertow.servlet.api.ServletInfo; //导入依赖的package包/类
private static ServletInfo createServletInfo(String mapping, String servletName, Class<? extends Servlet> servlet)
throws NoSuchMethodException {
ServletInfo servletInfo = Servlets
.servlet(servletName, servlet)
.setAsyncSupported(true)
.setLoadOnStartup(1)
.addMapping(mapping);
servletInfo.setInstanceFactory(CdiClassIntrospecter.INSTANCE.createInstanceFactory(servlet));
return servletInfo;
}
示例13: startUndertow
import io.undertow.servlet.api.ServletInfo; //导入依赖的package包/类
private static void startUndertow() throws ServletException {
ServletInfo servletInfo = new ServletInfo(VaadinServlet.class.getName(), VaadinServlet.class)
.setAsyncSupported(true)
.setLoadOnStartup(1)
.addInitParam("ui", "com.hybridbpm.ui.HybridbpmUI").addInitParam("widgetset", "com.hybridbpm.ui.HybridbpmWidgetSet")
.addMapping("/*").addMapping("/VAADIN");
DeploymentInfo deploymentInfo = deployment()
.setClassLoader(HybridbpmServer.class.getClassLoader())
.setContextPath(PATH)
.setDeploymentName("hybridbpm.war")
.setDisplayName("HYBRIDBPM")
.setResourceManager(new ClassPathResourceManager(HybridbpmServer.class.getClassLoader()))
.addServlets(servletInfo)
.addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, new WebSocketDeploymentInfo());
DeploymentManager manager = defaultContainer().addDeployment(deploymentInfo);
manager.deploy();
PathHandler path = Handlers.path(Handlers.redirect(PATH)).addPrefixPath(PATH, manager.start());
Undertow.Builder builder = Undertow.builder().addHttpListener(8080, "0.0.0.0").setHandler(path);
undertow = builder.build();
undertow.start();
logger.info("HybridbpmServer UI started");
}
示例14: createFathomDeploymentManager
import io.undertow.servlet.api.ServletInfo; //导入依赖的package包/类
protected DeploymentManager createFathomDeploymentManager() throws ServletException {
DeploymentInfo info = Servlets.deployment();
info.setDeploymentName("Fathom");
info.setClassLoader(this.getClass().getClassLoader());
info.setContextPath(settings.getContextPath());
info.setIgnoreFlush(true);
info.setDefaultEncoding("UTF-8");
FilterInfo guiceFilter = new FilterInfo("GuiceFilter", GuiceFilter.class);
guiceFilter.setAsyncSupported(true);
info.addFilterUrlMapping("GuiceFilter", "/*", DispatcherType.REQUEST);
info.addFilters(guiceFilter);
ServletInfo defaultServlet = new ServletInfo("DefaultServlet", DefaultServlet.class);
defaultServlet.setAsyncSupported(true);
defaultServlet.addMapping("/");
ServletContextListener fathomListener = new ServletContextListener(settings);
info.addListeners(new ListenerInfo(ServletContextListener.class, new ImmediateInstanceFactory<>(fathomListener)));
MultipartConfigElement multipartConfig = new MultipartConfigElement(settings.getUploadFilesLocation(), settings.getUploadFilesMaxSize(), -1L, 0);
defaultServlet.setMultipartConfig(multipartConfig);
info.addServlets(defaultServlet);
DeploymentManager deploymentManager = Servlets.defaultContainer().addDeployment(info);
deploymentManager.deploy();
return deploymentManager;
}
示例15: deployJaxrs
import io.undertow.servlet.api.ServletInfo; //导入依赖的package包/类
protected void deployJaxrs(BootContext context) {
String adminJaxrs = context.properties().getProperty("vas.admin.jaxrs", "false");
if(Boolean.valueOf(adminJaxrs)) {
DeploymentInfo deploymentInfo = context.deploymentInfo();
ServletInfo servletInfo = Servlets.servlet("admin-jaxrs", AdminServlet.class).setEnabled(true)
.setAsyncSupported(true).setLoadOnStartup(1).addMappings("/admin/jaxrs");
deploymentInfo.addServlet(servletInfo);
}
}