After looking at the EnvUtils and EnvConfig classes, here are my initial thoughts. Assuming that the purpose of centralized configuration is to mainly meet the requirements set out in the description:
- full attribute names appear in source code in one place:
- typesafe configuration getters
- full configuration dump on startup
1) I don't see an obvious requirement to keep separate classes. I think a single class can be used as the external facing API. If necessary, we can add other supporting classes for utility or environment specific purposes but I think a single class "Environment" or "Configuration" or whatever should suffice and is desirable for core developers. Even more important if we expect application developers to access this as well.
2) I think the logging, currently set for INFO on the attributes we are currently supporting, should be set to a lower level (DEBUG perhaps) and potentially dumped out all in one go when the decoding is done rather than logged per call to decode.
3) Not sure I agree with the non-type safe nature of the (Object context) parameter suggestion if that's what's being pitched. If we were using a different language maybe . ServletContext can be done via ServletContextListener, PortletContext can be done via the bridge. Since they are application scoped, neither really needs to be passed in to a method at all - they can be set at app startup. If it requires a FacesContext to access it, then non-Faces threads will have problems as noted. So we should have a simple, consistent way to guard against that and have it logged appropriately.
A fairly elegant form of the API could assume a FacesContext in scope:
public String getPushEstablish()
but it is likely that Configuration will need to be accessed during non-JSF contexts, so a reasonable API may be
public String getPushEstablish(Object context)
where acceptable context objects are FacesContext, ServletContext, or PortletContext.
Since new methods must be added for each configuration parameter, it should not be necessary to add both forms of the getter.