This discussion is archived
1 Reply Latest reply: Dec 4, 2012 2:16 PM by EJP RSS

method in a class that should not be visible to outside class

Manjit Newbie
Currently Being Moderated
I am using Spring task executor and I have a service that has two method.


public SpringTaskExecutor implement SpringExecutor {
List<Info> infos;

//called by spring to poll the db after every 10 mts
public pollDatabaseAfterEveryTenMinute(){
.
.
.infos= new ArrayList<Info>();
infos.add....
.}

//called by other class to get polling details
public List<Infor> getInfoOfTeam(){
return infos;

}


But I want to make pollDatabaseAfterEveryTenMinute as private or protected so that only Spring can call it ,but no one else.

Unfortunately I cannot make it private/protected because I implement an interface and spring will not find if I dont define the method in the interface.The second alternative is not to implement the interface.
Please tell me if I have any other alternative

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points