Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

how to implement singletun design patteren in struts?

Answer Posted / sk neelofar

public class Sample
{
pubic static Sample s=new Sample();
private sample(){
}//constructor
public static smple getInstance()//static factory method
{
return s;
}//method
}//class

......
Sample s1= Sample.getInstance();
Sample s2= Sample.getInstance();


1.A static method can b called outside the class using clas
name.
2.In this implementation, we used private constructor n a
static factory method to make a class as a singleton class.
3.if we call the getInstance(); of the class for any no. of
times, same object of the class will b returned to the
programmer.
4. the programmer can't create an object pf this class
outside the class, coz it has a private constructor.

Is This Answer Correct ?    23 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the two types of validations supported by validator framework?

991


Which configuration file is used for storing jsp configuration information in struts?

953


What are action errors and error and what are the consequences they impose?

956


What are the pros of struts 2?

938


What is the purpose of @intrangefieldvalidator annotation?

1286


How do I access token?

923


List the important attribute and elements of action mapping under struts.

950


What is the purpose of '@keyproperty'?

991


Why is action servlet a singleton in struts?

1044


What do you mean by the abstract package in struts2, and what is its utilization?

902


What is the difference between validation.xml and validator-rules.xml files in struts?

887


What is action support class in struts2?

957


What is the difference between empty default namespace and root namespace?

1074


How can we display all validation errors to user on jsp page?

1060


What are different ways to create Action classes in Struts2?

1041