UJO Framework is a Java library providing non-traditional object architecture different from JavaBeans. The original idea was a toy with generic data types of Java 5.0 however over time it appears, that the architecture has some exciting new features.

 

Features

60.png Revolutionary
object architecture based on two interfaces
12.png Performance
great performance include a high speed XML serialization
54.png Easy to use
short learning curve, high object reusability, opensource project
44.png Documentation
detailed documentation include samples of code.
More characteristics: UjoUml.png
  • serialization to / from formats XML, CSV and Resource bundle
  • UJO object can be simplify  manipulated by an application builder tool
  • UJO object itself recommends the availability of its attributes for different actions
  • there is possible to implement a listener to only one place for each properties include children
  • direct support of JavaBeans and the JTable component
  • small source code of your UJO objects
  • most features are checked by unit tests
  • tiny framework without further dependencies

 

architecture

Architecture

UJO is an abbreviation for Unified Java Object and it is a such object which implements an interface Ujo. You can imagine the object UJO like a map (an object that maps keys to values) with data access by methods of the key for example. This key is made up of the implementation of the UjoProperty including (among others) two type-safe methods: There is possible to send a property method to an another object simply by the property key contrary of the methods of JavaBean object. An example of the use can be a list of table columns sent to the data model (type of TableModel) or references to the methods of the bean in a JSP page. The core of the project are two interfaces Ujo a UjoProperty, which have got three abstract implementations:
  • MapUjo - easy for developers to implement with a sufficient performance for common applications based on the object HashMap
  • ArrayUjo - high performance objects are comparable to the speed of the JavaBeans, implemented by the object array
  • PojoUjo - the implementation maps properties directly to the methods of JavaBean object using Java reflection
I took inspiration for my work from project Cayenne (a solution for a persistence BO ORM)
 

architecture

Sample of usage:

How do you write your first UJO object? The easiest way is to use some abstract implementation of the Ujo interface. For example see an implementation of the class Person which includes three attributes and a one method to add a cash.
import org.ujoframework.implementation.map.*;
public class Person extends MapUjoExt<Person> {
    
  public static final MapProperty<Person, String > NAME = newProperty("Name", String.class);
  public static final MapProperty<Person, Boolean> MALE = newProperty("Male", Boolean.class);
  public static final MapProperty<Person, Double > CASH = newProperty("Cash", 0d);
    
  public void addCash(double cash) {
    double newCash = get(CASH) + cash;
    set(CASH, newCash);
  }
}

Note that a result of the method get(CASH) needs no casting to Double type and the Java compiler disallows improper parameter types in the statement set(CASH, newCash). The CASH property have got a default zero value to all Person instances similar like a primitive type do it.

The sample uses an extended API for more conventional property access in a source code that's available since the UJO release 0.80. The new solution allows to you to chain more properties according to a model of a some new popular languages. The extended API is a child of the original API so you can mix both types because all internal tools are handling the original API still .

Sometimes it is not possible to extend an abstract class so you can implements the Ujo interface by four methods only. Note the implementation is valid for all subclasses of the Person class too. The sample:

import java.util.HashMap;
import org.ujoframework.*;
import org.ujoframework.core.UjoManager;
import org.ujoframework.implementation.map.*;

@SuppressWarnings("unchecked")
public class Person implements Ujo {
    
  public static final MapProperty<Person, String > NAME = new MapProperty("Name", String.class);
  public static final MapProperty<Person, Boolean> MALE = new MapProperty("Male", Boolean.class);
  public static final MapProperty<Person, Double > CASH = new MapProperty("Cash", 0d);
  
  // --- The start of the map Ujo implementation ---
  private HashMap map = new HashMap();

  public Object readValue(UjoProperty property) {
    Object result = map.get(property);
    return result!=null ? result : property.getDefault();
  }

  public void writeValue(UjoProperty property, Object value) {
    map.put(property, value);
  }

  public UjoProperty[] readProperties() {
    return UjoManager.getInstance().readProperties(getClass());
  }

  public boolean readAuthorization(int action, UjoProperty property, Object value, Object context) {
    return true;
  } // --- The end of UJO implementation ---


  /** A solution for the Ujo implementation */
  public void addCash(double cash) {
    double newPrice = CASH.of(this) + cash;
    CASH.setValue(this, newPrice);
  }
}

Compare the both samples with a sample code of a JavaBean object. If we exclude all imports from the code then the Ujo implementation have got slightly less code lines in compare to JavaBeans. However the more properties gives significantly the better effect in favour of the Ujo implementation.

Reference project

jws48.png See application jWorkSheet for more details or an API of the application.
There are some characteristics of jWorkSheet:
  • persistence is made by UJO Framework include application parameters.
  • all table model are a child of UjoTable class.
  • very small size: 180 kB include the UJO Framework library.
  • the jWorkSheet have used features of UJO release 0.7x (hard core).
Source code is Java 5.0 compatible, an NetBeans IDE was used.

architecture

Licence:

Source code was released under license Apache License, Version 2.0.

Copyright 2007-2008 Paul Ponec Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

 

architecture

Download:

You can download an source and binary packages from SourceForge:

 

architecture

Contact: