Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Conversational state - Session Bean

 
Sandesh Tathare
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJB Specs - Section 7.4 Conversational state says:
The conversational state of a STATEFUL session object is defined as the session bean instance�s field values, plus the transitive closure of the objects from the instance�s fields reached by following Java object references.


Can some one please explain in simple words what they mean by transitive closure of the objects? :roll: An example would be appreciated.
 
Arun Krishnamoorthy
Greenhorn
Posts: 22
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Transitive closure in java parlance means recursive traversal of all objects referenced from within the bean's instance.

An example would be a Customer Session Bean with the following instance variables:Account & Profile (just consider these two instance variables as POJOs).

The Account object has the following definition:

public class Account
{
public String accountId;
public String accountName;
public Orders[] accountOrders;
public Profile aProfile;
}

public class Profile
{
public String profileId;
public String nickName;
public String preferredVendor;
}

public class Orders
{
public long orderNumber;
public String productOrdered;
private String notPartOfTransitiveClosure;

}

Transitive closure would imply that from an Account oject, say myAccount, we can do the following:

(1) You can refer to all Account object's instance variables (myAccount.accountId, myAccount.accountName,
myAccount.accountOrders, myAccount.aProfile)

(2) You can also refer to myAccount.aProfile.profileId, myAccount.aProfile.nickName, myAccount.aProfile.preferredVendor

(3) You are also able to access myAccount.[orderIndex].orderNumber, myAccount.[orderIndex].productOrdered
but, you will not be able to access myAccount.[orderIndex].notPartOfTransitiveClosure.

So, the object graph for Account object would be all the instance variables in myAccount plus recursively going through each reference (in this case, Account and Profile) to get to the lowest attribute reachable with the object reference.
 
Sandesh Tathare
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arun,

I am really impressed with your answer. Really Gr8!

Thanks for example. It was good one.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic