@SuppressWarnings("unchecked")
    public static <T> Set<Class<T>> loadClasses(String packageName, Class<T> baseClassOrInterface)
    {
        Set<Class<T>> result = new HashSet<>();

        try
        {
            Set<String> classNames = getClassNamesFromPackage(packageName);
            ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
            for (String className : classNames)
            {
                try
                {
                    Class< ? > clazz = classLoader.loadClass(packageName + "." + className);
                    if (!Modifier.isAbstract(clazz.getModifiers()) && baseClassOrInterface.isAssignableFrom(clazz))
                    {
                        result.add((Class<T>) clazz);
                    }
                }
                catch (Throwable e)
                {
                    logger.error(e, e);
                }

            }
            logger.info("Loaded " + result.size());
        }
        catch (Exception e)
        {
            logger.error(e, e);
        }

        return result;
    }
@ SuppressWarnings ( "unchecked" ) public static < T > Set < Class < T > > loadClasses ( String packageName , Class < T > baseClassOrInterface ) { Set < Class < T > > result = new HashSet < > ( ) ; try { Set < String > classNames = getClassNamesFromPackage ( packageName ) ; ClassLoader classLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; for ( String className : classNames ) { try { Class < ? > clazz = classLoader . loadClass ( packageName + "." + className ) ; if ( ! Modifier . isAbstract ( clazz . getModifiers ( ) ) && baseClassOrInterface . isAssignableFrom ( clazz ) ) { result . add ( ( Class < T > ) clazz ) ; } } catch ( Throwable e ) { logger . error ( e , e ) ; } } logger . info ( "Loaded " + result . size ( ) ) ; } catch ( Exception e ) { logger . error ( e , e ) ; } return result ; }
find and all non abstract classes that implement/extend
baseClassOrInterface in the package packageName

@param packageName
@param baseClassOrInterface
@return