/* JFox, the OpenSource J2EE Application Server
 *
 * Copyright (C) 2002 huihoo.com
 * Distributable under GNU LGPL license
 * See the GNU Lesser General Public License for more details.
 */

package org.jfox.ejb.plugin;

import java.util.Iterator;

import org.jfox.ejb.Bulk;
import org.jfox.ejb.Invocation;
import org.jfox.ejb.SessionBulk;

/**
 * 一般是最后一个 invoker
 * invokeHome: 生成 EJBObject 的 invoker
 * invokeBean: 执行实际的方法
 *
 * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
 */

public class Z5_SessionInvoker extends AbstractInvoker {

  public Object invokeHome(Bulk bulk, Invocation invocation, Iterator iter) throws Exception {
    // 直接返回 EJBObject 的 Id
//    System.out.println(this.getClass().getName() + " " + invocation.getMethod().getName());
    return ((SessionBulk)bulk).createBean(invocation);
  }

  public Object invokeBean(Bulk bulk, Invocation invocation, Iterator iter) throws Exception {
    return invocation.getMethod().invoke(invocation.getBean(),invocation.getArgs());
  }

  public static void main(String[] args) {

  }
}