I'm looking at the org.jboss.test.xml.MultispacedUnitTestCase which 
demonstrates unmarshalling a document that has two schemas/namespaces for two 
object models that are loosely coupled via a one-one unidirectional 
relationship. The two object models are the XMBeanMetaData and JDBCPm. A 
XMBeanMetaData can contain a JDBCPm, but the coupling in terms of type is that 
the XMBeanMetaData.persistenceManager is just an Object.

Now what I see in the XMBeanMetaDataFactory which knows how to unmarshall 
XMBeanMetaData instances from xml and the JDBCPmMetaDataFactory which knows how 
to unmarshall JDBCPm instances from xml, that the JDBCPmMetaDataFactory has an 
explicit type coupling to the particular usage context of an XMBeanMetaData 
containing a JDBCPm. This shows up in the following JDBCPmMetaDataFactory 
method:


  |    public void addChild(XMBeanMetaData xmbean,
  |                         JDBCPm pm,
  |                         ContentNavigator navigator,
  |                         String namespaceURI,
  |                         String localName)
  |    {
  |       xmbean.setPersistenceManager(pm);
  |    }
  | 

This should really be the other way around. The XMBeanMetaDataFactory  knows 
that is supports a persistence element of type="xs:anyType" as the injection 
point for the persistenceManager. So, the XMBeanMetaDataFactory is the factory 
which should have binding method:


  |    public void bind(XMBeanMetaData xmbean,
  |                         Object pm,
  |                         ContentNavigator navigator,
  |                         String namespaceURI,
  |                         String localName)
  |    {
  |       xmbean.setPersistenceManager(pm);
  |    }
  | 

This way, all ObjectModelFactory implementations deal with only the object 
models they understand. As the example currently exists, the 
JDBCPmMetaDataFactory has to know about every context in which its used.

Would this be a difficult change to make?


View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3859157#3859157

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3859157


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to