Discussions

EJB design: Naming Convention for Local Interfaces and Local Homes

  1. It was said that in here:
    http://www.theserverside.com/patterns/thread.jsp?thread_id=1842
    that the naming convension for EJBs are as follows:
    <ejbname>EJB for the bean
    <ejbname> for the remote interface
    <ejbname>Home for the home interface

    But what about local interfaces and local homes, that were added to the new EJB 2 pfd2 specifications?

    There is no problem when using only either local *or* remote interfaces; you can use <ejbname> and <ejbname>Home. But if one wants to use *both* at the same time, a new pair of names has to be used. There's no standard or convention that I can find anywhere.

    I propose using always:
      <ejbname>Local for a local interface
      <ejbname>LocalHome for local homes

    I'm curious to know what you think.
  2. I would probably put it the other way round:
    <EJBName>Bean for implementation class
    <EJBName>Remote for remote interface
    <EJBName>RemoteHome for remote home
    <EJBName> for local interface
    <EJBName>Home for local home interface

    This is because I think the local interfaces will probably be used more often if the bean offers both interfaces.
    Additionally I think the local interfaces are more of "standard" interfaces whereas the remote interfaces are something "special".

    kind regards

    Messi
  3. Emmanuel,

    I prefer to use the naming convention you proposed, and here is why. The first three should probably be left that way because most systems use that naming convention. There is nothing forcing you to use that convention, but I prefer to use EJB the standard way the industry is. The local interfaces is new in most cases, so it is a matter of coming up with what are good naming conventions for them. Again, I like what you have proposed and that is probably going to be the convention that I use. I am surely not going to go back and change the names of all my ejb files to add local interfaces. Just add the local interfaces and give them unique names like you have suggested.

    <ejbname>EJB for the bean
    <ejbname> for the remote interface
    <ejbname>Home for the home interface
    <ejbname>Local for a local interface
    <ejbname>LocalHome for local homes