Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!

1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

and many more ....

 

Android TextView with custom fonts

android-logo

While developing an android app I found that everytime I was trying to use a custom font on a TextView I copied the same lines:                   TextView textview = (TextView) findViewById(R.id.text); textview.setTypeface(...) Obviously, that’s unnecessary and repetitive. Why not just create a custom view? And more, why not adding the font through ...

Read More »

Probability distribution for programmers

scala-logo

This is one of these very simple programming puzzles I came across recently: given a function returning random integers from 0 to 4 inclusive with equal probability, write a function returning random integers from 0 to 6 inclusive. Of course the solution should also return equally distributed numbers. So let’s start from an input function sample definition:       ...

Read More »

OAuth 2.0 Bearer Token Profile Vs MAC Token Profile

oauth-logo

Almost all the implementation I see today are based on OAuth 2.0 Bearer Token Profile. Of course its an RFC proposed standard today. OAuth 2.0 Bearer Token profile brings a simplified scheme for authentication. This specification describes how to use bearer tokens in HTTP requests to access OAuth 2.0 protected resources. Any party in possession of a bearer token (a ...

Read More »

Fluent Object Creation

java-logo

Many posts have been written on this subject (overwhelmingly many) but I just wanted to contribute my two-cents and write a short post about how I use the Fluent Object Creation pattern or object builders in Java to instantiate Value Objects. Value Objects are abstractions that are defined by their state (value) rather than their address in memory. Examples of ...

Read More »

Apache Camel Cheatsheet

apache-camel-logo

                      Polling an empty directory (and send an empty message with null body) : from('file://temp?sendEmptyMessageWhenIdle=true') Stop a route : .process(new Processor() { public void process(Exchange exchange) throws Exception { getContext().stopRoute('ROUTE_ID'); } }) Access a property of the object in the body : admitting the object has a method named ‘getMydata()’ ...

Read More »

Caveats With MySQL Pagination

mysql-logo

We’ve all done pagination – it’s sensible for both lists in the UI and for processing data in batches. “SELECT (columns) FROM table LIMIT X, Y”. Possibly “SELECT (columns) FROM table ORDER BY some_column LIMIT X, Y”. What’s the caveat? Especially when working with an ORM and when processing batches, where order doesn’t matter, you are likely to omit the ...

Read More »

How to shoot yourself in foot with ThreadLocals

java-logo

It will start nicely. Like most of the stories. You discover a new concept and are amazed by it’s powers. And then equipped with this new hammer suddenly everything starts to look like a nail. From what we have experienced in past months, java.lang.ThreadLocal makes one hell of a hammer. I guess it all boils down to the very concept ...

Read More »

Going REST: embedding Jetty with Spring and JAX-RS (Apache CXF)

codehaus-jetty-logo

For hardcore server-side Java developer the only way to ‘speak’ out to the world is by using APIs. Today’s post is all about JAX-RS: writing and exposing RESTful services using Java. But we won’t do that using a traditional, heavyweight approach involving application server, WAR packaging and whatnot. Instead, we will use awesome Apache CXF framework and as always rely ...

Read More »

Mixin in Java with Aspects – for a Scala traits sample

java-interview-questions-answers

Scala traits allow new behaviors to be mixed into a class. Consider two traits to add auditing and version related fields to JPA entities:                   package mvcsample.domain import javax.persistence.Version import scala.reflect.BeanProperty import java.util.Date trait Versionable { @Version @BeanProperty var version: Int = _ } trait Auditable { @BeanProperty var createdAt: Date = ...

Read More »

MySql connections autodrop after a certain hours

mysql-logo

MySql is configured to drop any connection which has been Idle for more than 8 hours. What is the implication of this? After you return to your deployed app after a gap of 8 hours (If default SQL parameters have not been changed), you will be greeted with an exception. How to solve this issue? Increase the wait_time parameter -Not ...

Read More »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close