Another interesting tidbit:
@Benchmark
public void debug1Arg_date(Blackhole blackhole) {
LOGGER.debug("Started at %s", new Date(time));
time++;
blackhole.consume(time);
}
@Benchmark
public void guardedDebug1Arg_date(Blackhole blackhole) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Started at %s", new Date(time));
}
time++;
blackhole.consume(time);
}
Gives the following benchmark results:
Benchmark Mode Cnt Score Error Units
Log4jBenchmark.debug1Arg_date thrpt 20 179653191.248 ± 2731044.349 ops/s
Log4jBenchmark.guardedDebug1Arg_date thrpt 20 207001790.376 ± 2074020.617 ops/s
We can also compare guarding with SLF4J over logback
One of my colleagues had a question:
Now for some context, when the Jenkins project started off, Kohsuke was working for Sun and felt it would be wrong, as a Sun employee, to use a logging framework other than that provided by the JVM as using a different logging framework could be seen as being implication that the built in Java Utils Logging framework was a steaming pile of excrement.
You asked for it.
Logback:
@Benchmark
public void debug1Arg_date(Blackhole blackhole) {
LOGGER.debug("Started at {}", new Date(time));
time++;
blackhole.consume(time);
}
@Benchmark
public void debug2Arg_date(Blackhole blackhole) {
LOGGER.debug("Started at {}", new Date(time), null);
time++;
blackhole.consume(time);
}
@Benchmark
public void debugNArg_date(Blackhole blackhole) {
LOGGER.debug("Started at {}", new Date(time), null, null);
time++;
blackhole.consume(time);
}
static {
ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger)LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
root.setLevel(ch.qos.logback.classic.Level.INFO);
}
And the benchmarks
Benchmark Mode Cnt Score Error Units
LogbackBenchmark.debug1Arg_date thrpt 20 221056534.656 ± 8549233.826 ops/s
LogbackBenchmark.debug2Arg_date thrpt 20 220576341.742 ± 3778270.898 ops/s
LogbackBenchmark.debugNArg_date thrpt 20 134887126.088 ± 2973182.812 ops/s
JUL over SLF4J (same benchmark code but different dependency)
One of the headline grabbing things that people seem to be raving about over Log4J 2.0 is async loggers.
Now do not get me wrong, they are great… as long as you know what you are doing.
If you are using async loggers you had better make sure you are only passing immutable objects to your loggers, because otherwise you may end up logging the state of your objects at the time of the log record being written and not the time you called log.
I’ve been meaning to blog about getting transaction management working with OpenEjb and Jetty using jetty:run… it’s still an on-going story… but the following might get you going…
First off, in your pom.xml you need to add the configuration for maven-jetty-plugin… we need to dance around the various activemq/activeio versions and ensure that we get the correct version of ant…
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.openejb.examples</groupId>
<artifactId>jetty-openejb</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>jetty-openejb Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.22</version>
<dependencies>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
<version>4.1.1</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.activemq</groupId>
<artifactId>activeio-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-ra</artifactId>
<version>4.1.1</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.activemq</groupId>
<artifactId>activeio-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activeio-core</artifactId>
<version>3.1.2</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-core</artifactId>
<version>3.1.2</version>
<exclusions>
<exclusion>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-ra</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.activemq</groupId>
<artifactId>activeio-core</artifactId>
</exclusion>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- in order to use the latest version of openejb, we need to exclude
the dependencies provided in jsp-2.1-jetty -->
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1-jetty</artifactId>
<version>6.1.22</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<configuration>
<jettyConfig>${basedir}/src/main/jetty/jetty.xml</jettyConfig>
</configuration>
</plugin>
</plugins>
</build>
</project>
Next we need to configure a src/main/jetty/jetty.xml to bind the UserTransaction instance into jetty…
One of my co-workers has asked me to post this up. It’s rough and ready, so make of it what you want.
First off, Acer recently pushed an update for better performance with the Huawei USB modems… I’m assuming that you have this update… check if the file /etc/udev/rules.d/10-Huawei-Datacard.rules exists.
If that file exists then when you plug in a E169g it will be correctly autodetected without requiring poking about with usbmodeswitch… it will bind the three serial ports of the E169G to /dev/HuaweiMobile-0, /dev/HuaweiMobile-1 and /dev/HuaweiMobile-2.
Note to self, for later reading
http://technology.amis.nl/blog/?p=2610
Not sure why netbeans is essential on this!
I am sick of the fun that is getting JAX-WS 2.1 to work on JVM 1.6.
Oh, copy these four jars into the endorsed directory and then you can use JAX-WS 2.1… oh but sometimes it won’t work for some unknown reason and then it will work again.
How you are supposed to explain this to end users, I don’t know.
So next you need a platform specific installer to put those jars into the correct location, or a platform specific start script to tell the JVM about my alternate endorsed lib folder… or do I write a self-extracting jar file that exctracts the libs and forks a second JVM… no that won’t work for people wanting to use my library..
Working on this to add to EasyGloss.
There are a number of rules that JPA entities must obey:
equals and hashCode must only be based on the persistent fields that are @Id annotated.I want to have a JPA Entity excerciser that will check these rules for you (and can be included in your unit tests)