Posts

Should Logger members of a class be declared as static?

Advantages for declaring loggers as static Disadvantages for declaring loggers as static common and well-established idiom less CPU overhead: loggers are retrieved and assigned only once, at hosting class initialization less memory overhead: logger declaration will consume one reference per class For libraries shared between applications, not possible to take advantage of repository selectors. It should be noted that if the SLF4J binding and the underlying API ships with each application (not shared between applications), then each application will still have its own logging environment. not IOC-friendly Advantages for declaring loggers as instance variables Disadvantages for d...

How to get directory size in linux ?

 du -sm <dir_name>

What is Liquibase ?

1.  Liquibase is an open source database-independent library for tracking, managing and applying database changes. 2. All changes to the database are stored in XML files and identified by a combination of an "id" and "author" tag as well as the name of the file itself. 3. A list of all applied changes is stored in each database which is consulted on all database updates to determine what new changes need to be applied. 4. Liquibase executes changes based on this XML file to handle different revisions of database structures and data. 5. When you first run a changelog, LiquiBase manages those changelogs by adding two tables into your database. databasechangelog : maintains the database changes that were run. databasechangeloglock : ensures that two machines don't attempt to modify the database at one time. 6. Limitations do exist such that it will not export triggers, stored procedures, functions and packages. Sample changeLog file:  The above is...

How to integrate Liquibase with Spring and Hibernate ?

Image
A sample tutorial on how to integrate Liquibase with Spring and Hibernate. While writing this tutorial, I have added javadoc in the code for better understanding and I believe You already have good knowledge on Spring and Hibernate. The main motto of this tutorial is to give an idea on how you can integrate Liquibase with Spring and Hibernate. If you are new to Liquibase : Click Here To integrate liquibase into your project, you need liquibase jars, So  download it before starting the project. I have created an application named "SHLIntegration". The Structure of the project is as follows : The dependencies are also listed here: Lets start with Employee class : 1. Create Employee class having getter/setter and add proper JPA annotation to each variable as below.   public class Employee {     @Id     @GeneratedValue     @Column(name="EMPLOYEE_ID")     private long id;     @Column...

Some ANT task

1. How to build  project from another build. <target name="project2"             description="Builds project2 project, required depedency">         <!-- Build project2 first  -->         <subant target="dist" verbose="yes" inheritall="false">             <filelist dir="../com.waheed.project2"                       files="build.xml" />         </subant>     </target>   2. How to read SVN revision and write into some file <loadfile property="revision" srcFile="./.svn/entries">         <filterchain>           ...

Spring MVC tutorial

Before Starting, I believe you must have basic idea about JAVA, SPRING and Spring MVC. For Spring MVC : http://waheedtechblog.blogspot.in/2012/08/spring-mvc.html In this tutorial , I will just tell you what are the basic thing that you need to start MVC. Step 1 : Create a class  @Controller public class HelloWorld {        @RequestMapping ( "/hello" )      public String helloWorld() {           return = "Hello World, Spring 3.0!" ;      } } 1 . The class HelloWorld  has the annotation @Controller and @RequestMapping("/hello") . When Spring scans this class, it will recognize this bean as being a Controller bean for processing requests. 2 .The @RequestMapping annotation tells Spring that this Controller should process all requests beginning with /hello in the URL path. Step 2. Mapping Spring MVC in WEB.xml The entry point of Spring 3...

Spring MVC

Image
Spring MVC helps in building flexible and loosely coupled web applications. The Model-view-controller design pattern helps in seperating the business logic, presentation logic and navigation logic. Models are responsible for encapsulating the application data. The Views render response to the user with the help of the model object . Controllers are responsible for receiving the request from the user and calling the back-end services. When a request is sent to the Spring MVC Framework the following sequence of events happen. The DispatcherServlet first receives the request. The DispatcherServlet consults the HandlerMapping and invokes the Controller associated with the request. The Controller process the request by calling the appropriate service methods and returns a ModeAndView object to the DispatcherServlet . The ModeAndView object contains the model data and the view name. ...