Search This Blog

Friday, 20 December 2013

Update Timestamps Cache in Action

We saw the query cache in our previous post. We know that UpdateTimestampsCache is only used for query caching. I decided to try and bring it into play in this post.

Tuesday, 10 December 2013

The Query Cache

In the previous posts we saw the Hibernate cache system and the Cache modes. We saw the query cache is disabled by default.

Thursday, 5 December 2013

Listening for Session creation

With Spring security session creation and destruction is managed by the framework. Along with the session management code, we often tend to have some other activities performed. For e.g. I would like a count of the sessions created. As the code is now within Spring how do we add our audit code ? In a simple application the solution would be to add a HttpSessionListener.

Tuesday, 3 December 2013

DelegatingFilterProxy And Spring Security

We saw an example of the GenericFilterBean earlier. While the class included some nifty techniques from Spring, it isn't really a part of the Spring Environment. We saw how to get access to the Spring Environment we had to

Wednesday, 27 November 2013

Spring Security And Authorization

In a Java Web application, where authorization is involved, roles come into the picture. If a request is authorized to access a particular resource, then only will the Servlet Container allow it to work with the resource. How is the authorization decision made ?

Friday, 22 November 2013

Remember Me... Spring Security

Login page in most web applications have a small check-box that says "Remember Me". Nothing new there. The cool part is spring security comes with this functionality ready made.
I decided to use the default login form to test the feature:

Sunday, 17 November 2013

The Identity Hash Map

If we work with Maps in java than the keys need to implement equals and hashcode - Right ? Actually Wrong.

Tuesday, 12 November 2013

Enums as the key in Map

In the previous post we saw how EnumSet is an optimized collection built for use with Enums. While I genuinely struggled to come up with scenarios where I could need a set of enums, I have often come across and used Enums as keys in my maps. Java has come up with an optimized collection for the above use case too - EnumMap.

Saturday, 9 November 2013

A Set of Enums

