2 * Copyright 2007 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.wamblee.system.spring;
18 import org.springframework.beans.factory.FactoryBean;
19 import org.wamblee.system.core.ProvidedInterface;
20 import org.wamblee.system.core.RequiredInterface;
21 import org.wamblee.system.core.SystemAssemblyException;
24 * Bean which adds a service required by the spring component to
25 * the application context so that other spring beans can use it.
27 * @author Erik Brakkee
29 class RequiredServiceBean implements FactoryBean {
31 private RequiredInterface _required;
34 * Constructs the bean.
35 * @param aId Id of the bean in the service registry.
37 public RequiredServiceBean(String aId) {
38 RequiredInterface[] required = SpringComponent.THIS.get().getRequiredInterfaces();
39 for ( RequiredInterface intf: required) {
40 if ( intf.getName().equals(aId)) {
45 throw new SystemAssemblyException("Cannot resolve provided component '" + aId + "'");
49 public Object getObject() throws Exception {
50 return _required.getImplementation(Object.class);
54 public Class getObjectType() {
59 public boolean isSingleton() {