Easier initialization of the Root domain object

20 views
Skip to first unread message

Joao Cachopo

unread,
Apr 27, 2009, 7:16:33 PM4/27/09
to fenix-f...@googlegroups.com

With today's commit, I've added one more thing that simplifies the
bootstrapping of an application.

It is now possible to specify in the Config instance the class of a root
DomainObject. For instance:

Config config = new Config() {{
domainModelPath = "/domain.dml";
dbAlias = "//localhost:3306/test";
dbUsername = "test";
dbPassword = "test";
rootClass = MyApp.class;
}};
FenixFramework.initialize(config);

The new thing is the "rootClass = MyApp.class;" line.

This is optional, but if you specify it, then the initialization of the
framework will create and persist an instance of the MyApp class if none
exists yet. Moreover, you may use the new FenixFramework.getRoot()
method that will return you the single instance of the MyApp class that
corresponds to the root object of your application.

So, after initializing the framework with the code above, you simply
call (within a transaction, of course)

MyApp app = FenixFramework.getRoot();

and be assured that the app variable will contain an instance of MyApp
correctly persisted, regardless of this being the first run of the
application or not.

Enjoy,
--
João Cachopo

Reply all
Reply to author
Forward
0 new messages