使用 JAXB 框架定制 Web 服务行为
2010-03-25 00:00:00 来源:WEB开发网全局绑定声明:在整个 schema 范围内有效 ( 对于包含的子 schema 仍然有效 )。全局声明必须出现在 schema 文档中最顶级元素,而且在给定的 schema 或绑定定制文件中只能声明一次。比如我们可以通过 globalBindings 的 collectionType 属性来指定在映射的 Java 类中容器类使用我们指定的容器类。语法格式如下:
<globalBindings>
[ collectionType = "collectionType" ]
[ fixedAttributeAsConstantProperty = "true" | "false" | "1" | "0" ]
[ generateIsSetMethod = "true" | "false" | "1" | "0" ]
[ enableFailFastCheck = "true" | "false" | "1" | "0" ]
[ choiceContentProperty = "true" | "false" | "1" | "0" ]
[ underscoreBinding = "asWordSeparator" | "asCharInWord" ]
[ typesafeEnumBase = "typesafeEnumBase" ]
[ typesafeEnumMemberName = "generateName" | "generateError" ]
[ enableJavaNamingConventions = "true" | "false" | "1" | "0" ]
[ bindingStyle = "elementBinding" | "modelGroupBinding" ]
[ <JavaType> ... </JavaType> ]*
</globalBindings>
schema 绑定声明:通过这个注解可以实现从 XML schema 到产生 Java 类 / 接口的名称和包路径映射定制。比如我们可以通过指定 schemaBindings 的 package 属性来指定映射后 Java 类的包路径名称,通过 nameXmlTransform 属性来指定映射的 Java 类 / 接口名的前缀、后缀等。语法格式如下:
<schemaBindings>
[ <package> package </package> ]
[ <nameXmlTransform> ... </nameXmlTransform> ]*
</schemaBindings>
<package [ name = "packageName" ]
[ <Javadoc> ... </Javadoc> ]
</package>
<nameXmlTransform>
[ <typeName [ suffix="suffix" ]
[ prefix="prefix" ] /> ]
[ <elementName [ suffix="suffix" ]
[ prefix="prefix" ] /> ]
[ <modelGroupName [ suffix="suffix" ]
[ prefix="prefix" ] /> ]
[ <anonymousTypeName [ suffix="suffix" ]
[ prefix="prefix" ] /> ]
</nameXmlTransform>
更多精彩
赞助商链接