org.apache.http.impl.auth.DigestScheme#org.lastaflute.di.core.factory.SingletonLaContainerFactory源码实例Demo

下面列出了org.apache.http.impl.auth.DigestScheme#org.lastaflute.di.core.factory.SingletonLaContainerFactory 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: lastaflute   文件: LastaPrepareFilter.java
protected void viaLastaDiContext(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    final LaContainer container = SingletonLaContainerFactory.getContainer();
    final ExternalContext externalContext = container.getExternalContext();
    if (externalContext == null) {
        throw new IllegalStateException("The externalContext should not be null from the container: " + container);
    }
    final Object prevoiusRequest = externalContext.getRequest();
    final Object previousResponse = externalContext.getResponse();
    try {
        externalContext.setRequest(request);
        externalContext.setResponse(response);
        viaHotdeploy(request, response, chain); // #to_action
    } finally {
        externalContext.setRequest(prevoiusRequest);
        externalContext.setResponse(previousResponse);
    }
}
 
源代码2 项目: fess   文件: PathMappingHelper.java
private boolean matchUserAgent(final PathMapping pathMapping) {
    if (!pathMapping.hasUAMathcer()) {
        return true;
    }

    if (SingletonLaContainerFactory.getExternalContext().getRequest() != null) {
        return LaRequestUtil.getOptionalRequest().map(request -> {
            final String userAgent = request.getHeader("user-agent");
            if (StringUtil.isBlank(userAgent)) {
                return false;
            }

            return pathMapping.getUAMatcher(userAgent).find();
        }).orElse(false);
    }
    return false;
}
 
源代码3 项目: fess   文件: FessPropTest.java
public void test_maxUsernameLength() throws IOException {
    FessProp.propMap.clear();
    FessConfig fessConfig = new FessConfig.SimpleImpl() {
        @Override
        public Integer getLdapMaxUsernameLengthAsInteger() {
            return Integer.valueOf(-1);
        }
    };
    File file = File.createTempFile("test", ".properties");
    file.deleteOnExit();
    FileUtil.writeBytes(file.getAbsolutePath(), "ldap.security.principal=%[email protected]".getBytes("UTF-8"));
    DynamicProperties systemProps = new DynamicProperties(file);
    SingletonLaContainerFactory.getContainer().register(systemProps, "systemProperties");

    assertEquals("@fess.codelibs.local", fessConfig.getLdapSecurityPrincipal(null));
    assertEquals("@fess.codelibs.local", fessConfig.getLdapSecurityPrincipal(""));
    assertEquals("[email protected]", fessConfig.getLdapSecurityPrincipal("123456789"));
    assertEquals("[email protected]", fessConfig.getLdapSecurityPrincipal("1234567890"));
    assertEquals("[email protected]", fessConfig.getLdapSecurityPrincipal("12345678901"));
}
 
源代码4 项目: fess   文件: FessPropTest.java
public void test_maxUsernameLength10() throws IOException {
    FessProp.propMap.clear();
    FessConfig fessConfig = new FessConfig.SimpleImpl() {
        @Override
        public Integer getLdapMaxUsernameLengthAsInteger() {
            return Integer.valueOf(10);
        }
    };

    File file = File.createTempFile("test", ".properties");
    file.deleteOnExit();
    FileUtil.writeBytes(file.getAbsolutePath(), "ldap.security.principal=%[email protected]".getBytes("UTF-8"));
    DynamicProperties systemProps = new DynamicProperties(file);
    SingletonLaContainerFactory.getContainer().register(systemProps, "systemProperties");

    assertEquals("@fess.codelibs.local", fessConfig.getLdapSecurityPrincipal(null));
    assertEquals("@fess.codelibs.local", fessConfig.getLdapSecurityPrincipal(""));
    assertEquals("[email protected]", fessConfig.getLdapSecurityPrincipal("123456789"));
    assertEquals("[email protected]", fessConfig.getLdapSecurityPrincipal("1234567890"));
    assertEquals("[email protected]", fessConfig.getLdapSecurityPrincipal("12345678901"));
}
 
