Wednesday, February 17, 2010

Governance Registry- Remote Client part-1

Governance Registry is a WSO2 product which use to store and govern the data.

Here I am going to talk about creating a remote client for the WSO2 Governance Registry using Remote API.

For this I use the wso2 Governance Registry v3.03 which you can download from here.
Also it must be install Apache ANT in your machine.

In this post I am describe how to run the sample. Later I'll show how to what are the functions provide by the API and how to use them.
(sample path :- wso2greg-3.0.3/samples/filesampleutils)

First we have to set some of the jars which need to run the sample.

Jars you need to run the sample
-----------------------------------
1.jaxen-1.1.1. jar( http://www.java2s.com/Code/JarDownload/jaxen-1.1.1.jar.zip)
2.abdera -jars 0.4.0 (http://abdera.apache.org/)
3.commons httpclient 3.0.1 jar(http://www.java2s.com/Code/JarDownload/commons-httpclient-3.0.1.jar.zip)
4.commons-codec-1.3 jar (http://www.java2s.com/Code/JarDownload/commons-codec-1.3.jar.zip)
5.axiom-impl-1.2.5 jar(http://www.java2s.com/Code/JarDownload/axiom-impl-1.2.5.jar.zip)
6.axiom-api-1.2.5 jar(http://www.java2s.com/Code/JarDownload/axiom-api-1.2.5.jar.zip)
7.org.wso2.carbon.registry.core-2.0.2.jar (Find at GREG_HOME\webapps\ROOT\WEB-INF\plugins\common folder)
8.axis2-transport-base-1.0.0.wso2v2.jar(Find at GREG_HOME\webapps\ROOT\WEB-INF\plugins\common folder)

Copy above jars to the bin directory in the HOME.

Now you are ready to run the sample.

change directory to the samples/filesampleutils/src

In this example we were given two functionalities.
1. To upload a file of collection to the Registry
2. Download a file or a collection from the Registry.

To upload a file we need to execute ant upload

Then there will be some details to fill regarding the upload,
1. Keystore file path : Provide HOME/resources/security/client-truststore.jks
2. Registry URL : Provide "https://localhost:9443/registry" this is the URL which registry cab be accessed.
3. Username : user name of login to registry(default it's "admin")
4. Password : password of login to registry(default it's "admin")
5. From path : this is the path where upload file/directory is.
(eg :- /home/example/Sample.txt or /home/example/)
6. To path : this is the path where we going to save in the repository (eg :- /)

After fill these you can log on to https://localhost:9443/carbon and select the Browse from the Resources and you will appear your uploaded file/directory in there.

To upload a file we need to execute ant download

Then there will be some details to fill regarding the download,
1. Keystore file path : Provide HOME/resources/security/client-truststore.jks
2. Registry URL : Provide "https://localhost:9443/registry" this is the URL which registry cab be accessed.
3. Username : user name of login to registry(default it's "admin")
4. Password : password of login to registry(default it's "admin")
5. From path : this is the path where download file/directory from.
(eg :- /C1/C2)
6. To path : this is the path where we going to save download file/directory in the local disk.
(eg :- /home/example/)

Now you can see the file or directory you downloaded at the To path.

Thursday, February 11, 2010

Install D-link DWA120 in Ubuntu


This problem I faced with installing D-Link DWA 120 wifi adaptor to my Ubuntu machine. Yasith aiya found a method to do it.

For this you need the WinXp driver which include in the CD you get.
First we need to install ndiswrapper to install this.

1. Plug the device

2. Then type the following commands on Terminal
sudo apt-get install update
sudo apt-get install ndiswrapper-common
sudo apt-get install ndiswrapper-utils1.9
To see whether ndiswrapper install correctly we can type "ndiswrapper"

3. Now copy the WinXp driver to the local disk

4. Change directory of Terminal to driver folder which include .inf file and type followings
sudo ndiswrapper -i X.inf
sudo ndiswrapper -m
sudo modprobe ndiswrapper

Now you can see the device detected. (Try iwconfig)

Wednesday, January 27, 2010

Web Services using AXIS2

In this session I was trying to deploy a web service using Apache Axis2 in eclipse IDE.
Apache Axis2 can be downloaded from here. Here I used Axis2 1.5.1 which is the recently released version.
Apache tomcat server can be downloaded from here. Here I am using the newer version of Apache tomcat 6.0.16.
Eclipse IDE for java ee developers can be downloaded from here. It is a must to use eclipse j2ee platform here.
Then we can start our work......

Start eclipse.
  1. Set axis2 preference. navigate Window-->Preferences-->Web Services-->Axis2 Preferences-->Axis2 Runtime. Then set the Axis2 runtime location of downloaded Axis2 bin folder location. Click Ok.


  2. Then we must setup the web server which we use to deploy from. To do this....... right click on the Project Explorer pan-->New-->Other-->Server-->Server-->Next--> Select apache tomcat server according to the tomcat version. Click finish.



  3. Now its time to start the project..... Right click on the Project Explorer pan-->New-->Other-->Dynamic Web Project-->Next -->Name the project-->Click Finish.


  4. Next we create a java package in the previously created project by right click on the project name in the Project Explorer pan. This is the package which include our web service.
  5. Create a class in the package created on previous step and write the program in it.
  6. Right click on the class name in the Project Explorer pan-->Web Services-->Create Web Service.
  7. In the configuration set Web Service Runtime as Apache Axis2 and click Finish.
  8. Now the Web Service will create and deploy by the Apache tomcat server.
  9. You can see whether this work or not by visit localhost:8080/(Project name)-->Services Then it will show your public methods under your java class file name in which we implement the web service.
  10. If you want to see the wsdl file just click on the java class file name.





I will present how to create a client program which uses this web service later......

Thursday, December 24, 2009

Last month windows crashed on my machine and I recover it using the recovery DVD. After that windows gave me an extra option to fry eggs. Now if I am using my machine on day, I can use this facility. (I am using WINDOWS VISTA)


If I am working in day its heating up to almost 50-60 degree though I didn't pressure it. Also starting time of windows after I type my password is about 5min average. Another fault I have on my machine is that it works without my commands........ I mean that it is shown that the RAM 70% and CPU 50% after started and stabilized. So I thought it would be great if I can use either windows 7 or UBUNTU 9.10.
As a start up I install UBUNTU. What it shows amazes me................... that my battery is broken. Now my battery can store max 14.2Wh charge though the original battery can store max 47.2Wh. Now its been one and half years since I bought this machine. Can somebody tell me is it the lifetime of the battery????
Any way I thought I should buy a battery to remain cool other parts.
Prices: Compaq presario V3000 battery 4400mAh
ebay- $37+$15
hp-$120
hp-$112 for extended battery 8800mAh
Anyway I will see whether I can buy it in Unity cheaper than web.

Thursday, April 23, 2009

Making my Future

As I am a Learner a goal that I achieved lately is approving my Google Summer of Code project DERBY test and fix of Apache Software Foundation. So I am improving my coding knowledge on databases and its functionality. Try my best to complete it in success.

Thursday, April 2, 2009

Apache Derby- fixing bugs

For fixing bugs I first choice DERBY-3892 because it has become a major problem for the Derby development and it’s about a delay when because of the query hangs, so I did a analysis on it and here is the report I made out(this is a copy of what I send to mailing list),
Rows Insertion time(s) Querying time(s)
100 2.281 2.346
1000 3.31 3.388
1500 4.497 4.575
2000 7.717 7.807
5000 16.064 16.143
10000 23.711 23.797
20000 37.76 37.926
50000 91.748 92.086
100000 185.492 185.98

I check the two insertion separately (Messaged User,Values )

When only data inserted to Messaged_user(insert to values table removed from
the code) table only it took 80.926s to insertion and 80.992s for querying.

When only data inserted to Values(insert to Messaged_User table removed from
the code) table only it took 77.054s to insertion and 77.16s for querying.

sum of the two in separate insertions=157.98s
sum of the two in separate querying=157.98s

Thats 30s different from what i got when the two insertions are in same
coding.
I try another time with two insertion at the same time. Amazingly i got
141.721s for insertion and 142.21s for querying. Try for another gave
161.523s for insertion and 162.014s for querying.

So i decided that bug must be on the "insertion"
Next i include the Statement class for execution inside the loop
Insted of,
PreparedStatement ps = con.prepareStatement
("INSERT INTO Messaged_Users VALUES (?, ?, DEFAULT,
DEFAULT)");
for (i=0; i<100000; i++) {
ps.setString(1, ""+i);
ps.setString(2, "User" + i);
ps.executeUpdate();
}
I used,
Statement stmt=con.createStatement();
for (i=0; i<100000; i++) {
stmt.executeUpdate("INSERT INTO Users VALUES ('"+i+"',
'Eranda')");
}
As a test, But I waited 15s for over the insertion and querying and stop
the process.
For further information about DERBY-3892
visit-https://issues.apache.org/jira/browse/DERBY-3892

My Attitude on Open Source:

Sri Lanka is a 3rd world country that is suffering from poverty. So the people cannot spend much money on software for their applications. As a solution we can use open source software. As a programmer contribution to a world class software design is a dream for me. Now I have a chance for making my dream a truth with the Open Source. Because in Open Source software we can get source code out of it and make modification on it so that much more reliable. It make the product a good one as because more experts on dfferent areas contributing their knowledge on it. Also a student like me can read the source code and learn how the things inside of a software works.

All that things make my first choice "Open Source" software rather than going for pirate copy of software. In my machine i use Ubuntu for all the programming works, Apache tomcat 6.016, Glassfish, and newly i introduce my machine Apache Derby. Last year I use Red Hat and Fedora for "C-compiling". So one of my future ambition is to work on a such project.