protected Object resolveBeanInstance ( ) { // First, try to resolve from a cached EJB handle (if any) Object fromHandle = resolveBeanInstanceFromHandle ( ) ; if ( fromHandle != null ) return fromHandle ; // Find null arg create() on the home interface, and use it to get an instance try { /* todo: for efficiency, this could be done once per home interface and cached */ Method createMethod = _homeInterface . getMethod ( "create" , new Class [ ] { } ) ; Object beanInstance = createMethod . invoke ( _homeInstance , ( Object [ ] ) null ) ; _autoCreated = true ; return beanInstance ; } catch ( NoSuchMethodException e ) { throw new ControlException ( "Cannot auto-create session bean instance because no null argument create() method exists. To use this bean, you will need to call create() directly with the appropriate parameters" ) ; } catch ( InvocationTargetException e ) { _lastException = e . getTargetException ( ) ; throw new ControlException ( "Unable to create session bean instance" , _lastException ) ; } catch ( Exception e ) { throw new ControlException ( "Unable to invoke home interface create method" , e ) ; } }
Implements auto - create semantics for Session beans .