Tuesday, December 22, 2009

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

  1. SMPP protocol implementation

  2. 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

  1. Invoke a in only Web Service operation using a SMS

  2. Invoke a in out Web service operation and receive a reply

  3. Use Axis2 client and send messages out as a SMS

In this blog I 'll discuss how to use SMS Transport to invoke a simple a Web Service using a RPC type SMS via GSM implementation

Environment :

OS: Ubuntu 9.04

JDK : 1.6.0

Axis2 Version : 1.5.1

Modem : Huawei E220

Following are the Steps that need to be taken

  1. Add Runtime Libs to Axis2 to Start with SMS Transport

  2. Configure Axis2

  3. Deploy our Simple service

  4. Start Axis2

  5. invoke service using a SMS.

Adding Runtime libs

add following file to the Axis2-HOME/lib directory

Now we need to add Java communication API libs needed for the SMS lib

go to jre home and goto lib/ext/ directory and add following files

  • comm.jar

  • libLinuxSerialParallel.so

  • libLinuxSerialParallel_g.so

Now we are Axis2 two is ready to start with Axis2 .

Configuring Axis2

Goto Axis2-HOME/conf folder where you find the axis2.xml file which is the configuration file used for Axis2 configuration.

Then add following to the Transport section.


SMS Transport Receiver configuration




<transportreceiver name="sms" class="org.apache.axis2.transport.sms.SMSMessageReciever">
<parameter name="smsImplClass">org.apache.axis2.transport.sms.gsm.GSMImplManager</parameter>
<parameter name="com_port">/dev/ttyUSB0</parameter>
<parameter name="gateway_id">modem.ttyUSB0</parameter>
<parameter name="baud_rate">115200</parameter>
<parameter name="manufacturer">HUAWEI</parameter>
<parameter name="model">E220</parameter>
</transportreceiver>

SMS Transport Sender configuration


<transportsender name="sms" class="org.apache.axis2.transport.sms.SMSSender">
<parameter name="smsImplClass">org.apache.axis2.transport.sms.gsm.GSMImplManager</parameter>
<parameter name="com_port">/dev/ttyUSB0</parameter>
<parameter name="gateway_id">modem.ttyUSB0</parameter>
<parameter name="baud_rate">115200</parameter>
<parameter name="manufacturer">HUAWEI</parameter>
<parameter name="model">E220</parameter>
</transportsender>


Now Axis2 is ready. Now lets write a Simple Axis2 Service


Deploy Axis2 Service


Following is the Sample POJO Axis2 Service Class I wrote to demonstrate this



package sample.sms.test;



public class SampleInOutService {


public String sayHello(String name) {

return "Hello " + name;
}


}

Make a service archive of this POJO class and put that in the Axis2-HOME/repository/services directory.

Start Axis2

Then Start Axis2 by going to Axis2-HOME/bin and executing the shell script axis2server.sh.

If every thing goes ok you will see a log like this at the end

[INFO] Version: 3.4.1

[INFO] JRE Version: 1.6.0_06

[INFO] JRE Impl Version: 10.0-b22

[INFO] O/S: Linux / i386 / 2.6.28-14-generic

[INFO] GTW: modem.ttyUSB0: Starting gateway, using Generic AT Handler.

[INFO] GTW: modem.ttyUSB0: Opening: /dev/ttyUSB0 @115200

[INFO] GTW: modem.ttyUSB0: GSM: Registered to home network.

[INFO] GTW: modem.ttyUSB0: MEM: Storage Locations Found: SM

[INFO] GTW: modem.ttyUSB0: Gateway started.

[Axis2] Started in Port :/dev/ttyUSB0

[INFO] [SimpleAxisServer] Started


Now we are done now we can invoke the sayHello operation by sending a SMS message to the modem

following is the SMS

SampleInOutService:sayHello:name=charith

send that SMS to the modems phone number and you will get a SMS saying Hello charith

You can use SMS Transport Mixing implementations. ex : send messages using SMPP and recive via GSM modem.

