Java

Thread Pools in Java

To scale applications it becomes necessary to separate thread creation and management from rest of the application. Using thread pools is an approach typically employed in large scale systems. This article provides a quick overview on executor framework in Java and provides examples on how to work with thread pools. Significance of Thread Pools Thread …

Thread Pools in Java Read More »

Java Serialization

Serialization is the process of converting the current state of an object into a byte stream. Deserialization is the process of converting the serialized form of an object back into a copy of the object.  A Java object is Serializable if a class implements java.io.Serializable interface. java.io.Serializable is a marker interface which tells that object is Serializable. A quick example. In …

Java Serialization Read More »

FreeMarker Introduction

FreeMarker Introduction FreeMarker is a template engine that helps to generate text based on templates. Examples, generation of dynamic web pages, source code generators etc. Freemarker helps to separate the application logic and page design. FreeMarker is a Java library and is free to use with the BSD license terms. FreeMarker supports a powerful template language which helps …

FreeMarker Introduction Read More »

Using Log4j for debugging in Java

Log4j is a simple, reliable, fast and extensible open source logging and tracing API. Logging is an important part of any software development lifecycle and is the only way to debug in certain production systems where it is not feasible to use debuggers. To use these examples download Log4j from https://logging.apache.org/log4j/1.2/. Let us quickly start …

Using Log4j for debugging in Java Read More »

JAXB for XML handling

Java Architecture for XML Binding (JAXB) provides a fast and convenient way to bind XML schemas and Java representations. JAXB provides methods for reading XML documents into Java objects and writing Java objects into XML documents. JAXB annotations are used for customizing Java program elements to XML mapping. Refer to this link for list of …

JAXB for XML handling Read More »

Validate XML against XSD in Java

XSD (XML Schema Definition) represent the content model or grammar of an XML document. XML schema defines the elements that form an XML document.Validation is the process of verifying if the XML document complies to the defined schema definition. Let us consider a simple XML file and the corresponding schema definition. <?xml version=”1.0″?><catalog><book id=”bk101″><author>Gambardella, Matthew</author><title>XML …

Validate XML against XSD in Java Read More »

Parse XML file using XPath in Java

XPath is a language for defining parts of an XML document. XPath gets its name from its use of a path notation as in URLs for navigating through the hierarchical structure of an XML document. The primary syntactic construct in XPath is the expression. An XPath expression is evaluated to yield an object which has one …

Parse XML file using XPath in Java Read More »

Transform XML using XSLT in Java

This article explains how to transform XML documents using XSLT. XSLT (eXtensible Stylesheet Language Transformations) is a language for transforming XML documents into HTML, XML, or other types of documents. Formatting rules to transform the input XML data is specified in a XML stylesheet (XSL). Inside the XSL typically XML Path language (XPath) is used …

Transform XML using XSLT in Java Read More »

DOM Parser to read XML file in Java

Document Object Model (DOM) API for XML approach is memory intensive compared to the SAX parser. Refer SAX Parser for an example implementation of SAX parser. If XML content size is large it is recommended to use the SAX parser approach. In the DOM parsing approach we load the entire contents of an XML file into a …

DOM Parser to read XML file in Java Read More »