Return-Path: Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: (qmail 73903 invoked from network); 4 May 2005 16:43:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 May 2005 16:43:54 -0000 Received: (qmail 10997 invoked by uid 500); 4 May 2005 16:44:20 -0000 Mailing-List: contact jdo-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-dev@db.apache.org Received: (qmail 10657 invoked by uid 99); 4 May 2005 16:44:16 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from mail.spree.de (HELO miraculix.spree.de) (62.154.194.149) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 04 May 2005 09:44:15 -0700 Received: from [172.16.1.19] (rio.spree.de [172.16.1.19]) by miraculix.spree.de (8.11.6/8.11.6) with ESMTP id j44GfoS09208 for ; Wed, 4 May 2005 18:41:50 +0200 Message-ID: <4278FC03.8040403@spree.de> Date: Wed, 04 May 2005 18:44:51 +0200 From: Michael Watzek Organization: Tech@Spree GmbH User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: jdo-dev@db.apache.org Subject: Re: Dependencies between ri11 runtime and r11 query References: <42712862.1030601@spree.de> <6687bfc07de783a93b5e474b461f5907@Sun.COM> <427639D7.2090609@spree.de> In-Reply-To: Content-Type: multipart/mixed; boundary="------------090706050408000305050106" X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --------------090706050408000305050106 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi Craig, I filed a JIRA issue (http://issues.apache.org/jira/browse/JDO-36) on the query factory prososal below. That proposal solves issue 2) below. Attached you find an implementation for that issue which passes the ri11 testsuite. I attached four files containing the implementation: - rio.patch: This file contains the output of "svn diff" executed in directory "trunk/ri11". You can apply the patch using "patch -i rio.patch -p 0" in the same directory. - 3 .java files: These files declare new classes org.apache.jdo.jdoql.JDOQLQueryFactory, org.apache.jdo.impl.jdoql.JDOQLQueryFactoryImpl, and org.apache.jdo.impl.fostore.FOStorePM. You *must* copy these into your ri11 workspace. Otherwise, the project won't compile! The reason for the 3 .java files: I'm not familiar with "svn diff" and was not able to figure out how I can include new files into the patch. If anybody has a solution for this, please let me know. Regards, Michael > Hi Michael, > > On May 2, 2005, at 7:31 AM, Michael Watzek wrote: > >> Hi Craig, >> >> please find my comments inline: >> >>> Hi Michael, >>> Thanks for this analysis. >>> On Apr 28, 2005, at 11:16 AM, Michael Watzek wrote: >>> >>>> Hi, >>>> >>>> Micheal Bouschen raised the issue to get rid of the compile time >>>> dependencies between ri11 runtime and ri11 query. The benefit would be: >>>> >>>> 1) Runtime and query could be separated into 2 different projects. >>>> 2) ri11 runtime could be executed with another query implementation. >>>> 3) ri11 query could be executed with another runtime implementation. >>>> >>>> Below, I summerize what code changes have to be done to achieve >>>> issue 2). >>>> >>>> There are only 2 dependencies from runtime implementation to query >>>> implementation: >>>> >>>> - PersistenceManagerFactoryImpl calls Tree constructor >>>> - PersistenceManagerImpl calls QueryImpl constructors >>> >>> What if we move the method newQueryTree from PMFImpl to the >>> FOStorePMF class? >>> Similarly, we can move the nine newQueryXXX methods from PMImpl to >>> FOStorePM. >> >> The ri11 implementation does not declare a FOStore specific PM >> implementation. Following up your proposal, we would add a new class >> FOStorePM extending PMImpl. We would move all newQueryXXX methods to >> that class and make PMImpl abstract (removing all all newQueryXXX >> methods). > > > Right. When I wrote this, I had forgotten that there was no FOStorePM! > But you have accurately reflected the idea. > >> >> We could still keep the QueryFactory approach and move the interface >> from Runtime to Query. As an advantage, FOStore would not call >> constructors of the query implementation. Instead, it would create a >> query factory (using "Class.newInstance") and call the newQueryXXX >> methods. Thus, FOStore would not have compile time dependencies to the >> query implementation but only to the factory interface. Does this make >> sense? > > > Yes. Go for it. > >> >>> If we break this dependency, we could keep the dependency from Query >>> to Runtime. And not implement part 3 as outlined below. I think part >>> 3 is a lot of work and still doesn't remove the dependencies. >>> (The proposal below still requires the Query to know about >>> StateManagerInternal, FieldManager, and StoreManager which I guess >>> are still defined in Runtime.) >> >> Actually, it is not so much work. I already know all locations in the >> query implementation which have to be changed. The change is mostly to >> replace the PM instance by a RuntimeContext instance. >> >> However, we'd still have dependencies to FieldManager and >> StoreManager. We would not have dependencies to StateManager. The >> query implementation needs a StateManager instance to invoke >> "provideField". The two calls "PM.findStateManager" and >> "SM.provideField" can both be implemented in >> "RuntimeContext.provideField". For this reason, RuntimeContext would >> not declare method "findStateManager" (in contrast to my original >> proposal) and thus, would not depend on StateManager. >> >> Changes 2) and 3) will aproximately take a day. Please let me know >> which direction to go. > > > I expect the changes for 3) will be more difficult and take more time > for review to make sure we get it right. So I'd like to defer this > exercise for now. > >>> So the new proposal is to break out ri11 into >>> core20 (model plus utility): no dependencies >> >> Ok. >> >>> enhancer20: depends on core >> >> Ok. >> >>> runtime20: depends on core >> >> Ok. >> >>> query20: depends on runtime and core >> >> Ok. >> >>> fostore20: depends on core, runtime, and query >> >> Ok. > > > So the end result will be the five projects buildable and testable > against the api11 project library. We will then have a task to migrate > these projects to depend on api20 instead. > > Thanks, > > Craig > >> >> Thanks, >> Michael >> >>> Craig >>> >>>> >>>> The proposal is to introduce a new runtime interface QueryFactory >>>> which defines methods creating QueryTree instances and Query >>>> instances, e.g. >>>> >>>> public interface QueryFactory >>>> { >>>> QueryTree createTree(); >>>> Query createQuery(...); >>>> } >>>> >>>> This interface is implemented by query implementations. The ri11 >>>> query implementation calls the Tree and QueryImpl constructors. >>>> >>>> Additionally, ri11 runtime defines a new PMFInternal property >>>> containing the class name of the QueryFactory implementation. The >>>> property may be specified by a Properties instance which is passed >>>> to JDOHelper.getPersistenceManagerFactory, or it may be set calling >>>> a setter on the PMFInternal instance. The PMFInternal instance looks >>>> up the implementation class and calls newInstance() in order to >>>> create a QueryFactory instance. The class object is kept in an >>>> instance variable. The Tree and QueryImpl constructor calls in >>>> PersistenceManagerFactoryImpl and PersistenceManagerImpl are >>>> replaced by corresponding calls on the QueryFactory instance. >>>> >>>> Constraints on the QueryFactory implementation class: It must >>>> implement a public no argument constructor. >>>> >>>> >>>> Below, I summerize what code changes have to be done to achieve >>>> issue 3). >>>> >>>> The ri11 query implementation does not have references into runtime >>>> implementation packages, such as "org.apache.jdo.impl.pm" or >>>> "org.apache.jdo.impl.state". However, it has some references into >>>> runtime specific interfaces like PersistenceManagerInternal (PMI) >>>> and StateManagerInternal (SMI): >>>> >>>> - PMI.findStateManager(...) >>>> - PMI.loadClass(...) >>>> - PMI.assertIsOpen() >>>> - PMI.getStoreManager() >>>> - PMI.getCurrentWrapper() >>>> - SMI.provideField(...) >>>> >>>> Additionally, there is a dependency to the FieldManager interface: >>>> As query implementation calls method SMI.provideField(...) having a >>>> field manager parameter, it provides an implementation for that >>>> interface and passes an instance of that implementation. >>>> >>>> The proposal is to define a new query interface RuntimeContext >>>> defining all of the methods above, e.g. >>>> >>>> interface RuntimeContext >>>> { >>>> StateManager findStateManager(PersistenceCapable pc); >>>> Class loadClass(String name, ClassLoader given) throws >>>> ClassNotFoundException; >>>> void assertIsOpen(); >>>> StoreManager getStoreManager(); >>>> PersistenceManager getCurrentWrapper(); >>>> void provideField(int fieldNumber, FieldManager fieldManager, >>>> boolean identifying); >>>> } >>>> >>>> This interface is implemented by runtime implementations. A query >>>> instance has an instance of this interface which it gets through a >>>> parameter of query factory method "createQuery", e.g. >>>> >>>> QueryFactory.createQuery(..., RuntimeContext context); >>>> >>>> All calls of the methods above are replaced by corresponding method >>>> calls on RuntimeContext instance. >>>> >>>> Drawbacks of this proposal: It does not eliminate the dependency to >>>> the FieldManager interface. >>>> >>>> Advantages of this proposal: It gathers all runtime calls in an >>>> single instance implementing a small API, rather than having calls >>>> on 2 different instances each of which implements a big API (PMI >>>> defines 23 methods, SMI defines 33 meethods). >>>> >>>> Regards, >>>> Michael >>>> -- >>>> ------------------------------------------------------------------- >>>> Michael Watzek Tech@Spree Engineering GmbH >>>> mailto:mwa.tech@spree.de Buelowstr. 66 >>>> Tel.: ++49/30/235 520 36 10783 Berlin - Germany >>>> Fax.: ++49/30/217 520 12 http://www.spree.de/ >>>> ------------------------------------------------------------------- >>>> >>> Craig Russell >>> Architect, Sun Java Enterprise System http://java.sun.com/products/jdo >>> 408 276-5638 mailto:Craig.Russell@sun.com >>> P.S. A good JDO? O, Gasp! >> >> >> >> -- >> ------------------------------------------------------------------- >> Michael Watzek Tech@Spree Engineering GmbH >> mailto:mwa.tech@spree.de Buelowstr. 66 >> Tel.: ++49/30/235 520 36 10783 Berlin - Germany >> Fax.: ++49/30/217 520 12 http://www.spree.de/ >> ------------------------------------------------------------------- >> > Craig Russell > Architect, Sun Java Enterprise System http://java.sun.com/products/jdo > 408 276-5638 mailto:Craig.Russell@sun.com > P.S. A good JDO? O, Gasp! -- ------------------------------------------------------------------- Michael Watzek Tech@Spree Engineering GmbH mailto:mwa.tech@spree.de Buelowstr. 66 Tel.: ++49/30/235 520 36 10783 Berlin - Germany Fax.: ++49/30/217 520 12 http://www.spree.de/ ------------------------------------------------------------------- --------------090706050408000305050106 Content-Type: text/plain; name="rio.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="rio.patch" Index: test/java/org/apache/jdo/test/query/PositiveTest.java =================================================================== --- test/java/org/apache/jdo/test/query/PositiveTest.java (revision 168102) +++ test/java/org/apache/jdo/test/query/PositiveTest.java (working copy) @@ -22,13 +22,22 @@ package org.apache.jdo.test.query; -import java.util.*; import java.io.PrintStream; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Vector; -import javax.jdo.*; +import javax.jdo.Extent; +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; +import javax.jdo.Query; +import javax.jdo.Transaction; +import org.apache.jdo.impl.fostore.FOStorePMF; import org.apache.jdo.impl.jdoql.tree.Tree; import org.apache.jdo.impl.pm.PersistenceManagerFactoryImpl; import org.apache.jdo.jdoql.tree.QueryTree; @@ -327,7 +336,7 @@ protected QueryTree newQueryTree() { if (pmf instanceof PersistenceManagerFactoryImpl) - return ((PersistenceManagerFactoryImpl)pmf).newQueryTree(); + return ((FOStorePMF)pmf).newQueryTree(); else return new Tree(); } Index: test/java/org/apache/jdo/test/query/NegativeTest.java =================================================================== --- test/java/org/apache/jdo/test/query/NegativeTest.java (revision 168102) +++ test/java/org/apache/jdo/test/query/NegativeTest.java (working copy) @@ -22,16 +22,18 @@ package org.apache.jdo.test.query; -import java.util.Collection; -import java.util.ArrayList; -import java.util.Vector; -import java.util.Iterator; import java.io.PrintStream; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.lang.reflect.InvocationTargetException; +import java.util.Iterator; +import java.util.Vector; -import javax.jdo.*; +import javax.jdo.JDOException; +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; +import javax.jdo.Transaction; +import org.apache.jdo.impl.fostore.FOStorePMF; import org.apache.jdo.impl.jdoql.tree.Tree; import org.apache.jdo.impl.pm.PersistenceManagerFactoryImpl; import org.apache.jdo.jdoql.tree.QueryTree; @@ -73,7 +75,7 @@ protected QueryTree newQueryTree() { if (pmf instanceof PersistenceManagerFactoryImpl) - return ((PersistenceManagerFactoryImpl)pmf).newQueryTree(); + return ((FOStorePMF)pmf).newQueryTree(); else return new Tree(); } Index: src/java/org/apache/jdo/impl/fostore/FOStorePMF.java =================================================================== --- src/java/org/apache/jdo/impl/fostore/FOStorePMF.java (revision 168102) +++ src/java/org/apache/jdo/impl/fostore/FOStorePMF.java (working copy) @@ -16,40 +16,30 @@ package org.apache.jdo.impl.fostore; -import java.io.ByteArrayOutputStream; -import java.io.PrintWriter; import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectOutputStream; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.Enumeration; import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; import java.util.Properties; -import java.util.Set; import java.util.WeakHashMap; -import java.security.AccessController; -import java.security.PrivilegedAction; +import javax.jdo.JDOException; +import javax.jdo.JDOFatalException; +import javax.jdo.PersistenceManager; +import javax.jdo.spi.PersistenceCapable; import javax.naming.NamingException; import javax.naming.Reference; import javax.naming.Referenceable; import javax.naming.StringRefAddr; -import javax.jdo.JDOException; -import javax.jdo.JDOFatalException; -import javax.jdo.PersistenceManager; -import javax.jdo.spi.PersistenceCapable; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.apache.jdo.impl.model.java.runtime.RuntimeJavaModelFactory; import org.apache.jdo.impl.pm.PersistenceManagerFactoryImpl; -import org.apache.jdo.impl.pm.PersistenceManagerImpl; +import org.apache.jdo.jdoql.JDOQLQueryFactory; +import org.apache.jdo.jdoql.tree.QueryTree; import org.apache.jdo.model.jdo.JDOClass; -import org.apache.jdo.pm.PersistenceManagerFactoryInternal; -import org.apache.jdo.pm.PersistenceManagerInternal; import org.apache.jdo.store.StoreManager; import org.apache.jdo.store.TranscriberFactory; import org.apache.jdo.util.I18NHelper; @@ -102,6 +92,11 @@ */ private Properties configuredFrom = null; + /** + * The query factory for JDOQL. + */ + private JDOQLQueryFactory jdoqlQueryFactory; + /** RuntimeJavaModelFactory. */ private static final RuntimeJavaModelFactory javaModelFactory = (RuntimeJavaModelFactory) AccessController.doPrivileged( @@ -201,7 +196,38 @@ }); } } + + JDOQLQueryFactory getJDOQLQueryFactory() { + if (this.jdoqlQueryFactory==null) { + try { + Class clazz = Class.forName("org.apache.jdo.impl.jdoql.JDOQLQueryFactoryImpl"); + this.jdoqlQueryFactory = (JDOQLQueryFactory) clazz.newInstance(); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return this.jdoqlQueryFactory; + } + /** Returns a new QueryTree instance. This instance allows to specify a + * query with an API (see {@link org.apache.jdo.jdoql.tree.QueryTree} and + * {@link org.apache.jdo.jdoql.tree.ExpressionFactory}) rather than as JDOQL + * strings. To run you create a query object from the QueryTree (see + * {@link javax.jdo.PersistenceManager#newQuery(Object compiled)}) + * and call the execute method on the Query object. + * @return new QueryTree instance. + */ + public QueryTree newQueryTree() { + return getJDOQLQueryFactory().newTree(); + } + /** Return the FOStore-specific accessors (the * properties that are not in the JDO specification). * @return the hash map of FOStore accessors @@ -332,7 +358,7 @@ PersistenceManager rc = null; try { - rc = new PersistenceManagerImpl(this, userid, password); + rc = new FOStorePM(this, userid, password); setConfigured(); } catch (JDOException ex) { throw ex; Index: src/java/org/apache/jdo/impl/pm/PersistenceManagerImpl.java =================================================================== --- src/java/org/apache/jdo/impl/pm/PersistenceManagerImpl.java (revision 168102) +++ src/java/org/apache/jdo/impl/pm/PersistenceManagerImpl.java (working copy) @@ -22,20 +22,28 @@ package org.apache.jdo.impl.pm; -import java.util.*; +import java.lang.reflect.Constructor; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.Collection; +import java.util.Comparator; +import java.util.Iterator; +import java.util.Map; +import java.util.Properties; -import java.lang.reflect.Constructor; +import javax.jdo.Extent; +import javax.jdo.JDOFatalInternalException; +import javax.jdo.JDOFatalUserException; +import javax.jdo.JDOUserException; +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; +import javax.jdo.Query; +import javax.jdo.Transaction; +import javax.jdo.spi.PersistenceCapable; import javax.transaction.Status; -import javax.jdo.*; -import javax.jdo.spi.*; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - -import org.apache.jdo.impl.jdoql.QueryImpl; import org.apache.jdo.impl.model.java.runtime.RuntimeJavaModelFactory; import org.apache.jdo.model.java.JavaModel; import org.apache.jdo.model.java.JavaType; @@ -56,7 +64,7 @@ * * @author Marina Vatkina */ -public class PersistenceManagerImpl implements PersistenceManagerInternal { +public abstract class PersistenceManagerImpl implements PersistenceManagerInternal { private final boolean DEBUG = true; /** @@ -206,7 +214,7 @@ /** * I18N message handler */ - private final static I18NHelper msg = + protected final static I18NHelper msg = I18NHelper.getInstance(PersistenceManagerImpl.class); /** @@ -534,101 +542,71 @@ // /** Create a new Query with no elements. - * @return a new Query instance with no elements. - */ - public Query newQuery() { - assertIsOpen(); - return new QueryImpl(this); - } + * @return a new Query instance with no elements. + */ + public abstract Query newQuery(); - /** Create a new Query using elements from another Query. The other Query - * must have been created by the same JDO implementation. It might be active - * in a different PersistenceManager or might have been serialized and - * restored. - * @return the new Query - * @param compiled another Query from the same JDO implementation - */ - public Query newQuery (Object compiled) { - assertIsOpen(); - return new QueryImpl(this, compiled); - } + /** Create a new Query using elements from another Query. The other Query + * must have been created by the same JDO implementation. It might be active + * in a different PersistenceManager or might have been serialized and + * restored. + * @return the new Query + * @param compiled another Query from the same JDO implementation + */ + public abstract Query newQuery (Object compiled); - /** Create a new Query using the specified language. - * @param language the language of the query parameter - * @param query the query, which is of a form determined by the language + /** Create a new Query using the specified language. + * @param language the language of the query parameter + * @param query the query, which is of a form determined by the language + * @return the new Query + */ + public abstract Query newQuery (String language, Object query); + + /** Create a new Query specifying the Class of the results. + * @param cls the Class of the results * @return the new Query - */ - public Query newQuery (String language, Object query) { - assertIsOpen(); - if ("javax.jdo.query.JDOQL".equals(language)) //NOI18N - return new QueryImpl(this, query); - throw new JDOUserException(msg.msg( - "EXC_UnsupportedQueryLanguage", language)); // NOI18N - } - - /** Create a new Query specifying the Class of the results. - * @param cls the Class of the results - * @return the new Query - */ - public Query newQuery (Class cls) { - assertIsOpen(); - return new QueryImpl(this, cls); - } + */ + public abstract Query newQuery (Class cls); - /** Create a new Query with the candidate Extent; the class is taken - * from the Extent. + /** Create a new Query with the candidate Extent; the class is taken + * from the Extent. + * specified. + * @return the new Query + * @param cln the Extent of candidate instances */ + public abstract Query newQuery(Extent cln); + + /** Create a new Query with the Class of the results and candidate Collection. * specified. + * @param cls the Class of results + * @param cln the Collection of candidate instances * @return the new Query - * @param cln the Extent of candidate instances */ - public Query newQuery(Extent cln) { - assertIsOpen(); - return new QueryImpl(this, cln); - } + */ + public abstract Query newQuery (Class cls, Collection cln); - /** Create a new Query with the Class of the results and candidate Collection. - * specified. - * @param cls the Class of results - * @param cln the Collection of candidate instances - * @return the new Query - */ - public Query newQuery (Class cls, Collection cln) { - assertIsOpen(); - return new QueryImpl(this, cls, cln); - } + /** Create a new Query with the Class of the results and Filter. + * specified. + * @param cls the Class of results + * @param filter the Filter for candidate instances + * @return the new Query + */ + public abstract Query newQuery (Class cls, String filter); - /** Create a new Query with the Class of the results and Filter. - * specified. - * @param cls the Class of results - * @param filter the Filter for candidate instances - * @return the new Query - */ - public Query newQuery (Class cls, String filter) { - assertIsOpen(); - return new QueryImpl(this, cls, filter); - } - - /** Create a new Query with the Class of the results, candidate Collection, - * and Filter. - * @param cls the Class of results - * @param cln the Collection of candidate instances - * @param filter the Filter for candidate instances - * @return the new Query - */ - public Query newQuery (Class cls, Collection cln, String filter) { - assertIsOpen(); - return new QueryImpl(this, cls, cln, filter); - } - - /** Create a new Query with the candidate Extent and Filter. - * The class is taken from the Extent. + /** Create a new Query with the Class of the results, candidate Collection, + * and Filter. + * @param cls the Class of results + * @param cln the Collection of candidate instances + * @param filter the Filter for candidate instances * @return the new Query - * @param cln the Extent of candidate instances - * @param filter the Filter for candidate instances */ - public Query newQuery(Extent cln, String filter) { - assertIsOpen(); - return new QueryImpl(this, cln, filter); - } + */ + public abstract Query newQuery (Class cls, Collection cln, String filter); + /** Create a new Query with the candidate Extent and Filter. + * The class is taken from the Extent. + * @return the new Query + * @param cln the Extent of candidate instances + * @param filter the Filter for candidate instances */ + public abstract Query newQuery(Extent cln, String filter); + /** The PersistenceManager may manage a collection of instances in the data * store based on the class of the instances. This method returns an * Extent of instances in the data store that might be iterated or Index: src/java/org/apache/jdo/impl/pm/PersistenceManagerFactoryImpl.java =================================================================== --- src/java/org/apache/jdo/impl/pm/PersistenceManagerFactoryImpl.java (revision 168102) +++ src/java/org/apache/jdo/impl/pm/PersistenceManagerFactoryImpl.java (working copy) @@ -22,21 +22,34 @@ package org.apache.jdo.impl.pm; -import java.util.*; +import java.io.IOException; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; -import javax.jdo.*; +import javax.jdo.JDOException; +import javax.jdo.JDOFatalInternalException; +import javax.jdo.JDOFatalUserException; +import javax.jdo.JDOUserException; +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; import javax.jdo.spi.JDOPermission; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.apache.jdo.ejb.EJBImplHelper; -import org.apache.jdo.impl.jdoql.tree.Tree; import org.apache.jdo.impl.model.java.runtime.RuntimeJavaModelFactory; -import org.apache.jdo.jdoql.tree.QueryTree; -import org.apache.jdo.model.jdo.JDOClass; import org.apache.jdo.pm.Accessor; import org.apache.jdo.pm.PersistenceManagerFactoryInternal; import org.apache.jdo.util.I18NHelper; @@ -1523,19 +1536,6 @@ return; } - /** Returns a new QueryTree instance. This instance allows to specify a - * query with an API (see {@link org.apache.jdo.jdoql.tree.QueryTree} and - * {@link org.apache.jdo.jdoql.tree.ExpressionFactory}) rather than as JDOQL - * strings. To run you create a query object from the QueryTree (see - * {@link javax.jdo.PersistenceManager#newQuery(Object compiled)}) - * and call the execute method on the Query object. - * @return new QueryTree instance. - */ - public QueryTree newQueryTree() - { - return new Tree(); - } - public synchronized boolean equals(Object o) { if (o == this) return true; --------------090706050408000305050106 Content-Type: text/x-java; name="JDOQLQueryFactory.java" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="JDOQLQueryFactory.java" /* * Copyright 2005 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. */ package org.apache.jdo.jdoql; import java.util.Collection; import javax.jdo.Extent; import javax.jdo.Query; import org.apache.jdo.pm.PersistenceManagerInternal; import org.apache.jdo.jdoql.tree.QueryTree; /** * This interface allows for choosing between different * JDO query implementations. * Query implementations implementing this interface * are capable to run together with other components. * The interface declares methods creating JDO query instances * and JDO query tree instances. * All methods creating query instances take persistence manager * instances as parameters. * * @author Michael Watzek */ public interface JDOQLQueryFactory { /** * Returns a new QueryTree instance. This instance allows to specify a * query with an API (see {@link org.apache.jdo.jdoql.tree.QueryTree} and * {@link org.apache.jdo.jdoql.tree.ExpressionFactory}) rather than as JDOQL * strings. To run you create a query object from the QueryTree (see * {@link javax.jdo.PersistenceManager#newQuery(Object compiled)}) * and call the execute method on the Query object. * @return new QueryTree instance. */ QueryTree newTree(); /** * Creates a new Query with no elements. * @param pm the persistence manager for the new query. * It is the responsibility of the caller to check that the persistence manager is valid. * @return the new Query. */ Query newQuery(PersistenceManagerInternal pm); /** * Creates a new Query using elements from another Query. * The other Query must have been created by the same JDO implementation. * It might be active * in a different PersistenceManager or might have been serialized and restored. *

All of the settings of the other Query are copied to this Query, * except for the candidate Collection or Extent. * @return the new Query. * @param pm the persistence manager for the new query. * It is the responsibility of the caller to check that the persistence manager is valid. * @param compiled another Query from the same JDO implementation. */ Query newQuery(PersistenceManagerInternal pm, Object compiled); /** * Creates a new Query specifying the Class of the candidate instances. * @param pm the persistence manager for the new query. * It is the responsibility of the caller to check that the persistence manager is valid. * @param cls the Class of the candidate instances. * @return the new Query. */ Query newQuery(PersistenceManagerInternal pm, Class cls); /** * Creates a new Query with the Class of the * candidate instances and candidate Extent. * @param pm the persistence manager for the new query. * It is the responsibility of the caller to check that the persistence manager is valid. * @param cln the Extent of candidate instances. * @return the new Query. */ Query newQuery(PersistenceManagerInternal pm, Extent cln); /** * Creates a new Query with the candidate Class * and Collection. * @param pm the persistence manager for the new query. * It is the responsibility of the caller to check that the persistence manager is valid. * @param cls the Class of results. * @param cln the Collection of candidate instances. * @return the new Query. */ Query newQuery(PersistenceManagerInternal pm, Class cls, Collection cln); /** * Creates a new Query with the Class of the * candidate instances and filter. * @param pm the persistence manager for the new query. * It is the responsibility of the caller to check that the persistence manager is valid. * @param cls the Class of results. * @param filter the filter for candidate instances. * @return the new Query. */ Query newQuery(PersistenceManagerInternal pm, Class cls, String filter); /** * Creates a new Query with the Class of the candidate instances, * candidate Collection, and filter. * @param pm the persistence manager for the new query. * It is the responsibility of the caller to check that the persistence manager is valid. * @param cls the Class of candidate instances. * @param cln the Collection of candidate instances. * @param filter the filter for candidate instances. * @return the new Query. */ Query newQuery(PersistenceManagerInternal pm, Class cls, Collection cln, String filter); /** * Creates a new Query with the * candidate Extent and filter; the class * is taken from the Extent. * @param pm the persistence manager for the new query. * It is the responsibility of the caller to check that the persistence manager is valid. * @param cln the Extent of candidate instances. * @param filter the filter for candidate instances. * @return the new Query. */ Query newQuery(PersistenceManagerInternal pm, Extent cln, String filter); } --------------090706050408000305050106 Content-Type: text/x-java; name="JDOQLQueryFactoryImpl.java" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="JDOQLQueryFactoryImpl.java" /* * Copyright 2005 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. */ package org.apache.jdo.impl.jdoql; import java.util.Collection; import javax.jdo.Extent; import javax.jdo.Query; import org.apache.jdo.impl.jdoql.tree.Tree; import org.apache.jdo.jdoql.JDOQLQueryFactory; import org.apache.jdo.jdoql.tree.QueryTree; import org.apache.jdo.pm.PersistenceManagerInternal; /** * Implements the @link{QueryFactory} interface * in order to implement a component which is capable * to run together with JDO runtime. * * @author Michael Watzek */ public class JDOQLQueryFactoryImpl implements JDOQLQueryFactory { /** * Returns a new QueryTree instance. This instance allows to specify a * query with an API (see {@link org.apache.jdo.jdoql.tree.QueryTree} and * {@link org.apache.jdo.jdoql.tree.ExpressionFactory}) rather than as JDOQL * strings. To run you create a query object from the QueryTree (see * {@link javax.jdo.PersistenceManager#newQuery(Object compiled)}) * and call the execute method on the Query object. * @return new QueryTree instance. */ public QueryTree newTree() { return new Tree(); } /* * @see org.apache.jdo.jdoql.QueryFactory#newQuery(org.apache.jdo.pm.PersistenceManagerInternal) */ public Query newQuery(PersistenceManagerInternal pm) { return new QueryImpl( pm ); } /* * @see org.apache.jdo.jdoql.QueryFactory#newQuery(org.apache.jdo.pm.PersistenceManagerInternal, java.lang.Object) */ public Query newQuery(PersistenceManagerInternal pm, Object compiled) { return new QueryImpl( pm, compiled ); } /* * @see org.apache.jdo.jdoql.QueryFactory#newQuery(org.apache.jdo.pm.PersistenceManagerInternal, java.lang.Class) */ public Query newQuery(PersistenceManagerInternal pm, Class cls) { return new QueryImpl( pm, cls ); } /* * @see org.apache.jdo.jdoql.QueryFactory#newQuery(org.apache.jdo.pm.PersistenceManagerInternal, javax.jdo.Extent) */ public Query newQuery(PersistenceManagerInternal pm, Extent cln) { return new QueryImpl( pm, cln ); } /* * @see org.apache.jdo.jdoql.QueryFactory#newQuery(org.apache.jdo.pm.PersistenceManagerInternal, java.lang.Class, java.util.Collection) */ public Query newQuery(PersistenceManagerInternal pm, Class cls, Collection cln) { return new QueryImpl( pm, cls, cln ); } /* * @see org.apache.jdo.jdoql.QueryFactory#newQuery(org.apache.jdo.pm.PersistenceManagerInternal, java.lang.Class, java.lang.String) */ public Query newQuery(PersistenceManagerInternal pm, Class cls, String filter) { return new QueryImpl( pm, cls, filter ); } /* * @see org.apache.jdo.jdoql.QueryFactory#newQuery(org.apache.jdo.pm.PersistenceManagerInternal, java.lang.Class, java.util.Collection, java.lang.String) */ public Query newQuery(PersistenceManagerInternal pm, Class cls, Collection cln, String filter) { return new QueryImpl( pm, cls, cln, filter ); } /* * @see org.apache.jdo.jdoql.QueryFactory#newQuery(org.apache.jdo.pm.PersistenceManagerInternal, javax.jdo.Extent, java.lang.String) */ public Query newQuery(PersistenceManagerInternal pm, Extent cln, String filter) { return new QueryImpl( pm, cln, filter ); } } --------------090706050408000305050106 Content-Type: text/x-java; name="FOStorePM.java" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="FOStorePM.java" /* * Copyright 2005 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. */ package org.apache.jdo.impl.fostore; import java.util.Collection; import javax.jdo.Extent; import javax.jdo.JDOUserException; import javax.jdo.Query; import org.apache.jdo.impl.pm.PersistenceManagerImpl; /** * Subclass of @link{PersistenceManagerImpl} implementing * abstract methods newQuery. * * @author Michael Watzek */ public class FOStorePM extends PersistenceManagerImpl { /** Hides field PersistenceManagerImpl.pmf to avoid casts to @link{FOStorePMF} */ private FOStorePMF pmf; /** * Constructs new instance of PersistenceManagerImpl for this * PersistenceManagerFactoryInternal and particular combination of * username and password. * * @param pmf calling PersistenceManagerFactory as PersistenceManagerFactoryInternal * @param username user name used for accessing Connector or null if none * is provided. * @param password user password used for accessing Connector or null if * none is provided. */ FOStorePM(FOStorePMF pmf, String username, String password) { super(pmf, username, password); this.pmf = pmf; } /** Create a new Query with no elements. * @return a new Query instance with no elements. */ public Query newQuery() { assertIsOpen(); return this.pmf.getJDOQLQueryFactory().newQuery(this); } /** Create a new Query using elements from another Query. The other Query * must have been created by the same JDO implementation. It might be active * in a different PersistenceManager or might have been serialized and * restored. * @return the new Query * @param compiled another Query from the same JDO implementation */ public Query newQuery (Object compiled) { assertIsOpen(); return this.pmf.getJDOQLQueryFactory().newQuery(this, compiled); } /** Create a new Query using the specified language. * @param language the language of the query parameter * @param query the query, which is of a form determined by the language * @return the new Query */ public Query newQuery (String language, Object query) { assertIsOpen(); if ("javax.jdo.query.JDOQL".equals(language)) //NOI18N return this.pmf.getJDOQLQueryFactory().newQuery(this, query); throw new JDOUserException(msg.msg( "EXC_UnsupportedQueryLanguage", language)); // NOI18N } /** Create a new Query specifying the Class of the results. * @param cls the Class of the results * @return the new Query */ public Query newQuery (Class cls) { assertIsOpen(); return this.pmf.getJDOQLQueryFactory().newQuery(this, cls); } /** Create a new Query with the candidate Extent; the class is taken * from the Extent. * specified. * @return the new Query * @param cln the Extent of candidate instances */ public Query newQuery(Extent cln) { assertIsOpen(); return this.pmf.getJDOQLQueryFactory().newQuery(this, cln); } /** Create a new Query with the Class of the results and candidate Collection. * specified. * @param cls the Class of results * @param cln the Collection of candidate instances * @return the new Query */ public Query newQuery (Class cls, Collection cln) { assertIsOpen(); return this.pmf.getJDOQLQueryFactory().newQuery(this, cls, cln); } /** Create a new Query with the Class of the results and Filter. * specified. * @param cls the Class of results * @param filter the Filter for candidate instances * @return the new Query */ public Query newQuery (Class cls, String filter) { assertIsOpen(); return this.pmf.getJDOQLQueryFactory().newQuery(this, cls, filter); } /** Create a new Query with the Class of the results, candidate Collection, * and Filter. * @param cls the Class of results * @param cln the Collection of candidate instances * @param filter the Filter for candidate instances * @return the new Query */ public Query newQuery (Class cls, Collection cln, String filter) { assertIsOpen(); return this.pmf.getJDOQLQueryFactory().newQuery(this, cls, cln, filter); } /** Create a new Query with the candidate Extent and Filter. * The class is taken from the Extent. * @return the new Query * @param cln the Extent of candidate instances * @param filter the Filter for candidate instances */ public Query newQuery(Extent cln, String filter) { assertIsOpen(); return this.pmf.getJDOQLQueryFactory().newQuery(this, cln, filter); } } --------------090706050408000305050106--