Featured Post

Event Sourcing Video from Michael Ploed

Event Sourcing I want to share a great video I found few days ago that describes very well what Event Sourcing is.

Tuesday, March 19, 2013

Select for Update

A select for update is often use as a semaphore on your database. If you plan a transaction with a select for update, you are avoiding the other transactions to get a read o write lock on the accessed rows; at this way you are implementing a sort of semaphore that is released only when the transaction ends.

Maven Dependencies Plugin

In this post I will show an example of usage of the dependency plugin, that can be used when you want to make a check of your project dependencies. The dependency plugin has two main goals:
  • dependency:resolve
  • dependency:tree


The goal mvn dependency:resolve permits to see all dependencies of an artifact and its related features; for example it shows the scope of your dependency artifacts.
A common situation to use this goal is when you are interested to verify which jars are in WEB-INF/lib of your deployed war. If you run mvn dependency:resolve, you can see if your dependencies artifact are provided or compile and make a quick check on your dependencies. Here you are an example of output of this goal:

a@b:  cd myproject

a@b:  ls
pom.xml  src  target

a@b:  dependency:resolve

[INFO] [dependency:resolve {execution: default-cli}]
[INFO]    The following files have been resolved:
[INFO]    antlr:antlr:jar:2.7.7:compile
[INFO]    aopalliance:aopalliance:jar:1.0:compile
[INFO]    asm:asm:jar:3.3.1:compile
[INFO]    cglib:cglib:jar:2.2.2:compile
[INFO]    ch.qos.logback:logback-classic:jar:1.0.7:compile
[INFO]    ch.qos.logback:logback-core:jar:1.0.7:compile
[INFO]    com.caucho:hessian:jar:4.0.7:compile
[INFO]    com.google.code.spring-crypto-utils:spring-crypto-utils:jar:1.3.0:compile
[INFO]    com.google.guava:guava:jar:13.0.1:compile
[INFO]    com.liferay.portal:portal-client:jar:6.1.20:provided
[INFO]    com.liferay.portal:portal-impl:jar:6.1.20:provided
[INFO]    com.liferay.portal:portal-service:jar:6.1.20:provided
[INFO]    com.liferay.portal:util-bridges:jar:6.1.20:provided
[INFO]    com.liferay.portal:util-java:jar:6.1.20:provided
[INFO]    com.liferay.portal:util-taglib:jar:6.1.20:provided
[INFO]    com.mchange:c3p0:jar:0.9.2-pre5:compile
[INFO]    com.mchange:mchange-commons-java:jar:0.2.3:compile
[INFO]    com.oracle:ojdbc:jar:6:provided
[INFO]    com.sun.xml.bind:jaxb-impl:jar:2.1.11:compile


The goal dependency:tree permits to see the all tree of dependencies of an artifact. The output of this goal is a tree that shows the origin of your dependencies.
Here you are an example of output of this goal:

a@b:  cd myproject

a@b:  ls
pom.xml  src  target

a@b:  dependency:tree

[INFO] +- myartifact:myproject:myversion:compile
[INFO] |  +- javax.xml:jaxrpc-api:jar:1.1:compile
[INFO] |  +- org.apache.cxf.xjc-utils:cxf-xjc-runtime:jar:2.6.0:compile
[INFO] |  |  \- javax.xml.bind:jaxb-api:jar:2.2:compile
[INFO] |  |     +- javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] |  |     \- javax.activation:activation:jar:1.0.2:compile
[INFO] |  +- org.apache.cxf:cxf-api:jar:2.6.0:compile
[INFO] |  |  +- org.codehaus.woodstox:woodstox-core-asl:jar:4.1.2:runtime
[INFO] |  |  |  \- org.codehaus.woodstox:stax2-api:jar:3.1.1:runtime
[INFO] |  |  +- org.apache.ws.xmlschema:xmlschema-core:jar:2.0.2:compile
[INFO] |  |  +- org.apache.geronimo.specs:geronimo-javamail_1.4_spec:jar:1.7.1:compile
[INFO] |  |  \- wsdl4j:wsdl4j:jar:1.6.2:compile
[INFO] |  +- org.apache.cxf:cxf-rt-frontend-jaxws:jar:2.6.0:compile
[INFO] |  |  +- xml-resolver:xml-resolver:jar:1.2:compile
[INFO] |  |  +- asm:asm:jar:3.3.1:compile