01: package org.mockejb;
02:
03: import java.lang.reflect.*;
04:
05: import javax.ejb.*;
06:
07: /**
08: * TODO: update
09: *
10: * @author Alexander Ananiev
11: */
12: class SessionBeanHome extends BasicEjbHome {
13:
14: SessionBeanHome(BasicEjbDescriptor descriptor) {
15: super (descriptor);
16: }
17:
18: /**
19: * Creates Session bean. It involves instantiating it, setting the context and
20: * calling "create".
21: * Note that if the instantiated bean was already passed in the descriptor,
22: * setContext and create are called only if the bean implements SessionBean interface.
23: *
24: * @see org.mockejb.BasicEjbHome#create(org.mockejb.BasicEjbDescriptor, org.mockejb.MockEjbObject, java.lang.reflect.Method, java.lang.Object[])
25: */
26: public Object create(BasicEjbDescriptor descriptor,
27: MockEjbObject ejbObject, Method createMethod,
28: Object[] paramVals) throws Exception {
29:
30: Object bean = createBean(descriptor);
31:
32: MockEjbContext ejbContext = new MockEjbContext(getHomeProxy());
33:
34: if (bean instanceof SessionBean) {
35:
36: Class paramTypes[] = { SessionContext.class };
37: Object args[] = { ejbContext };
38:
39: invokeBeanMethod(bean, null, "setSessionContext",
40: paramTypes, args);
41:
42: invokeBeanCreateMethod(bean, createMethod, paramVals);
43: }
44:
45: Object ejbObjectProxy = ejbObject.createProxy(bean, ejbContext);
46:
47: return ejbObjectProxy;
48: }
49:
50: public Object invokeHomeMethod(BasicEjbDescriptor descriptor,
51: Method homeMethod, Object[] paramVals) throws Exception {
52:
53: throwMethodNotImplemented(homeMethod.toString());
54:
55: return null;
56:
57: }
58:
59: }
|