當前位置: 首頁>>代碼示例>>Java>>正文


Java ClasspathHelper.forPackage方法代碼示例

本文整理匯總了Java中org.reflections.util.ClasspathHelper.forPackage方法的典型用法代碼示例。如果您正苦於以下問題:Java ClasspathHelper.forPackage方法的具體用法?Java ClasspathHelper.forPackage怎麽用?Java ClasspathHelper.forPackage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.reflections.util.ClasspathHelper的用法示例。


在下文中一共展示了ClasspathHelper.forPackage方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: prepareAndgetContextListener

import org.reflections.util.ClasspathHelper; //導入方法依賴的package包/類
/**
 * Prepares the logger context. Locates the context and
 * sets the configuration file.
 * @return the logger context
 */
private ServletContextListener prepareAndgetContextListener() {
    try {
        if (StringUtils.isNotBlank(this.loggerContextPackageName)) {
            final Collection<URL> set = ClasspathHelper.forPackage(this.loggerContextPackageName);
            final Reflections reflections = new Reflections(new ConfigurationBuilder().addUrls(set).setScanners(new SubTypesScanner()));
            final Set<Class<? extends ServletContextListener>> subTypesOf = reflections.getSubTypesOf(ServletContextListener.class);
            final ServletContextListener loggingContext = subTypesOf.iterator().next().newInstance();
            this.context.setInitParameter(this.logConfigurationField, this.logConfigurationFile.getURI().toString());
            return loggingContext;
        }
        return null;
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:21,代碼來源:CasLoggerContextInitializer.java

示例2: scanContextForLoggerFactories

import org.reflections.util.ClasspathHelper; //導入方法依賴的package包/類
private Set<Class<? extends ILoggerFactory>> scanContextForLoggerFactories() {
    final Set<Class<? extends ILoggerFactory>> loggerFactories;
    final Collection<URL> set = ClasspathHelper.forPackage(PACKAGE_TO_SCAN);
    final Reflections reflections = new Reflections(new ConfigurationBuilder().addUrls(set).setScanners(new SubTypesScanner()));

    loggerFactories = reflections.getSubTypesOf(ILoggerFactory.class);
    loggerFactories.remove(this.getClass());
    return loggerFactories;
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:10,代碼來源:CasLoggerFactory.java

示例3: CasLoggerFactory

import org.reflections.util.ClasspathHelper; //導入方法依賴的package包/類
/**
 * Instantiates a new Cas logger factory.
 * Configures the reflection scanning engine to be prepared to scan <code>org.slf4j.impl</code>
 * in order to find other available factories.
 */
public CasLoggerFactory() {
    this.loggerMap = new ConcurrentHashMap<>();
    final Collection<URL> set = ClasspathHelper.forPackage(PACKAGE_TO_SCAN);
    final Reflections reflections = new Reflections(new ConfigurationBuilder().addUrls(set).setScanners(new SubTypesScanner()));

    final Set<Class<? extends ILoggerFactory>> subTypesOf = reflections.getSubTypesOf(ILoggerFactory.class);
    subTypesOf.remove(this.getClass());

    if (subTypesOf.size() > 1) {
        Util.report("Multiple ILoggerFactory bindings are found on the classpath:");
        for (final Class<? extends ILoggerFactory> c : subTypesOf) {
            Util.report("* " + c.getCanonicalName());
        }
    }

    if (subTypesOf.isEmpty()) {
        final RuntimeException e = new RuntimeException("No ILoggerFactory could be found on the classpath."
                + " CAS cannot determine the logging framework."
                + " Examine the project dependencies and ensure that there is one and only one logging framework available.");

        Util.report(e.getMessage(), e);
        throw e;
    }
    this.realLoggerFactoryClass = subTypesOf.iterator().next();
    Util.report("ILoggerFactory to be used for logging is: " + this.realLoggerFactoryClass.getName());
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:32,代碼來源:CasLoggerFactory.java

示例4: getSubClasses

import org.reflections.util.ClasspathHelper; //導入方法依賴的package包/類
private <CLASS> LinkedHashSet<Class<? extends CLASS>> getSubClasses(final Class<?> clazz, final String packageName) {
    final Set<URL> urls = new HashSet<>(ClasspathHelper.forPackage("gaffer"));

    final List<Class<? extends CLASS>> classes = new ArrayList(new Reflections(urls).getSubTypesOf(clazz));
    keepPublicConcreteClasses(classes);
    keepClassesInPackage(classes, packageName);
    Collections.sort(classes, new Comparator<Class>() {
        @Override
        public int compare(final Class class1, final Class class2) {
            return class1.getName().compareTo(class2.getName());
        }
    });

    return Sets.newLinkedHashSet((Iterable) classes);
}
 
開發者ID:gchq,項目名稱:gaffer-doc,代碼行數:16,代碼來源:ExampleDocRunner.java

示例5: _urlsForPackage

import org.reflections.util.ClasspathHelper; //導入方法依賴的package包/類
private static Collection<URL> _urlsForPackage(final String pckg,
                                                  final ClassLoader otherClassLoader) {
	ClassLoader[] classLoaders = _scanClassLoaders(otherClassLoader);
        
	// org.reflections.ClasspathHelper seems to return ONLY the jar or path containing the given package
	// ... so the package MUST be added back to the url to minimize scan time and unneeded class loading
       Collection<URL> outUrls = ClasspathHelper.forPackage(pckg,
                                                            classLoaders);
       if (CollectionUtils.hasData(outUrls)) {
       	outUrls = FluentIterable.from(outUrls)
                                   .transform(new Function<URL,URL>() {
													@Override
													public URL apply(final URL url) {
														try {
															URL fullUrl = new URL(url.toString() + _resourceName(pckg));
															log.trace("URL to be scanned: {}",fullUrl);
													        return fullUrl;
													    } catch(Throwable th) {
													    	th.printStackTrace(System.out);
													    }
													    return url;
													}
                                              })
                                   .toList();
        }
        return outUrls;
}
 
開發者ID:opendata-euskadi,項目名稱:r01fb,代碼行數:28,代碼來源:ServicesPackages.java

示例6: scan

import org.reflections.util.ClasspathHelper; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
private Map<Class<?>, Converter<?>> scan(ClassLoader... classloaders) {
	if (log.isDebugEnabled())
		log.debug("scan <-");
	
	Collection<URL> urls = ClasspathHelper.forPackage("play.utils.meta.convert", classloaders);
	if (log.isDebugEnabled())
		log.debug("urls : " + urls);

	Configuration configs = new ConfigurationBuilder().setUrls(
			urls).addClassLoaders(classloaders).setScanners(new SubTypesScanner(false));
	
	final Reflections reflections = new Reflections(configs);

	Map<Class<?>, Converter<?>> map = Maps.newHashMap();
	Set<Class<? extends Converter>> converterClasses = reflections.getSubTypesOf(Converter.class);
	if (log.isDebugEnabled())
		log.debug("converterClasses : " + converterClasses);

	for (Class<? extends Converter> converterClass : converterClasses) {
		try {
			if (log.isDebugEnabled())
				log.debug("converterClass : " + converterClass);

			Converter converter = converterClass.newInstance();
			if (converter != null) {
				Class<?> keyClass = converter.typeClass();
				log.info("Converter:" + keyClass + " : " + converter);
				map.put(keyClass, converter);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	return map;
}
 
開發者ID:hakandilek,項目名稱:play2-crud,代碼行數:37,代碼來源:ClasspathScanningConverterRegistry.java

示例7: dirWithSpaces

import org.reflections.util.ClasspathHelper; //導入方法依賴的package包/類
@Test public void dirWithSpaces() {
    Collection<URL> urls = ClasspathHelper.forPackage("dir+with spaces");
    assertFalse(urls.isEmpty());
    for (URL url : urls) {
        testVfsDir(url);
    }
}
 
開發者ID:ronmamo,項目名稱:reflections,代碼行數:8,代碼來源:VfsTest.java

示例8: addPackage

import org.reflections.util.ClasspathHelper; //導入方法依賴的package包/類
public void addPackage(String packageName) {
	ConfigurationBuilder config = new ConfigurationBuilder();
	FilterBuilder fb = new FilterBuilder();
	fb.include(FilterBuilder.prefix(packageName));
	config.filterInputsBy(fb);
	Set<URL> urls = ClasspathHelper.forPackage(packageName);
	urls = GoogleReflectionsUtil.fixURLs(urls); //jboss compatibility hack
	config.setUrls(urls);
	Reflections packageReflections = new Reflections(config);
	//packageReflections = new Reflections(packageName);
	reflections.merge(packageReflections);
	refresh();
}
 
開發者ID:java-prolog-connectivity,項目名稱:logicobjects,代碼行數:14,代碼來源:ClassPathContext.java

示例9: listLanguageSpecificationPlugins

import org.reflections.util.ClasspathHelper; //導入方法依賴的package包/類
private List<Class<? extends LanguageSpecification>> listLanguageSpecificationPlugins() {
	Reflections reflections = new Reflections(ClasspathHelper.forPackage("de.uniwue.info2"), new SubTypesScanner());

	Set<Class<? extends LanguageSpecification>> modules = reflections.getSubTypesOf(de.uniwue.info2.generator.LanguageSpecification.class);
	List<Class<? extends LanguageSpecification>> specs = new ArrayList<Class<? extends LanguageSpecification>>(modules);

	return specs;
}
 
開發者ID:kolbasa,項目名稱:IaTestGen,代碼行數:9,代碼來源:LanguageFactory.java

示例10: listUnitTestLibrarySpecificationPlugins

import org.reflections.util.ClasspathHelper; //導入方法依賴的package包/類
private List<Class<? extends UnitTestLibrarySpecification>> listUnitTestLibrarySpecificationPlugins(Package lang_package) {
	Reflections reflections = new Reflections(ClasspathHelper.forPackage("de.uniwue.info2"), new SubTypesScanner());

	Set<Class<? extends UnitTestLibrarySpecification>> modules = reflections
			.getSubTypesOf(de.uniwue.info2.generator.UnitTestLibrarySpecification.class);
	List<Class<? extends UnitTestLibrarySpecification>> specs = new ArrayList<Class<? extends UnitTestLibrarySpecification>>();
	for (Class<? extends UnitTestLibrarySpecification> u : modules) {
		if (u.getPackage().equals(lang_package)) {
			specs.add(u);
		}
	}

	return specs;
}
 
開發者ID:kolbasa,項目名稱:IaTestGen,代碼行數:15,代碼來源:LanguageFactory.java

示例11: listArithmeticLibrarySpecificationPlugins

import org.reflections.util.ClasspathHelper; //導入方法依賴的package包/類
private List<Class<? extends ArithmeticLibrarySpecification>> listArithmeticLibrarySpecificationPlugins(Package lang_package) {
	Reflections reflections = new Reflections(ClasspathHelper.forPackage("de.uniwue.info2"), new SubTypesScanner());

	Set<Class<? extends ArithmeticLibrarySpecification>> modules = reflections
			.getSubTypesOf(de.uniwue.info2.generator.ArithmeticLibrarySpecification.class);
	List<Class<? extends ArithmeticLibrarySpecification>> specs = new ArrayList<Class<? extends ArithmeticLibrarySpecification>>();
	for (Class<? extends ArithmeticLibrarySpecification> a : modules) {
		if (a.getPackage().equals(lang_package)) {
			specs.add(a);
		}
	}

	return specs;
}
 
開發者ID:kolbasa,項目名稱:IaTestGen,代碼行數:15,代碼來源:LanguageFactory.java

示例12: forPackage

import org.reflections.util.ClasspathHelper; //導入方法依賴的package包/類
/**
 * Creates an {@code EntityFinder} for the provided package.
 *
 * @param project     The Maven project in which the calling Mojo is
 *                    executed. Can be {@code null}.
 * @param log         An Maven log object for creating output.
 * @param packageName The name of the package in the class should look for
 *                    entities.
 *
 * @return An {@code EntityFinder} instance.
 *
 * @throws MojoFailureException If the {@link Reflections} instance needed
 *                              by the {@code EntityFinder} can't be
 *                              created.
 */
@SuppressWarnings("unchecked")
public static EntityFinder forPackage(final MavenProject project,
                                      final Log log,
                                      final String packageName)
    throws MojoFailureException {
    final Reflections reflections;
    if (project == null) {
        reflections = new Reflections(
            ClasspathHelper.forPackage(packageName));
    } else {
        final List<String> classPathElems;
        try {
            classPathElems = project.getCompileClasspathElements();
        } catch (DependencyResolutionRequiredException ex) {
            throw new MojoFailureException(
                "Failed to resolve project classpath.", ex);
        }
        final List<URL> classPathUrls = new ArrayList<>();
        for (final String classPathElem : classPathElems) {
            log.info(String.format("Adding classpath elemement '%s'...",
                                   classPathElem));
            classPathUrls.add(classPathElemToUrl(classPathElem));
        }

        log.info("Classpath URLs:");
        for (final URL url : classPathUrls) {
            log.info(String.format("\t%s", url.toString()));
        }

        //Here we have to do some classloader magic to ensure that the 
        //Reflections instance uses the correct class loader. Which is the 
        //one which has access to the compiled classes
        final ClassLoader classLoader = AccessController
            .doPrivileged(new ClassLoaderCreator(classPathUrls));

        reflections = new Reflections(
            ClasspathHelper.forPackage(packageName, classLoader));

    }

    return new EntityFinder(reflections);
}
 
開發者ID:jpdigital,項目名稱:hibernate5-ddl-maven-plugin,代碼行數:58,代碼來源:EntityFinder.java

示例13: runMethodParallelAppium

import org.reflections.util.ClasspathHelper; //導入方法依賴的package包/類
public boolean runMethodParallelAppium(List<String> test, String pack, int devicecount,
                                       String executionType) throws Exception {
    URL newUrl = null;
    List<URL> newUrls = new ArrayList<>();
    Collections.addAll(items, pack.split("\\s*,\\s*"));
    int a = 0;
    Collection<URL> urls = ClasspathHelper.forPackage(items.get(a));
    Iterator<URL> iter = urls.iterator();
    URL url = iter.next();
    urls.clear();
    for (int i = 0; i < items.size(); i++) {
        newUrl = new URL(url.toString() + items.get(i).replaceAll("\\.", "/"));
        newUrls.add(newUrl);
        a++;

    }
    Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(newUrls)
            .setScanners(new MethodAnnotationsScanner()));
    Set<Method> resources =
            reflections.getMethodsAnnotatedWith(org.testng.annotations.Test.class);
    boolean hasFailure;

    String runnerLevel = System.getenv("RUNNER_LEVEL") != null
            ? System.getenv("RUNNER_LEVEL") : prop.getProperty("RUNNER_LEVEL");

    if (executionType.equalsIgnoreCase("distribute")) {
        if (runnerLevel != null
                && runnerLevel.equalsIgnoreCase("class")) {
            constructXmlSuiteForDistribution(pack, test, createTestsMap(resources),
                    devicecount);
        } else {
            constructXmlSuiteForDistributionMethods(pack, test, createTestsMap(resources),
                    devicecount);
        }

        hasFailure = runMethodParallel();
    } else {
        constructXmlSuiteForParallel(pack, test, createTestsMap(resources), devicecount,
                deviceAllocationManager.getDevices());
        hasFailure = runMethodParallel();
    }
    System.out.println("Finally complete");
    ParallelThread.figlet("Test Completed");
    //ImageUtils.creatResultsSet();
    //ImageUtils.createJSonForHtml();
    return hasFailure;
}
 
開發者ID:saikrishna321,項目名稱:AppiumTestDistribution,代碼行數:48,代碼來源:MyTestExecutor.java


注:本文中的org.reflections.util.ClasspathHelper.forPackage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。