You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ke...@apache.org on 2007/06/20 13:01:59 UTC

svn commit: r549061 - in /incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo: ./ otherSources/ specCodeSnippets/ specExampleSection/ tuscanyapi/

Author: kelvingoodson
Date: Wed Jun 20 04:01:57 2007
New Revision: 549061

URL: http://svn.apache.org/viewvc?view=rev&rev=549061
Log:
More sample updates. I have updated AccessingDataObjectPropertiesByName and I have added an alternative means (ExecuteSamples2) of executing multiple samples that makes use of the new infrastructure.  This only has added to it the samples I have worked on.  I plan to switch over to this being the main method of executing multiple samples when more of the changes have been made.

Added:
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples2.java   (with props)
Modified:
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleBase.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleInfrastructure.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/CreateCompany.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/CreatePurchaseOrder.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/PurchaseOrderControl.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/ReadPurchaseOrder.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/AccessDataObjectPropertiesByName.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/AccessDataObjectUsingValidXPath.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/CreateDataObjectFromXmlString.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/CreateDataObjectFromXsdAndXmlFiles.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/DynamicCustomerTypeSample.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/ObtainingDataGraphFromXml.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/PrintPropertiesOfDataObject.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/UsingXPath.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessDataObjectsUsingXPath.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingDataObjectsViaPropertyIndex.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingTheContentsOfASequence.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingDataObjectTreesFromXMLDocuments.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingXmlFromDataObjects.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/SerializingDesearializingADataObject.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/UsingTypeAndPropertyWithDataObjects.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/tuscanyapi/CreateCompany.java

Added: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples2.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples2.java?view=auto&rev=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples2.java (added)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples2.java Wed Jun 20 04:01:57 2007
@@ -0,0 +1,58 @@
+/**
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.tuscany.samples.sdo;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.samples.sdo.specCodeSnippets.AccessDataObjectPropertiesByName;
+
+public class ExecuteSamples2 {
+  
+  public static Class[] sampleClasses = {
+    org.apache.tuscany.samples.sdo.otherSources.CreateCompany.class,     // NOVICE level samples
+    AccessDataObjectPropertiesByName.class,
+    
+    org.apache.tuscany.samples.sdo.tuscanyapi.CreateCompany.class        // INTERMEDIATE level samples
+                                                                         // ADVANCED level samples
+   
+  };
+  
+  public static Class[] constructorArgTypes = { Integer.class };
+
+  /*
+   * Edit the value of this argument to one of NOVICE, INTERMEDIATE or ADVANCED to see
+   * more or less commentary.  Note,  this value only controls the level of commentary,
+   * not which samples are executed.  Use it to filter out the noise if you have already
+   * understood the more basic commentary.
+   */
+  public static Object[] constructorArgs = { SampleInfrastructure.NOVICE };  
+  
+  public static void main(String [] args) throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
+
+//    
+    for (int i=0; i < sampleClasses.length; i++) {
+      Constructor c = sampleClasses[i].getConstructor(constructorArgTypes);
+      SampleBase sample = (SampleBase)c.newInstance(constructorArgs);
+      sample.run();
+    }
+    
+  }
+}

Propchange: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples2.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleBase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleBase.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleBase.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleBase.java Wed Jun 20 04:01:57 2007
@@ -30,7 +30,12 @@
 import commonj.sdo.helper.XSDHelper;
 import commonj.sdo.impl.HelperProvider;
 
