FileDocCategorySizeDatePackage
CustomEnum.javaAPI DocExample3989Tue Mar 11 22:47:34 GMT 2003ora.jwsnut.chapter7.jaxr

CustomEnum

public class CustomEnum extends Object

Fields Summary
private static javax.xml.registry.BusinessQueryManager
bqm
Constructors Summary
Methods Summary
private static voiddisplayEnum(boolean displayID)

        // First find the classification scheme
        ClassificationScheme scheme = bqm.findClassificationSchemeByName(null, "TestEnum");
        if (scheme == null) {
            System.out.println("Please install the registry test data");
            System.exit(1);
        }
        System.out.println("Scheme id is " + scheme.getKey().getId());
        if (displayID) {
            System.exit(0);
        }
        
        // Now look for the Concepts
        Collection coll = scheme.getDescendantConcepts();
        System.out.print("Enumeration values: ");
        Iterator iter = coll.iterator();
        while (iter.hasNext()) {
            Concept c = (Concept)iter.next();
            System.out.print(c.getValue() + "  ");
        }
        System.out.println();
        
        // Locate by path
        String path = "/" + scheme.getKey().getId() + "/1";
        Concept c = bqm.findConceptByPath(path);
        if (c != null) {
            System.out.println("Located concept by path: value = " + c.getValue());
        } else {
            System.out.println("Failed to locate concept by path");
        }    
    
public static voidmain(java.lang.String[] args)

        
        // Validate arguments
        if (args.length != 2) {
            usage();
        }
        
        // Process the arguments
        boolean isUddi = args[0].equals("-uddi");
        String queryURL = args[1];
        
        try {
            // Get the ConnectionFactory
            Properties props = new Properties();
            props.put("javax.xml.registry.queryManagerURL", queryURL);
 
            boolean displayID = false;
            if (isUddi) {
                String fileName = System.getProperty("CustomEnumFile");
                if (fileName != null) {
                    System.out.println("Custom taxonomy file is " + fileName);
                    System.setProperty("com.sun.xml.registry.userTaxonomyFilenames", fileName);
                } else {
                    displayID = true; // Step 1 - just display the ID
                }
            }
            
            ConnectionFactory cf = ConnectionFactory.newInstance();
            cf.setProperties(props);
            
            // Get and initialize the connection
            Connection conn = cf.createConnection();
            conn.setSynchronous(true);
            
            // Get the RegistryService and the BusinessQueryManager
            RegistryService registry = conn.getRegistryService();
            bqm = registry.getBusinessQueryManager();            

            // Run the example code
            displayEnum(displayID);
            
            // Close connection
            conn.close();           
            
        } catch (Throwable t) {
            System.out.println(t);
            t.printStackTrace(System.out);
            System.exit(1);
        }    
        
        System.exit(0);
    
private static voidusage()

        System.out.println("Usage:\tCustomEnum -uddi|-ebxml queryURL");
        System.exit(1);