01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.
15: */
16:
17: package org.springframework.beans.factory.wiring;
18:
19: import org.springframework.util.Assert;
20: import org.springframework.util.ClassUtils;
21:
22: /**
23: * Simple default implementation of the {@link BeanWiringInfoResolver} interface,
24: * looking for a bean with the same name as the fully-qualified class name.
25: * This matches the default name of the bean in a Spring XML file if the
26: * bean tag's "id" attribute is not used.
27: *
28: * @author Rod Johnson
29: * @author Juergen Hoeller
30: * @since 2.0
31: */
32: public class ClassNameBeanWiringInfoResolver implements
33: BeanWiringInfoResolver {
34:
35: public BeanWiringInfo resolveWiringInfo(Object beanInstance) {
36: Assert.notNull(beanInstance, "Bean instance must not be null");
37: return new BeanWiringInfo(ClassUtils.getUserClass(beanInstance)
38: .getName(), true);
39: }
40:
41: }
|