Reputation: 466
I have an Groovy class located in /src/groovy/
named testFilter
.
I want to find dynamicly filters, so i tried this:
def filterClass = grailsApplication.allClasses.find{it.name==className}
but that doesn't work for files in /src/groovy/
how can i find the class?
Upvotes: 2
Views: 611
Reputation: 466
I've found a solution:
def classObject= Class.forName(CLASSNAME, false, Thread.currentThread().contextClassLoader).newInstance()
Upvotes: 0
Reputation: 578
Using grails you can only list domains classes, but you can use java for example : ClassLoader.
In your case code will be like:
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
classLoader.getResource("src")
You can also find answer on your question here
Upvotes: 3