To show results for af:querycomponent when page loads set the below property
autoExecute="true".
autoExecute="true".
Singleton pattern used when we want to allow only a single instance of a class can be created inside our application. Using this pattern ensures that a class only have a single instance by protecting the class creation process, by setting the class constructor into private access modifier.
To get the class instance, the singleton class can provide a method for example a getInstance() method, this will be the only method that can be accessed to get the instance.
01.package new.mypack.sample02. 03.public class Service {04. private static Service instance = new Service();05. 06. private Service() {07. }08. 09. public static synchronized Service getInstance() {10. return instance;11. }12. 13. @Override14. protected Object clone() throws CloneNotSupportedException {15. throw new CloneNotSupportedException("Clone is not allowed.");16. }17.}There are some rules that need to be followed when we want to implement a singleton.
clone() method of the java.lang.Object class and throw CloneNotSupportedException so that another instance cannot be created by cloning the singleton object.