Objectify with Play Framework 2

时间:2016-07-11 20:32:03

标签: java playframework objectify playframework-2.5

Is there a way to work with objectify when we don't use a servlet or a WEB-INF/web.xml? I use Play! Framework 2.5.4 with Java and I don't know how to deal with that...

From this link : Objectify wiki setup

I found a way to execute this code by creating a new module :

bind(ObjectifyFilter.class).in(Singleton.class);

But i don't know how to execute :

filter("/*").through(ObjectifyFilter.class);

Since I don't know how to do that, I tried that :

ObjectifyService.begin();
ofy().save().entity(registration).now();

But I only get the following exception :

Error saving models.gcd.Registration@54cd7ad7: No API environment is registered for this thread.

Thanks for your help!

1 个答案:

答案 0 :(得分:3)

这看起来像是一个有趣的挑战。

在play框架中注册过滤器并不是很困难,尽管它不遵循servlet规范。

https://www.playframework.com/documentation/2.5.x/JavaHttpFilters

但我看到的主要问题是(对于我读过的一点点),这个框架使用Thread本地上下文来存储有关事务和异步任务的信息。这与play框架在非阻塞模型之后使用踏板的方式不兼容。 https://www.playframework.com/documentation/2.5.x/ThreadPools

不确定这些信息会对您有所帮助,但会让您对游戏框架有更全面的了解。

享受