/* JFox, the OpenSource J2EE Application Server
 *
 * Distributable under GNU LGPL license by gun.org
 * more details please visit http://www.huihoo.org/jfox
 */

package org.jfox.ejb.handler;

import java.util.Iterator;

import org.jfox.ejb.Bucket;
import org.jfox.ejb.Invocation;
import org.jfox.ejb.SessionBucket;

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

public class Z5_SessionHandler extends AbstractHandler {

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

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

    public static void main(String[] args) {

    }
}  
