Books
in black and white
Main menu
Share a book About us Home
Books
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics
Ads

More Java Pitfalls Share Reactor - Daconta M,C.

Daconta M,C. More Java Pitfalls Share Reactor - Wiley publishing, 2003. - 476 p.
ISBN: 0-471-23751-5
Download (direct link): morejavapitfallssharereactor2003.pdf
Previous << 1 .. 138 139 140 141 142 143 < 144 > 145 146 147 148 149 150 .. 166 >> Next

To show these possible pitfalls, we will build a skeletal program that includes the basics of JAXR, shown in our Listing 47.1. In this listing, we have an empty make-Call() method on lines 64 to 69. After we explain our example setup in the listing, we will implement several versions of makeCall() to query the registry.
In using JAXR, you must first set up a connection to a registry server. Listing 47.1 shows the beginning of a program using JAXR to speak to a registry server. In this example, we are using the public Microsoft UDDI registry, passed in to the constructor of JAXRQueryExample. In lines 29 to 32, we are able to get a connection to the registry using the ConnectionFactory object from the javax.xml.registry package. From that connection, we are able to get the RegistryService object, which allows us to receive the BusinessQueryManager object on line 34.
Listing 47.1 The start of our UDDI query example
Where's the WSDL? Pitfalls of Using JAXR with UDDI 399
007
008 public class JAXRQueryExample
009 {
010 RegistryService m_regserv = null;
011 BusinessQueryManager m_querymgr = null;
012 Connection m_connection = null;
013
014 public JAXRQueryExample(String registryURL) throws JAXRException
015 {
016 ConnectionFactory factory = null;
017
018 Properties props = new Properties();
019 props.setProperty("javax.xml.registry.queryManagerURL",
020 registryURL);
021
022 try
023 {
024 /*
025 * Create the connection, passing it the
026 * properties -- in this case, just the URL
027 */
028
029 factory = ConnectionFactory.newInstance();
030 factory.setProperties(props);
031
032 m_connection = factory.createConnection();
033 m_regserv = m_connection.getRegistryService();
034 m_querymgr = m_regserv.getBusinessQueryManager();
035 }
036 catch ( JAXRException e )
037 {
038 cleanUp();
039 //pass it on..
040 throw e;
041 }
042 }
043
044 /**
045 * Close the connection
046 */
047 public void cleanUp()
048 {
049 if ( m_connection != null )
050 {
051 try
052 {
053 m_connection.close();
054 }
Listing 47.1 (continued)
400 Item 47
055 catch ( JAXRException je )
056 {
057 }
058 }
059 }
060
061 /**
062 * Our main focus in this pitfall
063 **/
064 public void makeCall(String query) throws Exception
065 {
066 //We will use m_querymgr in this method
067
068 System.out.println("makeCall() Not implemented yet!");
069 }
070
071 /** Simple convenience function, since strings from registry
072 * are in this format
073 */
074 public String convertToString(InternationalString intl)
075 throws JAXRException
076 {
077 String stringVal = null;
078 if ( intl != null )
079 {
080 stringVal = intl.getValue();
081 }
082 return(stringVal);
083 }
084
085 public static void main(String[] args)
086 {
087 JAXRQueryExample jaxrex = null;
088 try
089 {
090 String uddiReg = "http://uddi.microsoft.com/inquire";
091 jaxrex = new JAXRQueryExample(uddiReg);
092
093 jaxrex.makeCall("truman");
094
095 System.out.println("-----------SECOND QUERY--------------");
096 jaxrex.makeCall("sched");
097 }
098 catch ( Exception e )
099 {
100 e.printStackTrace();
101 }
102 finally
Listing 47.1 (continued)
Where's the WSDL? Pitfalls of Using JAXR with UDDI 401
103 {
104 jaxrex.cleanUp();
105 }
106 }
107
108 }
109
Listing 47.1 (continued)
On lines 64 to 69, we have an empty makeCall() method that will be our focus for the rest of this pitfall item. In that method, we will make extensive use of the Busi-nessQueryManager interface returned from the RegistryService object on line 33. Because this is where some of the confusion comes in, we have listed the available methods of the javax.xml.registry.BusinessQueryManager interface in Table 47.1.
Table 47.1 The BusinessQueryManager Interface
METHOD DESCRIPTION
BulkResponse findAssociations (Collection findQualifiers, String sourceObjectId, String targetObjectId, Collection assocTypes) Finds Association objects that match parameters of this call.
BulkResponse findCallerAssociations(Collection findQualifiers, Boolean confirmedByCaller, Boolean confirmedByOtherParty, Collection associationTypes) Finds all Association objects owned by the caller that match all of the criteria specified by the parameters of this call.
ClassificationScheme findClassificationSchemeByName( Collection findQualifiers, String namePattern ) Finds a Classification-Scheme by name based on the specified find qualifiers and name pattern.
BulkResponse findClassificationSchemes(Collection findQualifiers, Collection namePatterns, Collection classifications, Collection externalLinks) Finds all Classification-Scheme objects that match all of the criteria specified by the parameters of this call.
Concept findConceptByPath(java.lang.String path) Finds a Concept object by the path specified.
(continued)
402 Item 47
Table 47.1 (continued)
I METHOD DESCRIPTION I
BulkResponse findConcepts(Collection Collection Collection Collection Collection findQualifiers, namePatterns, classifications, externalIdentifiers, externalLinks) Finds all Concept objects that match the parameters of this call.
Previous << 1 .. 138 139 140 141 142 143 < 144 > 145 146 147 148 149 150 .. 166 >> Next