// If there are no explicit service elements, then expose all the beans
if (services.isEmpty()) {
itb = beans.iterator();
// Loop through all the beans found
while (itb.hasNext()) {
SpringBeanElement beanElement = itb.next();
// If its a innerBean, ignore it
if (beanElement.isInnerBean()) continue;
// Load the Spring bean class
Class<?> beanClass = resolveClass(resolver, beanElement.getClassName());
// Introspect the bean
beanIntrospector =
new SpringBeanIntrospector(assemblyFactory, javaFactory, policyFactory, beanElement.getCustructorArgs());
ComponentType beanComponentType = assemblyFactory.createComponentType();
javaImplementation = beanIntrospector.introspectBean(beanClass, beanComponentType);
// Set the service name as bean name
for (Service componentService : beanComponentType.getServices())
componentService.setName(beanElement.getId());
// Get the service interface defined by this Spring Bean and add to
// the component type of the Spring Assembly
List<Service> beanServices = beanComponentType.getServices();
componentType.getServices().addAll(beanServices);
// Add these services to the Service / Bean map
for (Service beanService : beanServices) {
implementation.setBeanForService(beanService, beanElement);
}
} // end while
} // end if
itb = beans.iterator();
while (itb.hasNext()) {
SpringBeanElement beanElement = itb.next();
// Ignore if the bean has no properties and constructor arguments
if (beanElement.getProperties().isEmpty() && beanElement.getCustructorArgs().isEmpty())
continue;
Class<?> beanClass = resolveClass(resolver, beanElement.getClassName());
// Introspect the bean
beanIntrospector =
new SpringBeanIntrospector(assemblyFactory, javaFactory, policyFactory, beanElement.getCustructorArgs());
ComponentType beanComponentType = assemblyFactory.createComponentType();
javaImplementation = beanIntrospector.introspectBean(beanClass, beanComponentType);
Map<String, JavaElementImpl> propertyMap = javaImplementation.getPropertyMembers();
JavaConstructorImpl constructor = javaImplementation.getConstructor();
// Get the references by this Spring Bean and add the unresolved ones to
// the component type of the Spring Assembly
List<Reference> beanReferences = beanComponentType.getReferences();
List<Property> beanProperties = beanComponentType.getProperties();
Iterator<SpringPropertyElement> itp = beanElement.getProperties().iterator();
while (itp.hasNext()) {
SpringPropertyElement propertyElement = itp.next();
if (propertyRefUnresolved(propertyElement.getRef(), beans, references, scaproperties)) {
// This means an unresolved reference from the spring bean...
for (Reference reference : beanReferences) {
if (propertyElement.getName().equals(reference.getName())) {
// The name of the reference in this case is the string in
// the @ref attribute of the Spring property element, NOT the
// name of the field in the Spring bean....
reference.setName(propertyElement.getRef());
componentType.getReferences().add(reference);
} // end if
} // end for
// Store the unresolved references as unresolvedBeanRef in the Spring Implementation type
for (Property scaproperty : beanProperties) {
if (propertyElement.getName().equals(scaproperty.getName())) {
// The name of the reference in this case is the string in
// the @ref attribute of the Spring property element, NOT the
// name of the field in the Spring bean....
Class<?> interfaze = resolveClass(resolver, (propertyMap.get(propertyElement.getName()).getType()).getName());
Reference theReference = createReference(interfaze, propertyElement.getRef());
implementation.setUnresolvedBeanRef(propertyElement.getRef(), theReference);
} // end if
} // end for
} // end if
} // end while
Iterator<SpringConstructorArgElement> itcr = beanElement.getCustructorArgs().iterator();
while (itcr.hasNext()) {
SpringConstructorArgElement conArgElement = itcr.next();
if (propertyRefUnresolved(conArgElement.getRef(), beans, references, scaproperties)) {
for (JavaParameterImpl parameter : constructor.getParameters()) {
String paramType = parameter.getType().getName();