Posts

Showing posts from October, 2014

Featured Post

why POJO in JAVA

Normally we write classes with private variables and expose getters and setters to those variables which we think right approach . this is called as encapsulation in java . to protect our class properties we define those variables as private and expose public methods to modify properties . but there encapsulation not providing any security as such .      take a look at below class which has public members and we can change those members directly without using methods . even child class can access those variables modify directly .     public class Employee {       public String firstName;      public String lastName;   } but here only the problem is we can't test these classes and also latest frameworks like spring ,struts developed on POJO definition , hence if you don't expose methods difficult to use these type of classes .           Drawbacks     ...

Spring Transaction Management

Spring Declarative Txn Management current transaction propagation points as mentioned below S.N. Propagation & Description 1 TransactionDefinition.PROPAGATION_MANDATORY Support a current transaction; throw an exception if no current transaction exists. 2 TransactionDefinition.PROPAGATION_NESTED  Execute within a nested transaction if a current transaction exists. 3 TransactionDefinition.PROPAGATION_NEVER  Do not support a current transaction; throw an exception if a current transaction exists. 4 TransactionDefinition.PROPAGATION_NOT_SUPPORTED  Do not support a current transaction; rather always execute non-transactionally. 5 TransactionDefinition.PROPAGATION_REQUIRED   Support a current transaction; create a new one if none exists. 6 TransactionDefinition.PROPAGATION_REQUIRES_NEW   Create a new transaction, suspending the current transaction if one exists. 7 TransactionDefinition.PROPAGATION_SUPPORTS   Support a current transacti...

Struts 1 vs Struts 2

Friends,            you might be wondering why struts 2 framework came into picture , there are few reasons which I would like to explain . Anyways I have given well formatted table with differences below .     Struts 1 Actions are classes and Singletons , so there will be one object which handles the request hence this is bit trade off and prone to bugs . we need to make sure that our resources in presentation layer which calls DAO layer should be protected i.e should be thread safe .       Anyways looks at below tabular form which explains clearly about the differences       Struts 1 vs Struts 2 Feature  Struts 1  Struts 2  Action classes  Struts 1 requires Action classes to extend an abstract base class. A common problem in Struts 1 is programming to abstract classes instead of interfaces.  An Struts 2 Action  may  implement an  Action  interfac...