源代码5 项目: lastaflute   文件: WebLastaContainerInitializer.java
protected void setupExternalContext() {
    if (ComponentDeployerFactory.getProvider() instanceof ComponentDeployerFactory.DefaultProvider) {
        ComponentDeployerFactory.setProvider(newExternalComponentDeployerProvider());
    }
    final HttpServletExternalContext externalContext = newHttpServletExternalContext();
    externalContext.setApplication(application);
    SingletonLaContainerFactory.setExternalContext(externalContext);
    SingletonLaContainerFactory.setExternalContextComponentDefRegister(newHttpServletExternalContextComponentDefRegister());
}
 
源代码6 项目: lastaflute   文件: ContainerUtil.java
/**
 * @return The external context of Lasta Di. (NotNull)
 * @throws IllegalStateException When the external context is not found.
 */
public static ExternalContext retrieveExternalContext() {
    final ExternalContext context = SingletonLaContainerFactory.getExternalContext();
    if (context == null) {
        throw new IllegalStateException("Not found external context in Lasta Di container.");
    }
    return context;
}
 
源代码7 项目: fess   文件: Crawler.java
private static void destroyContainer() {
    if (running.getAndSet(false)) {
        TimeoutManager.getInstance().stop();
        if (logger.isDebugEnabled()) {
            logger.debug("Destroying LaContainer...");
        }
        SingletonLaContainerFactory.destroy();
        logger.info("Destroyed LaContainer.");
    }
}
 
源代码8 项目: lastaflute   文件: ModuleConfig.java
protected void prepareActionComponent(String actionName) {
    SingletonLaContainerFactory.getContainer().getComponent(actionName); // initialize
}
 
源代码9 项目: lastaflute   文件: WebLastaContainerInitializer.java
protected boolean isAlreadyInitialized() {
    return SingletonLaContainerFactory.hasContainer();
}
 
源代码10 项目: lastaflute   文件: WebLastaContainerInitializer.java
protected void setupOriginalConfigPath() {
    if (!LdiStringUtil.isEmpty(configPath)) {
        SingletonLaContainerFactory.setConfigPath(configPath);
    }
}
 
源代码11 项目: lastaflute   文件: WebLastaContainerInitializer.java
protected void doInitContainer() {
    SingletonLaContainerFactory.init();
}
 
源代码12 项目: lastaflute   文件: ComponentEnvDispatcher.java
public static boolean canDispatch(Class<?> componentClass) { // check before without instance
    return SingletonLaContainerFactory.hasContainer() && findEnvDispatch(componentClass) != null;
}
 
源代码13 项目: fess   文件: ThumbnailGenerator.java
private static void destroyContainer() {
    TimeoutManager.getInstance().stop();
    synchronized (SingletonLaContainerFactory.class) {
        SingletonLaContainerFactory.destroy();
    }
}
 
源代码14 项目: fess   文件: SuggestCreator.java
private static void destroyContainer() {
    TimeoutManager.getInstance().stop();
    synchronized (SingletonLaContainerFactory.class) {
        SingletonLaContainerFactory.destroy();
    }
}
 
源代码15 项目: fess   文件: ComponentUtil.java
public static boolean hasViewHelper() {
    return SingletonLaContainerFactory.getContainer().hasComponentDef(VIEW_HELPER);
}
 
源代码16 项目: fess   文件: ComponentUtil.java
public static boolean hasQueryHelper() {
    return SingletonLaContainerFactory.getContainer().hasComponentDef(QUERY_HELPER);
}
 
源代码17 项目: fess   文件: ComponentUtil.java
public static boolean hasPopularWordHelper() {
    return SingletonLaContainerFactory.getContainer().hasComponentDef(POPULAR_WORD_HELPER);
}
 
源代码18 项目: fess   文件: ComponentUtil.java
public static boolean hasRelatedQueryHelper() {
    return SingletonLaContainerFactory.getContainer().hasComponentDef(RELATED_QUERY_HELPER);
}
 
源代码19 项目: fess   文件: ComponentUtil.java
public static boolean hasIngestFactory() {
    return SingletonLaContainerFactory.getContainer().hasComponentDef(INGEST_FACTORY);
}
 
