Posts

Play with your byte-code using Javassist

I came to know about this nice tool named javassist which is a cool java byte code manipulation tool.It provides users with a very easy to use API to modify / create java classes in the Runtime. It provides some API to do that using a Java like syntax so that we can easily hack the byte code without knowing any thing in-depth about the byte code structure. In this blog post I'll explain you a simple example on how to use this tool.This will show how we can use javassist to change the byte code of a compiled class to change a method implementation in Runtime. Step 1 Download javassist library from http://sourceforge.net/projects/jboss/files/Javassist/3.14.0.GA/ Step 2 Create a new directory and copy javassist.jar to that directory. Step 3 Create Two java source file named HelloWorld.java and ByteCodeInjector.java in that directry HelloWorld.java public class HelloWorld { public static void main(String[] args) { new HelloWorld().sayHello(); } public void sayHello(){ ...

How to write a Axis2 Message Builder

Apache Axis2 is a open source SOAP/ Web services engine which consists of many extension points. Message Builders and Message Formatters are two ways we can extend the axis2 transport framework.In this post i’m going to explain the idea of Message builders and how we can implement a custom message builder and use it. As i mentioned above Axis2 is a SOAP engine. So it only accept SOAP messages for processing. So then a problem comes that how we can use axis2 with non-soap invocations like REST. So to convert row non soap content coming from a transport to a SOAP content we can use Message builders. This can really be useful when your in coming message have a non-xml format and you need to invoke a web service or process it with the axis2 engine with the given content information. Its simple to Write your own Message builder. First what you have to do is write a class implementing org.apache.axis2.builder.Builder interface in the Axis2 Kernal module. The Builder method signature we n...

Dead Letter Channel Enterprise Application Integration Pattern

Image
Dead Letter Channel Pattern belongs to the Category of Message Channel patterns which describes the Message transport level attributes. Idea of having a dead letter channel is to handle Message failures. Message failures can be occurred due to several reasons. Transport level failures Due to bad Configuration Message Expiration Problem with Message Consumer end In a failure Message will be routed to the dead letter channel. So that it can act as a Message archive mechanism , Re router or a special channel to process the bad messages. Having a Message archive system will be useful since later a Dead message can be viewed and re-delivered to the intended end point manually by a admin console.This will be useful to identify the Configuration problems Message Re-delivery is also a major part of a dead letter channel implementation. If we take a normal scenario like simple DB quarries or web-service calls some times a message will fail because of the endpo...

Invoking WebServices using Axis2 SMS Transport

In a previous blog I have explained the overview design of the Axis2 SMS Transport. Since Last week Axis2 Transport team announced Axis2 Transport 1.0 release in which SMS transport got released. I think its time to give some examples on how to use the SMS transport. SMS Transport currently have two SMS implementations SMPP protocol implementation GSM implementation where SMPP protocol implementation allow you to connect the axis2 to a SMSC and get messages form it. And GSM implementation allow you to connect a simple GSM modem to the computer that Axis2 is running and use that to send receive SMS form Axis2( its recommended not to use GSM implementation when your message traffic is higher than 6msgs per min). SMS Transport allow Axis2 users to do following Invoke a in only Web Service operation using a SMS Invoke a in out Web service operation and receive a reply Use Axis2 client and send messages out as a SMS In this blog I 'll discuss how to use SMS T...

Semaphores explained -- A Java approch

Image
Semaphore can be considered as a variable or Data Structure that can be used to archive mutual exclusion in a Parallel Programming environment. One good real life example to explain this is the tablet mechanism that is used in old railway system. Where when a train enters a Train Station it need to get a tablet from the Station master to proceed to the next station. When the train get the tablet that means there will be no other train in the railway track till it reaches the next station. When The train arrived to the next station it must give back the tablet to the station master so that he can signal the station that train has come from that line is cleared now (line is clear ) So getting a tablet is like acquiring a lock in the train line so that other trains that are in need of acquiring the line need to wait till the train reaches the next station and release the lock ( give the tablet back). This signal system still in use in Sri Lanken Railway line in some parts where the...

Executing maven test with the ant run plugin--A Real experiance.

Few days back i got a unexpected result with using the maven ant run task with a patch i submitted for the unit tests for the SMS Transport(which is my GSoC project).So i thought it would be useful if i blog my experiance and how i solved that issue. So i'll start with my xml segment in the pom. <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-antrun-plugin</artifactid> <executions> <execution> <id>build-repo</id> <phase>test-compile</phase> <configuration> <tasks> <mkdir dir="target/test-resources/samples/conf"> <mkdir dir="target/test-resources/samples/repository/modules"> <mkdir dir="target/test-resources/samples/repository/services"> <mkdir dir="targ...

Chandi jaisa rang hai tera- My favorite Gazal

Gazal is a beautiful Hindustan music style which have lot of great songs.the most important thing about gazal style is most of the songs can be enjoyed even without having a classical music background.Most of the gazals are written about romance.It carries "Srungara Rasa" with it. The Gazal song Chandi jaisa rang hai thera is a gazal that admire the beauty the girl that he loves. Chandi jaisa rang hai tera, sone jaise baal Ek tuhi dhanvaan hai gori, baaki sub kangaal Chandi jaisa rang hai tera, sone jaise baal Ek tuhi dhanvaan hai gori, baaki sub kangaal Ek tuhi dhanvaan hai gori, baaki sub kangaal Jis reste se tu gujre, voh phoolon se bhar jaye Jis reste se tu gujre, voh phoolon se bhar jaye Tere pair ki komal aahat sote bhaag jagaye Jo patthar choo le gori tu voh heera ban jaye Tu jisko mil jaye voh, tu jisko mil jaye Vo ho jaye malamal Ek tuhi dhanvaan hai gori, baaki sub kangaal Chandi jaisa rang hai tera, sone jaise baal Ek tuhi dhanvaan hai gori, baaki sub kangaal Jo be...