Why would I need a collection Of Enums? Consider that we do have a simple enum:
public enum Rating {
Now if I want to get all the values I would call the Rating.values method. This would give me an array of Enums. Any reason why I would want a set of the same ?

Tuesday, 5 November 2013

Components in JPA

We have used components in Hibernate. They provide a very good technique for code reuse. They are also useful if we do now want to represent a particular table as Entity and give them their own separate life cycle. JPA also provides support for components.

Friday, 1 November 2013

Repeating and Delaying Tasks

The ExecutorService Interface is not the end of Executors. The package provides another specialized interface ScheduledExecutorService which is capable of executing tasks after a certain delay, or repeating tasks at fixed intervals.
I decided to test the interface.

Thursday, 31 October 2013

And They All Work Together

In the previous post we had a look at the invokeAny method that allowed us to get the result from the first thread to complete. ExecutorService also provides us with the invokeAll method that will execute all the tasks given. Consider the below code:

Wednesday, 30 October 2013

Anybody just give me the result !!

I came across the invokeAny method of ExecutorService and liked the idea a lot. There could always be the case that you have a set of input of which you care to see any one processed. Once we have an output the remaining results don't matter.
Accordingly I decided to implement such a case with the invokeAny method of  ExecutorService.

Saturday, 26 October 2013

Understanding volatile

Before I start - I have never used volatile nor can I claim to well versed at it. To be more accurate my understanding of the java volatile keyword is zilch. Part of the reason is that I never used it. Did not use hence did not bother learning.
So to understand the concept I searched the net. I found articles where explanations where given. These articles were then followed by comments claiming that the explanation was wrong/incomplete. Some of the posts only managed to confuse me further.
So when I found something that made sense, I decided to jot it down...........

Tuesday, 22 October 2013

Interrupting a Thread

I was asked to do a revision in threads a while back - so as to then start understanding the concurrency package. I decided to do it from the Sun's Concurrency tutorial. I liked the part of sleeping and interrupting threads. Consider the simple program below:

Saturday, 19 October 2013

Logout Settings in Spring Security

We have seen how to configure login behavior for our application. How to let Spring manage authentication, session creation, authorization etc.The logical end to the flow would be to logout. A normal logout would involve releasing any resources, destroying sessions etc - and a logout page.

Thursday, 17 October 2013

form-login Custom Options

In the previous post we saw how to set the login page as a custom one. There are other configuration options available too. For instance:
<form-login login-page="/login.jsp" authentication-failure-url="loginError.jsp"/>
If now login fails, then user will be redirected to the above failure URL. Consider the logs generated when I entered invalid credentials:

Wednesday, 16 October 2013

Spring Security - The Login Flow

In the last post we saw how Spring security can be used to secure web applications. I used both the form login and the basic login to get the user authentication done.
While basic login is pretty much client system dependent, the form login can be tweaked and customized. I decided to try out the options.

Tuesday, 15 October 2013

Saving an Enum in JPA

Consider the below entity:
@Table(name = "STUDENT")
public class Student {
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 private Long id;

Monday, 7 October 2013

SOAP Action Header

How does a simple WSDL file look?
There will be a portType element that is like an interface definition of the web-service. It would tell us :

Saturday, 5 October 2013

SOAP Header at Client

In the previous post we saw CXF endpoints could set a soap header in the response. But what if the server needs to process a soap header ? The CXF website recommends using interceptors for reading headers. As I still do not have a very clear idea about the concept I decided to look for a different solution.

Friday, 4 October 2013

Headers in SOAP

What is a soap header ?
From w3schools:
The optional SOAP Header element contains application-specific information (like 
authentication, payment, etc) about the SOAP message. If the Header element is 
present, it must be the first child element of the Envelope element. All immediate 
child elements of the Header element must be namespace-qualified.
So the soap message would be something like :

Thursday, 26 September 2013

Method Injection in Spring

I knew Spring supports two types of injection - setter and constructor. I had also heard of a third type called method injection. But having never come across a use case for the same, I pretty much ignored it. Until I gave an interview.
All was going well until this question came along:
"You have a singleton bean. Is there a way to inject a new bean X into this class whenever you call the getX property of this bean ?"
I was pretty flummoxed. Later on I hunted on the web and came across this post by Rod Johnson.
The below post is an adaption from the same to focus on the interviewer's question.

Friday, 20 September 2013

The c namespace

With the growth of annotations XML configuration files continue to reduce in size (In some cases they have disappeared). I have never really been a fan of Annotations, especially those that bring in information that was best left outside Java code.

Monday, 16 September 2013

BeanFactory and Inheritance

Inheritance of Beans is a feature available in Spring Bean Factories. I decided to try the same using Spring's BeanFactory.

Saturday, 14 September 2013

Hibernate's custom annotations

In the previous few posts we saw how JPA provides us with an annotation driven approach to configure our entities. As with all standard APIs, when vendors implemented JPA, they found that the annotations did not cover every nifty trick provided by the implementations.

Monday, 9 September 2013

Saturday, 7 September 2013

Injecting Dependencies in a CXF Endpoint

We have seen how easy it is to create CXF endpoints. In the previous post on WSDL first web services we had defined server endpoints as:
<jaxws:endpoint id="randomWs"
   address="randomService" />
The "randomWs" endpoint is a CXF endpoint capable of processing SOAP requests, It is also a spring managed bean.

Tuesday, 3 September 2013

Exception Handling in Spring REST calls

I earlier did a post on error handling in Spring web applications. It was related to generating views for errors. But in a REST application we would prefer to return error codes or error JSON message. While the earlier style can be still used here to write out an appropriate JSON error response, Spring MVC provides other mechanisms to handle errors.

Saturday, 31 August 2013

CacheModes in Hibernate - continued

In the previous post we saw the GET and IGNORE values for CacheMode. The other values are PUT and REFRESH. Consider the below code:

Wednesday, 28 August 2013

CacheModes in Hibernate

Hibernate offers us a CacheMode option. This is something that allows us to control the behavior of the second level cache. Consider the below code:

Tuesday, 20 August 2013

Testing out the cache

In earlier posts we saw the settings needed for configuring Hibernate's second level cache and the various caches providers supported by Hibernate.
To test out the configurations for Eh Cache, I simply executed a main method to start and create a session factory.

Saturday, 17 August 2013

How to cache ?

In the previous post we saw how to setup the cache provider for Hibernate. But that is not the end of the story. We need to decide what kind of concurrency we need. Does our data ever change? Can we live with stale data? All these factors are decided by the concurrency strategy we use. Hibernate provides us with four built in concurrency strategies (as of version 3.0):

Friday, 16 August 2013

Hibernate Cache Framework

The Hibernate framework comes with a complete caching system. This cache system is used to reduce the amount of SQL queries fired in the system.
The Hibernate cache is built at two levels - a first level or session cache which we saw earlier and the second level cache. While the first level cache is non optional, the second level cache needs to be configured and switched on for use.

Wednesday, 14 August 2013

Accesing System Properties in Java

In an earlier post we saw The ExceptionUtils class provided by the Commons Lang library. The library also provides us with a SystemUtils class - it provides us with information about the JVM in use and the underlying platform. Consider the below code:

Sunday, 11 August 2013

Spring Security

All projects I have worked on included login. And roles. They were built using database tables or third party applications like LDAP or service based authentication. However the new projects starting now are going ahead with Spring Security. As I have no idea about it, I decided to give a go at understanding Spring Security.
I decided to first do a small simple web application and enable the security for it. Not spring based, simple Servlet style security.

Friday, 9 August 2013

Custom Marshaling With JAXB

Consider the below class:
public class Person {
   private String name;
   private BigDecimal weight;
   private Date dob;

