我想在tapestry中使用ApplicationStateManager来检索UserProfile SessionState对象,该对象将包括用户首选的语言环境。然后,我想使用此语言环境为每个请求设置ThreadLocale值,从而消除了对丑陋的URL语言环境值的需要。我的app模块中有以下代码:
@Decorate(serviceInterface = ThreadLocale.class)
public ThreadLocale decorateThreadLocale(final ThreadLocale threadLocale, final PersistentLocale persistentLocale,
@InjectService("ApplicationStateManager")
ApplicationStateManager asm) {
return new ThreadLocale() {
@Override
public void setLocale(Locale locale) {
threadLocale.setLocale(locale);
}
@Override
public Locale getLocale() {
if (!persistentLocale.isSet())
{
UserProfile profile = asm.get(UserProfile.class);
Locale userLocale = userProfile.getPreferredLocale();
if( userLocale != null)
setLocale(userLocale);
}
return threadLocale.getLocale();
}
};
}
问题是没有提供ApplicationStateManager实例,因此它不可用。如何从我的模块中访问ApplicationStateManager?