jump to navigation

EJB, again, best practices, patterns June 23, 2005

Posted by javafoo in ejb, javanotes.

Session Facade
Consider two Entity Beans and a client for ex: Employee and Paycheck. So you find the Employee, create a new Paycheck, populate some of the employee details or based on some values in Employee, you set some values on Paycheck. So you have all this business logic noise all over the client and the overhead of managing the entity beans. Enter Session Facade: You have a Session bean, that has a single method called managePaycheck, all the client has to do is call this method and all the noise moves to the Session bean.

Value Object/Data Transfer Object
Value objects are used to transfer bulk data between tiers. So if you have a remote object (entity bean) and you are calling a multitude of get methods on that object. It makes sense to create a single ValueObject containing all the data needed. So now you are just calling getValueObject on that Entity bean (provided ofcourse the entity bean populates all the fields in the ValueObject first).

Use of dirty flags in the EntityBean
Use dirty flags in ejbStore, basically init this as false in ejbLoad and set it to true in the setter. In ejbStore check this flag and only go ahead if it is true.

More to come…



No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: