avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/altrmi/server AltrmiDatabaseManager.java AltrmiDatabaseManager.xinfo
Date Thu, 10 Jan 2002 00:49:30 GMT
hammant     02/01/09 16:49:30

  Modified:    apps/db  build.xml
               apps/db/src/java/org/apache/avalon/db/driver
                        AvalonDBDriver.java
               apps/db/src/java/org/apache/avalon/db/driver/sql
                        SQLParserHelper.java
  Added:       apps/db/src/java/org/apache/avalon/db/transport/altrmi/client
                        AltrmiConnection.java
               apps/db/src/java/org/apache/avalon/db/transport/altrmi/client/jdbc2x
                        JDBC2xAltrmiConnection.java
               apps/db/src/java/org/apache/avalon/db/transport/altrmi/client/jdbc30
                        JDBC30AltrmiConnection.java
               apps/db/src/java/org/apache/avalon/db/transport/altrmi/server
                        AltrmiDatabaseManager.java
                        AltrmiDatabaseManager.xinfo
  Log:
  Added transport for AltRMI
  
  Revision  Changes    Path
  1.30      +4 -0      jakarta-avalon-cornerstone/apps/db/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/build.xml,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- build.xml	4 Jan 2002 21:53:49 -0000	1.29
  +++ build.xml	10 Jan 2002 00:49:29 -0000	1.30
  @@ -140,6 +140,10 @@
         <exclude name="org/apache/avalon/db/driver/jdbc2x/**"
                  if="jdbc30.present" />               
         
  +      <exclude name="org/apache/avalon/db/transport/altrmi/client/jdbc30/**"
  +               unless="jdbc30.present" />
  +      <exclude name="org/apache/avalon/db/transport/altrmi/client/jdbc2x/**"
  +               if="jdbc30.present" />
         <exclude name="org/apache/avalon/db/transport/soap/client/glue/jdbc30/**"
                  unless="jdbc30.present" />
         <exclude name="org/apache/avalon/db/transport/soap/client/glue/jdbc2x/**"
  
  
  
  1.13      +5 -2      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/AvalonDBDriver.java
  
  Index: AvalonDBDriver.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/AvalonDBDriver.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- AvalonDBDriver.java	30 Nov 2001 12:09:09 -0000	1.12
  +++ AvalonDBDriver.java	10 Jan 2002 00:49:29 -0000	1.13
  @@ -30,7 +30,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.12 $
  + * @version $Revision: 1.13 $
    */
   public class
           AvalonDBDriver extends AbstractDriver implements Driver {
  @@ -84,8 +84,11 @@
               connectionClass1 = "org.apache.avalon.db.transport.cmdstream.client.";
               connectionClass2 = "CommandConnection";
           } else if (words[2].equals("glue")) {
  -            connectionClass1 = "org.apache.avalon.db.transport.cmdstream.client.";
  +            connectionClass1 = "org.apache.avalon.db.transport.soap.client.";
               connectionClass2 = "GlueConnection";
  +        } else if (words[2].startsWith("altrmi-")) {
  +            connectionClass1 = "org.apache.avalon.db.transport.altrmi.client.";
  +            connectionClass2 = "AltrmiConnection";
           }
           AvalonDBConnection connection = null;
           try {
  
  
  
  1.4       +6 -6      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/sql/SQLParserHelper.java
  
  Index: SQLParserHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/sql/SQLParserHelper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SQLParserHelper.java	16 Nov 2001 06:14:59 -0000	1.3
  +++ SQLParserHelper.java	10 Jan 2002 00:49:29 -0000	1.4
  @@ -1,10 +1,10 @@
  +
   /*
  - * Created by IntelliJ IDEA.
  - * User: Administrator
  - * Date: Nov 4, 2001
  - * Time: 10:05:06 AM
  - * To change template for new class use 
  - * Code Style | Class Templates options (Tools | IDE Options).
  + * Copyright (C) The avalon Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the avalon Software License
  + * version 1.1, a copy of which has been included with this distribution in
  + * the LICENSE file.
    */
   package org.apache.avalon.db.driver.sql;
   
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/altrmi/client/AltrmiConnection.java
  
  Index: AltrmiConnection.java
  ===================================================================
  
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.avalon.db.transport.altrmi.client;
  
  import org.apache.avalon.db.driver.AvalonDBConnection;
  import org.apache.avalon.db.services.DatabaseManager;
  import org.apache.avalon.db.utils.StringUtils;
  import org.apache.avalon.db.common.AvalonDBSQLException;
  import org.apache.avalon.db.transport.Reply;
  import org.apache.avalon.db.transport.Request;
  import org.apache.commons.altrmi.client.AltrmiHostContext;
  import org.apache.commons.altrmi.client.AltrmiFactory;
  import org.apache.commons.altrmi.client.impl.rmi.RmiAltrmiHostContext;
  import org.apache.commons.altrmi.client.impl.socket.SocketObjectStreamHostContext;
  import org.apache.commons.altrmi.client.impl.ClientClassAltrmiFactory;
  import org.apache.commons.altrmi.common.AltrmiConnectionException;
  import org.apache.commons.altrmi.common.AltrmiInvocationException;
  
  import java.sql.SQLException;
  
  
  /**
   * Class GlueConnection
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public abstract class AltrmiConnection extends AvalonDBConnection {
  
  
      private DatabaseManager mDBManager;
      private String[] mOptions;
  
      private AltrmiHostContext getAltrmiHostContext(String url, String host, int port) throws
SQLException {
          String[] words = StringUtils.split(url,":");
  
          try {
              if (words[2].equals("altrmi-rmi")) {
                  return new RmiAltrmiHostContext(host,port);
              } else if (words[2].equals("altrmi-sos")) {
                  return new SocketObjectStreamHostContext(host,port);
              } else {
                  throw new SQLException("Unknown altrmi transport");
              }
          } catch (AltrmiConnectionException ace) {
              throw new SQLException("Unable to establish connection to server: " + ace.getMessage());
          }
      }
  
  
      protected void initialize(String host, int port, String url, String[] options, int syntax)
throws SQLException {
  
          AltrmiFactory altrmiFactory = new ClientClassAltrmiFactory();
          altrmiFactory.setHostContext(getAltrmiHostContext(url,host,port));
          mOptions = options;
  
          try {
              mDBManager = (DatabaseManager) altrmiFactory.lookup("AvalonDB");
          } catch (AltrmiConnectionException ace) {
              throw new AvalonDBSQLException(
                  "Some IO Exception during connection creation to AltRMI Service" + url
                  + " during connection creation", ace);
          }
      }
  
      protected void closeConnection() throws SQLException {
          // TODO
      }
  
      /**
       * Method sendRequest
       *
       *
       * @param request
       *
       * @return
       *
       * @throws SQLException
       *
       */
      public Reply sendRequest(Request request) throws SQLException {
          try {
              return mDBManager.processRequest(request);
          } catch (AltrmiInvocationException aie) {
              throw new SQLException("Connection to server lost, even after retries. Detail
: " + aie.getMessage());
          }
      }
  }
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/altrmi/client/jdbc2x/JDBC2xAltrmiConnection.java
  
  Index: JDBC2xAltrmiConnection.java
  ===================================================================
  
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.avalon.db.transport.altrmi.client.jdbc2x;
  
  import org.apache.avalon.db.transport.altrmi.client.AltrmiConnection;
  import org.apache.avalon.db.driver.jdbc2x.JDBC2xStatementFactory;
  
  import java.sql.SQLException;
  
  public class JDBC2xAltrmiConnection extends AltrmiConnection {
  
      public JDBC2xAltrmiConnection() throws SQLException {
          mStatementFactory = new JDBC2xStatementFactory();
      }
  
  }
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/altrmi/client/jdbc30/JDBC30AltrmiConnection.java
  
  Index: JDBC30AltrmiConnection.java
  ===================================================================
  
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.avalon.db.transport.altrmi.client.jdbc30;
  
  import org.apache.avalon.db.transport.altrmi.client.AltrmiConnection;
  import org.apache.avalon.db.driver.jdbc30.JDBC30StatementFactory;
  
  import java.sql.SQLException;
  import java.sql.Savepoint;
  import java.sql.Statement;
  import java.sql.PreparedStatement;
  import java.sql.CallableStatement;
  
  
  public class JDBC30AltrmiConnection extends AltrmiConnection {
  
      public JDBC30AltrmiConnection() throws SQLException {
          mStatementFactory = new JDBC30StatementFactory();
      }
  
      public Savepoint setSavepoint() throws SQLException {
          debug();
          return null;
      }
  
      public Savepoint setSavepoint(String s) throws SQLException {
          debug();
          return null;
      }
  
      public void rollback(Savepoint savepoint) throws SQLException {
          debug();
      }
  
      public void releaseSavepoint(Savepoint savepoint) throws SQLException {
          debug();
      }
  
      public Statement createStatement(int i, int i1, int i2) throws SQLException {
          debug();
          return null;
      }
  
      public PreparedStatement prepareStatement(String s, int i, int i1, int i2) throws SQLException
{
          debug();
          return null;
      }
  
      public CallableStatement prepareCall(String s, int i, int i1, int i2) throws SQLException
{
          debug();
          return null;
      }
  
      public PreparedStatement prepareStatement(String s, int i) throws SQLException {
          debug();
          return null;
      }
  
      public PreparedStatement prepareStatement(String s, int[] ints) throws SQLException
{
          debug();
          return null;
      }
  
      public PreparedStatement prepareStatement(String s, String[] strings) throws SQLException
{
          debug();
          return null;
      }
  
  
  }
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/altrmi/server/AltrmiDatabaseManager.java
  
  Index: AltrmiDatabaseManager.java
  ===================================================================
  
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.avalon.db.transport.altrmi.server;
  
  import org.apache.avalon.db.server.AbstractDatabaseManager;
  import org.apache.avalon.db.services.DatabaseManager;
  import org.apache.avalon.phoenix.Block;
  import org.apache.avalon.phoenix.BlockContext;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.commons.altrmi.server.AltrmiPublisher;
  
  /**
   * @author  Paul Hammant <Paul_Hammant@yahoo.com>
   * @version 1.0
   */
  public class AltrmiDatabaseManager extends AbstractDatabaseManager
          implements Block, DatabaseManager, Contextualizable,
          Initializable  {
  
      protected BlockContext mContext;
      protected AltrmiPublisher mAltrmiPublisher;
  
      /**
       * Method contextualize
       *
       *
       * @param context
       *
       */
      public void contextualize(final Context context) {
          mContext = (BlockContext) context;
      }
  
  
      /**
       * Method compose
       *
       *
       * @param componentManager
       *
       * @throws ComponentException
       *
       */
      public void compose(final ComponentManager componentManager) throws ComponentException
{
  
          super.compose(componentManager);
          mAltrmiPublisher = (AltrmiPublisher) componentManager.lookup(AltrmiPublisher.class.getName());
      }
  
  
      /**
       * Method initialize
       *
       *
       * @throws Exception
       *
       */
      public void initialize() throws Exception {
          //TODO published name should be taken from config.xml
          mAltrmiPublisher.publish(this, "AvalonDB", DatabaseManager.class);
      }
  
  }
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/altrmi/server/AltrmiDatabaseManager.xinfo
  
  Index: AltrmiDatabaseManager.xinfo
  ===================================================================
  <?xml version="1.0"?>
  
  <blockinfo>
  
    <!-- section to describe block -->
    <block>
      <version>1.0</version>
    </block>
  
    <!-- services that are offered by this block -->
    <services>
      <service name="org.apache.avalon.db.services.DatabaseManager" 
               version="1.0" />
    </services>
  
    <dependencies>
      <dependency>
        <service name="org.apache.commons.altrmi.server.AltrmiPublisher" version="1.0"/>
      </dependency>
      <dependency>
        <service name="org.apache.avalon.db.services.ParserManager" version="1.0"/>
      </dependency>
      <dependency>
        <service name="org.apache.avalon.db.services.SQLOptimizer" version="1.0"/>
      </dependency>
      <dependency>
        <service name="org.apache.avalon.db.services.DatabasePersistence" version="1.0"/>
      </dependency>      
    </dependencies>  
  
  </blockinfo>
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message