2 * Copyright 2004-2005 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
.codehaus
.groovy
.grails
.commons
.spring
;
18 import org
.springframework
.beans
.factory
.support
.AbstractBeanDefinition
;
21 * An interface that represent a runtime bean configuration
23 * Credit must go to Solomon Duskis and the
24 * article: http://jroller.com/page/Solomon?entry=programmatic_configuration_in_spring
31 public interface BeanConfiguration
{
32 String AUTOWIRE_BY_TYPE
= "byType";
33 String AUTOWIRE_BY_NAME
= "byName";
37 * @return The name of the bean
43 * @return True if the bean is singleton
45 boolean isSingleton();
49 * @return The Spring bean definition instance
51 AbstractBeanDefinition
getBeanDefinition();
54 * Adds a property value to this bean
55 * @param propertyName The name of the property
56 * @param propertyValue The value of the property
58 * @return Returns this bean configuration
60 BeanConfiguration
addProperty(String propertyName
, Object propertyValue
);
63 * Sets the name of the method to call when destroying the bean
65 * @param methodName The method name
66 * @return This bean configuration
68 BeanConfiguration
setDestroyMethod(String methodName
);
71 * Sets the names of the beans this bean configuration depends on
73 * @param dependsOn Bean names it depends on
74 * @return This bean configuration
76 BeanConfiguration
setDependsOn(String
[] dependsOn
);
81 * @return This BeanConfiguration
83 BeanConfiguration
setFactoryBean(String beanName
);
88 * @return This BeanConfiguration
90 BeanConfiguration
setFactoryMethod(String methodName
);
93 * Sets the autowire type, either "byType" or "byName"
95 * @param type The type
96 * @return This BeanConfiguration
98 BeanConfiguration
setAutowire(String type
);
102 * Sets the name of the bean in the app ctx
103 * @param beanName The bean name
105 void setName(String beanName
);
108 * Returns true if the bean config has the name property set
109 * @param name The name of the property
110 * @return True if it does have a property with the given name
112 boolean hasProperty(String name
);
115 * Returns the value of the given property or throws a MissingPropertyException
117 * @param name The name of the property
118 * @return The value of the property
120 Object
getPropertyValue(String name
);
123 * Sets a property value on the bean configuration
125 * @param property The name of the property
126 * @param newValue The value
128 void setPropertyValue(String property
, Object newValue
);
131 * Sets the BeanConfiguration as an Abstract bean definition
132 * @param isAbstract Whether its abstract or not
133 * @return This BeanConfiguration object
135 BeanConfiguration
setAbstract(boolean isAbstract
);
138 * Sets the name of the parent bean
140 * @param name Either a string which is the name of the bean, a RuntimeBeanReference or a BeanConfiguration
142 void setParent(Object name
);