db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: jakarta-ojb/src/java/org/apache/ojb/broker Identity.java PersistenceBroker.java PersistenceBrokerFactory.java
Date Thu, 09 Jan 2003 17:11:48 GMT
arminw      2003/01/09 09:11:48

  Modified:    src/java/org/apache/ojb/broker Identity.java
                        PersistenceBroker.java
                        PersistenceBrokerFactory.java
  Log:
  - rename DescriptorRepository#getExtentClass
  to #getTopLevelClass, deprecate PB#getExtentClass
  and add PB#getTopLevelClass
  
  Revision  Changes    Path
  1.12      +20 -21    jakarta-ojb/src/java/org/apache/ojb/broker/Identity.java
  
  Index: Identity.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/Identity.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Identity.java	1 Jan 2003 19:21:44 -0000	1.11
  +++ Identity.java	9 Jan 2003 17:11:48 -0000	1.12
  @@ -54,17 +54,18 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.ojb.broker.accesslayer.IndirectionHandler;
  +import org.apache.ojb.broker.metadata.ClassDescriptor;
  +import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException;
  +
   import java.io.ByteArrayInputStream;
   import java.io.ByteArrayOutputStream;
   import java.io.ObjectInputStream;
   import java.io.ObjectOutputStream;
  +import java.io.Serializable;
   import java.util.zip.GZIPInputStream;
   import java.util.zip.GZIPOutputStream;
   
  -import org.apache.ojb.broker.accesslayer.IndirectionHandler;
  -import org.apache.ojb.broker.metadata.ClassDescriptor;
  -import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException;
  -
   //#ifdef JDK13
   import java.lang.reflect.InvocationHandler;
   import java.lang.reflect.Proxy;
  @@ -82,7 +83,7 @@
    * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
    * @version $Id$
    */
  -public class Identity implements java.io.Serializable
  +public class Identity implements Serializable
   {
       /**
        * the Class of the identified object<br>
  @@ -150,10 +151,10 @@
           }
           finally
           {
  -        	if (broker != null)
  -        	{
  -            	broker.close();
  -        	}
  +            if (broker != null)
  +            {
  +                broker.close();
  +            }
           }
       }
   
  @@ -187,9 +188,9 @@
               }
               else
               {
  -                if(cld == null) cld = targetBroker.getClassDescriptor(objectToIdentitify.getClass());
  +                if (cld == null) cld = targetBroker.getClassDescriptor(objectToIdentitify.getClass());
                   // identities must be unique accross extents !
  -                this.objectsClass = targetBroker.getExtentClass(objectToIdentitify.getClass());
  +                this.objectsClass = targetBroker.getTopLevelClass(objectToIdentitify.getClass());
                   this.objectsRealClass = objectToIdentitify.getClass();
                   this.pkValues = targetBroker.serviceBrokerHelper().getKeyValues(cld, objectToIdentitify);
               }
  @@ -291,7 +292,7 @@
           if (stringRepresentation == null)
           {
               StringBuffer buf = new StringBuffer();
  -	    buf.append(objectsClass.getName());
  +            buf.append(objectsClass.getName());
               for (int i = 0; i < pkValues.length; i++)
               {
                   buf.append((i == 0) ? "{" : ",");
  @@ -304,8 +305,6 @@
       }
   
   
  -
  -
       /**
        * OJB can handle only classes that declare at least one primary key attribute,
        * this method checks this condition.
  @@ -315,12 +314,12 @@
       protected void checkForPrimaryKeys() throws ClassNotPersistenceCapableException
       {
           // if no PKs are specified OJB can't handle this class !
  -     	if (this.pkValues.length == 0)
  -     	{
  -     	 	throw new ClassNotPersistenceCapableException(
  -            	"OJB needs at least one primary key attribute for class " +
  -            	this.objectsClass + " / " + this.objectsRealClass);
  -     	}
  +        if (this.pkValues.length == 0)
  +        {
  +            throw new ClassNotPersistenceCapableException(
  +                    "OJB needs at least one primary key attribute for class " +
  +                    "objectClass=" + this.objectsClass + ", objectRealClass=" + this.objectsRealClass);
  +        }
       }
   
       /**
  
  
  
  1.16      +16 -5     jakarta-ojb/src/java/org/apache/ojb/broker/PersistenceBroker.java
  
  Index: PersistenceBroker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/PersistenceBroker.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- PersistenceBroker.java	28 Dec 2002 10:47:10 -0000	1.15
  +++ PersistenceBroker.java	9 Jan 2003 17:11:48 -0000	1.16
  @@ -158,6 +158,7 @@
       // *************************************************************************
       // Transaction and instance handling stuff
       // *************************************************************************
  +
       /**
        * Abort and close the transaction.
        * Calling abort abandons all persistent object modifications and releases the
  @@ -239,14 +240,24 @@
       public boolean hasClassDescriptor(Class clazz);
   
       /**
  -     * returnsthe Extent to which the class clazz belongs.
  -     * This may be a baseclass,an interface or clazz itself, if no Extent
  -     * is defined.
  -     * throws a PersistenceBrokerException if clazz is not persistence capable,
  +     * Returns the top level (extent) class to which the given class belongs.
  +     * This may be a (abstract) base-class, an interface or the given class itself, if
  +     * no extent is defined.
  +     * @throws PersistenceBrokerException if clazz is not persistence capable,
        * i.e. if clazz is not defined in the DescriptorRepository.
  +     *
  +     * @deprecated use {@link #getTopLevelClass} instead
        */
       public Class getExtentClass(Class clazz) throws PersistenceBrokerException;
   
  +    /**
  +     * Returns the top level (extent) class to which the given class belongs.
  +     * This may be a (abstract) base-class, an interface or the given class itself, if
  +     * no extent is defined.
  +     * @throws PersistenceBrokerException if clazz is not persistence capable,
  +     * i.e. if clazz is not defined in the DescriptorRepository.
  +     */
  +    public Class getTopLevelClass(Class clazz) throws PersistenceBrokerException;
   
   
   
  
  
  
  1.16      +3 -3      jakarta-ojb/src/java/org/apache/ojb/broker/PersistenceBrokerFactory.java
  
  Index: PersistenceBrokerFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/PersistenceBrokerFactory.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- PersistenceBrokerFactory.java	24 Dec 2002 13:31:58 -0000	1.15
  +++ PersistenceBrokerFactory.java	9 Jan 2003 17:11:48 -0000	1.16
  @@ -80,7 +80,7 @@
        * Set the default PersistenceBroker (e.g. used within OJB
        * to find OJB internal tables)
        */
  -    public void setDefaultKey(PBKey key)
  +    public static void setDefaultKey(PBKey key)
       {
           PersistenceBrokerFactoryFactory.instance().setDefaultKey(key);
       }
  @@ -89,7 +89,7 @@
        * Get the default PersistenceBroker (e.g. used within OJB
        * to find OJB internal tables)
        */
  -    public PBKey getDefaultKey()
  +    public static PBKey getDefaultKey()
       {
           return PersistenceBrokerFactoryFactory.instance().getDefaultKey();
       }
  
  
  

Mime
View raw message