org.apache.tomcat.util.scan.Constants Java Examples

The following examples show how to use org.apache.tomcat.util.scan.Constants. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TomcatServer.java    From javatech with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
@Override
public Server getServer() {
    if (server != null) {
        return server;
    }
    // 默认不开启JNDI. 开启时, 注意maven必须添加tomcat-dbcp依赖
    System.setProperty("catalina.useNaming", "false");
    ExtendedCatalina extendedCatalina = new ExtendedCatalina();

    // 覆盖默认的skip和scan jar包配置
    System.setProperty(Constants.SKIP_JARS_PROPERTY, "");
    System.setProperty(Constants.SCAN_JARS_PROPERTY, "");

    Digester digester = extendedCatalina.createStartDigester();
    digester.push(extendedCatalina);
    try {
        server = ((ExtendedCatalina) digester
            .parse(new File(System.getProperty("catalina.base") + RELATIVE_SERVERXML_PATH))).getServer();
        // 设置catalina.base和catalna.home
        this.initBaseDir();
        return server;
    } catch (Exception e) {
        log.error("Error while parsing server.xml", e);
        throw new RuntimeException("server未创建,请检查server.xml(路径:" + System.getProperty("catalina.base")
            + RELATIVE_SERVERXML_PATH + ")配置是否正确");
    }
}
 
Example #2
Source File: OWBJarScanner.java    From openwebbeans-meecrowave with Apache License 2.0 5 votes vote down vote up
@Override
public void scan(final JarScanType jarScanType, final ServletContext servletContext, final JarScannerCallback callback) {
    switch (jarScanType) {
        case PLUGGABILITY:
            CdiArchive.class.cast(WebScannerService.class.cast(WebBeansContext.getInstance().getScannerService()).getFinder().getArchive())
                    .classesByUrl().keySet().stream()
                    .filter(u -> !"jar:file://!/".equals(u)) // not a fake in memory url
                    .forEach(u -> {
                        try {
                            final URL url = new URL(u);
                            final File asFile = Files.toFile(url);
                            if (!asFile.exists()) {
                                return;
                            }
                            if (filter != null && !filter.check(jarScanType, asFile.getName())) {
                                return;
                            }

                            if (asFile.getName().endsWith(Constants.JAR_EXT)) {
                                try (final Jar jar = JarFactory.newInstance(asFile.toURI().toURL())) {
                                    callback.scan(jar, u, true);
                                }
                            } else if (asFile.isDirectory()) {
                                callback.scan(asFile, asFile.getAbsolutePath(), true);
                            }
                        } catch (final MalformedURLException e) {
                            // skip
                        } catch (final IOException ioe) {
                            throw new IllegalArgumentException(ioe);
                        }
                    });
            return;

        case TLD:
        default:
    }
}
 
Example #3
Source File: AbstractSpringTest.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@BeforeAll
public static void init() {
	setOmHome();
	System.setProperty(Constants.SKIP_JARS_PROPERTY, "*");
	LabelDao.initLanguageMap();
	if (LabelDao.getLanguages().isEmpty()) {
		fail("Failed to set languages");
	}
}
 
Example #4
Source File: TomcatCustomServer.java    From nano-framework with Apache License 2.0 5 votes vote down vote up
protected void init(final String contextRoot, final String resourceBase) throws ServletException, IOException {
    final Path basePath = Files.createTempDirectory(DEFAULT_TOMCAT_BASE_TEMP_DIR);
    setBaseDir(basePath.toString());

    if (StringUtils.isNotEmpty(resourceBase)) {
        this.resourceBase = resourceBase;
    }

    initExecutor();
    initConnector();

    final ContextConfig conf = new ContextConfig();
    final StandardContext ctx = (StandardContext) this.addWebapp(getHost(), contextRoot, new File(this.resourceBase).getAbsolutePath(), conf);
    createGlobalXml();
    conf.setDefaultWebXml(globalWebXml.getAbsolutePath());

    for (LifecycleListener listen : ctx.findLifecycleListeners()) {
        if (listen instanceof DefaultWebXmlListener) {
            ctx.removeLifecycleListener(listen);
        }
    }

    ctx.setParentClassLoader(TomcatCustomServer.class.getClassLoader());

    //Disable TLD scanning by default
    if (System.getProperty(Constants.SKIP_JARS_PROPERTY) == null && System.getProperty(Constants.SKIP_JARS_PROPERTY) == null) {
        LOGGER.debug("disabling TLD scanning");
        StandardJarScanFilter jarScanFilter = (StandardJarScanFilter) ctx.getJarScanner().getJarScanFilter();
        jarScanFilter.setTldSkip("*");
    }
}