当前位置: 首页>>代码示例>>Java>>正文


Java ResourceManager类代码示例

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


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

示例1: loadTemplate

import io.undertow.server.handlers.resource.ResourceManager; //导入依赖的package包/类
public static String loadTemplate(String template, ResourceManager resourceManager) throws Exception {
    byte[] buf = new byte[1024];
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Resource resource = resourceManager.getResource(template);
    if(resource == null) {
        throw UndertowScriptLogger.ROOT_LOGGER.templateNotFound(template);
    }
    try (InputStream stream = resource.getUrl().openStream()) {
        if(stream == null) {
            throw UndertowScriptLogger.ROOT_LOGGER.templateNotFound(template);
        }
        int res;
        while ((res = stream.read(buf)) > 0) {
            out.write(buf, 0, res);
        }
        return out.toString("UTF-8");
    }
}
 
开发者ID:undertow-io,项目名称:undertow.js,代码行数:19,代码来源:Templates.java

示例2: start

import io.undertow.server.handlers.resource.ResourceManager; //导入依赖的package包/类
@Override
public void start(StartContext context) throws StartException {
    ExtensibleHttpManagement httpManagement = httpManagementInjector.getValue();

    ResourceManager rm = new ClassPathResourceManager(getClass().getClassLoader(), getClass().getPackage());
    httpManagement.addStaticContext("static", rm);
    log.info("Added context 'static'");

    ExtensibleHttpManagement.PathRemapper remapper = new ExtensibleHttpManagement.PathRemapper() {
        @Override
        public String remapPath(String originalPath) {
            if ("/foo".equals(originalPath)) {
                String prefix = forServer ? "" : "/host/master";
                return prefix + "/extension/" + EXTENSION_NAME;
            }
            return null;
        }
    };
    httpManagement.addManagementGetRemapContext("remap", remapper);
    log.info("Added context 'remap'");
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:22,代码来源:CustomContextExtension.java

示例3: start

import io.undertow.server.handlers.resource.ResourceManager; //导入依赖的package包/类
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);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:ManagedServlet.java

示例4: stop

