Search code examples
jakarta-eeannotationsremote-accessprivate-methods

Does @Remote in Java EE 6 make private methods accessible?


Consider this code:

@Remote
public interface ISayHello {
    private void sayHello();
}

Will the sayHello method be accessible from the outside world or not?


Solution

  • You're not allowed to create private methods in an interface... They are all public abstract by default.

    All public methods of your @Remote interface are EJB's business methods.

    If you want to have some EJB methods not exposed to the outside world, either don't define them in the interface (in case you use local/remote business interfaces) or make them package private / protected / private (in case of no-interface view.)