org.reflections.util.ConfigurationBuilder Java Examples
The following examples show how to use
org.reflections.util.ConfigurationBuilder.
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: DataScopeSqlConfigService.java From smart-admin with MIT License | 7 votes |
/** * 刷新 所有添加数据范围注解的接口方法配置<class.method,DataScopeSqlConfigDTO></> * * @return */ private Map<String, DataScopeSqlConfigDTO> refreshDataScopeMethodMap() { Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage(scanPackage)).setScanners(new MethodAnnotationsScanner())); Set<Method> methods = reflections.getMethodsAnnotatedWith(DataScope.class); for (Method method : methods) { DataScope dataScopeAnnotation = method.getAnnotation(DataScope.class); if (dataScopeAnnotation != null) { DataScopeSqlConfigDTO configDTO = new DataScopeSqlConfigDTO(); configDTO.setDataScopeType(dataScopeAnnotation.dataScopeType().getType()); configDTO.setJoinSql(dataScopeAnnotation.joinSql()); configDTO.setWhereIndex(dataScopeAnnotation.whereIndex()); dataScopeMethodMap.put(method.getDeclaringClass().getSimpleName() + "." + method.getName(), configDTO); } } return dataScopeMethodMap; }
Example #2
Source File: ConnectorDocGenerator.java From pulsar with Apache License 2.0 | 7 votes |
private static Reflections newReflections() throws Exception { List<URL> urls = new ArrayList<>(); ClassLoader[] classLoaders = new ClassLoader[] { ConnectorDocGenerator.class.getClassLoader(), Thread.currentThread().getContextClassLoader() }; for (int i = 0; i < classLoaders.length; i++) { if (classLoaders[i] instanceof URLClassLoader) { urls.addAll(Arrays.asList(((URLClassLoader) classLoaders[i]).getURLs())); } else { throw new RuntimeException("ClassLoader '" + classLoaders[i] + " is not an instance of URLClassLoader"); } } ConfigurationBuilder confBuilder = new ConfigurationBuilder(); confBuilder.setUrls(urls); return new Reflections(confBuilder); }
Example #3
Source File: JaxRSScanner.java From swagger-maven-plugin with MIT License | 6 votes |
Application applicationInstance() { ConfigurationBuilder config = ConfigurationBuilder .build(resourcePackages) .setScanners(new ResourcesScanner(), new TypeAnnotationsScanner(), new SubTypesScanner()); Reflections reflections = new Reflections(config); Set<Class<? extends Application>> applicationClasses = reflections.getSubTypesOf(Application.class) .stream() .filter(this::filterClassByResourcePackages) .collect(Collectors.toSet()); if (applicationClasses.isEmpty()) { return null; } if (applicationClasses.size() > 1) { log.warn("More than one javax.ws.rs.core.Application classes found on the classpath, skipping"); return null; } return ClassUtils.createInstance(applicationClasses.iterator().next()); }
Example #4
Source File: PluginManager.java From DBus with Apache License 2.0 | 6 votes |
/** * copy on write 机制实现重新加载 */ private void initialize() throws Exception { List<EncodePlugin> plugins = loader.loadPlugins(); Set<String> urls = new HashSet<>(); Map<String, ExtEncodeStrategy> map = new ConcurrentHashMap<>(); for (EncodePlugin plugin : plugins) { if (!urls.contains(plugin.getJarPath())) { URL jar = new URL(PROTOCOL, null, plugin.getJarPath()); PluginScanner scanner = new ReflectionsPluginScanner(ConfigurationBuilder.build(jar)); Iterable<String> classes = scanner.scan(this.annotation); buildEncoders(classes, jar, plugin.getId(), map); urls.add(plugin.getJarPath()); } } this.encoderMap = map; }
Example #5
Source File: JsonDbDaoTest.java From syndesis with Apache License 2.0 | 6 votes |
public Class<? extends WithUsage>[] getClasses() { final Reflections reflections = new Reflections(new ConfigurationBuilder() .forPackages("io.syndesis") .filterInputsBy(r -> !r.contains("Immutable"))); Set<Class<? extends WithUsage>> withUsageSubtypes = new HashSet<Class<? extends WithUsage>>(); withUsageSubtypes.addAll(reflections.getSubTypesOf(WithUsage.class)); final Set<Class<?>> immutables = reflections.getTypesAnnotatedWith(Value.Immutable.class); @SuppressWarnings("rawtypes") final Set<Class<? extends TargetWithDomain>> withDomainClasses = reflections.getSubTypesOf(TargetWithDomain.class); withUsageSubtypes.retainAll(immutables); withUsageSubtypes.removeAll(withDomainClasses); // not sure why this is a DAO type withUsageSubtypes.remove(ConnectionOverview.class); @SuppressWarnings("unchecked") final Class<? extends WithUsage>[] classes = (Class<? extends WithUsage>[]) withUsageSubtypes.toArray(); return classes; }
Example #6
Source File: JarManagerService.java From DBus with Apache License 2.0 | 6 votes |
private String getPluginsEncoderTypes(String jarPath) throws Exception { URL jar = new URL("file", null, jarPath); PluginScanner scanner = new ReflectionsPluginScanner(ConfigurationBuilder.build(jar)); Iterable<String> encoders = scanner.scan(Encoder.class); StringBuilder sb = new StringBuilder(); if (encoders.iterator().hasNext()) { PluginsClassloader classloader = new PluginsClassloader(PluginManager.class.getClassLoader()); classloader.addJar(jar); for (String encoderClass : encoders) { Class<?> clazz = classloader.loadClass(encoderClass); Encoder e = clazz.getDeclaredAnnotation(Encoder.class); sb.append(e.type()).append(","); } } return sb.toString(); }
Example #7
Source File: CasLoggerContextInitializer.java From springboot-shiro-cas-mybatis with MIT License | 6 votes |
/** * 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); } }
Example #8
Source File: MessagesScanner.java From elasticactors with Apache License 2.0 | 6 votes |
@PostConstruct public void init() { String[] basePackages = ScannerHelper.findBasePackagesOnClasspath(applicationContext.getClassLoader()); ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); for (String basePackage : basePackages) { configurationBuilder.addUrls(ClasspathHelper.forPackage(basePackage)); } Reflections reflections = new Reflections(configurationBuilder); Set<Class<?>> messageClasses = reflections.getTypesAnnotatedWith(Message.class); for (Class<?> messageClass : messageClasses) { Message messageAnnotation = messageClass.getAnnotation(Message.class); // get the serialization framework SerializationFramework framework = applicationContext.getBean(messageAnnotation.serializationFramework()); framework.register(messageClass); } }
Example #9
Source File: SchemaGeneratorTest.java From kafka-connect-twitter with Apache License 2.0 | 6 votes |
@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); } }
Example #10
Source File: ReflectionsServiceDiscovery.java From katharsis-framework with Apache License 2.0 | 6 votes |
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); }
Example #11
Source File: Parser.java From Java2PlantUML with Apache License 2.0 | 6 votes |
private static Collection<? extends Class<?>> getPackageTypes(String packageToPase, Collection<URL> urls) { Set<Class<?>> classes = new HashSet<>(); Reflections reflections = new Reflections(new ConfigurationBuilder() .setScanners(new SubTypesScanner(false /* exclude Object.class */), new ResourcesScanner(), new TypeElementsScanner()) .setUrls(urls) .filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix(packageToPase)).exclude("java.*"))); Set<String> types; types = reflections.getStore().get("TypeElementsScanner").keySet(); for (String type: types) { Class<?> aClass = TypesHelper.loadClass(type, CLASS_LOADER); boolean wantedElement = StringUtils.startsWith(type, packageToPase); if (null != aClass && wantedElement) { logger.log(Level.INFO, "looking up for type: " + type); classes.add(aClass); } } return classes; }
Example #12
Source File: RoleClassLoader.java From anno4j with Apache License 2.0 | 6 votes |
private void scanConceptsWithReflections() throws ObjectStoreConfigException { logger.debug("Search for concepts with reflections"); Set<URL> classpath = new HashSet<>(); classpath.addAll(ClasspathHelper.forClassLoader()); classpath.addAll(ClasspathHelper.forJavaClassPath()); classpath.addAll(ClasspathHelper.forManifest()); classpath.addAll(ClasspathHelper.forPackage("")); Reflections reflections = new Reflections(new ConfigurationBuilder() .setUrls(classpath) .useParallelExecutor() .filterInputsBy(FilterBuilder.parsePackages("-java, -javax, -sun, -com.sun")) .setScanners(new SubTypesScanner(), new TypeAnnotationsScanner())); Set<Class<?>> annotated = reflections.getTypesAnnotatedWith(Iri.class, true); logger.debug("Search for concepts with reflections resulted in " + annotated.size() + " classes"); for (Class clazz : annotated) { logger.debug("Found concept class: " + clazz.getCanonicalName()); roleMapper.addConcept(clazz); } }
Example #13
Source File: StreamsScalaSourceGenerator.java From streams with Apache License 2.0 | 6 votes |
/** * StreamsScalaSourceGenerator constructor. * @param config StreamsScalaGenerationConfig */ public StreamsScalaSourceGenerator(StreamsScalaGenerationConfig config) { this.config = config; this.outDir = config.getTargetDirectory().getAbsolutePath(); reflections = new Reflections( new ConfigurationBuilder() // TODO .forPackages( config.getSourcePackages() .toArray(new String[config.getSourcePackages().size()]) ) .setScanners( new SubTypesScanner(), new TypeAnnotationsScanner())); }
Example #14
Source File: ActivitySerDeTest.java From streams with Apache License 2.0 | 6 votes |
/** * Tests that defined activity verbs have an example which can be loaded into * Activity beans and into verb-specific beans. * @throws Exception Exception */ @Test public void testVerbSerDe() throws Exception { Reflections reflections = new Reflections(new ConfigurationBuilder() .setUrls(ClasspathHelper.forPackage("org.apache.streams.pojo.json")) .setScanners(new SubTypesScanner())); Set<Class<? extends Activity>> verbs = reflections.getSubTypesOf(Activity.class); for ( Class verbClass : verbs) { LOGGER.info("Verb: " + verbClass.getSimpleName() ); Activity activity = (Activity) verbClass.newInstance(); String verbName = activity.getVerb(); String testfile = verbName.toLowerCase() + ".json"; LOGGER.info("Serializing: activities/" + testfile ); Path testActivityPath = Paths.get("target/dependency/activitystreams-testdata/" + testfile); assert (testActivityPath.toFile().exists()); FileInputStream testActivityFileStream = new FileInputStream(testActivityPath.toFile()); assert (testActivityFileStream != null); activity = MAPPER.convertValue(MAPPER.readValue(testActivityFileStream, verbClass), Activity.class); String activityString = MAPPER.writeValueAsString(activity); LOGGER.info("Deserialized: " + activityString ); assert ( !activityString.contains("null") ); assert ( !activityString.contains("[]") ); } }
Example #15
Source File: StreamsJacksonModule.java From streams with Apache License 2.0 | 6 votes |
public StreamsJacksonModule() { super(); Reflections reflections = new Reflections(new ConfigurationBuilder() .setUrls(ClasspathHelper.forPackage("org.apache.streams.jackson")) .setScanners(new SubTypesScanner())); Set<Class<? extends StreamsDateTimeFormat>> dateTimeFormatClasses = reflections.getSubTypesOf(StreamsDateTimeFormat.class); List<String> dateTimeFormats = new ArrayList<>(); for (Class dateTimeFormatClass : dateTimeFormatClasses) { try { dateTimeFormats.add(((StreamsDateTimeFormat) (dateTimeFormatClass.newInstance())).getFormat()); } catch (Exception ex) { LOGGER.warn("Exception getting format from " + dateTimeFormatClass); } } addSerializer(DateTime.class, new StreamsDateTimeSerializer(DateTime.class)); addDeserializer(DateTime.class, new StreamsDateTimeDeserializer(DateTime.class, dateTimeFormats)); addSerializer(Period.class, new StreamsPeriodSerializer(Period.class)); addDeserializer(Period.class, new StreamsPeriodDeserializer(Period.class)); }
Example #16
Source File: ElasticsearchParentChildUpdaterIT.java From streams with Apache License 2.0 | 6 votes |
@BeforeClass public void prepareTestParentChildPersistUpdater() throws Exception { testConfiguration = new ComponentConfigurator<>(ElasticsearchWriterConfiguration.class).detectConfiguration( "ElasticsearchParentChildUpdaterIT"); testClient = ElasticsearchClientManager.getInstance(testConfiguration).client(); ClusterHealthRequest clusterHealthRequest = Requests.clusterHealthRequest(); ClusterHealthResponse clusterHealthResponse = testClient.admin().cluster().health(clusterHealthRequest).actionGet(); assertNotEquals(clusterHealthResponse.getStatus(), ClusterHealthStatus.RED); IndicesExistsRequest indicesExistsRequest = Requests.indicesExistsRequest(testConfiguration.getIndex()); IndicesExistsResponse indicesExistsResponse = testClient.admin().indices().exists(indicesExistsRequest).actionGet(); assertTrue(indicesExistsResponse.isExists()); Reflections reflections = new Reflections(new ConfigurationBuilder() .setUrls(ClasspathHelper.forPackage("org.apache.streams.pojo.json")) .setScanners(new SubTypesScanner())); objectTypes = reflections.getSubTypesOf(ActivityObject.class); Path testdataDir = Paths.get("target/dependency/activitystreams-testdata"); files = Files.list(testdataDir).collect(Collectors.toList()); }
Example #17
Source File: ClassloaderScanner.java From yawp with MIT License | 6 votes |
private Reflections buildReflections(String packages) { String[] packagesArray = packages.replaceAll(" ", "").split(","); FilterBuilder filter = new FilterBuilder(); Set<URL> urls = new HashSet(); for (String packageStr : packagesArray) { urls.addAll(ClasspathHelper.forPackage(packageStr)); filter.include(FilterBuilder.prefix(packageStr)); } return new Reflections(new ConfigurationBuilder() .addUrls(urls) .filterInputsBy(filter) .setScanners(new TypeAnnotationsScanner(), new SubTypesScanner())); }
Example #18
Source File: GuiceBundle.java From robe with GNU Lesser General Public License v3.0 | 6 votes |
/** * Creates a {@link org.reflections.Reflections} with the given packages (configuration) * * @param scanPackages */ private void createReflections(String[] scanPackages) { if (scanPackages.length < 1) { LOGGER.warn("No package defined in configuration (scanPackages)!"); return; } ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); FilterBuilder filterBuilder = new FilterBuilder(); for (String packageName : scanPackages) { configurationBuilder.addUrls(ClasspathHelper.forPackage(packageName)); filterBuilder.include(FilterBuilder.prefix(packageName)); } configurationBuilder.filterInputsBy(filterBuilder).setScanners(new SubTypesScanner(), new TypeAnnotationsScanner()); this.reflections = new Reflections(configurationBuilder); }
Example #19
Source File: TypeScriptDtoGenerator.java From che with Eclipse Public License 2.0 | 6 votes |
/** * Init stuff is responsible to grab all DTOs found in classpath (classloader) and setup model for * String Template */ protected void init() { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder().setScanners(new SubTypesScanner(), new TypeAnnotationsScanner()); if (useClassPath) { configurationBuilder.setUrls(forJavaClassPath()); } else { configurationBuilder.setUrls(forClassLoader()); } // keep only DTO interfaces Reflections reflections = new Reflections(configurationBuilder); List<Class<?>> annotatedWithDtos = new ArrayList<>(reflections.getTypesAnnotatedWith(DTO.class)); List<Class<?>> interfacesDtos = annotatedWithDtos .stream() .filter(clazz -> clazz.isInterface()) .collect(Collectors.toList()); interfacesDtos.stream().forEach(this::analyze); }
Example #20
Source File: AnnotationLoader.java From livingdoc-core with GNU General Public License v3.0 | 6 votes |
public void addLoader(ClassLoader loader) { if (builder == null) { this.builder = new ConfigurationBuilder(); builder.setScanners(new SubTypesScanner(), new TypeAnnotationsScanner()); } builder.addClassLoader(loader); builder.addUrls(ClasspathHelper.forClassLoader(loader)); if(loader instanceof JoinClassLoader) { // When the object "reflections" is created in the method scanClassPath(), are scanned the URLs so // it is necessary to add the URLs from the enclosing class loader in the JoinClassLoader that it // contains the fixture classpath (see org.reflections.Reflections.scan()). builder.addUrls(ClasspathHelper.forClassLoader(((JoinClassLoader) loader).getEnclosingClassLoader())); } scanClassPath(builder); }
Example #21
Source File: ClassFinder.java From brooklyn-server with Apache License 2.0 | 5 votes |
public static <T extends BrooklynObject> Set<Class<? extends T>> findClasses(Collection<URL> urls, Class<T> clazz) { ClassLoader classLoader = new UrlClassLoader(urls.toArray(new URL[urls.size()])); Reflections reflections = new Reflections(new ConfigurationBuilder() .addClassLoader(classLoader) .addScanners(new SubTypesScanner(), new TypeAnnotationsScanner(), new FieldAnnotationsScanner()) .addUrls(urls)); Set<Class<? extends T>> types = reflections.getSubTypesOf(clazz); return types; }
Example #22
Source File: NativeImageHelper.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
private static void generateReflectConfig() throws JsonProcessingException { System.out.println("---------------------------"); System.out.println("--- reflect-config.json ---"); System.out.println("---------------------------"); List<String> packages = Arrays.asList("com.arangodb.entity", "com.arangodb.model"); ObjectMapper mapper = new ObjectMapper(); ArrayNode rootNode = mapper.createArrayNode(); ObjectNode noArgConstructor = mapper.createObjectNode(); noArgConstructor.put("name", "<init>"); noArgConstructor.set("parameterTypes", mapper.createArrayNode()); ArrayNode methods = mapper.createArrayNode(); methods.add(noArgConstructor); packages.stream() .flatMap(p -> { final ConfigurationBuilder config = new ConfigurationBuilder() .setScanners(new ResourcesScanner(), new SubTypesScanner(false)) .setUrls(ClasspathHelper.forPackage(p)) .filterInputsBy(new FilterBuilder().includePackage(p)); return new Reflections(config).getSubTypesOf(Object.class).stream(); }) .map(Class::getName) .map(className -> { ObjectNode entry = mapper.createObjectNode(); entry.put("name", className); entry.put("allDeclaredFields", true); entry.set("methods", methods); return entry; }) .forEach(rootNode::add); String jsonString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(rootNode); System.out.println(jsonString); }
Example #23
Source File: HiveFunctionLoader.java From tajo with Apache License 2.0 | 5 votes |
private static <T> Set<Class<? extends T>> getSubclassesFromJarEntry(URL[] urls, Class<T> targetCls) { Reflections refl = new Reflections(new ConfigurationBuilder(). setUrls(urls). addClassLoader(new URLClassLoader(urls))); return refl.getSubTypesOf(targetCls); }
Example #24
Source File: ClassTools.java From api-boot with Apache License 2.0 | 5 votes |
/** * 初始化反射对象 * * @param scannerPackage 扫描的package * @return 反射对象 */ static Reflections initReflections(String scannerPackage) { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setScanners(new TypeAnnotationsScanner(), new SubTypesScanner()); configurationBuilder.filterInputsBy(new FilterBuilder().includePackage(scannerPackage)); configurationBuilder.addUrls(ClasspathHelper.forPackage(scannerPackage)); return new Reflections(scannerPackage); }
Example #25
Source File: ParameterParsingChain.java From gauge-java with Apache License 2.0 | 5 votes |
private Reflections createReflections() { Configuration config = new ConfigurationBuilder() .setScanners(new SubTypesScanner()) .addUrls(ClasspathHelper.getUrls()) .filterInputsBy(new FilterBuilder().include(".+\\.class")); return new Reflections(config); }
Example #26
Source File: ReflectionScanner.java From brooklyn-server with Apache License 2.0 | 5 votes |
/** scanner which will look in the given urls * (or if those are null attempt to infer from the first entry in the classloaders, * although currently that seems to only pick up directories, not JAR's), * optionally filtering for the given prefix; * any or all arguments can be null to accept all (and use default classpath for classloading). **/ public ReflectionScanner( final Iterable<URL> urlsToScan, final String optionalPrefix, final Predicate<String> filter, final ClassLoader ...classLoaders) { if (Reflections.log==null) { Reflections.log = log; } reflections = new Reflections(new ConfigurationBuilder() { { if (urlsToScan!=null) setUrls(ImmutableSet.copyOf(urlsToScan)); else if (classLoaders.length>0 && classLoaders[0]!=null) setUrls( ClasspathHelper.forPackage(Strings.isNonEmpty(optionalPrefix) ? optionalPrefix : "", asClassLoaderVarArgs(classLoaders[0]))); if (filter!=null) filterInputsBy(filter); Scanner typeScanner = new TypeAnnotationsScanner(); if (filter!=null) typeScanner = typeScanner.filterResultsBy(filter); Scanner subTypeScanner = new SubTypesScanner(); if (filter!=null) subTypeScanner = subTypeScanner.filterResultsBy(filter); setScanners(typeScanner, subTypeScanner); for (ClassLoader cl: classLoaders) if (cl!=null) addClassLoader(cl); } }); this.classLoaders = Iterables.toArray(Iterables.filter(Arrays.asList(classLoaders), Predicates.notNull()), ClassLoader.class); }
Example #27
Source File: Manager.java From hbase-tools with Apache License 2.0 | 5 votes |
private static Reflections createReflections() { List<ClassLoader> classLoadersList = new LinkedList<>(); classLoadersList.add(ClasspathHelper.contextClassLoader()); classLoadersList.add(ClasspathHelper.staticClassLoader()); return new Reflections(new ConfigurationBuilder() .setScanners(new SubTypesScanner(false /* don't exclude Object.class */), new ResourcesScanner()) .setUrls(ClasspathHelper.forManifest(ClasspathHelper.forClassLoader( classLoadersList.toArray(new ClassLoader[classLoadersList.size()])))) .filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix("com.kakao.hbase.manager.command")))); }
Example #28
Source File: Manager.java From hbase-tools with Apache License 2.0 | 5 votes |
private static Reflections createReflections() { List<ClassLoader> classLoadersList = new LinkedList<>(); classLoadersList.add(ClasspathHelper.contextClassLoader()); classLoadersList.add(ClasspathHelper.staticClassLoader()); return new Reflections(new ConfigurationBuilder() .setScanners(new SubTypesScanner(false /* don't exclude Object.class */), new ResourcesScanner()) .setUrls(ClasspathHelper.forManifest(ClasspathHelper.forClassLoader( classLoadersList.toArray(new ClassLoader[classLoadersList.size()])))) .filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix("com.kakao.hbase.manager.command")))); }
Example #29
Source File: Manager.java From hbase-tools with Apache License 2.0 | 5 votes |
private static Reflections createReflections() { List<ClassLoader> classLoadersList = new LinkedList<>(); classLoadersList.add(ClasspathHelper.contextClassLoader()); classLoadersList.add(ClasspathHelper.staticClassLoader()); return new Reflections(new ConfigurationBuilder() .setScanners(new SubTypesScanner(false /* don't exclude Object.class */), new ResourcesScanner()) .setUrls(ClasspathHelper.forManifest(ClasspathHelper.forClassLoader( classLoadersList.toArray(new ClassLoader[classLoadersList.size()])))) .filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix("com.kakao.hbase.manager.command")))); }
Example #30
Source File: CustomProviderVerifier.java From code-examples with MIT License | 5 votes |
@Override public boolean verifyResponseByInvokingProviderMethods(ProviderInfo providerInfo, ConsumerInfo consumer, Object interaction, String interactionMessage, Map failures) { try { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder() .setScanners(new MethodAnnotationsScanner()) .forPackages(packagesToScan.toArray(new String[]{})); Reflections reflections = new Reflections(configurationBuilder); Set<Method> methodsAnnotatedWith = reflections.getMethodsAnnotatedWith(PactVerifyProvider.class); Set<Method> providerMethods = methodsAnnotatedWith.stream() .filter(m -> { PactVerifyProvider annotation = m.getAnnotation(PactVerifyProvider.class); return annotation.value().equals(((Interaction)interaction).getDescription()); }) .collect(Collectors.toSet()); if (providerMethods.isEmpty()) { throw new RuntimeException("No annotated methods were found for interaction " + "'${interaction.description}'. You need to provide a method annotated with " + "@PactVerifyProvider(\"${interaction.description}\") that returns the message contents."); } else { if (interaction instanceof Message) { verifyMessagePact(providerMethods, (Message) interaction, interactionMessage, failures); } else { throw new RuntimeException("only supports Message interactions!"); } } } catch (Exception e) { throw new RuntimeException("verification failed", e); } return true; }