Quantcast
Channel: Learning the code way
Browsing all 231 articles
Browse latest View live

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...

View Article


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...

View Article


A Set of Enums

Why would I need a collection Of Enums? Consider that we do have a simple enum: public enum Rating { TOP, GOOD, PASSABLE, BAD, POOR, FAIL}Now if I want to get all the values I would call the...

View Article

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...

View Article

The Identity Hash Map

If we work with Maps in java than the keys need to implement equals and hashcode - Right ? Actually Wrong.The reason we need hashcode is all Map implementations that we know of are hash based...

View Article


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...

View Article

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...

View Article

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...

View Article


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...

View Article


Image may be NSFW.
Clik here to view.

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.The first step to getting the Query cache working is in the configuration...

View Article

Update Timestamps Cache in Action

We saw the query cache in our previous post. We also learned about the UpdateTimestampsCache and its impact on query caching. I decided to try and bring it into play in this post.publicstatic void...

View Article

Image may be NSFW.
Clik here to view.

Writing Logs to the Database

With loggers we have something called as an Appender. Simply defined an appender is a component responsible  for taking a log request, building the log message in a suitable format and sending it to...

View Article

Handlers and Interceptors in CXF - Are they related ?

I have been trying out some things in CXF (and also feeling pretty good about it :P ) The other day I needed to modify the message of more than one web service in a common manner. I achieved the same...

View Article


Which Log message belongs to which user ?

I created a very simple web application. In it any calls to URLs ending in ".do" reach the below servlet : publicclass SimpleServlet extends HttpServlet {privatestaticfinal Logger logger =...

View Article

Mapping a Filter directly to a Servlet

I guess we have all used filters in our web projects. The common approach that I have followed is specifying the URL patterns to be intercepted by the...

View Article


Semaphores in Java

What exactly is a semaphore ? To use the wiki definition: In computer science, particularly in operating systems, a semaphore is a variable or abstract data type that is used for controlling access, by...

View Article

Views in ModelAndView

We had an interesting scenario in our code. It all started out when we had this complex controller that included methods specific to a certain flow. In case of any exception, we used an error handler...

View Article


Weak References in Java

I have been looking at the java.lang.ref package with a view to understanding references in java. It all started when I tried to understand WeakHashMap and its use in string pools. The various related...

View Article

Soft References in Java

In the last post I looked at using weak references in my java code. As we saw Java has not just strong and weak but also soft and phantom references.Firstly, what are soft references ?I modified my...

View Article

Reference Queues

In the previous posts we had a look at weak and soft references. The java.lang.ref package also includes a class ReferenceQueue. As per the class documentation: Reference queues, to which registered...

View Article
Browsing all 231 articles
Browse latest View live