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


Please Help Members By Posting Answers For Below Questions

What are the reasons for an error message not being displayed while developing struts application?

621


What is DynaActionForm?

683


Explain the complete struts validator framework.

646


What is the role of action class?

655


Explain about the validation steps which have to be carried during validation of client-side address?

636






What applications use apache struts?

583


Describe the basic steps used to create a tiles application?

650


What is struts.devmode?

678


Which design pattern is implemented by Struts2 interceptors?

651


Which components are available using actioncontext map?

805


while working struts in intellij 7.0error unable to initialize tld location cache: zip file is closed is displayed anybdy can answer me immdialy .ungert

2156


How do I install struts?

668


What is http redirect?

660


What's the purpose of execute method of action class?

608


What is the purpose of @key?

669