26 May

Java 8 default and static methods example

In this tutorial I am going to show how default and static methods can be included into Java 8 interface. Prior to Java 8 we did not have such mechanism to include default method or static method into interface but Java 8 provides such option to include those methods. Static methods are regarded as utility methods, not as essential, core methods. Whereas default methods are treated as common behaviors for all the client classes. Read More

13 May

@PreAuthorize annotation – hasPermission example in Spring Security

In this tutorial I will show you the most useful annotation is @PreAuthorize which decides whether a method can actually be invoked or not based on user’s role and permission. hasRole() method returns true if the current principal has the specified role and hasPermission() method returns true if the current user’s rola has the specific permission such as READ, WRITE, UPDATE or DELETE. By default if the supplied role does not start with ROLE_ will be added. This can be customized by modifying the defaultRolePrefix on DefaultWebSecurityExpressionHandler.

You can check my previous tutorial on hasRole @PreAuthorize annotation – hasRole example in Spring Security

Read More

11 May

@PreAuthorize annotation – hasRole example in Spring Security

In this tutorial I will show you the most useful annotation is @PreAuthorize which decides whether a method can actually be invoked or not based on user’s role. hasRole() method returns true if the current principal has the specified role. By default if the supplied role does not start with ROLE_ will be added. This can be customized by modifying the defaultRolePrefix on DefaultWebSecurityExpressionHandler.

You can check my tutorial on hasPermission @PreAuthorize annotation – hasPermission example in Spring Security

Read More

07 May

Custom Thread Pool in Java

In this tutorial I am going to show how to create custom thread pool in Java.

Multi-threaded and multi-process programming is a great way to optimize CPU usage and get things done quickly.

Creation of Threads in Java is a costly IO operation. Therefore it is not advisable to create & destroy thread(s) every often. It is recommended to use pool of threads as per the needs. Thread pool is a collection of threads, which are created to perform certain tasks.

Read More

03 May

Spring Service Layer Bean Validation

In my previous tutorial I have shown how to validate input data coming from client or end user to Spring REST Controller. Now in this tutorial I will show you how to validate data in Spring Service Layer.

Read More

Share