/* * @(#)FundLister * Copyright 2002 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * */ package com.sun.eportal; import java.util.*; import java.io.*; /** * Class which dynamically lists all available funds. This uses Client Query, * to search for all the Retirement Service Providers ( NAICS keyName : * Pension Funds, keyValue : 52511 ) and then uses RSClient_DII to send * getAvailableFunds message to all the retirement service providers, who are * exposing JAXRPC binding. This class then aggregates the available funds * information from all the providers. * * @author: Ramesh Mandava and Edward Ort */ public class FundLister { Hashtable fundHash; String[] jaxrpcEndpointArray ; public FundLister( ) { fundHash = new Hashtable(); } public Hashtable getFundHash( ) { return fundHash; } //Method which lists all available funds dynamically. public void populateAvailableFunds ( ) { try { String cScheme="ntis-gov:naics"; String keyName="Pension Funds"; String keyValue="52511"; String serviceName="Retirement Service"; System.out.println("Now trying to run query"); ClientQuery clientQuery = new ClientQuery( ); Vector serviceProviderInfoVector = clientQuery.query( cScheme, keyName, keyValue); //Now use cleanup to close JAXR Connection System.out.println("Closing Connection"); clientQuery.cleanup(); //Now populate endpoint array to get available funds Vector jaxrpcEndpointVector= new Vector(); for ( int i=0; i< serviceProviderInfoVector.size(); i++ ) { ServiceProviderInfo spi = (ServiceProviderInfo) serviceProviderInfoVector.elementAt(i); //Collect all JAXRPC related endpoints and communicate with // them using RSClinet_DII if ( spi.getCommunicationType().equals("JAXRPC") ) { jaxrpcEndpointVector.addElement( spi.getEndpoint() ); } } jaxrpcEndpointArray = new String[ jaxrpcEndpointVector.size() ]; jaxrpcEndpointVector.copyInto ( (Object[])jaxrpcEndpointArray ); RSClient_DII rsclient_DII = new RSClient_DII(); fundHash =rsclient_DII.getAllAvailableFunds ( jaxrpcEndpointArray ); } catch ( Exception e ) { System.err.println("Exception : In populateAvailableFunds" ); e.printStackTrace(); } } /** * This method gets the quotes from each retirement service provider * for the user selected funds and monthly investment * @param reqFundInfos User selected fund information * @param mi user selected monthly investment * @return Hashtable containing the quotes */ public Hashtable getAllQuotes ( FundInfo[] reqFundsInfos, double mi ) { RSClient_DII rsclient_DII = new RSClient_DII(); Hashtable quoteHash = rsclient_DII.getAllQuotes ( jaxrpcEndpointArray, reqFundsInfos, mi ); return quoteHash; } }