Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
710fdc73
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 搜索 >>
提交
710fdc73
编写于
12月 21, 2013
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish Javadoc for Groovy bean support classes
上级
f9e8eb59
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
47 addition
and
31 deletion
+47
-31
spring-beans-groovy/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java
...work/beans/factory/groovy/GroovyBeanDefinitionReader.java
+31
-23
spring-context/src/main/java/org/springframework/context/support/GenericGroovyApplicationContext.java
...work/context/support/GenericGroovyApplicationContext.java
+16
-8
未找到文件。
spring-beans-groovy/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java
浏览文件 @
710fdc73
...
...
@@ -56,10 +56,11 @@ import org.springframework.core.io.support.EncodedResource;
import
org.springframework.core.io.support.ResourcePatternUtils
;
/**
* A Groovy-based reader for Spring bean definitions:
L
ike a Groovy builder,
* A Groovy-based reader for Spring bean definitions:
l
ike a Groovy builder,
* but more of a DSL for Spring configuration. Allows syntax like:
*
* <pre>import org.hibernate.SessionFactory
* <pre class="code">
* import org.hibernate.SessionFactory
* import org.apache.commons.dbcp.BasicDataSource
*
* def reader = new GroovyBeanDefinitionReader(myApplicationContext)
...
...
@@ -81,11 +82,12 @@ import org.springframework.core.io.support.ResourcePatternUtils;
* }
* }</pre>
*
* <p>You can also load resources containing beans defined
as
a Groovy script using
* <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:
*
* <pre>import org.hibernate.SessionFactory
* <pre class="code">
* import org.hibernate.SessionFactory
* import org.apache.commons.dbcp.BasicDataSource
*
* beans {
...
...
@@ -257,10 +259,10 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
}
/**
* Define
s an inner bean definition
* @param type
T
he bean type
* @param args
T
he constructors arguments and closure configurer
* @return
T
he bean definition
* Define
an inner bean definition.
* @param type
t
he bean type
* @param args
t
he constructors arguments and closure configurer
* @return
t
he bean definition
*/
public
AbstractBeanDefinition
bean
(
Class
<?>
type
,
Object
...
args
)
{
GroovyBeanDefinitionWrapper
current
=
this
.
currentBeanDefinition
;
...
...
@@ -292,7 +294,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
}
/**
* Define
s an
Spring namespace definition to use.
* Define
a
Spring namespace definition to use.
* @param definition the namespace definition
*/
public
void
xmlns
(
Map
<
String
,
String
>
definition
)
{
...
...
@@ -314,7 +316,8 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
}
/**
* Imports Spring bean definitions from either XML or Groovy sources into the current bean builder instance.
* Import Spring bean definitions from either XML or Groovy sources into the
* current bean builder instance.
* @param resourcePattern the resource pattern
*/
public
void
importBeans
(
String
resourcePattern
)
throws
IOException
{
...
...
@@ -336,7 +339,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
/**
* This method overrides method invocation to create beans for each method name that
* takes a class argument
* takes a class argument
.
*/
public
Object
invokeMethod
(
String
name
,
Object
arg
)
{
Object
[]
args
=
(
Object
[])
arg
;
...
...
@@ -411,7 +414,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
}
/**
* When a
n methods
argument is only a closure it is a set of bean definitions.
* When a
method
argument is only a closure it is a set of bean definitions.
* @param callable the closure argument
* @return this GroovyBeanDefinitionReader instance
*/
...
...
@@ -528,7 +531,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
}
/**
* Checks whether there are any {@link RuntimeBeanReference} inside the Map
* Checks whether there are any {@link RuntimeBeanReference}
s
inside the Map
* and converts it to a ManagedMap if necessary.
* @param map the original Map
* @return either the original map or a managed copy of it
...
...
@@ -550,8 +553,8 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
}
/**
* Checks whether there are any {@link RuntimeBeanReference}
inside the Lis
* and
converts it to a ManagedList if necessary.
* Checks whether there are any {@link RuntimeBeanReference}
s inside the List
* and converts it to a ManagedList if necessary.
* @param list the original List
* @return either the original list or a managed copy of it
*/
...
...
@@ -612,10 +615,14 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
}
/**
* This method overrides property retrieval in the scope of the GroovyBeanDefinitionReader to either:
* a) Retrieve a variable from the bean builder's binding if it exists
* b) Retrieve a RuntimeBeanReference for a specific bean if it exists
* c) Otherwise just delegate to MetaClass.getProperty which will resolve properties from the GroovyBeanDefinitionReader itself
* This method overrides property retrieval in the scope of the
* 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
* </ul>
*/
public
Object
getProperty
(
String
name
)
{
Binding
binding
=
getBinding
();
...
...
@@ -678,9 +685,10 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
/**
* This class is used to defer the adding of a property to a bean definition until later
* This is for a case where you assign a property to a list that may not contain bean references at
* that point of assignment, but may later hence it would need to be managed
* This class is used to defer the adding of a property to a bean definition
* until later. This is for a case where you assign a property to a list that
* may not contain bean references at that point of assignment, but may later;
* hence, it would need to be managed.
*/
private
static
class
DeferredProperty
{
...
...
@@ -703,7 +711,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
/**
* A RuntimeBeanReference that takes care of adding new properties to runtime references
* A RuntimeBeanReference that takes care of adding new properties to runtime references
.
*/
private
class
GroovyRuntimeBeanReference
extends
RuntimeBeanReference
implements
GroovyObject
{
...
...
spring-context/src/main/java/org/springframework/context/support/GenericGroovyApplicationContext.java
浏览文件 @
710fdc73
...
...
@@ -36,9 +36,10 @@ import org.springframework.core.io.Resource;
*
* <p>Consider this as the equivalent of {@link GenericXmlApplicationContext} for
* Groovy bean definitions. The main difference is that, within a Groovy script,
* the context can be used with an inline bean definition closure
like
as follows:
* the context can be used with an inline bean definition closure as follows:
*
* <pre>import org.hibernate.SessionFactory
* <pre class="code">
* import org.hibernate.SessionFactory
* import org.apache.commons.dbcp.BasicDataSource
*
* def context = new GenericGroovyApplicationContext()
...
...
@@ -59,12 +60,14 @@ import org.springframework.core.io.Resource;
* }
* }
* }
* context.refresh()</pre>
* context.refresh()
* </pre>
*
* <p>Alternatively, load a Groovy bean definition script like the following
* from an external resource (e.g. an "applicationContext.groovy" file):
*
* <pre>import org.hibernate.SessionFactory
* <pre class="code">
* import org.hibernate.SessionFactory
* import org.apache.commons.dbcp.BasicDataSource
*
* beans {
...
...
@@ -83,18 +86,23 @@ import org.springframework.core.io.Resource;
* dataSource = dataSource
* }
* }
* }</pre>
* }
* </pre>
*
* <p>With the following Java code creating the {@code GenericGroovyApplicationContext}
* (potentially using Ant-style '*'/'**' location patterns):
*
* <pre>GenericGroovyApplicationContext context = new GenericGroovyApplicationContext();
* <pre class="code">
* GenericGroovyApplicationContext context = new GenericGroovyApplicationContext();
* context.load("org/myapp/applicationContext.groovy");
* context.refresh();</pre>
* context.refresh();
* </pre>
*
* <p>Or even more concise, provided that no extra configuration is needed:
*
* <pre>ApplicationContext context = new GenericGroovyApplicationContext("org/myapp/applicationContext.groovy");</pre>
* <pre class="code">
* ApplicationContext context = new GenericGroovyApplicationContext("org/myapp/applicationContext.groovy");
* </pre>
*
* @author Juergen Hoeller
* @author Jeff Brown
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录