Question

I started to use Javadocs for documenting my Java code, although I really like the idea, I have ran into some trouble. Basically there are two seperate projects, WEB project, with html pages and servlets, and EJB project, with beans and interfaces. Bean's interface is exported like .jar intro WEB project, so servlet can lookup with JNDI and call beans's methods.

Problems:
1) Why can't I see the javadoc comment in interface implemented by the bean? Example:

@Remote
public interface BeanRemote{
    //CAN'T SEE JAVADOC HERE
    public String tuna(String fish);
}

@Stateless
public class Bean implements BeanRemote{
    /**
    This is very nice function
    */
    public String tuna(String fish){
        return "this is"+fish;
    }
    public void printStuff(){
        //CAN SEE JAVADOC HERE
        String stuff = tuna("big tuna");
        System.out.println(stuff);
    }
}

2) Would it be possible to see javadoc comment from WEB project's servlet, if it has .jar of interface, while actual javadoc comment is in the bean?

Thanks in advance.

EDIT:
simplified structure of both projects:
WEB:

webProject
  JavaResources
    src
      servlets
        //Can't see Javadoc here
        BeanServlet.java
  WebContent
    WEB-INF
      lib
        //This is interface on the bean from BEAN project
        BeanRemote.jar

BEAN:

beanProject
  ejbModule
    beans
      //Javadoc is here
      Bean.java
    remote
      //Can't see Javadoc here
      //This is exported into WEB project
      BeanRemote.java
Was it helpful?

Solution

Since you are referencing the interface on your web project, your Javadocs should be placed in the interface method.

If your implementation method needs a more specific documentation, you could also inherit Javadocs from the interface and add the specifics. Just use {@inheritDoc} inside your Javadoc block.

Example:

/**
* {@inheritDoc}
* <p>
* For this specific implementation of the interface, you're better off
* calling the more efficient {@link foo} method, provided you have the
* additional arguments!
* </p>
*/
@Override
public void methodX() {
    // Your code here
}

Remember that the specific docs will only appear if you're explicitly referencing this class.

BeanRemote bean = new Bean();

When you put your mouse cursor over BeanRemote it will show you the docs from BeanRemote whereas when you put it over Bean it'll show the specific docs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top