You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by to...@apache.org on 2004/11/14 10:33:38 UTC
cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer ConnectionManagerIF.java JdbcAccessImpl.java RowReaderDefaultImpl.java StatementManager.java BasePrefetcher.java RowReader.java ConnectionManagerImpl.java RsIterator.java
tomdz 2004/11/14 01:33:38
Modified: src/java/org/apache/ojb/broker OJB.java
PersistenceBroker.java
PersistenceBrokerFactory.java
PersistenceBrokerInternal.java
PersistenceConfiguration.java
src/java/org/apache/ojb/broker/accesslayer
ConnectionManagerIF.java JdbcAccessImpl.java
RowReaderDefaultImpl.java StatementManager.java
BasePrefetcher.java RowReader.java
ConnectionManagerImpl.java RsIterator.java
Added: src/java/org/apache/ojb/broker ContainerHelper.java
Log:
Reworked the OJB core:
- replaced the factories/configuration concept with the ComponentContainer
- removal of most static calls within OJB
- removed the old "D" collection implementations and renamed the new ones
- moved StatementForClassIF handling to the PersistenceConfiguration
- moved RowReader caching from the ClassDescriptor to the PersistenceConfiguration
and other changes (see mail on the dev list for more details)
Revision Changes Path
1.4 +206 -54 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- OJB.java 26 Oct 2004 15:27:39 -0000 1.3
+++ OJB.java 14 Nov 2004 09:33:37 -0000 1.4
@@ -1,21 +1,5 @@
package org.apache.ojb.broker;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.apache.ojb.broker.cache.CacheManager;
-import org.apache.ojb.broker.core.Factories;
-import org.apache.ojb.broker.core.factory.ObjectFactory;
-import org.apache.ojb.broker.metadata.MetadataManager;
-import org.apache.ojb.broker.metadata.ObjectCacheDescriptor;
-import org.apache.ojb.broker.metadata.PersistenceConfigurationDescriptor;
-import org.apache.ojb.broker.util.BrokerHelper;
-import org.apache.ojb.broker.util.ObjectModification;
-import org.apache.ojb.broker.util.logging.Logger;
-import org.apache.ojb.broker.util.logging.LoggerFactory;
-import org.apache.ojb.broker.core.factory.ObjectFactoryDefaultImpl;
-
/* Copyright 2002-2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -31,6 +15,29 @@
* limitations under the License.
*/
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.ojb.broker.cache.CacheManager;
+import org.apache.ojb.broker.core.configuration.ComponentContainer;
+import org.apache.ojb.broker.core.configuration.PicoComponentContainer;
+import org.apache.ojb.broker.core.proxy.CollectionProxy;
+import org.apache.ojb.broker.core.proxy.IndirectionHandler;
+import org.apache.ojb.broker.core.proxy.ListProxy;
+import org.apache.ojb.broker.core.proxy.ProxyFactory;
+import org.apache.ojb.broker.core.proxy.SetProxy;
+import org.apache.ojb.broker.metadata.MetadataManager;
+import org.apache.ojb.broker.metadata.ObjectCacheDescriptor;
+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.util.BrokerHelper;
+import org.apache.ojb.broker.util.ObjectModification;
+import org.apache.ojb.broker.util.logging.Logger;
+import org.apache.ojb.broker.util.logging.LoggerFactory;
+
/**
* The OJB main/start class. All OJB services depend on this class. So a instance of this
* class represents "one OJB application".
@@ -40,79 +47,198 @@
*/
public class OJB
{
+ /** Default filename of the OJB properties file */
+ public static final String DEFAULT_PROPERTIES_FILE = "OJB.properties";
+
private Logger log = LoggerFactory.getLogger(OJB.class);
public static final ObjectModification INSERT = ObjectModificationImpl.INSERT;
public static final ObjectModification UPDATE = ObjectModificationImpl.UPDATE;
- private Factories factories;
+ /** The container */
+ private ComponentContainer container;
+ /** Whether this runtime is fully initialized */
+ private boolean isInitialized = false;
private MetadataManager metadataManager;
- private HashMap configurationMap;
+ private ProxyFactory proxyFactory;
+ private HashMap configurationMap = new HashMap();
private Object dummy = new Object();
- public OJB()
- {
- initialize(new ObjectFactoryDefaultImpl());
- }
-
- public OJB(ObjectFactory objectFactory)
- {
- initialize(objectFactory);
- }
-
- private void initialize(ObjectFactory objectFactory)
- {
- configurationMap = new HashMap();
- factories = new Factories();
- factories.setObjectFactory(objectFactory);
- metadataManager = new MetadataManager(factories);
- }
+ /**
+ * Creates a new OJB runtime.
+ */
+ public OJB()
+ {
+ container = new PicoComponentContainer();
+ initStaticSystem(true);
+ }
+
+ /**
+ * Creates a new OJB runtime that uses the given container, or more
+ * precisely a child container of it.
+ *
+ * @param container The container
+ * @param loadConf Whether to load the configuration properties from
+ * the OJB.properties file
+ */
+ public OJB(ComponentContainer container, boolean loadConf)
+ {
+ this.container = container.createChildContainer();
+ initStaticSystem(loadConf);
+ }
+
+ /**
+ * Initializes the static part of the runtime system, e.g. sets default mappings
+ * and loads the properties from an external file (if requested).
+ *
+ * @param loadConf Whether to load the configuration from an external file
+ */
+ private void initStaticSystem(boolean loadConf)
+ {
+ ContainerHelper helper = new ContainerHelper();
+
+ helper.initWithDefaults(container);
+ if (loadConf)
+ {
+ helper.loadProperties(container, System.getProperty(DEFAULT_PROPERTIES_FILE, DEFAULT_PROPERTIES_FILE), false);
+ }
+ // setting singleton instances
+ container.setSingletonInstance(getClass(), this);
+ }
+
+ /**
+ * Initializes the dynamic part of the runtime system. This is separated from the
+ * static part to allow for setting properties at this runtime instance before
+ * any OJB functionality is used.
+ */
+ private void initDynamicSystem()
+ {
+ if (isInitialized)
+ {
+ return;
+ }
+
+ PersistentFieldFactory fieldFactory = new PersistentFieldFactory(container.getImplementationClass(PersistentField.class));
+
+ container.setSingletonInstance(PersistentFieldFactory.class, fieldFactory);
+ metadataManager = (MetadataManager)container.getSingletonInstance(MetadataManager.class);
+
+ // configuring the proxy proxyFactory
+ proxyFactory = new ProxyFactory();
+
+ proxyFactory.setIndirectionHandlerClass(container.getImplementationClass(IndirectionHandler.class));
+ proxyFactory.setCollectionProxyClass(container.getImplementationClass(CollectionProxy.class));
+ proxyFactory.setListProxyClass(container.getImplementationClass(ListProxy.class));
+ proxyFactory.setSetProxyClass(container.getImplementationClass(SetProxy.class));
+ container.setSingletonInstance(ProxyFactory.class, proxyFactory);
+ }
+
+ /**
+ * Returns the value of a configuration property. Note that using this method does not result in the
+ * initialization of the runtime. This means that the properties may not have been loaded yet from
+ * the OJB.properties file.
+ *
+ * @param name The property name
+ * @return The property value
+ */
+ public String getProperty(String name, String value, boolean force)
+ {
+ return new ContainerHelper().getProperty(container, name);
+ }
+
+ /**
+ * Sets a configuration property. Note that this is only possible prior to using
+ * any OJB functionality, e.g. accessing the persistence configuration or broker.
+ *
+ * @param name The property name
+ * @param value The property value
+ * @param force Whether to override an existing value
+ */
+ public void setProperty(String name, String value, boolean force)
+ {
+ if (isInitialized)
+ {
+ throw new OJBRuntimeException("Cannot change the runtime configuration after it has been initialized");
+ }
+ new ContainerHelper().setProperty(container, name, value, force);
+ }
- public Factories getFactories()
+ /**
+ * Returns the component container.
+ *
+ * @return The container
+ */
+ public ComponentContainer getComponentContainer()
{
- return factories;
+ return container;
}
public MetadataManager getMetadataManager()
{
+ initDynamicSystem();
return metadataManager;
}
+ /**
+ * Returns the proxy factory.
+ *
+ * @return The proxy factory
+ */
+ public ProxyFactory getProxyFactory()
+ {
+ initDynamicSystem();
+ return proxyFactory;
+ }
+
public void shutdown()
{
- log.info("Start shutdown OJB");
- List list = getConfigurations();
- PersistenceConfiguration pc = null;
- for (int i = 0; i < list.size(); i++)
+ if (!isInitialized)
+ {
+ // nothing to do
+ return;
+ }
+ log.info("Starting to shutdown OJB");
+ for (Iterator it = getConfigurations().iterator(); it.hasNext();)
{
+ PersistenceConfiguration conf = (PersistenceConfiguration)it.next();
+
try
{
- pc = (PersistenceConfiguration) list.get(i);
- pc.destroy();
+ conf.destroy();
}
catch (Exception e)
{
- log.error("Error while destroy PersistenceConfiguration for key " + (pc != null ? pc.getKey() : null), e);
+ log.error("Error while destroy PersistenceConfiguration for key " + (conf != null ? conf.getKey() : null), e);
}
}
- log.info("Shutdown OJB finished");
+ log.info("Shutdown of OJB finished");
}
//======================================================
// PersistenceConfiguration methods
//======================================================
/**
- * Get the {@link org.apache.ojb.broker.PersistenceConfiguration} for given key.
+ * Get the {@link org.apache.ojb.broker.PersistenceConfiguration} for given key. If none
+ * exists but a connection descriptor exists for this key, a new configuration will be created.
*
* @param key The key of the searched {@link org.apache.ojb.broker.PersistenceConfiguration}.
- * @return The associated configuration or <em>null</em> if not found.
+ * @return The associated configuration
*/
public PersistenceConfiguration getConfiguration(PBKey key) throws ConfigurationException
{
- PersistenceConfiguration conf = (PersistenceConfiguration) configurationMap.get(key);
+ initDynamicSystem();
+
+ PBKey realKey = key;
+ PersistenceConfiguration conf = null;
+
+ if (realKey == null)
+ {
+ realKey = metadataManager.getDefaultPBKey();
+ }
+ conf = (PersistenceConfiguration) configurationMap.get(realKey);
if (conf == null)
{
- conf = createAndAddNewPersistenceConfiguration(key);
+ conf = createAndAddNewPersistenceConfiguration(realKey);
}
return conf;
}
@@ -128,7 +254,7 @@
// lookup the configuration metadata
PersistenceConfigurationDescriptor pcd = getMetadataManager().getConfigurationFor(key);
// create new configuration for given key
- conf = new PersistenceConfiguration(this, pcd);
+ conf = new PersistenceConfiguration(container, pcd);
// TODO: Correct handling of the used CacheManager
/*
We have to differentiate three cases:
@@ -163,6 +289,7 @@
*/
public void addPersistenceConfiguration(PersistenceConfiguration pc) throws ConfigurationException
{
+ initDynamicSystem();
if (pc == null)
{
throw new ConfigurationException("Added PersistenceConfiguration is 'null'");
@@ -190,6 +317,7 @@
*/
public PersistenceConfiguration removePersistenceConfiguration(PBKey key)
{
+ initDynamicSystem();
synchronized (dummy)
{
return (PersistenceConfiguration) configurationMap.remove(key);
@@ -203,6 +331,7 @@
*/
public synchronized List getConfigurations()
{
+ initDynamicSystem();
return new ArrayList(configurationMap.values());
}
@@ -219,6 +348,7 @@
*/
public PersistenceBroker lookupBroker()
{
+ initDynamicSystem();
return lookupBroker(metadataManager.getDefaultPBKey());
}
@@ -230,13 +360,23 @@
*/
public PersistenceBroker lookupBroker(PBKey key)
{
+ initDynamicSystem();
try
{
key = BrokerHelper.crossCheckPBKey(this, key);
- PersistenceConfiguration configuration = getConfiguration(key);
- return configuration.getPersistenceBrokerFactory().createPersistenceBroker();
+
+ PersistenceConfiguration conf = getConfiguration(key);
+ if (conf == null)
+ {
+ throw new OJBRuntimeException("No persistence configuration defined for key " + key);
+ }
+ return conf.createPersistenceBroker();
+ }
+ catch (ConfigurationException e)
+ {
+ throw new OJBRuntimeException("Can't lookup PersistenceBroker instance for key: " + key, e);
}
- catch (Exception e)
+ catch (PBFactoryException e)
{
throw new OJBRuntimeException("Can't lookup PersistenceBroker instance for key: " + key, e);
}
@@ -244,8 +384,20 @@
public PersistenceBroker lookupBroker(String alias, String user, String passwd)
{
+ initDynamicSystem();
PBKey key = new PBKey(alias, user, passwd);
return lookupBroker(key);
+ }
+
+ /**
+ * Releases all connections from all persistence configurations that this runtime has.
+ */
+ public void releaseAllConnections()
+ {
+ for (Iterator it = configurationMap.values().iterator(); it.hasNext();)
+ {
+ ((PersistenceConfiguration)it.next()).releaseAllInstances();
+ }
}
public static final class ObjectModificationImpl implements ObjectModification
1.34 +2 -3 db-ojb/src/java/org/apache/ojb/broker/PersistenceBroker.java
Index: PersistenceBroker.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/PersistenceBroker.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- PersistenceBroker.java 14 Sep 2004 16:36:14 -0000 1.33
+++ PersistenceBroker.java 14 Nov 2004 09:33:37 -0000 1.34
@@ -29,7 +29,6 @@
import org.apache.ojb.broker.query.Query;
import org.apache.ojb.broker.util.BrokerHelper;
import org.apache.ojb.broker.util.ObjectModification;
-import org.apache.ojb.broker.util.configuration.Configurable;
import org.apache.ojb.broker.util.sequence.SequenceManager;
import org.odbms.ObjectContainer;
@@ -43,7 +42,7 @@
* @version $Id$
*
*/
-public interface PersistenceBroker extends Configurable, ObjectContainer
+public interface PersistenceBroker extends ObjectContainer
{
// *************************************************************************
// Services handled by the PersistenceBroker
1.27 +10 -57 db-ojb/src/java/org/apache/ojb/broker/PersistenceBrokerFactory.java
Index: PersistenceBrokerFactory.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/PersistenceBrokerFactory.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- PersistenceBrokerFactory.java 26 Oct 2004 15:27:39 -0000 1.26
+++ PersistenceBrokerFactory.java 14 Nov 2004 09:33:37 -0000 1.27
@@ -17,10 +17,6 @@
import java.util.List;
-import org.apache.ojb.broker.core.factory.ObjectFactory;
-import org.apache.ojb.broker.util.configuration.Configurator;
-import org.apache.ojb.broker.util.configuration.impl.OjbConfigurator;
-
/**
* Convenience factory class that produces {@link PersistenceBroker} instances.
* Since version 1.1 it necessary to set an {@link OJB} instance before use or replace
@@ -42,34 +38,23 @@
ojb = ojbInstance;
}
- public static OJB getOjb(ObjectFactory objectFactory)
+ public static OJB getOjb()
{
// To preserve OJB 1.0 behavior, we create a default OJB instance if the
// OJB instance is request but hasn't been configured yet
if (ojb == null)
{
- ojb = new OJB(objectFactory);
+ ojb = new OJB();
}
return ojb;
}
/**
- * Returns the {@link org.apache.ojb.broker.util.configuration.Configurator}
- * object.
- *
- * @return the configurator
- */
- public static Configurator getConfigurator()
- {
- return OjbConfigurator.getInstance();
- }
-
- /**
* @see MetadataManager#setDefaultPBKey(org.apache.ojb.broker.PBKey)
*/
public static void setDefaultKey(PBKey key)
{
- getOjb(null).getMetadataManager().setDefaultPBKey(key);
+ getOjb().getMetadataManager().setDefaultPBKey(key);
}
/**
@@ -77,33 +62,17 @@
*/
public static PBKey getDefaultKey()
{
- return getOjb(null).getMetadataManager().getDefaultPBKey();
+ return getOjb().getMetadataManager().getDefaultPBKey();
}
- /**
- * @see MetadataManager#getDefaultPBKey()
- */
- public static PBKey getDefaultKey(ObjectFactory objectfactory)
- {
- return getOjb(objectfactory).getMetadataManager().getDefaultPBKey();
- }
-
/**
* @see OJB#lookupBroker()
*/
public static PersistenceBroker defaultPersistenceBroker() throws PBFactoryException
{
- return getOjb(null).lookupBroker();
+ return getOjb().lookupBroker();
}
- public static PersistenceBroker defaultPersistenceBroker(ObjectFactory objectFactory)
- throws PBFactoryException
- {
- return getOjb(objectFactory).lookupBroker();
- }
-
-
-
/**
* @see OJB#lookupBroker(java.lang.String, java.lang.String, java.lang.String)
*/
@@ -111,40 +80,24 @@
String user, String password)
throws PBFactoryException
{
- return getOjb(null).lookupBroker(jcdAlias, user, password);
+ return getOjb().lookupBroker(jcdAlias, user, password);
}
- public static PersistenceBroker createPersistenceBroker(String jcdAlias,
- String user, String password, ObjectFactory objectFactory)
- throws PBFactoryException
- {
- return getOjb(objectFactory).lookupBroker(jcdAlias, user, password);
- }
-
public static PersistenceBroker createPersistenceBroker(PBKey key)
throws PBFactoryException
{
- return getOjb(null).lookupBroker(key);
+ return getOjb().lookupBroker(key);
}
/**
- * @see OJB#lookupBroker(org.apache.ojb.broker.PBKey)
- */
- public static PersistenceBroker createPersistenceBroker(PBKey key, ObjectFactory objectFactory)
- throws PBFactoryException
- {
- return getOjb(objectFactory).lookupBroker(key);
- }
-
- /**
* @see org.apache.ojb.broker.core.PersistenceBrokerFactoryIF#releaseAllInstances
*/
public synchronized static void releaseAllInstances()
{
- List list = getOjb(null).getConfigurations();
+ List list = getOjb().getConfigurations();
for (int i = 0; i < list.size(); i++)
{
- ((PersistenceConfiguration) list.get(i)).getPersistenceBrokerFactory().releaseAllInstances();
+ ((PersistenceConfiguration) list.get(i)).releaseAllInstances();
}
}
}
1.2 +46 -2 db-ojb/src/java/org/apache/ojb/broker/PersistenceBrokerInternal.java
Index: PersistenceBrokerInternal.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/PersistenceBrokerInternal.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PersistenceBrokerInternal.java 4 Jun 2004 16:02:44 -0000 1.1
+++ PersistenceBrokerInternal.java 14 Nov 2004 09:33:37 -0000 1.2
@@ -1,5 +1,10 @@
package org.apache.ojb.broker;
+import org.apache.ojb.broker.accesslayer.RowReader;
+import org.apache.ojb.broker.accesslayer.batch.BatchManager;
+import org.apache.ojb.broker.core.proxy.ProxyFactory;
+import org.apache.ojb.broker.metadata.ClassDescriptor;
+
/* Copyright 2002-2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,10 +23,49 @@
/**
* Internal used extended version of {@link PersistenceBroker}
*
+ * TODO: Declare internal services in this interface
+ *
* @author <a href="mailto:arminw@apache.org">Armin Waibel</a>
* @version $Id$
*/
public interface PersistenceBrokerInternal extends PersistenceBroker
{
-
+ /**
+ * Returns a row reader for the given class descriptor.
+ *
+ * @param classDesc The class descriptor
+ * @return The row reader
+ */
+ public RowReader getRowReaderFor(ClassDescriptor classDesc);
+
+ /**
+ * Returns the batch manager used by this broker.
+ *
+ * @return The batch manager
+ */
+ public BatchManager getBatchManager();
+
+ /**
+ * Returns the proxy factory used by this broker.
+ *
+ * @return The factory
+ */
+ public ProxyFactory getProxyFactory();
+
+ /**
+ * Creates a collection object.
+ *
+ * @param collectionClass The type
+ * @return The collection object
+ */
+ public ManageableCollection createCollection(Class collectionClass);
+
+ /**
+ * Creates a proxy of the given type.
+ *
+ * @param proxyClass The proxy type
+ * @param realSubjectsIdentity The identity of the real subject
+ * @return The proxy
+ */
+ public Object createProxy(Class proxyClass, Identity realSubjectsIdentity);
}
1.2 +142 -12 db-ojb/src/java/org/apache/ojb/broker/PersistenceConfiguration.java
Index: PersistenceConfiguration.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/PersistenceConfiguration.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PersistenceConfiguration.java 11 Aug 2004 00:41:49 -0000 1.1
+++ PersistenceConfiguration.java 14 Nov 2004 09:33:37 -0000 1.2
@@ -1,12 +1,23 @@
package org.apache.ojb.broker;
+import java.util.HashMap;
+
import org.apache.ojb.broker.OJB;
import org.apache.ojb.broker.PBKey;
+import org.apache.ojb.broker.accesslayer.RowReader;
+import org.apache.ojb.broker.accesslayer.StatementsForClassIF;
+import org.apache.ojb.broker.accesslayer.sql.SqlGenerator;
import org.apache.ojb.broker.core.PersistenceBrokerFactoryIF;
+import org.apache.ojb.broker.core.configuration.ComponentContainer;
+import org.apache.ojb.broker.core.factory.ObjectFactory;
import org.apache.ojb.broker.cache.CacheManager;
+import org.apache.ojb.broker.metadata.ClassDescriptor;
import org.apache.ojb.broker.metadata.DescriptorRepository;
import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
+import org.apache.ojb.broker.metadata.MetadataException;
import org.apache.ojb.broker.metadata.PersistenceConfigurationDescriptor;
+import org.apache.ojb.broker.platforms.Platform;
+import org.apache.ojb.broker.util.ClassHelper;
/* Copyright 2002-2004 The Apache Software Foundation
@@ -30,17 +41,35 @@
*/
public class PersistenceConfiguration
{
- private final PersistenceConfigurationDescriptor pcd;
- private final OJB ojb;
- private final PersistenceBrokerFactoryIF persistenceBrokerFactory;
+ /** Our own sub-subContainer */
+ private ComponentContainer subContainer;
+ private PersistenceConfigurationDescriptor pcd;
+ private OJB ojb;
+ private PersistenceBrokerFactoryIF persistenceBrokerFactory;
private CacheManager cacheManager;
+ private ObjectFactory objectFactory;
+ /** The sql generator for this configuration */
+ private SqlGenerator sqlGenerator;
+ /** Cache for class-statement objects keyed per class descriptor */
+ private HashMap statementsForClass = new HashMap();
+ /** Cache for row-reader objects keyed per class descriptor */
+ private HashMap rowReaderForClass = new HashMap();
- public PersistenceConfiguration(OJB ojb, PersistenceConfigurationDescriptor pcd)
+ public PersistenceConfiguration(ComponentContainer container, PersistenceConfigurationDescriptor pcd)
{
- this.ojb = ojb;
this.pcd = pcd;
- this.persistenceBrokerFactory =
- ojb.getFactories().getPersistenceBrokerFactoryFactory().createPersistenceBrokerFactoryIF(this);
+ this.ojb = (OJB)container.getInstance(OJB.class);
+
+ subContainer = container.createChildContainer();
+ subContainer.setSingletonInstance(this);
+ subContainer.setSingletonInstance(pcd.getJdbcConnectionDescriptor());
+ subContainer.setSingletonInstance(pcd.getJdbcConnectionDescriptor().getPlatform());
+
+ persistenceBrokerFactory = (PersistenceBrokerFactoryIF)subContainer.getSingletonInstance(PersistenceBrokerFactoryIF.class);
+ // we're registering the sql generator instance as a singleton so that any pb instance
+ // created in the context of this pc will get the same sql generator instance
+ sqlGenerator = (SqlGenerator)subContainer.getSingletonInstance(SqlGenerator.class);
+ objectFactory = (ObjectFactory)subContainer.getSingletonInstance(ObjectFactory.class);
}
public PBKey getKey()
@@ -53,11 +82,16 @@
return ojb;
}
- public PersistenceBrokerFactoryIF getPersistenceBrokerFactory()
+ /**
+ * Returns the component container.
+ *
+ * @return The container
+ */
+ public ComponentContainer getComponentContainer()
{
- return persistenceBrokerFactory;
+ return subContainer;
}
-
+
public DescriptorRepository getModel()
{
/*
@@ -82,10 +116,106 @@
{
this.cacheManager = cacheManager;
}
+
+ /**
+ * Returns the object factory.
+ *
+ * @return The object factory
+ */
+ public ObjectFactory getObjectFactory()
+ {
+ return objectFactory;
+ }
+
+ /**
+ * Returns the statement generator for the given class descriptor.
+ *
+ * @param classDesc The class descriptor
+ * @return The statement generator object
+ */
+ public StatementsForClassIF getStatementsForClass(ClassDescriptor classDesc)
+ {
+ StatementsForClassIF result = (StatementsForClassIF)statementsForClass.get(classDesc);
+
+ if (result == null)
+ {
+ Platform platform = getJdbcConnectionDescriptor().getPlatform();
+ Double jdbcLevel = new Double(getJdbcConnectionDescriptor().getJdbcLevel());
+
+ try
+ {
+ result = (StatementsForClassIF)ClassHelper.newInstance(
+ subContainer.getImplementationClass(StatementsForClassIF.class),
+ new Class[]{ Platform.class, ClassDescriptor.class, SqlGenerator.class, Double.class },
+ new Object[]{ platform, classDesc, sqlGenerator, jdbcLevel });
+ }
+ catch (Exception ex)
+ {
+ throw new OJBRuntimeException("Failed to create statement generator for class "+classDesc.getClassNameOfObject(), ex);
+ }
+ statementsForClass.put(classDesc, result);
+ }
+ return result;
+ }
+
+ /**
+ * Returns the row reader object for the given class descriptor.
+ *
+ * @param classDesc The class descriptor
+ * @return The row reader
+ */
+ public RowReader getRowReaderForClass(ClassDescriptor classDesc)
+ {
+ RowReader reader = (RowReader)rowReaderForClass.get(classDesc);
+
+ if (reader == null)
+ {
+ ComponentContainer localContainer = getComponentContainer().createChildContainer();
+
+ // we're using a local container so that we can register the current class descriptor (in which
+ // the row reader is probably interested)
+ localContainer.setSingletonInstance(ClassDescriptor.class, classDesc);
+
+ if (classDesc.getRowReaderClassName() != null)
+ {
+ Class rowReaderClass;
+
+ try
+ {
+ rowReaderClass = ClassHelper.getClass(classDesc.getRowReaderClassName());
+ }
+ catch (ClassNotFoundException ex)
+ {
+ throw new MetadataException("Could not create RowReader of type "+classDesc.getRowReaderClassName()+
+ " that is configured for class descriptor "+classDesc.getClassNameOfObject(), ex);
+ }
+
+ reader = (RowReader)localContainer.getInstance(rowReaderClass);
+ }
+ else
+ {
+ reader = (RowReader)localContainer.getInstance(RowReader.class);
+ }
+ rowReaderForClass.put(classDesc, reader);
+ }
+
+ return reader;
+ }
+
+ public PersistenceBroker createPersistenceBroker() throws PBFactoryException
+ {
+ return persistenceBrokerFactory.createPersistenceBroker();
+ }
- void destroy()
+ public void releaseAllInstances()
{
persistenceBrokerFactory.releaseAllInstances();
+ rowReaderForClass.clear();
+ }
+
+ void destroy()
+ {
+ releaseAllInstances();
cacheManager.clearCaches();
}
}
1.1 db-ojb/src/java/org/apache/ojb/broker/ContainerHelper.java
Index: ContainerHelper.java
===================================================================
package org.apache.ojb.broker;
/* 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.
*/
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import org.apache.ojb.broker.accesslayer.ConnectionFactory;
import org.apache.ojb.broker.accesslayer.ConnectionFactoryDBCPImpl;
import org.apache.ojb.broker.accesslayer.ConnectionManagerIF;
import org.apache.ojb.broker.accesslayer.ConnectionManagerImpl;
import org.apache.ojb.broker.accesslayer.JdbcAccess;
import org.apache.ojb.broker.accesslayer.JdbcAccessImpl;
import org.apache.ojb.broker.accesslayer.RowReader;
import org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl;
import org.apache.ojb.broker.accesslayer.StatementManager;
import org.apache.ojb.broker.accesslayer.StatementManagerIF;
import org.apache.ojb.broker.accesslayer.StatementsForClassIF;
import org.apache.ojb.broker.accesslayer.StatementsForClassImpl;
import org.apache.ojb.broker.accesslayer.batch.BatchManager;
import org.apache.ojb.broker.accesslayer.batch.BatchManagerImpl;
import org.apache.ojb.broker.accesslayer.batch.BatchStrategy;
import org.apache.ojb.broker.accesslayer.batch.BatchStrategyDefaultImpl;
import org.apache.ojb.broker.accesslayer.sql.SqlGenerator;
import org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl;
import org.apache.ojb.broker.cache.LocalCache;
import org.apache.ojb.broker.core.IdentityFactoryImpl;
import org.apache.ojb.broker.core.PBPoolInfo;
import org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl;
import org.apache.ojb.broker.core.PersistenceBrokerFactoryIF;
import org.apache.ojb.broker.core.PersistenceBrokerImpl;
import org.apache.ojb.broker.core.configuration.ComponentContainer;
import org.apache.ojb.broker.core.factory.ObjectFactory;
import org.apache.ojb.broker.core.factory.ObjectFactoryDefaultImpl;
import org.apache.ojb.broker.core.proxy.CollectionProxy;
import org.apache.ojb.broker.core.proxy.CollectionProxyDefaultImpl;
import org.apache.ojb.broker.core.proxy.IndirectionHandler;
import org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl;
import org.apache.ojb.broker.core.proxy.ListProxy;
import org.apache.ojb.broker.core.proxy.ListProxyDefaultImpl;
import org.apache.ojb.broker.core.proxy.SetProxy;
import org.apache.ojb.broker.core.proxy.SetProxyDefaultImpl;
import org.apache.ojb.broker.locking.LockManager;
import org.apache.ojb.broker.locking.LockManagerDefaultImpl;
import org.apache.ojb.broker.locking.LockMap;
import org.apache.ojb.broker.locking.LockMapInMemoryImpl;
import org.apache.ojb.broker.locking.LockMapRemoteImpl;
import org.apache.ojb.broker.locking.LockStrategyManager;
import org.apache.ojb.broker.metadata.MetadataManager;
import org.apache.ojb.broker.metadata.fieldaccess.PersistentField;
import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessImplNew;
import org.apache.ojb.broker.transaction.tm.JBossTransactionManagerFactory;
import org.apache.ojb.broker.transaction.tm.TransactionManagerFactory;
import org.apache.ojb.broker.util.ClassHelper;
import org.apache.ojb.broker.util.logging.Logger;
import org.apache.ojb.broker.util.logging.LoggerFactory;
import org.apache.ojb.broker.util.pooling.PoolConfiguration;
import org.apache.ojb.broker.util.sequence.SequenceManager;
import org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl;
import org.apache.ojb.odmg.ImplementationImpl;
import org.apache.ojb.odmg.ImplementationInternal;
import org.apache.ojb.odmg.LocalTxManager;
import org.apache.ojb.odmg.OJBTxManager;
import org.apache.ojb.odmg.TransactionImpl;
import org.apache.ojb.odmg.collections.DBagImpl;
import org.apache.ojb.odmg.collections.DListImpl;
import org.apache.ojb.odmg.collections.DMapImpl;
import org.apache.ojb.odmg.collections.DSetImpl;
import org.apache.ojb.odmg.locking.LockManagerOdmgImpl;
import org.odmg.DArray;
import org.odmg.DBag;
import org.odmg.DList;
import org.odmg.DMap;
import org.odmg.DSet;
import org.odmg.Implementation;
/**
* Helper class for working with the component container, e.g. setting default values,
* and translating old-style configuration properties into the new fully-qualified format.
*
* @author <a href="mailto:tomdz@apache.org">Thomas Dudziak<a>
*/
public class ContainerHelper
{
/** Logger; we're logging in the context of OJB */
private Logger log = LoggerFactory.getLogger(OJB.class);
/** Contains the old->new mapping */
private HashMap _translationMap = new HashMap();
/**
* Creates the translator instance.
*/
public ContainerHelper()
{
_translationMap.put("repositoryFile",
MetadataManager.class.getName() + ".repositoryPath");
_translationMap.put("useSerializedRepository",
MetadataManager.class.getName() + ".usingSerializedRepository");
_translationMap.put("serializedRepositoryPath",
MetadataManager.class.getName() + ".serializedRepositoryPath");
_translationMap.put("PersistenceBrokerFactoryClass",
PersistenceBrokerFactoryIF.class.getName() + ".class");
_translationMap.put("PersistenceBrokerClass",
PersistenceBroker.class.getName() + ".class");
_translationMap.put("maxActive",
PoolConfiguration.class.getName() + ".maxActive");
_translationMap.put("maxIdle",
PoolConfiguration.class.getName() + ".maxIdle");
_translationMap.put("maxWait",
PoolConfiguration.class.getName() + ".maxWait");
_translationMap.put("timeBetweenEvictionRunsMillis",
PoolConfiguration.class.getName() + ".timeBetweenEvictionRunsMillis");
_translationMap.put("minEvictableIdleTimeMillis",
PoolConfiguration.class.getName() + ".minEvictableIdleTimeMillis");
_translationMap.put("whenExhaustedAction",
PoolConfiguration.class.getName() + ".whenExhaustedAction");
_translationMap.put("ConnectionManagerClass",
ConnectionManagerIF.class.getName() + ".class");
_translationMap.put("ConnectionFactoryClass",
ConnectionFactory.class.getName() + ".class");
_translationMap.put("SqlGeneratorClass",
SqlGenerator.class.getName() + ".class");
_translationMap.put("IndirectionHandlerClass",
IndirectionHandler.class.getName() + ".class");
_translationMap.put("ListProxyClass",
ListProxy.class.getName() + ".class");
_translationMap.put("SetProxyClass",
SetProxy.class.getName() + ".class");
_translationMap.put("CollectionProxyClass",
CollectionProxy.class.getName() + ".class");
_translationMap.put("StatementManagerClass",
StatementManagerIF.class.getName() + ".class");
_translationMap.put("StatementsForClassClass",
StatementsForClassIF.class.getName() + ".class");
_translationMap.put("JdbcAccessClass",
JdbcAccess.class.getName() + ".class");
_translationMap.put("RowReaderDefaultClass",
RowReader.class.getName() + ".class");
_translationMap.put("IdentityFactoryClass",
IdentityFactory.class.getName() + ".class");
_translationMap.put("LocalCacheClass",
LocalCache.class.getName() + ".class");
_translationMap.put("LockManagerClass",
LockManager.class.getName() + ".class");
_translationMap.put("OdmgLockManagerClass",
org.apache.ojb.odmg.locking.LockManager.class.getName() + ".class");
_translationMap.put("LockMapClass",
LockMap.class.getName() + ".class");
_translationMap.put("LockTimeout",
LockMapInMemoryImpl.class.getName() + ".lockTimeout");
_translationMap.put("LockServletUrl",
LockMapRemoteImpl.class.getName() + ".lockServletUrl");
_translationMap.put("ImplicitLocking",
ImplementationInternal.class.getName() + ".usingImplicitLocking");
_translationMap.put("LockAssociations",
TransactionImpl.class.getName() + ".lockAssociations");
_translationMap.put("OqlCollectionClass",
ImplementationImpl.class.getName() + ".oqlCollectionClass");
_translationMap.put("SqlInLimit",
PersistenceBrokerImpl.class.getName() + ".sqlInLimit");
_translationMap.put("PersistentFieldClass",
PersistentField.class.getName()+".class");
_translationMap.put("ImplementationClass",
Implementation.class.getName() + ".class");
_translationMap.put("OJBTxManagerClass",
OJBTxManager.class.getName() + ".class");
_translationMap.put("DListClass",
DList.class.getName() + ".class");
_translationMap.put("DArrayClass",
DArray.class.getName() + ".class");
_translationMap.put("DMapClass",
DMap.class.getName() + ".class");
_translationMap.put("DBagClass",
DBag.class.getName() + ".class");
_translationMap.put("DSetClass",
DSet.class.getName() + ".class");
_translationMap.put("JTATransactionManagerClass",
TransactionManagerFactory.class.getName() + ".class");
}
/**
* Translates a OJB 1.0-style property into the new fully qualified format
*
* @param oldPropName The old name
* @return The new name
*/
public String translate(String oldPropName)
{
String newName = (String)_translationMap.get(oldPropName);
return newName != null ? newName : oldPropName;
}
/**
* Initializes the container with default values.
*
* @param container The container
*/
public void initWithDefaults(ComponentContainer container)
{
// setting default types
container.ensureImplementationClass(BatchManager.class, BatchManagerImpl.class);
container.ensureImplementationClass(BatchStrategy.class, BatchStrategyDefaultImpl.class);
container.ensureImplementationClass(CollectionProxy.class, CollectionProxyDefaultImpl.class);
container.ensureImplementationClass(ConnectionFactory.class, ConnectionFactoryDBCPImpl.class);
container.ensureImplementationClass(ConnectionManagerIF.class, ConnectionManagerImpl.class);
container.ensureImplementationClass(IdentityFactory.class, IdentityFactoryImpl.class);
container.ensureImplementationClass(Implementation.class, ImplementationImpl.class);
container.ensureImplementationClass(IndirectionHandler.class, IndirectionHandlerDefaultImpl.class);
container.ensureImplementationClass(JdbcAccess.class, JdbcAccessImpl.class);
container.ensureImplementationClass(LockManager.class, LockManagerDefaultImpl.class);
container.ensureImplementationClass(org.apache.ojb.odmg.locking.LockManager.class, LockManagerOdmgImpl.class);
container.ensureImplementationClass(LockMap.class, LockMapInMemoryImpl.class);
container.ensureImplementationClass(LockStrategyManager.class, LockStrategyManager.class);
container.ensureImplementationClass(ListProxy.class, ListProxyDefaultImpl.class);
container.ensureImplementationClass(ObjectFactory.class, ObjectFactoryDefaultImpl.class);
container.ensureImplementationClass(PersistenceBroker.class, PersistenceBrokerImpl.class);
container.ensureImplementationClass(PersistenceBrokerFactoryIF.class, PersistenceBrokerFactoryDefaultImpl.class);
container.ensureImplementationClass(PersistentField.class, PersistentFieldDirectAccessImplNew.class);
container.ensureImplementationClass(PoolConfiguration.class, PBPoolInfo.class);
container.ensureImplementationClass(RowReader.class, RowReaderDefaultImpl.class);
container.ensureImplementationClass(SequenceManager.class, SequenceManagerHighLowImpl.class);
container.ensureImplementationClass(SetProxy.class, SetProxyDefaultImpl.class);
container.ensureImplementationClass(SqlGenerator.class, SqlGeneratorDefaultImpl.class);
container.ensureImplementationClass(StatementManagerIF.class, StatementManager.class);
container.ensureImplementationClass(StatementsForClassIF.class, StatementsForClassImpl.class);
container.ensureImplementationClass(TransactionManagerFactory.class, JBossTransactionManagerFactory.class);
container.ensureImplementationClass(OJBTxManager.class, LocalTxManager.class);
container.ensureImplementationClass(DList.class, DListImpl.class);
container.ensureImplementationClass(DArray.class, DListImpl.class);
container.ensureImplementationClass(DMap.class, DMapImpl.class);
container.ensureImplementationClass(DBag.class, DBagImpl.class);
container.ensureImplementationClass(DSet.class, DSetImpl.class);
}
/**
* Returns a property from the given container.
*
* @param container The container
* @param property The property
*/
public String getProperty(ComponentContainer container, String property)
{
return (String)container.getProperty(translate(property));
}
/**
* Sets a property in the given container.
*
* @param container The container
* @param property The property
* @param value The value
* @param force Whether to override an existing value
*/
public void setProperty(ComponentContainer container, String property, Object value, boolean force)
{
container.setProperty(translate(property), value, force);
}
/**
* Loads the properties from the given path and adds them to the container.
*
* @param container The container
* @param path The path
* @param force Whether already existing property values shall be overridden
*/
public void loadProperties(ComponentContainer container, String path, boolean force)
{
Properties conf = new Properties();
try
{
URL url = ClassHelper.getResource(path);
if (url == null)
{
url = (new File(path)).toURL();
}
log.info("Loading OJB's properties from file " + url);
InputStream strIn = url.openStream();
conf.load(strIn);
strIn.close();
}
catch (FileNotFoundException ex)
{
if ((path == null) || (path.length() == 0))
{
log.info("Starting OJB without a properties file. OJB is using default settings instead.");
}
else
{
log.warn("Could not load properties file '" + path + "'. Using default settings!", ex);
}
}
catch (Exception ex)
{
throw new OJBRuntimeException("An error happend while loading the properties file '" + path + "'", ex);
}
for (Iterator it = conf.entrySet().iterator(); it.hasNext();)
{
Map.Entry entry = (Map.Entry)it.next();
setProperty(container, (String)entry.getKey(), entry.getValue(), force);
}
}
}
1.16 +7 -0 db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionManagerIF.java
Index: ConnectionManagerIF.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionManagerIF.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ConnectionManagerIF.java 14 Sep 2004 16:03:33 -0000 1.15
+++ ConnectionManagerIF.java 14 Nov 2004 09:33:37 -0000 1.16
@@ -33,6 +33,13 @@
public JdbcConnectionDescriptor getConnectionDescriptor();
/**
+ * Returns the connection factory used by this manager.
+ *
+ * @return The factory
+ */
+ public ConnectionFactory getConnectionFactory();
+
+ /**
* Returns the supported {@link org.apache.ojb.broker.platforms.Platform}
* determined by the {@link org.apache.ojb.broker.metadata.JdbcConnectionDescriptor}.
* @see #getConnectionDescriptor
1.25 +9 -7 db-ojb/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java
Index: JdbcAccessImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- JdbcAccessImpl.java 20 Sep 2004 14:33:14 -0000 1.24
+++ JdbcAccessImpl.java 14 Nov 2004 09:33:37 -0000 1.25
@@ -27,8 +27,8 @@
import org.apache.ojb.broker.Identity;
import org.apache.ojb.broker.KeyConstraintViolatedException;
import org.apache.ojb.broker.OptimisticLockException;
-import org.apache.ojb.broker.PersistenceBroker;
import org.apache.ojb.broker.PersistenceBrokerException;
+import org.apache.ojb.broker.PersistenceBrokerInternal;
import org.apache.ojb.broker.PersistenceBrokerSQLException;
import org.apache.ojb.broker.accesslayer.sql.SqlExistStatement;
import org.apache.ojb.broker.core.ValueContainer;
@@ -60,7 +60,7 @@
/**
* The broker in use.
*/
- protected PersistenceBroker broker;
+ protected PersistenceBrokerInternal broker;
/**
* This map contains {@link org.apache.ojb.broker.metadata.ClassDescriptor} as key and a
@@ -73,7 +73,7 @@
* constructor is private, use getInstance to get
* the singleton instance of this class
*/
- public JdbcAccessImpl(PersistenceBroker broker)
+ public JdbcAccessImpl(PersistenceBrokerInternal broker)
{
this.broker = broker;
logger = LoggerFactory.getLogger(this.getClass());
@@ -611,9 +611,11 @@
// data available read object, else return null
if (rs.next())
{
- Map row = new HashMap();
- cld.getRowReader().readObjectArrayFrom(rs, row);
- return cld.getRowReader().readObjectFrom(row);
+ Map row = new HashMap();
+ RowReader rowReader = broker.getRowReaderFor(cld);
+
+ rowReader.readObjectArrayFrom(rs, row);
+ return rowReader.readObjectFrom(row);
}
else
{
1.35 +25 -42 db-ojb/src/java/org/apache/ojb/broker/accesslayer/RowReaderDefaultImpl.java
Index: RowReaderDefaultImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/RowReaderDefaultImpl.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- RowReaderDefaultImpl.java 26 Oct 2004 15:27:39 -0000 1.34
+++ RowReaderDefaultImpl.java 14 Nov 2004 09:33:38 -0000 1.35
@@ -22,10 +22,8 @@
import org.apache.ojb.broker.PersistenceBrokerException;
import org.apache.ojb.broker.core.factory.ObjectFactory;
-import org.apache.ojb.broker.core.factory.ObjectFactoryException;
import org.apache.ojb.broker.metadata.ClassDescriptor;
import org.apache.ojb.broker.metadata.FieldDescriptor;
-import org.apache.ojb.broker.util.ClassHelper;
/**
* Default implementation of the {@link RowReader} interface.
@@ -44,11 +42,14 @@
*/
private static final Object[] NO_ARGS = {};
- private ClassDescriptor m_cld;
+ private ClassDescriptor classDescriptor;
+ /** The object factory to be used by this row reader for classes that require it */
+ private transient ObjectFactory factory;
- public RowReaderDefaultImpl(ClassDescriptor cld)
+ public RowReaderDefaultImpl(ObjectFactory factory, ClassDescriptor classDescriptor)
{
- this.m_cld = cld;
+ this.factory = factory;
+ this.classDescriptor = classDescriptor;
}
/**
@@ -106,24 +107,15 @@
* be refreshed.
* @throws PersistenceBrokerException if there ewas an error creating the new object
*/
- protected Object buildOrRefreshObject(Map row, ClassDescriptor targetClassDescriptor, Object targetObject) throws ObjectFactoryException
+ protected Object buildOrRefreshObject(Map row, ClassDescriptor targetClassDescriptor, Object targetObject)
{
Object result = targetObject;
FieldDescriptor fmd = null;
- if(targetObject == null)
+ if (targetObject == null)
{
// 1. create new object instance if needed
- if(targetClassDescriptor.useObjectFactory())
- {
- ObjectFactory factory = getObjectFactory();
- result = factory.getInstanceOf(targetClassDescriptor.getClassOfObject());
- }
- else
- {
- result = ClassHelper.buildNewObjectInstance(targetClassDescriptor);
- }
-
+ result = factory.newInstance(targetClassDescriptor);
}
// 2. fill all scalar attributes of the new object
@@ -146,7 +138,7 @@
}
catch (Exception ex)
{
- throw new PersistenceBrokerException("Unable to invoke initialization method:" + initializationMethod.getName() + " for class:" + m_cld.getClassOfObject(), ex);
+ throw new PersistenceBrokerException("Unable to invoke initialization method:" + initializationMethod.getName() + " for class:" + classDescriptor.getClassOfObject(), ex);
}
}
}
@@ -154,15 +146,6 @@
}
/**
- * @return
- */
- private ObjectFactory getObjectFactory()
- {
- return m_cld.getRepository().getFactories().getObjectFactory();
-
- }
-
- /**
* materialize a single object, described by cld,
* from the first row of the ResultSet rs.
* There are two possible strategies:
@@ -183,17 +166,17 @@
public void readObjectArrayFrom(ResultSet rs, Map row)
{
FieldDescriptor[] fields = null;
- if (m_cld.getSuperClass() != null)
+ if (classDescriptor.getSuperClass() != null)
{
/**
* treeder
* append super class fields if exist
*/
- fields = m_cld.getFieldDescriptorsInHeirarchy();
+ fields = classDescriptor.getFieldDescriptorsInHeirarchy();
}
else
{
- String ojbDiscriminator = extractOjbConcreteClass(m_cld, rs);
+ String ojbDiscriminator = extractOjbConcreteClass(classDescriptor, rs);
/*
arminw:
if multiple classes were mapped to the same table, lookup the concrete
@@ -201,19 +184,19 @@
*/
if(ojbDiscriminator != null)
{
- ClassDescriptor cld = m_cld.getRepository().getDescriptorForDiscriminator(m_cld,ojbDiscriminator);
+ ClassDescriptor cld = classDescriptor.getRepository().getDescriptorForDiscriminator(classDescriptor,ojbDiscriminator);
fields = cld.getFieldDescriptions();
row.put(OJB_DISCRIMINATOR_KEY, cld.getClassOfObject());
}
else
{
- // fields = m_cld.getRepository().getFieldDescriptorsForMultiMappedTable(m_cld);
+ // fields = classDescriptor.getRepository().getFieldDescriptorsForMultiMappedTable(classDescriptor);
/*
arminw:
should be valid to use fields of class-descriptor, because we handle ojbDiscriminator
above, so a multi mapped table class-descriptor will never be used here
*/
- fields = m_cld.getFieldDescriptions();
+ fields = classDescriptor.getFieldDescriptions();
}
}
readValuesFrom(rs, row, fields);
@@ -225,7 +208,7 @@
*/
public void readPkValuesFrom(ResultSet rs, Map row)
{
- FieldDescriptor[] pkFields = m_cld.getPkFields();
+ FieldDescriptor[] pkFields = classDescriptor.getPkFields();
readValuesFrom(rs, row, pkFields);
}
@@ -248,14 +231,14 @@
}
catch (SQLException t)
{
- throw new PersistenceBrokerException("Error reading class type: " + m_cld.getClassNameOfObject()
+ throw new PersistenceBrokerException("Error reading class type: " + classDescriptor.getClassNameOfObject()
+ " from result set, current read field was " + (fld != null ? fld.getPersistentField().getName() : null), t);
}
}
protected String extractOjbConcreteClass(ClassDescriptor cld, ResultSet rs)
{
- FieldDescriptor discriminatorFD = m_cld.getDiscriminatorField();
+ FieldDescriptor discriminatorFD = classDescriptor.getDiscriminatorField();
if (discriminatorFD == null)
{
return null;
@@ -278,7 +261,7 @@
{
throw new PersistenceBrokerException("Unexpected error while try to read 'ojbConcretClass'" +
" field from result set using column name " + discriminatorFD.getColumnName() + " main class" +
- " was " + m_cld.getClassNameOfObject(), e);
+ " was " + classDescriptor.getClassNameOfObject(), e);
}
}
@@ -287,22 +270,22 @@
*/
protected ClassDescriptor selectClassDescriptor(Map row) throws PersistenceBrokerException
{
- ClassDescriptor result = m_cld;
+ ClassDescriptor result = classDescriptor;
Class temp = (Class) row.get(OJB_DISCRIMINATOR_KEY);
if(temp != null)
{
- result = m_cld.getRepository().getDescriptorFor(temp);
+ result = classDescriptor.getRepository().getDescriptorFor(temp);
}
return result;
}
public void setClassDescriptor(ClassDescriptor cld)
{
- this.m_cld = cld;
+ this.classDescriptor = cld;
}
public ClassDescriptor getClassDescriptor()
{
- return m_cld;
+ return classDescriptor;
}
}
1.52 +10 -10 db-ojb/src/java/org/apache/ojb/broker/accesslayer/StatementManager.java
Index: StatementManager.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/StatementManager.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- StatementManager.java 15 Sep 2004 17:18:45 -0000 1.51
+++ StatementManager.java 14 Nov 2004 09:33:38 -0000 1.52
@@ -61,11 +61,11 @@
private final ClassDescriptor dummy = new ClassDescriptor(null);
/** the associated broker */
- private final PersistenceBroker m_broker;
+ private PersistenceBroker m_broker;
private Platform m_platform;
private ConnectionManagerIF m_conMan;
- public StatementManager(final PersistenceBroker pBroker)
+ public StatementManager(PersistenceBroker pBroker)
{
this.m_broker = pBroker;
this.m_conMan = m_broker.serviceConnectionManager();
@@ -686,7 +686,7 @@
{
try
{
- return cld.getStatementsForClass(m_broker).getDeleteStmt(m_conMan.getConnection());
+ return m_broker.getConfiguration().getStatementsForClass(cld).getDeleteStmt(m_conMan.getConnection());
}
catch (SQLException e)
{
@@ -706,7 +706,7 @@
{
try
{
- return dummy.getStatementsForClass(m_broker).getGenericStmt(m_conMan.getConnection(), scrollable);
+ return m_broker.getConfiguration().getStatementsForClass(dummy).getGenericStmt(m_conMan.getConnection(), scrollable);
}
catch (LookupException e)
{
@@ -721,7 +721,7 @@
{
try
{
- return cds.getStatementsForClass(m_broker).getInsertStmt(m_conMan.getConnection());
+ return m_broker.getConfiguration().getStatementsForClass(cds).getInsertStmt(m_conMan.getConnection());
}
catch (SQLException e)
{
@@ -740,7 +740,7 @@
{
try
{
- return dummy.getStatementsForClass(m_broker).getPreparedStmt(m_conMan.getConnection(), sql, scrollable);
+ return m_broker.getConfiguration().getStatementsForClass(dummy).getPreparedStmt(m_conMan.getConnection(), sql, scrollable);
}
catch (LookupException e)
{
@@ -755,7 +755,7 @@
{
try
{
- return cds.getStatementsForClass(m_broker).getSelectByPKStmt(m_conMan.getConnection());
+ return m_broker.getConfiguration().getStatementsForClass(cds).getSelectByPKStmt(m_conMan.getConnection());
}
catch (SQLException e)
{
@@ -774,7 +774,7 @@
{
try
{
- return cds.getStatementsForClass(m_broker).getUpdateStmt(m_conMan.getConnection());
+ return m_broker.getConfiguration().getStatementsForClass(cds).getUpdateStmt(m_conMan.getConnection());
}
catch (SQLException e)
{
@@ -793,7 +793,7 @@
{
try
{
- return cds.getStatementsForClass(m_broker).getUpdateFieldsStmt(m_conMan.getConnection(), fieldsToUpdate);
+ return m_broker.getConfiguration().getStatementsForClass(cds).getUpdateFieldsStmt(m_conMan.getConnection(), fieldsToUpdate);
}
catch (SQLException e)
{
1.11 +2 -23 db-ojb/src/java/org/apache/ojb/broker/accesslayer/BasePrefetcher.java
Index: BasePrefetcher.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/BasePrefetcher.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- BasePrefetcher.java 11 Jun 2004 18:49:09 -0000 1.10
+++ BasePrefetcher.java 14 Nov 2004 09:33:38 -0000 1.11
@@ -20,8 +20,6 @@
import java.util.Iterator;
import org.apache.ojb.broker.Identity;
-import org.apache.ojb.broker.PersistenceBrokerFactory;
-import org.apache.ojb.broker.core.PersistenceBrokerConfiguration;
import org.apache.ojb.broker.core.PersistenceBrokerImpl;
import org.apache.ojb.broker.metadata.ClassDescriptor;
import org.apache.ojb.broker.metadata.DescriptorRepository;
@@ -30,7 +28,6 @@
import org.apache.ojb.broker.query.Query;
import org.apache.ojb.broker.query.QueryByCriteria;
import org.apache.ojb.broker.query.QueryFactory;
-import org.apache.ojb.broker.util.configuration.ConfigurationException;
import org.apache.ojb.broker.util.logging.Logger;
import org.apache.ojb.broker.util.logging.LoggerFactory;
@@ -46,24 +43,6 @@
protected ClassDescriptor itemClassDesc;
protected final int pkLimit; // max number of pk's in one query
- protected static final int IN_LIMIT = getPrefetchInLimit();
-
- /**
- * read the prefetchInLimit from Config based on OJB.properties
- */
- private static int getPrefetchInLimit()
- {
- try
- {
- PersistenceBrokerConfiguration config = (PersistenceBrokerConfiguration) PersistenceBrokerFactory.getConfigurator().getConfigurationFor(null);
- return config.getSqlInLimit();
- }
- catch (ConfigurationException e)
- {
- return 200;
- }
- }
-
/**
* Constructor for BasePrefetcher.
*/
@@ -73,7 +52,7 @@
broker = aBroker;
itemClassDesc = aBroker.getDescriptorRepository().getDescriptorFor(anItemClass);
logger = LoggerFactory.getLogger(this.getClass());
- pkLimit = getPrefetchInLimit() / getItemClassDescriptor().getPkFields().length;
+ pkLimit = broker.getSqlInLimit() / getItemClassDescriptor().getPkFields().length;
}
/**
1.10 +5 -3 db-ojb/src/java/org/apache/ojb/broker/accesslayer/RowReader.java
Index: RowReader.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/RowReader.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- RowReader.java 4 Apr 2004 23:53:31 -0000 1.9
+++ RowReader.java 14 Nov 2004 09:33:38 -0000 1.10
@@ -25,8 +25,10 @@
*/
public interface RowReader extends Serializable
{
- static final long serialVersionUID = -1283322922537162249L; /**
- * materialize a single object from the values of the Map row.
+ static final long serialVersionUID = -1283322922537162249L;
+
+ /**
+ * Materialize a single object from the values of the Map row.
* the implementor of this class must not care for materializing
* references or collection attributes, this is done later!
* @param row the Map containing the new values
1.20 +85 -63 db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionManagerImpl.java
Index: ConnectionManagerImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionManagerImpl.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ConnectionManagerImpl.java 14 Sep 2004 16:03:33 -0000 1.19
+++ ConnectionManagerImpl.java 14 Nov 2004 09:33:38 -0000 1.20
@@ -20,18 +20,17 @@
import org.apache.ojb.broker.OJBRuntimeException;
import org.apache.ojb.broker.PersistenceBrokerException;
-import org.apache.ojb.broker.PersistenceConfiguration;
+import org.apache.ojb.broker.PersistenceBrokerInternal;
import org.apache.ojb.broker.TransactionAbortedException;
import org.apache.ojb.broker.TransactionInProgressException;
import org.apache.ojb.broker.TransactionNotInProgressException;
-import org.apache.ojb.broker.core.PersistenceBrokerImpl;
import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
import org.apache.ojb.broker.platforms.Platform;
import org.apache.ojb.broker.util.logging.Logger;
import org.apache.ojb.broker.util.logging.LoggerFactory;
/**
- * Manages Connection ressources.
+ * Manages Connection resources.
*
* @see ConnectionManagerIF
* @author Thomas Mahler
@@ -41,22 +40,19 @@
{
private Logger log = LoggerFactory.getLogger(ConnectionManagerImpl.class);
- private PersistenceConfiguration pc;
- private PersistenceBrokerImpl broker = null;
+ private PersistenceBrokerInternal broker = null;
private ConnectionFactory connectionFactory;
- private Platform platform;
+ private JdbcConnectionDescriptor jcd;
private Connection con = null;
private boolean originalAutoCommitState;
private boolean isInLocalTransaction;
private boolean batchMode;
- public ConnectionManagerImpl(PersistenceBrokerImpl broker)
+ public ConnectionManagerImpl(ConnectionFactory connFactory, PersistenceBrokerInternal broker, JdbcConnectionDescriptor jcd)
{
+ this.connectionFactory = connFactory;
this.broker = broker;
- pc = broker.getConfiguration();
- this.connectionFactory = pc.getOjb().getFactories().getConnectionFactoryFactory()
- .getConnectionFactoryFor(pc.getJdbcConnectionDescriptor());
- this.platform = pc.getJdbcConnectionDescriptor().getPlatform();
+ this.jcd = jcd;
/*
by default batch mode is not enabled and after use of a PB
instance, before instance was returned to pool, batch mode
@@ -72,23 +68,31 @@
*/
public JdbcConnectionDescriptor getConnectionDescriptor()
{
- return pc.getJdbcConnectionDescriptor();
+ return jcd;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.ojb.broker.accesslayer.ConnectionManagerIF#getConnectionFactory()
+ */
+ public ConnectionFactory getConnectionFactory()
+ {
+ return connectionFactory;
}
public Platform getSupportedPlatform()
{
- return this.platform;
+ return jcd.getPlatform();
}
/**
* Returns the underlying connection, requested at the
* {@link org.apache.ojb.broker.accesslayer.ConnectionFactory}.
* PB.beginTransaction() opens a single jdbc connection via
- * serviceConnectionManager().localBegin().
- * If you call ask serviceConnectionManager().getConnection() later
- * it returns the already opened connection.
- * the PB instance will close the connection during
- * commitTransaction() or abortTransaction().
+ * serviceConnectionManager().localBegin().
+ * If you call ask serviceConnectionManager().getConnection() later
+ * it returns the already opened connection.
+ * the PB instance will close the connection during
+ * commitTransaction() or abortTransaction().
*/
public Connection getConnection() throws LookupException
{
@@ -97,21 +101,26 @@
// create a new connection isn't the right way I think.
if (con == null)
{
- con = this.connectionFactory.lookupConnection();
- JdbcConnectionDescriptor jcd = pc.getJdbcConnectionDescriptor();
- if (con == null) throw new PersistenceBrokerException("Cannot get connection for " + jcd);
+ con = connectionFactory.lookupConnection();
+ if (con == null)
+ {
+ throw new PersistenceBrokerException("Cannot get connection for " + jcd);
+ }
if (jcd.getUseAutoCommit() == JdbcConnectionDescriptor.AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE)
{
try
{
- this.originalAutoCommitState = con.getAutoCommit();
+ originalAutoCommitState = con.getAutoCommit();
}
catch (SQLException e)
{
throw new PersistenceBrokerException("Cannot request autoCommit state on the connection", e);
}
}
- if (log.isDebugEnabled()) log.debug("Request new connection from ConnectionFactory: " + con);
+ if (log.isDebugEnabled())
+ {
+ log.debug("Request new connection from ConnectionFactory: " + con);
+ }
}
return con;
@@ -122,30 +131,33 @@
*/
public void localBegin()
{
- if (this.isInLocalTransaction)
+ if (isInLocalTransaction)
{
throw new TransactionInProgressException("Connection is already in transaction");
}
Connection connection = null;
try
{
- connection = this.getConnection();
+ connection = getConnection();
}
catch (LookupException e)
{
- /**
- * must throw to notify user that we couldn't start a connection
- */
+ // must throw to notify user that we couldn't start a connection
throw new PersistenceBrokerException("Can't lookup a connection", e);
}
- if (log.isDebugEnabled()) log.debug("localBegin was called for con " + connection);
- JdbcConnectionDescriptor jcd = pc.getJdbcConnectionDescriptor();
+ if (log.isDebugEnabled())
+ {
+ log.debug("localBegin was called for con " + connection);
+ }
if (jcd.getUseAutoCommit() == JdbcConnectionDescriptor.AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE)
{
- if (log.isDebugEnabled()) log.debug("Try to change autoCommit state to 'false'");
- platform.changeAutoCommitState(jcd, connection, false);
+ if (log.isDebugEnabled())
+ {
+ log.debug("Try to change autoCommit state to 'false'");
+ }
+ getSupportedPlatform().changeAutoCommitState(jcd, connection, false);
}
- this.isInLocalTransaction = true;
+ isInLocalTransaction = true;
}
/**
@@ -153,8 +165,11 @@
*/
public void localCommit()
{
- if (log.isDebugEnabled()) log.debug("commit was called");
- if (!this.isInLocalTransaction)
+ if (log.isDebugEnabled())
+ {
+ log.debug("commit was called");
+ }
+ if (!isInLocalTransaction)
{
throw new TransactionNotInProgressException("Not in transaction, call begin() before commit()");
}
@@ -162,7 +177,10 @@
{
try
{
- if(isBatchMode()) executeBatch();
+ if (isBatchMode())
+ {
+ executeBatch();
+ }
}
finally
{
@@ -175,14 +193,14 @@
catch (SQLException e)
{
log.error("Commit on underlying connection failed, try to rollback connection", e);
- this.localRollback();
+ localRollback();
throw new TransactionAbortedException("Commit on connection failed", e);
}
finally
{
- this.isInLocalTransaction = false;
+ isInLocalTransaction = false;
restoreAutoCommitState();
- this.releaseConnection();
+ releaseConnection();
}
}
@@ -192,21 +210,24 @@
public void localRollback()
{
log.info("Rollback was called, do rollback on current connection " + con);
- if (!this.isInLocalTransaction)
+ if (!isInLocalTransaction)
{
throw new PersistenceBrokerException("Not in transaction, cannot abort");
}
try
{
//truncate the local transaction
- this.isInLocalTransaction = false;
+ isInLocalTransaction = false;
try
{
- if(isBatchMode()) clearBatch();
+ if (isBatchMode())
+ {
+ clearBatch();
+ }
}
finally
{
- if (con != null && !con.isClosed())
+ if ((con != null) && !con.isClosed())
{
con.rollback();
}
@@ -221,12 +242,12 @@
{
try
{
- restoreAutoCommitState();
- }
- catch(OJBRuntimeException ignore)
+ restoreAutoCommitState();
+ }
+ catch (OJBRuntimeException ignore)
{
- // Ignore or log exception
- }
+ // Ignore or log exception
+ }
releaseConnection();
}
}
@@ -238,11 +259,12 @@
{
try
{
- JdbcConnectionDescriptor jcd = pc.getJdbcConnectionDescriptor();
- if (jcd.getUseAutoCommit() == JdbcConnectionDescriptor.AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE
- && originalAutoCommitState == true && con != null && !con.isClosed())
+ if ((jcd.getUseAutoCommit() == JdbcConnectionDescriptor.AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE) &&
+ originalAutoCommitState &&
+ (con != null) &&
+ !con.isClosed())
{
- platform.changeAutoCommitState(jcd, con, true);
+ getSupportedPlatform().changeAutoCommitState(jcd, con, true);
}
}
catch (SQLException e)
@@ -259,7 +281,7 @@
{
try
{
- return con != null ? !con.isClosed() : false;
+ return (con != null) ? !con.isClosed() : false;
}
catch (SQLException e)
{
@@ -270,7 +292,7 @@
public boolean isInLocalTransaction()
{
- return this.isInLocalTransaction;
+ return isInLocalTransaction;
}
/**
@@ -279,7 +301,7 @@
*/
public void releaseConnection()
{
- if (this.con == null)
+ if (con == null)
{
//if (log.isDebugEnabled()) log.debug("No connection to release");
return;
@@ -292,8 +314,8 @@
}
else
{
- this.connectionFactory.releaseConnection(this.con);
- this.con = null;
+ connectionFactory.releaseConnection(con);
+ con = null;
}
}
@@ -318,11 +340,11 @@
There are many users having weird problems
when batch mode was enabled behind the scenes
*/
- if(!mode && batchMode)
+ if (!mode && batchMode)
{
executeBatch();
}
- batchMode = mode && pc.getJdbcConnectionDescriptor().getBatchMode();
+ batchMode = mode && jcd.getBatchMode();
}
/**
@@ -330,7 +352,7 @@
*/
public boolean isBatchMode()
{
- return batchMode && platform.supportsBatchOperations();
+ return batchMode && getSupportedPlatform().supportsBatchOperations();
}
/**
@@ -340,7 +362,7 @@
{
try
{
- broker.ojbBatchManager().executeBatch();
+ broker.getBatchManager().executeBatch();
}
catch (SQLException e)
{
@@ -355,7 +377,7 @@
{
try
{
- broker.ojbBatchManager().cancelBatch();
+ broker.getBatchManager().cancelBatch();
}
catch (SQLException e)
{
1.71 +9 -8 db-ojb/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java
Index: RsIterator.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- RsIterator.java 12 Nov 2004 00:15:58 -0000 1.70
+++ RsIterator.java 14 Nov 2004 09:33:38 -0000 1.71
@@ -34,7 +34,6 @@
import org.apache.ojb.broker.PersistenceBrokerSQLException;
import org.apache.ojb.broker.cache.LocalCache;
import org.apache.ojb.broker.core.PersistenceBrokerImpl;
-import org.apache.ojb.broker.core.proxy.VirtualProxy;
import org.apache.ojb.broker.metadata.ClassDescriptor;
import org.apache.ojb.broker.metadata.DescriptorRepository;
import org.apache.ojb.broker.metadata.FieldDescriptor;
@@ -426,7 +425,9 @@
// in any case we need the PK values of result set row
// provide m_row with primary key data of current row
- getQueryObject().getClassDescriptor().getRowReader().readPkValuesFrom(getRsAndStmt().m_rs, getRow());
+ RowReader reader = getBroker().getRowReaderFor(getQueryObject().getClassDescriptor());
+
+ reader.readPkValuesFrom(getRsAndStmt().m_rs, getRow());
if (getItemProxyClass() != null)
{
@@ -445,10 +446,10 @@
{
// map all field values from the current result set
- getQueryObject().getClassDescriptor().getRowReader().readObjectArrayFrom(getRsAndStmt().m_rs, getRow());
+ reader.readObjectArrayFrom(getRsAndStmt().m_rs, getRow());
// 3. If Object is not in cache
// materialize Object with primitive attributes filled from current row
- result = getQueryObject().getClassDescriptor().getRowReader().readObjectFrom(getRow());
+ result = reader.readObjectFrom(getRow());
// result may still be null!
if (result != null)
{
@@ -498,8 +499,8 @@
if (cld.isAlwaysRefresh())
{
// map all field values from the current result set
- getQueryObject().getClassDescriptor().getRowReader().readObjectArrayFrom(getRsAndStmt().m_rs, getRow());
- getQueryObject().getClassDescriptor().getRowReader().refreshObject(result, getRow());
+ reader.readObjectArrayFrom(getRsAndStmt().m_rs, getRow());
+ reader.refreshObject(result, getRow());
}
getBroker().refreshRelationships(result, cld);
}
@@ -522,7 +523,7 @@
Identity oid = getIdentityFromResultSet();
// 2. return a Proxy instance:
- return VirtualProxy.createProxy(getBroker().getPBKey(), getItemProxyClass(), oid);
+ return getBroker().createProxy(getItemProxyClass(), oid);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org