KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > beans > factory > support > InstantiationStrategy


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.support;
18
19 import java.lang.reflect.Constructor JavaDoc;
20 import java.lang.reflect.Method JavaDoc;
21
22 import org.springframework.beans.BeansException;
23 import org.springframework.beans.factory.BeanFactory;
24
25 /**
26  * Interface responsible for creating instances corresponding to a root bean definition.
27  *
28  * <p>This is pulled out into a strategy as various approaches are possible,
29  * including using CGLIB to create subclasses on the fly to support Method Injection.
30  *
31  * @author Rod Johnson
32  * @since 1.1
33  */

34 public interface InstantiationStrategy {
35     
36     /**
37      * Return an instance of the bean with the given name in this factory.
38      * @param beanDefinition the bean definition
39      * @param beanName name of the bean when it's created in this context.
40      * The name can be <code>null</code> if we're autowiring a bean that
41      * doesn't belong to the factory.
42      * @param owner owning BeanFactory
43      * @return a bean instance for this bean definition
44      * @throws BeansException if the instantiation failed
45      */

46     Object JavaDoc instantiate(
47             RootBeanDefinition beanDefinition, String JavaDoc beanName, BeanFactory owner) throws BeansException;
48     
49     /**
50      * Return an instance of the bean with the given name in this factory,
51      * creating it via the given constructor.
52      * @param beanDefinition the bean definition
53      * @param beanName name of the bean when it's created in this context.
54      * The name can be <code>null</code> if we're autowiring a bean
55      * that doesn't belong to the factory.
56      * @param owner owning BeanFactory
57      * @param ctor the constructor to use
58      * @param args the constructor arguments to apply
59      * @return a bean instance for this bean definition
60      * @throws BeansException if the instantiation failed
61      */

62     Object JavaDoc instantiate(
63             RootBeanDefinition beanDefinition, String JavaDoc beanName, BeanFactory owner,
64             Constructor JavaDoc ctor, Object JavaDoc[] args) throws BeansException;
65     
66     /**
67      * Return an instance of the bean with the given name in this factory,
68      * creating it via the given factory method.
69      * @param beanDefinition bean definition
70      * @param beanName name of the bean when it's created in this context.
71      * The name can be <code>null</code> if we're autowiring a bean
72      * that doesn't belong to the factory.
73      * @param owner owning BeanFactory
74      * @param factoryBean the factory bean instance to call the factory method on,
75      * or <code>null</code> in case of a static factory method
76      * @param factoryMethod the factory method to use
77      * @param args the factory method arguments to apply
78      * @return a bean instance for this bean definition
79      * @throws BeansException if the instantiation failed
80      */

81     Object JavaDoc instantiate(
82             RootBeanDefinition beanDefinition, String JavaDoc beanName, BeanFactory owner,
83             Object JavaDoc factoryBean, Method JavaDoc factoryMethod, Object JavaDoc[] args) throws BeansException;
84     
85 }
86
Popular Tags