Package com.dbxml.db.client.xmlrpc

Source Code of com.dbxml.db.client.xmlrpc.dbXMLClientImpl

package com.dbxml.db.client.xmlrpc;

/*
* dbXML - Native XML Database
* Copyright (c) 1999-2006 The dbXML Group, L.L.C.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* $Id: dbXMLClientImpl.java,v 1.5 2006/02/02 18:53:47 bradford Exp $
*/

import com.dbxml.db.client.CollectionClient;
import com.dbxml.db.client.ContentClient;
import com.dbxml.db.client.dbXMLClient;
import com.dbxml.util.dbXMLException;

/**
* dbXMLClientImpl
*/

public final class dbXMLClientImpl extends ConnectionManager implements dbXMLClient {
   private static final String PATH = "dbXML";

   private boolean connected;
   private CollectionClient database;

   public dbXMLClientImpl() {
   }

   public void connect() throws dbXMLException {
      if ( connected )
         throw new dbXMLException("Already connected");

      try {
         setClientPath(PATH);
         getXmlRpcClient();
         getDatabase(); // to Test
         connected = true;
      }
      catch ( dbXMLException e ) {
         connected = false;
         throw e;
      }
      catch ( Exception e ) {
         connected = false;
         throw new dbXMLException(e);
      }
   }

   public void disconnect() throws dbXMLException {
      if ( connected ) {
         connected = false;
         database = null;
      }
      else
         throw new dbXMLException("Not connected");
   }

   public String getServerVersion() throws dbXMLException {
      return executeString("getServerVersion", null);
   }

   public void shutdown(int exitCode) throws dbXMLException {
      try {
         execute("shutdown", new Object[]{new Integer(exitCode)});
      }
      catch ( dbXMLException e ) {
         if ( e.getFaultCode() == 0 )
            return;
         else
            throw e;
      }
   }

   public CollectionClient getDatabase() throws dbXMLException {
      if ( database == null )
         database = new CollectionClientImpl(this, "/", false);
      return database;
   }

   public CollectionClient getCollection(String childPath) throws dbXMLException {
      return new CollectionClientImpl(this, childPath);
   }

   public ContentClient getContent(String docPath) throws dbXMLException {
      ContentClient doc = new ContentClientImpl(this, docPath);
      return doc;
   }
}
TOP

Related Classes of com.dbxml.db.client.xmlrpc.dbXMLClientImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.