formatter-registry config

This commit is contained in:
Keith Donald
2008-04-11 14:18:53 +00:00
parent 875b4c304a
commit 0d9e9b7f84
6 changed files with 131 additions and 18 deletions

View File

@@ -13,8 +13,9 @@
<xsd:annotation>
<xsd:documentation>
<![CDATA[
Deploys the flow builder services, including the ViewFactoryCreator, ExpressionParser, and ConversionService to
be used by a flow definition registry.
Registers custom implementations of services needed to build flow definitions in a JSF environment.
With this tag, you may configure a custom ConversionService, FormatterFactory, ExpressionParser, and ViewFactoryCreator implementation.
This tag is only needed when you wish to plugin custom implementations.
]]>
</xsd:documentation>
</xsd:annotation>
@@ -25,7 +26,16 @@ be used by a flow definition registry.
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The idref of the conversion service that should be used. If not provided, the default conversion service will be used.
The custom ConversionService implementation to use to convert from one type to another.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="formatter-registry">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The custom FormatterRegistry implementation to use to format model properties for display in a View.
]]>
</xsd:documentation>
</xsd:annotation>
@@ -34,8 +44,7 @@ The idref of the conversion service that should be used. If not provided, the d
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The idref of the expression parser instance that should be used. If not provided, the default OGNL expression parser
will be used.
The custom ExpressionParser implementation to use to compile expression strings into Expressions.
]]>
</xsd:documentation>
</xsd:annotation>
@@ -44,8 +53,7 @@ will be used.
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The idref of the view factory creator that should be used. The view factory creator is specific to the view technology
being used. If not provided, the default Spring MVC view factory creator will be used.
The custom ViewFactoryCreator implementation to use produce ViewFactories capable of rendering Views.
]]>
</xsd:documentation>
</xsd:annotation>

View File

@@ -2,12 +2,21 @@ package org.springframework.faces.config;
import junit.framework.TestCase;
import org.springframework.binding.convert.ConversionException;
import org.springframework.binding.convert.ConversionExecutor;
import org.springframework.binding.convert.ConversionService;
import org.springframework.binding.expression.Expression;
import org.springframework.binding.expression.ExpressionParser;
import org.springframework.binding.format.Formatter;
import org.springframework.binding.format.FormatterRegistry;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.faces.model.converter.FacesConversionService;
import org.springframework.faces.webflow.JSFMockHelper;
import org.springframework.faces.webflow.JsfManagedBeanAwareELExpressionParser;
import org.springframework.faces.webflow.JsfViewFactoryCreator;
import org.springframework.webflow.engine.builder.ViewFactoryCreator;
import org.springframework.webflow.engine.builder.support.FlowBuilderServices;
import org.springframework.webflow.execution.ViewFactory;
import org.springframework.webflow.expression.el.WebFlowELExpressionParser;
public class FacesFlowBuilderServicesBeanDefinitionParserTests extends TestCase {
@@ -40,4 +49,60 @@ public class FacesFlowBuilderServicesBeanDefinitionParserTests extends TestCase
assertTrue(builderServices.getViewFactoryCreator() instanceof JsfViewFactoryCreator);
assertTrue(builderServices.getConversionService() instanceof FacesConversionService);
}
public void testFlowBuilderServicesCustomized() {
builderServices = (FlowBuilderServices) context.getBean("flowBuilderServicesCustom");
assertNotNull(builderServices);
assertNotNull(builderServices.getExpressionParser());
assertTrue(builderServices.getViewFactoryCreator() instanceof TestViewFactoryCreator);
assertTrue(builderServices.getConversionService() instanceof TestConversionService);
assertTrue(builderServices.getFormatterRegistry() instanceof TestFormatterRegistry);
}
public static class TestViewFactoryCreator implements ViewFactoryCreator {
public ViewFactory createViewFactory(Expression viewIdExpression, ExpressionParser expressionParser,
FormatterRegistry formatterRegistry) {
throw new UnsupportedOperationException("Auto-generated method stub");
}
public String getViewIdByConvention(String viewStateId) {
return viewStateId;
}
}
public static class TestConversionService implements ConversionService {
public Class getClassByAlias(String alias) throws ConversionException {
throw new UnsupportedOperationException("Auto-generated method stub");
}
public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass)
throws ConversionException {
throw new UnsupportedOperationException("Auto-generated method stub");
}
public ConversionExecutor getConversionExecutorByTargetAlias(Class sourceClass, String targetAlias)
throws ConversionException {
throw new UnsupportedOperationException("Auto-generated method stub");
}
public ConversionExecutor[] getConversionExecutorsForSource(Class sourceClass) throws ConversionException {
throw new UnsupportedOperationException("Auto-generated method stub");
}
}
public static class TestFormatterRegistry implements FormatterRegistry {
public Formatter getFormatter(Class clazz) {
throw new UnsupportedOperationException("Auto-generated method stub");
}
public Formatter getFormatter(String id) {
throw new UnsupportedOperationException("Auto-generated method stub");
}
}
}

View File

