File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes private or public EJB method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "private or public EJB method" Watch "private or public EJB method" New topic
Author

private or public EJB method

Peter Warde
Ranch Hand

Joined: Aug 18, 2004
Posts: 71
Does anybody know what the difference is between having a private method in an EJB and a public method which is not exposed on component interface ie not visible to clients. I'm using such methods as helper methods.;

Is there any difference between the 2 and if not which one is good practice?

Thanks
Sanju Thomas
Ranch Hand

Joined: Dec 29, 2004
Posts: 243
The client can access only those methods, that are exposed through the Component interface or Home interface. So if you are not exposing a business method in the component interface then it will become a helper method. Or only those methods that are exposed through the component interface are considered as business methods.

Normally helper methods which are implemented by the bean is decalred as private. I think that is the best practice too. Then even if your are writing helper methods are public and not exposing the same in the component interface, then the client can't access it. So it does't mean a lot, but still it is legal.
ravi janap
Ranch Hand

Joined: Nov 04, 2000
Posts: 389
If your helper methods are declared in a interface and your bean implements the interface then your helper methods are public. However if you define your methods in bean class then your helper methods are private though you can still declare the helper methods in your bean class as public and it would not do any harm as long as you have not exposed the same in your component interface as pointed out in the previous posting.
[ April 15, 2005: Message edited by: Ravindra Janapareddy ]

SCJP, SCJD, SCWCD, SCBCD, SCEA
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: private or public EJB method