You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by sv...@apache.org on 2003/11/11 14:50:49 UTC

cvs commit: ws-juddi/src/java/org/apache/juddi/registry Registry.java RegistryEngine.java

sviens      2003/11/11 05:50:49

  Added:       src/java/org/apache/juddi/registry Registry.java
                        RegistryEngine.java
  Log:
  Moved from jUDDI CVS at SourceForge
  
  Revision  Changes    Path
  1.1                  ws-juddi/src/java/org/apache/juddi/registry/Registry.java
  
  Index: Registry.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "jUDDI" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.juddi.registry;
  
  import java.util.Vector;
  
  import org.apache.juddi.datatype.CategoryBag;
  import org.apache.juddi.datatype.DiscoveryURLs;
  import org.apache.juddi.datatype.IdentifierBag;
  import org.apache.juddi.datatype.KeyedReference;
  import org.apache.juddi.datatype.RegistryObject;
  import org.apache.juddi.datatype.TModelBag;
  import org.apache.juddi.datatype.request.AddPublisherAssertions;
  import org.apache.juddi.datatype.request.AuthInfo;
  import org.apache.juddi.datatype.request.DeleteBinding;
  import org.apache.juddi.datatype.request.DeleteBusiness;
  import org.apache.juddi.datatype.request.DeletePublisher;
  import org.apache.juddi.datatype.request.DeletePublisherAssertions;
  import org.apache.juddi.datatype.request.DeleteService;
  import org.apache.juddi.datatype.request.DeleteTModel;
  import org.apache.juddi.datatype.request.DiscardAuthToken;
  import org.apache.juddi.datatype.request.FindBinding;
  import org.apache.juddi.datatype.request.FindBusiness;
  import org.apache.juddi.datatype.request.FindPublisher;
  import org.apache.juddi.datatype.request.FindQualifiers;
  import org.apache.juddi.datatype.request.FindRelatedBusinesses;
  import org.apache.juddi.datatype.request.FindService;
  import org.apache.juddi.datatype.request.FindTModel;
  import org.apache.juddi.datatype.request.GetAssertionStatusReport;
  import org.apache.juddi.datatype.request.GetAuthToken;
  import org.apache.juddi.datatype.request.GetBindingDetail;
  import org.apache.juddi.datatype.request.GetBusinessDetail;
  import org.apache.juddi.datatype.request.GetBusinessDetailExt;
  import org.apache.juddi.datatype.request.GetPublisherAssertions;
  import org.apache.juddi.datatype.request.GetPublisherDetail;
  import org.apache.juddi.datatype.request.GetRegisteredInfo;
  import org.apache.juddi.datatype.request.GetServiceDetail;
  import org.apache.juddi.datatype.request.GetTModelDetail;
  import org.apache.juddi.datatype.request.SaveBinding;
  import org.apache.juddi.datatype.request.SaveBusiness;
  import org.apache.juddi.datatype.request.SavePublisher;
  import org.apache.juddi.datatype.request.SaveService;
  import org.apache.juddi.datatype.request.SaveTModel;
  import org.apache.juddi.datatype.request.SetPublisherAssertions;
  import org.apache.juddi.datatype.response.AssertionStatusReport;
  import org.apache.juddi.datatype.response.AuthToken;
  import org.apache.juddi.datatype.response.BindingDetail;
  import org.apache.juddi.datatype.response.BusinessDetail;
  import org.apache.juddi.datatype.response.BusinessDetailExt;
  import org.apache.juddi.datatype.response.BusinessList;
  import org.apache.juddi.datatype.response.DispositionReport;
  import org.apache.juddi.datatype.response.PublisherAssertions;
  import org.apache.juddi.datatype.response.PublisherDetail;
  import org.apache.juddi.datatype.response.PublisherList;
  import org.apache.juddi.datatype.response.RegisteredInfo;
  import org.apache.juddi.datatype.response.RelatedBusinessesList;
  import org.apache.juddi.datatype.response.ServiceDetail;
  import org.apache.juddi.datatype.response.ServiceList;
  import org.apache.juddi.datatype.response.TModelDetail;
  import org.apache.juddi.datatype.response.TModelList;
  import org.apache.juddi.error.RegistryException;
  
  /**
   * Represents a vesion 2.0 UDDI registry and implements all
   * services as specified in the UDDI version 2.0 specification.
   *
   * @author Steve Viens (sviens@apache.org)
   */
  public abstract class Registry
  {
    public static final String UDDI_V1_GENERIC = "1.0";
    public static final String UDDI_V2_GENERIC = "2.0";
    public static final String UDDI_V3_GENERIC = "3.0";
    public static final String JUDDI_V1_GENERIC = "1.0";
  
    public static final String UDDI_V1_NAMESPACE = "urn:uddi-org:api";
    public static final String UDDI_V2_NAMESPACE = "urn:uddi-org:api_v2";
    public static final String UDDI_V3_NAMESPACE = "urn:uddi-org:api_v3";
    public static final String JUDDI_V1_NAMESPACE = "urn:juddi-org:api_v1";
  
    /**
     * "Used to locate specific bindings within a registered
     *  businessService. Returns a bindingDetail message."
     *
     * @exception RegistryException
     */
    public BindingDetail findBinding(String serviceKey,TModelBag tModelBag,FindQualifiers findQualifiers,int maxRows)
      throws RegistryException
    {
      FindBinding request = new FindBinding();
      request.setServiceKey(serviceKey);
      request.setTModelBag(tModelBag);
      request.setFindQualifiers(findQualifiers);
      request.setMaxRows(maxRows);
  
      return (BindingDetail)execute(request);
    }
  
    /**
     * Used to locate information about one or more businesses. Returns a
     * businessList message that matches the conditions specified.
     *
     * @exception RegistryException;
     */
    public BusinessList findBusiness(Vector nameVector,DiscoveryURLs discoveryURLs,IdentifierBag identifierBag,CategoryBag categoryBag,TModelBag tModelBag,FindQualifiers findQualifiers,int maxRows)
      throws RegistryException
    {
      FindBusiness request = new FindBusiness();
      request.setNameVector(nameVector);
      request.setDiscoveryURLs(discoveryURLs);
      request.setIdentifierBag(identifierBag);
      request.setCategoryBag(categoryBag);
      request.setTModelBag(tModelBag);
      request.setFindQualifiers(findQualifiers);
      request.setMaxRows(maxRows);
  
      return (BusinessList)execute(request);
    }
  
    /**
     * @exception RegistryException;
     */
    public RelatedBusinessesList findRelatedBusinesses(String businessKey,KeyedReference keyedReference,FindQualifiers findQualifiers,int maxRows)
      throws RegistryException
    {
      FindRelatedBusinesses request = new FindRelatedBusinesses();
      request.setBusinessKey(businessKey);
      request.setKeyedReference(keyedReference);
      request.setFindQualifiers(findQualifiers);
      request.setMaxRows(maxRows);
  
      return (RelatedBusinessesList)execute(request);
    }
  
    /**
     * "Used to locate specific services within a registered
     *  businessEntity. Return a serviceList message." From the
     *  XML spec (API, p18) it appears that the name, categoryBag,
     *  and tModelBag arguments are mutually exclusive.
     *
     * @exception RegistryException;
     */
    public ServiceList findService(String businessKey,Vector nameVector,CategoryBag categoryBag,TModelBag tModelBag,FindQualifiers findQualifiers,int maxRows)
      throws RegistryException
    {
      FindService request = new FindService();
      request.setBusinessKey(businessKey);
      request.setNameVector(nameVector);
      request.setCategoryBag(categoryBag);
      request.setTModelBag(tModelBag);
      request.setFindQualifiers(findQualifiers);
      request.setMaxRows(maxRows);
  
      return (ServiceList)execute(request);
    }
  
    /**
     * "Used to locate one or more tModel information structures. Returns a
     *  tModelList structure."
     *
     * @exception RegistryException;
     */
    public TModelList findTModel(String name,CategoryBag categoryBag,IdentifierBag identifierBag,FindQualifiers findQualifiers,int maxRows)
      throws RegistryException
    {
      FindTModel request = new FindTModel();
      request.setName(name);
      request.setCategoryBag(categoryBag);
      request.setIdentifierBag(identifierBag);
      request.setFindQualifiers(findQualifiers);
      request.setMaxRows(maxRows);
  
      return (TModelList)execute(request);
    }
  
    /**
     * "Used to get full bindingTemplate information suitable for make one
     *  or more service requests. Returns a bindingDetail message."
     *
     * @exception RegistryException;
     */
    public BindingDetail getBindingDetail(Vector bindingKeys)
      throws RegistryException
    {
      GetBindingDetail request = new GetBindingDetail();
      request.setBindingKeyVector(bindingKeys);
  
      return (BindingDetail)execute(request);
    }
  
    /**
     * "Used to get the full businessEntity information for one or more
     *  businesses. Returns a businessDetail message."
     *
     * @exception RegistryException;
     */
    public BusinessDetail getBusinessDetail(Vector businessKeyVector)
      throws RegistryException
    {
      GetBusinessDetail request = new GetBusinessDetail();
      request.setBusinessKeyVector(businessKeyVector);
  
      return (BusinessDetail)execute(request);
    }
  
    /**
     * "Used to get extended businessEntity information. Returns a
     *  businessDetailExt message."
     *
     * @exception RegistryException;
     */
    public BusinessDetailExt getBusinessDetailExt(Vector businessKeyVector)
      throws RegistryException
    {
      GetBusinessDetailExt request = new GetBusinessDetailExt();
      request.setBusinessKeyVector(businessKeyVector);
  
      return (BusinessDetailExt)execute(request);
    }
  
    /**
     * "Used to get full details for a given set of registered
     *  businessService data. Returns a serviceDetail message."
     *
     * @exception RegistryException;
     */
    public ServiceDetail getServiceDetail(Vector serviceKeyVector)
      throws RegistryException
    {
      GetServiceDetail request = new GetServiceDetail();
      request.setServiceKeyVector(serviceKeyVector);
  
      return (ServiceDetail)execute(request);
    }
  
    /**
     * "Used to get full details for a given set of registered tModel
     *  data. Returns a tModelDetail message."
     *
     * @exception RegistryException;
     */
    public TModelDetail getTModelDetail(Vector tModelKeyVector)
      throws RegistryException
    {
      GetTModelDetail request = new GetTModelDetail();
      request.setTModelKeyVector(tModelKeyVector);
  
      return (TModelDetail)execute(request);
    }
  
    /**
     * @exception RegistryException;
     */
    public DispositionReport addPublisherAssertions(AuthInfo authInfo,Vector assertionVector)
      throws RegistryException
    {
      AddPublisherAssertions request = new AddPublisherAssertions();
      request.setAuthInfo(authInfo);
      request.setPublisherAssertionVector(assertionVector);
  
      return (DispositionReport)execute(request);
    }
  
    /**
     * @exception RegistryException;
     */
    public AssertionStatusReport getAssertionStatusReport(AuthInfo authInfo,String completionStatus)
      throws RegistryException
    {
      GetAssertionStatusReport request = new GetAssertionStatusReport();
      request.setAuthInfo(authInfo);
      request.setCompletionStatus(completionStatus);
  
      return (AssertionStatusReport)execute(request);
    }
  
    /**
     * @exception RegistryException;
     */
    public PublisherAssertions getPublisherAssertions(AuthInfo authInfo)
      throws RegistryException
    {
      GetPublisherAssertions request = new GetPublisherAssertions();
      request.setAuthInfo(authInfo);
  
      return (PublisherAssertions)execute(request);
    }
  
    /**
     * "Used to remove an existing bindingTemplate from the bindingTemplates
     *  collection that is part of a specified businessService structure."
     *
     * @exception RegistryException;
     */
    public DispositionReport deleteBinding(AuthInfo authInfo,Vector bindingKeyVector)
      throws RegistryException
    {
      DeleteBinding request = new DeleteBinding();
      request.setAuthInfo(authInfo);
      request.setBindingKeyVector(bindingKeyVector);
  
      return (DispositionReport)execute(request);
    }
  
    /**
     * "Used to delete registered businessEntity information from the registry."
     *
     * @exception RegistryException;
     */
    public DispositionReport deleteBusiness(AuthInfo authInfo,Vector businessKeyVector)
      throws RegistryException
    {
      DeleteBusiness request = new DeleteBusiness();
      request.setAuthInfo(authInfo);
      request.setBusinessKeyVector(businessKeyVector);
  
      return (DispositionReport)execute(request);
    }
  
    /**
     * "Used to delete an existing businessService from the businessServices
     *  collection that is part of a specified businessEntity."
     *
     * @exception RegistryException;
     */
    public DispositionReport deleteService(AuthInfo authInfo,Vector serviceKeyVector)
      throws RegistryException
    {
      DeleteService request = new DeleteService();
      request.setAuthInfo(authInfo);
      request.setServiceKeyVector(serviceKeyVector);
  
      return (DispositionReport)execute(request);
    }
  
    /**
     * "Used to delete registered information about a tModel.  If there
     *  are any references to a tModel when this call is made, the tModel
     *  will be marked deleted instead of being physically removed."
     *
     * @exception RegistryException;
     */
    public DispositionReport deleteTModel(AuthInfo authInfo,Vector tModelKeyVector)
      throws RegistryException
    {
      DeleteTModel request = new DeleteTModel();
      request.setAuthInfo(authInfo);
      request.setTModelKeyVector(tModelKeyVector);
  
      return (DispositionReport)execute(request);
    }
  
    /**
     * @exception RegistryException;
     */
    public DispositionReport deletePublisherAssertions(AuthInfo authInfo,Vector assertionVector)
      throws RegistryException
    {
      DeletePublisherAssertions request = new DeletePublisherAssertions();
      request.setAuthInfo(authInfo);
      request.setPublisherAssertionVector(assertionVector);
  
      return (DispositionReport)execute(request);
    }
  
    /**
     * "Used to inform an Operator Site that a previously provided
     *  authentication token is no longer valid.  See get_authToken."
     *
     * @exception RegistryException;
     */
    public DispositionReport discardAuthToken(AuthInfo authInfo)
      throws RegistryException
    {
      DiscardAuthToken request = new DiscardAuthToken();
      request.setAuthInfo(authInfo);
  
      return (DispositionReport)execute(request);
    }
  
    /**
     * "Used to request an authentication token from an Operator Site.
     *  Authentication tokens are required to use all other APIs defined
     *  in the publishers API.  This server serves as the program's
     *  equivalent of a login request."
     *
     * @exception RegistryException;
     */
    public AuthToken getAuthToken(String userID,String cred)
      throws RegistryException
    {
      GetAuthToken request = new GetAuthToken();
      request.setUserID(userID);
      request.setCredential(cred);
  
      return (AuthToken)execute(request);
    }
  
    /**
     * "Used to request an abbreviated synopsis of all information currently
     *  managed by a given individual."
     *
     * @exception RegistryException;
     */
    public RegisteredInfo getRegisteredInfo(AuthInfo authInfo)
      throws RegistryException
    {
      GetRegisteredInfo request = new GetRegisteredInfo();
      request.setAuthInfo(authInfo);
  
      return (RegisteredInfo)execute(request);
    }
  
    /**
     * "Used to register new bindingTemplate information or update existing
     *  bindingTemplate information.  Use this to control information about
     *  technical capabilities exposed by a registered business."
     *
     * @exception RegistryException;
     */
    public BindingDetail saveBinding(AuthInfo authInfo,Vector bindingVector)
      throws RegistryException
    {
      SaveBinding request = new SaveBinding();
      request.setAuthInfo(authInfo);
      request.setBindingTemplateVector(bindingVector);
  
      return (BindingDetail)execute(request);
    }
  
    /**
     * "Used to register new businessEntity information or update existing
     *  businessEntity information.  Use this to control the overall
     *  information about the entire business.  Of the save_x APIs this one
     *  has the broadest effect."
     *
     * @exception RegistryException;
     */
    public BusinessDetail saveBusiness(AuthInfo authInfo,Vector businessVector)
      throws RegistryException
    {
      SaveBusiness request = new SaveBusiness();
      request.setAuthInfo(authInfo);
      request.setBusinessEntityVector(businessVector);
  
      return (BusinessDetail)execute(request);
    }
  
    /**
     * "Used to register or update complete information about a businessService
     *  exposed by a specified businessEntity."
     *
     * @exception RegistryException;
     */
    public ServiceDetail saveService(AuthInfo authInfo,Vector serviceVector)
      throws RegistryException
    {
      SaveService request = new SaveService();
      request.setAuthInfo(authInfo);
      request.setServiceVector(serviceVector);
  
      return (ServiceDetail)execute(request);
    }
  
    /**
     * "Used to register or update complete information about a tModel."
     *
     * @exception RegistryException;
     */
    public TModelDetail saveTModel(AuthInfo authInfo,Vector tModelVector)
      throws RegistryException
    {
      SaveTModel request = new SaveTModel();
      request.setAuthInfo(authInfo);
      request.setTModelVector(tModelVector);
  
      return (TModelDetail)execute(request);
    }
  
    /**
     * @exception RegistryException;
     */
    public PublisherAssertions setPublisherAssertions(AuthInfo authInfo,Vector assertionVector)
      throws RegistryException
    {
      SetPublisherAssertions request = new SetPublisherAssertions();
      request.setAuthInfo(authInfo);
      request.setPublisherAssertionVector(assertionVector);
  
      return (PublisherAssertions)execute(request);
    }
  
    /**
     * "Used to delete an existing publisher accounts."
     *
     * @exception RegistryException;
     */
    public DispositionReport deletePublisher(AuthInfo authInfo,Vector publisherIDVector)
      throws RegistryException
    {
      DeletePublisher request = new DeletePublisher();
      request.setAuthInfo(authInfo);
      request.setPublisherIDVector(publisherIDVector);
  
      return (DispositionReport)execute(request);
    }
  
    /**
     * @exception RegistryException;
     */
    public PublisherDetail getPublisherDetail(Vector publisherIDVector)
      throws RegistryException
    {
      GetPublisherDetail request = new GetPublisherDetail();
      request.setPublisherIDVector(publisherIDVector);
  
      return (PublisherDetail)execute(request);
    }
  
    /**
     * @exception RegistryException;
     */
    public PublisherList findPublisher(String publisherID,String name,FindQualifiers findQualifiers,int maxRows)
      throws RegistryException
    {
      FindPublisher request = new FindPublisher();
      request.setName(name);
      request.setFindQualifiers(findQualifiers);
      request.setMaxRows(maxRows);
  
      return (PublisherList)execute(request);
    }
  
    /**
     * @exception RegistryException;
     */
    public PublisherDetail savePublisher(AuthInfo authInfo,Vector publisherVector)
      throws RegistryException
    {
      SavePublisher request = new SavePublisher();
      request.setAuthInfo(authInfo);
      request.setPublisherVector(publisherVector);
  
      return (PublisherDetail)execute(request);
    }
  
    /**
     * @exception RegistryException
     */
    public abstract RegistryObject execute(RegistryObject request)
      throws RegistryException;
  }
  
  
  1.1                  ws-juddi/src/java/org/apache/juddi/registry/RegistryEngine.java
  
  Index: RegistryEngine.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "jUDDI" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.juddi.registry;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.apache.juddi.datastore.DataStoreFactory;
  import org.apache.juddi.datatype.RegistryObject;
  import org.apache.juddi.error.RegistryException;
  import org.apache.juddi.error.UnsupportedException;
  import org.apache.juddi.function.FunctionMaker;
  import org.apache.juddi.function.IFunction;
  import org.apache.juddi.util.Config;
  
  /**
   * @author Steve Viens (sviens@apache.org)
   */
  public class RegistryEngine extends Registry
  {
    // private reference to the jUDDI logger
    private static Log log = LogFactory.getLog(RegistryEngine.class);
  
    // jUDDI shared UDDI Function maker
    private static FunctionMaker maker = FunctionMaker.getInstance();
  
    // registry singleton instance
    private static RegistryEngine registry = null;
  
    // registry status
    private boolean isAvailable = false;
  
    /**
     *
     */
    private RegistryEngine()
    {
    }
  
    /**
     *
     */
    public static RegistryEngine getInstance()
    {
      if (registry == null)
        registry = createInstance();
      return registry;
    }
  
    /**
     *
     */
    private static synchronized RegistryEngine createInstance()
    {
      if (registry == null)
        registry = new RegistryEngine();
      return registry;
    }
  
    /**
     * Initialize required resources.
     */
    public void init()
    {
      // turn off registry access
  
      isAvailable = false;
  
      // create, initialize and register
      // the core jUDDI components.
  
      DataStoreFactory.initFactory();
  
      // turn on registry access
  
      isAvailable = true;
    }
  
    /**
     * Releases any acquired resources. Will stop these
     * if they are currently running.
     */
    public void dispose()
    {
      // turn off registry access
  
      isAvailable = false;
  
      // call each sub-component's dispose methods
  
      DataStoreFactory.destroyFactory();
    }
  
    /**
     * Returns 'true' if the registry is available
     * to handle requests, otherwise returns 'false'.
     */
    public boolean isAvailable()
    {
      return this.isAvailable;
    }
  
    /**
     *
     */
    public RegistryObject execute(RegistryObject request)
      throws RegistryException
    {
      String className = request.getClass().getName();
  
      IFunction function = (IFunction)maker.lookup(className);
      if (function == null)
        throw new UnsupportedException(className);
  
      RegistryObject response = function.execute(request);
  
      return response;
    }
  
  
    /***************************************************************************/
    /***************************** TEST DRIVER *********************************/
    /***************************************************************************/
  
  
    public static void main(String[] args)
      throws Exception
    {
      // okay, let's build the registry
      RegistryEngine registry = RegistryEngine.getInstance();
      registry.init();
  
      // dump all registry properties to the console
      System.out.println(Config.getProperties());
  
      // test the logger
      log.debug("log.debug");
      log.info("log.info");
      log.warn("log.warn");
      log.error("log.error");
      log.fatal("log.fatal");
  
      // tear down the registry
      registry.dispose();
    }
  }