This Transport will be useful when your going to implement your EDA (Event driven architecture) since users will be able to generate events and/or get notifications of events via SMSs

More details of SMS Transport can be found at SMS Transport documentation

Sunday, October 18, 2009

Semaphores explained -- A Java approch

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 there is only one rail track between two stations.




Above explained situation is an example for the Binary Semaphore. where it supports two operations up() and down() . A binary semaphore can have only two values 0 and 1 .(NOTE that up() , down() operations are atomic operations )

when someone call a up on semaphore if its value is 0 then it increment it to one and return so that execution can proceed. But if its value is 1 then that up call block the process execution till some one make the semaphore value to 0 (wait till a down call);

In a down call if semaphore value is 1 it decrement it can return. If its 0 then the down call will block the process execution till the semaphore value set to one (wait till a up call).

This little idea is extended to an idea called Counting Semaphores there we can have more than two values for the semaphore. So that process can call multiple up s /down s till it get blocked.Which means more that one thread can pass the through before it blocked.

Now its time to look in to how this going help to solve a mutual exclusion problem.

Following is a famous problem in Concurrent programming text books lets see how we can solve it.

Bill and Ben work in a cafe that specialises in a soup and sandwich combination.

Bill makes two rounds of sandwiches while, at the same time, Ben makes two bowls of soup. When the sandwiches and soup are ready Bill and Ben each, they serve a soup and sandwich combination to a customer. These actions are repeated throughout the day.

[Note: Bill cannot serve until Ben has made the soup and Ben cannot serve until Bill has made the sandwiches.]

So as the Problem explained Before Serving sandwiches and soup Bill and Ben need to sync up.

Which means there can be no two customers in the shop at any time that has only served one item.(soup/sandwich)

If we model Bill and Ben as two processes that executes parallely it must be like follows

process Bill {

while (true) {

// Bill makes sandwiches //

SYNCH 1;

// Bill delivers //

}

}

process Ben {

while (true) {

// Ben makes soup //

SYNCH 2;

// Ben delivers //

}

}

To implement this Processes I'll be using the Java Language. Java has inbuilt semaphore implementation in java.util.concurrent.Semaphore

Its a counting Semaphore implementation. For this case since we only need a binery semaphore I'll will use it with permit value 1. which means only 1 thread is permitted to acquire it at a time.

I'll use the operations acquire and release operations which are smiler to up and down operations .

First lets look in to the code.



import java.util.concurrent.Semaphore;

public class Cafe {
private final Semaphore bill = new Semaphore(1);
private final Semaphore ben = new Semaphore(1);


public static void main(String[] args) throws InterruptedException {
//Cafe opening
new Cafe().openCafe();
// Cant keep it open for long time.... :D
Thread.sleep(1000);
System.exit(0);
}


private void openCafe () throws InterruptedException {
// allocating them to the work
bill.acquire();
ben.acquire();


Thread benProcess = new Thread(new Ben());
Thread billProcess = new Thread(new Bill());
//work started
benProcess.start();
billProcess.start();


}
class Bill implements Runnable {

public void run() {
int i=0;
while(true) {
System.out.println("[Bill] finished making 1 sandwitch");
System.out.println("[Bill] finished making 2 sandwitchs");

try {

//bill says i m done
bill.release();
// bill wait till ben done
ben.acquire();
} catch (InterruptedException e) {
System.out.println("Process interrupted....");
}

System.out.println("[Bill Serves...Sandwitch to customer "+ ++i+" ]");
}
}
}

class Ben implements Runnable {

public void run() {
int i=0;
while(true) {
System.out.println("[Ben] finished making 1 Soup");
System.out.println("[Ben] finished making 2 Soup");

try {

// ben says i m done
ben.release();
// ben waits till bill done
bill.acquire();
} catch (InterruptedException e) {
System.out.println("Process interrupted....");
}

System.out.println("[Ben Serves... Soup to Customer "+ ++i+"]");
}
}
}
}
So if we looked in to the code Bill and Ben are implemented as two runnable s . At the start We create a Cafe allocate Ben and Bob work and tell them to start work.

