Part 1 - Part 2 - Part 3 - Part 4 - Part 5
In the first part, we created a Prevayler-based project in Eclipse including the root of our prevalent Sytem: the DVDStorage class. Now, we want to add our Business Objects to this prevalent systems, that is, we want to store DVDs in the DVDStorage.
Right-click on the DVDStorage class and select "Create Business Object":
We can choose the options for our new BO in the following dialog:
Of course, our new DVD object is a business object, too, so we create it inside the BO folder. We call it "DVD". As we right-clicked on "DVDStorage" to create our BO, the field(s) containing DVDs will be added to "DVDStorage".
We can choose between a 'Single Object' implementation (in this case, only one DVD can be added to DVDStorage, which is not what we want here), or 'List' implementation (in this case, multiple DVD objects can be added to DVDStorage, which is what we want). We also select "add standard methods" so Preclipse will automatically generate add, remove, and change methods for DVDs inside DVDStorage.
Hit finish. The resulting DVD class will look like this:
Note that support for IDs has automatically been added! IDs are critical for prevalent systems to function, but you needn't take care of that yourself when using Preclipse.
The parent object, DVDStorage, now contains all the methods needed for handling DVDs:
Of course, you can later change these methods to your liking. However, you will find this way of creating prevalent applications very useful, as it is very easy to add transactions for your BOs using Preclipse given the structure created above.
Our DVD object currently only contains an ID, which is not very useful on its own. Therefore, we add some fields and the getters and setters for them:
The field "name" will contain the movie title. "year" will contain the release date, "len" the running time in minutes. "imdb" will contain the identification number of this movie in the International Movie Database (www.imdb.com). "comment" will contain our own comment about this movie.
Now it is time to add transactions to our DVD object.