In this library I tried to find a minimal abstraction for the standard Java JDBC framework. Overwhelmed by the complexity of the existing OR-mapping frameworks, I was searching for a library, which doesn’t try to hide SQL from the developer. But still gives you enough support by handling the tedious parts of JDBC. With a background in the Scala/Play development, I’d enjoyed using the Scala Anorm library. Unfortunately I couldn’t find a similar library for Java. So, I decided to implement one myself.
How to do dependency injection in Java with static injection methods.
In a previous post I described how the Jenetics library uses the static
RandomRegistry for injecting
Random engines into the library code. In this post I will describe the details of the injection implementation.
RandomRegistry of the Jenetics library delegates the functionality to the
Context class, which contains the actual implementation.
Context class is responsible for storing the object which is injected and the
RandomRegistry defines the static scope for the injection of the
Random object. It is not required to have only one…
Random engines into the Jenetics library.
When I was implementing the Genetic Algorithm (GA) and Genetic Programming (GP) library, Jenetics, it was clear that I needed a way to change the PRNG implementation the GA was using during the evolution process. Unfortunately, there are a lot of possible methods for injecting the
Random engine into the objects which needed it. The most important criteria for me was:
Random number generators should not be chosen at random. — Donald Knuth
While implementing the Jenetics library, I faced the problem of creating proper seed values for the
Randomengines I used. The usual way for doing this, is to take the current time stamp.
To get a feeling about the quality for this kind of seed values, I treated it as special random engine and applied the dieharder test suite to it. As you might expect, the quality of this random engine was disastrous. It didn’t pass a single dieharder test. All of the 114 tests failed.