The code below produces a NumberFormatException in this line:
val cache = cf.createCache(Collections.emptyMap())
Do you see any errors?
Will I need to write a Java version to avoid this, or is there a Scala way?
...
import java.util.Collections
import net.sf.jsr107cache._
object QueryGenerator extends ServerResource {
private val log = Logger.getLogger(classOf[QueryGenerator].getName)
}
class QueryGenerator extends ServerResource {
def getCounter(cache:Cache):long = {
if (cache.containsKey("counter")) {
cache.get("counter").asInstanceOf[long]
} else {
0l
}
}
@Get("html")
def getHtml(): Representation = {
val cf = CacheManager.getInstance().getCacheFactory()
val cache = cf.createCache(Collections.emptyMap())
val counter = getCounter(cache)
cache.put("counter", counter + 1)
val q = QueueFactory.getQueue("query-generator")
q.add(TaskOptions.Builder.url("/tasks/query-generator").method(Method.GET).countdownMillis(1000L))
QueryGenerator.log.warning(counter.toString)
new StringRepresentation("QueryGenerator started!", MediaType.TEXT_HTML)
}
}
Thanks!