Top Description Fields Constructors Methods
org.springframework.scripting.config

pack-priv Class ScriptBeanDefinitionParser

extends AbstractBeanDefinitionParser
Class Inheritance
Imports
java.util.List, org.w3c.dom.Element, org.springframework.beans.factory.config.ConstructorArgumentValues, .RuntimeBeanReference, org.springframework.beans.factory.support.AbstractBeanDefinition, .BeanDefinitionDefaults, .GenericBeanDefinition, org.springframework.beans.factory.xml.AbstractBeanDefinitionParser, .BeanDefinitionParserDelegate, .ParserContext, .XmlReaderContext, org.springframework.lang.Nullable, org.springframework.scripting.support.ScriptFactoryPostProcessor, org.springframework.util.StringUtils, org.springframework.util.xml.DomUtils

BeanDefinitionParser implementation for the '<lang:groovy/>', '<lang:std/>' and '<lang:bsh/>' tags. Allows for objects written using dynamic languages to be easily exposed with the org.springframework.beans.factory.BeanFactory.

The script for each object can be specified either as a reference to the resource containing it (using the 'script-source' attribute) or inline in the XML configuration itself (using the 'inline-script' attribute.

By default, dynamic objects created with these tags are not refreshable. To enable refreshing, specify the refresh check delay for each object (in milliseconds) using the 'refresh-check-delay' attribute.

Authors
Rob Harrop, Rod Johnson, Juergen Hoeller, Mark Fisher
Since
2.0

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private final String
scriptFactoryClassName

The org.springframework.scripting.ScriptFactory class that this parser instance will create bean definitions for.

Inherited from org.springframework.beans.factory.xml.AbstractBeanDefinitionParser:
ID_ATTRIBUTENAME_ATTRIBUTE

Constructor Summary

AccessConstructor and Description
public
ScriptBeanDefinitionParser(String
the ScriptFactory class to operate on
scriptFactoryClassName
)

Create a new instance of this parser, creating bean definitions for the supplied org.springframework.scripting.ScriptFactory class.

Method Summary

Modifier and TypeMethod and Description
protected AbstractBeanDefinition
parseInternal(Element
the element that is to be parsed into one or more BeanDefinitions
element
,
ParserContext
the object encapsulating the current state of the parsing process; provides access to a org.springframework.beans.factory.support.BeanDefinitionRegistry
parserContext
)

Implements abstract org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parseInternal.

Parses the dynamic object element and returns the resulting bean definition.
private String
resolveScriptSource(Element element, XmlReaderContext readerContext)

Resolves the script source from either the 'script-source' attribute or the 'inline-script' element.

protected boolean
Inherited from org.springframework.beans.factory.xml.AbstractBeanDefinitionParser:
parsepostProcessComponentDefinitionregisterBeanDefinitionresolveIdshouldFireEventsshouldGenerateIdshouldParseNameAsAliases

Field Detail

AUTOWIRE_ATTRIBUTEback to summary
private static final String AUTOWIRE_ATTRIBUTE
CUSTOMIZER_REF_ATTRIBUTEback to summary
private static final String CUSTOMIZER_REF_ATTRIBUTE
DEPENDS_ON_ATTRIBUTEback to summary
private static final String DEPENDS_ON_ATTRIBUTE
DESTROY_METHOD_ATTRIBUTEback to summary
private static final String DESTROY_METHOD_ATTRIBUTE
ENGINE_ATTRIBUTEback to summary
private static final String ENGINE_ATTRIBUTE
INIT_METHOD_ATTRIBUTEback to summary
private static final String INIT_METHOD_ATTRIBUTE
INLINE_SCRIPT_ELEMENTback to summary
private static final String INLINE_SCRIPT_ELEMENT
PROXY_TARGET_CLASS_ATTRIBUTEback to summary
private static final String PROXY_TARGET_CLASS_ATTRIBUTE
REFRESH_CHECK_DELAY_ATTRIBUTEback to summary
private static final String REFRESH_CHECK_DELAY_ATTRIBUTE
SCOPE_ATTRIBUTEback to summary
private static final String SCOPE_ATTRIBUTE
SCRIPT_INTERFACES_ATTRIBUTEback to summary
private static final String SCRIPT_INTERFACES_ATTRIBUTE
SCRIPT_SOURCE_ATTRIBUTEback to summary
private static final String SCRIPT_SOURCE_ATTRIBUTE
scriptFactoryClassNameback to summary
private final String scriptFactoryClassName

The org.springframework.scripting.ScriptFactory class that this parser instance will create bean definitions for.

Constructor Detail

ScriptBeanDefinitionParserback to summary
public ScriptBeanDefinitionParser(String scriptFactoryClassName)

Create a new instance of this parser, creating bean definitions for the supplied org.springframework.scripting.ScriptFactory class.

Parameters
scriptFactoryClassName:String

the ScriptFactory class to operate on

Method Detail

parseInternalback to summary
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext)

Implements abstract org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parseInternal.

Parses the dynamic object element and returns the resulting bean definition. Registers a ScriptFactoryPostProcessor if needed.

Parameters
element:Element

Doc from org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parseInternal.

the element that is to be parsed into one or more BeanDefinitions

parserContext:ParserContext

Doc from org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parseInternal.

the object encapsulating the current state of the parsing process; provides access to a org.springframework.beans.factory.support.BeanDefinitionRegistry

Returns:AbstractBeanDefinition

Doc from org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parseInternal.

the primary BeanDefinition resulting from the parsing of the supplied Element

Annotations
@Override
@SuppressWarnings:deprecation
@Nullable
resolveScriptSourceback to summary
private String resolveScriptSource(Element element, XmlReaderContext readerContext)

Resolves the script source from either the 'script-source' attribute or the 'inline-script' element. Logs and XmlReaderContext#error and returns null if neither or both of these values are specified.

Annotations
@Nullable
shouldGenerateIdAsFallbackback to summary
protected boolean shouldGenerateIdAsFallback()

Overrides org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.shouldGenerateIdAsFallback.

Scripted beans may be anonymous as well.

Returns:boolean

Doc from org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.shouldGenerateIdAsFallback.

whether the parser should generate an id if no id was specified

Annotations
@Override