/* 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;

import java.lang.reflect.Method;
import javax.ejb.TimerService;

import org.jfox.ejb.meta.EJBDescriptor;
import org.jfox.framework.Component;
import org.jfox.framework.extra.Destroyable;
import org.jfox.framework.extra.Initializable;
import org.jfox.jndi.enc.EnterpriseContext;

/**
 * a bucket 容纳一个特定的 bean，保存了这个 bean 的一切资源，bucket 放在 container 中
 * <p/>
 * 继承 EJBOperation 是为了强迫实现它的方法，以便在方法调用时可以直接调用
 *
 * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
 */

public interface Bucket extends EJBOperation, Component, Initializable, Destroyable {

    /**
     * invoke a method
     * @return
     */
//  Object invoke(Invocation invocation) throws Exception;

    /**
     * 得到该 ejb 的 classLoader
     */
    ClassLoader getEJBClassLoader();

    Method getHomeMethod(Invocation invocation) throws NoSuchMethodException;

    Method getBeanMethod(Invocation invocation) throws NoSuchMethodException;

    /**
     * 来自 EJBHome 的方法
     *
     * @param invocation
     * @return Bean 的 ObjectId
     * @throws Exception
     */
    Object invokeHome(Invocation invocation) throws Exception;

    /**
     * 执行 Bean 的方法
     *
     * @param invocation
     * @return
     * @throws Exception
     */
    Object invokeBean(Invocation invocation) throws Exception;

    EJBDescriptor getEJBDescriptor();

    EnterpriseContext getEnterpriseContext();

    TimerService getTimerService();

    EJBObjectId nextObjectId();

    EJBObjectId getHomeObjectId();

    Class getBeanClass();

}