diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/implementation-spring-runtime/src')
2 files changed, 13 insertions, 6 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.java index 5b4ef9e130..13fe341881 100644 --- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.java +++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.java @@ -69,7 +69,15 @@ class SCAParentApplicationContext implements ApplicationContext { * @return Object - a Bean which matches the requested bean */ public Object getBean(String name, Class requiredType) throws BeansException { - return implementation.getBean(name, requiredType); + Object bean = implementation.getBean(name, requiredType); + if (bean == null && getParent() != null) { + bean = getParent().getBean(name, requiredType); + } + if (bean == null) { + throw new NoSuchBeanDefinitionException("Unable to find Bean with name " + name); + } else { + return bean; + } } // end method getBean( String, Class ) public Object getBean(String name, Object[] args) throws BeansException { @@ -77,7 +85,7 @@ class SCAParentApplicationContext implements ApplicationContext { } public <T> T getBean(Class<T> clazz) throws BeansException { - return clazz.cast(implementation.getBean(clazz.getName(), clazz)); + return clazz.cast(getBean(clazz.getName(), clazz)); } public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> clazz) throws BeansException { diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.java index bf46765f13..20e5d6b8d2 100644 --- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.java +++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.java @@ -22,7 +22,6 @@ package org.apache.tuscany.sca.implementation.spring.runtime.context; import java.lang.reflect.Method; import org.springframework.beans.BeansException; -import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.context.ApplicationContext; /** @@ -80,9 +79,9 @@ public class SpringImplementationStub { try { Object bean = getBean.invoke(tie, new Object[] {name, requiredType}); - if (bean == null) { - throw new NoSuchBeanDefinitionException("Unable to find Bean with name " + name); - } +// if (bean == null) { +// throw new NoSuchBeanDefinitionException("Unable to find Bean with name " + name); +// } return bean; } catch (Exception e) { |