Wednesday, August 29, 2007

ActiveRecord Migration: how to write and the results

Recently, I started learning Ruby on Rails which is getting more and more popular than a Java based web application framework. Ideas and cultures are quite different from those of Java, so I have struggled to understand them. What I figured out first was that Ruby on Rails programming is tightly coupled to database tables. Creating a table in a database is the first step of every programming. To cope with a database, Rails provides us a tool, ActiveRecord, to connect to the database, and to create tables in the database. ActiveRecord enables us to migrate from a table definition written by ruby to the database schema. This is the memo how a migration can be defined and what tables in databases I got as a result of the migration.

When I wrote a database table definition for a migration, I referred to the web pages listed below.
For example, from this table definition in SQL, I defined following ruby file.
CREATE TABLE items (
id smallint(5) unsigned NOT NULL auto_increment,
done tinyint(1) unsigned NOT NULL default '0',
priority tinyint(1) unsigned NOT NULL default '3',
description varchar(40) NOT NULL default '',
due_date date default NULL,
category_id smallint(5) unsigned NOT NULL default '0',
node_id smallint(5) unsigned default NULL,
private tinyint(3) unsigned NOT NULL default '0',
created_on timestamp(14) NOT NULL,
updated_on timestamp(14) NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM COMMENT='List of items to be done';

class CreateItems < ActiveRecord::Migration
def self.up
create_table :items do |t|
t.column :done, :integer, :null => false, :default => 0
t.column :priority, :integer, :null => false, :default => 3
t.column :description, :string, :limit => 40, :null => false, :default =>''
t.column :due_date, :date, :null => true, :default => nil
t.column :category_id, :integer, :null => false, :default => 0
t.column :note_id, :integer, :null => true, :default => nil
t.column :private, :integer, :null => false, :default => 0
t.column :created_on, :timestamp, :null => false
t.column :updated_on, :timestamp, :null => false
end
end

def self.down
drop_table :items
end
end
According to the API documentation of ActiveRecord::ConnectionAdapters::TableDefinition, data type must be one of primary_key, string, text, integer, float, decimal, datetime, timestamp, time, date, binary, and boolean. Therefore, I mapped both smallint and tinyint types to a integer type. I could write the size of integer precisely by adding :limit, but I didn't do that. There's no unsigned integer type, and I have to care not to have negative values.

What I didn't mapped to the ruby file at all was “TYPE=MyISAM COMMENT='List of items to be done';” in the last line of SQL. I could have written like this:
create_table :items, :options => 'engine=MyISAM' do |t|
However, this MySQL specific parameter doesn't have any special effect because my DBMS is Apache Derby that comes with NetBeans.

Here's another mapping example. This shows how I can define UNIQUE KEY in a ruby file.
CREATE TABLE 'categories' (
id smallint(5) unsigned NOT NULL auto_increment,
category varchar(20) NOT NULL default ''
created_on timestamp(14) NOT NULL,
updated_on timestamp(14) NOT NULL,
PRIMARY KEY ('id'),
UNIQUE KEY 'category_key' ('category')
) TYPE=MyISAM COMMENT='List of categories'

class CreateCategories < ActiveRecord::Migration
def self.up
create_table :categories do |t|
t.column :category, :string, :limit => 20, :default => '', :null => false
t.column :created_on, :timestamp, :null => false
t.column :updated_on, :timestamp, :null => false
end
add_index :categories, :category, :unique => true, :name => 'category_key'
end

def self.down
drop_table :categories
end
end

Executing migration is the next step after defining the database table in ruby. Before doing it, I edited config/databse.yml and config/environment.rb to set up a connection to the database as follows:
databse.yml(exerpt)
development:
adapter: jdbc
driver: org.apache.derby.jdbc.ClientDriver
url: jdbc:derby://localhost:1527/todos
username: foo
password: bar
encoding: utf8

evironment.rb(excerpt)
RAILS_GEM_VERSION = '1.2.3' unless defined? RAILS_GEM_VERSION

require File.join(File.dirname(__FILE__), 'boot')

if RUBY_PLATFORM =~ /java/
require 'rubygems'
RAILS_CONNECTION_ADAPTERS = %w(jdbc)
end

Rails::Initializer.run do |config|
end

To make it happen, I chose “Migrate Database” from menus provided by NetBeans IDE(Go to the Projects window, right click on the project name, choose“Migrate Database” from a popup menu then select “To Current Version”). This is equivalent to run “rake db:migrate” command. NetBeans showed some messages on Output window, and create the table in the database. Though I can see what table was created on NetBeans, I dared check it interactively by running ij command of Apache Derby because outputs in interactive mode was more familiar than properties in the
popup window.

$ java -jar lib/derbyrun.jar ij
ij> connect 'jdbc:derby://localhost:1527/todos' user 'foo' password 'bar';
ij> describe items;
COLUMN_NAME |TYPE_NAME|DEC&|NUM&amp;amp;|COLUM&|COLUMN_DEF|CHAR_OCTE&|IS_NULL&
------------------------------------------------------------------------------
ID |INTEGER |0 |10 |10 |GENERATED&|NULL |NO
DONE |INTEGER |0 |10 |10 |0 |NULL |NO
PRIORITY |INTEGER |0 |10 |10 |3 |NULL |NO
DESCRIPTION |VARCHAR |NULL|NULL|40 |'' |80 |NO
DUE_DATE |DATE |0 |10 |10 |NULL |NULL |YES
CATEGORY_ID |INTEGER |0 |10 |10 |0 |NULL |NO
NOTE_ID |INTEGER |0 |10 |10 |NULL |NULL |YES
PRIVATE |INTEGER |0 |10 |10 |0 |NULL |NO
CREATED_ON |TIMESTAMP|6 |10 |26 |NULL |NULL |NO
UPDATED_ON |TIMESTAMP|6 |10 |26 |NULL |NULL |NO

ij> describe categories;
COLUMN_NAME |TYPE_NAME|DEC&|NUM&amp;amp;|COLUM&|COLUMN_DEF|CHAR_OCTE&|IS_NULL&
------------------------------------------------------------------------------
ID |INTEGER |0 |10 |10 |GENERATED&|NULL |NO
CATEGORY |VARCHAR |NULL|NULL|20 |'' |40 |NO
CREATED_ON |TIMESTAMP|6 |10 |26 |NULL |NULL |NO
UPDATED_ON |TIMESTAMP|6 |10 |26 |NULL |NULL |NO

ij> show indexes from categories;
TABLE_NAME |COLUMN_NAME |NON_U&|TYPE|ASC&amp;amp;|CARDINA&|PAGES
----------------------------------------------------------------------------
CATEGORIES |CATEGORY |0 |3 |A |NULL |NULL
CATEGORIES |ID |0 |3 |A |NULL |NULL

For comparison, I tried the migration in the same way by using well-used MySQL. On MySQL, the table was created like this:
mysql> describe items;
+-------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| done | int(11) | NO | | 0 | |
| priority | int(11) | NO | | 3 | |
| description | varchar(40) | NO | | NULL | |
| due_date | date | YES | | NULL | |
| category_id | int(11) | NO | | 0 | |
| note_id | int(11) | YES | | NULL | |
| private | int(11) | NO | | 0 | |
| created_on | datetime | NO | | NULL | |
| updated_on | datetime | NO | | NULL | |
+-------------+-------------+------+-----+---------+----------------+
10 rows in set (0.01 sec)

We can see small differences in length of an integer type, a mapping of a timestamp type and default value of a varchar type.

Every time I try to run Rails samples, I'm often puzzled how I can write schema definitions in ruby and how the migration works from definitions to real tables on database. This memo would help me not to be confused next time.

Tuesday, June 12, 2007

Four Days on Rails by NetBeans

Recently, I have been intent on learning (J)Ruby on Rails. Many books are in bookstores, and so many tutorials are on the Internet. I had a bit hard time what was the good one to start learning. Wondering around the Internet, I found "Four Days on Rails"(http://rails.homelinux.org/) is one of the best tutorials though it is a little bit old. It is based on a command line interface and older version of Rails. However, I successfully got the examples in tutorials work on NetBeans after struggling with both NetBeans and Rails. Here's a memo how I could run the first example and get an output on my browser.

The example ran on...
  • Ubuntu 6.10
  • JDK 1.6.0
  • JRuby 1.0
  • NetBeans 6.0M9
  • Java DB(a.k.a. Apache Derby) included in NetBeans
Before I create Ruby on Rails project, I updated JRuby from 0.9.8 to 1.0 as in my previous blog. I think updating JRuby might be optional, but the latest version would be better because it is the best version so far.
  1. Creating the ToDo project
    • Click File -> select New Project -> click Ruby -> click Ruby on Rails Application -> type "ToDo" in the Project Name box -> click Next -> click the Install Rails button if Rails is not installed and click Close button after Rails is installed -> click Finish
  2. Setting up the database
    • As in the tutorial, "Creating a Ruby Weblog in 10 Minites," edit database.yml and envitonment.rb to make Java DB available from a Rails Application.
    • Goto Projects window and expand Configuration folder -> open database.yml and edit lines after the "development:" so as to be in followings
    • development:
      adapter: jdbc
      driver: org.apache.derby.jdbc.ClientDriver
      url: jdbc:derby://localhost:1527/todos
      username: foo
      password: bar
    • Open environment.rb and add a following snippet before the line "Rails::Initializer.run do |config|" to plug in the JDBC adaptor.
      if RUBY_PLATFORM =~ /java/
      require 'rubygems'
      RAILS_CONNECTION_ADAPTERS = %w(jdbc)
      end
  3. Creating the todos database on Java DB
    • Click Tools -> select Java DB Database -> click Create Java DB Database... -> type the database name, user name, and password in the boxes as follows:
      Database Name: todos
      User Name: foo
      password: bar
  4. Connecting the todos database
    • Go to the Runtime window -> expand Databases -> right-click the todos database -> select Connect...
  5. Creating the category model
    • Go to the Projects window -> right-click the Models node under the ToDo project -> select Generate... -> type the model name, Category, in the box -> click OK
      Arguments: Category
  6. Creating the categories table in the todos database
    • Open the generated file, 001_create_categories.rb, and edit it to be shown below.
      class CreateCategories < ActiveRecord::Migration
      def self.up
      create_table :categories do |t|
      t.column :category, :string, :limit => 20, :default => '', :null => false
      t.column :created_on, :timestamp, :null => false
      t.column :updated_on, :timestamp, :null => false
      end
      add_index :categories, :category, :unique => true, :name => 'category_key'
      end

      def self.down
      drop_table :categories
      end
      end
    • Go to Projects window -> right-click the ToDo project node -> select Migrate Database -> select To Current Version
    • If this completes successfully, the table, categories, is created in the todos database.
    • You might have problems on this stage. For me, restarting NetBeans was the good solution. You can find other solutions on the tutorial, "Creating a Ruby Weblog in 10 Minites."
  7. Creating the script controllers
    • Go to Projects window -> right-click the Controllers node under the ToDo project -> select Generate... -> type the controller name, Script, in the Name box and leave the View box blank -> click OK
      Name: Script
      Views:
    • Open the generated file, script_controller.rb, and edit it. The following code is the script_controller.rb after editing.
      class ScriptController < ApplicationController
      scaffold :category
      end
    • Expand the Configuration node under the ToDo project -> open route.rb and add following line just before the last "end" line.
      map.connect '', :controller => "script"
    • Expand the Public node under the ToDo project -> delete index.html
  8. Running the application
    • Right-click the ToDo project node -> select Run Project or click the Run Main Project button if the ToDo project is a main one.
    • In the browser, you see the page created by the Rails application.

Monday, June 11, 2007

Using JRuby 1.0 on NetBeans

Congratulations on JRuby 1.0 release! Right after the release, I successfully updated JRuby of my NetBeans. Here's what I did.
  1. Install JDK 1.6.0 or later. Ubuntu(and probably other Linux) users *must* use JDK 1.6.0(never use 1.6.0_01) to avoid the problem that some dialog windows of NetBeans don't open.
  2. Download a JRuby 1.0 binary version of archive from http://jruby.codehaus.org/ and extract files.
  3. If you use Java DB for a Ruby on Rails Application, make symbolic link to jdk1.6.0/db/lib/derbyclient.jar in the directory, jruby-1.0/lib or copy it in this directory.
  4. Download Full version of NetBeans 6.0M9 from http://bits.netbeans.org/download/6.0/milestones/latest/ and install it.
  5. Start up NetBeans.
  6. Click Tools in the tool bar, select Options, click Miscellaneous, and open Ruby Installation. Type full path to jruby command or click Browse button and select jruby command from extracted JRuby 1.0 files.
  7. Click Tools in the tool bar, select Ruby Gems, and click Update all button.
  8. Install Rails when you create Ruby on Rails project for the first time by clicking Next button in the dialog window in which you typed the project name. Install Rails button shows up to allow us to click it.
After updating JRuby from 0.9.8 to 1.0, I tried the 10 minutes example introduced at http://www.netbeans.org/kb/60/rapid-ruby-weblog.html. The example worked fine.

Sunday, March 18, 2007

Guice made a good start in Japan

A DI container Guice, which is written in Java and released from Google, has fascinated Japanese Java programmers since its 1.0 release in March 8, 2007. Everyday, they write blogs about Guice and shows how much they are zealous to explore Guice. It is clear that Guice made a good start in Japan. I'll introduce what they have written in their blogs.

Many bloggers refer to the online magazine article that explains what is Guice and how we write code using Guice. This article, http://journal.mycom.co.jp/articles/2007/03/14/googleguice/, was publishd in March 14, 2007, just six days after the release. The title might be "It is just like Google to think much of the sense of balance" in English. The author emphasizes Guice would be an effective DI container to innovate into Java based system because it realizes DI by API only.

Among bloggers, committers of Seasar2, which is a de facto DI container in Japan, express concerns for Guice. One of them wrote the result of the benchmark test including Guice, Spring and Seasar2 on the web site, http://d.hatena.ne.jp/arumani/20070316 . The code used for the benchmark test is based on PerformanceComparison class distributed with other Guice source code, and its patch to the original code can be seen at http://docs.google.com/Doc?id=dd3xcjm8_6ddtd3k . According to the result, we know Guice works far faster than Spring, while Seasar2's performance is very close to Guice. The Seasar2 committer analyzes the delay might have come from the slow start of an OGNL library.

Another blogger has trasnlated the User's Guide of Guice into Japanese for a couple of days, which can be read on the blog site, "http://d.hatena.ne.jp/iad_otomamay/ ." The blogger's activity would help to accelerate increasing Guice users in Japan because most Japanese programmers are reluctant to read English documents. Of course, there are some bloggers writing code snippets by using Guice. These would also help to swell up the number of Guice users since how to make a program is interpretted in Japanese.

Current situation would be the first Guice boom raised by skilled programmers who are good at reading source code; therefore, it might take more time for ordinary Java programmers to start to use Guice. Probably, the ordinary programmers would need more documents and articles to decide to embrace it so that they don't lose the way while they are writing code. However, Guice will surely thrive after gaining large amount of users.

Thursday, March 15, 2007

A complement to the example of Guice struts plugin


A Struts plugin provided by Guice has been my big concern because Sturts is used for web applications commonly. This would be one of the most attractive features in Guice. Today, I tried the counter example included in source code directory and explained in the user's guide. However, it was not easy to get the example to work. The explanation in the user's guide covers princepal parts but is not perfect. Working on the struts plugin example for a couple of hours on netbeans, I finally succeeded in running the Guice example. This is a complement to the example of Guice struts plugin.

All files that must be edited and created to work the counter example are
web.xml, struts.xml, Counter.java, Count.java, Counter.jsp. Each of all is as follows:
  • web.xml
    User's Guide doesn't refer to web.xml, but Counter class uses @SessionScoped annotation. GuiceFilter is necessary.

<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xsi="http://www.w3.org/2001/XMLSchema-instance" schemalocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Struts Guice Test</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter>
<filter-name>guice</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>guice</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

  • struts.xml
    The path defined in a result tag doesn't seem to be correct. WEB-INF is not needed.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.objectFactory" value="guice" />
<package name="strutsguicetest" extends="struts-default">
<action name="Count" class="com.google.inject.struts2.example.Count">
<result>/Counter.jsp</result>
</action>
</package>
</struts>

  • Counter.java
    I just added packge and import declarations

package com.google.inject.struts2.example;

import com.google.inject.servlet.SessionScoped;

@SessionScoped
public class Counter {
private int count = 0;

public synchronized int increment() {
return count++;
}

public Counter() {
}
}

  • Count.java
    I added package and import declarations and modified a static parameter SUCCESS

package com.google.inject.struts2.example;

import com.google.inject.Inject;
import com.opensymphony.xwork2.ActionSupport;

public class Count {
private final Counter counter;

@Inject
public Count(Counter counter) {
this.counter = counter;
}

public String execute() throws Exception {
return ActionSupport.SUCCESS;
}

public int getCount() {
return counter.increment();
}
}

  • Counter.jsp
    I edited netbeans generated jsp file, so nothing has changed in the main part.

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>JSP Page</h1>
<h2>Counter Example</h2>
<h3>
<b>Hits in this session:</b>
<s:property value="count"/>
</h3>
</body>
</html>

All libraries I set in the libraries directory are guice-1.0.jar, guice-servlet-1.0.jar, guice-struts2-plugin-1.0.jar, struts2-core-2.0.6.jar, xwork-2.0.1.jar, ognl-2.6.11.jar, freemarker-2.3.8.jar, commons-logging-1.0.4.jar, 8 jars in total. A file structure in my strutsguicetes project is shown in the above image.

The URL to make the example to run is http://localhost:8084/strutsguicetest/Count.action. Since netbeans assigns 8084 port to Tomcat 5.5.17, and my project name is strutsguicetest, I tried this URL. When I clicked a reload button, the number shown on my browser increased one by one.

Tuesday, March 13, 2007

Simple comparison with the two DI containers, Seasar and Guice

Lightweight DI container, Guice 1.0 has been released. This news draws remarkable attention of Japanese Java developers who use DI container in their products. While Seasar(http://www.seasar.org/en/), which has been developed by Japanese Java programmers, is a de fact DI container and is used broadly in Japan. To study how I can write a code using Guice, I rewrote the example introduced in Seasar's quick start tutorial(http://s2container.seasar.org/en/DIContainer.html#Quickstart) and compaired two types of programs reinforced by a DI containter.

The two programs I wrote show a simple well-known message, "Hello World!" and inject two implemented classes in each series of codes. In my programs, a GreetingClient type object uses a Greeting type object, and the implementation classes of Greeting and GreetingClient are injected. When I wrote codes for Guice, Paul Barry's blog(http://paulbarry.com/articles/2007/03/12/guice-hello-world) helped me a lot.

First three codes, Greeting.java, GreetingImpl.java and GreetingClinet.java are identical for both Seasar and Guice are utilized.

//Greeting.java
public interface Greeting {
String greet();
}

//GreetingImpl.java
public class GreetingImpl implements Greeting {

public GreetingImpl() {
}

public String greet() {
return "Hello World!";
}
}

//GreetingClient.java
public interface GreetingClient {
void execute();
}

However, the implementation class of GreetingClient for Guice has an @Inject annotation to inject the implementation for the Greeting type class, while it is still POJO as a Seasar's code.

//GreetingClientImpl.java for Guice
import com.google.inject.Inject;

public class GreetingClientImpl implements GreetingClient {
private Greeting greeting;

public GreetingClientImpl() {
}

public void execute() {
System.out.println(greeting.greet());
}

@Inject
public void setGreeting(Greeting greeting) {
this.greeting = greeting;
}
}

//GreetingClientImpl.java for Seasar
public class GreetingClientImpl implements GreetingClient {

private Greeting greeting;

public void setGreeting(Greeting greeting) {
this.greeting = greeting;
}

public void execute() {
System.out.println(greeting.greet());
}
}

Besides, I wrote the class to inject the implementation of GreetingClient, whereas the role of this class might be performed by a Dicon file for Seasar. The Dicon is an XML file and defines dependencies, adds intercepting classes and more.

//GreetingController.java for Guice
import com.google.inject.Inject;

public class GreetingController {
private GreetingClient greetingClient;

public GreetingController() {
}

public void execute() {
greetingClient.execute();
}

@Inject
public void setGreetingClient(GreetingClient greetingClient) {
this.greetingClient = greetingClient;
}
}

//GreetingMain2.dicon
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE components PUBLIC
"-//SEASAR//DTD S2Container 2.3//EN"
"http://www.seasar.org/dtd/components23.dtd">
<components>
<component name="greeting"
class="examples.di.impl.GreetingImpl"/>
<component name="greetingClient"
class="examples.di.impl.GreetingClientImpl">
<property name="greeting">greeting
</component>
</components>

Main classes for Guice and Seasar are as follows.

// Main.java for Guice
import com.google.inject.AbstractModule;
import com.google.inject.Injector;
import com.google.inject.Guice;

public class Main {

public Main() {
Injector injector = Guice.createInjector(new GreetingModule());
GreetingController controller = new GreetingController();
injector.injectMembers(controller);
controller.execute();
}

public static void main(String[] args) {
new Main();
}

private class GreetingModule extends AbstractModule {
protected void configure() {
bind(Greeting.class).to(GreetingImpl.class);
bind(GreetingClient.class).to(GreetingClientImpl.class);
}
}
}

// Main.java for Seasar
import org.seasar.framework.container.S2Container;
import org.seasar.framework.container.factory.S2ContainerFactory;

public class GreetingMain2 {

private static final String PATH =
"examples/di/dicon/GreetingMain2.dicon";

public static void main(String[] args) {
S2Container container =
S2ContainerFactory.create(PATH);
GreetingClient greetingClient = (GreetingClient)
container.getComponent("greetingClient");
greetingClient.execute();
}
}

Comparting two series of code powered by Guice and Seasar, I assured Guice is configuration free DI container. It is convenient, flexible and easy to understand. However, today's DI containers are not merely a DI container. They have additional useful features such as utility classes of logging, exception handling, integration to other products and etc. I wonder people who are accustomed to other DI container and have many codes depends on it can start to use Guice soon.

Anyway, Guice programming dosen't require to write XML based configuration file and is probably easy to use(I'm note sure because I just wrote one simple application).At least, it is a great advantage for users who newly started to use DI containers.

Thursday, March 08, 2007

Jar Archive setting of NetBeans Ruby Pack

Recently, NetBeans Ruby Pack has been released, so I tried it immediately. It's very sweat and exciting except one problem. How can I set a classpath to a jdbc diver jar archive? I googled again and again putting various key words in the box, which ended up vain efforts. Instead keep searching, I looked carefully each directory related to NetBeans because JUnit tests seem to work in Ruby on Rails project on NetBeans as in the demo video. Class names of JUnit don't start with java or javax, but JUnit classes seem to be available in Ruby project. I figured out. Jar archives used in Ruby and Ruby on Rails projects exist in the directory /home/username/.netbeans/dev/jruby-0.9.2/lib. When I made a link to derby.jar in that directory, I could get my JRuby code work successfully.
Released Ruby Pack is the very first version and might have bugs and lack of convenient features. By the time those would be fixed and improved, I will avoid the jar-archive-setting problem by making links to necessary jar archives.

Friday, February 09, 2007

Still now, Jini and JavaSpaces are sluggish in Japan

When I wrote about JavaSpaces a few days ago, I got the comment which pointed out my out-of-date knowledge. The real cases based on JavaSpaces (or Jini) have worked already, though my awareness was opposite. I should have researched American Web sites. Now, I know JavaSpaces and Jini have been improving steadily. On the contrary, the situation in Japan remains the same that I wrote in my blog from my old information. Jini and JavaSpaces are sluggish in Japan still now.

I googled to find out recent entries about Jini and JavaSpaces from Japanese Web sites. Many sites were listed; however, most articles were written in 1999 and 2000. Many of them has gone. Besides, I found one article written in 2002 which said Jini based application wasn't developed anymore. In this article(http://www.atmarkit.co.jp/news/200211/12/upnp.html) about UPnP, the writer said that Microsift's UPnP thrived while Jini technology was struggling to find the way. The writer also said that topics on Jini seldom showed up in those days. It is true. Everything I could find on the Japanese Internet sites was just two articles about Jini after 2002.

I don't know the reason why Jini and JavaSpaces have been depressed in Japan. I guess a simple web application would have been effective enough in the early 2000s. J2EE products would have been sold well thanks to the vendors' efforts or Japanese character that they love to act same as others. Since JEE has become too big, recently, there is obvious tendency amid Japanese Java developers to go over to lightweight language such as Ruby. This would be negative elements to popularize Jini or JavaSpaces.

I think big obstacles exist in Japan to make Jini or JavaSpaces technology be adopted into a real case right now.

Wednesday, February 07, 2007

Is XUL obscure? That's OK.

The article of XUL appeared on XML.com this February. It's a very recent article, which is a bit strange. I mean it is the least likely appearing one. As the writer describes XUL as "a little-known use," it is obscure technology. I like XUL, and feel happy to support it; however, I admit XUL application has been slowed its development speed for more than a couple of years except products from Mozilla foundation. Accordingly, I wondered why XUL was up in this time of period. Exciting, I read the article.

This article introduces XUL, supposedly, to readers who don't know it. The writer tries to impress the readers superiority of XUL by comparing with DHTML. The tree example successfully achieved this scheme. Rendering speed is fast; appearance is good. On the contrary, the writer says DHTML is more convenient than XUL implicitly. DHTML works on every browser including Firefox. This, of course, isn't the purpose, but his concern to DHML would help the readers' interest turn to DHTML. That he introduces the utility available for both XUL and DHTML might spur the readers on. I know the writer wanted to defend from a counter-argument. The number of users of XUL-enabled browsers is very small, so programmers are reluctant to support XUL. I mind the readers conclude they don't choose XUL because they need to write not only XUL but also DHTML.

I like XUL, for its programming is simple. It has rich UI, besides, works fast. An XML file is all I need to make UI. I like to write XML, so XUL is fun for me. I think it isn't necessary for XUL to fit into the world all browsers reside. It's all right that XUL is for XUL-lovers' obscure UI. Let's pursuit fun to create own UI by XUL.

Tuesday, February 06, 2007

Does JavaSpaces have a possibility to become major?

I found an article about JavaSpaces in TheServerSide.com a couple of days ago. I remembered this name well. I had worked for it for about a year before JINI was released. Since it was almost ten years ago, I'm interested in today's situation.
In this article, the writer explains about the definition and the feature of JavaSpaces. In addition, he introduces a small example with describing how to get it work. Every part of this article is familiar to the programmer who once got involved to JavaSpaces. However, how does JavaSpaces sound to Java programmers who don't know this technology?
In the same domain, distributed processing, Web Services technology grew to become eminent. Real Web Services applications have been in action these days. Why JavaSpaces couldn't develop like Web Services? I think the concept of JavaSpaces was too innovative to be understood easily and broadly. Strict to say, JavaSpaces isn't the server-client model. It adopts the peer-to-peer communication model. The "space" provides a place to communicate; therefore, the "space" doesn't control or manage any entries. On the other hand, the concept of Web Services follows the traditional server-client model. Newly added idea was less than that of JavaSpaces. Moreover, as an internet based application, Web Services technology well suited to today's network system.
The writer shows we already have enough tools to make JavaSpaces application. It is true, but JavaSpaces might need innovative application that only JavaSpaces can realize. This would be the most difficult and effective answer JavaSpaces leaps.
What changed is that implementations have been released in public and free. What not changed is that decisive application hasn't created yet.

Monday, February 05, 2007

The answer for what is Web 2.0

I had wondered what is the definition of Web 2.0 for more than a year. Recently, the word, "Web 2.0," has often appeared in articles about Web applications. None of these articles helped me to figure out the definition of Web 2.0. Web applications, which were introduced as Web 2.0, didn't look innovative though those were useful and attractive. Yesterday, I found the entry in Martin Fowler's Bliki which was written about Web 2.0. It was the very answer for my question.
As Fowler wrote "a common misconception I run into is that Web 2.0 is all new stuff," the jargon surely misleads people. When I heard this jargon for the first time, I thought new HTTP protocol might be defined. Reading some articles and using applications of Web 2.0, soon, I knew my misunderstand. Then, why was it reported like something new? Why did they say new era had come? My question had remained until I read Fowler's entry. Fowler explained the word, Web 2.0, expresses the movement from minority to majority. Internet based application is on the way to become vital. Although Fowler admitted the naming was not the best suited to the movement, he acclaimed the concept.
Web 2.0 technology is not new. The word describes just the concept which encourages web application to develop more sophisticated. I like Web 2.0 applications, so I hope they thrive more and more.

Wednesday, January 24, 2007

Cars bumped on a snowy road

Today, snow accumulated in Michigan. Especially, snow fall in the evening was extreme, so roads were covered by snow and very slippery. When I was heading toward the swimming pool, I saw two cars bumped about 20 feet ahead of me. One car was waiting a chance to turn left; another car was to turn right to enter into a mall. Suddenly, the car turning left changed its direction and hit the car. Though it was a small accident, it reminded me importance of speeding down and avoiding from sharp handling.

Tuesday, January 23, 2007

Revived Old Note PC

Recently, I revived my old Note PC. Newly installed OS is FreeBSD 6.2R, which is the only one choice to revive this PC. This PC, released in 1998, has only a 96M-memory(which is a max size) and an 8G-disk. Besides, it is unable to boot by CD-ROM, so I really needed FD bootable OS. I prefered to install some recent easy-to-install and easy-to-use Linux, but Ubuntu, Fedore Core, Gentoo,,, all of which don't support FD boot anymore. Only FreeBSD supports it still now. The install process wasn't easy in spite of the catchphrase in the FreeBSD web site. However, my old Note PC started working again, so I can browse the Internet by this PC connected with wireless LAN. Though responses are not prompt, a 1.19kg(2.62lb), small and easy-to-carry Note PC will give me a good time at a coffee shop.