@@ -11,5 +11,19 @@
<faces:flow-builder-services id="flowBuilderServicesDefault"/>
<faces:flow-builder-services id="flowBuilderServicesLegacy" enable-managed-beans="true"/>
<faces:flow-builder-services id="flowBuilderServicesCustom"
expression-parser="customExpressionParser"
view-factory-creator="customViewFactoryCreator"
conversion-service="customConversionService"
formatter-registry="customFormatterRegistry"/>
<bean id="customExpressionParser" class="org.springframework.webflow.expression.DefaultExpressionParserFactory" factory-method="getExpressionParser"/>
<bean id="customViewFactoryCreator" class="org.springframework.faces.config.FacesFlowBuilderServicesBeanDefinitionParserTests$TestViewFactoryCreator"/>
<bean id="customConversionService" class="org.springframework.faces.config.FacesFlowBuilderServicesBeanDefinitionParserTests$TestConversionService"/>
<bean id="customFormatterRegistry" class="org.springframework.faces.config.FacesFlowBuilderServicesBeanDefinitionParserTests$TestFormatterRegistry"/>
</beans>

View File

@@ -69,8 +69,8 @@ Registers a custom FlowBuilder implementation in this registry.
<xsd:annotation>
<xsd:documentation>
<![CDATA[
A refernence to a FlowBuilderServices implementation defining custom services needed to build the flows registered in this registry.
Optional. For use when custom builder services are required.
A reference to a FlowBuilderServices implementation defining custom services needed to build the flows registered in this registry.
Optional. For use when one or more custom builder services are required.
]]>
</xsd:documentation>
</xsd:annotation>
@@ -213,7 +213,7 @@ The default value 'flowRegistry'.
<xsd:documentation>
<![CDATA[
Registers custom implementations of services needed to build flow definitions.
With this tag, you may configure a custom ConversionService, ExpressionParser, ViewFactoryCreator, and FlowArtifactFactory implementation.
With this tag, you may configure a custom ConversionService, FormatterFactory, ExpressionParser, and ViewFactoryCreator implementation.
This tag is only needed when you wish to plugin custom implementations.
]]>
</xsd:documentation>
@@ -221,29 +221,38 @@ This tag is only needed when you wish to plugin custom implementations.
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="beans:identifiedType">
<xsd:attribute name="expression-parser" use="optional">
<xsd:attribute name="conversion-service">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The custom ExpressionParser implementation to use.
The custom ConversionService implementation to use to convert from one type to another.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="view-factory-creator" use="optional">
<xsd:attribute name="formatter-registry">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The custom ViewFactoryCreator implementation to use.
The custom FormatterRegistry implementation to use to format model properties for display in a View.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="conversion-service" use="optional">
<xsd:attribute name="expression-parser">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The custom ConversionService implementation to use.
The custom ExpressionParser implementation to use to compile expression strings into Expressions.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="view-factory-creator">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The custom ViewFactoryCreator implementation to use produce ViewFactories capable of rendering Views.
]]>
</xsd:documentation>
</xsd:annotation>
@@ -254,7 +263,7 @@ The custom ConversionService implementation to use.
</xsd:element>
<xsd:complexType name="flowExecutionRepositoryType">
<xsd:attribute name="type" type="flowExecutionRepositoryTypeAttribute" use="required">
<xsd:attribute name="type" type="flowExecutionRepositoryTypeAttribute">
<xsd:annotation>
<xsd:documentation>
<![CDATA[

View File

@@ -8,6 +8,7 @@ import org.springframework.binding.convert.ConversionService;
import org.springframework.binding.convert.service.DefaultConversionService;
import org.springframework.binding.expression.Expression;
import org.springframework.binding.expression.ExpressionParser;
import org.springframework.binding.format.Formatter;
import org.springframework.binding.format.FormatterRegistry;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.webflow.engine.builder.ViewFactoryCreator;
@@ -38,6 +39,7 @@ public class FlowBuilderServicesBeanDefinitionParserTests extends TestCase {
assertNotNull(builderServices.getExpressionParser());
assertTrue(builderServices.getViewFactoryCreator() instanceof TestViewFactoryCreator);
assertTrue(builderServices.getConversionService() instanceof TestConversionService);
assertTrue(builderServices.getFormatterRegistry() instanceof TestFormatterRegistry);
}
public static class TestViewFactoryCreator implements ViewFactoryCreator {
@@ -75,4 +77,16 @@ public class FlowBuilderServicesBeanDefinitionParserTests extends TestCase {
}
public static class TestFormatterRegistry implements FormatterRegistry {
public Formatter getFormatter(Class clazz) {
throw new UnsupportedOperationException("Auto-generated method stub");
}
public Formatter getFormatter(String id) {
throw new UnsupportedOperationException("Auto-generated method stub");
}
}
}

View File

@@ -13,12 +13,15 @@
<webflow:flow-builder-services id="flowBuilderServicesCustom"
expression-parser="customExpressionParser"
view-factory-creator="customViewFactoryCreator"
conversion-service="customConversionService"/>
conversion-service="customConversionService"
formatter-registry="customFormatterRegistry"/>
<bean id="customExpressionParser" class="org.springframework.webflow.expression.DefaultExpressionParserFactory" factory-method="getExpressionParser"/>
<bean id="customViewFactoryCreator" class="org.springframework.webflow.config.FlowBuilderServicesBeanDefinitionParserTests$TestViewFactoryCreator"/>
<bean id="customConversionService" class="org.springframework.webflow.config.FlowBuilderServicesBeanDefinitionParserTests$TestConversionService"/>
<bean id="customFormatterRegistry" class="org.springframework.webflow.config.FlowBuilderServicesBeanDefinitionParserTests$TestFormatterRegistry"/>
</beans>