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


Java Reflections.getSubTypesOf方法代码示例

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


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

示例1: main

import org.reflections.Reflections; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    Reflections reflections = new Reflections();
    LukkitPlus.BUKKIT_EVENTS = reflections.getSubTypesOf(Event.class);
    ClassPool classpath = ClassPool.getDefault();
    CtClass eventClass = classpath.makeClass("online.pizzacrust.lukkitplus" +
            ".EventCallback");
    for (Class<? extends Event> event : LukkitPlus.BUKKIT_EVENTS) {
        CtMethod eventMethod = CtNewMethod.make(CtClass.voidType, "on" + event.getSimpleName
                (), new CtClass[] { classpath.get(event.getName()) }, new CtClass[0], "online" +
                ".pizzacrust.lukkitplus.EventCallbackGenerator.call($1);", eventClass);
        eventClass.addMethod(eventMethod);
        AnnotationsAttribute attribute = new AnnotationsAttribute(eventClass.getClassFile()
                .getConstPool(), AnnotationsAttribute.visibleTag);
        Annotation eventHandlerAnnt = new Annotation(EventHandler.class.getName(), eventClass
                .getClassFile().getConstPool());
        attribute.addAnnotation(eventHandlerAnnt);
        eventMethod.getMethodInfo().addAttribute(attribute);
    }
    System.out.println("Done!");
    eventClass.writeFile();
}
 
开发者ID:LukkitPlus,项目名称:Lukkit,代码行数:22,代码来源:EventCallbackGenerator.java

示例2: getImplementations

import org.reflections.Reflections; //导入方法依赖的package包/类
public static AntFactory[] getImplementations() {
	Reflections reflections = new Reflections("");
	Set<Class<? extends AntFactory>> classes = reflections.getSubTypesOf(AntFactory.class);

	List<AntFactory> ret = new ArrayList<>();

	for (Class<? extends AntFactory> it : classes) {
		try {
			ret.add(it.getConstructor().newInstance());
		} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
				| InvocationTargetException | NoSuchMethodException | SecurityException e) {
			e.printStackTrace();
		}
	}

	return ret.stream().toArray(AntFactory[]::new);
}
 
开发者ID:gamefest2017,项目名称:ants,代码行数:18,代码来源:AntLoader.java

示例3: getPluginDesc

