2007-02-25
TOB 6 编程界面重大简化
关键字: TOB
TOB 6 的编程界面最近完成了一次重大简化, 附件是更新后的持久应用样板程序, 用6.0的SUN JDK和1.6.5或更新的Apache Ant就可以编译.
简化后的持久类模样从下面代码可见一斑, 特别注意 getAllProducts() 的实现.
完整项目源码在附件zip中.
简化后的持久类模样从下面代码可见一斑, 特别注意 getAllProducts() 的实现.
完整项目源码在附件zip中.
package tob.bookstore;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import av.tob.IAm;
import av.tob.Index;
import av.tob.Kin;
import av.tob.KinSet;
import av.tob.Retying;
import av.tob.Swappable;
import av.tob.TheRelation;
import av.tob.Writing;
@Swappable(typeInSwap = "Category")
public class Category extends TheRelation
{
@Index(unique = false)
protected static final String NAME_INDEX = "name";
protected Tie<Category> parent;
@IAm("parent")
protected KinSet<Category, Category> subcategories = null;
@IAm("maincate")
protected KinSet<Product, Product> products = null;
protected KinSet<Categorization, Product> moreProducts = null;
private String name;
private String description;
protected Category()
{
}
public Category(Category parentCate, String name, String desc)
{
this.parent = (parentCate == null) ? null : new Tie<Category>(
parentCate);
this.name = name;
this.description = desc;
}
public Category getParent()
{
return parent == null ? null : parent.o;
}
@Retying("parent")
public void changeParent(Category newParent)
{
this.parent = (newParent == null) ? null : new Tie<Category>(newParent);
}
public KinSet<Category, Category> getSubcategories()
{
return this.subcategories;
}
public KinSet<Product, Product> getMainProducts()
{
return this.products;
}
public KinSet<Categorization, Product> getMoreProducts()
{
return this.moreProducts;
}
private void enlistProducts(List<Product> l)
{
for (Kin<?, Product> p : products)
l.add(p.getO());
for (Kin<?, Product> p : moreProducts)
l.add(p.getO());
for (Kin<?, Category> subcate : subcategories)
subcate.getO().enlistProducts(l);
}
public List<Product> getAllProducts()
{
List<Product> all = new ArrayList<Product>(100);
this.enlistProducts(all);
return Collections.unmodifiableList(all);
}
public String getName()
{
return this.name;
}
@Writing
public void setName(String name)
{
this.name = name;
}
public String getDesciption()
{
return this.description;
}
@Writing
public void setDescription(String desc)
{
this.description = desc;
}
}
- 11:55
- 浏览 (3111)
- 评论 (2)
- 分类: TheObjectBase
- 进入论坛
- 发布在 驾驭无形的力量—软件艺法思考 圈子
- 相关推荐
评论
歆渊
2007-02-25
zrweng 写道
TestBookStore 的OrderQ.STATUS 和TestContant的UserQ.NAME等这是什么表示法啊
JDK5.0无法编译通过,只能使用JDK6.0?
JDK5.0无法编译通过,只能使用JDK6.0?
编译时TOB自动生成用于拼装SQL的查询条件类, 对应应用自己的持久类名, 后面加个 Q.
TOB 6 是基于 JSR 269 的 Annotation Processor 的, 所以必须是JDK 6才行. 不过这样其实简化了编译步骤, 和平常javac/ant没有什么差别了, 原来5的时候还必须用apt编译才行的.
zrweng
2007-02-25
TestBookStore 的OrderQ.STATUS 和TestContant的UserQ.NAME等这是什么表示法啊
JDK5.0无法编译通过,只能使用JDK6.0?
JDK5.0无法编译通过,只能使用JDK6.0?
- 浏览: 181875 次
- 性别:


- 详细资料
搜索本博客
最近加入圈子
最新评论
-
实例观察网络模型与关系模 ...
Class Screwing()不就是一种服务吗?[Evans03]跟关系模型有 ...
-- by sslaowan -
我也谈谈JAVA并发程序设计 ...
读写锁,这个概念几十年前就有了,*nix下应用的很广泛。JAVA如果能支持那是更 ...
-- by ken1984 -
我也谈谈JAVA并发程序设计 ...
可惜无法下载源码看看写得怎样。。 不然,我参与进来。。。。。。
-- by whyandwhat -
我也谈谈JAVA并发程序设计 ...
使用 j.u.c 的工程在并发控制的代码编写上,明显比传统的 synchroni ...
-- by totobacoo -
我也谈谈JAVA并发程序设计 ...
不知道LZ的Hosting Based Interfacing和移动代理的差异。 ...
-- by cuijunrong






评论排行榜