public Object getComponentInstance ( PicoContainer container ) throws PicoInitializationException , PicoIntrospectionException , AssignabilityRegistrationException , NotConcreteRegistrationException { if ( instantiationGuard == null ) { instantiationGuard = new Guard ( ) { public Object run ( ) { final Constructor constructor ; try { constructor = getGreediestSatisfiableConstructor ( guardedContainer ) ; } catch ( AmbiguousComponentResolutionException e ) { e . setComponent ( getComponentImplementation ( ) ) ; throw e ; } ComponentMonitor componentMonitor = currentMonitor ( ) ; try { Object [ ] parameters = getConstructorArguments ( guardedContainer , constructor ) ; componentMonitor . instantiating ( constructor ) ; long startTime = System . currentTimeMillis ( ) ; Object inst = newInstance ( constructor , parameters ) ; componentMonitor . instantiated ( constructor , System . currentTimeMillis ( ) - startTime ) ; return inst ; } catch ( InvocationTargetException e ) { componentMonitor . instantiationFailed ( constructor , e ) ; if ( e . getTargetException ( ) instanceof RuntimeException ) { throw ( RuntimeException ) e . getTargetException ( ) ; } else if ( e . getTargetException ( ) instanceof Error ) { throw ( Error ) e . getTargetException ( ) ; } throw new PicoInvocationTargetInitializationException ( e . getTargetException ( ) ) ; } catch ( InstantiationException e ) { // can't get here because checkConcrete() will catch it // earlier, but see PICO-191 // /CLOVER:OFF componentMonitor . instantiationFailed ( constructor , e ) ; throw new PicoInitializationException ( "Should never get here" ) ; // /CLOVER:ON } catch ( IllegalAccessException e ) { // can't get here because either filtered or access mode // set // /CLOVER:OFF componentMonitor . instantiationFailed ( constructor , e ) ; throw new PicoInitializationException ( e ) ; // /CLOVER:ON } } } ; } instantiationGuard . setArguments ( container ) ; Object result = instantiationGuard . observe ( getComponentImplementation ( ) ) ; instantiationGuard . clear ( ) ; return result ; }
difference with picocontainer