源代码20 项目: fess   文件: FessXpathTransformerTest.java
public void test_transform() throws Exception {
    String data = "<html><head><title>Test</title></head><body><h1>Header1</h1><p>This is a pen.</p></body></html>";

    final FessXpathTransformer fessXpathTransformer = new FessXpathTransformer();
    fessXpathTransformer.init();
    SingletonLaContainerFactory.getContainer().register(CrawlingInfoHelper.class, "crawlingInfoHelper");
    SingletonLaContainerFactory.getContainer().register(PathMappingHelper.class, "pathMappingHelper");
    SingletonLaContainerFactory.getContainer().register(CrawlingConfigHelper.class, "crawlingConfigHelper");
    SingletonLaContainerFactory.getContainer().register(SystemHelper.class, "systemHelper");
    SingletonLaContainerFactory.getContainer().register(FileTypeHelper.class, "fileTypeHelper");
    SingletonLaContainerFactory.getContainer().register(DocumentHelper.class, "documentHelper");
    SingletonLaContainerFactory.getContainer().register(LabelTypeHelper.class, "labelTypeHelper");

    WebConfig webConfig = new WebConfig();
    ComponentUtil.getCrawlingConfigHelper().store("test", webConfig);
    setValueToObject(ComponentUtil.getLabelTypeHelper(), "labelTypePatternList", new ArrayList<LabelTypePattern>());

    long max = 0;
    for (int i = 0; i < 10000; i++) {
        if (i % 1000 == 0) {
            logger.info(MemoryUtil.getMemoryUsageLog() + ":" + i);
            long mem = MemoryUtil.getUsedMemory();
            if (max < mem) {
                max = mem;
            }
        }
        ResponseData responseData = new ResponseData();
        responseData.setCharSet("UTF-8");
        responseData.setContentLength(data.length());
        responseData.setExecutionTime(1000L);
        responseData.setHttpStatusCode(200);
        responseData.setLastModified(new Date());
        responseData.setMethod("GET");
        responseData.setMimeType("text/html");
        responseData.setParentUrl("http://fess.codelibs.org/");
        responseData.setResponseBody(data.getBytes());
        responseData.setSessionId("test-1");
        responseData.setStatus(0);
        responseData.setUrl("http://fess.codelibs.org/test.html");
        /*ResultData resultData =*/fessXpathTransformer.transform(responseData);
        // System.out.println(resultData.toString());
    }

    System.gc();
    Thread.sleep(1000L);
    logger.info(MemoryUtil.getMemoryUsageLog());
    assertTrue(MemoryUtil.getUsedMemory() < max - 100000000L);
}
 
源代码21 项目: lastaflute   文件: ContainerUtil.java
/**
 * @param componentType The component type to find. (NotNull)
 * @return The array of found components. (NotNull)
 * @throws CyclicReferenceComponentException When the components refers each other.
 */
@SuppressWarnings("unchecked")
public static <COMPONENT> COMPONENT[] searchComponents(Class<COMPONENT> componentType) {
    return (COMPONENT[]) SingletonLaContainerFactory.getContainer().findComponents(componentType);
}
 
源代码22 项目: lastaflute   文件: ContainerUtil.java
/**
 * @param componentType The component type to find. (NotNull)
 * @return The array of found components. (NotNull)
 * @throws CyclicReferenceComponentException When the components refers each other.
 */
@SuppressWarnings("unchecked")
public static <COMPONENT> COMPONENT[] searchComponentsAll(Class<COMPONENT> componentType) {
    return (COMPONENT[]) SingletonLaContainerFactory.getContainer().findAllComponents(componentType);
}
 
源代码23 项目: lastaflute   文件: ContainerUtil.java
/**
 * @param componentType The component type to find. (NotNull)
 * @return The determination, true or false.
 */
public static boolean hasComponent(Class<?> componentType) {
    return SingletonLaContainerFactory.getContainer().hasComponentDef(componentType);
}
 
源代码24 项目: lastaflute   文件: ContainerUtil.java
/**
 * @param componentName The component name to find. (NotNull)
 * @return The determination, true or false.
 */
public static boolean proveComponentByName(String componentName) {
    return SingletonLaContainerFactory.getContainer().hasComponentDef(componentName);
}
 
源代码25 项目: lastaflute   文件: ContainerUtil.java
/**
 * Does the Lasta Di have external context instance?
 * @return The determination, true or false.
 */
public static boolean hasExternalContext() {
    return SingletonLaContainerFactory.getExternalContext() != null;
}