Wednesday, October 15, 2008

Working with XML

When work with XML, most of time we start with a question of which technology or library should be used to speed up the development and also server the biz spec.

One guy summarized it in an article and here is the excerpt:

Which tool should I pick?

If you're new to XML you might not quite understand the need for having several XML tools. You might think that an API that allows you to read and write an XML document would be sufficient. The need for several tools arises when you realize that XML can be used in a lot of very different situations. Some examples are:

  • configuration files--or parameter files--are often written in XML. They typically contain technical data for systems like web servers.
  • XML files can be used when sending updates of business data to an application. Think of a list of new customers, orders or exchange rates.
  • XML data sometimes have to be persisted on files or in databases, but more often XML is only a format held in memory.
  • XML can be used as a description language for other types of XML documents. An example is XML schemas that are used to validate other XML documents.

Let's look at some of the different situations where you need to read an XML document, for example from a file.

When reading a configuration file, you need to get some or all of the parameters extracted from the file and then stored somewhere in your program. Digester is a great tool for this kind of operation. An introduction to Digester is "Digesting XML documents". Digester is also a natural choice if you only want to read some of the data in an XML file.

If you want to read all the data in an XML file and then continue to do some processing with these data, then you need to convert the XML into some kind of Java object structure. The simplest way to do this is to convert into JavaBeans, since beans are simple to work with. My own favorite tools for converting between XML files and JavaBeans are Castor and XMLBeans. Two articles that give you more information are " Converting XML documents to Java objects with Castor XML" and "Converting XML to JavaBeans with XMLBeans". XMLBeans is currently my number one pick since it seems capable of handling even the most complex XML structures and automatically packs the generated JavaBeans into a jar-file.

Castor and XMLBeans can be used when your XML files have a known, fixed structure that doesn't change over time. Castor and XMLBeans typically take the XML schemas that define the XML structures and generate beans for you. This is something you'll have to do manually, so you need an XML format that doesn't change too often.

If the format of your XML data is not fixed, you need to look for another tool. JDOM is such a tool, since it'll read any XML file and produce a tree-like structure in memory. This structure is very easy to work with for a Java programmer because of its simple API and its use of well-known Java objects like those implementing the List interface.

"

For full article, read from here .

Additional reading list:

Working with JDOM, XPath and XSLT

Java and JDOM: the perfect couple

Parsing an XML Document with XPath

Tuesday, October 14, 2008

Java + Excel XLS

Currently, I am doing a research on various solutions available for java & excel xls integration to be used for our next generation sales quotation tools. I found this article already did some work and compile a list of solution available below:

Library / package License Description
Actuate Spreadsheet Engine Commercial, 30-day trial version available Write Excel (XLS) files.
ExcelAccessor ?
Read and write Excel (XLS) files.
ExcelReader ? JavaWorld article on how to read Microsoft Excel (XLS) files, including code. Requires an installed Microsoft ODBC driver for Excel files, and Sun's ODBC-JDBC driver.
ExtenXLS Commercial, 30-day trial version available Read and write Microsoft Excel (XLS) files.
JACOB project LGPL Java COM bridge with examples to interface Excel.
Java Excel API LGPL Read Excel (XLS) 97, 98 and 2000 files.
Java to Excel conversion ? Write SYLK files, which Excel can import and export.
JExcel Commercial Swing component to integrate Excel via JNI.
jXLS LGPL Create Excel files using XLS templates.
POI Apache Software License 1.1 Read and write Microsoft OLE 2 compound document format files. This includes MS Office files (DOC, XLS, PPT) written with Office versions that were released after 1997.
Snowbound Commercial Read Excel files.
SoftArtisans OfficeWriter Commercial Write Word and Excel files.
Vista JDBC Commercial, 15-day trial version available JDBC driver to access MS Excel (XLS) files.
xlSQL GPL JDBC driver to access MS Excel (XLS) and CSV files.

In addition to this table, following links are viable choice for java & excel integration in the application.

Handle Excel files

Content Tagged with excel + Java

ExtenXLS Java Spreadsheet SDK

XLSBeans - mapping Excel sheets to POJOs

Java Excel API

JACOB - JAVA-COM Bridge to call COM components

The Java-Excel solution

Read and Write Microsoft Excel Documents with Jakarta's POI - (The Excel Document Model)

Excel Reports with Apache Cocoon and POI

Jxcell

j-integra - Accessing Excel from Java

ActiveXLS™ Professional for Java

Apache POI - Java API To Access Microsoft Format Files

jXLS - generating Excel files using XLS templates

Thursday, June 12, 2008

Cloudspace

