I made a change in the blogger configuration to ease the later work when blogging. It is possible that older entries are not correctly formatted.

Thursday 2 September 2010

Maven Repository in PHP or Virutal machine for Maven Repository

Since I would like to put my software in a maven repository, and since it is difficult to find Java/JSP enabled providers in Europe. I was wondering whether I should not try to reimplement the archiva project directory with PHP or perhaps Ruby.

After having a look, it does seem quite a lot of dirty work. But it is probably not too complex to perform. But is it worth it ?

Monday 30 August 2010

Hosting and Server types

I have been searching for diverse information lately on Servers and possible hosting of my own stuff. I found the web page: Hotsuche.de. It is a typical site to look for the currently available offers in the hosting and servers.

They present the offers according to the following category, and quite extensive search formular to define the kind of offers one might prefer.

I give here a summary of these categories:

  • domains
  • Web hosting
  • dedicated server
  • server housing
  • Buy Server
  • Virtual server
  • Game server
  • Internet access
  • Shops
  • SSL Certificates
  • Test accounts

I discovered the possibility of server housing, i.e you buy a server and you have some company keep it in its computer center. I have to take a look at the prices. But I suppose that this is not cheaper as using a server from the company. You can also have Game servers or buy servers. This sounds also interesting.

Where do I get a cheap Java/JSP Server ?

Thursday 10 June 2010

ac - user connect time

I just discovered a new command that I did not know: ac. It gives the connect times of users. This may prove useful.

Vendor Lock-In

Here is an interesting blog entry on vendor lock-in.

It lists three types of vendor lock-ins each based on some component of the application: platform, data or tools.

Postgresql Info Website

I just discovered this postgresql info website: http://www.postgresonline.com/. I guess I will learn quite a lot from this website.

I learnt that the new version of postgres is nearly out, since the version beta 2 is out. It should not be long before the 9.0 comes out.

It might also be good to follow: http://www.planetpostgresql.org/.

Thursday 20 May 2010

Quo Vadis with Software Patent

After I read this news, I had to sit: German High court ruled in favor of software patents.. Unfortunately, this is not an April joke. However, the strange thing is that it does seem like there is already a patent for the technology provided, and that even if it should be obvious that the technology described in the patent existed already at the time of the patent submission.

Privacy on Facebook

Thanks to a friend, I heard about the site: http://www.reclaimprivacy.org. It contains certain useful information on privacy settings onf Facebook. For instance, there is an interesting page on the privacy on facebook (hosted by the New York Times).

In order to check your own privacy on Facebook, you can follow the instructions on the website:

This website provides an independent and open tool for scanning your Facebook privacy settings. The source code and its development will always remain open and transparent.

Note: we are still working on privacy scans for your photos and status updates. The tool does not check these yet, so stay tuned for updates!

  1. 1. Drag this link to your web browser bookmarks bar: Scan for Privacy
  2. 2. Go to your Facebook privacy settings and then click that bookmark once you are on Facebook.
  3. 3. You will see a series of privacy scans that inspect your privacy settings and warn you about settings that might be unexpectedly public.
  4. 4. Follow us on Facebook to hear about the latest updates.

Monday 10 May 2010

New Advances in Neural Networks

There is a great google talk about recent advances in pattern recognition in Neural Network. It is given by Goeff Hinton. The title of the talk is Recent Developments in Deep Learning.

Thursday 6 May 2010

AXIOM - an Apache Stax Parser

I will have to take a look at Axiom which provides a Stax implementation to access XML info sets. It was developed for Axis 2. But it can be used independantly.

Apache Tika - Content and Metadata Extraction in Java

Apache Tika is an useful tool to extract text and metadata from a number of formats.

For example, you have a document pdf, doc,... on the web from which you wish to extract some part. Then you can use tika to extract some part. For this you can use tika:

curl http:urltodoc/.../document.pdf | java -jar tika-app/target/tika-app-0.7.jar --text
produces the text of the document. Other options exist to return an html, an xhtml or only the metadata of the document.

Maven Integration

As for other maven projects, you can specify the dependency in the pom. Note however, that depending on your needs, you might want to specify one of these ( mostly quoted from this page):

  • tika-core/target/tika-core-0.7.jar Tika core library. Contains the core interfaces and classes of Tika, but none of the parser implementations. Depends only on Java 5.
  • tika-parsers/target/tika-parsers-0.7.jar Tika parsers. Collection of classes that implement the Tika Parser interface based on various external parser libraries.
  • tika-app/target/tika-app-0.7.jar Tika application. Combines the above libraries and all the external parser libraries into a single runnable jar with a GUI and a command line interface.
  • tika-bundle/target/tika-bundle-0.7.jar Tika bundle. An OSGi bundle that includes everything you need to use all Tika functionality in an OSGi environment.

<dependency>
  <groupId>org.apache.tika</groupId>
  <artifactId>tika-core</artifactId>
  <version>0.7</version>
</dependency>
If you want to use Tika to parse documents (instead of simply detecting document types, etc.), you'll want to depend on tika-parsers instead:
<dependency>
  <groupId>org.apache.tika</groupId>
  <artifactId>tika-parsers</artifactId>
  <version>0.7</version>
</dependency>

Wednesday 5 May 2010

IBM FileNet P8 Platform

Disclaimer: This entry is not complete and will be probably be finished later, since some information needs to be checked. The goal is to have a short summary of the documentation I found.

The IBM FileNet P8 Platform is a platform providing enterprise content management. Documentation can be found on the IBM website at this place. A FileNet P8 System Overview can be found there. The source of most of the information for this entry comes from this document.

  • content management
  • business objects
  • Lifecycles
  • Properties
  • Events and subscription
  • classification
  • entry templates
  • publishing
  • content storage
  • content caching
  • import and export
  • search
  • versioning
  • process management
  • extern application integration
  • form management
  • record Management (Email management)
  • system management
  • application development and deployment
  • scalability
  • high availability
  • disaster recovery
  • accessability
  • security
  • internationalization (i18n)

FileNet uses XML and Java2 Platform, Enterprise Edition (J2EE), as well as mainly the following protocols: Lightweight Direct Access Protocol (LDAP), Hypertext Transport Protocol (HTTP), and SOAP.

Content Management

Business Objects

Lifecycles

Properties

Events and subscription