If we look in to Bill Process what it does is it creates two Sandwiches and tell that I, m done by releasing bill semaphore and waits till Ben finished by trying to acquire the ben semaphore.

And Ben does other way around.

So it guarantees that Ben cant serve till Bill finish and Bill cant till Ben finishes.

So at the end when the processors executing parallely the condition of there can be no two customers in the shop at any time that has only served one item.(soup/sandwich) is satisfied.

Following is sample console out put I got

[Ben] finished making 1 Soup
[Ben] finished making 2 Soup
[Bill] finished making 1 sandwitch
[Bill] finished making 2 sandwitchs
[Ben Serves... Soup to Customer 1]
[Ben] finished making 1 Soup
[Ben] finished making 2 Soup
[Bill Serves...Sandwitch to customer 1 ]
[Bill] finished making 1 sandwitch
[Bill] finished making 2 sandwitchs
[Ben Serves... Soup to Customer 2]
[Ben] finished making 1 Soup
[Ben] finished making 2 Soup
[Bill Serves...Sandwitch to customer 2 ]
[Bill] finished making 1 sandwitch
[Bill] finished making 2 sandwitchs
[Ben Serves... Soup to Customer 3]
[Ben] finished making 1 Soup
[Ben] finished making 2 Soup
[Bill Serves...Sandwitch to customer 3 ]


......... goes on


You can see the condition is satisfied.
Hope this helps to improve your understanding on Semaphores...


Wednesday, August 19, 2009

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="target/test-resources/samples/repository/services/SampleService/org/apache/axis2/transport/sms">
<mkdir dir="target/test-resources/samples/repository/services/SampleService/META-INF">
<copy file="${settings.localRepository}/org/apache/axis2/addressing/${axis2.version}/addressing-${axis2.version}.mar" tofile="target/test-resources/samples/repository/modules/addressing.mar">
<copy file="target/test-classes/org/apache/axis2/transport/sms/SimpleInOutMessageReceiver.class" tofile="target/test-resources/samples/repository/services/SampleService/org/apache/axis2/transport/sms/SimpleInOutMessageReceiver.class">
<copy file="conf/axis2.xml" tofile="target/test-resources/samples/conf/axis2.xml">
<copy file="repository/services/SampleService/META-INF/MANIFEST.MF" tofile="target/test-resources/samples/repository/services/SampleService/META-INF/MANIFEST.MF">
<copy file="repository/services/SampleService/META-INF/services.xml" tofile="target/test-resources/samples/repository/services/SampleService/META-INF/services.xml">
</copy>
</copy>
<goals>
<goal>run</goal>
</goals>
</copy>
</copy>
</copy>

</mkdir></mkdir></mkdir></mkdir></mkdir></tasks></configuration></execution></executions></plugin>
As you see there is only some mkdir and copy tasks listed in the test-compile phase

So When I run the tests test where executed successfully(mvn clean install / mvn test)
And also when i skip the tests with mvn clean install -Dtest=false the build was successful.

The problem comes when i try to skip the test with mvn clean install -Dmaven.test.skip=true
when i do that follwing error appiers

[ERROR] BUILD ERROR
[INFO] ------------------------------
------------------------------------------
[INFO] An Ant BuildException has occured: Warning: Could not find file /home/charith/projects/transport/modules/sms/target/test-classes/org/apache/axis2/transport/sms/SimpleInOutMessageReceiver.class to copy.

So If you look in to the ant run plugin the copy tasks are listed in the "test-compile" phase so its seems correct to assume that those tasks will not execute when we skip the tests.And it seems that assumption is correct when we use the -Dtest=false.But that assumption fails with we run with -Dmaven.test.skip=true

The reason for this error is the .class file that the copy task trying to copy created after compiling the test sources.but when we use -Dmaven.test.skip=true to skip the tests it will execute the tesks that are listed in the test-compile phase .So it reports the Error.

