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.annotation;
18:
19: import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
20:
21: /**
22: * Enumeration determining autowiring status: that is, whether a bean should
23: * have its dependencies automatically injected by the Spring container using
24: * setter injection. This is a core concept in Spring DI.
25: *
26: * <p>Available for use in annotation-based configurations, such as for the
27: * AspectJ AnnotationBeanConfigurer aspect.
28: *
29: * @author Rod Johnson
30: * @author Juergen Hoeller
31: * @since 2.0
32: * @see org.springframework.beans.factory.annotation.Configurable
33: * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory
34: */
35: public enum Autowire {
36:
37: /**
38: * Constant that indicates that autowiring information was not specified.
39: * In some cases it may be necessary to specify autowiring status,
40: * but merely confirm that this should be inherited from an enclosing
41: * container definition scope.
42: */
43: INHERITED(-1),
44:
45: /**
46: * Constant that indicates no autowiring at all.
47: */
48: NO(AutowireCapableBeanFactory.AUTOWIRE_NO),
49:
50: /**
51: * Constant that indicates autowiring bean properties by name.
52: */
53: BY_NAME(AutowireCapableBeanFactory.AUTOWIRE_BY_NAME),
54:
55: /**
56: * Constant that indicates autowiring bean properties by type.
57: */
58: BY_TYPE(AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE);
59:
60: private final int value;
61:
62: Autowire(int value) {
63: this .value = value;
64: }
65:
66: public int value() {
67: return this .value;
68: }
69:
70: /**
71: * Return whether this represents an actual autowiring value.
72: * @return whether actual autowiring was specified
73: * (either BY_NAME or BY_TYPE)
74: */
75: public boolean isAutowire() {
76: return (this == BY_NAME || this == BY_TYPE);
77: }
78:
79: }
|