jUDO is short for "java Universal Data Objects" and
speeds up development/maintainence and remove database-vendor dependency
for applications using databases. You should use jUDO whenever you don't
want to use EJB's. It will also work for .NET in a near future.
You don't write ANY database-code ,you only have to
specify the container classes and the Interfaces for the Models and
then jUDO creates the implementation for you runtime, no source is generated!!!
It derives all info need to by your Interfaces method names ,that follows
name-pattern rules. In case you need some special access method you either
add a plugin for this or simply go directly against the database.
jUDO is not as "configurable" and advanced as other much more professional software like Castor , Hibernate etc, BUT since jUDO derives the database from your code, there is NEVER EVER mismatch between code/database.
Click here for
download
jUDO Key features:
- Creates the database and its tables for your container classes.
- Creates code for your model interfaces that access the containers,
(method names must follow pattern ).
- coding is independent of database vendor ,jUDO is using plugins
for db2/cloudscape/mysql/oracle.
- allows extremly easy profileing/statistics.
- Validation of your database structure for diffrent drivers(like db2/Oracle/mysql etc).
Below is an example with one Table User and main class that test some
of the accessor methods. NOTE!! this is all source code needed since the
implementation itself are manufactured troughout your given method name.
NOTE: No code is written for accessing the database ,isn't this great ???
User.java is an cointainer
with 3 fields
|
import musli.util.persistence.Constrain; public class User implements java.io.Serializable { public Integer id; public String name; public Integer fkcountry;
static final private Constrain[] constrain={ new Constrain.PrimaryKey("id"), new Constrain.MaxLength("name",24), new Constrain.NotNull("name"), };
}
|
NOTE: jUDO fires the following
SQL for this container "create table User (id INTEGER,name VARCHAR (24)
NOT NULL ,fkcountry INTEGER )
|
UserModel.java is an INTERFACE
setters/getters/facade methods.
|
import java.util.Vector;
public interface UserModell {
public User getById(Integer id) throws Exception; // match id public User getByIdGroup(Integer id,Integer group) throws Exception; // match both id && group
public Country fkGetFkcountryById(Integer id) throws Exception; // get Country object pointed by fkcountry public Country fkGetFkcountryByIdName(Integer id) throws Exception; // get Country object pointed by fkcountry
public String getNameById(Integer id) throws Exception; public Vector getList(Integer id) throws Exception;
public Integer create(User user) throws Exception; public boolean insert(User user) throws Exception;
public Integer getAge(Integer id) throws Exception; public String getName(Integer id) throws Exception;
public Class container=User.class; // The variable "container" binds this model to its conteiner. }
|
NOTE1: jUDO matches every
method name and manufactures "code" for you ,this is done at startup.
|
NOTE: the classes above are ALL that is need for 1 table , NO CODE !!!!!!
only fields and methods names .
Below is a test program ,that actually does a lot , e.g executes
the methods that we only have specified the names in the INTERFACE.
(jUDO has manufactured the implementation , out of the method
names)
Test.java simply shows
jUDO usage.
|
import musli.util.persistence.Engine; import musli.util.persistence.DB;
import java.lang.reflect.*; import java.util.HashMap; import java.net.URL; import java.io.File; import musli.util.Logger;
public class Test {
public static void main (String s[]) { try { Engine engine = new Engine(musli.util.persistence.cloudscape.insert.class); // Use Cloudscape. could be DB2/Oracle/mysql. Class[] theTables={User.class,Country.class}; // Ok ,,Country is not shown , but is just another container.
DB db = engine.getDataBase("databasen",theTables); // Ok init done ,, lets play with database UserModell usermodell=(UserModell)engine.getInstance(UserModell.class); // Get an accessor object for our INTERFACE (MAGIC!)
User user=new User(); usermodell.create(user); // This adds a row in the database !!!
user=usermodell.getById(user.id); // get the user we just added , for fun! String name=usermodell.getNameById(user.id); // Get one single field. } catch(Exception e) { System.out.print("errooos"+e); }
}
}
|
NOTE1: Magic part is
that you give an interface , and jUDO manufactures an implementation for
you (by pattern match of your method names)
|