Collaboration diagram

Startup Use Case

Startup Use Case for Menu-driven Application

Startup Use Case for Application Test

Create ProductCatalog

CatalogBroker


import java.io.*;

public class CatalogBroker {

    public ProductCatalog getCatalog() throws Exception {
	ProductCatalog catalog = null;
  	FileInputStream fileIn = new FileInputStream("catFile");
	ObjectInputStream objIn = new ObjectInputStream(fileIn);
	Object obj = objIn.readObject();
	objIn.close();
	catalog = (ProductCatalog) obj;
	return catalog;
    }

    /**
     * @pre catalog != null
     */
    public void commit(ProductCatalog catalog) throws Exception {
	FileOutputStream fileOut = new FileOutputStream("catFile");
	ObjectOutputStream objOut = new ObjectOutputStream(fileOut);
	objOut.writeObject(catalog);
	objOut.close();
    }
}

Linking the ProductCatalog and POST

Starting the Application (Java)

From the Application's main() method

      public class Application {
          public static void main(String[] argv) {
              CatalogBroker broker = new CatalogBroker();
              ProductCatalog catalog = null;
              try {
                  catalog = broker.getCatalog();
              } catch(Exception e) {
                 System.out.println("Can't get catalog " +
                                    e.toString());
                 System.exit(1);
              }

              Post post = new Post(catalog);
              ....
          }
      }
      

Starting the Application (Jacl)


set catBroker [java::new CatalogBroker]
java::try {
    set catalog [$catBroker getCatalog]
} catch {TclException err} {
    puts "Can't get Product Catalog"
    puts $err
}

set post [java::new Post $catalog]
...

Creating an Initial ProductCatalog (Java)


public MakeCatalog {
    static public void main(String[] argv) {
        ProductCatalog catalog = new ProductCatalog();
        catalog.add(123, "descr1");
        catalog.add(234, "descr2");
        catalog.add(345, "descr3");

        CatalogBroker catBroker = new CatalogBroker();
        try {
            catBroker.commit(catalog);
        } catch(Exception e) {
            System.out.println("Couldn't save Product Catalog" +
                               e.toString());
        }
    }
}

Creating an Initial ProductCatalog (Jacl)


package require java

set catalog [java::new ProductCatalog]
$catalog add 123 descr1
$catalog add 234 descr2
$catalog add 345 desrc3

set catBroker [java::new CatalogBroker]
java::try {
    $catBroker commit $catalog
} catch {TclException err} {
    puts "can't save Product Catalog"
    puts $err
}

Miscellaneous Jacl Comments


Jan Newmarch (http://pandonia.canberra.edu.au)
jan@ise.canberra.edu.au
Last modified: Thu Sep 7 13:59:15 EST 2000
Copyright ©Jan Newmarch