Posted in AOP, Java EE, Spring

AOP Concepts


Joinpoint A specific point in the code, every method in every class is a Joinpoint.
Pointcut A collection of one or more Joinpoints, for example all the methods of a class.
Advice The implementation of crosscutting concern, it means what do I want to do with crosscutting concern (Before, Around, After).
Aspect What crosscutting concern do I execute (=Advice) at which location (=Pointcut); in other words what do I want to do, where do I want to do it in the code. –> advice + pointcut
Weave The advice code together + Target code at corresponding Pointcuts such that we get the correct execution; it means different methods together with right sequence.

And this would be an example how we can write a Pointcut:


Posted in Core Java, Design Pattern, Object Oriented Programming

Singleton Pattern

A Singletone class;

Only one time in JVM per class loader would be instantiated. Same instance would be use for repeated calls.

public class OnlyOne {

            private static OnlyOne one = new OnlyOne();

            // private constructor, so this class cannot be instantiated from outside and prevents


private OnlyOne();

//a global point of access

public static OnlyOne getInstance() {

            return one;



To use it:

OnlyOne myOne = OnlyOne.getInstance();


Posted in Core Java, Object Oriented Programming

String vs StringBuffer == and .equals methods

  str1==str2 str1.equals(str2)
String Compares Objs location Compares Objs String contents
StringBuffer, StringBuilder Compares Objs location If and only if str1==str2 would be True.


So if we need to compare or sort in StringBuffer / StringBuilder we need to turn them into String first. For example:

if (str1.ToString() = str2.ToString())   {


}   else   {




Posted in App-server, Java EE, Tomcat, Uncategorized, Web-Server

Application Server vs. Web Server

This chart* perfectly captures different features of App Servers versus Web Servers:

Application Server Web Server
What is it? A server that exposes business logic to client applications through various protocols including HTTP. A server that handles HTTP protocol.
Job Application server is used to serve web based applications and enterprise based applications(i.e servlets, jsps and ejbs…). Application servers may contain a web server internally. Web server is used to serve web based applications.(i.e servlets and jsps)
Functions To deliver various applications to another device, it allows everyone in the network to run software off of the same machine. Keeping HTML, PHP, ASP, etc files available for the web browsers to view when a user accesses the site on the web, handles HTTP requests from clients.
Supports distributed transaction and EJB’s Servlets and JSP
Resource utilization High Low

Question: Apache Tomcat is a Web Server or an Application Server?

Answer: Tomcat is a web server (can handle HTTP requests/responses) and web container (implements Java Servlet API, also called servletcontainer) in one. Some may call it an application server, but it is definitely not an fullfledged Java EE application server (it does not implement the whole Java EE API).**


* source: