HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML
 

"Performance Management Starts with IDL Design"
Vol. 6, Issue 1, p. 94

	

Listing 1: Product Catalog Proxy Implementation

public class ProductServiceProxy {
	private static ProductServiceProxy instance;
	private ProductServiceProxy () {}

	public static ProductServiceClient getInstance() {
   if(instance==null)  instance= new ProductServiceProxy ();
   return instance;
}

public ArrayList getProducts(String group, String category, String status) 
throws SomeException{
	  ArrayList productList = new ArrayList ();
	  try {
	 ProductService productService = locateRemotetService();
		 if ( productService == null ) {
		   // return empty list or throw user defined exception
		 }
		// get product list
		try{
		   // get products using criteria
		  // when request returns data, prepare data and store results in collection object
		} catch(SystemException se){  // handle exception}
	   } catch ( Exception e) { //handle exception }
  return productList;		
}
...
}

Listing 2: Base Iterators in IDL

#include "util/exceptions/idlexceptions.idl"
module iterator
{
	interface BaseIterator {
	  boolean hasNext() raises (SomeRemoteException);
	  short count() raises (SomeRemoteException);
	};
	interface BaseListIterator {
	 boolean hasPrevious() raises (SomeRemoteException);
	  short previousIndex() raises (SomeRemoteException);
	  boolean hasNext() raises (SomeRemoteException);
	  short nextIndex()raises (SomeRemoteException);
	  short count() raises (SomeRemoteException);
	};
};

Listing 3: IDL Design of Service-Specific Iterator

#include "util/iterator/iterator.idl"
module productcatalog
{
	struct ProductItem{
	 string productName;
	...
	};
	typedefsequence<ProductItem> ProductItemList;

	interface ProductIterator : iterator::BaseListIterator {
	   ProductItem next()  raises (SomeRemoteException);
	   ProductItemList nextBlock (in short size) raises (SomeRemoteException);
	  ProductItem previous () raises (SomeRemoteException);
	  ProductItemList previousBlock (in short size) raises (SomeRemoteException);
	};

	interface ProductCatalog {
	   ProductIterator getProductItems(in string group, in string category, in string status)
	     raises (SomeRemoteException);
	};
}

Listing 4: Changes to ProductServiceProxy implementation

public class ProductServiceProxy {
	private int nItems=15;
	private ProductIterator remoteIterator;
	private static ProductServiceProxy instance;
 	private ProductServiceProxy () {}

public static ProductServiceClient getInstance() {
   if(instance==null)  instance= new ProductServiceProxy ();
   return instance;
}

public ArrayList getProducts(String group, String category, String status) 
throws SomeException{
	  ArrayList productList = new ArrayList ();
	  try {
	 ProductService productService = locateRemoteProductService();
		 if ( productService == null ) {
		   // return empty list or throw user defined exception
		 }
		// get product list
		try{
		   remoteIterator=productService.getProducts(...);
		} catch(SystemException se){  // handle exception}
	   } catch ( Exception e) { //handle exception }
  return this.getMoreProducts(nItems);		
}
public ArrayList getMoreProducts(int nItems) throws SomeException{
 	    // retrieve the next 10-15 items using cache iterator
}
...
}


  
 
 

All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.