db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/core/proxy CollectionProxyDefaultImpl.java IndirectionHandlerDefaultImpl.java
Date Mon, 12 Apr 2004 18:20:57 GMT
tomdz       2004/04/12 11:20:57

  Modified:    src/java/org/apache/ojb/broker/core/proxy
                        CollectionProxyDefaultImpl.java
                        IndirectionHandlerDefaultImpl.java
  Log:
  Changed interface for easier subclassing: overridable methods (materializeSubject; loadSize,
loadData) now do not modify the state internally, but rather return the loaded values
  
  Revision  Changes    Path
  1.4       +10 -6     db-ojb/src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java
  
  Index: CollectionProxyDefaultImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CollectionProxyDefaultImpl.java	12 Apr 2004 18:03:43 -0000	1.3
  +++ CollectionProxyDefaultImpl.java	12 Apr 2004 18:20:56 -0000	1.4
  @@ -99,13 +99,16 @@
       }
   
       /**
  -     * Determines the number of elements that the query would return.
  +     * Determines the number of elements that the query would return. Override this
  +     * method if the size shall be determined in a specific way.
  +     * 
  +     * @return The number of elements
        */
  -    protected synchronized void loadSize() throws PersistenceBrokerException
  +    protected synchronized int loadSize() throws PersistenceBrokerException
       {
           try
           {
  -            setSize(getBroker().getCount(getQuery()));
  +            return getBroker().getCount(getQuery());
           }
           catch (Exception ex)
           {
  @@ -128,7 +131,8 @@
       }
       
       /**
  -     * Loads the data from the database.
  +     * Loads the data from the database. Override this method if the objects
  +     * shall be loaded in a specific way.
        * 
        * @return The loaded data
        */
  @@ -209,7 +213,7 @@
           {
               if (_size < 0)
               {
  -                loadSize();
  +                _size = loadSize();
               }
               return _size;
           }
  
  
  
  1.3       +12 -10    db-ojb/src/java/org/apache/ojb/broker/core/proxy/IndirectionHandlerDefaultImpl.java
  
  Index: IndirectionHandlerDefaultImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/proxy/IndirectionHandlerDefaultImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IndirectionHandlerDefaultImpl.java	12 Apr 2004 18:03:43 -0000	1.2
  +++ IndirectionHandlerDefaultImpl.java	12 Apr 2004 18:20:56 -0000	1.3
  @@ -325,7 +325,9 @@
       {
           if (_realSubject == null)
           {
  -            materializeSubject();
  +            beforeMaterialization();
  +            _realSubject = materializeSubject();
  +            afterMaterialization();
           }
           return _realSubject;
       }
  @@ -342,22 +344,22 @@
       }
   
       /**
  -     * Retrieves the real subject from the underlying RDBMS.
  +     * Retrieves the real subject from the underlying RDBMS. Override this method if
  +     * the object is to be materialized in a specific way.
  +     * 
  +     * @return The real subject of the proxy
        */
  -    protected synchronized void materializeSubject() throws PersistenceBrokerException
  +    protected synchronized Object materializeSubject() throws PersistenceBrokerException
       {
           try
           {
  -            beforeMaterialization();
  +            Object realSubject = getBroker().getObjectByIdentity(_id);
   
  -            _realSubject = getBroker().getObjectByIdentity(_id);
  -
  -            if (_realSubject == null)
  +            if (realSubject == null)
               {
                   LoggerFactory.getLogger(IndirectionHandler.class).warn("Can not materialize
object for Identity " + _id + " - using PBKey " + _brokerKey);
               }
  -
  -            afterMaterialization();
  +            return realSubject;
           }
           catch (Exception ex)
           {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message