banq 你好,我有个问题,请帮忙!!

andyj2ee 03-01-02

DatabaseObjectIterator.java 中有如下构造器我不明白。
extraObject 是Object 的类型。为什么能:ForumFactory factory = (ForumFactory)extraObject;
在DbForum 中传过来的只是this.它只实现了Forum, //public class DbForum implements Forum, Cacheable //
且我只看到有一个private DbForumFactory factory; 变量。
return new DatabaseObjectIterator(JiveGlobals.THREAD, popularThreads,this);






public DatabaseObjectIterator(int type, long [] elements,
final Object extraObject)
{
this.elements = elements;

// Load the appropriate proxy factory depending on the type of object
// that we're iterating through.
switch (type) {
// FORUM
case JiveGlobals.FORUM:
// Create an objectFactory to load forums.
this.objectFactory = new DatabaseObjectFactory() {
ForumFactory factory = (ForumFactory)extraObject;

public Object loadObject(long id) {
try {
Forum forum = factory.getForum(id);
return forum;
。。。。。。。。。。。。。。。。。。