public void handleRequest(MessageContext context, HandlersChain chain) throws Throwable { SearchResult result = context.getAttribute(SearchResult.class); // create and save the invocation parameters for the found method List<Injectable> formal = result.getMethod().getMetadata().getFormalParameters(); logger.trace("Formal Injectable parameters list is: {}", formal); //$NON-NLS-1$ Object[] parameters = InjectableFactory.getInstance().instantiate(formal, context); if(logger.isTraceEnabled()) { if(parameters == null) { logger.trace("Actual parameters list to inject is: null"); //$NON-NLS-1$ } else { logger.trace("Actual parameters list to inject is: {}", parameters); //$NON-NLS-1$ } } result.setInvocationParameters(parameters); chain.doChain(context); }
InjectableFactory.getInstance().instantiate(method.getFormalParameters(), context); try {
InjectableFactory.getInstance().instantiate(method.getFormalParameters(), context); try {
/** * creates object (StaticResource or Provider) based on its ClassMetadata * * @param metadata * @param runtimeContext * @return created object */ static Object createObject(ClassMetadata metadata, RuntimeContext runtimeContext) { try { // use constructor to create a prototype ConstructorMetadata constructorMetadata = metadata.getConstructor(); Constructor<?> constructor = constructorMetadata.getConstructor(); List<Injectable> formalParameters = constructorMetadata.getFormalParameters(); Object[] params = InjectableFactory.getInstance().instantiate(formalParameters, runtimeContext); Object object = constructor.newInstance(params); injectFields(object, metadata, runtimeContext); return object; } catch (RuntimeException e) { throw e; } catch (InvocationTargetException e) { Throwable targetException = e.getTargetException(); if (targetException instanceof RuntimeException) { throw (RuntimeException)targetException; } throw new ObjectCreationException(targetException); } catch (Exception e) { throw new ObjectCreationException(e); } }