   // getters and setter
If we were to marshal a Person instance the generated XML would be:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
The value for dob is a little complex. Could we change this to a more suitable value ?

Tuesday, 6 August 2013

DataBinding Options with CXF

When using CXF, the marshaling and unmarshaling of data happens under the covers. So when we make the call through java, the request is marshaled to XML by CXF client. It sends it over the wire to the server.

Monday, 5 August 2013

Excluding a property from the ORM framework

If we have a property that does not map to any column in the table, we simply do not specify that property in our hbm files. But with JPA annotations it is a little different. A class if marked with an Entity annotation, all its properties are considered persistent by default. So how do we exclude a property ?

Thursday, 1 August 2013

Can we mark entity classes as final ?

We have already seen that Hibernate extensively uses proxies. It uses proxies when we call load, it uses proxies for lazily loading associations and collections.But what if our entity class was final ?

Tuesday, 30 July 2013

Order and Occurence indicators in xsd

Unlike simple types, complex types can have nested elements. Consider the below complex type:
<element name="address">

Sunday, 28 July 2013

Table names - does the case matter ?

In one of my previous projects I encountered a strange issue. The SQL queries that worked in our development code always failed on the server. The logs indicated that the queried tables did not exist.
This did not make any sense to us. The code ran perfectly on local MySQL database installed on our developer machines. But the minute we did it on the server we got table does not exist error. After a lot of digging we discovered that there was no problem in the code. Our table name in the ddl queries was in lower case but in our code it was in title case. But why did it work on Windows then. Some searching on the net explained the actual cause of the issue.
From the MySql docs:
In MySQL, databases correspond to directories within the data directory. Each table within a database corresponds to at least one file within the database directory (and possibly more, depending on the storage engine). Consequently, the case sensitivity of the underlying operating system plays a part in the case sensitivity of database and table names. This means database and table names are not case sensitive in Windows, and case sensitive in most varieties of Unix
Our development machines were using Windows operating systems. In Windows you cannot have two files in same directory with same names but different cases. So the case difference did not cause any problems on Windows. MySql was able to find the table correctly on the file system and all things worked fine. But our test server was a linux environment. The table in the SQL query was not same as the table in the database. Result - requested table not found.
Our solution was to create constants in the code to hold our table names in small case and to ensure that all references in our queries used these values only.
An alternative action to doing drop/rename is also available in MySql docs.
How table and database names are stored on disk and used in MySQL is affected by the value of lower_case_table_names. Changing this value on linux can make MySQL use Windows style treatment for the tables.

Friday, 26 July 2013

Filters and Spring

I guess we have all used filters in our web applications. With the arrival of spring and its very solid front controller, code that was in filters is most of the time placed in Spring interceptors. But that does not mean that we cannot add a filter.

Monday, 22 July 2013

Stacks in JDK

In the previous post we saw the various queue implementations available in Java. Today I decided to check out stacks:
public static void main(final String[] args) {

Wednesday, 17 July 2013

Conduits in CXF

If we observe any page request sent by a browser, it will be seen to be composed of multiple headers. Consider the below screenshot taken for a simple AJAX request.

Thursday, 11 July 2013

Combine CREATE and UPDATE operations in REST

I was searching the net on good practices for developing RestFull services when I came across this interesting discussion on stack overflow:
The question was "Should we use PUT or POST for Create Resource ?"

Monday, 8 July 2013

POST with a location

IN the last few posts I have been trying out Springs REST API. For the create operation we had used a POST call. The API would take an user resource, create it and return the user resource in the response stream.

Saturday, 6 July 2013


In the previous post we saw several of the JPA annotations. The one that occurs most commonly is the Column annotation can be used without any attributes.

Sunday, 30 June 2013


One of the most commonly used features in Java is Exceptions. I have always used it- throwing, catching and sometimes crashing code with them. I recently had a requirement where I needed to convert a stack trace to a String.

Friday, 28 June 2013

Result Transformers

In the previous post we saw the need for ResultTransformer, how using the value of Criteria.DISTINCT_ROOT_ENTITY filters duplicate records.

Monday, 24 June 2013

Inheritance in xsd

In the last post we were able to map elements which included attributes. An alternative way of representing elements is to nest them. Consider the below schema definition:

Wednesday, 19 June 2013

Why the need for ResultTransformers ?

Consider the below criteria example which simply loads the Entity records from the database with ids less than 6.

Monday, 17 June 2013

JPA's GenerationType.TABLE

In the previous posts we saw the identifier generation strategies supported by JPA and their equivalent ones in Hibernate. There is however one in JPA - The TABLE GenerationType that is not there in Hibernate API. I decided to look at the same.

Saturday, 15 June 2013

Using Spring's RestTemplate class

In an earlier post we saw how to work create REST services using Spring. For testing the same we used a RESTClient Plugin available with Firefox.
It is often the case that we need our test code to be in Java so that it can be reused by others too. Spring provides us with an easy to use Rest Service client that can be used in our code.

Monday, 10 June 2013


In our previous posts we saw how the GeneratedValue annotation was used to specify the identifier generator strategy. I decided to look at the various options available in detail

Thursday, 6 June 2013

Interceptors and Logging

The CXF architecture provides us with interceptors – or the ability to intercept outgoing request and responses. One useful scenario could be logging. CXF in this case has stayed one step ahead and already built custom Log Interceptors.

Tuesday, 4 June 2013

A LIFO Queue - like a Stack

The last of the queues is a LIFO queue. This queue behaves like a stack. It follows LIFO ordering.
public static void main(final String[] args) {

      final Deque<Integer> deQ = new ArrayDeque<Integer>();
      final Queue<Integer> asLifoQ = Collections.asLifoQueue(deQ);
      System.out.println("LifoQueue Contents : " + asLifoQ);
      // should behave like a stack
There is no direct way to create the same. We need to use the asLifoQueue method of Collections class to create a LIFO queue. Further this method requires an instance of Deque to be available . It will not work with any queue. The output is :
LifoQueue Contents : [6, 5, 4]
Be sure to pass and empty Deque as the parameter. Any elements already present in the deque are not treated in the LIFO order.

Sunday, 2 June 2013

Queues in Java

I first came across queues in Engineering. The very first chapter in data structures involved stacks and queues. So when I needed to implement one in my java project, I started recollecting the queue's working, recalling important points.I decided to build a generic structure and spend half a day coming up with a Queue interface based in generics. For good practice I decide to check the web and that is when it bombed.

Tuesday, 28 May 2013

Rest Example with Spring - 2

Continuing from the previous post, I decided to take up the next method
@RequestMapping(value = "{id}", method = RequestMethod.GET)
public @ResponseBody

Monday, 27 May 2013

Rest Example with Spring.

Over the last one year I have worked on three projects involving REST based services. I found REST pretty cool as a concept - also the fact that unlike SOAP I did not have to learn any new terminologies. instead I needed to model my existing understanding of HTTP to build services.

Thursday, 16 May 2013

More on Complex Types

In the last post we were able to map complex xml elements to classes. However it is recommended to build complex types and associate them to elements.

Wednesday, 15 May 2013

JAXB and Complex types

In the previous post we saw how JAXB generated JAXBElement instances from simple types. Simple types however are just that - simple (!!!)
We often need our elements to allows attributes, include child elements etc. These cannot be achieved using simple types. We need to create complex types for the same.

Monday, 13 May 2013

JAXB and simple elements

In the past few weeks I have been working with web-services. So exposure to xml and xsd was inevitable. I had used xsd a while back and so I needed a revision of some of those topics. I decided to do a quick summary of some of the options available in xsd and how JAXB works with them

Friday, 10 May 2013

instanceof operator and equals method

I always based my equals implementation on the code written in the String class.

Tuesday, 7 May 2013

Contract First web service with CXF

In the post on Spring web services, I had used a contract first approach for development. This being the only style supported by Spring.
JAX-WS and also CXF on the other hand support both code first and contact first approaches.
I decided to use the same wsdl file from my Spring post:

Saturday, 4 May 2013

Building Clients with the CXF API

In the previous posts we saw how to run a CXF application and test the web services using a JAX-WS client. While our previous client was built using classes from the JAX-WS API, there are other ways to execute the code too.

Thursday, 2 May 2013

Simple Annotated Entity

In an earlier post when working with Hibernate I tried to generate an hbm with minimal content. I decided to try something similar with JPA. The minimum annotations needed to work with a simple table.

Wednesday, 1 May 2013

Monday, 29 April 2013


Hibernate provides us with the option to fire explicit SQL queries. But with the presence of HQL and Criteria why would one want to do that ?

Thursday, 25 April 2013

Getting the total records while using pagination

We often have grids in our application where we need to show the results as pages. There is also often a row of text making the claim " Record  1 to 30 of 100". While the bounds of the result can be obtained easily as we know the limits to apply, it is getting the total record count that is interesting.

Tuesday, 16 April 2013

Select in Criteria using SQL

In an earlier post we saw how Criteria provided us with the ability to add restrictions in the where clause using pure SQL. The next question would then be if Criteria allows SQL in select clause ?

Saturday, 13 April 2013

Friday, 12 April 2013

The first CXF Service

In the previous post we saw how JAX-WS 's RI implementation could be used to build and interact with web services. I decided to work with one of the other implementations - Apache CXF. I decided to create and run a code first webservice using CXF implementation.

Tuesday, 9 April 2013

Criteria and Aggregation

We saw aggregate functions with HQL. Criteria too has methods that provide for using aggregate functions. Consider the below code that simply fetches the count of all rows.

Saturday, 6 April 2013

Setting schema information

In all my posts on JPA I have used a PostgreSQL database. The database is composed of multiple schemas (Unlike PostgreSQL, MySQL database supports only a single schema). So we need to specify to our application the schema being used. I did that by setting the schema attribute of the Table annotation.

Thursday, 4 April 2013

Learning web services

In the various programming environments supported by Java, I have found web-services to be the most difficult to penetrate (That and JNDI) . The thing is there are several web-service providers in the Java community. They all make various claims, add to already vague terminology and almost always leave a novice reader confused.
So when I got a chance to implement web services using Spring's web service framework, I was pleasantly surprised with the well explained Spring docs. And while learning some cool stuff, I also realized that Spring web services is quite different from some of the other implementations.
So when I got the chance today, I decided  to do some investigation on few of these frameworks. I have earlier blogged on how Spring allows us to expose our application as a web service
Spring's web service implementation is not related to JAX-WS. Spring's implementation as we saw, only supports contract first development. There are several advantages to the same. In the words of Spring web services creator Arjen Poutsma

Wednesday, 3 April 2013


In previous posts we have seen how to use the Criteria interface. We have also been using the setProjection method when needed to select properties or objects from the executed query.

Sunday, 24 March 2013

First Look at JPA Annotations

In the earlier posts we saw how to run a JPA application. I decided to have a look at the annotations used in the previous examples.

Tuesday, 19 March 2013


In previous post we have seen the persistence.xml file - the file provides all the configuration information needed to get JPA up and running. We also saw that the JPA standard is very particular of the location of the file.

Sunday, 17 March 2013

Working with the Iterator

Before I start let me state that I am still to come across a valid scenario in actual application code where I could find this functionality useful.

Thursday, 14 March 2013

My First JPA Application - 3

In the last two posts we setup the code to run a simple JPA example. In this post I shall now test out the code. The code to execute is as below:

Wednesday, 13 March 2013

My First JPA Application - 2

In the previous post I created  the project structure for my JPA application. Now to look deeper into the code. I decided to build a simple Pet-Owner relation. One owner can have multiple pets. The java classes for the same is as below:

Tuesday, 12 March 2013

My First JPA Application

Till date I have always worked with Hibernate's native API. All my projects involved the SessionFactory, Session and other Hibernate APIs. And it works great. So why should I be looking at JPA ?

Saturday, 9 March 2013

Accessing the Request object outside Controllers

We have seen that when working with controllers, Spring automatically gives us access to the HttpServletRequest object. But what if we are in some utility class and would like to access the request ? For this Spring includes the ServletRequestAttributes class.

Thursday, 7 March 2013


Deploying a web application in Tomcat involves placing the war file or the extracted folder in Tomcat's webapps folder. I created a very basic web application named simple and placed it in the webapps folder.

Saturday, 2 March 2013

new ArrayList(????)

Writing code without using collections framework would be crazy. They are really cool part of java with a lot of nifty stuff. More importantly unlike arrays you do not have to worry about size management here. The ArrayList will grow as long as  memory is there. No need for the developer to worry about initial size and ArrayIndexOutOfBoundsException.
But what when we are actually asked to watch out our memory footprint ? Can we be memory efficient when we are using Collections ?

Thursday, 21 February 2013

Criteria and Inner joins

Few posts ago we saw HQL's extensive support for joins. I decided to check out Criteria's claims to the same. I decided to start out with Inner joins.

Wednesday, 20 February 2013

Scheduling with Annotations

In my previous post we saw how to achieve scheduling using Quartz API and Spring. The thing about Quartz is that it adds an additional dependency in your project.If you have a simple project and do not need Quartz's heavy power, you can use Spring's own scheduling mechanism. I modified our previous example to use it.

Thursday, 14 February 2013

SQL inside Criteria

We earlier how a custom criterion could be created to handle special scenarios. However this may seem overkill if the condition can be easily expressed using native SQL. For Criteria allows us to add custom SQL expressions which get added in the where clause.

Saturday, 9 February 2013

Working with Quartz and Spring

In an earlier post we saw how Spring allows us to get scheduling done using Java's Timer Implementation. The timer schedulers has one shortcoming- There is no way to specify the time of the day when the task is to be run.An alternative and more powerful scheduler is the Quartz Scheduler.

Monday, 4 February 2013

Scheduling via Spring

Spring provides support for scheduling activities. One way to do it is using java's Timer class. I created a simple program to display random messages.

Tuesday, 29 January 2013

ServletContext and ServletConfig

With Spring MVC we have the Front Controller pattern at work. So there is the one Servlet - Spring's own DispatcherServlet which receives the requests and forwards them to the controllers in the code.
But what if you wanted to access the ServletContext ? Or (in some rare case) the Servlet Config ?
Could you get them in your controller?

Friday, 25 January 2013

Restrictions AND OR

I need to execute a query to fetch all entities with id is greater than 5 and the names start with "ent". That means there are two distinct conditions. Doing that using HQL would be pretty straightforward:

Monday, 21 January 2013

Applying Restrictions

In the previous post we saw how a Criterion was actually translated into an SQL query. In this post we shall use the different restrictions available. I started with the simple ones involving the equality operator.

Thursday, 17 January 2013

Creating a new Criterion

We have seen Hibernate's set of Restrictions and they cover a very large range of queries. However Hibernate also allows the creation of a custom Criterion that can be used in the criteria.

Sunday, 13 January 2013

Applying Restrictions - continued

In the last post we saw restrictions associated with equality and comparison.We can even use a single criterion instance to apply multiple equality conditions.

Wednesday, 9 January 2013

FactoryBean Interface in Spring

In our post on Velocity integration in Spring we saw an example of a FactoryBean. If we look at the configuration for velocity:

Sunday, 6 January 2013

Processing Template Text in Spring

In our previous post we saw Spring's ability to allow us to send mails. With mails comes up the requirement for mail templates. We want to dynamically generate our content using some template generation framework.
I decided to integrate Velocity via Spring for this purpose.

Wednesday, 2 January 2013

Emailing - the Spring way

I am yet to work in a project that did not involve any mail related functionality. Send notification mails to admin, send alerts to users, send password mails... the use cases for mails go on.
Spring has provided a utility class that wraps around the the javax.Mail library.
So we do not need to acquire any mail Sessions, create javax.mail.Transport objects or attempt to connect with the mail server.We simply get the wrapper class and call send.