1 package org.wamblee.system.spring;
3 import org.springframework.beans.factory.FactoryBean;
4 import org.wamblee.system.ProvidedInterface;
5 import org.wamblee.system.RequiredInterface;
6 import org.wamblee.system.SystemAssemblyException;
9 * Bean which adds a service required by the spring component to
10 * the application context so that other spring beans can use it.
12 * @author Erik Brakkee
14 class RequiredServiceBean implements FactoryBean {
16 private RequiredInterface _required;
19 * Constructs the bean.
20 * @param aId Id of the bean in the service registry.
22 public RequiredServiceBean(String aId) {
23 RequiredInterface[] required = SpringComponent.THIS.get().getRequiredServices();
24 for ( RequiredInterface intf: required) {
25 if ( intf.getName().equals(aId)) {
30 throw new SystemAssemblyException("Cannot resolve provided component '" + aId + "'");
34 public Object getObject() throws Exception {
35 return _required.getImplementation(Object.class);
39 public Class getObjectType() {
44 public boolean isSingleton() {