Παρασκευή 15 Οκτωβρίου 2010

Ubuntu Linux Enable Compiz Fusion

In order to make Ubuntu Linux look cool, you need to install the compiz fusion plugins.
Open a new terminal window and type:


sudo apt-get install compiz compiz-plugins compiz-gnome compiz-core emerald compiz-fusion-plugins-main compiz-fusion-plugins-extra fusion-icon compizconfig-settings-manager


When the installation is complete all the effects are available under the System->Preferences->CompizConf Settings Manager.

Τρίτη 3 Αυγούστου 2010

PosterGenius for Mac has entered private beta testing


PosterGenius™, the first application specifically designed for the creation of scientific posters, has been developed to be compatible with Macs and Mac OS X.

PosterGenius for Mac has now entered private beta testing. If you would like to participate, click here.

Τετάρτη 10 Μαρτίου 2010

Apache HttpClient 4.x Monitoring File Upload

There are quite a few articles on the web which are implementing the monitoring of a file upload with HttpClient 3.x. Since 4.0 release the API has been changed and HttpClient component is incompatible with the previous versions. Digging a bit into the source code i came up with the following implementation.

In order to capture the file upload progress there is a need for controlling the data send over the output stream.

Ex.
FileBody fooBin = new FileBody(new File("/foo.png"));

The class FileBody contains a method writeTo(OutputStream out) which is responsible for the byte transfer over the output stream. In order to capture the bytes send, the FileBody class should be inherited and the writeTo method should be overridden as shown below.

Simple listener:

public interface IFileUploadProgressListener{
public void blockSend(int blockSize);
}

Inherited FilePart Class:

@Override
public void writeTo(OutputStream out) throws IOException {
if (out == null) {
throw new IllegalArgumentException("Output stream may not be null");
}
InputStream in = new FileInputStream(getFile());
try {
byte[] tmp = new byte[4096];
int l;
while ((l = in.read(tmp)) != -1) {
out.write(tmp, 0, l);
if(this.progressListener != null){
this.progressListener.blockSend(4096);
}

}
out.flush();
} finally {
in.close();
}
}


In this example i use a simple interface as a progress listener. When a block of bytes is sent over the output stream the listener informs any class which implements it.