import io.undertow.server.handlers.resource.ResourceManager; //导入依赖的package包/类
public synchronized void stop() {
    if (handle != null) {
        final ResourceManager resourceManager = servletContext.getDeployment().getDeploymentInfo().getResourceManager();
        if(changeListener != null) {
            resourceManager.removeResourceChangeListener(changeListener);
        }
        invokeDestroy();
        handle.release();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:ManagedServlet.java

示例5: getDocumentRootResourceManager

import io.undertow.server.handlers.resource.ResourceManager; //导入依赖的package包/类
private ResourceManager getDocumentRootResourceManager() {
	File root = getCanonicalDocumentRoot();
	if (root.isDirectory()) {
		return new FileResourceManager(root, 0);
	}
	if (root.isFile()) {
		return new JarResourceManager(root);
	}
	return ResourceManager.EMPTY_RESOURCE_MANAGER;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:UndertowEmbeddedServletContainerFactory.java

示例6: getDocumentRootResourceManager

import io.undertow.server.handlers.resource.ResourceManager; //导入依赖的package包/类
private ResourceManager getDocumentRootResourceManager() {
	File root = getValidDocumentRoot();
	if (root != null && root.isDirectory()) {
		return new FileResourceManager(root, 0);
	}
	if (root != null && root.isFile()) {
		return new JarResourcemanager(root);
	}
	return ResourceManager.EMPTY_RESOURCE_MANAGER;
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:11,代码来源:UndertowEmbeddedServletContainerFactory.java

示例7: getResource

import io.undertow.server.handlers.resource.ResourceManager; //导入依赖的package包/类
@Override
public Resource getResource(String p) {
    for (int i = 0, managersSize = size(); i < managersSize; i++) {
        ResourceManager x = get(i);
        try {
            Resource y = x.getResource(p);
            if (y != null)
                return y;
        } catch (Throwable ignored) {
            //ignore
        }
    }
    return null;
}
 
开发者ID:automenta,项目名称:spimedb,代码行数:15,代码来源:ChainedResourceManager.java

示例8: init

import io.undertow.server.handlers.resource.ResourceManager; //导入依赖的package包/类
@Override
public void init(Map<String, String> properties, ResourceManager resourceManager) {
    this.resourceManager = resourceManager;
    engine = MustacheEngineBuilder
            .newBuilder()
            .registerHelpers(HelpersBuilder.extra().build())
            .addTemplateLocator(new ResourceManagerTemplateLocator())
            .setProperty(EngineConfigurationKey.DEBUG_MODE, Boolean.parseBoolean(properties.get("debug")))
            .setProperty(EngineConfigurationKey.DEFAULT_FILE_ENCODING, properties.containsKey("charset") ? properties.get("charset") : "UTF-8")
            .build();
}
 
开发者ID:undertow-io,项目名称:undertow.js,代码行数:12,代码来源:TrimouTemplateProvider.java

示例9: UndertowSupport

import io.undertow.server.handlers.resource.ResourceManager; //导入依赖的package包/类
public UndertowSupport(RoutingHandler routingHandler, ClassLoader classLoader, Map<String, InjectionProvider> injectionProviders, JavabeanIntrospector javabeanIntrospector, List<HandlerWrapper> handlerWrappers, ResourceManager resourceManager, RoutingHandler wsRoutingHandler, Map<String, TemplateProvider> templateProviders) {
    this.routingHandler = routingHandler;
    this.classLoader = classLoader;
    this.injectionProviders = injectionProviders;
    this.javabeanIntrospector = javabeanIntrospector;
    this.handlerWrappers = handlerWrappers;
    this.resourceManager = resourceManager;
    this.wsRoutingHandler = wsRoutingHandler;
    this.templateProviders = templateProviders;
}
 
开发者ID:undertow-io,项目名称:undertow.js,代码行数:11,代码来源:UndertowJS.java

示例10: getResourceManager

import io.undertow.server.handlers.resource.ResourceManager; //导入依赖的package包/类
private ResourceManager getResourceManager(File warFile, Long transferMinSize, String cfmlDirs, File internalCFMLServerRoot) {
    MappedResourceManager mappedResourceManager = new MappedResourceManager(warFile, transferMinSize, cfmlDirs, internalCFMLServerRoot);
    if(serverOptions.isDirectoryListingRefreshEnabled()) return mappedResourceManager;
    final DirectBufferCache dataCache = new DirectBufferCache(1000, 10, 1000 * 10 * 1000, BufferAllocator.DIRECT_BYTE_BUFFER_ALLOCATOR, METADATA_MAX_AGE);
    final int metadataCacheSize = 100;
    final long maxFileSize = 10000;
    return new CachingResourceManager(metadataCacheSize,maxFileSize, dataCache, mappedResourceManager, METADATA_MAX_AGE);
}
 
开发者ID:cfmlprojects,项目名称:runwar,代码行数:9,代码来源:Server.java

示例11: createStaticContentHandler

import io.undertow.server.handlers.resource.ResourceManager; //导入依赖的package包/类
static ResourceHandlerDefinition createStaticContentHandler(ResourceManager resource, String context) {
    final io.undertow.server.handlers.resource.ResourceHandler handler = new io.undertow.server.handlers.resource.ResourceHandler(resource)
            .setCacheTime(60 * 60 * 24 * 31)
            .setAllowed(not(path("META-INF")))
            .setResourceManager(resource)
            .setDirectoryListingEnabled(false)
            .setCachable(not(suffixes(NOCACHE_JS, APP_HTML, INDEX_HTML)));

    // avoid clickjacking attacks: console must not be included in (i)frames
    SetHeaderHandler frameHandler = new SetHeaderHandler(handler, "X-Frame-Options", "SAMEORIGIN");
    // we also need to setup the default resource redirect
    PredicateHandler predicateHandler = new PredicateHandler(path("/"), new RedirectHandler(ExchangeAttributes.constant(context + DEFAULT_RESOURCE)), frameHandler);
    return new ResourceHandlerDefinition(context, DEFAULT_RESOURCE, predicateHandler);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:15,代码来源:DomainUtil.java

示例12: addStaticContext

import io.undertow.server.handlers.resource.ResourceManager; //导入依赖的package包/类
public void addStaticContext(String contextName, ResourceManager resourceManager) {
    Assert.checkNotNullParam("contextName", contextName);
    Assert.checkNotNullParam("resourceManager", resourceManager);
    String context = fixPath(contextName);
    // Reject reserved contexts or duplicate extensions
    if (extensionHandlers.reservedContexts.contains(context) || !extensionHandlers.extensionContexts.add(context)) {
        throw new IllegalStateException();
    }
    ResourceHandlerDefinition def = DomainUtil.createStaticContentHandler(resourceManager, context);
    HttpHandler readinessHandler = new RedirectReadinessHandler(extensionHandlers.readyFunction, def.getHandler(),
            ErrorContextHandler.ERROR_CONTEXT);
    extensionHandlers.extensionPathHandler.addPrefixPath(context, readinessHandler);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:14,代码来源:ManagementHttpServer.java

示例13: newResourceManager

import io.undertow.server.handlers.resource.ResourceManager; //导入依赖的package包/类
protected ResourceManager newResourceManager(OptionMap config) {
	if (this.loadFrom == null) {
		return new FileResourceManager(new File(this.root),
				config.get(Config.TRANSFER_MIN_SIZE));
	}
	return new ClassPathResourceManager(this.loadFrom, this.root);
}
 
开发者ID:taichi,项目名称:siden,代码行数:8,代码来源:AssetDef.java

示例14: wrapWithStaticHandler

import io.undertow.server.handlers.resource.ResourceManager; //导入依赖的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

示例15: getIndexFiles

import io.undertow.server.handlers.resource.ResourceManager; //导入依赖的package包/类
protected Resource getIndexFiles(ResourceManager resourceManager, final String base, List<String> possible) throws IOException {
    String realBase;
    if (base.endsWith("/")) {
        realBase = base;
    } else {
        realBase = base + "/";
    }
    for (String possibility : possible) {
        Resource index = resourceManager.getResource(realBase + possibility);
        if (index != null) {
            return index;
        }
    }
    return null;
}
 
开发者ID:projectodd,项目名称:wunderboss,代码行数:16,代码来源:UndertowWeb.java


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