• Post Reply Bookmark Topic Watch Topic
  • New Topic

Newbie needs help

 
tan kian
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all, i have a noob question regarding j2ee......i'm supposed to write a sessionbean(ABSession) that provides a client interface to 2 CMP entity beans(a and b) that should have a many to many CMR between them. now, i'm confused about the "sessionbean that provides a client interface" part. is this 1 class file that specifies the interface for the 2 entity beans? or is there more to it? thanks for the help.

something like this?:
public interface ABSession extends EJBLocalHome
{
create(String name, int age) throws CreateException;
findByPrimaryKey(String name);
}

or:
public class ABSession implements SessionBean
{
public void ejbCreate() throws CreateException
{
}

//methods here
}
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For every session and entity bean, you must write the bean class, the home interface and the component interface. You will also need the ejb-jar.xml file, which will contain amongst other things the relationships between the beans. Note that a CMR field must be a local interface type (the EJB spec requires this).

Although there is often a tool which generates the ejb-jar.xml file, I recommend writing it yourself as a learning excercise.
 
tan kian
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmm.....so for my case i'll need a total of 9 files, 3 for the sessionbean and 3 for each entitybean?
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing is that simple in EJB. It is common that there will also be a vendor-specific deployment descriptor file. And if your session bean is invoked by a client, then you will have to write that client class too.

Let's not forget that data has to be passed around as arguments or return type. If your remote client needs either, then you may have to write a serializable class or two for data transfer.
 
tan kian
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah i'm supposed to have a client for the sessionbean as well.....damm this is confusing
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!