Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
9cd065c1
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9cd065c1
编写于
2月 28, 2015
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish Javadoc for GroovyBeanDefinitionReader
上级
2ba1151b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
39 deletion
+42
-39
spring-beans-groovy/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java
...work/beans/factory/groovy/GroovyBeanDefinitionReader.java
+42
-39
未找到文件。
spring-beans-groovy/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java
浏览文件 @
9cd065c1
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
5
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -31,6 +31,7 @@ import groovy.lang.GroovyObjectSupport;
import
groovy.lang.GroovyShell
;
import
groovy.lang.GroovySystem
;
import
groovy.lang.MetaClass
;
import
org.codehaus.groovy.runtime.DefaultGroovyMethods
;
import
org.codehaus.groovy.runtime.InvokerHelper
;
...
...
@@ -58,8 +59,17 @@ import org.springframework.util.StringUtils;
/**
* A Groovy-based reader for Spring bean definitions: like a Groovy builder,
* but more of a DSL for Spring configuration. Allows syntax like:
* but more of a DSL for Spring configuration.
*
* <p>This bean definition reader also understands XML bean definition files,
* allowing for seamless mixing and matching with Groovy bean definition files.
*
* <p>Typically applied to a
* {@link org.springframework.beans.factory.support.DefaultListableBeanFactory}
* or a {@link org.springframework.context.support.GenericApplicationContext},
* but can be used against any {@link BeanDefinitionRegistry} implementation.
*
* <h3>Example Syntax</h3>
* <pre class="code">
* import org.hibernate.SessionFactory
* import org.apache.commons.dbcp.BasicDataSource
...
...
@@ -84,8 +94,9 @@ import org.springframework.util.StringUtils;
* }</pre>
*
* <p>You can also load resources containing beans defined in a Groovy script using
* either the {@link #loadBeanDefinitions(org.springframework.core.io.Resource...)}
* or {@link #loadBeanDefinitions(String...)} method, with a script looking as follows:
* either the {@link #loadBeanDefinitions(Resource...)} or
* {@link #loadBeanDefinitions(String...)} method, with a script looking similar to
* the following.
*
* <pre class="code">
* import org.hibernate.SessionFactory
...
...
@@ -109,17 +120,10 @@ import org.springframework.util.StringUtils;
* }
* }</pre>
*
* <p><b>This bean definition reader also understands XML bean definition files,
* allowing for seamless mixing and matching with Groovy bean definition files.</b>
*
* <p>Typically applied to a
* {@link org.springframework.beans.factory.support.DefaultListableBeanFactory}
* or a {@link org.springframework.context.support.GenericApplicationContext},
* but can be used against any {@link BeanDefinitionRegistry} implementation.
*
* @author Jeff Brown
* @author Graeme Rocher
* @author Juergen Hoeller
* @author Sam Brannen
* @since 4.0
* @see BeanDefinitionRegistry
* @see org.springframework.beans.factory.support.DefaultListableBeanFactory
...
...
@@ -130,21 +134,20 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
private
final
XmlBeanDefinitionReader
xmlBeanDefinitionReader
;
private
final
Map
<
String
,
String
>
namespaces
=
new
HashMap
<
String
,
String
>();
private
final
Map
<
String
,
DeferredProperty
>
deferredProperties
=
new
HashMap
<
String
,
DeferredProperty
>();
private
MetaClass
metaClass
=
GroovySystem
.
getMetaClassRegistry
().
getMetaClass
(
getClass
());
private
Binding
binding
;
private
GroovyBeanDefinitionWrapper
currentBeanDefinition
;
private
final
Map
<
String
,
String
>
namespaces
=
new
HashMap
<
String
,
String
>();
private
final
Map
<
String
,
DeferredProperty
>
deferredProperties
=
new
HashMap
<
String
,
DeferredProperty
>();
/**
* Create new GroovyBeanDefinitionReader for the given bean factory.
* @param registry the BeanFactory to load bean definitions into,
* in the form of a BeanDefinitionRegistry
* Create a new {@code GroovyBeanDefinitionReader} for the given {@link BeanDefinitionRegistry}.
* @param registry the {@code BeanDefinitionRegistry} to load bean definitions into
*/
public
GroovyBeanDefinitionReader
(
BeanDefinitionRegistry
registry
)
{
super
(
registry
);
...
...
@@ -153,9 +156,9 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
}
/**
* Create
new GroovyBeanDefinitionReader based on the given XmlBeanDefinitionReader
,
* using
the same registry
and delegating XML loading to it.
* @param xmlBeanDefinitionReader the
XmlBeanDefinitionReader
to derive the registry
* Create
a new {@code GroovyBeanDefinitionReader} based on the given {@link XmlBeanDefinitionReader}
,
* using
its {@code BeanDefinitionRegistry}
and delegating XML loading to it.
* @param xmlBeanDefinitionReader the
{@code XmlBeanDefinitionReader}
to derive the registry
* from and to delegate XML loading to
*/
public
GroovyBeanDefinitionReader
(
XmlBeanDefinitionReader
xmlBeanDefinitionReader
)
{
...
...
@@ -174,7 +177,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
/**
* Set the binding, i.e. the Groovy variables available in the scope
* of a
GroovyBeanDefinitionReader
closure.
* of a
{@code GroovyBeanDefinitionReader}
closure.
*/
public
void
setBinding
(
Binding
binding
)
{
this
.
binding
=
binding
;
...
...
@@ -192,9 +195,9 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
/**
* Load bean definitions from the specified Groovy script or XML file.
* <p>Note that
".xml"
files will be parsed as XML content; all other kinds
* <p>Note that
{@code ".xml"}
files will be parsed as XML content; all other kinds
* of resources will be parsed as Groovy scripts.
* @param resource the resource descriptor for the Groovy script
* @param resource the resource descriptor for the Groovy script
or XML file
* @return the number of bean definitions found
* @throws BeanDefinitionStoreException in case of loading or parsing errors
*/
...
...
@@ -204,10 +207,10 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
/**
* Load bean definitions from the specified Groovy script or XML file.
* <p>Note that
".xml"
files will be parsed as XML content; all other kinds
* <p>Note that
{@code ".xml"}
files will be parsed as XML content; all other kinds
* of resources will be parsed as Groovy scripts.
* @param encodedResource the resource descriptor for the Groovy script,
* allowing
to specify
an encoding to use for parsing the file
* @param encodedResource the resource descriptor for the Groovy script
or XML file
,
* allowing
specification of
an encoding to use for parsing the file
* @return the number of bean definitions found
* @throws BeanDefinitionStoreException in case of loading or parsing errors
*/
...
...
@@ -255,14 +258,14 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
/**
* Defines a set of beans for the given block or closure.
* @param closure the block or closure
* @return this
GroovyBeanDefinitionReader
instance
* @return this
{@code GroovyBeanDefinitionReader}
instance
*/
public
GroovyBeanDefinitionReader
beans
(
Closure
closure
)
{
return
invokeBeanDefiningClosure
(
closure
);
}
/**
* Define
s
an inner bean definition.
* Define an inner bean definition.
* @param type the bean type
* @return the bean definition
*/
...
...
@@ -307,7 +310,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
}
/**
* Define a Spring namespace definition to use.
* Define a Spring
XML
namespace definition to use.
* @param definition the namespace definition
*/
public
void
xmlns
(
Map
<
String
,
String
>
definition
)
{
...
...
@@ -419,7 +422,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
/**
* When a method argument is only a closure it is a set of bean definitions.
* @param callable the closure argument
* @return this
GroovyBeanDefinitionReader
instance
* @return this
{@code GroovyBeanDefinitionReader}
instance
*/
protected
GroovyBeanDefinitionReader
invokeBeanDefiningClosure
(
Closure
callable
)
{
callable
.
setDelegate
(
this
);
...
...
@@ -534,8 +537,8 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
}
/**
* Checks whether there are any {@link RuntimeBeanReference}s inside the
Map
* and converts it to a
ManagedMap
if necessary.
* Checks whether there are any {@link RuntimeBeanReference}s inside the
{@link Map}
* and converts it to a
{@link ManagedMap}
if necessary.
* @param map the original Map
* @return either the original map or a managed copy of it
*/
...
...
@@ -556,8 +559,8 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
}
/**
* Checks whether there are any {@link RuntimeBeanReference}s inside the
List
* and converts it to a
ManagedList
if necessary.
* Checks whether there are any {@link RuntimeBeanReference}s inside the
{@link List}
* and converts it to a
{@link ManagedList}
if necessary.
* @param list the original List
* @return either the original list or a managed copy of it
*/
...
...
@@ -578,7 +581,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
}
/**
* This method overrides property setting in the scope of the
GroovyBeanDefinitionReader
* This method overrides property setting in the scope of the
{@code GroovyBeanDefinitionReader}
* to set properties on the current bean definition.
*/
public
void
setProperty
(
String
name
,
Object
value
)
{
...
...
@@ -619,12 +622,12 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
/**
* This method overrides property retrieval in the scope of the
*
GroovyBeanDefinitionReader
to either:
*
{@code GroovyBeanDefinitionReader}
to either:
* <ul>
* <li>Retrieve a variable from the bean builder's binding if it exists
* <li>Retrieve a RuntimeBeanReference for a specific bean if it exists
* <li>Otherwise just delegate to MetaClass.getProperty which will resolve
* properties from the
GroovyBeanDefinitionReader
itself
* properties from the
{@code GroovyBeanDefinitionReader}
itself
* </ul>
*/
public
Object
getProperty
(
String
name
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录