@Override public synchronized void stop(final StopContext stopContext) { IoUtils.safeClose(this.deploymentInfo.getResourceManager()); if (securityDomain != null && securityFunction.getOptionalValue() == null) { AuthenticationManager authManager = securityDomainContextValue.getValue().getAuthenticationManager(); if (authManager != null && authManager instanceof JBossCachedAuthenticationManager) { ((JBossCachedAuthenticationManager) authManager).releaseModuleEntries(module.getClassLoader()); } } this.deploymentInfo.setConfidentialPortManager(null); this.deploymentInfo = null; if (registration != null) { registration.cancel(); } }
@Override public void init(ServletConfig config) throws ServletException { super.init(config); ServletContextImpl sc = (ServletContextImpl) config.getServletContext(); this.deployment = sc.getDeployment(); if (config.getInitParameter(DEFAULT_ALLOWED) != null) { defaultAllowed = Boolean.parseBoolean(config.getInitParameter(DEFAULT_ALLOWED)); } if (config.getInitParameter(ALLOWED_EXTENSIONS) != null) { String extensions = config.getInitParameter(ALLOWED_EXTENSIONS); allowed = new HashSet<>(Arrays.asList(extensions.split(","))); } if (config.getInitParameter(DISALLOWED_EXTENSIONS) != null) { String extensions = config.getInitParameter(DISALLOWED_EXTENSIONS); disallowed = new HashSet<>(Arrays.asList(extensions.split(","))); } if (config.getInitParameter(RESOLVE_AGAINST_CONTEXT_ROOT) != null) { resolveAgainstContextRoot = Boolean.parseBoolean(config.getInitParameter(RESOLVE_AGAINST_CONTEXT_ROOT)); } this.resourceManager = deployment.getDeploymentInfo().getResourceManager(); String listings = config.getInitParameter(DIRECTORY_LISTING); if (Boolean.valueOf(listings)) { this.directoryListingEnabled = true; } }
@Override public URL getResource(final String path) throws MalformedURLException { if (!path.startsWith("/")) { throw UndertowServletMessages.MESSAGES.pathMustStartWithSlash(path); } Resource resource = null; try { resource = deploymentInfo.getResourceManager().getResource(path); } catch (IOException e) { return null; } if (resource == null) { return null; } return resource.getUrl(); }
public ServletPathMatches(final Deployment deployment) { this.deployment = deployment; this.welcomePages = deployment.getDeploymentInfo().getWelcomePages().toArray(new String[deployment.getDeploymentInfo().getWelcomePages().size()]); this.resourceManager = deployment.getDeploymentInfo().getResourceManager(); }
public boolean resolveResource(int type, String name) { Resource resource; try { resource = servletRequestContext.getDeployment().getDeploymentInfo().getResourceManager().getResource(name); } catch (IOException e) { throw new RuntimeException(e); } switch (type) { case 0: return (resource == null); case 1: return (resource != null); case 2: return (resource != null && resource.getContentLength() > 0); default: return false; } }
@Bean public WebServerFactoryCustomizer<UndertowServletWebServerFactory> jsfUndertowFactoryCustomizer() { return factory -> factory.addDeploymentInfoCustomizers(deploymentInfo -> { AccessController.doPrivileged((PrivilegedAction<Void>) () -> { deploymentInfo.setResourceManager(new CompositeResourceManager( new ClassPathResourceManager(deploymentInfo.getClassLoader(), this.undertowProperties.getClassPathResource()), deploymentInfo.getResourceManager())); return null; }); log.info("Setting Undertow classLoader to {} directory", this.undertowProperties.getClassPathResource()); }); } }
public synchronized void stop() { if (handle != null) { final ResourceManager resourceManager = servletContext.getDeployment().getDeploymentInfo().getResourceManager(); if(changeListener != null) { resourceManager.removeResourceChangeListener(changeListener); } invokeDestroy(); handle.release(); } }
public synchronized void stop() { if (handle != null) { final ResourceManager resourceManager = servletContext.getDeployment().getDeploymentInfo().getResourceManager(); if (changeListener != null) { resourceManager.removeResourceChangeListener(changeListener); } invokeDestroy(); handle.release(); } }
public synchronized void stop() { if (handle != null) { final ResourceManager resourceManager = servletContext.getDeployment().getDeploymentInfo().getResourceManager(); if (changeListener != null) { resourceManager.removeResourceChangeListener(changeListener); } invokeDestroy(); handle.release(); } }
@Override public boolean resolve(final HttpServerExchange value) { String location = this.location.readAttribute(value); ServletRequestContext src = value.getAttachment(ServletRequestContext.ATTACHMENT_KEY); if(src == null) { return false; } ResourceManager manager = src.getDeployment().getDeploymentInfo().getResourceManager(); if(manager == null) { return false; } try { Resource resource = manager.getResource(location); if(resource == null) { return false; } return resource.isDirectory(); } catch (IOException e) { throw new RuntimeException(e); } }
public void testGetResource() throws IOException { UndertowDeploymentInfoCustomizer undertowDeploymentInfoCustomizer = new JsfUndertowDeploymentInfoCustomizer(this.undertowProperties); DeploymentInfo deploymentInfo = new DeploymentInfo(); undertowDeploymentInfoCustomizer.customize(deploymentInfo); assertThat(deploymentInfo.getResourceManager().getResource("test.txt")) .isNotNull(); }
public void customize() throws MalformedURLException, IOException { UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory(); this.undertowSpringBootAutoConfiguration.customize(factory); UndertowDeploymentInfoCustomizer undertowDeploymentInfoCustomizer = factory.getDeploymentInfoCustomizers().iterator().next(); DeploymentInfo deploymentInfo = new DeploymentInfo(); undertowDeploymentInfoCustomizer.customize(deploymentInfo); assertThat(deploymentInfo.getResourceManager().getResource("test.txt")) .isNotNull(); }
@Test public void customize() throws MalformedURLException, IOException { UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory(); this.undertowSpringBootAutoConfiguration.customize(factory); UndertowDeploymentInfoCustomizer undertowDeploymentInfoCustomizer = factory.getDeploymentInfoCustomizers().iterator().next(); DeploymentInfo deploymentInfo = new DeploymentInfo(); undertowDeploymentInfoCustomizer.customize(deploymentInfo); assertThat(deploymentInfo.getResourceManager().getResource("testUndertow.txt")) .isNotNull(); }
@Test public void testGetResource() throws IOException { UndertowDeploymentInfoCustomizer undertowDeploymentInfoCustomizer = new JsfUndertowDeploymentInfoCustomizer(this.undertowProperties); DeploymentInfo deploymentInfo = new DeploymentInfo(); undertowDeploymentInfoCustomizer.customize(deploymentInfo); assertThat(deploymentInfo.getResourceManager().getResource("testUndertow.txt")) .isNotNull(); }
@Test public void customize() throws IOException { UndertowServletWebServerFactory factory = new UndertowServletWebServerFactory(); this.undertowAutoConfiguration.jsfUndertowFactoryCustomizer().customize(factory); UndertowDeploymentInfoCustomizer undertowDeploymentInfoCustomizer = factory.getDeploymentInfoCustomizers().iterator().next(); DeploymentInfo deploymentInfo = new DeploymentInfo(); deploymentInfo.setClassLoader(this.getClass().getClassLoader()); undertowDeploymentInfoCustomizer.customize(deploymentInfo); assertThat(deploymentInfo.getResourceManager().getResource("testUndertow.txt")) .isNotNull(); } }
@Override public synchronized void stop(final StopContext stopContext) { IoUtils.safeClose(this.deploymentInfo.getResourceManager()); if (securityDomain != null && securityFunction.getOptionalValue() == null) { AuthenticationManager authManager = securityDomainContextValue.getValue().getAuthenticationManager(); if (authManager != null && authManager instanceof JBossCachedAuthenticationManager) { ((JBossCachedAuthenticationManager) authManager).releaseModuleEntries(module.getClassLoader()); } } this.deploymentInfo.setConfidentialPortManager(null); this.deploymentInfo = null; if (registration != null) { registration.cancel(); } }
@Override public synchronized void stop(final StopContext stopContext) { IoUtils.safeClose(this.deploymentInfo.getResourceManager()); if (securityDomain != null && securityFunction.getOptionalValue() == null) { AuthenticationManager authManager = securityDomainContextValue.getValue().getAuthenticationManager(); if (authManager != null && authManager instanceof JBossCachedAuthenticationManager) { ((JBossCachedAuthenticationManager) authManager).releaseModuleEntries(module.getClassLoader()); } } this.deploymentInfo.setConfidentialPortManager(null); this.deploymentInfo = null; if (registration != null) { registration.cancel(); } }
public synchronized void start() throws ServletException { try { handle = factory.createInstance(); } catch (Exception e) { throw UndertowServletMessages.MESSAGES.couldNotInstantiateComponent(servletInfo.getName(), e); } instance = handle.getInstance(); new LifecyleInterceptorInvocation(servletContext.getDeployment().getDeploymentInfo().getLifecycleInterceptors(), servletInfo, instance, new ServletConfigImpl(servletInfo, servletContext)).proceed(); //if a servlet implements FileChangeCallback it will be notified of file change events final ResourceManager resourceManager = servletContext.getDeployment().getDeploymentInfo().getResourceManager(); if(instance instanceof ResourceChangeListener && resourceManager.isResourceChangeListenerSupported()) { resourceManager.registerResourceChangeListener(changeListener = (ResourceChangeListener) instance); } }
public synchronized void start() throws ServletException { try { handle = factory.createInstance(); } catch (Exception e) { throw UndertowServletMessages.MESSAGES.couldNotInstantiateComponent(servletInfo.getName(), e); } instance = handle.getInstance(); new LifecyleInterceptorInvocation(servletContext.getDeployment().getDeploymentInfo().getLifecycleInterceptors(), servletInfo, instance, new ServletConfigImpl(servletInfo, servletContext.getDelegatedContext()), new ServletConfigImpl(servletInfo, servletContext)).proceed(); // if a servlet implements FileChangeCallback it will be notified of file change events final ResourceManager resourceManager = servletContext.getDeployment().getDeploymentInfo().getResourceManager(); if (instance instanceof ResourceChangeListener && resourceManager.isResourceChangeListenerSupported()) { resourceManager.registerResourceChangeListener(changeListener = (ResourceChangeListener) instance); } }
public synchronized void start() throws ServletException { try { handle = factory.createInstance(); } catch (Exception e) { throw UndertowServletMessages.MESSAGES.couldNotInstantiateComponent(servletInfo.getName(), e); } instance = handle.getInstance(); new LifecyleInterceptorInvocation(servletContext.getDeployment().getDeploymentInfo().getLifecycleInterceptors(), servletInfo, instance, new ServletConfigImpl(servletInfo, servletContext.getDelegatedContext()), new ServletConfigImpl(servletInfo, servletContext)).proceed(); // if a servlet implements FileChangeCallback it will be notified of file change events final ResourceManager resourceManager = servletContext.getDeployment().getDeploymentInfo().getResourceManager(); if (instance instanceof ResourceChangeListener && resourceManager.isResourceChangeListenerSupported()) { resourceManager.registerResourceChangeListener(changeListener = (ResourceChangeListener) instance); } }