spring mvc - Java Reflection - How to exclude interface when loading the class dynamically -


i use spring framework find class , methods , arguments dynamically.

these methods use :

public list<class> findmytypes(string basepackage) throws ioexception, classnotfoundexception     {         resourcepatternresolver resourcepatternresolver = new pathmatchingresourcepatternresolver();         metadatareaderfactory metadatareaderfactory = new cachingmetadatareaderfactory(resourcepatternresolver);          list<class> candidates = new arraylist<class>();         string packagesearchpath = resourcepatternresolver.classpath_all_url_prefix +                                    resolvebasepackage(basepackage) + "/" + "**/*.class";         resource[] resources = resourcepatternresolver.getresources(packagesearchpath);         (resource resource : resources) {             if (resource.isreadable()) {                 metadatareader metadatareader = metadatareaderfactory.getmetadatareader(resource);                 if (iscandidate(metadatareader)) {                     candidates.add(class.forname(metadatareader.getclassmetadata().getclassname()));                 }             }         }         return candidates;     }     public string resolvebasepackage(string basepackage) {         return classutils.convertclassnametoresourcepath(systempropertyutils.resolveplaceholders(basepackage));     }      @suppresswarnings({ "rawtypes", "unchecked" })     public boolean iscandidate(metadatareader metadatareader) throws classnotfoundexception     {         try {             class c = class.forname(metadatareader.getclassmetadata().getclassname());             if (c.getannotation(controller.class) != null) {                 return true;             }         }         catch(throwable e){         }         return false;     } 

i load class has got annotation @controller. working fine want load class not interface how methods , arguments of class loaded.

edit :

this how class names , try methods name :

list classnames = hexgenclassutils.findmytypes("com.hexgen.*");             iterator<class> = classnames.iterator();             while(it.hasnext())             {                 class obj = it.next();                  system.out.println("class  :"+obj.tostring());                  cls = class.forname(obj.tostring());                 method[] method = cls.getmethods();                 (method method2 : method) {                     system.out.println("method name : "+method2.togenericstring());                 }                 // todo  obj             } 

the problem face class com.hexgen.api.facade.hexgenwebapi here class coming because of not able load class dynamically , following exception.

java.lang.classnotfoundexception: class com.hexgen.api.facade.hexgenwebapi how solve it.

kindly me find solution.

best regards

try

        class c = class.forname(metadatareader.getclassmetadata().getclassname());         if (!c.isinterface() && c.getannotation(controller.class) != null) {             return true;         } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -