Pages Navigation Menu

Coding is much easier than you think

RECENT POSTS

Difference between Struts2 FilterDispatcher and StrutsPrepareAndExecuteFilter?

Posted by in Struts-2

Difference between Struts2 FilterDispatcher and StrutsPrepareAndExecuteFilter?

  The FilterDispatcher is used in the early Struts2 development, and it has deprecated since Struts 2.1.3.   ** UPDATE: Struts 2 Complete tutorial now available here.   If you are using Struts version >= 2.1.3, it’s recommended to upgrade the new filter class StrutsPrepareAndExecuteFilter   The new filter was introduced for the following reasons There were a lot of issued with the FilterDispatcher and its deployment. New Filter provides a better way to enable customizations and overrides. Make it crystal clear to...

read more

Aspect Oriented Programming(AOP)

Posted by in Spring

Aspect Oriented Programming(AOP)

  AOP is one of the main features available in spring that facilitate Cross-cutting of concerns. AOP is another way of organizing the program structure, that complements the OOP. The modularity is implemented in OOP using class, whereas in AOP aspect takes up the job. Aspects enable the modularization of concerns such as transaction management that cut across multiple types and objects. Spring IOC container does not depend upon AOP. That is, using of AOP is totally up to the requirements at hand.     AOP...

read more

Dependency Injection(DI)

Posted by in Spring

Dependency Injection(DI)

  One of the most striking features of Spring, is the way loose coupling between the components has been achieved. The modules are made independent by keeping them abstract. The values / dependencies are injected to them through the underlying Spring framework’s IOC container. Three types of dependency Injection are available. 1. Setter injection 2. Constructor injection 3. Interface injection The value can be set using either constructor injection or setter injection.   Note : Interface injection is not mainly supported...

read more

Spring AOP – Around Advice

Posted by in Spring

Spring AOP – Around Advice

  Download It Spring AOP –...

read more

Spring AOP – AfterThrows Advice

Posted by in Spring

Spring AOP – AfterThrows Advice

  Download It Spring AOP – AfterThrowsAdvice   Requirement : In case a particular method call throws an exception, a log needs to be printed.   ** UPDATE: Spring Complete tutorial now available here.   Step 1 : Changes in IteratorImpl class to mock an exception being thrown. No change in IteratorImpl interface   File : Iterator.java   package com.simpleCodeStuffs.aop; public interface Iterator { void goPrevious(); void goNext(); }   File : ...

read more

Bean Method invocation using spEL

Posted by in Spring

Bean Method invocation using spEL

  Download It Bean Method invocation using spEL   Step 1 : Create the POJO   File : Customer.java   package com.simpleCodeStuffs.spEL; public class Customer { private String name; private double bill; public String getName() { return name; } public void setName(String name) { this.name = name; } public double getBill() { return bill; } public void setBill(double bill) { this.bill = bill; } }   File : Amount.java   package...

read more

Basic example of Spring AOP Concept using BeforeAdvice

Posted by in Spring

Basic example of Spring AOP Concept using BeforeAdvice

  Download It€“ Simple example for AOP concept -BeforeAdvice   Take an example wherein there exists an interface ‘Iterator’™. It is implemented by a class ‘IteratorImpl’€™(which obviously, overrides the methods of ‘€˜Iterator’€™, in this case goNext() ). Consider a scenario wherein this set up is part of a very large code. Now, I get a requirement to insert a logging step into this code. This can be done using AOP with no impact at all on the existing...

read more

Operators in spEL

Posted by in Spring

Operators in spEL

  Download It Operators in spEL   The various operators that are most frequently used in this context are :- Relational operators equal (==) not equal (!=) less than (<) less than or equal (<=) greater than (>) greater than or equal (>=) Logical operators And(&&) Or(||) not (!). Mathematical operators addition (+) Subtraction (-) Multiplication (*) division (/) modulus (%) exponential power (^). Ternary operator if-then-else...

read more

What is the use of the finally block? Is finally block in Java guaranteed to be called? When finally block is NOT called?

Posted by in Java

What is the use of the finally block? Is finally block in Java guaranteed to be called? When finally block is NOT called?

  Finally is the block of code that executes always. The code in finally block will execute even if an exception is occurred. Finally block is NOT called in following conditions If the JVM exits while the try or catch code is being executed, then the finally block may not execute. This may happen due to System.exit() call. if the thread executing the try or catch code is interrupted or killed, the finally block may not execute even though the application as a whole continues. If a exception is thrown in finally block and not handled then...

read more