As one of our project is looking for a open source, lightweight and stable database to be embedded into application, cloudspace has come into my eyes as its superior features and ready support of synchronization with various enterprise back ends, such as DB2 UDB™ or Informix® Dynamic Server.

Cloudscape is the original zero-admin, embeddable, 100% Java relational database that entered the marketplace in 1996. In August 2004 IBM contributed Derby, a copy of its Cloudscape 10.0 relational database product, to the Apache Software Foundation (ASF) to help accelerate innovation around data-driven Java applications. IBM continues its Cloudscape commercial offering at no-charge, which adds features to the core Derby engine. The most current release is Cloudscape 10.1, which includes Apache Derby 10.1.

Cloudscape- Key Features

* 100% Pure Java
o Completely portable to any hardware, any OS
o Only requires JVM (J2SE 1.3 or higher)
* Embeddable
o Can be installed as a JAR file (as part of a Java application)
o Can be started within an application
o Installation, startup and shutdown are invisible to user
* Fully-functional RDBMS

* Adheres to standards
o JDBC
o SQLJ
o ANSI SQL-92 * "Zero" Administration
o No need for DBA at customer site
o Users may even be unaware that a database engine is present
* Lightweight
o Approx. 2MB “footprint”
o Can run on many “palm”-size devices (new feature!)
* Scales to Moderate Size
o No defined limits on table sizes
o Table size limit of 2GB in some environments (OS limit)
o Existing customer databases of >10 GB working well
* Supports Disk Encryption
o Tested with IBM JCE

* Easy for Application Developers to Use
o To set up, just copy Cloudscape JAR files and set Java CLASSPATH
o Database engine starts automatically when application attempts to connect to it
* Cloudscape databases are completely portable
o To move a Cloudscape database to another machine, just copy it! (This works even if the machines have different OS or hardware!)
* Distributed transaction support (new!)
o Participates in XA transactions with other database systems

Cloudscape is a Fully-Functional RDBMS

* Indexes
* Views
* Triggers and Stored Procedures
* Constraints (primary-key, foreign-key, unique, check)
* Concurrency Support
o Transactions (with crash recovery)
o Savepoints
o Row-level locking, with escalation
o JDBC isolation levels (including dirty-read)
* Scrollable Cursors (result sets)
* Cascading Delete
* Internationalization/Localization Support

Reference List:

Synchronize IBM Cloudscape V10.0 and IBM DB2 Everyplace Sync Server V8.2


DB2 Everyplace Java Sync Client for IBM Cloudscape Version 10

Cloudscape Past and Present

Cloudscape Version 10: A technical overview

TPC - Transaction Processing Performance Council

An organization devoted to benchmarking transaction processing systems. In order to derive the number of transactions that can be processed in a given time frame, TPC benchmarks measure the total performance of the system, which includes the computer, operating system, database management system and any other related components involved in the transaction processing operation.

Transactions
The TPC-C benchmark yields transactions per minutes expressed in tpmC ratings. Earlier TPC-A and TPC-B benchmarks produced tpsA and tpsB ratings, which measured transactions per second.

TPC-W is a Web benchmark, performed in a controlled Internet e-commerce scenario and reported as the number of Web interactions processed per second. Shopping, browsing and ordering are the three simulated profiles measured.

Database Queries
TPC-H carries an ad-hoc label and is used in environments where users do not know which queries will be executed against a database system. TPC-R analysis assumes pre-knowledge of a standard set of queries, and execution is very fast as a result. The earlier TPC-D benchmark based its results on the size of the database being queried and yielded a single-user Qppd Power metric and multiple-user QthD Throughput metric.

TPC benchmarks are widely used today in evaluating the performance of computer systems; the results are published on the TPC web site.

Reference

TPC Intro
Wikipedia
TPC Portal

Wednesday, June 11, 2008

open source audit trail and logging component

The Inspektr project allows for non-intrusive auditing and logging by using annotations and aspects.

It also includes a generic Grails-based web application to view statistics and audit logs stored in various data sources.

Find out more from here

Groovy, Java's New Scripting Language

Groovy is a new scripting language for the Java environment. Groovy scripts can be interpreted (for faster development: no compile cycle!) or compiled to Java bytecode (.class format) for faster execution. Groovy accepts most Java constructs but also quite a few of its own.