to overcome that case i had to add the system variable check to the task.Now it will check for the maven.test.skip variable before executing the test.So if it is true it will not execute the tasks in the test-compile phase.Following this the modified pom which resolved the issue.




<plugin>
<groupid>org.apache.maven.plugins</groupid>
<artifactid>maven-antrun-plugin</artifactid>
<executions>
<execution>
<id>build-repo</id>
<phase>test-compile</phase>
<configuration>
<tasks unless="maven.test.skip">
<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="target/test-resources/samples/repository/services/SampleService/org/apache/axis2/transport/sms">
<mkdir dir="target/test-resources/samples/repository/services/SampleService/META-INF">
<copy file="${settings.localRepository}/org/apache/axis2/addressing/${axis2.version}/addressing-${axis2.version}.mar" tofile="target/test-resources/samples/repository/modules/addressing.mar">
<copy file="target/test-classes/org/apache/axis2/transport/sms/SimpleInOutMessageReceiver.class" tofile="target/test-resources/samples/repository/services/SampleService/org/apache/axis2/transport/sms/SimpleInOutMessageReceiver.class">
<copy file="conf/axis2.xml" tofile="target/test-resources/samples/conf/axis2.xml">
<copy file="repository/services/SampleService/META-INF/MANIFEST.MF" tofile="target/test-resources/samples/repository/services/SampleService/META-INF/MANIFEST.MF">
<copy file="repository/services/SampleService/META-INF/services.xml" tofile="target/test-resources/samples/repository/services/SampleService/META-INF/services.xml">
</copy>
</copy>
<goals>
<goal>run</goal>
</goals>
</copy>
</copy>
</copy>

</mkdir></mkdir></mkdir></mkdir></mkdir></tasks></configuration></execution></executions></plugin>
As you see the only change is tasks unless="maven.test.skip" in the task element which check !(maven.test.skip)

the follwing xml segment is logically equal to

if(!(maven.test.skip)) {
//execute task
}


<tasks unless="maven.test.skip">
After this system variable check I was successful with running the tests with -Dtest=false , -Dmaven.test.skip=true.

Monday, August 17, 2009

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-rang ho us par kya kya rang jamate log
Jo be-rang ho us par kya kya rang jamate log
Tu naadaan na jane kaise roop churate log
Nazaren bhar bhar dekhen tujhko aate jaate log
Chail chabeeli rani thoda, Chail chabeeli rani thoda
ghoonghat aur nikaal
Ek tuhi dhanvaan hai gori, baaki sub kangaal
Chandi jaisa rang hai tera, sone jaise baal
Ek tuhi dhanvaan hai gori, baaki sub kangaal

Dhanak ghata kaliyan aur tare sub hain tere roop
Dhanak ghata kaliyan aur tare sub hain tera roop
Ghazalen hon ya geet hon mere sub mein tera roop
Yunhi chamakti rahe hamesha tere husn ki dhoop
Tujhe nazar na lage kisi ki
Tujhe nazar na lage kisi ki
Jiye hazaron saal
Ek tuhi dhanvaan hai gori, baaki sub kangaal
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
Ek tuhi dhanvaan hai gori, baaki sub kangaal




Monday, June 22, 2009

Axis2 SMS Transport

Apache Axis2 is an opensource framework for webservices which is widely used today ,and its implementation is available in both java and c. Axis2 is independent of the underlying transports which takes the Messages to it.Axis2 Engine is concentrating on the SOAP processing. Users can select transports to suite their requirement and that transports are responsible for injecting Axis2Messages to the Axis2Engine.So Axis2 Engine is dealing only with this Axis2MessageContex build from the underlying transport framework.

I' m writing SMS Transport as my Google Summer of Code 2009 project for Apache Axis2 which is a project focusing on implementing a SMPP support for Axis2java (And also it will able be used in Apache Synapse too Since Synapse uses the same axis2Transports ) by which Axis2 will be able to communicate with SMSCs (Short message service centers) or Any other Message centers that support SMPP . And also in this project it will make enable axis2 to communicate with Simple GSM modems.

