I haven't found any issues with running the bamboo.Prevalence engine within the HttpApplication object:
public class Global : System.Web.HttpApplication
{
// prevalence engine stuff
public static PrevalenceEngine PsEngine;
public static ToDoList PsSystem;
protected void Application_Start(Object sender, EventArgs e)
{
string prevalenceBase = "{some physical path (C:\data)}";
Global.PsEngine = PrevalenceActivator.CreateTransparentEngine(
typeof(ToDoList), prevalenceBase);
Global.PsSystem = Global.PsEngine.PrevalentSystem as ToDoList;
}
}
I posted the main source code pieces here.
Later on, after posting my test, I found this message posted by Rodrigo. He posted a recommendation on how to use the engine with ASP.NET. The only difference I found was that he used PrevalenceActivator.CreateEngine. I used .CreateTransparentEngine. I wasn't sure what the difference meant so I checked into it. The Prevalence Engine uses a reader/writer strategy based on command and query objects. It will allow query objects to run concurrently but will only allow one command object to execute at a time. The Transparent Proxy created by .CreateTransparentEngine will automatically transform the method calls to commands for you. Pretty slick!
He also posted another way to implement the prevalence system. You basically add the following to your application config file:
<bamboo.prevalence>
<engines>
<add id="tasks"
type="Bamboo.Prevalence.Demo.TaskSystem"
base="c:\tasks" />
<add id="documents"
type="Bamboo.Prevalence.Demo.DocumentSystem"
base="c:\documents"
autoVersionMigration="true" />
</engines>
<bamboo.prevalence>
With this, the engine will automatically be created for you and will be available using:
PrevalenceEngine engine = PrevalenceSettings.GetEngine("tasks");

0 Comments:
Post a Comment
<< Home