* is an agile and dynamic language for the Java Virtual Machine
* builds upon the strengths of Java but has additional power features inspired by languages like Python, Ruby and Smalltalk
* makes modern programming features available to Java developers with almost-zero learning curve
* supports Domain-Specific Languages and other compact syntax so your code becomes easy to read and maintain
* makes writing shell and build scripts easy with its powerful processing primitives, OO abilities and an Ant DSL
* increases developer productivity by reducing scaffolding code when developing web, GUI, database or console applications
* simplifies testing by supporting unit testing and mocking out-of-the-box
* seamlessly integrates with all existing Java objects and libraries
* compiles straight to Java bytecode so you can use it anywhere you can use Java


See these links for complete information on Groovy:

http://www.darwinsys.com/groovy/

Groovy Is Not Java

Differences from Java

http://groovy.codehaus.org/

Java on Grails ?

Java programmers needn't abandon their favorite language and existing development infrastructure to adopt a modern Web development framework. In the first installment of his new monthly series Get started with Grails, get introduced to Grails and demonstrates how to build your first Grails application.

Grails is a modern Web development framework that mixes familiar Java technologies like Spring and Hibernate with contemporary practices like convention over configuration. Written in Groovy, Grails gives you seamless integration with your legacy Java code while adding the flexibility and dynamism of a scripting language. After you learn Grails, you'll never look at Web development the same way again.

Find original post here

Run your web applications on Google's infrastructure!

Google App Engine lets you run your web applications on Google's infrastructure. App Engine applications are easy to build, easy to maintain, and easy to scale as your traffic and data storage needs grow. With App Engine, there are no servers to maintain: You just upload your application, and it's ready to serve your users.

You can serve your app using a free domain name on the appspot.com domain, or use Google Apps to serve it from your own domain. You can share your application with the world, or limit access to members of your organization.

App Engine costs nothing to get started. Sign up for a free account, and you can develop and publish your application for the world to see, at no charge and with no obligation. A free account can use up to 500MB of persistent storage and enough CPU and bandwidth for about 5 million page views a month.

During the preview release of Google App Engine, only free accounts are available. In the near future, you will be able to purchase additional computing resources.

Find more from here

Thursday, April 10, 2008

Make Windows Installer for your application

Recently, my project is using a window installer script called NSIS to make windows executable exe file for product distribution which brings me to a post that comparing the similar products out there.

"Many of you know that Windows Installer is the preferred method of distributing software, according to Microsoft. However, Windows Installer has the serious flaw of requiring the OS to support the Windows Installer Runtime. This can be a problem on older operating systems, such as Windows 95 Gold and Windows NT SP0-SP3. ... If your program is designed to work on all Win32 systems, then you cannot use Windows Installer. You could use something such as Inno Setup or Nullsoft Scriptable Install System. Both are very good, but I believe that NSIS is much more versatile and expandable, due to its widespread support and many various plugins to make it more professional. The only thing NSIS is missing is Visual Studio plugins. At least for VS6 it would be good, since the InstallShield for VC++6 is very bad. Also, many installers that I built with that version of InstallShield do not work on XP due to the old structure of the installer. If you do not want to shell out $300+ for a good installer with universal support and still have a professional look, I recommend three things in combination: NSIS, HM NIS Edit, and ExperienceUI SDK. All three together allow you to build installers that look as good as the latest InstallShield installers, but with smaller overhead and much more flexibility. I see more good coming from open-source each day. NSIS is currently at 2.14 release, HM NIS Edit is at 2.0.3, and ExperienceUI SDK is at 1.1 release. The major advances in all three make things easier for the lower budgeted programmers to make nice installers for their projects. I think that Inno Setup should get its fair end of praise. Inno Setup is designed to be very similar in style to InstallShield, and does a good job of it. Inno Setup's ability to go silent install is very useful for automated runtime installs, making it as good as an automated Windows Installer installation. However, NSIS has advanced SILENT ONLY capabilities, forcing network install styles. Inno Setup already has 64-bit installations, while most others do not yet have this capability. I think NSIS may be able to be recompiled to build 64-bit installs, but I am not quite sure on that. InstallShield has one advantage that would make someone who needs this feature to shell out for it: The ability to make cross-platform installers. InstallShield can make RPMs for Linux apps and binary installers for Windows, MSI files for Windows Installer, and more. That would be the only reason I would shell out for it, if I had a program developed cross platform and need easy installer development. However, recently I came across another installer: InstallerBuilder Enterprise... This version does the one thing that would have tied me to InstallShield, ....
"

References

Find the original post (1 | 2)

External Links:

NSIS Users Manual

Windows Installer Authoring Tools

MSI / EXE UnAttended Installation

Thursday, January 17, 2008

JTS Topology Suite & GeoTools

Both are java open source tools for spatial data management.

The Open Source Java GIS Toolkit