At the beginning of the Project I considered the Word "SMS" as a generic one where there can be many implementations.Currently it support the SMPP protocol to send receive SMS via Message Centers.The SMS transport is designed and implimented in a such a way that it can be easyly extended to use any other implimentations or to use any SMS message formats.

SMPP - Short Message Peer to Peer protocal is an open, industry standard protocol
designed to provide a flexible data communications interface for transfer of short message data between a Message Center, such as a Short Message Service Centre (SMSC), GSM
Unstructured Supplementary Services Data (USSD) Server or other type of Message Center
and a SMS application system, such as a WAP Proxy Server, EMail Gateway or other
Messaging Gateway.The advantage of supporting SMPP protocol with the Axis2 SMS Transport is it can be use to send receive high volume of Short messages very fast.SMPP protocal is a Application layer protocal which can be used over TCP. There are many SMPP gateways avalilable in the world.and now almost all the Message centers support SMPP.Click is a good example of a SMPP sms gateway.
https://www.clickatell.com

SMS Transport will also support send receive SMSs using a Simple GSM modems attached to the Computer.This sms implementation can be used when the data Traffic is very low.A Typical GSM modem can only handdle about 6 messages per minute.If a user need to have a heiger data Traffic with the Axis2 the SMPP implimentation can be used.

following is an diagram of the overview of SMS Transport




Extending SMS Transport

SMS Transport was design to be a extensible one.where it provides proper interface to extend and reuse the current implementations.

If we focus on Axis2 SMS Transport the Axis2 dependent Transport senders , Transport listeners , Message Builders , Message Formatters are put in the generic SMS layer. That layer will be depending on the underlying implementation layer which only focus on the current SMS implementation which will have nothing to do with Axis2. So the advantage is that the Developers who need to write another implementation need not to worry about the Axis2.They just need to rely on the provided API and focus on their Implementation logic.

Other Extensible point of the SMS Transport is the Extending MessageFormatters and Message Builders.Users can write there own Message Builders and formatter to send receive any message formats they like by implementing the interfaces coming with the SMS Transport.

This blog is only a overview of the Axis2 SMS Transport and there will be documentation coming explaining the configuration , and extensibility of this Transport.

Saturday, April 25, 2009

Spot Light to Service Component Architecture

If we take a Normal Software application it will be consist of Many components.Where they may be developed using a same technology or different technologies.And also they may be deployed in a Same runtime ,machine or different ones and communicating with each other using a same technology or different technologies.

SCA (Service component Architecture) defines how these components are created and how they are assembled together to build composites.It is a programing model build based on the SOA.

According to the SCA specification SCA applications can be implemented using many technologies like Java ,Spring ,C++ etc ... SCA defines how these components built using any technology can be Assembled to built a application.

A Simple example of a Component assembled to build a Application would be a Simple Java Application with few classes communicating with each other in a Single JVM.Or in a More Complex case it will be set of Web Services working together to build up a Custom Service .

SCA Component is the atomic unit in a SCA application where they can be combine together in a preferable way
As the Diagram shows a Component can expose services that other components (or may be the out side applications )will be able to use.And also a Component may be relying on the Services provided by other components(or by out side systems).And also a Components can have properties that will be able to initialized at the component creation.In SCA a component can be properly configured by mentiong above mentioned properties ,services etc using SCDL (service component definition language)

Composites are Logical constructs that will consist of one or many components.but interestingly these components in side a Composite may be distributed in many runtimes. So it is impotent to understand that composite only define a logical construct using deferent components.It will have a logical meaning in the context of work done within the composite.But the components that the composite is build from may use different technologies.



As u see The composites can also have Services references , properties.

Following is a example of how a composite is configured using SCDL

sample.composite

<?xml version="1.0" encoding="UTF-8"?>

