⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlregistrymanager.java

📁 java web services how to program
💻 JAVA
字号:
// Fig. 10.5: XMLRegistryManager.java
// Establishes connection to UDDI registry
// and returns references to life-cycle manager and 
// query manager capability interfaces.

package com.deitel.jws1.jaxr;

// JAXR core packages
import javax.xml.registry.*;
import javax.xml.registry.infomodel.*;

// java core packages
import java.util.*;
import java.net.PasswordAuthentication;

public class XMLRegistryManager {

   // capability interface for querying XML registry
   private BusinessQueryManager queryManager;

   // capability interface for adding, updating, removing entries
   private BusinessLifeCycleManager lifeCycleManager;
   
   // UDDI registry URLs
   private static final String queryURL = 
      "http://www-3.ibm.com:80/" + 
      "services/uddi/v2beta/inquiryapi";
   
   private static final String lifeCycleURL = 
      "https://www-3.ibm.com:443/" + 
      "services/uddi/v2beta/protect/publishapi";
   
   // constructor 
   public XMLRegistryManager( String userName, 
      String password ) throws JAXRException
   {
      // create connection instance
      ConnectionFactory connectionFactory =
         ConnectionFactory.newInstance();

      // create Properties object that contains 
      // 1) URLs of registry service, and
      // 2) connection factory implementation
      Properties properties = new Properties();

      // specify connection factory property
      properties.setProperty( 
         "javax.xml.registry.factoryClass", 
         "com.sun.xml.registry.uddi.ConnectionFactoryImpl" );
      
      // store URL of query registry service
      // as property javax.xml.registry.queryManagerURL
      properties.setProperty( 
         "javax.xml.registry.queryManagerURL", queryURL );
      
      // store URL of publish registry service
      // as property javax.xml.registry.lifeCycleManagerURL
      properties.setProperty(
         "javax.xml.registry.lifeCycleManagerURL", lifeCycleURL );
      
      // set properties
      connectionFactory.setProperties( properties );
      
      // create connection
      Connection connection = 
         connectionFactory.createConnection();
      
      // set credentials iff username and password supplied
      if ( userName != null || password != null ) {
            
         // create password authorization
         PasswordAuthentication authentication =
            new PasswordAuthentication(
               userName, password.toCharArray() );
         
         // create credentials set
         Set credentials = new HashSet();
         
         // populate credentials with authorization object
         credentials.add( authentication );
         
         // set credentials in connection instance
         connection.setCredentials( credentials );
      } // end if
      
      // obtain registry service reference
      RegistryService registryService = 
         connection.getRegistryService();
      
      // obtain business query 
      queryManager =
         registryService.getBusinessQueryManager();
      
      // obtain business life cycle manager reference   
      lifeCycleManager =
         registryService.getBusinessLifeCycleManager();      
   } // end constructor 

   // no-argument constructor
   public XMLRegistryManager() throws JAXRException
   {
      this( null, null );
   }
   
   // return BusinessQueryManager
   public BusinessQueryManager getBusinessQueryManager()
   {
      return queryManager;
   }
   
   // return BusinessLifeCycleManager
   public BusinessLifeCycleManager getBusinessLifeCycleManager()
   {
      return lifeCycleManager;
   }
     
} // end class XMLRegistryManager

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -