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


Java ClasspathHelper类代码示例

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


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

示例1: GuiceApplication

import org.reflections.util.ClasspathHelper; //导入依赖的package包/类
protected GuiceApplication(String... basePackages) {
  final ConfigurationBuilder confBuilder = new ConfigurationBuilder();
  final FilterBuilder filterBuilder = new FilterBuilder();

  if (basePackages.length == 0) {
    basePackages = new String[] {};
  }

  logger.info("op=create, auto_scan_packages={}", (Object[]) basePackages);

  for (String pkg : basePackages) {
    confBuilder.addUrls(ClasspathHelper.forPackage(pkg));
    filterBuilder.include(FilterBuilder.prefix(pkg));
  }

  confBuilder.filterInputsBy(filterBuilder)
      .setScanners(new SubTypesScanner(), new TypeAnnotationsScanner());

  this.reflections = new Reflections(confBuilder);
}
 
开发者ID:dehora,项目名称:outland,代码行数:21,代码来源:GuiceApplication.java

示例2: fromConfigWithPackage

import org.reflections.util.ClasspathHelper; //导入依赖的package包/类
/**
 * Scans the specified packages for annotated classes, and applies Config values to them.
 * 
 * @param config the Config to derive values from
 * @param packageNamePrefix the prefix to limit scanning to - e.g. "com.github"
 * @return The constructed TypesafeConfigModule.
 */
public static TypesafeConfigModule fromConfigWithPackage(Config config, String packageNamePrefix) {
	 ConfigurationBuilder configBuilder = 
		 new ConfigurationBuilder()
         .filterInputsBy(new FilterBuilder().includePackage(packageNamePrefix))
         .setUrls(ClasspathHelper.forPackage(packageNamePrefix))
         .setScanners(
        	new TypeAnnotationsScanner(), 
        	new MethodParameterScanner(), 
        	new MethodAnnotationsScanner(), 
        	new FieldAnnotationsScanner()
         );
	Reflections reflections = new Reflections(configBuilder);
	
	return new TypesafeConfigModule(config, reflections);
}
 
开发者ID:racc,项目名称:typesafeconfig-guice,代码行数:23,代码来源:TypesafeConfigModule.java

示例3: loadPathCorrelation

import org.reflections.util.ClasspathHelper; //导入依赖的package包/类
/**
 * Initializes correlations between json paths and xpaths
 */
private static PathCorrelation loadPathCorrelation() {
	PathCorrelation pathCorrelation;

	try {
		InputStream input = ClasspathHelper.contextClassLoader().getResourceAsStream(config);
		ObjectMapper mapper = new ObjectMapper();
		pathCorrelation = mapper.readValue(input, PathCorrelation.class);
		flattenCorrelations(pathCorrelation);
	} catch (IOException ioe) {
		String message = "Problem loading path correlation configuration";
		DEV_LOG.error(message, ioe);
		throw new PathCorrelationException(message, ioe);
	}

	return pathCorrelation;
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:20,代码来源:PathCorrelator.java

示例4: grabConfiguration

import org.reflections.util.ClasspathHelper; //导入依赖的package包/类
public static Map<String, MeasureConfig> grabConfiguration(String fileName) {
	ObjectMapper mapper = new ObjectMapper();

	InputStream measuresInput = ClasspathHelper.contextClassLoader().getResourceAsStream(fileName);

	try {
		TypeReference<List<MeasureConfig>> measureConfigType = new TypeReference<List<MeasureConfig>>() {};
		List<MeasureConfig> configurations = mapper.readValue(measuresInput, measureConfigType);
		return configurations.stream()
				.collect(Collectors.toMap(MeasureConfigs::getMeasureId, Function.identity()));
	} catch (IOException e) {
		String message = "failure to correctly read measures config json";
		DEV_LOG.error(message);
		throw new IllegalArgumentException(message, e);
	}
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:17,代码来源:MeasureConfigs.java

示例5: parseClinicalDocument

import org.reflections.util.ClasspathHelper; //导入依赖的package包/类
@Test
void parseClinicalDocument() throws Exception {
	InputStream stream =
			ClasspathHelper.contextClassLoader().getResourceAsStream("valid-QRDA-III-abridged.xml");
	String xmlFragment = IOUtils.toString(stream, StandardCharsets.UTF_8);

	Context context = new Context();
	Node clinicalDocumentNode = XmlInputDecoder.decodeXml(context, XmlUtils.stringToDom(xmlFragment));

	// remove default nodes (will fail if defaults change)
	DefaultDecoder.removeDefaultNode(clinicalDocumentNode.getChildNodes());

	QppOutputEncoder encoder = new QppOutputEncoder(context);
	encoder.setNodes(Collections.singletonList(clinicalDocumentNode));

	StringWriter sw = new StringWriter();
	encoder.encode(new BufferedWriter(sw));

	assertThat(sw.toString()).isEqualTo(expected);
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:21,代码来源:ClinicalDocumentRoundTripTest.java

示例6: setup

import org.reflections.util.ClasspathHelper; //导入依赖的package包/类
@BeforeAll
static void setup() {
	ObjectMapper mapper = new ObjectMapper();

	InputStream stream =
			ClasspathHelper.contextClassLoader().getResourceAsStream("measures-data-aci-test.json");

	try {
		TypeReference<List<MeasureConfig>> measureConfigType = new TypeReference<List<MeasureConfig>>() {};
		measureConfigs = mapper.readValue(stream, measureConfigType);
	} catch (IOException e) {
		throw new IllegalArgumentException("failure to correctly read measures config json", e);
	}

	theConfig = measureConfigs.get(0);
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:17,代码来源:MeasureConfigTest.java

示例7: 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

示例8: getCasBannerInstance

import org.reflections.util.ClasspathHelper; //导入依赖的package包/类
/**
 * Gets cas banner instance.
 *
 * @return the cas banner instance
 */
public static Banner getCasBannerInstance() {
    final String packageName = CasEmbeddedContainerUtils.class.getPackage().getName();
    final Reflections reflections =
            new Reflections(new ConfigurationBuilder()
                    .filterInputsBy(new FilterBuilder().includePackage(packageName))
                    .setUrls(ClasspathHelper.forPackage(packageName))
                    .setScanners(new SubTypesScanner(true)));

    final Set<Class<? extends AbstractCasBanner>> subTypes = reflections.getSubTypesOf(AbstractCasBanner.class);
    subTypes.remove(DefaultCasBanner.class);
    
    if (subTypes.isEmpty()) {
        return new DefaultCasBanner();
    }
    try {
        final Class<? extends AbstractCasBanner> clz = subTypes.iterator().next();
        LOGGER.debug("Created banner [{}]", clz);
        return clz.newInstance();
    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    return new DefaultCasBanner();
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:29,代码来源:CasEmbeddedContainerUtils.java

示例9: generateReport

import org.reflections.util.ClasspathHelper; //导入依赖的package包/类
public void generateReport(String packageName,List<String> flagList) throws IOException
{

    URL testClassesURL = Paths.get("target/test-classes").toUri().toURL();

    URLClassLoader classLoader = URLClassLoader.newInstance(new URL[]{testClassesURL},
            ClasspathHelper.staticClassLoader());

    reflections = new Reflections(new ConfigurationBuilder()
            .setUrls(ClasspathHelper.forPackage(packageName,classLoader))
            .addClassLoader(classLoader)
            .filterInputsBy(new FilterBuilder().includePackage(packageName))
            .setScanners(new MethodAnnotationsScanner(), new TypeAnnotationsScanner(), new SubTypesScanner())
    );


    List<Map<String, TestClass>> list = new ArrayList<>();

    for (String flag : flagList)
    {
        list.add(printMethods(flag));
    }

    Gson gson = new Gson();
    String overviewTemplate = IOUtils.toString(getClass().getResourceAsStream("/index.tpl.html"));


    String editedTemplate = overviewTemplate.replace("##TEST_DATA##", gson.toJson(list));

    FileUtils.writeStringToFile(new File("target/test-list-html-report/index.html"), editedTemplate);
    logger.info("report file generated");
}
 
开发者ID:cyildirim,项目名称:Lahiya,代码行数:33,代码来源:LahiyaTestCaseReport.java

示例10: ReflectionsServiceDiscovery

import org.reflections.util.ClasspathHelper; //导入依赖的package包/类
public ReflectionsServiceDiscovery(String resourceSearchPackages, JsonServiceLocator locator) {
	this.locator = locator;

	ConfigurationBuilder builder = new ConfigurationBuilder();

	PreconditionUtil.assertNotNull("no resourceSearchPackage configured", resourceSearchPackages);

	FilterBuilder filter = new FilterBuilder();
	for (String resourceSearchPackage : resourceSearchPackages.split(",")) {
		builder = builder.addUrls(ClasspathHelper.forPackage(resourceSearchPackage));
		filter.includePackage(resourceSearchPackage);
	}
	filter.includePackage(Repository.class.getPackage().getName());
	filter.includePackage(ResourceRepository.class.getPackage().getName());
	builder = builder.filterInputsBy(filter);

	builder = builder.addUrls(ClasspathHelper.forClass(Repository.class));
	builder = builder.addUrls(ClasspathHelper.forClass(ResourceRepository.class));
	builder = builder.addUrls(ClasspathHelper.forClass(ResourceRepositoryV2.class));

	builder = builder.setScanners(new SubTypesScanner(false), new TypeAnnotationsScanner());
	reflections = new Reflections(builder);
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:24,代码来源:ReflectionsServiceDiscovery.java

示例11: doExecute

import org.reflections.util.ClasspathHelper; //导入依赖的package包/类
@Test
public void doExecute() throws Exception {
    final PackageMojo mojo = getMojoFromPom();
    final PackageMojo mojoSpy = spy(mojo);
    ReflectionUtils.setVariableValueInObject(mojoSpy, "finalName", "artifact-0.1.0");
    doReturn(mock(AnnotationHandler.class)).when(mojoSpy).getAnnotationHandler();
    doReturn(ClasspathHelper.forPackage("com.microsoft.azure.maven.function.handlers").toArray()[0])
            .when(mojoSpy)
            .getTargetClassUrl();
    doReturn("target/azure-functions").when(mojoSpy).getDeploymentStageDirectory();
    doReturn("target").when(mojoSpy).getBuildDirectoryAbsolutePath();
    doReturn(mock(MavenProject.class)).when(mojoSpy).getProject();
    doReturn(mock(MavenSession.class)).when(mojoSpy).getSession();
    doReturn(mock(MavenResourcesFiltering.class)).when(mojoSpy).getMavenResourcesFiltering();

    mojoSpy.doExecute();
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:18,代码来源:PackageMojoTest.java

示例12: CommandHandler

import org.reflections.util.ClasspathHelper; //导入依赖的package包/类
public CommandHandler() {
  try {
    Set<URL> classPathList = new HashSet<>();
    classPathList.addAll(ClasspathHelper.forJavaClassPath());
    Set<Class<? extends Command>> result = new Reflections(
        new ConfigurationBuilder().setScanners(new SubTypesScanner()).setUrls(classPathList))
        .getSubTypesOf(Command.class);

    for (Class<? extends Command> c : result) {
      String[] categoryString = c.getPackage().toString().split("\\.");
      String category = categoryString[categoryString.length - 1];
      if (category.equalsIgnoreCase("commands")) {
        category = "default";
      }
      Command command = c.newInstance();
      command.getSettings().setCategory(category);
      commands.add(command);
    }
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:Svetroid,项目名称:Hobbes-v1,代码行数:23,代码来源:CommandHandler.java

示例13: concreteSubTypesOf

import org.reflections.util.ClasspathHelper; //导入依赖的package包/类
private static <T> List<Class<? extends T>> concreteSubTypesOf(final Class<? extends T> clazz) {
    final ConfigurationBuilder conf = new ConfigurationBuilder()
            .setUrls(ClasspathHelper.forClass(clazz))
            .setScanners(new SubTypesScanner(true));
    final Reflections reflections = new Reflections(conf);
    final List<Class<? extends T>> result = new ArrayList<>();
    for (final Class<? extends T> type : reflections.getSubTypesOf(clazz)) {
        if (type.isInterface()) {
            continue;
        }

        if (Modifier.isAbstract(type.getModifiers())) {
            continue;
        }

        result.add(type);
    }

    return result;
}
 
开发者ID:bblfsh,项目名称:java-driver,代码行数:21,代码来源:GoGen.java

示例14: tweetEntities

import org.reflections.util.ClasspathHelper; //导入依赖的package包/类
@Test
public void tweetEntities() {
  Reflections reflections = new Reflections(new ConfigurationBuilder()
      .setUrls(ClasspathHelper.forJavaClassPath())
      .forPackages(TweetEntity.class.getPackage().getName())
  );

  List<Class<?>> allClasses = new ArrayList<>();
  List<Class<? extends TweetEntity>> classes = list(reflections, TweetEntity.class);
  allClasses.add(MediaEntity.Variant.class);
  allClasses.add(MediaEntity.Size.class);
  allClasses.addAll(classes);


  for (Class<?> cls : allClasses) {
    StringBuilder builder = new StringBuilder();
    processClass(cls, builder);

    System.out.println(builder);
  }


}
 
开发者ID:jcustenborder,项目名称:kafka-connect-twitter,代码行数:24,代码来源:SchemaGeneratorTest.java

示例15: before

import org.reflections.util.ClasspathHelper; //导入依赖的package包/类
@BeforeEach
public void before() throws MalformedURLException {
  log.info("before() - Configuring reflections to use package '{}'", packages());

  if (null == this.reflections) {
    this.reflections = new Reflections(new ConfigurationBuilder()
        .setUrls(ClasspathHelper.forJavaClassPath())
        .forPackages(packages())
    );
  }

  List<Class<? extends Transformation>> transformClasses = list(Transformation.class);
  List<Class<? extends SourceConnector>> sourceConnectorClasses = list(SourceConnector.class);
  List<Class<? extends SinkConnector>> sinkConnectorClasses = list(SinkConnector.class);

  this.pluginTemplate = PluginTemplate.from(sourceConnectorClasses, sinkConnectorClasses, transformClasses);
}
 
开发者ID:jcustenborder,项目名称:connect-utils,代码行数:18,代码来源:BaseDocumentationTest.java


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