The platform provides an event framework so as to push to subscribers the given event of the system.

Classification

The FileNet platform provides the infrastructure for different kind of classification of the resources. This classification can either be performed manually but also automatically using specific tools.

Entry Templates

Entry templates provides means of creating objects in a more uniform manner.

Publishing

The platform also provides means of publishing the content stored.

Content Storage

Content Caching

Import and Export

Search

Versioning

The FileNet application provides the tools to perform a versioning of the resource stored in the system.

Process Management

Extern Application Integration

The platform can be integrated in other existing applications such as: Microsoft Office and SAP R/3 and Sharepoint.

Form Management

The documentation of FileNet says that the application provides powerful form creation and management tools.

Record Management (Email management)

System management

Application Development and Deployment

Scalability

One interesting aspect of the FileNet P8 Platform is that it seems to be designed considering scalability issues and techniques. It provides for diverse components horizontal scalability solutions (like computer farms) or vertically (i.e multiple instances of an application can be run in parallel.

Accessability

Accessability is an issuse for enterprise software in order to make sure that every one can use the software. The software is tested according to the Section 508 Compliance based on Electronic and Information Technology Accessibility Standards, published by the U.S. Access Board on December 21, 2000, at 36 CFR Part 1194.. This includes for example key traversal and access.

Architecture

FileNet Architecture Overview The preceding picture shows the architecture of FileNet, it is taken from the document cited earlier. In addition to this overall picture it should be noted that FileNet provides both a Java and .Net API, although the java API seems to be the one providing the most functionality.

Content Engine

The content engine is the component taking care of the management of the content. It provides all the necessary functionalities, for example secure access, caching, indexing (also full text), search, classification, versioning, life cycles....

The access is either provides through a Java or .Net API or using the Content Engine Web Services. A particular mode when using Java is to use the EJB Means of transport.

Process Engine

The process engine provides a number of components.

  • Process Analyzer (which is a OLAP component)
  • Process Simulator to test scenarios
  • Business Process Framework

Application Engine

Workspace XT - The Graphical Interface

Rendition Engine

Rendition Engine can be used to convert documents to various formats, for example the usual Office formats (Word, Excel, PowerPoint) as well as to PDF or HTML. Multiple Rendition Engines can also be used in order to scale the document conversion process.

Administrative Components

The platform provides a number of adminstrative components: the dashboard, the system usage reporter, the system monitor

Tuesday 4 May 2010

UIMA - Unstructured Information Management Architecture

Disclaimer: This entry is not complete and will be finished later, since some information needs to be checked.

The UIMA (Unstructured Information Management Architecture) is a project which was first created by IBM, but which is now one of the top-level project of the Apache Software Foundation. It provides an architecture to annotate a unstructured information with the help of a set of annotators and analysis engines which can be combined and aggregated.

In the following sections, I will introduce the main elements which allow the understanding of the UIMA infrastructure.

CAS - Common Analysis Structure

The main structure in the UIMA architecture is the CAS (aka. Common Analysis Structure). Note that I had some difficulties finding what it means, but I finally found it in the glossary, which should be read at first because I even in the overview there was no explanation as to what a CAS is.

A CAS is the structure manipulated by the annotators and annotation engines.

Analysis Engines

The UIMA architecture provides the idea of analysis engines which take a CAS View (i.e some annotation structure representing a view of the data) and return a .

Annotators

The glossary of the UIMA documentation defines annotators as:

A software component that implements the UIMA annotator interface. Annotators are implemented to produce and record annotations over regions of an artifact (e.g., text document, audio, and video).
They represent the starting point for the analysis engine.

Indexing

One of the main interest of the UIMA architecture is that it provides a standard interface to define the indexing of the CAS and their views. However, I still need to clear things up here.

PEAR

A PEAR is an archive file packaging the code, descriptor files and other resources required to install and run a UIMA component in another environments. The UIMA SDK provides tools to create such PEAR. Note that the PEAR acronym is not defined in the documentation either.

New Top Level Apache Projects

In an announcement per mail, the Apache Software Foundation announced a number of new top level projects.

Apache Traffic Server is a richly-featured, fast, scalable, and extensible HTTP/1.1 compliant caching proxy server.

Apache Mahout provides scalable implementations of machine learning algorithms on top of Apache Hadoop and other technologies.

Apache Tika is an embeddable, lightweight toolkit for content detection, and analysis.

Apache Nutch is a highly-modular, Web searching engine based on Lucene Java with added Web-specifics, such as a crawler, a link-graph database, and parsers for HTML and other document formats.

Apache Avro is a fast data serialization system that includes rich and dynamic schemas in all its processing.

Apache HBase is a distributed database modeled after Google's Bigtable.

Apache UIMA (Unstructured Information Management Architecture) is a framework for analyzing unstructured information, such as natural language text.

Apache Cassandra ( an advanced, second-generation “NoSQL” distributed data store that has a shared-nothing architecture)

Apache Subversion a source code management system very often used in enterprise and open source projects.

Apache Click is a modern Java EE Web application framework that provides a natural, rich client style programming model.

Apache Shindig is an OpenSocial container and helps you to start hosting OpenSocial apps quickly by providing the code to render gadgets, proxy requests, and handle REST and RPC requests.

I believe I am becoming somewhat an apache fan boy ;-).

Monday 3 May 2010

OSGi

OSGi (used to be "Open Services Gateway initiative") is a standard to define a software platform infrastructure for java. The goal is to have the infrastructure to deploy modularised applications and services with a comnponent model (called Bundles or services). The components can be managed using a service registry. They can be loaded, started and stopped.

The OSGi standard uses metadata found in the Jar file Manifests, in order to load the bundles. In particular, the manifests specifies the classes exported and imported by the bundle. In that way, it is possible to use, or hide conflicting classes in a bundle and not export it. Other bundles may use the classes exported by other bundles.

Bundles

Bundles are jar files with a corresponding entries in the manifest. The following example shows the manifest of a bundle requiring the package org.eclipse.ui.

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: My Yellow World Example
Bundle-SymbolicName: de.desprofundis.example; singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: de.desprofundis.example.Activator
Require-Bundle: org.eclipse.ui,
  org.eclipse.core.runtime
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6