<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:burlap="http://www.fabric3.org/binding/burlap/0.2"
name="BurlapTestComposite">

<!-- Hello Client -->
<component name="HelloClient">

<implementation.java class="org.fabric3.sample.hello.HelloClientImpl"/>
<reference name="helloService" target="HelloService"/>
</component>

<!-- Hello Service -->
<component name="HelloService">
<implementation.java class="org.fabric3.sample.hello.HelloServiceImpl"/>
</component>

</composite>





These fundamentals of SCA (components and composites) are contained with in a lager construct called SCA domain.Which is normally a Set of Systems with a common SCA runtime technology and common management(people).


Apache Tuscany , HydraSCA , Fabric3 are few examples of these SCA Runtimes.

SCA can be seen as a programming modal that will be very useful when developing and maintaining complex business applications.Which ensure the reuse by having low coupling and componentizing . The modal that SCA is trying to bring in is not a new concept to the domain. Even the Spring frame work has same concepts that shears with the SCA.These evelutions happening are showing some bright lights of the Pinnacle we are seeking in the Computer Science.

references : http://www.osoa.org/display/Main/Service+Component+Architecture+Home

Sunday, March 29, 2009

Configuring Apache Synapse - Spring With IDE support

Apache Synapse uses its own XML based DSL for Configuration.At the Synapse Initialising phase Synapse reads the XML file and Build the Synapse Configuration Object Structure.
It takes time to new users to be familiar with the Synapse Configuration language.Some times they may have to look in to the synapse configuration factories to know the all the configuration parameters.

Spring-DSL for synapse project enable users who are familiar with Spring syntax to configure synapse in Spring (both underlying Axis2 instence and Synapse)

One of the main advantages here is users being able to configure synapse using IDE support . Following are few Screen shots taken from the comming tutorial on Spring DSL for Synapse


Saturday, March 7, 2009

Guardian-Mobile become handy when your mobile got stolen(personal experience)


I lost my mobile yesterday night while i m on the way home in a train.Its about 10:30 pm when that happen.since its late night there were only few people in the train.This happen when the train stopped at the Bulugahagoda(between Gampaha and Ragama).
I was holding the phone because i got a phone call just before that happen.Suddenly one from the back grabbed my phone and run away and jump from the Train.I was fraction of a second late from catching him.
The reason i m blogging now is to explain how the Guardian-Mobile which is installed in my mobile helping me and the police to track the guy who is using it.

Guardian is an Advanced Antitheft Software for Mobile devices, it provides unique and powerful features:
- Sim Changed notification through Invisible sms
- Password Protection of messaging, gallery, contacts or every other application
- GPS Localization and Tracking through GoogleMaps
- optimized for Low Memory and Battery consumption
- and MUCH more...[1]

I have registered my sim as the user sim in that software.So when some one change the sim in my mobile , my mobile send a SMS from my mobile to a pre-configured no(In my case its my brothers no).

That SMS contains following details

  1. phone NO: phone number of the currrent user
  2. IMEI : International mobile euipment identity
  3. IMSI : International Mobile Subscriber Identity
  4. GSM CELL ID
  5. GSM AREA ID
  6. GSM COUNTRY ID
Now i'm getting updates from my mobile about the SIM changes containing above info.I have provided that information to the police So they can get the user information form the service provider.

IMEI can also used to track a user.

IMEI is a unique number for a given mobile device.when that device try to do any data transfer it sends it IMIE to the service provider (Which get logged) even a service provider can reject any data transfers from a given IMEI.So we can use this to track the device and also to make is useless to the user.

IMSI is a unique no for a given SIM

cell id and area id are GSM network specific details which can be used to track the mobile location.

I have already given up in finding my mobile but i hope at least police will be able to track the guy or the gang who did this which is finally good for the Country.

IMHO even the Gardian free edition is good for general use.

[1]http://www.guardian-mobile.com

Thursday, January 22, 2009

Its time to Stop Forwarding junk mails

