ammulder    2005/07/07 17:37:09

  Added:       modules/pkgen-builder/src/schema openejb-pkgen.xsd
                        xmlconfig.xml
  Log:

  Add option to configure PK generation via direct schema elements instead
    of only using references to GBeans.
  The old style configuration is still supported, though the syntax is
    different (if you want to use a GBean reference, put it in a
    key-generator/custom-generator element)
  There's also a placeholder commented out of the XML Schema for key
    generation using IDs inserted directly into the target table by the
    database (using AUTO_INCREMENT columns or triggers) though that
    requires additional features from TranQL before it works.
  
  Revision  Changes    Path
  1.1                  
openejb/modules/pkgen-builder/src/schema/openejb-pkgen.xsd
  
  Index: openejb-pkgen.xsd
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!-- ================================================================
  Redistribution and use of this software and associated documentation
  ("Software"), with or without modification, are permitted provided
  that the following conditions are met:
  
  1. Redistributions of source code must retain copyright
  statements and notices.  Redistributions must also contain a
  copy of this document.
  
  2. Redistributions in binary form must reproduce this list of
  conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.
  
  3. The name "OpenEJB" must not be used to endorse or promote
  products derived from this Software without prior written
  permission of The OpenEJB Group.  For written permission,
  please contact [EMAIL PROTECTED]
  
  4. Products derived from this Software may not be called "OpenEJB"
  nor may "OpenEJB" appear in their names without prior written
  permission of The OpenEJB Group. OpenEJB is a registered
  trademark of The OpenEJB Group.
  
  5. Due credit should be given to the OpenEJB Project
  (http://openejb.org/).
  
  THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
  ``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 OPENEJB GROUP 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 OpenEJB Project.  For more information
  please see <http://openejb.org/>.
  
  ================================================================ -->
  
  <xsd:schema
      xmlns:xsd="http://www.w3.org/2001/XMLSchema";
      xmlns:j2ee="http://java.sun.com/xml/ns/j2ee";
      xmlns:pkgen="http://www.openejb.org/xml/ns/pkgen";
      targetNamespace="http://www.openejb.org/xml/ns/pkgen";
      elementFormDefault="qualified"
      attributeFormDefault="unqualified"
      version="1.0">
  
      <xsd:element name="key-generator" type="pkgen:key-generatorType"/>
  
      <xsd:complexType name="key-generatorType">
          <xsd:annotation>
              <xsd:documentation>
                Primary Key generation element.
  
                If this is present, a key generator GBean will be created
                and configured to generate IDs for the surrounding object.
              </xsd:documentation>
          </xsd:annotation>
  
          <xsd:choice>
  <!-- Add this in as soon as TranQL has support.
       I assume it needs some kind of token PK generator that just tells
       it which column(s) in the table will be populated automatically
       by a database feature (such as MySQL AUTO_INCREMENT columns or a
       pre-insert trigger or whatever)
              <xsd:element name="database-generated" 
type="pkgen:database-generatedType" /> -->
              <xsd:element name="sequence-table" 
type="pkgen:sequence-tableType" />
              <xsd:element name="auto-increment-table" 
type="pkgen:auto-increment-tableType" />
              <xsd:element name="sql-generator" type="pkgen:sql-generatorType" 
/>
              <xsd:element name="custom-generator" 
type="pkgen:custom-generatorType" />
          </xsd:choice>
  
      </xsd:complexType>
  
      <xsd:complexType name="database-generatedType" >
          <xsd:annotation>
              <xsd:documentation>
                  Indicates that the database automatically populates a primary 
key
                  ID in the listed column(s).  Typically this is used for 
columns
                  with an AUTO_INCREMENT flag or the equivalent.  This only 
makes
                  sense if this key generator is used for an EJB or something 
else
                  with a corresponding database table (not if it's meant to 
generate
                  unique web session IDs or something like that -- see
                  auto-increment-tableType for that case).
              </xsd:documentation>
          </xsd:annotation>
          <xsd:sequence>
              <xsd:element name="identity-column" type="xsd:string"
                  maxOccurs="unbounded"/>
          </xsd:sequence>
      </xsd:complexType>
  
      <xsd:complexType name="sequence-tableType" >
          <xsd:annotation>
              <xsd:documentation>
                  Indicates that a separate table holds a list of table name/ID
                  pairs and the server should fetch the next ID from that table.
              </xsd:documentation>
          </xsd:annotation>
          <xsd:sequence>
              <xsd:element name="table-name" type="xsd:string"/>
              <xsd:element name="sequence-name" type="xsd:string"/>
              <xsd:element name="batch-size" type="xsd:int"/>
          </xsd:sequence>
      </xsd:complexType>
  
      <xsd:complexType name="sql-generatorType" >
          <xsd:annotation>
              <xsd:documentation>
                  Indicates that an arbitrary SQL statement should be used to
                  generate the next ID.
              </xsd:documentation>
          </xsd:annotation>
          <xsd:sequence>
              <xsd:element name="sql" type="xsd:string"/>
              <xsd:element name="return-type" type="xsd:string"/>
          </xsd:sequence>
      </xsd:complexType>
  
      <xsd:complexType name="auto-increment-tableType" >
          <xsd:annotation>
              <xsd:documentation>
                  Handles the case where an arbitrary SQL statement is executed,
                  and the JDBC driver returns a new automatically generated ID.
                  This should not be used when the destination table itself
                  generates the ID (see database-generatedType), but it could be
                  used for a web session ID or something where there is no
                  naturally matching database table (but you could create one
                  with an AUTO_INCREMENT key, specify an insert statement here,
                  and then capture the newly returned ID and use it as your
                  web session ID).
              </xsd:documentation>
          </xsd:annotation>
          <xsd:sequence>
              <xsd:element name="sql" type="xsd:string"/>
              <xsd:element name="return-type" type="xsd:string"/>
          </xsd:sequence>
      </xsd:complexType>
  
      <xsd:complexType name="custom-generatorType" >
          <xsd:annotation>
              <xsd:documentation>
                  Handles a user-provided generator.  You deploy any old 
generator
                  as a GBean, and then point to that GBean here.  The generator
                  should implement org.tranql.pkgenerator.PrimaryKeyGenerator.
              </xsd:documentation>
          </xsd:annotation>
          <xsd:sequence>
              <xsd:element name="generator-name" type="xsd:string"/>
              <xsd:element name="primary-key-class" type="xsd:string"/>
          </xsd:sequence>
      </xsd:complexType>
  </xsd:schema>
  
  
  
  1.1                  openejb/modules/pkgen-builder/src/schema/xmlconfig.xml
  
  Index: xmlconfig.xml
  ===================================================================
  <xb:config xmlns:xb="http://www.bea.com/2002/09/xbean/config";>
  
      <xb:namespace uri="http://www.openejb.org/xml/ns/pkgen";>
          <xb:package>org.openejb.xbeans.pkgen</xb:package>
          <xb:prefix>Ejb</xb:prefix>
      </xb:namespace>
  
  </xb:config>
  
  

Reply via email to