Monthly Archives: March 2014

REST API Documentation with Swagger

This is going to focus REST API documentation with Swagger. We know that REST APIs are very popular with modern world technology and most of the technology solutions came up with REST Implementations. Developers who are involved with the REST APIs development and they have kind of problem like how to document the REST APIs and how to simply expose those REST APIs to the end users. Swagger is good solution for above explained problem. So lets talk about swagger integration to the JAX-RS API. I think that you are familiar with the JAVA JAX-RS implementations. If not you have to get some knowledge about JAX-RS implementation.

1. You have to add swagger maven artifact to your project.

2. Secondly you have to mentioned the base path on your web.xml. This URL will be used as backend service call from swagger-ui

3. Finally you have to annotate your REST-APIs by swagger annotations. You can get total idea from following code snippets.

4. Then you have to get the swagger-ui and host it on your local tomcat.

5. Now you can simply view and invoke the REST APIs which is developed by you by using the Swagger UI.




Posted by on March 25, 2014 in java


Tags: , , ,

Pagination with Java Hibernate Criteria

Hibernate is most popular technology in Java development. Most of the real world application they used kind of hibernate technology with fine tuned mechanisms. If you are in java development I hope the following code snippet will be helpful you to make your application faster.

What I’m going to explain in this post is how to load the chunk of data with efficient manner.
Hibernate Criteria helps to do this as we wish. Think about if you have millions of data in your data table and you are going to display the data in your application. Check the following code snippet

You can see in the above example I have used two numbers to query the data from back end. The pageNumber means which page that your are in and the recordesPerPage will use to filter the max record count going to be query. Then the each time fetch the data from database by given range.

This will really make the performance gain rather than loading whole chunk of data.


Posted by on March 13, 2014 in java, mysql


Tags: , , ,

How to create simple maven repository on GitHub

Most of the people who are developing simple important projects in java have the following problem.
The problem is how to expose their java libraries as maven artifact.

This is a simple and easy solution for the above matter.

You can easily create the Git repository on GitHub and do the following steps.

First of all tell maven to deploy artifacts to a temporary staging location inside your target directory. Add this to your project pom.xml

        <name>Temporary Staging Repository</name>


Run mvn clean deploy. You’ll see maven artifact is deployed your maven repository located in target/mvn-repo.

Secondly we have to upload the created artifact to github. In order to do that add your authentication information to ~/.m2/settings.xml so then the github site-maven-plugin can push to github


Please make sure this file has proper security because some one can take your credentials.Then the next step is give the server details to your project by referring the server id created above.

Go to your project pom file and place the following property

    <!-- github server corresponds to entry in ~/.m2/settings.xml -->

The last step is going to upload your locally created artifacts in to the github. In my point of view you better create new branch on your project as mvn-repo and place the following configuration on your project.

              <!-- git commit message -->
              <message>Maven artifacts for ${project.version}</message>
              <!-- disable webpage processing -->
              <!-- matches distribution management repository url above -->
              <!-- remote branch name -->
              <!-- If you remove this then the old artifact will be removed and new 
               one will replace. But with the merge tag you can just release by changing 
                                                the version -->
                <!-- github repo name -->
                <!-- github username -->

Run mvn clean deploy again. You should see maven-deploy-plugin create the files to your local staging repository in the target directory, then site-maven-plugin committing those files and pushing them to the server. Now the artifact is available to public use.

When you need to use your uploaded artifact you have to do the following step. You need to add your repository as follows


Now you can refer your maven artifacts easily. I hope now you can expose your simple artifacts as you wish.


Posted by on March 10, 2014 in java


Tags: ,

%d bloggers like this: