Hi,

First of all, thank you. Surely your approach works , but in my opinion it
somehow violates EJB's goals. I mean to have a reusable, independent
enterprise component we better to wrap all necessary code in an EJB
component or at most in an EJB module instead of distributing the code on
different parts or tiers!

Best regards,
Mohammad

-----Original Message-----
From: Fred Loney [mailto:[EMAIL PROTECTED]]
Sent: Saturday, September 22, 2001 4:11 AM
To: Mohammad Kargar; [EMAIL PROTECTED]
Subject: Re: Where to put multi-entity business rules?


A useful approach is to validate update intent in two places:

Perform validations that do not depend on database state in a non-EJB
JavaBean, e.g. a form bean checking field format.

Perform validations that depend on database state in a Session Bean,
with a transactional context if appropriate.

E.g.

InventoryUpdateAction {
  perform(InventoryForm form) {
     if (form.validate())
session.updateInventory(form.getInventoryItem())
  }
}

InventoryChangeSession {
  updateInventory(InventoryItem item) {
     if (isValidAccountId(item.getAcctId())) ...
  }
}

Fred Loney
Spirited Software, Inc.
www.spiritedsw.com

----- Original Message -----
From: "Mohammad Kargar" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, September 22, 2001 2:07 AM
Subject: Where to put multi-entity business rules?


> Hi all,
>
> We are developing an integrated accounting-inventory environment under
J2EE.
> Say Entity A is responsible for general ledger(GL) accounts and Entity
B
> handles inventory. According to the current requirements, each
inventory
> item contains 3 account IDs from GL.
> My question is about the best place to put ID validation. One approach
is to
> ask Entity B to do this. Based on this approach Entity B does
validation by
> getting a reference to Entity A and asking it to validate ID. Another
way is
> to have a session facade to fulfill this. It means that session facade
will
> has a reference to Entity A and validates IDs before delivering them
to
> Entity B.
>
> Thanks in advance,
> Mohammad
>
>
========================================================================
===
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff EJB-INTEREST".  For general help, send email
to
> [EMAIL PROTECTED] and include in the body of the message "help".
>

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to