db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer RelationshipPrefetcherFactory.java RelationshipPrefetcher.java
Date Mon, 08 Dec 2003 21:13:19 GMT
brj         2003/12/08 13:13:19

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        RelationshipPrefetcherFactory.java
                        RelationshipPrefetcher.java
  Log:
  - new factory method
  - enhanced interface
  
  Revision  Changes    Path
  1.2       +37 -24    db-ojb/src/java/org/apache/ojb/broker/accesslayer/RelationshipPrefetcherFactory.java
  
  Index: RelationshipPrefetcherFactory.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/RelationshipPrefetcherFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RelationshipPrefetcherFactory.java	4 Aug 2002 07:45:42 -0000	1.1
  +++ RelationshipPrefetcherFactory.java	8 Dec 2003 21:13:19 -0000	1.2
  @@ -57,36 +57,49 @@
   import org.apache.ojb.broker.PersistenceBroker;
   import org.apache.ojb.broker.PersistenceBrokerException;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
  +import org.apache.ojb.broker.metadata.CollectionDescriptor;
   import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
   
   /**
    * Factory for Relationship Prefetchers
    * 
  - * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
  + * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
    * @version $Id$
    */
   public class RelationshipPrefetcherFactory
   {
  -	/**
  -	 * create either a CollectionPrefetcher or a ReferencePrefetcher
  -	 */ 
  -	public static RelationshipPrefetcher createRelationshipPrefetcher(PersistenceBroker aBroker,
ClassDescriptor anOwnerCld, String aRelationshipName)
  -	{
  -		ObjectReferenceDescriptor ord;
  -		
  -		ord = anOwnerCld.getCollectionDescriptorByName(aRelationshipName);
  -		if (ord != null)
  -		{
  -			return new CollectionPrefetcher(aBroker, ord);
  -		}
  -		
  -		ord = anOwnerCld.getObjectReferenceDescriptorByName(aRelationshipName);
  -		if (ord != null)
  -		{
  -			return new ReferencePrefetcher(aBroker, ord);
  -		}
  -		
  -		throw new PersistenceBrokerException("Relationship not found: " + aRelationshipName);
  -	}	
  -
  +    /**
  +     * create either a CollectionPrefetcher or a ReferencePrefetcher
  +     */ 
  +    public static RelationshipPrefetcher createRelationshipPrefetcher(PersistenceBroker
aBroker, ObjectReferenceDescriptor ord)
  +    {
  +        if (ord instanceof CollectionDescriptor)
  +        {
  +            return new CollectionPrefetcher(aBroker, ord);                
  +        }
  +        else
  +        {    
  +            return new ReferencePrefetcher(aBroker, ord);
  +        }
  +    }   
  +    
  +    /**
  +     * create either a CollectionPrefetcher or a ReferencePrefetcher
  +     */ 
  +    public static RelationshipPrefetcher createRelationshipPrefetcher(PersistenceBroker
aBroker, ClassDescriptor anOwnerCld, String aRelationshipName)
  +    {
  +        ObjectReferenceDescriptor ord;
  +        
  +        ord = anOwnerCld.getCollectionDescriptorByName(aRelationshipName);
  +        if (ord == null)
  +        {
  +            ord = anOwnerCld.getObjectReferenceDescriptorByName(aRelationshipName);
  +            if (ord == null)
  +            {
  +                throw new PersistenceBrokerException("Relationship not found: " + aRelationshipName);
  +            }
  +        }
  +        
  +        return createRelationshipPrefetcher(aBroker, ord);
  +    }   
   }
  
  
  
  1.3       +11 -3     db-ojb/src/java/org/apache/ojb/broker/accesslayer/RelationshipPrefetcher.java
  
  Index: RelationshipPrefetcher.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/RelationshipPrefetcher.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RelationshipPrefetcher.java	25 Oct 2003 23:59:26 -0000	1.2
  +++ RelationshipPrefetcher.java	8 Dec 2003 21:13:19 -0000	1.3
  @@ -56,17 +56,25 @@
    */
   
   import java.util.Collection;
  +
  +import org.apache.ojb.broker.metadata.ClassDescriptor;
    
   /**
    * Interface for Relationship Prefetchers.
    * Each Prefetcher handles a single Relationship (1:1 or 1:n)
    * 
  - * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
  + * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
    * @version $Id$
    */
   public interface RelationshipPrefetcher
   {
  -	/**
  +    /**
  +     * Returns the ClassDescriptor of the item Class
  +     * @return ClassDescriptor
  +     */
  +    public ClassDescriptor getItemClassDescriptor();
  +
  +    /**
   	 * Prepare the Relationship for prefetch (ie: disable auto-retrieve)
   	 */ 
   	public void prepareRelationshipSettings();
  
  
  

---------------------------------------------------------------------
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