Code review of SWF-210 commits.

This commit is contained in:
Erwin Vervaet
2006-12-22 19:34:51 +00:00
parent d2ed8a61d1
commit 6250adb877
2 changed files with 142 additions and 121 deletions

View File

@@ -80,49 +80,69 @@ class ExecutorBeanDefinitionParser extends AbstractBeanDefinitionParser {
}
/**
* Configures a repository based on the <code>repositoryType</code> attribute
* Configures a repository based on the <code>repository-type</code> attribute
* or a <code>repository</code> tag.
* @param element the root element to extract repository configuration from
* @param definitionBuilder the builder
*/
private void configureRepository(Element element, BeanDefinitionBuilder definitionBuilder) {
Element repositoryElement = DomUtils.getChildElementByTagName(element, REPOSITORY_ELEMENT);
String repositoryTypeAttribute = getRepositoryType(element);
if(repositoryElement != null) {
if(StringUtils.hasText(repositoryTypeAttribute)) {
throw new IllegalArgumentException("The 'repositoryType' attribute of the 'executor' element must not have a value if there is a 'repository' element");
if (repositoryElement != null) {
if (StringUtils.hasText(repositoryTypeAttribute)) {
throw new IllegalArgumentException(
"The 'repositoryType' attribute of the 'executor' element must " +
"not have a value if there is a 'repository' element");
}
definitionBuilder.addPropertyValue(REPOSITORY_TYPE_PROPERTY, getType(repositoryElement));
configureContinuations(repositoryElement, definitionBuilder);
configureConversationManager(repositoryElement, definitionBuilder);
} else if (StringUtils.hasText(repositoryTypeAttribute)) {
}
else if (StringUtils.hasText(repositoryTypeAttribute)) {
definitionBuilder.addPropertyValue(REPOSITORY_TYPE_PROPERTY, repositoryTypeAttribute);
}
}
private void configureConversationManager(Element repositoryElement, BeanDefinitionBuilder definitionBuilder) {
String conversationManagerRef = getConversationManagerRef(repositoryElement);
String maxConversations = getMaxConversations(repositoryElement);
if(StringUtils.hasText(conversationManagerRef)) {
if(StringUtils.hasText(maxConversations)) {
throw new IllegalArgumentException("The 'maxConversations' attribute of the 'repository' element must not have a value if there is a value for the 'conversation-manager-ref' attribute");
}
definitionBuilder.addPropertyReference(CONVERSATION_MANAGER_PROPERTY, conversationManagerRef);
} else if (StringUtils.hasText(maxConversations)) {
definitionBuilder.addPropertyValue(MAX_CONVERSATIONS_PROPERTY, maxConversations);
}
}
/**
* Configure the max continuations setting.
* @param repositoryElement the repository element
* @param definitionBuilder the builder
*/
private void configureContinuations(Element repositoryElement, BeanDefinitionBuilder definitionBuilder) {
RepositoryType repositoryType = (RepositoryType) StaticLabeledEnumResolver.instance().getLabeledEnumByLabel(RepositoryType.class, getRepositoryType(repositoryElement));
RepositoryType repositoryType = (RepositoryType)StaticLabeledEnumResolver.instance().getLabeledEnumByLabel(
RepositoryType.class, getRepositoryType(repositoryElement));
String maxContinuations = getMaxContinuations(repositoryElement);
if(StringUtils.hasText(maxContinuations)) {
if(repositoryType != RepositoryType.CONTINUATION) {
throw new IllegalArgumentException("The 'maxContinuations' attribute of the 'repository' element must not have a value if the 'type' attribute is not 'continuation'");
if (StringUtils.hasText(maxContinuations)) {
if (repositoryType != RepositoryType.CONTINUATION) {
throw new IllegalArgumentException(
"The 'max-continuations' attribute of the 'repository' element must not " +
"have a value if the 'type' attribute is not 'continuation'");
}
definitionBuilder.addPropertyValue(MAX_CONTINUATIONS_PROPERTY, maxContinuations);
}
}
/**
* Configure the conversation manager
* @param repositoryElement the repository element
* @param definitionBuilder the builder
*/
private void configureConversationManager(Element repositoryElement, BeanDefinitionBuilder definitionBuilder) {
String conversationManagerRef = getConversationManagerRef(repositoryElement);
String maxConversations = getMaxConversations(repositoryElement);
if (StringUtils.hasText(conversationManagerRef)) {
if(StringUtils.hasText(maxConversations)) {
throw new IllegalArgumentException(
"The 'max-conversations' attribute of the 'repository' element must not " +
"have a value if there is a value for the 'conversation-manager-ref' attribute");
}
definitionBuilder.addPropertyReference(CONVERSATION_MANAGER_PROPERTY, conversationManagerRef);
}
else if (StringUtils.hasText(maxConversations)) {
definitionBuilder.addPropertyValue(MAX_CONVERSATIONS_PROPERTY, maxConversations);
}
}
/**
* Returns the name of the registry detailed in the bean definition.
* @param element the element to extract the registry name from
@@ -131,7 +151,8 @@ class ExecutorBeanDefinitionParser extends AbstractBeanDefinitionParser {
private String getRegistryRef(Element element) {
String registryRef = element.getAttribute(REGISTRY_REF_ATTRIBUTE);
if (!StringUtils.hasText(registryRef)) {
throw new IllegalArgumentException("The 'registry-ref' attribute of the 'executor' element must have a value");
throw new IllegalArgumentException(
"The 'registry-ref' attribute of the 'executor' element must have a value");
}
return registryRef;
}

View File

@@ -93,16 +93,16 @@ an execution repository.
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="beans:identifiedType">
<xsd:sequence>
<xsd:element name="repository" type="repositoryType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
Explicit repository configuration for this executor. This element is used if configuration needs
to be more fine grained than the repositoryType attribute on executor.
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="repository" type="repositoryType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
Explicit repository configuration for this executor. This element is used if configuration needs
to be more fine grained than the repositoryType attribute on executor.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="execution-attributes" type="execution-attributesType" minOccurs="0">
<xsd:annotation>
@@ -146,94 +146,94 @@ The idref to the registry this executor will use to locate flow definitions for
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:simpleType name="repositoryTypeAttribute">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="continuation">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The continuation repository type. Use this to snapshot flow execution state server-side to support use
of the browser back button.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="simple">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The simple repository type. Use of this strategy incurs minimal storage overhead but explicity prevents
resubmits using the browser back button.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="client">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The client continuation repository type. Use this to snapshot flow execution state client-side to support use of the browser
back button in a stateless server environment.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="singlekey">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The "single key" repository type. Use of this strategy assigns a single key per flow execution that remains
constant throughout the life of the execution.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="repositoryType">
<xsd:attribute name="type" type="repositoryTypeAttribute" use="required">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The type of execution repository to use. The repository is responsible for managing flow execution
persistence between requests.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="max-conversations" type="xsd:integer">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The maximum number of conversations to preserve in a repository. It is illegal to populate this
attribute if you are also populating conversation-manager-ref.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="max-continuations" type="xsd:integer">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The maximum number of continuations to preserve in a repository. This attribute is only useful
only useful when the repository is of type 'continuation'.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="conversation-manager-ref" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The idref to the conversation manager used by this registry to persist conversations. Populating
this attribute implies that that you should not populate max-conversations.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:element>
<xsd:simpleType name="repositoryTypeAttribute">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="continuation">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The continuation repository type. Use this to snapshot flow execution state server-side to support use
of the browser back button.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="simple">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The simple repository type. Use of this strategy incurs minimal storage overhead but explicity prevents
resubmits using the browser back button.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="client">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The client continuation repository type. Use this to snapshot flow execution state client-side to support use of the browser
back button in a stateless server environment.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="singlekey">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The "single key" repository type. Use of this strategy assigns a single key per flow execution that remains
constant throughout the life of the execution.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="repositoryType">
<xsd:attribute name="type" type="repositoryTypeAttribute" use="required">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The type of execution repository to use. The repository is responsible for managing flow execution
persistence between requests.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="max-conversations" type="xsd:integer">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The maximum number of conversations to preserve in a repository. It is illegal to populate this
attribute if you are also populating conversation-manager-ref.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="max-continuations" type="xsd:integer">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The maximum number of continuations to preserve in a repository. This attribute is only useful
when the repository is of type 'continuation'.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="conversation-manager-ref" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The idref to the conversation manager used by this registry to persist conversations. Populating
this attribute implies that you should not populate max-conversations.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<xsd:complexType name="execution-listenersType">