With the fast growth of internet facilities and lot of free space given in mail accounts.Now People used to forward some mails that contain

Wishes , Beautiful Pictures ,etc....
They are using it as a good way of keeping touch with friends.

But if we see the size of those mails with attachments.and the way they are transfered between people its a great waste of resources.each and every mail we send use the processing power of every node in its path.Processing time of those nodes means power.

I think its time for us to sit back and think about the big process happening behind before we forward a another mail.

according to the Butterfly effect "Small variations of the initial condition of a dynamical system may produce large variations in the long term behavior of the system."

Lets make that Small variation for the betterment of the globe.
So lets try do minimize the unwanted data transfers through networks.And save some resources of the globe.

As a conclusion i remember a great saying "Earth has more than enough resources to fulfill mans needs but not his unlimited desires"

Tuesday, January 6, 2009

Apache Synapse Spring Mediator -(Feel the power of Apache Synapse)

Apache Synapse is a Light weight ESB from Apache which supports XML webservies. And also it is a very extendible project[1].

Massage mediation is a core mode in Synapse. When in massage mediation mode Synapse act as a transparent proxy for clients. And also if Synapse receives a massage that does not belongs to any of the proxy services it will go through massage mediation[2] defined.

Synapse has Components named as Mediators witch can perform mediation action on the Message(MessageContext).Mediators get the full control over the message that is passing through it. Mediator can modify and inspect message or do something by looking at the message body. Since Synapse supports writing custom mediators the possibilities of usage of Mediators become unlimited.

Synapse Spring Mediator is a Mediator which enables Spring users to expose their Spring Beans as Mediators in Synapse.


Following is a example of how to use Spring Mediator

First thing we have to do is write a simple Bean that extends org.apache.synapse.mediators.AbstractMediator (AbstractMediator class can be found in Synapse core).


Eg:

package demo.hello;

import .....

public class HelloMediator extends AbstractMediator {


private String name;

public void setName(String name){

this.name=name;

}

public String getName(){

return name;

}

public boolean mediate(MessageContext synCtx) {

System.out.println(“Messsage Id: ”+ synCtx.getMessageID());

System.out.println(“Hello ”+name);


return true;

}

}


then put that class in to a Jar file and put it in the lib directory in Synapse installation directory(SYNAPSE_HOME).

Then we should write a xml file for that Spring Bean

ex: springsample.xml



and then we must write a SynapseConfiguration to use this. For that edit the Synapse.xml file in SYNAPSE_HOME/repository/conf/ as follows






put the springsample.xml in repository/conf/ directory of the Synapse installation directory.

Then Start the Synapse and try sending a message through synapse (you can use the client and server that is used in Synapse sample 0).

Above example shows how we can use the Synapse Spring Mediator to make Spring Bean a Mediator.


Now lets Look at the Power of this usage of Spring mediator. Since a mediator gives the total control over the message passing through it and the Spring supports Inject dependencies to the Spring bean using a XML configuration file,using a Spring Bean as a Mediator gives Spring users unlimited degree of freedom over the Message passing through the Spring bean.


One possibility came across my mind is Spring Users can use the Spring Mediator as a Bridge to pass a the Message to their own project.Using the inversion of control capability given by Spring .Spring users can make that very effective and flexible.




As image shows Spring Bean Mediator can be used as a bridge to pass the Messsage context to a project,And using the Spring XML file user can define appropriate dependencies that can be used to process the message without changing the code or changing Synapse Configuration. The main advantage here is Spring users do not have to have the knowledge on Synapse configuration. Once they have configure the synapse to use the the Spring Mediator they can use and change the Spring XML file to inject dependencies that can be used to use/change the message context.

And also I think Spring Mediator can be used to make a Wrapper Software project around synapse(As the same way synapse is wrapped around axis2) and Spring XML file can be used as a configuration file for that software.


[1] -http://synapse.apache.org/Synapse_Extending.html

[2]-http://synapse.apache.org/Synapse_Configuration_Language.html