import org.reflections.Reflections; //导入方法依赖的package包/类
private <T> Collection<PluginDesc<T>> getPluginDesc(
        Reflections reflections,
        Class<T> klass,
        ClassLoader loader
) throws InstantiationException, IllegalAccessException {
    Set<Class<? extends T>> plugins = reflections.getSubTypesOf(klass);

    Collection<PluginDesc<T>> result = new ArrayList<>();
    for (Class<? extends T> plugin : plugins) {
        if (PluginUtils.isConcrete(plugin)) {
            // Temporary workaround until all the plugins are versioned.
            if (Connector.class.isAssignableFrom(plugin)) {
                result.add(
                        new PluginDesc<>(
                                plugin,
                                ((Connector) plugin.newInstance()).version(),
                                loader
                        )
                );
            } else {
                result.add(new PluginDesc<>(plugin, "undefined", loader));
            }
        }
    }
    return result;
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:27,代码来源:DelegatingClassLoader.java

示例4: load

import org.reflections.Reflections; //导入方法依赖的package包/类
public void load() {
	Reflections reflect = new Reflections(new Object[]{Manager.class});
	Set managers = reflect.getSubTypesOf(Manager.class);
	float progress = 0;
	for (Object obj : managers) {
		Class objClass = (Class)obj;
		try {
			progress += 100.0f / managers.size();
			Manager manager = (Manager)objClass.newInstance();

			this.managers.add(manager);

			ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
			ProgressBar progressBar = new ProgressBar(scaledresolution.getScaledWidth() / 2, scaledresolution.getScaledHeight() / 2, 100, 10, progress, "Loading Managers " + this.managers.size() + " / " + managers.size(), -1);
			ProgressBarList.addProgress(0, progressBar);

			Thread.sleep(10);
		} catch (Exception e) {;}
	}

	this.managers.sort((o2, o1) -> o2.getLoadLevel() - o1.getLoadLevel());
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:23,代码来源:Managers.java

示例5: populateMap

import org.reflections.Reflections; //导入方法依赖的package包/类
private static void populateMap(final Map<String, FsConnRuleCommand<FsConnRuleCmdParamBean, FsConnRuleCmdResultBean>> commands) {
    final String commandPackage = "com.espirit.moddev.fstesttools.rules.firstspirit.commands";
    LOGGER.info("Scanning class path in '{}' for command classes...", commandPackage);
    Reflections reflections = new Reflections(commandPackage);
    Set<Class<? extends FsConnRuleCommand>> commandsFromPackage = reflections.getSubTypesOf(FsConnRuleCommand.class);

    int counter = 0;
    for (Class<? extends FsConnRuleCommand> commandClass : commandsFromPackage) {
        if (commandClass.isAnonymousClass()) {
            continue;
        }
        LOGGER.debug("Processing '{}'...", commandClass.getSimpleName());
        counter = handleEnumCommands(commands, counter, commandClass);
        counter = handleSimpleCommands(commands, counter, commandClass);
    }
    LOGGER.info("Loaded {} commands!", counter);
}
 
开发者ID:e-Spirit,项目名称:FSTestTools,代码行数:18,代码来源:FirstSpiritConnectionRule.java

示例6: concreteSubTypesOf

import org.reflections.Reflections; //导入方法依赖的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

示例7: scanContextForLoggerFactories

import org.reflections.Reflections; //导入方法依赖的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

示例8: CasLoggerFactory

import org.reflections.Reflections; //导入方法依赖的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

示例9: getClasses

import org.reflections.Reflections; //导入方法依赖的package包/类
static Set<Class<?>> getClasses(String packageName) {
    List<ClassLoader> classLoadersList = new LinkedList<>();
    classLoadersList.add(ClasspathHelper.contextClassLoader());
    classLoadersList.add(ClasspathHelper.staticClassLoader());

    Reflections reflections = new Reflections(new ConfigurationBuilder()
            .setScanners(new SubTypesScanner(false /* don't exclude Object.class */), new ResourcesScanner())
            .setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0])))
            .filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix(packageName))));

    Set<Class<?>> classes = reflections.getSubTypesOf(Object.class);
    return classes;
}
 
开发者ID:chaokunyang,项目名称:jkes,代码行数:14,代码来源:ClassUtils.java

示例10: getClasses

import org.reflections.Reflections; //导入方法依赖的package包/类
private Set<Class<?>> getClasses(Reflections reflections) {
  Set<Class<?>> annotatedClasses = reflections.getSubTypesOf(Object.class);
  for (Iterator<Class<?>> iterator = annotatedClasses.iterator(); iterator.hasNext(); ) {
    Class<?> annotatedClass = iterator.next();

    if (Modifier.isAbstract(annotatedClass.getModifiers())) {
      iterator.remove();
    } else if (!matchesPatternOrIsEnabledSuite(annotatedClass)) {
      iterator.remove();
    }
  }
  return annotatedClasses;
}
 
开发者ID:jlupi,项目名称:sweet-junit-runner,代码行数:14,代码来源:SuiteComponentsScanner.java

示例11: registerAllSubtypes

import org.reflections.Reflections; //导入方法依赖的package包/类
public static <T> Kryo registerAllSubtypes(Kryo destination, Class<T> baseType, String sourcePackageName)
{
    Reflections reflections = new Reflections(sourcePackageName);
    @SuppressWarnings("unchecked")
    Set<Class<?>> subtypes = (Set<Class<?>>) (Set<?>) reflections.getSubTypesOf(baseType);
    registerCollection(destination, subtypes);
    return destination;
}
 
开发者ID:MMORPG-Prototype,项目名称:MMORPG_Prototype,代码行数:9,代码来源:PacketsRegisterer.java

示例12: OidcProfileScopeToAttributesFilter

