Alternating between Spray-servlet and Spray-can

On a server you may want to deploy your application as a war. How to build a war with spray-servlet. Locally it’s easiest to run without an application server. We include both the spray-servlet and spray-can dependencies: name := "sprayApiExample" version := "1.0" scalaVersion := "2.11.6" libraryDependencies ++= { val akkaV = "2.3.9" val sprayV = "1.3.3" Seq( "io.spray" %% ...

Read More »

5 Ways to Destroy Your Productivity

Hey you. Yeah, you. Want to know how to absolutely and utterly destroy your productivity? Good. You’ve come to the right place. Being productive is overrated. I mean really. What good does it get you? The more work you get done, the more work you get asked to do. So, here are a few quick tips that will help ensure ...

Read More »

Spring from the Trenches: Injecting Property Values Into Configuration Beans

spring-interview-questions-answers

Spring Framework has a good support for injecting property values found from properties files into bean or @Configuration classes. However, if we inject individual property values into these classes, we will face some problems. This blog post identifies these problems and describes how we can solve them. Let’s get started. If you use Spring Boot, you should use its typesafe ...

Read More »

Biological computer simulation of selfish genes

TL;DR: I did a computer simulation of behavior evolution of monkeys, continue reading to see how problem was stated originally in The Selfish Gene. First part shows my Java implementation, second part shows charted results and conclusions. The problem I read The Selfish Gene by Richard Dawkins recently, very wide-opening book despite being 40 years old. While the original text ...

Read More »

A way to read properties with variable interpolation

Recently, I tried to define and read a global properties in an application server. The benefit of such property configured in the application server – it can be shared across all web applications that are deployed on this server. Every deployed application can read the same property which is configured just once at one place. What I tried to do ...

Read More »

Timeout policies for EJBs : how do they help?

java-interview-questions-answers

EJB 3.1 introduced timeout related annotations as a part of its API. @AccessTimeout @StatefulTimeout Let’s quickly look at what they are and why are they important @AccessTimeout Specifies the time period after which a queued request (waiting for another thread to complete) times out. When your session bean instances are bombarded with concurrent requests, the EJB container ensures sanity by ...

Read More »

Creating a DSL for AWT’s Robot

The Java SDK ships with the class java.awt.Robot that allows the automation of keyboard and mouse input as well as the creation of screen captures. When you want to write a small test application that simulates user input or you just want to automate the input of some recurring text, this features comes in handy. But you do not want ...

Read More »

Caching of web content with Spring’s cache manager

spring-interview-questions-answers

I this post, I would like to show basics how to cache and manage the caching of web content with Spring’s CacheManager, @Cacheable and JMX annotations. Imagine a web shop which fetches some content, such as header, footer, teasers, main navigation, from a remote WCMS (Web Content Management System). The fetching may e.g. happen via a REST service. Some content ...

Read More »