JavaBean框架 UJO

fmms 13年前
     <p>UJO Framework为对象提供了一种有别于JavaBeans的架构。最初的想法来源于Java5.0的范型。但是,随着时间的流逝,这种架构表现一些激动人心的特性:</p>    <ul>     <li>很轻松实现对象的自省<span lang="EN-US"><span style="font-family:Times New Roman;">(introspection)</span></span><span style="font-family:宋体;">而不再需要笨重的</span><span lang="EN-US"><span style="font-family:Times New Roman;">PropertyDescriptor</span></span><span style="font-family:宋体;">实现</span> </li>     <li>一个transfer <span class="hilite1">UJO</span><span style="font-family:宋体;">对象属性可以是集合</span><span lang="EN-US"><span style="font-family:Times New Roman;">(</span></span><span style="font-family:宋体;">并非</span><span lang="EN-US"><span style="font-family:Times New Roman;">values)</span></span> </li>     <li>核心部分才两个接口<span lang="EN-US"><span style="font-family:Times New Roman;">(<span class="hilite1">Ujo</span></span></span><span style="font-family:宋体;">和</span><span lang="EN-US"><span style="font-family:Times New Roman;"><span class="hilite1">Ujo</span>Property)</span></span><span style="font-family:宋体;">,实现起来非常简单。</span></li>     <li>multi row insert, update and delete is supported by a single SQL statement</li>     <li>resources for ORM mapping can be a database table, view or native SQL SELECT</li>     <li>LIMIT and OFFSET are supported</li>     <li>subset of table columns on SELECT can be specified for the SQL statement</li>     <li>JDBC query parameters are passed by a 'question mark' notation to the <a href="/misc/goto?guid=4959517400158684339">PreparedStatement</a> for a high security </li>     <li>stored database procedures and functions are supported</li>     <li>all persistent objects are based on the interface <a href="/misc/goto?guid=4959517400246597870">OrmUjo</a>, namely on the implementation <a href="/misc/goto?guid=4959517400336838941">OrmTable</a> </li>     <li>internal object cache is based on the WeakHashMap class so that large transactions does not cause any OutOfMemoryException</li>     <li>database indexes are created by the meta-model, added support for unique, non-unique indexes including the composed one</li>     <li><br /> </li>    </ul>    <p><img alt="JavaBean框架 UJO" src="https://simg.open-open.com/show/c55235459fd8a22e4d5b4986fc6af992.png" width="462" height="475" /></p>    <p>代码示例:</p>    <pre class="brush:java; toolbar: true; auto-links: false;">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 NAME = new MapProperty("Name", String.class);   public static final MapProperty MALE = new MapProperty("Male", Boolean.class);   public static final MapProperty CASH = new MapProperty("Cash", 0d);      // --- The start of the MapUjo 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(UjoAction action, UjoProperty property, Object value) {     return true;   } // --- The end of MapUjo implementation ---    /** Add cash in the Ujo implementation */   public void addCash(double cash) {     double newPrice = CASH.of(this) + cash;     CASH.setValue(this, newPrice);   } }</pre>    <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1326937077843" target="_blank">http://www.open-open.com/lib/view/home/1326937077843</a></p>    <p></p>