DeWitt, One possibility is to use the hivemind.SymbolSources configuration point. Then it would be transparent to your TemplateEngine whether symbol values were provided by your own ServletContext aware symbol source or by the ApplicationDefaults (or FactoryDefaults) symbol source.
You just have to figure out how your symbol source can access the ServletContext. Regards, --knut On 1/23/06, DeWitt Clinton <[EMAIL PROTECTED]> wrote: > Hi: > > I am new to HiveMind, though relatively familiar with component > frameworks in general. I am currently working on a new application > and have a question about best practices. > > Part of this application is being built using MVC-2 patterns (i.e., > "push" MVC). In other words, I would like to use services to build up > a set of data, then "push" that data to a templating service (in this > case, Velocity, but that could change) to be rendered for the client. > > To accomplish this, I have created a generic TemplateEngine interface > and a specific implementation called VelocityTemplateEngine. > > When the VelocityTemplateEngine is instantiated it needs to determine > the location of the Velocity configuration file. The location of this > file is neither static nor absolute -- the file is typically found at > runtime as a resource relative to the WAR file it is deployed in. > > If I were *not* writing a HiveMind service, I would simply use the > getResourceAsStream method on the ServetContext to load the > appropriate Velocity configuration at runtime based on the servlet's > context. > > However, since I am using HiveMind, I would like to create a more > flexible and reusable VelocityTemplateEngine. Ideally, the service > instance would be able to determine, upon instantiation, whether or > not it was running in the context of a servlet. If it was (i.e., it > had access to a ServletContext), then it would load the resources > accordingly. If not, then it would fall back on default paths or on > simple configuration values from HiveMind (ApplicationDefaults, > perhaps?). > > My question is this: what is the best way for the > VelocityTemplateEngine instance to be made aware of a global context? > > It feels wrong to explicitly pass the ServletContext to a generic > TemplateEngine, which might not be running in a servlet at all. Is it > possible for the calling code to "contribute" the ServletContext to a > configuration point for the TemplateEngine? If so, how? > > This pattern will likely apply in more scenarios than simply the > template example, so I want to make sure I understand the correct way > to proceed. > > Thanks in advance! > > -DeWitt > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
