Skip to main content

Posts

Bulk loading files into Sedna XML DB

The problem is to upload plenty of files into Sedna XML DB . How would you do this? If it is a repeated action, it's logical to create an application for this. This is quite easy using Sedna XML:DB Java API . Actually we've already done so but this article addresses another case. There is a problem using Java API that is the performance. Using Java API always brings overhead compared to using embedded terminal utility (I got the performance of 2 seconds per file with the remote Sedna installation). Now I have several thousands of files and I want to upload them fast so let's turn to writing some useful scripts to automate it. Generate bulk load file First we need to generate an xquery file with LOAD instructions that are supported by Sedna terminal utility. Let's do this with another simple script. I had to do this under both Linux and Windows systems so you'll find two scripts below. First comes the Linux shell script: #!/bin/sh OUTPUT_FILE=bulk_load.xque...

Do It Yourself Java Profiling

This article is a free translation of the Russian one that is a transcript of the Russian video lecture done by Roman Elizarov at the Application Developer Days 2011 conference. The lecturer talked about profiling of Java applications without any standalone tools. Instead, it's suggested to use internal JVM features (i.e. threaddumps, java agents, bytecode manipulation) to implement profiling quickly and efficiently. Moreover, it can be applied on Production environments with minimal overhead. This concept is called DIY or "Do It Yourself". Below the lecture's text and slides begin. Today I'm giving a lecture "Do It Yourself Java Profiling". It's based on the real life experience that was gained during more than 10 years of developing high-loaded finance applications that work with huge amounts of data, millions currency rate changes per second and thousands of online users. As a result, we have to deal with profiling. Application pro...

Still looking for a Java profiler?

This post is just a short overview on the topic. Recently I've had to investigate a performance issue of a Java application running under JBoss server. This problem resulted in using a full-featured free Java profiling tool - VisualVM that is available separately and as an embedded JDK tool starting from JDK 6 update 7. Thus, it's most likely already installed on your system. This solution was great in localizing the performance bottleneck on the Production environment in my case. The list of features include monitoring CPU and memory usage, application threads, profiling, sampling, taking thread and heap dumps, etc. I advise to watch the video tutorial on the Getting Started page . Here is my screenshot: I'm not going to make a thorough comparison of different Java profiler tools here but this is a list of alternatives for completeness: YourKit  is free for open-source projects; JProfiler  is free for open-source projects; NetBeans profiler is embedded into c...

Using Jetty 6 to run a Cocoon block

This article explains how to set up maven jetty plugin 6 for rapid development of Cocoon applications (this part is based on the official tutorial about cocoon maven plugin ). The article also describes an interesting pitfall reported here by Robby Pelssers. Modify project pom file In order to enable Jetty support you need to add the following plugins into your project pom file: <!-- Prepares block resources and classes for Jetty plugin --> <plugin> <groupId>org.apache.cocoon</groupId> <artifactId>cocoon-maven-plugin</artifactId> <version>1.0.0</version> <executions> <execution> <phase>compile</phase> <goals> <goal>prepare</goal> </goals> <configuration> <useConsoleAppender>true</useConsoleAppender> </configuration> </execution> </executions> </plugin> <!-- Runs current coc...

Using YUI3 Panel to send server transaction request from client-side

This article presents a nice way how to save some user-defined input on server and make browser wait for it before proceeding with navigation. This will be shown in a context of my use case that consists in a Cocoon Java application that allows exporting page in PDF format. Exported page is being generated by a specific Java Servlet as soon as the client browser redirects to the corresponding URL. Now assume that the end user wants to set a custom title for the exported page. Thus, we need some kind of interruption when the user clicks on the 'Export' link. It'll be implemented using nice  YUI3-based Transaction utility  and YUI3 Panel shown below: Initialize YUI3 To get started with YUI3, you should perform two steps: Load the YUI javascript file on your web page. Create and configure a new YUI instance. Please refer to this manual for code snippets. The only difference is that we'll use two modules: io and panel . Module io is required for transaction ...

Selecting date range with YUI3 Calendar

This is a fully UI related article about YUI3 Calendar widget . Whereas official documentation page and provided examples ( here and here ) are good enough to start with, there are still many pitfalls when you're going to customize the widget. My use case required a date range selection feature with a nice calendar window open only when a user clicks on text input fields. Also the selected day should be highlighted in the calendar whenever a user clicks again on the filled text input field ( a nice example with YUI2 Calendar widget ). This is how one date input field looks like: Add calendar container and date fields on the web page First of all you need to add a container div for the calendar: <div id="calendar-container"> </div> You will provide this id to the Calendar constructor later either as a bounding box or a content box . The difference is in html markup generated by YUI3. I'll use a bounding box below in order to manipulate position ...

How to efficiently cache static resources in a web application

This article is about an efficient technique of caching static resources on the client side (user's browser). There are quite many ways to implement caching including HTTP headers. A common disadvantage of them is that as soon as some resource is cached by the browser, it won't be updated until it's expired. Thus, the server loses control over the browser caching mechanism for some period of time. As a result we have to adjust the expiration time period or updating frequency somehow. The better alternative is the case when it's only the server that is in charge of the browser caching mechanism. Actually the idea has been borrowed here . If we append a GET parameter with some changing value (like a timestamp or a version) for a static resource URL, it'll force the browser to get the fresh version of the resource from the server. If we keep the parameter value steady, the resource will be taken from the browser cache. Finally this article is about implementation....