commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject cvs commit: jakarta-commons/betwixt/xdocs/guide derived.xml
Date Thu, 23 Sep 2004 21:46:01 GMT
rdonkin     2004/09/23 14:46:01

  Modified:    betwixt/src/java/org/apache/commons/betwixt
                        ElementDescriptor.java
                        IntrospectionConfiguration.java
                        XMLIntrospector.java
               betwixt/src/java/org/apache/commons/betwixt/digester
                        ElementRule.java
               betwixt/src/java/org/apache/commons/betwixt/io
                        AbstractBeanWriter.java
               betwixt/src/java/org/apache/commons/betwixt/io/read
                        BeanBindAction.java
               betwixt/src/resources dotbetwixt.dtd
               betwixt/src/test/org/apache/commons/betwixt/derived
                        TestDerived.java
               betwixt/xdocs navigation.xml tasks.xml
               betwixt/xdocs/guide derived.xml
  Log:
  Improved support for derived beans.
  
  Revision  Changes    Path
  1.18      +43 -0     jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java
  
  Index: ElementDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ElementDescriptor.java	4 Jul 2004 16:59:14 -0000	1.17
  +++ ElementDescriptor.java	23 Sep 2004 21:46:00 -0000	1.18
  @@ -98,6 +98,13 @@
         * or null if there is no separate implementation */
       private Class implementationClass = null;
       
  +    /** 
  +     * Should the bind time type determine the mapping? 
  +     * (As opposed to the introspection time type.)
  +     * Note that this attribute is write once, read many (WORM). 
  +     */
  +    private Boolean useBindTimeTypeForMapping = null;
  +    
       /**  
        * Constructs an <code>ElementDescriptor</code> that refers to a primitive
type.
        */
  @@ -617,4 +624,40 @@
       public void setHollow(boolean isHollow) {
           this.isHollow = isHollow;
       }  
  +    
  +    /**
  +     * Is the bind time type to be used to determine the mapping?
  +     * The mapping for an object property value can either be the 
  +     * introspection time type (based on the logical type of the property)
  +     * or the bind time type (based on the type of the actual instance).
  +     * 
  +     * @return true if the bind time type is to be used to determine the mapping,
  +     * false if the introspection time type is to be used
  +     */
  +    public boolean isUseBindTimeTypeForMapping() {
  +        boolean result = true;
  +        if ( this.useBindTimeTypeForMapping != null ) {
  +            result = this.useBindTimeTypeForMapping.booleanValue();
  +        }
  +        return result;
  +    }
  +
  +    /**
  +     * <p>Sets whether the bind time type to be used to determine the mapping?
  +     * The mapping for an object property value can either be the 
  +     * introspection time type (based on the logical type of the property)
  +     * or the bind time type (based on the type of the actual instance).
  +     * </p><p>
  +     * <strong>Note:</strong> this property is write once, read many.
  +     * So, the first time that this method is called the value will be set
  +     * but subsequent calls will be ignored.
  +     * </p>
  +     * @param useBindTimeTypeForMapping true if the bind time type is to be used to 
  +     * determine the mapping, false if the introspection time type is to be used
  +     */
  +    public void setUseBindTimeTypeForMapping(boolean useBindTimeTypeForMapping) {
  +        if ( this.useBindTimeTypeForMapping == null ) {
  +            this.useBindTimeTypeForMapping = new Boolean(useBindTimeTypeForMapping);
  +        }
  +    }
   }
  
  
  
  1.4       +28 -1     jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/IntrospectionConfiguration.java
  
  Index: IntrospectionConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/IntrospectionConfiguration.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- IntrospectionConfiguration.java	14 Jul 2004 21:38:17 -0000	1.3
  +++ IntrospectionConfiguration.java	23 Sep 2004 21:46:00 -0000	1.4
  @@ -19,6 +19,7 @@
   import org.apache.commons.betwixt.strategy.ClassNormalizer;
   import org.apache.commons.betwixt.strategy.DefaultNameMapper;
   import org.apache.commons.betwixt.strategy.DefaultPluralStemmer;
  +import org.apache.commons.betwixt.strategy.MappingDerivationStrategy;
   import org.apache.commons.betwixt.strategy.NameMapper;
   import org.apache.commons.betwixt.strategy.NamespacePrefixMapper;
   import org.apache.commons.betwixt.strategy.PluralStemmer;
  @@ -82,6 +83,11 @@
       private SimpleTypeMapper simpleTypeMapper = new StandardSimpleTypeMapper();
       /** Binding strategy for Java type */
       private TypeBindingStrategy typeBindingStrategy = TypeBindingStrategy.DEFAULT;
  +    /** 
  +     * Strategy used to determine whether the bind or introspection time type is to be
used to  
  +     * determine the mapping.
  +     */
  +    	private MappingDerivationStrategy mappingDerivationStrategy = MappingDerivationStrategy.DEFAULT;
       
       /**
         * Gets the <code>ClassNormalizer</code> strategy.
  @@ -320,5 +326,26 @@
        */
       public void setTypeBindingStrategy(TypeBindingStrategy typeBindingStrategy) {
           this.typeBindingStrategy = typeBindingStrategy;
  +    }
  +    
  +    
  +    /**
  +     * Gets the <code>MappingDerivationStrategy</code>
  +     * used to determine whether the bind or introspection time
  +     * type should determine the mapping.
  +     * @return <code>MappingDerivationStrategy</code>, not null
  +     */
  +    public MappingDerivationStrategy getMappingDerivationStrategy() {
  +        return mappingDerivationStrategy;
  +    }
  +    /**
  +     * Sets the <code>MappingDerivationStrategy</code>
  +     * used to determine whether the bind or introspection time
  +     * type should determine the mapping.
  +     * @param mappingDerivationStrategy <code>MappingDerivationStrategy</code>,
not null
  +     */
  +    public void setMappingDerivationStrategy(
  +            MappingDerivationStrategy mappingDerivationStrategy) {
  +        this.mappingDerivationStrategy = mappingDerivationStrategy;
       }
   }
  
  
  
  1.35      +20 -1     jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java
  
  Index: XMLIntrospector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- XMLIntrospector.java	27 Aug 2004 21:14:04 -0000	1.34
  +++ XMLIntrospector.java	23 Sep 2004 21:46:00 -0000	1.35
  @@ -674,7 +674,6 @@
               getLog().trace(elementDescriptor);
           }
       }
  -
       
       /**
        * Creates XMLBeanInfo for the given DynaClass.
  @@ -802,6 +801,26 @@
                   Method twinParameterAdder = (Method) it.next();
                   setMapAdder(elementsByPropertyName, twinParameterAdder);
               }
  +            
  +            // need to call this once all the defaults have been added
  +            // so that all the singular types have been set correctly
  +            configureMappingDerivation( rootDescriptor );
  +        }
  +    }
  +    
  +    /**
  +     * Configures the mapping derivation according to the current
  +     * <code>MappingDerivationStrategy</code> implementation.
  +     * This method acts recursively.
  +     * @param rootDescriptor <code>ElementDescriptor</code>, not null
  +     */
  +    private void configureMappingDerivation(ElementDescriptor descriptor) {
  +        boolean useBindTime = getConfiguration().getMappingDerivationStrategy()
  +        		.useBindTimeTypeForMapping(descriptor.getPropertyType(), descriptor.getSingularPropertyType());
  +        descriptor.setUseBindTimeTypeForMapping(useBindTime);
  +        ElementDescriptor[] childDescriptors = descriptor.getElementDescriptors();
  +        for (int i=0, size=childDescriptors.length; i<size; i++) {
  +            configureMappingDerivation(childDescriptors[i]);
           }
       }
       
  
  
  
  1.17      +8 -0      jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/ElementRule.java
  
  Index: ElementRule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/ElementRule.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ElementRule.java	4 Jul 2004 16:40:49 -0000	1.16
  +++ ElementRule.java	23 Sep 2004 21:46:00 -0000	1.17
  @@ -102,6 +102,14 @@
                       + " property=" + propertyName + " type=" + propertyType);
           }
           
  +        // set mapping derivation
  +        String mappingDerivation = attributes.getValue( "mappingDerivation" );
  +        if ( "introspection".equals(mappingDerivation) ) {
  +            descriptor.setUseBindTimeTypeForMapping( false );
  +        } else if ( "bind".equals(mappingDerivation) ) {
  +            descriptor.setUseBindTimeTypeForMapping( true );
  +        }
  +        
           // set the property type using reflection
           descriptor.setPropertyType( 
               getPropertyType( propertyType, beanClass, propertyName ) 
  
  
  
  1.32      +38 -1     jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/AbstractBeanWriter.java
  
  Index: AbstractBeanWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/AbstractBeanWriter.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- AbstractBeanWriter.java	24 Aug 2004 21:00:50 -0000	1.31
  +++ AbstractBeanWriter.java	23 Sep 2004 21:46:00 -0000	1.32
  @@ -225,6 +225,8 @@
        * @param namespaceUri the namespace uri
        * @param localName the local name
        * @param qualifiedName the string naming root element
  +     * @param introspectedBindType the <code>Class</code> of the bean 
  +     * as resolved at introspection time, or null if the type has not been resolved
        * @param bean the <code>Object</code> to write out as xml
        * @param context not null
        * 
  @@ -254,6 +256,39 @@
           log.trace( "Finished writing bean graph." );
       }
       
  +    
  +    private void writeBean (
  +            String namespaceUri,
  +            String localName,
  +            String qualifiedName, 
  +            Object bean,
  +            ElementDescriptor parentDescriptor,
  +            Context context) 
  +                throws 
  +                    IOException, 
  +                    SAXException,
  +                    IntrospectionException {                    
  +    
  +    if ( log.isTraceEnabled() ) {
  +        log.trace( "Writing bean graph (qualified name '" + qualifiedName + "'" );
  +    }
  +    
  +    // introspect to obtain bean info
  +    XMLBeanInfo beanInfo = null;
  +    Class introspectedBindType = parentDescriptor.getSingularPropertyType();
  +    if ( introspectedBindType == null ) {
  +        introspectedBindType = parentDescriptor.getPropertyType();
  +    }
  +    if ( parentDescriptor.isUseBindTimeTypeForMapping() || introspectedBindType == null
) {
  +        beanInfo = introspector.introspect( bean );
  +    } else {
  +        beanInfo = introspector.introspect( introspectedBindType );
  +    }
  +    writeBean(namespaceUri, localName, qualifiedName, bean, context, beanInfo);
  +    
  +    log.trace( "Finished writing bean graph." );
  +}
  +    
       /**
        * <p>Writes the given bean to the current stream 
        * using the given mapping.</p>
  @@ -900,6 +935,7 @@
                                               localName, 
                                               qualifiedName, 
                                               object, 
  +                                            childDescriptor,
                                               context );
                                   }
                               } else {
  @@ -908,6 +944,7 @@
                                               localName, 
                                               qualifiedName, 
                                               childBean, 
  +                                            childDescriptor,
                                               context );
                               }
                           }                    
  
  
  
  1.3       +17 -4     jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/read/BeanBindAction.java
  
  Index: BeanBindAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/read/BeanBindAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BeanBindAction.java	13 Jun 2004 21:32:45 -0000	1.2
  +++ BeanBindAction.java	23 Sep 2004 21:46:00 -0000	1.3
  @@ -78,6 +78,10 @@
                       
               if (instance != null) {
                   action = this;
  +                if (computedDescriptor.isUseBindTimeTypeForMapping())
  +                {
  +                    beanClass = instance.getClass();
  +                }
                   context.markClassMap(beanClass);
   
                   if (log.isTraceEnabled()) {
  @@ -92,7 +96,6 @@
                   // XXX: this should probably be done by the NodeDescriptors...
                   ElementDescriptor typeDescriptor =
                       getElementDescriptor(computedDescriptor, context);
  -                //ElementDescriptor typeDescriptor = descriptor;
   
                   // iterate through all attributes        
                   AttributeDescriptor[] attributeDescriptors =
  @@ -196,7 +199,7 @@
           }
   
           // TODO: beanClass can be deduced from descriptor
  -        // so probably 
  +        // so this feels a little over-engineered
           mapping.setType(beanClass);
           mapping.setNamespace(namespace);
           mapping.setName(name);
  @@ -219,15 +222,25 @@
       * referenced by this descriptor
       * @return descriptor for the singular property class type referenced.
       */
  -    ElementDescriptor getElementDescriptor(
  +    private ElementDescriptor getElementDescriptor(
           ElementDescriptor propertyDescriptor,
           ReadContext context) {
           Log log = context.getLog();
           Class beanClass = propertyDescriptor.getSingularPropertyType();
  +        if (propertyDescriptor.isUseBindTimeTypeForMapping()) {
  +            // use the actual bind time type
  +            Object current = context.getBean();
  +            if (current != null) {
  +                beanClass = current.getClass();
  +            }
  +        }
           if (beanClass != null && !Map.class.isAssignableFrom(beanClass)) {
               if (beanClass.isArray()) {
                   beanClass = beanClass.getComponentType();
               }
  +            // support for derived beans
  +            
  +            
               if (log.isTraceEnabled()) {
                   log.trace("Filling descriptor for: " + beanClass);
               }
  
  
  
  1.10      +2 -1      jakarta-commons/betwixt/src/resources/dotbetwixt.dtd
  
  Index: dotbetwixt.dtd
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/resources/dotbetwixt.dtd,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- dotbetwixt.dtd	4 Jul 2004 17:03:14 -0000	1.9
  +++ dotbetwixt.dtd	23 Sep 2004 21:46:00 -0000	1.10
  @@ -55,6 +55,7 @@
       property CDATA #IMPLIED
       updater CDATA #IMPLIED
       class CDATA #IMPLIED
  +    mappingDerivation (bind|introspection) #IMPLIED
     >
   
   <!-- Use for mixed content text -->
  
  
  
  1.7       +3 -12     jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/derived/TestDerived.java
  
  Index: TestDerived.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/derived/TestDerived.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestDerived.java	28 Feb 2004 13:38:35 -0000	1.6
  +++ TestDerived.java	23 Sep 2004 21:46:01 -0000	1.7
  @@ -48,12 +48,6 @@
       public void testPersonList() throws Exception {
   
           BeanReader reader = new BeanReader();
  -//        reader.getXMLIntrospector().setLog(log);
  -              
  -//        SimpleLog log = new SimpleLog("[TestPersonList:BeanReader]");
  -//        log.setLevel(SimpleLog.LOG_LEVEL_TRACE);
  -        
  -//        reader.setLog(log);
           reader.registerBeanClass( PersonListBean.class );
           
           InputStream in =  
  @@ -87,11 +81,8 @@
           PersonBean manager = (PersonBean) bean.getPersonList().get(2);
           assertEquals("should be derived class", "org.apache.commons.betwixt.derived.ManagerBean",
manager.getClass().getName());
   
  -        // derived properties are not implemented yet...        
  -/*
  -        ManagerBean manager2 = (ManagerBean) manager;
  -        assertEquals("should have a derived property", 12, manager2.getCheeseSize());
  -*/        
  +        // test derived properties       
  +        //assertEquals("should have a derived property", 12, ((ManagerBean) manager).getCheeseSize());
       }
       
   }
  
  
  
  1.16      +1 -1      jakarta-commons/betwixt/xdocs/navigation.xml
  
  Index: navigation.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/xdocs/navigation.xml,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- navigation.xml	3 Jul 2004 11:18:02 -0000	1.15
  +++ navigation.xml	23 Sep 2004 21:46:01 -0000	1.16
  @@ -44,7 +44,7 @@
       <menu name="User guide">
         <item name="Getting Started"         href="/guide/start.html"/>
         <item name="Binding Beans"           href="/guide/binding.html"/>
  -      <item name="Derived Beans"           href="/guide/derived.html"/>
  +      <item name="Derived Bindings"        href="/guide/derived.html"/>
         <item name="Writing Beans(Advanced)" href="/guide/writing.html"/>
         <item name="Outputing The Results"   href="/guide/output.html"/>
         <item name="Reading Beans(Advanced)" href="/guide/reading.html"/>
  
  
  
  1.35      +8 -0      jakarta-commons/betwixt/xdocs/tasks.xml
  
  Index: tasks.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/xdocs/tasks.xml,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- tasks.xml	27 Aug 2004 21:13:36 -0000	1.34
  +++ tasks.xml	23 Sep 2004 21:46:01 -0000	1.35
  @@ -194,6 +194,8 @@
               documents can be passed in directly.</li>
               <li><strong>Multi mapping</strong> documents allowing several
mappings to be
               specified within a single document.</li>
  +            <li><strong>Improved support for derived beans</strong> bind
time type
  +            population now supported and enabled by default</li>
           </ul>
       </subsection>
       <subsection name='0.6'>
  @@ -440,6 +442,12 @@
   The old behaviour can be restored by setting the <code>ValueSuppressionStrategy</code>
   of the <code>BindingConfiguration</code> used by the writer to 
   <code>ValueSuppressionStrategy.ALLOW_ALL_VALUES</code>.
  +            </li>
  +            <li>
  +Betwixt now defaults to bind time type mapping. Now read beans will (by default)
  +be populated by their bind time type (as opposed to their introspection time type).
  +Most users should notice no negative effects from this change. The previous behaviour
  +can be enabled by setting an introspection configuration property.
               </li>
           </ul>
       </subsection>
  
  
  
  1.4       +130 -2    jakarta-commons/betwixt/xdocs/guide/derived.xml
  
  Index: derived.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/xdocs/guide/derived.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- derived.xml	4 Jul 2004 16:40:16 -0000	1.3
  +++ derived.xml	23 Sep 2004 21:46:01 -0000	1.4
  @@ -26,10 +26,138 @@
   <section name='Derived Beans'>
           <subsection name='What Is A Derived Bean?'>
               <p>
  -A derived bean has the implementating class specified as an xml attribute.
  -Instances will be created of this type (rather than the mapped property type).
  +A derived bean is one which runtime class differs from the mapped property type
  +(as determined during introspection).
                   </p>
       </subsection>   
  +</section>
  +    <section name='Specifying The Bind Time Type'>
  +        <subsection name='Using An Attribute To Specify Class'>
  +            <p>
  +An easy way to specify the class to be loaded is for the class name to be 
  +specified by an xml attribute. By default, the <code>className</code> attribute
  +(if present) is assumed to contain the name of the class to be loaded. 
  +        </p>
  +            <p>
  +For example the following xml:
  +        </p>
  +<source><![CDATA[
  +    <Animals> 
  +        <animal className='org.apache.commons.betwixt.io.read.FerretBean'> 
  +            <call>Dook</call>
  +            <colour>albino</colour> 
  +            <latinName>Mustela putoris furo</latinName>
  +            <name>Lector</name> 
  +        </animal> 
  +        <animal className='org.apache.commons.betwixt.io.read.CatBean'> 
  +            <call>Meow</call>
  +            <colour>black</colour> 
  +            <latinName>Felis catus</latinName>
  +            <name>Sam</name> 
  +        </animal> 
  +        <animal className='org.apache.commons.betwixt.io.read.DogBean'> 
  +            <breed>mongrol</breed>
  +            <call>Woof</call>
  +            <latinName>Canis familiaris</latinName> 
  +            <name>Bobby</name>
  +            <pedigree>false</pedigree> 
  +        </animal> 
  +    </Animals>
  +]]>
  +</source>
  +            <p>
  +will construct objects of type <code>FerretBean</code>, <code>CatBean</code>
and 
  +<code>DogBean</code>.
  +        </p>
  +            <p>
  +The attribute which contains the fully qualified class name can be configured through
  +the <code>classNameAttribute</code> property of the <code>BindingConfiguration</code>.
  +        </p>
  +            <p>
  +The classname mapping is implemented by a <code>ChainedBeanCreator</code>.
If this
  +feature is not required, a custom bean creation chain should be used.
  +        </p>
  +    </subsection>
  +</section>
  +    <section name='Mapping Derived Beans'>
  +        <subsection name="Bind Time Type Verses Introspection Time Type">
  +            <p>
  +The introspection time type is the (expected) type as discovered during introspection.
  +The bind time type is the actual type of the object found as Betwixt runs. For example,
  +a property might have type <code>Animal</code> but when the getter of that
property is 
  +called, the object returned might be a subclass (if <code>Animal</code> is
a class) 
  +or an implementation (if <code>Animal</code> is an interface) - <code>Cat</code>,
say.
  +In this case, <code>Animal</code> would be the introspection time type but
<code>Cat</code>
  +the bind time type.
  +        </p>
  +            <p>
  +There are two approaches to deal with this situation: either the object can be mapped 
  +on the basis of it's bind time type (the actual class of the object) or on the basis
  +of it's introspection time type. In the first case, all the properties present will be

  +mapped, in the second only a subset.
  +        </p>    
  +            <p>
  +For example, say that <code>Animal</code> has properties <code>latinName</code>
  +and <code>call</code> and that <code>Cat</code> is a subclass with
an additional
  +<code>colour</code> property. Consider a bean with a property returning an
<code>Animal</code>.
  +If the introspection time type is used, only the <code>latinName</code>
  +and <code>call</code> properties of a<code>Cat</code> bean will
be read and written
  +whereas when bind time typing is used, all properties will be.
  +        </p>
  +            <p>
  +There are typical use cases which demonstate the need for each approach. Betwixt 
  +supports both in a flexible way, for both reading and writing but defaults to 
  +bind time typing (which is typically more intuitive).
  +        </p>
  +    </subsection>
  +        <subsection name='Configuring Mapping Derivation'>
  +            <p>
  +Whether the bind time type or the introspection time type should determine the mapping
  +is configurable in two different ways. The <code>MappingDerivationStrategy</code>

  +implementation set on the introspection configuration allows powerful but course-grained
  +control over which types of property should have their mappings determine in which ways.
  +Per-element control is also available through the dot betwixt document. This is typically
  +used for more finely grained refinements. The dot betwixt settings override the strategy.
  +        </p>
  +            <p>
  +For example, the following code snippet configures an <code>XMLIntrospector</code>

  +so that (unless overriden by a dot betwixt document setting), introspection time types
  +will determine the mapping:
  +        </p>
  +<source><![CDATA[
  +        XMLIntrospector xmlIntrospector = ...;
  +        xmlIntrospector.getConfiguration()
  +            .setMappingDerivationStrategy(
  +                MappingDerivationStrategy.USE_INTROSPECTION_TIME_TYPE);
  +}	
  +]]></source>
  +            <p>
  +The optional <code>mappingDerivation</code> attribute on an <code>&lt;element&gt;</code>
element.
  +This attribute takes two enumerated values: <code>bind</code> and <code>introspection</code>.
  +As might be expected, <code>bind</code> indicates that the element should use

  +the bind time type whereas <code>introspection</code> indicates that the introspection
time
  +type should be used.
  +        </p>
  +            <p>
  +For example, when the following dot betwixt document is used, the <code>pet</code>
  +property's mapping will be dertermined by the introsection time type mapping.
  +        </p>
  +<source><![CDATA[
  +    <?xml version='1.0'?>
  +    <info>
  +        <element name='pet-record'>
  +            <element name='pet' property='pet' mappingDerivation='introspection'/>"
+
  +        </element>
  +    </info>"
  +}	
  +]]></source>
  +
  +            <p>
  +Note that the mapping derivations are added together with all of the other defaults
  +and so all elements without the <code>mappingDerivation</code> attribute will
  +default to bind time typing unless and <code>addDefaults</code> is present.
  +        </p>
  +    </subsection>
   </section>
   </body>
   </document>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message