Send As SMS

2004-03-28

Write A JVM and OS with Java Itself

It is realy a interest things to write the Java VM and even the OS itself in Java, there is some projects tring to do it. JikesRVM is a JVM build on Java itself, and jnode is a OS(include a JVM) build on java, also there is a VM named joeq which is build on Java itself.


I realy think this would be the next choice to implement a JVM and a OS in java, specially for embeded environment and next-generation os. In the next OS, virtual memory is not nessicary.


Structure:


VM*.java --(aot compiler) -> VM Bootstrap Image


The core of the VM is task management, We may build the OS without virtual memeory, but we can allocate a standalone heap for each Process, In such a case, when we need to terminate the Process, we can free the memory at all. Dont use virtual memory makes the thread as simple and fast as possible.


So there is a VM process, a application process, and maybe the FS, DB Server can be standalone process. Process can use service provide by other Process, and use the "pass-by-value". or create a share Process which shared by each other.


A Process is a memory which contains object, both the Java Object and VM Object are both same.


the AOT compiler compile a class to an VM_Class, and also VM_Method, the link can be done at runtime.


We may also use C/ASM to provide additional process, using JNI or a lowlevel FastJNI(which shares the frame as same).

SPACE for the JavaOS

在我所构想的JavaOS中,整个操作系统、应用程序均共享单一的地址空间,与Linux等操作系统不同,因此,在任务之间进行切换,不需要进行地址空间的切换。


与将所有的Java对象分配在同一个堆中的做法(现有的JVM都是这样的)不同,JavaOS仍然采用SPACE的概念,一个SPACE是一个相对独立的堆(地址不一定连续),一般的,一个任务,在一个独立的SPACE中运行。


SPACE0是一个特殊的区间,它包含了JVM的基本的类的元信息(包括已经预编译好的方法代码),SPACE0为JavaOS上的所有任务所共享,因此,在运行一个Java应用程序时,不再需要对JVM基本的类库进行处理。


webeans demo1

Steps to run demo1:



  1. Code Login.java(see below)
  2. Compile it( I like eclipse for its auto-increase compile)
  3. Deploy it (Just put the class under WEB-INF/webeans/classes directory and it will be hot-deployed automated)
  4. Test it from url http://localhost:8080/webeans/Login
  5. It should be run, display a form with two input field "userName" & "password", 1 button "Login"
  6. input and submit, it will display a message as "result is true" or "result is false"

Features of webeans from this demo:



  • webeans is an framework support RAD, code such a demo costs no more than 5 minutes.

  • webeans support hot-deploy feature to improve develop cycle.

  • webeans follows the POJO pattern, no special interface or super class to be used, u just code u business model.

Features to be improved:



  • The input field "userName" should be "User Name"
  • The input field "userName" should be a text field with length 16 and don't permit long input than 16 chars
  • The input field "password" should not be clear text for security
  • The result page should be "Login success" or "Login failure"

Lets improve it at demo2


public class Login{


private String userName, password;


.... getter/setter method ....


public boolean login(){
// do login like
if( "admin".equals(userName) && "password".equals(password) ) return true;
else return false;
}


}

webeans demo 2: Login

Steps to run demo2:



  1. modify Login.java ( see below )
  2. using ant to generate the anotations. ( when using Java 5, no this step)
  3. compile it, hot-deploy it ( done by ide and framework runtime automatic)
  4. retest it
  5. ok, it will be improved than demo1

Features from this demo:



  • webeans is POJO with metadata for extra information(we call model information)

  • webeans is Model-Driven-Application without complex MDA tool, just using java to do the model

Login.java


public class Login{


/** @webeans.field length=16 maxlength=16 label="User Name" */
private String userName;


/** @webeans.field input=password length=12 maxlength=12 */
private String password;


.... getter/setter method ....


/** @webbeans.action */
public String login(){
// do login like
if( "admin".equals(userName) && "password".equals(password) ) return "Login Success"
else return "Login Failure";
}


}

webeans demo 3: Database Access

Demo 3: Database Access using Webeans


Use Cases:



  1. Use Case 1: Database Query
  2. Use Case 2: New Record
  3. Use Case 3: Edit Record
  4. Use Case 4: Delete Record

Steps to running this demo:



  1. Build the model as Demo3.java
  2. run use case 1 from http://localhost/webeans/Demo3/queryUser
  3. input and submit, if find a user, it will be displayed
  4. run use case 1 from http://localhost/webeans/Demo3/queryAllUsers
  5. a list will be displayed, each record can be clicked to see the detail information
  6. run use case 2 from http://localhost/webeans/Demo3/addUser
  7. run use case 3 from http://localhost/webeabs/Demo3/editUser
  8. run use case 4 from http://localhost/webeans/Demo3/deleteUser

Features to be improve:



  • The Model bean

Demo3.java:


// metadata is not appended, do it your self
public class User {


private String userName;
private String password;
private String email;
private String address;
private String telephone;


}


public class Demo3 {


public User query(String userName){
// ... do it yourself
}


public User queryUserByEmail(String email){ /* do it your self */ }


public Collection queryAllUsers(){ /* */ }


public void addUser(User user){ ... }
public void updateUser(User user){ .... }
public void deleteUser(User user){ .... }


}

How to draw graph in Browser

在Bindows中是如何实现画图的功能的?

Bindwos的IE版本是通过VML(Vector Markup Language)来实现Graph处理的,相关的文档可以在 MSDN | Web Development | Web MultiMedia | VML 来找到

\\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InternetExplorer\DefaultBehavious ?VML = CLSID:10072CEC-8CC1-11D1-986E-00A0C955B42E

CLSID:C:\Program Files\Common Files\Microsoft Shared\VGX\vgx.dll
PeerDraw.PeerDraw.1
behavior

但在Mozilla中是如何实现的,暂时还没有研究。Bindows1.3的版本是支持在Mozilla中生成Graph的。