import org.reflections.Reflections; //导入方法依赖的package包/类
public OidcProfileScopeToAttributesFilter(final PrincipalFactory principalFactory,
                                          final ServicesManager servicesManager,
                                          final Collection<BaseOidcScopeAttributeReleasePolicy> userScopes,
                                          final OidcAttributeToScopeClaimMapper attributeToScopeClaimMapper) {
    this.attributeToScopeClaimMapper = attributeToScopeClaimMapper;
    this.filters = new HashMap<>();

    final String packageName = BaseOidcScopeAttributeReleasePolicy.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 BaseOidcScopeAttributeReleasePolicy>> subTypes =
            reflections.getSubTypesOf(BaseOidcScopeAttributeReleasePolicy.class);
    subTypes.forEach(Unchecked.consumer(t -> {
        final BaseOidcScopeAttributeReleasePolicy ex = t.newInstance();
        filters.put(ex.getScopeName(), ex);
    }));

    userScopes.forEach(t -> filters.put(t.getScopeName(), t));

    this.principalFactory = principalFactory;
    this.servicesManager = servicesManager;
    this.userScopes = userScopes;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:28,代码来源:OidcProfileScopeToAttributesFilter.java

示例13: loadVariableResolverClasses

import org.reflections.Reflections; //导入方法依赖的package包/类
private VariableResolvers loadVariableResolverClasses() {
    Reflections reflections = new Reflections("br.com.moip.mockkid");
    Set<Class<? extends VariableResolver>> conditionals = reflections.getSubTypesOf(VariableResolver.class);
    VariableResolvers instances = new VariableResolvers();

    for (Class<? extends VariableResolver> conditional : conditionals) {
        try {
            instances.add(conditional.newInstance());
        } catch (IllegalAccessException | InstantiationException e) {
            logger.error("Couldn't instantiate class " + conditional.getName() + ", skipping...", e);
        }
    }

    return instances;
}
 
开发者ID:moip,项目名称:mockkid,代码行数:16,代码来源:VariableResolverProvider.java

示例14: getPayloadClasses

import org.reflections.Reflections; //导入方法依赖的package包/类
public static Set<Class<? extends ObjectPayload>> getPayloadClasses () {
    final Reflections reflections = new Reflections(ObjectPayload.class.getPackage().getName());
    final Set<Class<? extends ObjectPayload>> payloadTypes = reflections.getSubTypesOf(ObjectPayload.class);
    for ( Iterator<Class<? extends ObjectPayload>> iterator = payloadTypes.iterator(); iterator.hasNext(); ) {
        Class<? extends ObjectPayload> pc = iterator.next();
        if ( pc.isInterface() || Modifier.isAbstract(pc.getModifiers()) ) {
            iterator.remove();
        }
    }
    return payloadTypes;
}
 
开发者ID:hucheat,项目名称:APacheSynapseSimplePOC,代码行数:12,代码来源:ObjectPayload.java

示例15: loadPlugin

import org.reflections.Reflections; //导入方法依赖的package包/类
/**
 * @param scanPack
 * @param specifyPluginNames
 *
 * @throws WispPluginException
 */
@Override
public void loadPlugin(String scanPack, Set<String> specifyPluginNames) throws WispPluginException {

    Reflections reflections = ReflectionUtil.getReflection(scanPack);
    Set<Class<? extends IWispRouter>> wispRouters = reflections.getSubTypesOf(IWispRouter
            .class);

    boolean isFirst = true;
    for (Class<? extends IWispRouter> canalInjector : wispRouters) {

        String pluginName = canalInjector.getAnnotation(PluginName.class).name();

        if (!specifyPluginNames.contains(pluginName)) {
            continue;
        }

        LOGGER.info("loading router: {} - {}", pluginName, canalInjector.toString());

        try {
            Class<IWispRouter> canalInjectorClass = (Class<IWispRouter>) canalInjector;

            innerWispRouterMap.put(pluginName, canalInjectorClass.newInstance());

            if (isFirst) {
                firstWispRouter = innerWispRouterMap.get(pluginName);
                isFirst = false;
            }

        } catch (Exception e) {
            LOGGER.error(e.toString());
        }
    }
}
 
开发者ID:warlock-china,项目名称:wisp,代码行数:40,代码来源:RouterMgrImpl.java


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