Hi Wilfred,
Thanks for the prompt reply!
***ISSUE #1 AND ISSUE #2***
If you look at the "inheritedTestBean" and
"inheritsWithDifferentClass" bean definitions at the following URL:
http://static.springsource.org/spring/docs/2.5.x/reference/beans.html#beans-child-bean-definitions
You will see that the "inheritedTestBean" is defined as abstract. Now,
in version 1.0 of the code I've been using, the static
"me.springframework.di.spring.SpringConfigurationLoader.load(BeanDefinitionRegistry)"
method would not take into account the fact that the bean definition
is abstract. So a bean would be created called "inheritedTestBean".
But the definition is defined as abstract, and so a bean should not be
directly created from this.
Now, the "inheritsWithDifferentClass" bean created by spring-me would
not recognise the fact that there is a "parent" attribute defined, and
so it would ignore the parent bean definition's configuration. What
should happen, is the bean definition for "inheritsWithDifferentClass"
should be merged with that of "inheritedTestBean". Unfortunately, the
"getMergedBeanDefinition" is only accessible to
"org.springframework.beans.factory.config.ConfigurableBeanFactory", so
we need to pass an instance of this to the load method. But
"org.springframework.beans.factory.config.ConfigurableBeanFactory"
does not have the "getBeanDefinitionNames" method! So we either need
to pass a
"org.springframework.beans.factory.support.DefaultListableBeanFactory"
class, which supports both methods, or pass in a BeanRegistry and
ConfigurableBeanFactory separately. For example:
private static Map<String, MutableInstance>
load(DefaultListableBeanFactory registry) {
Map<String, MutableInstance> instances = new HashMap<String,
MutableInstance>();
for (String name : registry.getBeanDefinitionNames()) {
// ***CHANGE*** Ignore abstract definitions and use merged
definition for ALL bean definitions
BeanDefinition definition =
registry.getBeanDefinition(name);
if (!definition.isAbstract()) {
BeanDefinition mergedDefinition =
registry.getMergedBeanDefinition(name);
MutableInstance instance = new MutableInstance(name);
load(instance, mergedDefinition);
instances.put(name, instance);
}
}
return instances;
}
The abstract definitions are ignored, as beans should not be created
from these and ALL bean definitions are merged in case they inherit
from other bean definitions.
I'm not too sure how to send you a patch, Wilfred. If you can advise I
would be more than happy to!
Great news regarding your Android phone! I'm still using my HTC Magic,
but contract is up in September so hope to upgrade to something like
the HTC Desire or Samsung Galaxy!
Am happy to talk further about the project's current status and future
goals.
Paul.