-public class SampleBase extends SampleInfrastructure {
+/**
+ * the base function for samples is split into two classes.  This one is intended
+ * to house all the interesting SDO utility methods,  and the superclass houses
+ * all the infrastructure that the SDO user isn't interested in inspecting.
+ */
+public abstract class SampleBase extends SampleInfrastructure {
 
 
   public SampleBase()
@@ -38,7 +43,7 @@
     super(NOVICE);
   }
   
-  public SampleBase(int userLevel) {
+  public SampleBase(Integer userLevel) {
     super(userLevel);
 
   }
@@ -51,7 +56,7 @@
         "The Helper Context instance provides access to a collection of other helpers\n" +
         "that you will see exercised in the SDO samples\n" +
         "All the Helpers related to a given helper context instance know about the same set of types\n\n" +
-        "The SDO specification doesn't currently state how an SDO implementation should create a HelperContext\n" +
+        "The SDO specification doesn't state how an SDO implementation should create a HelperContext\n" +
         "So we use a Tuscany specific API to do this ...\n\n" +
         "HelperContext scope = SDOUtil.createHelperContext();",
         
@@ -89,7 +94,8 @@
         "use an instance of XSDHelper. You get that helper from a HelperContext.\n" +
         "After successful loading of a schema, the new types are available to every\n" +
         "other helper belonging to the HelperContext instance\n\n" +
-        "XSDHelper xsdHelper = scope.getXSDHelper();",
+        "XSDHelper xsdHelper = scope.getXSDHelper();\n"+
+        "xsdHelper.define(inputStream, null);",
         
         "Using an XSDHelper again to create types from an XML schema file"
         );

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleInfrastructure.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleInfrastructure.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleInfrastructure.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleInfrastructure.java Wed Jun 20 04:01:57 2007
@@ -29,27 +29,26 @@
 
 import commonj.sdo.helper.HelperContext;
 
-public class SampleInfrastructure {
+public abstract class SampleInfrastructure {
 
   
   /*
    * sample program infrastructure
    */
-  protected int userLevel = NOVICE;
-  private Set commentaryHistory = new HashSet();
+  protected int userLevel = NOVICE.intValue();
+  private static Set commentaryHistory = new HashSet();
   
-  public SampleInfrastructure (int userLevel) {
-    this.userLevel = userLevel;
+  public SampleInfrastructure (Integer novice2) {
+    this.userLevel = novice2.intValue();
   }
   
   private static String hrule = "********************************************";
-  protected static final int NOVICE = 1;
-  protected static final int INTERMEDIATE = 2;
-  protected static final int ADVANCED = 3;
-  
-  protected static final String noviceStr = " novice ";
-  protected static final String intermediateStr = " intermediate ";
-  protected static final String advancedStr = " advanced ";
+  protected static final Integer NOVICE = new Integer(0);
+  protected static final Integer INTERMEDIATE = new Integer(1);
+  protected static final Integer ADVANCED = new Integer(2);
+  protected static final Integer ALWAYS = new Integer(3);
+  
+  protected static final String[] userLevels = {"NOVICE","INTERMEDIATE","ADVANCED","ALWAYS"};
   
   public void banner(char borderChar, String text) {
     if(text == null || text.length() == 0) {
@@ -85,9 +84,9 @@
     banner('-', text);
   }
   
-  protected void commentary(int commentLevel, String text, String repeatText) {
+  protected void commentary(Integer commentLevel, String text, String repeatText) {
 
-    if(commentLevel < userLevel) return;
+    if(commentLevel.intValue() < userLevel) return;
     
     if(repeatText != null)  {
       boolean alreadySeen = commentaryHistory.contains(text);
@@ -103,8 +102,8 @@
     
   }
   
-  protected void commentary(int commentLevel, String text) {
-    if(commentLevel >= userLevel) {
+  protected void commentary(Integer commentLevel, String text) {
+    if(commentLevel.intValue() >= userLevel) {
       banner(text);
     }
   }
@@ -145,6 +144,26 @@
           return false;
       }
   }
+  
+  public void run() {
+    
+    commentary(ALWAYS,"    Tuscany SDO Java Sample " + this.getClass().getName() + "    ");
+    commentary(INTERMEDIATE, "Running with commentary level for a " + userLevels[userLevel] + " user\n"+
+        "Edit the sample program's constructor argument to one from NOVICE, INTERMEDIATE or ADVANCED\n"+
+        "in order to alter the level of commentary you are seeing",
+        "");
+    
+    try {
+      runSample();
+    } catch (Exception e) {
+      somethingUnexpectedHasHappened(e);
+    }
+    finally {   
+      commentary(ALWAYS, "    End of sample "  + this.getClass().getName() + "    ");
+    }
+  }
+  
+  public abstract void runSample() throws Exception ;
   
   
 }

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/CreateCompany.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/CreateCompany.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/CreateCompany.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/CreateCompany.java Wed Jun 20 04:01:57 2007
@@ -62,8 +62,8 @@
  */
 public class CreateCompany extends SampleBase {
 
-    public CreateCompany(int userLevel) {
-      super(userLevel);
+    public CreateCompany(Integer novice) {
+      super(novice);
     }
 
     /**
@@ -79,23 +79,20 @@
     public static void main(String[] args) {
       /*
        * this sample is suitable for a novice to SDO.
-       * Change the experience level argument to change
+       * Change the experience level constructor argument to one of
+       * NOVICE, INTERMEDIATE, ADVANCED, change
        * the level of commentary output.
        */
       CreateCompany sample = new CreateCompany(NOVICE);
 
-      try {
-        sample.run();
-      }
-      catch (Exception e) {
-        sample.somethingUnexpectedHasHappened(e);
-      }
+
+      sample.run();
+
     }
 
-    public void run () throws Exception {
+    public void runSample () throws Exception {
       
         banner('*',
-               "               SDO Sample Create Company                 \n\n"+
                "Demonstrates how to create a data graph using a model loaded\n"+
                "from an XML Schema contained in a file on the file system");
                 

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/CreatePurchaseOrder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/CreatePurchaseOrder.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/CreatePurchaseOrder.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/CreatePurchaseOrder.java Wed Jun 20 04:01:57 2007
@@ -81,8 +81,8 @@
 
 public class CreatePurchaseOrder extends SampleBase {
 
-    public CreatePurchaseOrder(int userLevel) {
-      super(userLevel);
+    public CreatePurchaseOrder(Integer intermediate) {
+      super(intermediate);
     }
 
     /**
@@ -114,15 +114,12 @@
       // TODO make the default level NOVICE, once the rest of the sample has been
       // converted to using commentary()
       CreatePurchaseOrder sample = new CreatePurchaseOrder(INTERMEDIATE);
-      try {
-        sample.run();
-      }
-      catch (Exception e) {
-        sample.somethingUnexpectedHasHappened(e);
-      }
+
+      sample.run();
+
     }
     
-    public void run() throws Exception {
+    public void runSample() throws Exception {
         try {
 
             System.out.println("***************************************");

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/PurchaseOrderControl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/PurchaseOrderControl.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/PurchaseOrderControl.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/PurchaseOrderControl.java Wed Jun 20 04:01:57 2007
@@ -352,7 +352,26 @@
         // for an example of accessing properties by name see
         // AccessDataObjectPropertiesByName or
         // the method below printAddressInfo
-        AccessDataObjectPropertiesByName.printPurchaseOrderSummary(purchaseOrder);
+        System.out.println("Purchase Order: ");
+        System.out.println("    Order date: " + purchaseOrder.get("orderDate"));
+        System.out.println("    Comment: " + purchaseOrder.get("comment"));
+        
+        DataObject shipTo = purchaseOrder.getDataObject("shipTo");
+        System.out.println("    Ship to name: " + shipTo.get("name"));
+        
+        DataObject billTo = purchaseOrder.getDataObject("billTo");
+        System.out.println("    Bill to name: " + billTo.get("name"));
+        
+        DataObject items = purchaseOrder.getDataObject("items");
+        List itemList = items.getList("item");
+        
+        System.out.println("    Items:");
+        for (int i = 0; i < itemList.size(); i++) {
+            DataObject item = (DataObject) itemList.get(i);
+            System.out.println("        Item " + i);
+            System.out.println("            Part num: " + item.get("partNum"));
+            System.out.println("            Product name: " + item.get("productName"));
+        }
     }
 
     /**
@@ -497,5 +516,11 @@
 
         }// end of switch
 
+    }
+
+    public void runSample() throws Exception {
+      // TODO Auto-generated method stub
+      // FIXME make this sample fit the pattern
+      
     }
 }

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/ReadPurchaseOrder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/ReadPurchaseOrder.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/ReadPurchaseOrder.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/ReadPurchaseOrder.java Wed Jun 20 04:01:57 2007
@@ -79,7 +79,7 @@
 
 
   
-    public ReadPurchaseOrder(int userLevel) {
+    public ReadPurchaseOrder(Integer userLevel) {
       super(userLevel);
     }
 
@@ -107,7 +107,7 @@
       }
     }
 
-    public void run () throws Exception {
+    public void runSample () throws Exception {
         System.out.println("***************************************");
         System.out.println("SDO Sample ReadPurchaseOrder");
         System.out.println("***************************************");

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/AccessDataObjectPropertiesByName.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/AccessDataObjectPropertiesByName.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/AccessDataObjectPropertiesByName.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/AccessDataObjectPropertiesByName.java Wed Jun 20 04:01:57 2007
@@ -73,35 +73,47 @@
  */
 public class AccessDataObjectPropertiesByName extends SampleBase {
 
-    HelperContext scope;
-
-    public AccessDataObjectPropertiesByName(int userLevel) {
+    public AccessDataObjectPropertiesByName(Integer userLevel) {
       super(userLevel);
     }
 
-    /**
-     * Prints a subset of PurchaseOrder properties to System.out
-     * 
-     * @param purchaseOrder.
-     *            DataObject defined by Types in
-     *            {@link org.apache.tuscany.samples.sdo.SdoSampleConstants#PO_XSD_RESOURCE}
-     */
-    public static void printPurchaseOrderSummary(DataObject purchaseOrder) {
 
-        // example accessing properties via property names
+    public static void main(String[] args) {
+      /*
+       * This sample is well suited to exploration by a novice user
+       */
+      AccessDataObjectPropertiesByName sample = new AccessDataObjectPropertiesByName(NOVICE);
+      sample.run();
+
+    }
+
+    public void runSample () throws Exception {
+
+        banner("This sample will access a DataObject's properties by name\n"+
+            "Take a look at the sample code to see all the uses of dataObject.get(String)\n"+
+            "dataObject.getList(String) and dataobhect.getdataObject(String)");
+
+        // setting up the type system for the example,  see the utility methods for details of these operations
+        HelperContext scope = createScopeForTypes();
+        loadXMLSchemaFromFile(scope, SdoSampleConstants.PO_XSD_RESOURCE);
+
+        DataObject purchaseOrder = loadXMLFromFile(scope, SdoSampleConstants.PO_XML_RESOURCE);
+
+
+        System.out.println("Accessing properties by name");
         System.out.println("Purchase Order: ");
         System.out.println("    Order date: " + purchaseOrder.get("orderDate"));
         System.out.println("    Comment: " + purchaseOrder.get("comment"));
-
+        
         DataObject shipTo = purchaseOrder.getDataObject("shipTo");
         System.out.println("    Ship to name: " + shipTo.get("name"));
-
+        
         DataObject billTo = purchaseOrder.getDataObject("billTo");
         System.out.println("    Bill to name: " + billTo.get("name"));
-
+        
         DataObject items = purchaseOrder.getDataObject("items");
         List itemList = items.getList("item");
-
+        
         System.out.println("    Items:");
         for (int i = 0; i < itemList.size(); i++) {
             DataObject item = (DataObject) itemList.get(i);
@@ -109,64 +121,7 @@
             System.out.println("            Part num: " + item.get("partNum"));
             System.out.println("            Product name: " + item.get("productName"));
         }
-    }
-
-    /**
-     * Prints properties of a purchase order DataObject( properties are defined in
-     * the xsd
-     * {@link org.apache.tuscany.samples.sdo.SdoSampleConstants#PO_XSD_RESOURCE} and
-     * populated by xml
-     * {@link org.apache.tuscany.samples.sdo.SdoSampleConstants#PO_XML_RESOURCE} )
-     * 
-     * @param args.
-     *            No parameters required.
-     */
-    public static void main(String[] args) {
-      // TODO make the default level NOVICE, once the rest of the sample has been
-      // converted to using commentary()
-      AccessDataObjectPropertiesByName sample = new AccessDataObjectPropertiesByName(INTERMEDIATE);
-
-      try {
-        sample.run();
-      }
-      catch (Exception e) {
-        sample.somethingUnexpectedHasHappened(e);
-      }
-    }
-
-    public void run () throws Exception {
-
-        // information
-        System.out.println("***************************************");
-        System.out.println("SDO Sample AccessDataObjectPropertiesByName");
-        System.out.println("***************************************");
-        System.out.println("This sample will access a DataObject properties by name");
-        System.out.println("***************************************");
-
-        // create a DataObejct
-        scope = createScopeForTypes();
-        
-        DataObject purchaseOrder = null;
-        try {
-            scope.getXSDHelper().define(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.PO_XSD_RESOURCE), null);           
-            purchaseOrder = scope.getXMLHelper().load(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.PO_XML_RESOURCE)).getRootObject();
-            System.out.println("DataObject created");
-        } catch (Exception e) {
-            System.out.println("Error creating DataObject " + e.toString());
-            e.printStackTrace();
-            return;
-        }
 
-        // start of sample
-        try {
-            System.out.println("Accessing properties by name");
-            printPurchaseOrderSummary(purchaseOrder);
-        } catch (Exception e) {
-            System.out.println("Sorry there was an error accessing properties by name " + e.toString());
-            e.printStackTrace();
-        }
-        System.out.println("GoodBye");
-        // end of sample
     }
 
 }

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/AccessDataObjectUsingValidXPath.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/AccessDataObjectUsingValidXPath.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/AccessDataObjectUsingValidXPath.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/AccessDataObjectUsingValidXPath.java Wed Jun 20 04:01:57 2007
@@ -71,7 +71,7 @@
 public class AccessDataObjectUsingValidXPath extends SampleBase {
     HelperContext scope;
   
-    public AccessDataObjectUsingValidXPath(int userLevel) {
+    public AccessDataObjectUsingValidXPath(Integer userLevel) {
       super(userLevel);
     }
 
@@ -120,7 +120,7 @@
       }
     }
 
-    public void run () throws Exception {
+    public void runSample () throws Exception {
 
         // information
         System.out.println("***************************************");

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/CreateDataObjectFromXmlString.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/CreateDataObjectFromXmlString.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/CreateDataObjectFromXmlString.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/CreateDataObjectFromXmlString.java Wed Jun 20 04:01:57 2007
@@ -73,7 +73,7 @@
     HelperContext scope;
 
 
-    public CreateDataObjectFromXmlString(int userLevel) {
+    public CreateDataObjectFromXmlString(Integer userLevel) {
       super(userLevel);
     }
 
@@ -115,7 +115,7 @@
       }
     }
 
-    public void run () throws Exception {
+    public void runSample () throws Exception {
 
         // information
         System.out.println("***************************************");

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/CreateDataObjectFromXsdAndXmlFiles.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/CreateDataObjectFromXsdAndXmlFiles.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/CreateDataObjectFromXsdAndXmlFiles.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/CreateDataObjectFromXsdAndXmlFiles.java Wed Jun 20 04:01:57 2007
@@ -78,7 +78,7 @@
     HelperContext scope;
 
   
-    public CreateDataObjectFromXsdAndXmlFiles(int userLevel) {
+    public CreateDataObjectFromXsdAndXmlFiles(Integer userLevel) {
       super(userLevel);
     }
 
@@ -188,7 +188,7 @@
     }
   }
 
-  public void run () throws Exception {
+  public void runSample () throws Exception {
 		// information
 		System.out.println("***************************************");
 		System.out.println("SDO Sample CreateDataObjectFromXsdAndXmlFiles");

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/DynamicCustomerTypeSample.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/DynamicCustomerTypeSample.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/DynamicCustomerTypeSample.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/DynamicCustomerTypeSample.java Wed Jun 20 04:01:57 2007
@@ -73,7 +73,7 @@
 public class DynamicCustomerTypeSample extends SampleBase {
     HelperContext scope;
 
-    public DynamicCustomerTypeSample(int userLevel) {
+    public DynamicCustomerTypeSample(Integer userLevel) {
       super(userLevel);
     }
 
@@ -182,7 +182,7 @@
       }
     }
 
-    public void run () throws Exception {
+    public void runSample () throws Exception {
         System.out.println("***************************************");
         System.out.println("SDO Sample DynamicCustomerTypeSample");
         System.out.println("***************************************");

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/ObtainingDataGraphFromXml.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/ObtainingDataGraphFromXml.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/ObtainingDataGraphFromXml.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/ObtainingDataGraphFromXml.java Wed Jun 20 04:01:57 2007
@@ -100,7 +100,7 @@
 
 
    
-    public ObtainingDataGraphFromXml(int userLevel) {
+    public ObtainingDataGraphFromXml(Integer userLevel) {
       super(userLevel);
     }
     
@@ -116,7 +116,7 @@
     }
     
     
-    public void run () {
+    public void runSample () {
         banner('*',
             "SDO Sample " + this.getClass().getName() + "\n\n" +
 

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/PrintPropertiesOfDataObject.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/PrintPropertiesOfDataObject.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/PrintPropertiesOfDataObject.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/PrintPropertiesOfDataObject.java Wed Jun 20 04:01:57 2007
@@ -80,7 +80,7 @@
 
     HelperContext scope;
 
-    public PrintPropertiesOfDataObject(int userLevel) {
+    public PrintPropertiesOfDataObject(Integer userLevel) {
       super(userLevel);
     }
 
@@ -160,7 +160,7 @@
       }
     }
 
-    public void run () throws Exception {
+    public void runSample () throws Exception {
         // information
         System.out.println("***************************************");
         System.out.println("SDO Sample InspectAndPrintPropertiesOfDataObject");

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/UsingXPath.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/UsingXPath.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/UsingXPath.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/UsingXPath.java Wed Jun 20 04:01:57 2007
@@ -70,7 +70,7 @@
       HelperContext scope;
 
 
-      public UsingXPath(int userLevel) {
+      public UsingXPath(Integer userLevel) {
         super(userLevel);
       }
 
@@ -127,7 +127,7 @@
       }
     }
 
-    public void run () throws Exception {
+    public void runSample () throws Exception {
 
         // information
         System.out.println("***************************************");

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessDataObjectsUsingXPath.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessDataObjectsUsingXPath.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessDataObjectsUsingXPath.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessDataObjectsUsingXPath.java Wed Jun 20 04:01:57 2007
@@ -109,7 +109,7 @@
 
     HelperContext scope;
 
-    public AccessDataObjectsUsingXPath(int userLevel) {
+    public AccessDataObjectsUsingXPath(Integer userLevel) {
       super(userLevel);
     }
 
@@ -132,7 +132,7 @@
     }
   }
 
-  public void run () throws Exception {
+  public void runSample () throws Exception {
         System.out.println("***************************************");
         System.out.println("SDO Sample AccessDataObjectsUsingXPath");
         System.out.println("***************************************");

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingDataObjectsViaPropertyIndex.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingDataObjectsViaPropertyIndex.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingDataObjectsViaPropertyIndex.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingDataObjectsViaPropertyIndex.java Wed Jun 20 04:01:57 2007
@@ -119,7 +119,7 @@
 
     HelperContext scope;
 
-    public AccessingDataObjectsViaPropertyIndex(int userLevel) {
+    public AccessingDataObjectsViaPropertyIndex(Integer userLevel) {
       super(userLevel);
     }
 
@@ -161,7 +161,7 @@
       }
     }
 
-    public void run () throws Exception {
+    public void runSample () throws Exception {
         System.out.println("***************************************");
         System.out.println("SDO Sample AccessingDataObjectsViaPropertyIndex");
         System.out.println("***************************************");

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingTheContentsOfASequence.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingTheContentsOfASequence.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingTheContentsOfASequence.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingTheContentsOfASequence.java Wed Jun 20 04:01:57 2007
@@ -94,7 +94,7 @@
 
     HelperContext scope;
 
-    public AccessingTheContentsOfASequence(int userLevel) {
+    public AccessingTheContentsOfASequence(Integer userLevel) {
       super(userLevel);
     }
 
@@ -127,7 +127,7 @@
       }
     }
 
-    public void run () throws Exception {
+    public void runSample () throws Exception {
         System.out.println("***************************************");
         System.out.println("SDO Sample AccessingTheContentsOfASequence");
         System.out.println("***************************************");

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingDataObjectTreesFromXMLDocuments.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingDataObjectTreesFromXMLDocuments.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingDataObjectTreesFromXMLDocuments.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingDataObjectTreesFromXMLDocuments.java Wed Jun 20 04:01:57 2007
@@ -91,7 +91,7 @@
 
     HelperContext scope;
 
-    public CreatingDataObjectTreesFromXMLDocuments(int userLevel) {
+    public CreatingDataObjectTreesFromXMLDocuments(Integer userLevel) {
       super(userLevel);
     }
 
@@ -115,7 +115,7 @@
     }
   }
 
-  public void run () throws Exception {
+  public void runSample () throws Exception {
         try {
 
             System.out.println("***************************************");

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingXmlFromDataObjects.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingXmlFromDataObjects.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingXmlFromDataObjects.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingXmlFromDataObjects.java Wed Jun 20 04:01:57 2007
@@ -92,7 +92,7 @@
 
     HelperContext scope;
 
-    public CreatingXmlFromDataObjects(int userLevel) {
+    public CreatingXmlFromDataObjects(Integer userLevel) {
       super(userLevel);
     }
 
@@ -110,7 +110,7 @@
     }
   }
 
-  public void run () throws Exception {
+  public void runSample () throws Exception {
         try {
 
             System.out.println("***************************************");

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/SerializingDesearializingADataObject.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/SerializingDesearializingADataObject.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/SerializingDesearializingADataObject.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/SerializingDesearializingADataObject.java Wed Jun 20 04:01:57 2007
@@ -97,7 +97,7 @@
 
     HelperContext scope;
 
-    public SerializingDesearializingADataObject(int userLevel) {
+    public SerializingDesearializingADataObject(Integer userLevel) {
       super(userLevel);
     }
 
@@ -133,7 +133,7 @@
       }
     }
 
-    public void run () throws Exception {
+    public void runSample () throws Exception {
         System.out.println("***************************************");
         System.out.println("SDO Sample AccessingTheContentsOfASequence");
         System.out.println("***************************************");

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/UsingTypeAndPropertyWithDataObjects.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/UsingTypeAndPropertyWithDataObjects.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/UsingTypeAndPropertyWithDataObjects.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/UsingTypeAndPropertyWithDataObjects.java Wed Jun 20 04:01:57 2007
@@ -92,7 +92,7 @@
     HelperContext scope;
 
 
-    public UsingTypeAndPropertyWithDataObjects(int userLevel) {
+    public UsingTypeAndPropertyWithDataObjects(Integer userLevel) {
       super(userLevel);
     }
 
@@ -115,7 +115,7 @@
     }
   }
 
-  public void run () throws Exception {
+  public void runSample () throws Exception {
         System.out.println("***************************************");
         System.out.println("SDO Sample UsingTypeAndPropertyWithDataObjects");
         System.out.println("***************************************");

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/tuscanyapi/CreateCompany.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/tuscanyapi/CreateCompany.java?view=diff&rev=549061&r1=549060&r2=549061
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/tuscanyapi/CreateCompany.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/tuscanyapi/CreateCompany.java Wed Jun 20 04:01:57 2007
@@ -64,7 +64,7 @@
  */
 public class CreateCompany extends org.apache.tuscany.samples.sdo.otherSources.CreateCompany {
 
-    public CreateCompany(int userLevel) {
+    public CreateCompany(Integer userLevel) {
       super(userLevel);
     }
 
@@ -86,16 +86,11 @@
        * or less commentary.
        */
       CreateCompany sample = new CreateCompany(INTERMEDIATE);
+      sample.run();
 
-      try {
-        sample.run();
-      }
-      catch (Exception e) {
-        sample.somethingUnexpectedHasHappened(e);
-      }
     }
 
-    public void run () throws Exception {
+    public void runSample () throws Exception {
       
         banner('*',
                "              SDO Sample Create Company in a DataGraph              \n\n"+



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org