class Singleton{
private static Singleton singletonObject;
private static int single;
/** A private Constructor prevents any other class from instantiating. */
private Singleton(){
// Optional Code
single++;
System.out.println(“Singleton Zero ARGS Constructor:”+single);
}
public static synchronized Singleton getSingletonObject()
{
if (singletonObject == null){
singletonObject = new Singleton();
}
return singletonObject;
}
public Object clone()throws CloneNotSupportedException
{
throw new CloneNotSupportedException();
}
}
public class SingletonObjectDemo {
public static void main(String args[]){
// Singleton obj = new Singleton(); Compilation error not [...]
Archive for November 3rd, 2008
Singleton Design pattern in java – example
Posted in Java on November 3, 2008 | Leave a Comment »
JVM, JRE, JDK
Posted in Java on November 3, 2008 | Leave a Comment »
JVM is interpreter.
JVM is an instance of JRE comes into action when a java program is executed.
JVM + API JRE
JVM may use Just in time compiler for interpreting or uses set of JVM instructions set.
JIIT is the part of the JVM that is used to speed up the execution time. JIT compiles parts of [...]
Interpreter and compile
Posted in Java on November 3, 2008 | Leave a Comment »
The name “compiler” is primarily used for programs that translate source code from a high-level programming language to a lower level language (e.g., assembly language or machine language). A compiler is likely to perform many or all of the following operations: lexical analysis, preprocessing, parsing, semantic analysis, code generation, and code optimization.
A compiler first takes [...]
Web and application server
Posted in Java on November 3, 2008 | Leave a Comment »
Webserver serves pages for viewing in web browser, application server provides exposes business logic for client applications through various protocols
Webserver exclusively handles http requests.application server serves business logic to application programs through any number of protocols.
Webserver delegation model is fairly simple,when the request comes into the webserver,it simply passes the request to the program best [...]
Diff b/w directive include(@include) and jsp:include
Posted in Java on November 3, 2008 | Leave a Comment »
Think of the include directive as a header file of languages like C/C++. When using the include directive, the combined contents of the original JSP page and all its included resources are translated into the same implementation servlet i.e. the contents of the included resource is copy pasted before translation to a servlet. The important [...]
Types of JDBC technology drivers
Posted in JDBC on November 3, 2008 | Leave a Comment »
JDBC technology drivers fit into one of four categories:
A JDBC-ODBC bridge provides JDBC API access via one or more ODBC drivers. Note that some ODBC native code and in many cases native database client code must be loaded on each client machine that uses this type of driver. Hence, this kind of driver is [...]