RC/PRC Access from Service Model

Simply looking for the “best practice” on a minor issue I am running up against, using ColdFusion 9.0.2 with ColdBox 3.5.2.

We have a mobile gateway built supporting RESTful services. It is stateless. User authenticate to a proxy, and a token is passed in each request. This is validated and the user information is cached (CacheBox) for a short period of time (for performance reasons to handle multiple requests. This is all working well.

Recently I’ve set about to wire in the i18n plugin. This has gone well. The only snag is that our system actually has a database of languages supported, identified with a languageKey (UUID), and associated with a locale (e.g.: en_US, etc.). I’ve wrapped the i18n plugin with a language service which abstracts out the resolution of languageKey to locale. This is necessary as the application the gateway accesses is a reporting system which stores reports in multiple language identified with the languageKey.

On to the problem…

The handlers accept, where appropriate, a languageKey from the device, for some of the routes. Many of the queries, etc., then use the languageKey to translate information returned (e.g.: pick-lists, etc.) to be sent back to the device.

I’m trying to avoid passing the languageKey (UUID) to every service method. It is my understanding that the locale can be stored, as part of the request, using the setFwLocale(), but not sure what to do with the languageKey, which is necessary as well. I realize that I “could” store the languageKey in the RC/PRC, and access that from the service models, but not sure if that is a good idea.

Not sure I’m making the issue clear. If so, suggestions? If not, I can elaborate as needed.

Thanks in advance!

Kevin S. Anderson

I would certainly avoid passing the entire rc or prc into your models. If you don’t want to clutter your model’s API by adding the local to every model method, just inject the i18n plugin into your models and call its getfwLocal() method. For every model that needs to be locale-dependant, it’s ok for it to have a dependency on the i18n plugin.



ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Hey, Brad:

Thanks for your response. I do have an injection of the i18n plugin, where needed, and that is working well. Primary question was how to persist the languageKey (UUID) so that I would not have to pass it in between all the methods; however, I think your recommendation was to pass it, as needed.

I guess that means I’m moving forward. Ah the joys of the “stateless” system, eh? :wink:


Kevin S. Anderson