The factory I was trying to create a bean from was the JAX-RS Client API class ClientBuilder.newClient() which returns a Client object.
Here is what the bean definition looks like in my Grails resources.groovy file:
import javax.ws.rs.client.ClientBuilder
beans = {
httpClient(ClientBuilder) { bean ->
bean.factoryMethod = 'newClient'
bean.destroyMethod = 'close'
}
}
Then in your Grails service or controller you can autowire or inject the bean by doing the following:
class FooService {
def httpClient
def get(url) {
return httpClient.target(url).request().get()
}
}
Hope it helps the next person.