Note the "Require-Bundle", entry which lists the packages which are required by this bundle. The OSGi container is responsible for checking whether the dependencies are satisfied. Another important information is also here the Bundle-Activator, which is the class in charge of the activation of the bundle (as well as its shutting down when needed.

Services

In addition to the dependency management and version hiding, the OSGi framework provides also a registry for services. Moreover, services can be injected in to some other bundle. A tutorial by Lars Vogel presents their use succintly.

Zen Coding

Zen Coding is an utility to generate simple HTML skeleton structures using a path like expression with some syntactic enhancement. From the demos, it is really quite impressive, because in this way one can generate quite quickly complex HTML structures.

I read the entry on slashdot.org and then followed the link to this blog.

Though I still need to try it. I am amazed. I have to make it work in eclipse and emacs (aswell as perhaps vi).

Thursday 29 April 2010

Javascript Performance Talk

I watched the javascript performance talk from Nicholas C. Zakas at Google Tech Talks: Nicholas C. Zakas: Speed Up Your JavaScript.

  • Scope Management
  • Loop optimization
  • About HTMLCollection Live objects
  • Document Fragments - postponing reflow

Scope Management

The tip given to improve efficiency is to use local variables, because variables which are in the local scope are accessed first. Every time a global or a variable from a prototype or a dot object variable is accessed twice. Use a local variable.

Another issue related to the scope aspect is that using functions and closures comes with a certain cost.

Loops Optimization

Loops can be optimized in different ways, when avoiding unnecessary work.

About HTMLCollection Live objects

The presentation explains that the collection returned by methods such as: .getElementsByTagName, ... return HTMLCollection objects which remain 'live', that is they get updated. A typical example is the following loop:

var divs = document.getElementsByTagName('div');

for (var i = 0; i< divs.length; i++){
var div = document.createElement('div');
document.body.append(div);
}
The collection in divs is an HTMLCollection. The body of the loops goes over the loops and adds a div for every object in the collection. But since new objects are added to the loop every time one goes through the loops, the loops never ends !!!!!

DocumentFragment - postponing reflow

Reflow occurs when the the size of the elements on the page are recalculated. To improve performance it is useful to minimize the number of reflows.

In general, Nicholas C. Zakas explained that reflow happens at five particular moments in browsers:

  • Page load
  • browser window resize
  • adding and removing elements
  • setting style attribute of elements
  • (sometimes) accessing the style elements of the nodes

To prevent useless reflows, one can use a document fragment in order to create a quite complete element as a document fragment and then add it to the DOM. In this way, reflow is only performed when the element is added to the page.

To minimize the access to the style attributes of elements, a better way to perform that is to change the class of the element, i.e: use .className instead of .style.

Wednesday 28 April 2010

Behavior Driven Development (aka. BDD) using EasyB

One more term for "test driven development", behaviour driven development. The idea behind the change in term is to highlight, that the principle underlying behind this style of development is more a design methodology as a test methodology.

To illustrate the purpose, and methodology, I will present it here using easyb.

The main idea is to write the specification as text, and then to replace the text using groovy code. Easyb provides two types of tests: specifications and stories.

I first describe the specification by giving an example.

before "initialize the queue for each spec", {
  queue = new Queue()
}

it "should dequeue gives item just enqueued", {
  queue.enqueue(2)
  queue.dequeue().shouldBe(2)
}
it "should throw an exception when null is enqueued", {
  ensureThrows(RuntimeException){
   queue.enqueue(null)
  }
}

easyb uses a number of keywords and methods. First of all, the keyword before for the code to be used when setting the test environment at the beginning. In this case a queue is created. The next important keyword is "it" at the beginning of certain lines. It indicates that this is a specification. It is followed by a text describing the specification. Finally, after the description some groovy code is included between "{" and "}".

Different methods belong to the easyb specification language: "shouldBe" and "ensureThrows". The first one checks that the result of the emthod to which it is applied returns a given value, whereas the second one verifyies that an exception as been thrown.

Maven Configuration

As usual, I find very useful to have a template of what I need in a maven pom to use somekind of framework. I haven't tested that yet. I still find that useful:

<project>
  ...
  <repositories>
   <repository>
     <id>easyb</id>
     <url>http://www.easyb.org/maven2/</url>
    </repository>
   </repositories>
   <pluginRepositories>
    <pluginRepository>
     <id>easyb</id>
     <url>http://www.easyb.org/maven2/</url>
    </pluginRepository>
   </pluginRepositories>
   ...
  </project>

Easyb clone for javascript

I also found the following code to perform bdd in javascript: JavaScript BDD framework in less than 200 lines.

Tuesday 27 April 2010

A site for Javascript library

As I was looking for a Java based implementation of javascript. I fell upon the following site: http://javascriptlibraries.com/ which will probably be useful.

Learning Python 3.0

I am learning python 3.0. There are a few reasons for this. For instance, there is a suggestion from the 'Pragmatic Programmer' book I bought lately. This other thing is that it would make it easier to cooperate with my brother and to perform more useful stuff for and with him. I am also using Mark Lutz: Learning Python (Fourth Edition from Oreilly).

So I installed pyhton 3.0 on my machine.

$> ./configure
$> su
$> make altinstall
And here it is:
$ /usr/local/bin/python3.0
Python 3.0 (r30:67503, Apr 27 2010, 01:32:05)
[GCC 4.4.3 20100127 (Red Hat 4.4.3-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

I will probably need to make a few tests that everything works.

Friday 23 April 2010

Mockito - basics

This entry gives simple methods on how to use mockito.

Maven configuration

To add mockito-core to your configuration, update your dependencies with:

<!-- needs extra dependencies: objenesis & hamcrest -->
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.8.1</version>

In order to add the complete mockito framework, i.e. mockito-all, update your dependencies with

<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.1</version>

Of course if the mock code is only found in unit tests, then you might want to add:

<scope>test<scope>
to your pom.xml

Use of Mocks to verify interaction (Spying)

The following example is adapted from the mockito documentation

// the staic import allows the direct use of the help methods: mock and verify
import static org.mockito.Mockito.*;

// create a mock of a map
List mockedMap = mock(Map.class);

//using mock object
mockedMap.put("key", "value");
mockedMap.clear();
//verification
verify(mockedMap).put("key","value");
verify(mockedMap).clear();

Stubbing - Or Have your objects mock others

While the previous section was used to verify that some operation did occur on a specific object. In some cases, you may not wish to initialize completely a complex object. In such a case, you can use mockito to perform stubbing, i.e. mockito provides an interface, so that the object returns a specific value, when a call to a method is performed.

For instance, it is possible to use the mocking framework to return a given result for certain parameters:

when(mockedMap.get("key")).thenReturn("first");
when(mockedList.get(5)).thenThrow(new RuntimeException());

Content delivery network

Content delivery network are a cool thing though I am not sure how secure is such an approach. I will have to take a closer look.

In particular in the case of using dojo, a few issues have to be taken into account.

Interesting seems that google provides an api for asynchonuous loading.

Browser based javascript library loading

Wouldn't it be interesting to have browser taking care of the javascript frameworks library loading such as dojo, ext, ... in the version corresponding to some specification in the HTML file.

Dojo Toolkit - Basics

This is a high level overview of the dojo toolkit.

  • Function called on load
  • package framework
  • a DOM element retrieval mechanism
  • a number of Widgets
  • Helper Methods
  • Dojo Array Methods
  • dojo.connect - Event mechanism
  • Parsing, formatting and validation of numbers and dates
  • Ajax request tools
  • An history and bookmarking mechanism
  • Event System tools
  • Animation tools
  • I18n tools (Internationalization)

Loading the dojo code

The code of dojo can be loaded from http://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/dojo.xd.js. I would like to try loading it from the web server.

Function called on load

As for other web frameworks, you can have different function called on load:

dojo.addOnLoad(funtion( // code to perform on load ));

package framework

The dojo toolkit provides a package mechanism, the code is used in the following way:

dojo.require('dojo.fx');
loads the dojo.fx package.

a DOM element retrieval mechanism

Dojo provides a number of methods to retrieve elements of the DOM document. For instance, dojo.byId('myId'); retrieves the element with the id 'myId' just as document.getElementById would.

Just as other frameworks dojo provides also a query mechanism.

From the dojo documentation:

// all <h3> elements
dojo.query('h3')
// all <h3> elements which are first-child of their parent node
dojo.query('h3:first-child')
// a node with id="main"
dojo.query('#main')
// all <h3> elements within a node with id="main"
dojo.query('#main h3')
// a <div> with an id="main"
dojo.query('div#main')
// all <h3> elements within a div with id="main"
dojo.query('div#main h3')
// all <h3> elements that are immediate children of a <div>, within node with id="main"
dojo.query('#main div > h3')
// all nodes with class="foo"
dojo.query('.foo')
// all nodes with classes "foo" and "bar"
dojo.query('.foo.bar')
// all <h3> elements that are immediate children of a node with id="main"
dojo.query('#main > h3')

A number of Widgets

The dojo toolkit provides a number of widgets. These can be retrieved by the dijit.byId() method.

Dojo Array Methods

Dojo provides some other useful methods for example: dojo.forEach(). A similar method can be used on the resuklt of a dojo.query().

Dojo also provides filter and map functions. filters an array and returns all the elements verifying a given property. The map function applies some function on all the elements of an array and returns a new array of new values.

The functions dojo.some() and dojo.every() checking that some property is true for some, respectively all the elements of the array

dojo.connect - Event mechanism

The dojo toolkit provides the dojo.connect methods which allows to connect some event to a given event.

Parsing, formatting and validation of numbers and dates

Ajax request tools

An history and bookmarking mechanism

Event System tools

Animation tools

I18n tools (Internationalization)

Java Web Framework Comparison

Here is an useful link for comparing the different existing Java web frameworks.

In particular, "java Web Frameworks sweet spots" is quite interesting.

I learnt about a framework I yet had never heard of: RIFE. The developer, who was asked in the article, seems to be a little too subjective for my taste.

Thursday 22 April 2010

Flex - generating Flex on Java Project

I collected the following from The Flex On Java Book.

$workspace > mvn archetype:create -DarchetypeGroupId=org.foj -DarchetypeArtifactId=flex-mojos-archetype -DarchetypeVersion=1.0-SNAPSHOT -DgroupId=org.foj -DartifactId=flex-bugs-ria -DremoteRepositories=http://flexonjava.googlecode.com/svn/repository

However, I still need to solve some dependency problems. In particular I needed to install the following packages:

  • com.adobe.flex.compiler:asdoc:zip:template:3.2.0.3958
  • org.graniteds:granite-generator:jar:1.1.0
  • com.adobe.flex:compiler:pom:4.0.0.7219

But this is solved by using the correct repository by adding
<repositories>
   ...
    <repository>
       <id>flexcompiler-repo</id>
       <url>http://repository.sonatype.org/content/groups/flexgroup/</url>
    </repository>
</repositories>

However, after running:

$flex-bugs-ria >mvn package
it runs quite a while with an error. It seems it just could not start the flash player. So it may be all good ;-).

It returns successful and the generated swf can be displayed in the browser

$flex-bugs-ria >mvn package-Dmaven.test.skip=true

Next step: do a more complex flex example.

Mock Frameworks

In this entry, I present a summary of the features of mock frameworks. In particular, I looked at two different mock frameworks: easyMock (MIT Licence), Mockito (Apache Licence) and JMock (probably equivalent to BSD, MIT or Apache but I am not completely sure). The Mockito framework seems to be trying to extend even more the features of the easy mock.

Usual Use Cases of Mock Objects

I adapted the following list from a wikipedia entry. It shows the cases where it a good practice to use mocks.

  • results of method do not follow a very deterministic pattern
  • The mock can simulate a complex object or an object difficult to obtain, e.g a given state in a GUI
  • A state of a system which is expensive to create, resource, processing, power...
  • The object has not yet been provided, perhaps by an other team

Here are some useful posts on mocks:

I notice this post is not at all too clean. It needs to explain the purpose of spying and the difference there is with mock objects which are only dummy object or fake object.

Ext JS Feature Overview

After implementing a whole application with Ext JS, and after presenting also in this blog basic overview of the prototype and jquery javascript frameworks and given a small idea of the functionalities of qooxdoo (and a little overview of QWT), I want to give a more or less thorough view of all the features of this quality framework. In a later entry, I will give a thorough presentation of the relations between GWT and Ext JS.

It is important to notice, that unlike other frameworks the extJS framework does not have a licence mechanism which is very suitable for enterprise application which need to be kept closed source, unless you are ready to pay licence fees to the company owning the code of extJS. However, the core of ext JS is proposed under an LGPL licence, so it can still be used in closed source development.

I first list the main features of extJS, then I go in a little more details for each of these points:

  • Namespace functionalities
  • DOM elements manipulation Utilities
  • Data Manipulation Utilities
  • Data Store functionalities
  • Ajax request functionalities
  • an extended set of application widgets: trees, tables form, charts
  • a complete RIA framework, with menus, drag and drop,....

Namespace functionalities

This is presented in this entry. Namespaces makes it easy it construct more modular applications.

DOM elements manipulation Utilities

This is presented in another entry:

Data Manipulation Utilities

This is presented in another entry:

Data Store functionalities

This is presented in another entry:

Ajax request functionalities

This is presented in another entry:

an extended set of application widgets: trees, tables form, charts

This is presented in another entry:

a complete RIA framework, with menus, drag and drop,....

This is presented in another entry:

Ext JS Tutorial - Namespaces

In this entry I will give a tutorial on using Ext JS Namespaces.

Namespaces are a very useful functionality in extJS. You can define a namespace using:

var myNamespaceNS = new ext.Ext.NS('my.namespaces.mymodules');

Then you can add objects, or functions to the namespaces as easily as if they were normal variables:

myNamespaceNS.myObject = {title:'my title',author:'me'};

In other pieces of the code, you can get the hold of the namespace using its name or a variable.

var myNamespaceNS = new ext.Ext.NS('my.namespaces.mymodules'); alert(myNamespaceNS.myObject.title + " "+my.namespaces.mymodules.myObject.author);

JQuery - Plugins

JQuery is a framework designed with extensions or plugins in mind. There is a large number of plugins which can be found at the plugin page.

In this entry, I will try to select and explain some of the main useful plugins.

Wednesday 21 April 2010

JQuery - Basics

After the post on prototype I thought I might just present the features of jQuery. Just as for prototype I first summarize the features of JQuery, then I describe in a little more details these features. The informations from this entry come from the jQuery API.

  • simple on load execution mechanism
  • simple query mechanism using selectors and syntactic sugar $()
  • Simple Ajax functions and Helpers
  • Manipulation of the DOM elements
  • visualization effects
  • Dimensions Utilities
  • Data Storage and manipulation utilities

simple on load execution mechanism

JQuery provides a way to load code directly on load, by using the .ready() function. In that way, it is possible to initialize a certain number of elements once the web page is ready.

$(document).ready(function() {
  // Handler for .ready() called.
});

Simple Query Mechanism using Selectors and Syntactic Sugar $()

As prototype and other frameworks provide, jquery provides the means of selecting elements using css selectors. The function to use for this is the jQuery() function ( or its equivalent syntactic sugar: $()).

Simple Ajax functions and Helpers

jQuery provides a simple framework to perform Ajax Queries of the sort:

$.ajax({ url: "urltocall",
  context: document.body,
  success: function(){
  // code to perform when the ajax query has been a success
}}
);
Some callback functions can be given as parameters, in order to act depending on the result of the call. In the previous example, the function success is a callback function used when the Ajax request was successful. Other possibility is for example error. But also the request parameters can be changed before the HttpRequest is sent to the server.

Manipulation of the DOM Elements

jQuery provides a great number of utility methods to interact with DOM elements retrieved for instance with the CSS selectors mentioned earlier. For instance, you can add a title ( here an h2 element ) to all elements of the class container.

$('.container').append($('h2'));
Other possibilities is to prepend, the content to an element.

Two other methods can be useful: html() and text() which return respectively the HTML content or the text content of the element or its child elements.

Visualization Effects

JQuery provides the possibility to animate the elements of the page. For example, if the user clics on an elements a small animation can be displayed to inform the user that something actually occurs.

jQuery('#elementToClick').click(function() {
  $('#elementToAnimate').animate({
   opacity: 0.35,
   left: '+=20',
   height: 'toggle'
  }, 5000, function() {
  // the code called once the animation is finished
  });
});

Dimensions Utilities

JQuery provides a number of useful methods to determinate the dimensions of objects. See for example:

$(window).height(); // returns height of browser viewport
$(document).height(); // returns height of HTML document
Other methods are for example width(), innerHeight() and innerWidth()

Data Storage and manipulation Utilities

// code to add data to an element elementToStoreData
$('elementToStoreData').data('age', 52);
$('elementToStoreData').data('nameInfo', { firstName: 'Mark', lastName: 'MacGuire });
// code to remove the data from the element elementToStoreData
$('elementToStoreData').removeData('age');
$('elementToStoreData').removeData('nameInfo');
$('elementToStoreData').removeData(); // removes all entries stored in this Element

Visit the API page for more informations.

prototype javascript - API features

Prototype is a minimalistic javascript Ajax and Dom manipulation framework.

By taking a look at the API, I decided to sum up the interesting features of prototype (version 1.6). Here are the following useful features of prototype

  • Ajax Requests
  • syntactic sugar
  • CSS selector manipulation
  • enumeration
  • String manipulation and Template mechanism
  • periodical workers

Ajax Requests

The prototype API provides a simple browser independant API to perform Ajax requests:

new Ajax.Request('/theserverURLpath', {
  onSuccess: function(response) {
   // Handle the response content...
  }
});
Just as in other javascript frameworks to perform Ajax requests you can set callback depending on the type of response you obtain from the server. The code might look like this:
new Ajax.Request('/theserverURLpath', {
  onSuccess: function(response) {
   alert('The call was successful');
  },
  onFailure: function(response) {
   alert('The call has failed');
  }
});

Syntactic Sugar and Element Manipulation

Prototype provides a certain number of shortcuts to obtain elements more easily. For example, you can directly obtain elements when you know their id (for example for an element with id: 'myid', you can get the element using the call to $('myid'))

Other example of syntactic sugar are $F (returns the value of a form element), $A return an array from an iterable element, $H (returns a Hash map), $R (returns an object range), $w (returns the array from the splitted string given as argument).

CSS selector manipulation

CSS Selectors provides a powerful means of selecting elements of a web page either using their tags, or their ids, or their css class... prototype provides a selector class and two syntactic sugar constructs to perform easy queries using selectors.

Enumerations

Prototype provides a mixin in order to create enumerable classes more easily. The following example illustrate the definition and the use of the mixin.

var theEnumerableClass = Class.create(Enumerable, {
  initialize: function() {
   // the constructor code
  },
  _each: function(iterator) {
  // Your iteration code, invoking iterator at every turn
  },
  // Your other methods here, including Enumerable overrides
}); var enumerableInstance = new theEnumbarableClass({});
After having defined the enumerable class and instance, prototype provides a number of methods from the Enumerable mixin in order to perform actions on the enumerable aspect of the instance, for instance using the each() function.

String manipulation and Template mechanism

Prototype provides a number of string manipulations extensions of the string class as well as a regular expression framework.

It also provides the usual template mechanism which allows the passing of arguments to a given string.

var myTemplate = new Template('Dear #{title} #{firstname} #{lastname}.');
var personInfo = {
  title: 'Dr',
  firstname: 'Homer',
  lastname: 'Simpson'
};
// let's format our data
myTemplate.evaluate(personInfo);

periodical workers

Like many other javascript frameworks, prototype has also a mechanism to perform some tasks periodically. The code is clear in itself.

new PeriodicalExecuter(function (pe) { // the code to be performed every five seconds !!! }, 5);

git trick - shallow cloning

I am reading Oreilly's kurz & gut Git book. And I discovered, that it is possible to clone with a very shallow level by using the "--depth=" option. For example, if you want only to clone the repository with only the three latest commit, you may use:

$mygitworkingdirectory> git clone --depth=3 git:path/repository

Isn't that great.

Git rocks !!! ;-)

Installing qwt (Qooxdoo Windowing Toolkit)

After trying qooxdoo, I natually tried QWT, which is a simple implementation of the windowing toolkit with java. The default project generated for qwt is basicall the same as the one provided by qooxdoo. However, the main idea is to use java as programming language. The javascript components are then generated I suppose.

Getting QWT to run with maven without the installed Maven

The QWT install package contains a maven instance. However, I already have two instances of maven installed on my computer, therefore I prefered using my own maven instance. This worked quite well after I installed the qooxdoo files as well as some eclipse base package in my local repository. Moreover I need the following setting:

<settings>
  <pluginGroups>
   <pluginGroup>org.qooxdoo.toolkit</pluginGroup>
  </pluginGroups>
</settings>

Then I could use the qwt project generator: $qwt-workplace> mvn-jul qx:new -Dpackage=de.deprofundis.exampleqwt -Dorg.apache.maven.global-settings=`pwd`/../qwt-0.2.0/bin/settings.xml
and then I could change in the directory "exampleqwt", where there is a src directory as well as a pom.xml.

Installing the project in my repository was easy:
$exampleqwt> mvn package -Dorg.apache.maven.global-settings=`pwd`/../qwt-0.2.0/bin/settings.xml
Then using qx:run task from the qwt maven plugin:
$exampleqwt> mvn qx:run -Dorg.apache.maven.global-settings=`pwd`/../qwt-0.2.0/bin/settings.xml

This started an instance of tomcat on port 8080. Therefore I could then test the application.

First Comments

The generated code is an index.html (or index.html.gz for browser/servers supporting gz I suppose. This is a huge html file containing the core content of the javascript for running qwt. I wonder why the programmers have not put this generated code in a javascript file and loaded this file.

The directory layout of a qwt project is described in a wiki page: directory_layout. Note that, there is a logging mechanism. Though I have not yet looked at what it really does. There is also a list of the modules to be loaded and the index.html which has been created.

From all this, it is not yet clear to me how to have a more modular approach, so that the qooxdoo code does not need to be loaded every time I need a qooxdoo component. I suppose this might be solved in a later version of the code.

Caveats

According to the following page of the documentation, QWT only works in a Tomcat 6 Servlet instance:

In order to distribute your QWT application, simply run mvn clean package to generate a target/yourapp-version.war file. Your application should run in any Tomcat 6 servlet container. QWT applications follow Sun’s servlet specification 2.5. Unfortunately, the servlet specification has currently no support for “reverse Ajax” (sometimes called “Comet”). QWT uses Tomcat 6 features to work-around this limitation. As a consequence, you cannot deploy in other servlet containers.

Trying qooxdoo

I have been trying qooxdoo? And I do not find it very easy to use. But I am not really clear about every commands: So here is what I did:
  1. checked the qooxdoo sdk and generated a project using
    /qooxdoo-1.0.1/tools/bin/create-application.py --name mytest
    in the directory where the project should be generated.
  2. this created the template of the demo project but it took some time
  3. to see the default I used: ./generate.py source-all as suggested in the documentation and this took also along time
  4. once done I looked at the result in the browser ( without a webserver!)
  5. I added code for a tree, and reused
    ./generate.py source-all
    (maybe I should have used ./generate.py source

One of the disadvantage of course is the use of python. I have to take a look at what RAP exactly does with the code. It probably does not need to use any python or generation since the application components are already generated. But I should check.

Use JQuery in firebug with jQueryfy

Here is a great presentation on how to use firebug to test interactively jquery.

JQueryfy is a bookmarklet to load jquery in any web page easily.

So all you have to do is:

  1. go to some web page.
  2. Load Jquery with jQueryfy
  3. then start firebug

Then go to the console of firebug, and type jQuery(). This should return
"function()".

In order to have all the images disappear for example, you can use:
jQuery('img').hide()

Of course you need to use a correct selector for your queries. But isn't that just great ?

Note: I had to update my version of firebug to have all this working.

Sunday 18 April 2010

Agile Methods - Pair Programming

I had a job interview the week before and I enjoyed the possibility of participating in a mock job day last week. This day was really interesting for me. I could learn a lot about agile methods. In particular I noticed how difficult it was for me to interact in pair programming work.

After that I looked more into agile methods to try to see what I was missing and what I could have done better. The following article: All I Really Need to Know about Pair Programming I Learned In Kindergarten gives some tips on how to work with pair programming. It also states that pair programming needs a little adaptation

I summed up in the following paragraphs the positive and negative aspects of pair programming.

Positive Aspects

  • More structured: Pairs usually choose to code at more appropriate positions and have shorter breaks.
  • Better Code: during pair programming, programmers come less into dead ends and achieve a better quality.
  • Better distributed Flow: Pair programming has another kind of Flow: a programmer can choose to communicate to his partner the current state and let the partner resume coding at that place. Stops in the coding can be thus better minimized.
  • Fun Working: Pair programming is often more thrilling and interesting as lone development.
  • Distribution of Project Knowledge: When Pair programming is used, and partners are changed frequently, programmers obtain a better knowledge of the whole code base. Preventing the loss of knowledge assets when programmers go.
  • Mentoring: Every one has knowledge that others do not. Pair programmierung distributes knowledge and skills.
  • Team consolidation: people learn to know each other better, which improves the collaboration in the team.
  • Less Break: Pairs are less frequently disturbed as people working alone.

Disadvantages

  • Cost: Advantages such as better quality and efficience need a number of iterations to be able to work correctly, therefore the cost in early phases are higher.
  • Finding Team Elements : not every programmer can be used together and getting used to pair programming may need some time
  • Autority problem: Who decides the solution to use when the solution are contradicting each others?
  • Time pressure: programmers may require more time because of mentoring tasks or to adapt to different code styles and strategies
  • Code copyright: it is not always clear who is the real owner of the code.
  • accountability: when mistake or copyright violations occur, it may be difficult to decide who is accountable.
  • Team size: it is more difficult for larger teams to decide what and how the code should be solved, therefore pair programming is more efficient for smaller teams
  • Knowledge requirements: if different types of tasks need to be performed, programmers need to know more.

Thursday 18 March 2010

Virtualization architectures

The linux technical review presented an overview of the different type of virtualizations architectures. I recopied the table as a reminder.

From the Linux Magazine 01/2010 Linux Technical Review:

Gleiche ISA Verschiedene ISA
System VMs Classic Hypervisors System Emulators
z.B.: Xen, VMware ESX z.B.: Bochs, Qemu
Hosted VMs Co-Designed VMs
z.B.: VMware Workstation z.B. AS/40
Prozess VMs Multiprogramming Dynamic Translation
z.B.: Linux, Windows z.B. FX!32, Transmeta
Binary Recoding HLL VMs
z.B.: Valgrind z.B. Java VM

Tuesday 16 March 2010

jsp:plugin

Rereading the Java EE 5 Tutorial I learnt there is the possibility to use the jsp:plugin to embed java applet into a page without having to take care of which browser is behind it. I still have to test this but this sounds really good.

Monday 8 March 2010

commandlinefu

I bought a number of linux magazine during my week holiday and discovered a number of new interesting, useful things:

  • Ubuntu One, a way to store data on some ubuntu servers to share it with other ubuntu users (I must check that)
  • Writer's Cafe, a tool helping creative writing
  • impro-visor, some GPL software working with lead sheets.

And one thing I really found useful is: commandlinefu (http://www.commandlinefu.com/). This site provides a way for people to advertise useful commandline tricks. I should probably follow them, I will learn a lot. And it already started.

I already learnt a new useful command: youtube-dl. Say you have some google URL:

http://www.youtube.com/watch?v=1504cSBhWG0

And you want to get the url of the file being downloaded, then you can use (-b for best quality and -g for just getting the url): $> youtube-dl -b -g http://www.youtube.com/watch?v=1504cSBhWG0

Of course this command has a certain number of options.

Thursday 18 February 2010

Desktop recording Suse

I have just tried a desktop recording software under OpenSuse 11.2: recordmydesktop. It really worked as a charm for the video part even with thesound.

Eclipse 3.5 Windows and Unicode and Subversion

File.encoding in Eclipse and strange encoding problem in JavaSource UTF-8 files

While trying to deploy the package I have been deploying, a few problem arised yesterday.

We first had checked out a Web application.

Afterwards we set the default encoding to UTF-8 for a few files in the Window > Preferences > General > Content-Type > Text > JSP .

We also changed the encoding in the eclipse.ini file, adding the following line to the java command -Dfile.encoding=UTF-8 in the eclipse.ini

We had strange text where umlauts had been destroyed. The text was in UTF-8 in UTF-8 files in the JavaSource directory. By Debugging, we discovered that they were also called by UTF-8 JSP or UTF-8 Java Files.

The solution has been to check the Application again. Afterwards the text was displayed correctly

Subversion problem while checking files with same names with different Case

The other problem we had, was caused by two files having the same names but with different case: file.jsp and File.jsp. This caused some kind of conflict when checking the file out with subclipse.

Monday 15 February 2010

Adding .inc as content Type under eclipse

After spending much time looking for the place of the configuration for adding .inc as possible types for files in eclipse, I had to ask a friend again. So here is the place where you do it in Galileo: Window > Preferences > General > Content Types Choose Text > JSP > JSP Fragment And add *.inc to the list of files. You probably also should set the Default encoding.

Thursday 21 January 2010

Gradle - a groovy Make

So in my search for some maven solution. I fell on YAPMT (Yet Another Project Management Tool). I am not sure it does the same things as Maven. It uses Maven and looks much more like a script mechanism. So I will have to see whether it is suitable. While Maven is quite useful since it has a lot of plugins and a really well organized workflow. I would say that gradle seems to be like a groovy shell with a certain number of plugins for project management.

I will have to keep an eye on it.

Sunday 17 January 2010

Dojo Toolkit - Yet another javascript toolkit

After looking at roo, I noticed that they used the Dojo Toolkit for their default implementation of the web toolkit of the page. I Have not yet done a real comparison of the two frameworks. It seems to have more or less the same functionality as ext-js. I will have to keep an eye on both systems. At least from the licence point of view is Dojo more appropriate for companies, since it uses a BSD/Apache licence, where as ext-js under GPL ( I do not think that it has also a LGPL version apart from the core). Dojo seems to be composed of three parts:
  • Dojo core
  • dijit
  • dojox
Dojo core contains a number of utility methods for querying web pages content and perform operations on it. Dijit is a widget mechanism. Dojox are extensions based on dijit.

Saturday 16 January 2010

URL Rewriting Code in Java

Some time ago, I had to take a look and have something work with URL rewriting. My colleague told me there was an URL rewriting tool called URLRewrite. I will later introduce it here: http://tuckey.org/urlrewrite/.

On Top of the Monitoring

So the new trend in naming of projects is to top every thing, in order to imply that these tools are similar to the top command. So the idea is to have a console (text-based) tool indicating what process or activity are currently at the top of their category (e.g memory consumption, processor last)...

So here are the few project I just discovered:

  • htop
  • innotop
  • ApacheTop

And I suppose there are many others.

htop

htop is the closest to (the ;-) ) top, since it is a kind of enhanced top. I tried it. And it was quite nice.

innotop

The name of this one comes from innoDB which is one of the possible backend to a mysql database. I have not tried this tool but I suppose it is like top but just for a mysql database.

ApacheTop

A kind of top for apache request. I think I should take a look, because it might be useful for debugging purposes of our applications.

Thursday 14 January 2010

Coole Eclipse Shortcuts

I found this link on http://viralpatel.net/blogs/2009/07/20-very-useful-eclipse-ide-shortcuts-for-developers.html.

I found the following shortcuts really great:

# Alt + Shift + L : Extract to Local Variable

Say you have the following method:

public void myTest(){ String finalVariable = "first part" + "second part"+ "third part"; }

if you select "first part" + "second part" and use the short cut :

Alt + Shift + L : Extract to Local Variable

Then eclipse ask for the name of the new local variable, e.g firstTwoParts, and the method looks like:

public void myTest(){
  String firstTwoParts = "first part" + "second part";
  String finalVariable = firstTwoParts + "third part";
}

# Alt + Shift + M : Extract to Method

The same also works with methods. Say you have the following method:

public final static void main(String[] args){
  if (args.length >2){
   System.out.println(args[0]);
   System.out.println(args[1]);
  }
}
if you select the whole if statement up to the }, and use the shortcut: Alt + Shift + M eclipse prompts for the name of the method and creates the parameter, for args.

# Alt + Shift + W : show the class in the package view.

Well I did not know that. But this is very useful, because I often need it.

# Ctrl+Q : Last edit

There is also a button to find this. But a short cut is even better.

# Alt + Left or Alt + Right : Navigate Left and Right

I knew this one but this is also very useful, since it is much quicker than using the mouse every time.

Java scrapbook page

I discovered the java scrapbook page. Which allows you to try simple snippets of code very easily. I should try that. It is really cool.

Myllyn WikiText - Edit documentation easily for different formats

I just discovered that there is in the Eclipse Galileo a very easy and simple way to edit documentation called Wikitext. Documentation for this can be found in the eclipse documentation. Try it. It is just great.

It is in that way possible to use a WikiText format (out of a choice of 3 or 4 different one to write documentation. This Wikitext cabn be then used to generate html or docbook format. This is therefore very useful to create documentation.

See more at http://help.eclipse.org/galileo/topic/org.eclipse.mylyn.wikitext.help.ui/help/Mylyn%20WikiText%20User%20Guide.html

ROO - a spring and Maven based rapid development framework

I just discovered ROO. I tried it. But I had some problems running it under fedora with java 1.6 and maven 2.0.8. It seems that it need maven 2.0.9. The idea behind roo is to have a command line based system to develop. It is somewhat similar to Ruby on Rails. You issue commands and create and edit the entities that way. I give here an example of script:
project --topLevelPackage org.myexample persistence setup --provider HIBERNATE --database HYPERSONIC_PERSISTENT database properties list database properties set --key database.url --value jdbc:hsqldb:${user.home}/tmp/datasources/my-example database properties list
This first part of the script creates a project pom.xml (for maven) and sets the necessary properties for working with hibernate using an in memory database.
entity --class ~.domain.MyExample field string code --notNull --sizeMin 32 --sizeMax 32 field string firstName --sizeMax 65 field string lastName --sizeMax 65 field string email --sizeMax 65 field number age --type java.lang.Integer field date confirmed --type java.util.Date
This second party from the script creates an entity: MyExample. It also creates a number of fields: code, firstName, lastName, email. The next part of the script takes care of creating controllers and tests. The line:
controller scaffold ~.web.MyExampleController
creates a controller for CRUD operations. It also performs the tests to make sure it works correctly. Finally, it sets up the logging framework as well as the security framework.
test integration controller scaffold ~.web.MyExampleController selenium test --controller ~.web.MyExampleController perform test // (OPTION: quit, mvn tomcat:run, localhost:8080/myexample, mvn selenium:selenese) logging setup --level DEBUG --package WEB security setup
The next section creates a new controller class called: org.myexample.web.My2ndExampleController. It lists the finders and adds the finder to the class.
controller class --class ~.web.My2ndExampleController finder list --class ~.domain.MyExample --filter code,equ finder add --finderName findMyExamplesByCodeEquals perform eclipse
At the end the perform eclipse sets the system for using the system under eclipse.

Wednesday 13 January 2010

Interesting Loading Properties or files in Servlet Context

I was reading the documentation on tomcat in the web to be sure not to miss important information. And I found this at this wiki FAQ:

How do I load a properties file? Here are the two most popular ways:

  • Use a ResourceBundle. See the Java docs for the specifics of how the ResourceBundle class works. Using this method, the properties file must go into the WEB-INF/classes directory or in a jar file contained in the WEB-INF/lib directory.

  • Another way is to use the method getResourceAsStream() from the ServletContext class. This allows you update the file without having to reload the webapp as required by the first method. Here is an example code snippet, without any error trapping:

    // Assuming you are in a Servlet extending HttpServlet
    // This will look for a file called "/more/cowbell.properties" relative
    // to your servlet Root Context
    InputStream is = getServletContext().getResourceAsStream("/more/cowbell.properties");
    Properties p = new Properties();
    p.load(is);
    is.close();

Thursday 7 January 2010

The long way to a maveniozed Eclipse: M2Eclipse

I had some trouble installing everything for M2Eclipse. One part of the problem was that the fedora installation from eclipse did not really allow the installation of the correct packages. I used the description found in the free online book documenting M2: Developing with Eclipse and Maven.

Therefore, I downloaded the new eclipse from the web site and then I could install subclipse, AJDT and WST as needed. Though WST should have been there since it was the JEE version of eclipse.

Then I could install M2 from the http://m2eclipse.sonatype.org/update/ site.

It is interesting to have the poms. But since the poms are a little complex, I generate them from a more simple xml file. And these XML files can be generated using an even more simple XML file (though this is not yet finished). The goal is to help the bootstrapping of projects. In a simple manner.