Hi,
In attempt to analyze JIRA-1317, I had some questions and would like to get
some
points clear.

1)Tuscany xmlHelperImpl have load() method where options can be passed in.
Why save() methods with
XMLDocument only have options supported and not for save() methods with
DataObject?

2)Why ResolvableImpl is in tuscany-sdo-lib, should it not be in
tuscany-sdo-impl? As this class is
in tuscany-sdo-lib and not tuscany-sdo-impl, it can not make use of options
implementation in tuscany-sdo-impl,
as these impl classes are not visible in tuscany-sdo-lib.

3)What is meaning of  below code in XMLDocumentImpl?
if (options instanceof Map)
   {
     Class resourceFactoryClass =
(Class)((Map)options).get("GENERATED_LOADER");
     if (resourceFactoryClass != null)
     {
       try
       {
         Object resourceFactory = resourceFactoryClass.newInstance();
         
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*",
resourceFactory);
       }
       catch (Exception e)
       {
         e.printStackTrace();
       }
     }
   }
4)To provide code fix, code will change in (this is what I have thought so
far)
*HelperProviderBase->HelperProviderImpl->HelperContextImpl - constructor to
have options,
*XMLHelperImpl-to have member defaultOptions.
*tuscany-sdo-lib -SDOUtil code - SDOUtil.setDefaultXMLOptions(options)

A typical test case will look like -
   public void testXMLOptions() throws IOException{
    options = new HashMap();
    options.put(SDOHelper.XMLOptions.XML_SAVE_LINE_BREAK, new Integer(1));

((HelperProviderBase)HelperProvider.INSTANCE).createDefaultHelpers(options);

    XMLHelper xmlHelper =
((HelperProviderBase)HelperProvider.INSTANCE).xmlHelper();

    String xml="<?xml version=\"1.0\" encoding=\"ASCII\"?> " +
       "<simple:stockQuote
xmlns:simple=\"www.example.com/simple\<http://www.example.com/simple/>">
" +
       "<symbol>fbnt \n </symbol> " +
       "<companyName>FlyByNightTechnology</companyName> " +
       "<price>1000.0</price> " +
       "<open1>1000.0</open1> " +
       "<high>1000.0</high> " +
       "<low>1000.0</low> " +
       "<volume>1000.0</volume> " +
       "<change1>1000.0</change1> " +
       "<quotes> " +
           "<price>2000.0</price> " +
       "</quotes> " +
   "</simple:stockQuote>";

    XMLDocument xmlDoc = xmlHelper.load(new StringReader(xml), null, null);
    DataObject root = xmlDoc.getRootObject();
    List symbols = root.getList("symbol");
       DataObject symbol = (DataObject)symbols.get(0);
       String seqValue = (String)symbol.getSequence().getValue(0);
       System.out.println("seqValue:"+seqValue+ "done");
       System.out.println("index:"+seqValue.indexOf('\n'));
       assertEquals(5, seqValue.indexOf('\n'));
   }
5)When providing fix for this JIRA, when caller to load/save provides
options, these will override defaultOptions from XMLHelperImpl

6) What is being done in SDOXMLResourceImpl? How options are processed here?

7) Why SDOUtil is lying in tuscany-sdo-impl and is used in many places? Are
new changes
supposed to be done only in tuscany-sdo-lib/SDOUtil?

Please let me know some details for above and I will be happy to ask more
questions :)

Regards,
Amita

Reply via email to