среда, 17 июля 2013 г.

Apache Ivy. My experience.

I've been using Apache Ant for a long time. It is easy to use. But the most feature it lacks is a project dependency management. Moreover, I need not just resolve the open source projects, but to resolve my own projects.

In my development I have 2 projects that share common classes, which are in a third project. I also have a continues integration server. All projects are build on it and later deployed.

I found that Apache Ivy best suites my need. The reasons for this are:
  • it does integrate with Ant. 
  • it takes minimum intervention into the project to use Ivy. 
  • it has tutorials and good documentation. 

What I like is that in default configuration Ivy offers you a local repository. All you have to do is write an ivy.xml file, which describes your project and dependencies and modify build.xml.

In my situation I write the ivy.xml, that describes the shared project like this:
<ivy-module version="2.0">
    <info organisation="my" module="common"/>
    <publications>
      <artifact name="common" type="jar" />
    </publications>
</ivy-module>

And modified build.xml to publish project like this:
<!-- =================================
          target: publish-local
         ================================= -->
<target name="publish-local" depends="jar" description="--> publish this project in the local ivy repository">
        <tstamp>
            <format property="now" pattern="yyyyMMddHHmmss" />
        </tstamp>
        <ivy:publish artifactspattern="${dist.dir}/[artifact].[ext]" resolver="local" pubrevision="${version}" pubdate="${now}" forcedeliver="true" />
        <echo message="project ${ant.project.name} published locally with version ${version}" />
        <ivy:cleancache />
    </target>

In my other projects which depends on a "common.jar" I write the following ivy.xml:
<ivy-module version="2.0">
    <info organisation="my" module="booking"/>
    <dependencies>
        <dependency name="common" rev="latest.integration" />
    </dependencies>
</ivy-module>

And modified the build.xml like this:
<!-- =================================
          target: resolve             
         ================================= -->
    <target name="resolve" depends="clean, clean-cache">
        <ivy:retrieve />
    </target>

That is all.

One more thing. You can use Ivy in Eclipse. For this one can download plugin IvyDE.

среда, 3 июля 2013 г.

Book review. Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications

Hi. Have just finished reading "Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications".

A good book to scratch the surface from the J2EE development. It gives you an overview of J2EE 6 and gives you direction to further investigation. The cons of this book are a tutorial style which describes how to do something in different containers. In my opinion this information can be obtained from the documentation to that containers.

четверг, 27 июня 2013 г.

MySQL table size statistics

If you need to monitor and analyze your MySQL databases size over time you can automate this process.
1) create the database
CREATE DATABASE stat   DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;

2) create the table
CREATE  TABLE `stat`.`sizeTable` (
  `idsizeTable` INT NOT NULL AUTO_INCREMENT ,
  `insertdate` DATE NOT NULL ,
  `databaseName` VARCHAR(45) NOT NULL ,
  `sizeMB` DOUBLE NOT NULL ,
  PRIMARY KEY (`idsizeTable`) ,
  INDEX `dateIndex` (`insertdate` ASC) )
ENGINE = InnoDB;

3) schedule the sql to collect statistics:
create event stat_db_evt
on schedule
every 24 hour
do
insert into stat.sizeTable (insertdate,databaseName, sizeMB) SELECT NOW() as insertdate, table_schema databaseName, sum( data_length + index_length ) / 1024 / 1024 sizeMB  FROM information_schema.TABLES GROUP BY table_schema;

Thar is all. This script will run every 24 hours and collect the statistics into the table, which you can analyze later.

пятница, 14 июня 2013 г.

OCPJP 7 Passed!

Yesterday I have passed 1z0-804 and earned the OCPJP status! Yeah!
So, what did I use for my preparation:
  1. Book Oracle Certified Professional Java SE 7 Programmer Exams by Ganesh and Sharma.
  2. Tests from http://enthuware.com.
It took me 3 months for preparation.

пятница, 3 мая 2013 г.

Java 7 Concurrency Cookbook

Have read Java 7 Concurrency Cookbook.
A very good book about concurrency in Java.
Every feature is accompanied with an example.
Most important thing is that examples are clear and resemble some real problems.
When working with an examples one should be very careful, because of the typos in the text. So it's better to consult errata on the publisher's site.
Also you can get 2 free chapters and source code on the publisher's site.

вторник, 9 апреля 2013 г.

Spring WS 2.1.0. Expose WSDL with external schema.

It is a good practice to keep schema external to your wsdl.
In Spring WS documentation it is not clearly mentioned how to publish wsdl with external schema.
After some time searching google i managed to found the solution:
<!-- WSDL -->
  <sws:static-wsdl id="BookingFacadeService" location="/WEB-INF/wsdl/BookingFacadeService.wsdl"  />
 
<!-- Schema -->
  <bean
        id="BookingFacadeService_schema"
        class="org.springframework.xml.xsd.SimpleXsdSchema">
        <property
            name="xsd"
            value="/WEB-INF/wsdl/BookingFacadeService_schema.xsd">
        </property>
    </bean>

BookingFacadeService.wsdl is my wsdl which include the external schema BookingFacadeService_schema.xsd.

Manipulate XML with Ant

Sometimes it is necessary to manipulate xml configs with Ant.
This can be done with XMLTask. A great tutorial about this ant task can be found here.

Software in Government

Did you know that http://dorogi.mos.ru is made with:
1) Spring security
2) Apache Wicket
3) Oracle Application Server 11.