Spring - Reading values from file and injecting to bean property using SPEL

Sometimes you would need to inject value for spring bean property by reading values from a file. Good use case for this would be injecting passwords into bean property by reading value from a file rather than hard coding password into application context xml.

This can be done by creating property file with values we want to inject and use spring util properties to read values into application context as properties. Then, this property value can be injected using Spring SpEL.

To demonstrate this, lets pick example of initializing Jetty SslContextFactory with keystore file and key store password.

Continue reading...

Turning Knowledge into Intelligence and Creativity

What is difference between Knowledge, Intelligence and Creativity?

Knowledge is facts, information, and skills acquired by a person through experience or education by perceiving, discovering or learning.

Intelligence is using that knowledge in different contexts to invent new thoughts, new ideas, etc.

Creativity is using intelligence to create new work, new inventions etc.

Why mere knowledge is not enough?

Our education system is mostly designed around providing and evaluating knowledge acquired and undermines intelligence and curiosity. if we just keep accumulating knowledge without applying, it will get lost. We need to make knowledge easily accessible to be able gain the intelligence out of it. Let’s think about how knowledge is stored in memory to find out how we can retain knowledge.

How knowledge is stored in memory?

The brain contains dynamic connection of neurons. Anything we retain in memory create new connections or change existing connections in the brain. The things we learn generally get stored in short-term working memory. But brain has only limited space in short-term memory. Most things get discarded out of short-term memory.

We mostly use repetition technique to make items in short-term memory stay long enough. But the biggest problem with memorization through repetition is that it frequetly puts the information on just one connection. The brain always seeks meaning, patterns with exiting information to make more connections. The more ways you have to find a piece of information, the easier it is to retrieve.

How to improve your intelligence?

Whatever you learn, associate it with a meaning, associate it with a different contexts, associate it with similar things - don’t learn anything in isolation. This will make it retain in long-term memory. Then knowledge will be easily retrievable when you want to apply it. This can help with generating new ideas.

How to improve your creativity?

Creativity is “just connecting things.” - Steve Jobs

Creativity is using imagination to connect, stretch and merge things in new ways. To improve creativity we need to further expand connections of information in our brain so that it can be easily combined, transformed to create new ideas. Curiosity can help expanding connections and is the essential element for becoming more creative.

Curiosity is a lens through which you view everything around you. Without it,there are no adventures to be had, With it, there are enough for a million times - **Sean Patrick , Awakening your inner genius **

Curiosity will persuade you to seek interesting things, discover new information, explore related things.


We acquire knowledge through learning and experiences. Whatever you learn, try to associate it with as many things you can. Always learn with curiosity to expand your knowledge, expand your ideas. You will able to create something new.

Further Reading

If you are reading this post with curiosity, you would be interested in further reading on this topic. Here are some useful resources.

Continue reading...

Turning adversity into opportunity

The book Happiness Advantage suggests the trick to turn adversity into opportunity is to realize that there always exists a path that leads us from failure or setback to a place where we are even stronger and more capable than before the fall.

Things do not necessarily happen for the best, but some people are able to make the best out of things that happen - Tal Ben-Shahar

Success is more about using that downward momentum to propel ourselves in the opposite direction. It’s about capitalizing on setbacks and adversity to become even happier, even more motivated, and even more successful.

Continue reading...

Improving Positive Attitude

I wrote about Happiness Advantage Book in my earlier post and the book suggests following exercise to improve your positive attitude.

The best way to kick-start this is to start making a daily list of the good things in your job, your career, and your life. It may sound hokey, or ridiculously simple— and indeed the activity itself is simple— but over a decade of empirical studies has proven the profound effect it has on the way our brains are wired. When you write down a list of “three good things” that happened that day, your brain will be forced to scan the last 24 hours for potential positives— things that brought small or large laughs, feelings of accomplishment at work, a strengthened connection with family, a glimmer of hope for the future. In just five minutes a day, this trains the brain to become more skilled at noticing and focusing on possibilities for personal and professional growth, and seizing opportunities to act on them.

The book also narrates very interesting experiment done on the luck factor by Richard Wiseman and what he found was

it turns out that there is no such thing—in a scientific sense, at least— as luck. The only difference (and it is a big one) is whether or not people think that they are lucky— in essence, whether they expect good or bad things to happen to them.

Continue reading...

Happiness Advantage Book by Shawn Achor

I recently read the book Happiness Advantage by Shawn Achor and it was excellent read. The fundamental idea that this book evangelizes is that happiness brings you success and not otherway around. Here is highlight from the book.

we have led to believe that happiness orbited around success. That if we work hard enough, we will be successful, and only if we are successful will we become happy. Success was thought to be the fixed point of the work universe, with happiness revolving around it. Now, thanks to breakthroughs in the burgeoning field of positive psychology, we are learning that the opposite is true. When we are happy—when our mindset and mood are positive—we are smarter, more motivated, and thus more successful. Happiness is the center, and success revolves around it

Here is the number of proven methods suggested in the book that can improve our moods and raise our levels of happiness.

  • Meditate: Take just five minutes each day to watch your breath go in and out.

  • Find Something to Look forward to: If you can’t take time for a enjoyable event right now, put something on the calendar. Then whenever you need a boost of happiness, remind yourself about it

  • Commit Concious Act of Kindness: Pick one a day of a week and make point of commiting five acts of kindness.

  • Infuse Positivity Into Your Surroundings: Make specific efforts to infuse positivity in your surroundings and also change your surroundings to keep negative emotions out.

  • Exercise: Walk, Bike , Run, Play or whatever you can do to keep you moving.

  • Spend money on experiences (but Not on Stuff): Spend your money experiences like vacation , dinner out etc., instead of things like television, shoes.

  • Exercise a Signature Strength: Everyone is good at something. A team of psychlogists recently catalogued the 24 cross-cultural signature strengths, you can take this survey to indentify your own signature strengths, then try to incorporate at least one of them into your life each day.

The book also provides practical, actionable principles that you can follow to increase your positive attitudes, happiness and become successful in your work and life.

Continue reading...