The JTS Topology Suite is an API of 2D spatial predicates and functions. It has the following design goals:

* JTS conforms to the Simple Features Specification for SQL published by the Open GIS Consortium
* JTS provides a complete, consistent, robust implementation of fundamental 2D spatial algorithms
* JTS is fast enough for production use
* JTS is written in 100% pure JavaTM
* JTS is open source (under the LGPL license)

Find more information, you can find it from here.


Geo Tools is an open source (LGPL) Java code library which provides standards compliant methods for the manipulation of geospatial data, for example to implement Geographic Information Systems (GIS) . The Geo Tools library implements Open Geospatial Consortium (OGC) specifications as they are developed, in close collaboration with the GeoAPI and GeoWidgets projects. The capabilities of Geotools are presented in the feature list.

For more information, you can find it from here ( 1|2 ).

Understanding insurance

Having this post is because i am working some projects for insurance and need to have the domain knowledge of insurance.

Term life insurance

Term life insurance is the original form of life insurance and is considered to be pure insurance protection because it builds no cash value. This is in contrast to permanent life insurance such as whole life, universal life, and variable universal life.

Permanent life insurance

Permanent life insurance is a form of life insurance such as whole life or endowment, where the policy is for the life of the insured, the payout is assured at the end of the policy (assuming the policy is kept current) and the policy accrues cash value.

Here are the main characteristics of permanent life insurance:

* Permanent insurance protection.
* More expensive to own.
* Builds cash value.
* Loans are permitted against the policy.
* Favorable tax treatment of policy earnings.
* Level premiums.

There are three basic types of permanent insurance: whole life, variable life and universal life. The two most common are whole life and universal life. Whole life insurance provides lifetime protection, for which you pay a predetermined premium. Cash values usually have a minimum guaranteed rate of interest and the death benefit is a fixed amount. Whole life insurance is the most expensive life-insurance product available.

Universal life insurance separates the investment and the death benefit portions. The investment choices available usually include some type of equity investments, which may make your cash value accumulate quicker. As the you can usually change your premiums and death benefits to suit your current budget.

What i feel that variable and universal life insurance are all variation of whole life insurance policy and differences are:

Variable life insurance policy is something like death benefit + flexible investment options and much more expensive and risky as there are investment risk.

Universal life insurance policy is something like death benefit + saving component + loan facility as insurer will pay fixed amount regularly against to the interest rate or certain managed fund. It is much cheaper than whole and variable life insurance policy.

You can find more from here

Participating Policy

An insurance contract that pays dividends to the policy holder. Dividends are generated from the profits of the insurance company that sold the policy and are typically paid out on an annual basis over the life of the policy. Most policies also include a final or terminal payment that is paid out to the holder when the contract matures. Some participating policies may include a guaranteed dividend amount, which is determined at the onset of the policy.

Also referred to as a "with-profits policy".

Investopedia Says:
Participating policies are typically life insurance contracts such as a whole life participating policy. The dividend received by the policy holder can be used in several different ways. First, the policy holder can apply the dividend proceeds to the insurance policy's premium payment. Second, the dividend can be kept with the insurance as a deposit in order to generate interest much like a savings account at a bank. Finally, the policy holder can simply receive the dividend payment in cash, much like a dividend payment on a stock.

Nonparticipating Life Insurance Policy

Life insurance policy that does not pay dividends. Policyholders thus do not participate in the interest, dividends, and capital gains earned by the insurer on premiums paid. In contrast, Participating Insurance Policies pay dividends to policyholders from earnings on investments.

Frequently used Insurance Term

Term Life Insurance :: definition
Noted, there is no cash value with this policy.

Permanent Life Insurance :: definition
There are cash values with this set of policies.

Substandard Premium Rate :: definition

This is an extra premium (a substandard premium rate) charged a policy owner as a result of the insured being classified as having a higher-than-average risk of death. Reasons may include the person's physical condition, health, occupation and/or life-style. The premium rate charged is higher than a standard premium rate.

Cash Surrender Value :: definition

Indemnity :: definition

Long Term Care Insurance :: definition

Projected Dividend

Estimated future dividends to be paid by a Participating Insurance Policy. These dividend estimations cannot be part of the policy since they are not guaranteed. They are normally shown in a separate computer printout and are only as accurate as the basic interest rate assumptions made.

Reference and recommended links

Let Life Insurance Riders Drive Your Coverage?

Five Insurance Policies Everyone Should Have

Fifteen Insurance Policies You Don't Need

Understand Your Insurance Contract

Exploring Advanced Insurance Contract Fundamentals

Insurance Glossary (1 | 2)

´