assuming the code runs as is, and assuming it does what you think it does, you could leave it as inline java in your b4a app, write a little helper function (or method, depending) and call your helper from b4a with a java object. you pass the host name, and your helper returns a list of candidates or a single candidate back to b4a and you stuff it in the url of your okhttputils2 job. you'll need the required imports to resolve references.
i believe there are some issues that might make it impossible, frustrating, difficult and/or time consuming to get it to work in b4a (with java object and reflection). but there are some members who might see this as an interesting challenge. if you were looking at java code, it sounds to me like you could handle my first suggestion without too much hassle. if you have all the necessary pieces for the inline java (ie, the imports), it will blend perfectly with a b4a app and a single java object declared in the app. if you don't program in java, then you'll have to wait and see if somebody thinks it's worth the time to do it for you. i certainly intend to take a look at it, although i'm not totally convinced it will actually make a difference. cdn is usually set up to optimize the distribution.