how to implement singletun design patteren in struts?
Answer Posted / shaik baji
Singletun design patteren means we can't create more than
one object for that class which follws Singletun design
pattern.
We can implement it by using one "private" constructor and
one Factory mathod as like follows:
class Sample
{
public static Sample s = new Sample();
private Sample()//constructor
{
}
public static Sample getInstance()//static factory
method
{
return s;
}
}
public class SingleTun
{
public static void main(String arg[])
{
Sample s1= Sample.getInstance();
Sample s2= Sample.getInstance();
}
}
Is This Answer Correct ? | 5 Yes | 4 No |
Post New Answer View All Answers
What is struts?
How to work with error tags?
Can a reducer dispatch an action?
Which design pattern the interceptors in struts2 is based on?
What is difference between interceptors and filters?
What is the use of struts config xml file?
What is the use of namespace in action mapping in Struts2?
What is the purpose of @createifnull annotation annotation?
Which file is used by controller to get mapping information for request routing?
What are the two types of validations supported by validator framework?
What is the purpose of '@customvalidator'?
What is the use of Struts.xml configuration file?
What is switchaction?
When do I need “struts.jar” on my classpath?
Provide some important Struts2 constants that you have used?