2

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?

YAT
  • 456
  • 1
  • 4
  • 14

2 Answers2

3

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

Community
  • 1
  • 1
0

I've found a solution:

def classObject= Class.forName(CLASSNAME, false, Thread.currentThread().contextClassLoader).newInstance()
YAT
  • 456
  • 1
  • 4
  • 14