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/query QueryFactoryNew.java QueryFactoryNewImpl.java QueryFactory.java
Date Thu, 07 Apr 2005 19:55:11 GMT
brj         2005/04/07 12:55:11

  Modified:    src/java/org/apache/ojb/broker OJB.java ContainerHelper.java
               src/java/org/apache/ojb/broker/query QueryFactory.java
  Added:       src/java/org/apache/ojb/broker/query QueryFactoryNew.java
                        QueryFactoryNewImpl.java
  Log:
  get QueryFactory from OJB
  
  Revision  Changes    Path
  1.10      +17 -5     db-ojb/src/java/org/apache/ojb/broker/OJB.java
  
  Index: OJB.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/OJB.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- OJB.java	2 Apr 2005 09:44:39 -0000	1.9
  +++ OJB.java	7 Apr 2005 19:55:11 -0000	1.10
  @@ -33,6 +33,7 @@
   import org.apache.ojb.broker.metadata.PersistenceConfigurationDescriptor;
   import org.apache.ojb.broker.metadata.fieldaccess.PersistentField;
   import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldFactory;
  +import org.apache.ojb.broker.query.QueryFactoryNew;
   import org.apache.ojb.broker.util.BrokerHelper;
   import org.apache.ojb.broker.util.ObjectModification;
   import org.apache.ojb.broker.util.logging.Logger;
  @@ -68,6 +69,7 @@
       private boolean isInitialized = false;
       private MetadataManager metadataManager;
       private ProxyFactory proxyFactory;
  +    private QueryFactoryNew queryFactory;
       private HashMap configurationMap = new HashMap();
       private Object dummy = new Object();
   
  @@ -126,7 +128,7 @@
           }
   
           // configuring the proxy proxyFactory
  -        proxyFactory = (ProxyFactory)container.getSingletonInstance(ProxyFactory.class);
  +        proxyFactory = (ProxyFactory) container.getSingletonInstance(ProxyFactory.class);
           proxyFactory.setIndirectionHandlerClass(container.getImplementationClass(IndirectionHandler.class));
           proxyFactory.setCollectionProxyClass(container.getImplementationClass(CollectionProxy.class));
           proxyFactory.setListProxyClass(container.getImplementationClass(ListProxy.class));
  @@ -136,8 +138,8 @@
           PersistentFieldFactory fieldFactory = new PersistentFieldFactory(container.getImplementationClass(PersistentField.class),
proxyFactory);
           container.setSingletonInstance(PersistentFieldFactory.class, fieldFactory);
           
  -        metadataManager = (MetadataManager)container.getSingletonInstance(MetadataManager.class);
  -        
  +        metadataManager = (MetadataManager) container.getSingletonInstance(MetadataManager.class);
  +        queryFactory = (QueryFactoryNew) container.getSingletonInstance(QueryFactoryNew.class);
           
           isInitialized = true;
       }
  @@ -198,7 +200,17 @@
           initDynamicSystem();
           return proxyFactory;
       }
  -    
  +
  +    /**
  +     * Returns the Query factory.
  +     * @return The Query factory
  +     */
  +    public QueryFactoryNew getQueryFactory()
  +    {
  +        initDynamicSystem();
  +        return queryFactory;
  +    }
  +
       public void shutdown()
       {
           if (!isInitialized)
  
  
  
  1.6       +3 -0      db-ojb/src/java/org/apache/ojb/broker/ContainerHelper.java
  
  Index: ContainerHelper.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/ContainerHelper.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ContainerHelper.java	2 Apr 2005 09:44:39 -0000	1.5
  +++ ContainerHelper.java	7 Apr 2005 19:55:11 -0000	1.6
  @@ -70,6 +70,8 @@
   import org.apache.ojb.broker.metadata.MetadataManager;
   import org.apache.ojb.broker.metadata.fieldaccess.PersistentField;
   import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectImpl;
  +import org.apache.ojb.broker.query.QueryFactoryNew;
  +import org.apache.ojb.broker.query.QueryFactoryNewImpl;
   import org.apache.ojb.broker.transaction.tm.JBossTransactionManagerFactory;
   import org.apache.ojb.broker.transaction.tm.TransactionManagerFactory;
   import org.apache.ojb.broker.util.ClassHelper;
  @@ -264,6 +266,7 @@
           container.ensureImplementationClass(DMap.class, DMapImpl.class);
           container.ensureImplementationClass(DBag.class, DBagImpl.class);
           container.ensureImplementationClass(DSet.class, DSetImpl.class);
  +        container.ensureImplementationClass(QueryFactoryNew.class, QueryFactoryNewImpl.class);
       }
   
       /**
  
  
  
  1.21      +20 -36    db-ojb/src/java/org/apache/ojb/broker/query/QueryFactory.java
  
  Index: QueryFactory.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/QueryFactory.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- QueryFactory.java	1 Apr 2005 20:28:08 -0000	1.20
  +++ QueryFactory.java	7 Apr 2005 19:55:11 -0000	1.21
  @@ -1,5 +1,9 @@
   package org.apache.ojb.broker.query;
   
  +import org.apache.ojb.broker.OJB;
  +import org.apache.ojb.broker.PersistenceBrokerFactory;
  +import org.apache.ojb.broker.locking.LockManager;
  +
   /* Copyright 2002-2004 The Apache Software Foundation
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
  @@ -23,6 +27,9 @@
    */
   public final class QueryFactory
   {
  +    // we use the setup'd OJB instance
  +    private static final QueryFactoryNew theFactory = PersistenceBrokerFactory.getOjb().getQueryFactory();
  +    
       /**
        * create a new ReportQueryByMtoNCriteria
        * @param classToSearchFrom
  @@ -32,9 +39,7 @@
        */
       public static ReportQueryByMtoNCriteriaImpl newMtoNReportQuery(Class classToSearchFrom,
String[] columns, Criteria criteria, boolean distinct, String indirectionTable)
       {
  -        ReportQueryByMtoNCriteriaImpl query = new ReportQueryByMtoNCriteriaImpl(classToSearchFrom,
columns, criteria, distinct);
  -        query.setIndirectionTable(indirectionTable);
  -        return query;
  +        return theFactory.newMtoNReportQuery(classToSearchFrom, columns, criteria, distinct,
indirectionTable);
       }
   
       /**
  @@ -46,7 +51,7 @@
        */
       public static ReportQueryByCriteria newReportQuery(Class classToSearchFrom, String[]
columns, Criteria criteria, boolean distinct)
       {
  -        return new ReportQueryByCriteriaImpl(classToSearchFrom, columns, criteria, distinct);
  +        return theFactory.newReportQuery(classToSearchFrom, columns, criteria, distinct);
       }
   
       /**
  @@ -58,7 +63,7 @@
        */
       public static ReportQueryByCriteria newReportQuery(Class classToSearchFrom, Criteria
criteria, boolean distinct)
       {
  -        return newReportQuery(classToSearchFrom, null, criteria, distinct);
  +        return theFactory.newReportQuery(classToSearchFrom, criteria, distinct);
       }
   
       /**
  @@ -69,7 +74,7 @@
        */
       public static ReportQueryByCriteria newReportQuery(Class classToSearchFrom, Criteria
criteria)
       {
  -        return newReportQuery(classToSearchFrom, criteria, false);
  +        return theFactory.newReportQuery(classToSearchFrom, criteria);
       }
   
       /**
  @@ -81,7 +86,7 @@
        */
       public static QueryByCriteria newQuery(Class classToSearchFrom, Criteria criteria,
boolean distinct)
       {
  -        return new QueryByCriteriaImpl(classToSearchFrom, criteria, distinct);
  +        return theFactory.newQuery(classToSearchFrom, criteria, distinct);
       }
   
       /**
  @@ -92,7 +97,7 @@
        */
       public static QueryByCriteria newQuery(Class classToSearchFrom, Criteria criteria)
       {
  -        return newQuery(classToSearchFrom, criteria, false);
  +        return theFactory.newQuery(classToSearchFrom, criteria, false);
       }
   
       /**
  @@ -102,7 +107,7 @@
        */
       public static QueryByIdentity newQueryByIdentity(Object object_or_identity)
       {
  -        return new QueryByIdentityImpl(object_or_identity);
  +        return theFactory.newQueryByIdentity(object_or_identity);
       }
   
       /**
  @@ -113,7 +118,7 @@
        */
       public static QueryByExample newQueryByExample(Object example)
       {
  -        return new QueryByExampleImpl(example);
  +        return theFactory.newQueryByExample(example);
       }
   
       /**
  @@ -126,7 +131,7 @@
        */
       public static QueryByMtoNCriteria newQuery(Class classToSearchFrom, String indirectionTable,
Criteria criteria, boolean distinct)
       {
  -        return new QueryByMtoNCriteria(classToSearchFrom, indirectionTable, criteria, distinct);
  +        return theFactory.newQuery(classToSearchFrom, indirectionTable, criteria, distinct);
       }
   
       /**
  @@ -138,7 +143,7 @@
        */
       public static QueryByCriteria newQuery(Class classToSearchFrom, String indirectionTable,
Criteria criteria)
       {
  -        return new QueryByMtoNCriteria(classToSearchFrom, indirectionTable, criteria);
  +        return theFactory.newQuery(classToSearchFrom, indirectionTable, criteria);
       }
   
       /**
  @@ -149,7 +154,7 @@
        */
       public static QueryBySQL newQuery(Class classToSearchFrom, String anSqlStatement)
       {
  -        return new QueryBySQLImpl(classToSearchFrom, anSqlStatement);
  +        return theFactory.newQuery(classToSearchFrom, anSqlStatement);
       }
   
       /**
  @@ -159,27 +164,6 @@
        */
       public static QueryByCriteria copyQuery(QueryByCriteria aQuery)
       {
  -        if (aQuery instanceof ReportQueryByMtoNCriteriaImpl)
  -        {
  -            return new ReportQueryByMtoNCriteriaImpl((ReportQueryByMtoNCriteriaImpl) aQuery);
  -        }
  -        
  -        if (aQuery instanceof ReportQuery)
  -        {
  -            return new ReportQueryByCriteriaImpl((ReportQueryByCriteriaImpl) aQuery);
  -        }
  -
  -        if (aQuery instanceof QueryByExample)
  -        {
  -            return new QueryByExampleImpl((QueryByExampleImpl) aQuery);
  -        }
  -
  -        if (aQuery instanceof QueryByMtoNCriteria)
  -        {
  -            return new QueryByMtoNCriteria((QueryByMtoNCriteria) aQuery);
  -        }
  -        
  -        return new QueryByCriteriaImpl((QueryByCriteriaImpl) aQuery); 
  +        return theFactory.copyQuery(aQuery);
       }
  -
   }
  
  
  
  1.1                  db-ojb/src/java/org/apache/ojb/broker/query/QueryFactoryNew.java
  
  Index: QueryFactoryNew.java
  ===================================================================
  package org.apache.ojb.broker.query;
  
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  /**
   * Interface for Query-Factories.
   * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi<a>
   * @version $Id: QueryFactoryNew.java,v 1.1 2005/04/07 19:55:11 brj Exp $
   */
  public interface QueryFactoryNew
  {
      /**
       * create a new ReportQueryByMtoNCriteria.
       * @param classToSearchFrom
       * @param criteria
       * @param distinct
       * @return ReportQueryByMtoNCriteria
       */
      ReportQueryByMtoNCriteriaImpl newMtoNReportQuery(Class classToSearchFrom, String[] columns,
Criteria criteria, boolean distinct, String indirectionTable);
  
      /**
       * create a new ReportQueryByCriteria.
       * @param classToSearchFrom
       * @param criteria
       * @param distinct
       * @return ReportQueryByCriteria
       */
      ReportQueryByCriteria newReportQuery(Class classToSearchFrom, String[] columns, Criteria
criteria, boolean distinct);
  
      /**
       * create a new ReportQueryByCriteria.
       * @param classToSearchFrom
       * @param criteria
       * @param distinct
       * @return ReportQueryByCriteria
       */
      ReportQueryByCriteria newReportQuery(Class classToSearchFrom, Criteria criteria, boolean
distinct);
  
      /**
       * create a new ReportQueryByCriteria.
       * @param classToSearchFrom
       * @param criteria
       * @return ReportQueryByCriteria
       */
      ReportQueryByCriteria newReportQuery(Class classToSearchFrom, Criteria criteria);
  
      /**
       * create a new QueryByCriteria.
       * @param classToSearchFrom
       * @param criteria
       * @param distinct
       * @return QueryByCriteria
       */
      QueryByCriteria newQuery(Class classToSearchFrom, Criteria criteria, boolean distinct);
  
      /**
       * create a new QueryByCriteria.
       * @param classToSearchFrom
       * @param criteria
       * @return QueryByCriteria
       */
      QueryByCriteria newQuery(Class classToSearchFrom, Criteria criteria);
  
      /**
       * Return a QueryByIdentity for object_or_identity.
       * @param object_or_identity
       * @return QueryByIdentity
       */
      QueryByIdentity newQueryByIdentity(Object object_or_identity);
  
      /**
       * Return a QueryByCriteria for example.
       * <br>Use with care because building of Query is not foolproof !!!
       * @param example
       * @return QueryByExample
       */
      QueryByExample newQueryByExample(Object example);
  
      /**
       * create a new QueryByMtoNCriteria.
       * @param classToSearchFrom
       * @param indirectionTable
       * @param criteria
       * @param distinct
       * @return QueryByMtoNCriteria
       */
      QueryByMtoNCriteria newQuery(Class classToSearchFrom, String indirectionTable, Criteria
criteria, boolean distinct);
  
      /**
       * create a new QueryByCriteria.
       * @param classToSearchFrom
       * @param indirectionTable
       * @param criteria
       * @return QueryByCriteria
       */
      QueryByCriteria newQuery(Class classToSearchFrom, String indirectionTable, Criteria
criteria);
  
      /**
       * Factory method for QueryBySQL.
       * @param classToSearchFrom
       * @param anSqlStatement
       * @return QueryBySQL
       */
      QueryBySQL newQuery(Class classToSearchFrom, String anSqlStatement);
  
      /**
       * Return a copy of a QueryByCriteria.
       * @param QueryByCriteria
       * @return QueryByCriteria
       */
      QueryByCriteria copyQuery(QueryByCriteria aQuery);
  }
  
  
  
  1.1                  db-ojb/src/java/org/apache/ojb/broker/query/QueryFactoryNewImpl.java
  
  Index: QueryFactoryNewImpl.java
  ===================================================================
  package org.apache.ojb.broker.query;
  
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  /**
   * Implementation of QueryFactoryNew.
   * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi<a>
   * @version $Id: QueryFactoryNewImpl.java,v 1.1 2005/04/07 19:55:11 brj Exp $
   */
  public class QueryFactoryNewImpl implements QueryFactoryNew
  {
      /**
       * create a new ReportQueryByMtoNCriteria.
       * @param classToSearchFrom
       * @param criteria
       * @param distinct
       * @return ReportQueryByMtoNCriteria
       */
      public ReportQueryByMtoNCriteriaImpl newMtoNReportQuery(Class classToSearchFrom, String[]
columns, Criteria criteria, boolean distinct, String indirectionTable)
      {
          ReportQueryByMtoNCriteriaImpl query = new ReportQueryByMtoNCriteriaImpl(classToSearchFrom,
columns, criteria, distinct);
          query.setIndirectionTable(indirectionTable);
          return query;
      }
  
      /**
       * create a new ReportQueryByCriteria.
       * @param classToSearchFrom
       * @param criteria
       * @param distinct
       * @return ReportQueryByCriteria
       */
      public ReportQueryByCriteria newReportQuery(Class classToSearchFrom, String[] columns,
Criteria criteria, boolean distinct)
      {
          return new ReportQueryByCriteriaImpl(classToSearchFrom, columns, criteria, distinct);
      }
  
      /**
       * create a new ReportQueryByCriteria.
       * @param classToSearchFrom
       * @param criteria
       * @param distinct
       * @return ReportQueryByCriteria
       */
      public ReportQueryByCriteria newReportQuery(Class classToSearchFrom, Criteria criteria,
boolean distinct)
      {
          return newReportQuery(classToSearchFrom, null, criteria, distinct);
      }
  
      /**
       * create a new ReportQueryByCriteria.
       * @param classToSearchFrom
       * @param criteria
       * @return ReportQueryByCriteria
       */
      public ReportQueryByCriteria newReportQuery(Class classToSearchFrom, Criteria criteria)
      {
          return newReportQuery(classToSearchFrom, criteria, false);
      }
  
      /**
       * create a new QueryByCriteria.
       * @param classToSearchFrom
       * @param criteria
       * @param distinct
       * @return QueryByCriteria
       */
      public QueryByCriteria newQuery(Class classToSearchFrom, Criteria criteria, boolean
distinct)
      {
          return new QueryByCriteriaImpl(classToSearchFrom, criteria, distinct);
      }
  
      /**
       * create a new QueryByCriteria.
       * @param classToSearchFrom
       * @param criteria
       * @return QueryByCriteria
       */
      public QueryByCriteria newQuery(Class classToSearchFrom, Criteria criteria)
      {
          return newQuery(classToSearchFrom, criteria, false);
      }
  
      /**
       * Return a QueryByIdentity for object_or_identity.
       * @param object_or_identity
       * @return QueryByIdentity
       */
      public QueryByIdentity newQueryByIdentity(Object object_or_identity)
      {
          return new QueryByIdentityImpl(object_or_identity);
      }
  
      /**
       * Return a QueryByCriteria for example.
       * <br>Use with care because building of Query is not foolproof !!!
       * @param example
       * @return QueryByExample
       */
      public QueryByExample newQueryByExample(Object example)
      {
          return new QueryByExampleImpl(example);
      }
  
      /**
       * create a new QueryByMtoNCriteria.
       * @param classToSearchFrom
       * @param indirectionTable
       * @param criteria
       * @param distinct
       * @return QueryByMtoNCriteria
       */
      public QueryByMtoNCriteria newQuery(Class classToSearchFrom, String indirectionTable,
Criteria criteria, boolean distinct)
      {
          return new QueryByMtoNCriteria(classToSearchFrom, indirectionTable, criteria, distinct);
      }
  
      /**
       * create a new QueryByCriteria.
       * @param classToSearchFrom
       * @param indirectionTable
       * @param criteria
       * @return QueryByCriteria
       */
      public QueryByCriteria newQuery(Class classToSearchFrom, String indirectionTable, Criteria
criteria)
      {
          return new QueryByMtoNCriteria(classToSearchFrom, indirectionTable, criteria);
      }
  
      /**
       * Factory method for QueryBySQL.
       * @param classToSearchFrom
       * @param anSqlStatement
       * @return QueryBySQL
       */
      public QueryBySQL newQuery(Class classToSearchFrom, String anSqlStatement)
      {
          return new QueryBySQLImpl(classToSearchFrom, anSqlStatement);
      }
  
      /**
       * Return a copy of a QueryByCriteria.
       * @param QueryByCriteria
       * @return QueryByCriteria
       */
      public QueryByCriteria copyQuery(QueryByCriteria aQuery)
      {
          if (aQuery instanceof ReportQueryByMtoNCriteriaImpl)
          {
              return new ReportQueryByMtoNCriteriaImpl((ReportQueryByMtoNCriteriaImpl) aQuery);
          }
          
          if (aQuery instanceof ReportQuery)
          {
              return new ReportQueryByCriteriaImpl((ReportQueryByCriteriaImpl) aQuery);
          }
  
          if (aQuery instanceof QueryByExample)
          {
              return new QueryByExampleImpl((QueryByExampleImpl) aQuery);
          }
  
          if (aQuery instanceof QueryByMtoNCriteria)
          {
              return new QueryByMtoNCriteria((QueryByMtoNCriteria) aQuery);
          }
          
          return new QueryByCriteriaImpl((QueryByCriteriaImpl) aQuery); 
      }
  
  }
  
  
  

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