dain 2004/04/11 01:55:25
Modified: modules/core/src/java/org/openejb/entity/cmp
CMPContainerBuilder.java CMPCreateMethod.java
CMPGetter.java CMPInstanceContext.java
CMPInstanceContextFactory.java CMPSetter.java
Log:
Added cmp-field support
Revision Changes Path
1.5 +256 -47
openejb/modules/core/src/java/org/openejb/entity/cmp/CMPContainerBuilder.java
Index: CMPContainerBuilder.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/cmp/CMPContainerBuilder.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CMPContainerBuilder.java 6 Apr 2004 18:41:46 -0000 1.4
+++ CMPContainerBuilder.java 11 Apr 2004 05:55:25 -0000 1.5
@@ -48,9 +48,15 @@
package org.openejb.entity.cmp;
import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
+import javax.sql.DataSource;
+import javax.ejb.EJBLocalObject;
+import javax.ejb.EJBObject;
import org.openejb.AbstractContainerBuilder;
import org.openejb.EJBComponentType;
@@ -66,10 +72,41 @@
import org.openejb.entity.EntityInterceptorBuilder;
import org.openejb.entity.HomeMethod;
import org.openejb.proxy.EJBProxyFactory;
+import org.tranql.cache.CacheLoadCommand;
+import org.tranql.cache.CacheRowAccessor;
import org.tranql.cache.CacheTable;
+import org.tranql.cache.FaultHandler;
+import org.tranql.cache.ModifiedSlotAccessor;
+import org.tranql.cache.ModifiedSlotDetector;
+import org.tranql.cache.QueryFaultHandler;
+import org.tranql.ejb.CMPFieldAccessor;
+import org.tranql.ejb.CMPFieldFaultTransform;
+import org.tranql.ejb.CMPFieldTransform;
+import org.tranql.ejb.EJB;
+import org.tranql.ejb.LocalProxyTransform;
+import org.tranql.ejb.RemoteProxyTransform;
+import org.tranql.ejb.SimplePKTransform;
+import org.tranql.field.FieldAccessor;
import org.tranql.field.FieldTransform;
+import org.tranql.identity.IdentityDefiner;
import org.tranql.identity.IdentityTransform;
+import org.tranql.identity.UserDefinedIdentity;
+import org.tranql.ql.Query;
+import org.tranql.ql.QueryBuilder;
+import org.tranql.ql.QueryException;
+import org.tranql.ql.QueryTransformer;
+import org.tranql.query.ParamRemapper;
import org.tranql.query.QueryCommand;
+import org.tranql.query.UpdateCommand;
+import org.tranql.schema.Attribute;
+import org.tranql.sql.SQLQuery;
+import org.tranql.sql.SQL92Generator;
+import org.tranql.sql.SQLTransform;
+import org.tranql.sql.jdbc.InputBinding;
+import org.tranql.sql.jdbc.JDBCQueryCommand;
+import org.tranql.sql.jdbc.JDBCUpdateCommand;
+import org.tranql.sql.jdbc.ResultBinding;
+import org.tranql.sql.jdbc.binding.BindingFactory;
/**
*
@@ -77,42 +114,74 @@
* @version $Revision$ $Date$
*/
public class CMPContainerBuilder extends AbstractContainerBuilder {
- private IdentityTransform primaryKeyTransform = null;
- private IdentityTransform localProxyTransform = null;
- private IdentityTransform remoteProxyTransform = null;
- private CacheTable cacheTable = null;
- private QueryCommand[][] queryCommands = null;
- private MethodSignature[] queries = null;
+ private EJB ejb;
+ private DataSource dataSource;
+ private IdentityDefiner identityDefiner;
protected int getEJBComponentType() {
return EJBComponentType.CMP_ENTITY;
}
+ public EJB getEJB() {
+ return ejb;
+ }
+
+ public void setEJB(EJB ejb) {
+ this.ejb = ejb;
+ }
+
+ // todo this is broken but will work for createContainer
+ public DataSource getDataSource() {
+ return dataSource;
+ }
+
+ public void setDataSource(DataSource dataSource) {
+ this.dataSource = dataSource;
+ }
+
protected Object buildIt(boolean buildContainer) throws Exception {
- // stuff we still need
- String[] cmpFields = null;
- String[] relations = null;
-
- // Stuff we must build
- FieldTransform[] cmpFieldTransforms = null;
- FieldTransform[] relationTransforms = null;
+ // this should be more configurable
+ QueryTransformer queryTransformer = new SQLTransform(SQL92Generator.class);
// get the bean class
Class beanClass = getClassLoader().loadClass(getBeanClassName());
+ CacheTable cacheTable = createCacheTable(ejb, queryTransformer, dataSource);
+
+ // identity definer
+ identityDefiner = new UserDefinedIdentity(cacheTable, 0); // todo
+
+ // the load all by primary key command
+ QueryCommand loadCommand = createLoadAllCommand(ejb, queryTransformer,
identityDefiner, dataSource);
+
+ // load all fault handler
+ FaultHandler faultHandler = new QueryFaultHandler(loadCommand,
identityDefiner);
+
+ // build cmp field accessor map
+ LinkedHashMap cmpFieldAccessors = createCMPFieldAccessors(ejb,
faultHandler);
+
+ // Identity Transforms
+ TranqlEJBProxyFactory tranqlEJBProxyFactory = new TranqlEJBProxyFactory();
+ IdentityTransform primaryKeyTransform = new SimplePKTransform(cacheTable);
+ IdentityTransform localProxyTransform = new
LocalProxyTransform(primaryKeyTransform, tranqlEJBProxyFactory);
+ IdentityTransform remoteProxyTransform = new
RemoteProxyTransform(primaryKeyTransform, tranqlEJBProxyFactory);
+
// build the vop table
- LinkedHashMap vopMap = buildVopMap(beanClass);
+ LinkedHashMap vopMap = buildVopMap(beanClass, cacheTable,
primaryKeyTransform, localProxyTransform, remoteProxyTransform);
InterfaceMethodSignature[] signatures = (InterfaceMethodSignature[])
vopMap.keySet().toArray(new InterfaceMethodSignature[vopMap.size()]);
VirtualOperation[] vtable = (VirtualOperation[])
vopMap.values().toArray(new VirtualOperation[vopMap.size()]);
+ // build the proxy factory
EJBProxyFactory proxyFactory = createProxyFactory(signatures);
+ // todo this is a terrible hack... the vop build code needs the identity
transforms and we need the vop signatures to build the transforms
+ tranqlEJBProxyFactory.ejbProxyFactory = proxyFactory;
// create and intitalize the interceptor builder
InterceptorBuilder interceptorBuilder = initializeInterceptorBuilder(new
EntityInterceptorBuilder(), signatures, vtable);
// build the instance factory
- Map instanceMap = buildInstanceMap(beanClass, cmpFields,
cmpFieldTransforms, relations, relationTransforms, queries, queryCommands);
- InstanceContextFactory contextFactory = new
CMPInstanceContextFactory(getContainerId(), proxyFactory, primaryKeyTransform,
beanClass, instanceMap);
+ Map instanceMap = buildInstanceMap(beanClass, cmpFieldAccessors);
+ InstanceContextFactory contextFactory = new
CMPInstanceContextFactory(getContainerId(), proxyFactory, cacheTable,
primaryKeyTransform, beanClass, instanceMap);
EntityInstanceFactory instanceFactory = new
EntityInstanceFactory(getComponentContext(), contextFactory);
// build the pool
@@ -125,47 +194,171 @@
}
}
- private Map buildInstanceMap(Class beanClass, String[] cmpFields,
FieldTransform[] cmpFieldTransforms, String[] relations, FieldTransform[]
relationTransforms, MethodSignature[] queries, QueryCommand[][] queryCommands) {
+ private static LinkedHashMap createCMPFieldAccessors(EJB ejb, FaultHandler
faultHandler) {
+ List attributes = ejb.getAttributes();
+ LinkedHashMap cmpFieldAccessors = new LinkedHashMap(attributes.size());
+ for (int i = 0; i < attributes.size(); i++) {
+ Attribute attribute = (Attribute) attributes.get(i);
+ String name = attribute.getName();
+ CMPFieldTransform accessor = new CMPFieldAccessor(new
CacheRowAccessor(i), name);
+ accessor = new CMPFieldFaultTransform(accessor, faultHandler, new
int[]{i});
+ cmpFieldAccessors.put(name, accessor);
+ }
+ return cmpFieldAccessors;
+ }
+
+ private static QueryCommand createLoadAllCommand(EJB ejb, QueryTransformer
queryTransformer, IdentityDefiner idDefiner, DataSource ds) throws QueryException {
+ // READ
+ Query loadQuery = QueryBuilder.buildSelectById(ejb, false).getQuery();
+ SQLQuery loadSQLQuery = (SQLQuery) queryTransformer.transform(loadQuery);
+ InputBinding[] loadBindings =
BindingFactory.getInputBindings(loadSQLQuery.getParamTypes());
+ // todo there should be an easier way to create the results bindings
+ ResultBinding[] resultBindings = createResultsBindings(ejb);
+ QueryCommand loadCommand = new JDBCQueryCommand(ds,
loadSQLQuery.getSQLText(), loadBindings, resultBindings);
+ // todo this is lame... should be the default slot mapping
+ int[] slotMap = new int[resultBindings.length];
+ for (int i = 0; i < slotMap.length; i++) {
+ slotMap[i] = i;
+ }
+ loadCommand = new CacheLoadCommand(loadCommand, idDefiner, slotMap);
+ return loadCommand;
+ }
+
+ private static CacheTable createCacheTable(EJB ejb, QueryTransformer
queryTransformer, DataSource ds) throws QueryException {
+ CacheTable cacheTable;
+ // CREATE
+ Query createQuery = QueryBuilder.buildInsert(ejb).getQuery();
+ SQLQuery createSQLQuery = (SQLQuery)
queryTransformer.transform(createQuery);
+ // todo shouldn't UpdateCommand take a query directly?
+ InputBinding[] createBindings =
BindingFactory.getInputBindings(createSQLQuery.getParamTypes());
+ UpdateCommand createCommand = new JDBCUpdateCommand(ds,
createSQLQuery.getSQLText(), createBindings);
+
+ // UPDATE
+ Query updateQuery = QueryBuilder.buildUpdate(ejb).getQuery();
+ SQLQuery updateSQLQuery = (SQLQuery)
queryTransformer.transform(updateQuery);
+ InputBinding[] updateBindings =
BindingFactory.getInputBindings(updateSQLQuery.getParamTypes());
+ UpdateCommand updateCommand = new JDBCUpdateCommand(ds,
updateSQLQuery.getSQLText(), updateBindings);
+ // todo shouldn't query builder do this transform?
+ List attributes = ejb.getAttributes();
+ List updateTransformList = new ArrayList(attributes.size() * 2 + 1);
+ for (Iterator iterator = attributes.iterator(); iterator.hasNext();) {
+ Attribute attribute = (Attribute) iterator.next();
+ if (!attribute.isIdentity()) {
+ int index = updateTransformList.size() / 2;
+ updateTransformList.add(new ModifiedSlotDetector(index));
+ updateTransformList.add(new ModifiedSlotAccessor(index));
+ }
+
+ }
+ // todo I'd bet this is wrong
+ updateTransformList.add(new FieldAccessor(0));
+ FieldTransform[] updateTransforms = (FieldTransform[])
updateTransformList.toArray(new FieldTransform[updateTransformList.size()]);
+ updateCommand = new ParamRemapper(updateCommand, updateTransforms);
+
+
+ // DELETE
+ Query removeQuery = QueryBuilder.buildDelete(ejb).getQuery();
+ SQLQuery removeSQLQuery = (SQLQuery)
queryTransformer.transform(removeQuery);
+ InputBinding[] removeBindings =
BindingFactory.getInputBindings(removeSQLQuery.getParamTypes());
+ UpdateCommand removeCommand = new JDBCUpdateCommand(ds,
removeSQLQuery.getSQLText(), removeBindings);
+
+ // defaults
+ Object[] defaults = createDefaults(ejb);
+
+ // cahce table
+ cacheTable = new CacheTable(defaults, createCommand, updateCommand,
removeCommand);
+ return cacheTable;
+ }
+
+ private static ResultBinding[] createResultsBindings(EJB ejb) throws
QueryException {
+ List attributes = ejb.getAttributes();
+ ResultBinding[] resultBindings = new ResultBinding[attributes.size()];
+ for (int i = 0; i < attributes.size(); i++) {
+ Attribute attribute = (Attribute) attributes.get(i);
+ resultBindings[i] =
BindingFactory.getResultBinding(attribute.getType(), i+1);
+ }
+ return resultBindings;
+ }
+
+ private static Object[] createDefaults(EJB ejb) {
+ List attributes = ejb.getAttributes();
+ Object[] defaults = new Object[attributes.size()];
+ for (int i = 0; i < attributes.size(); i++) {
+ Attribute attribute = (Attribute) attributes.get(i);
+ Class type = attribute.getType();
+
+ if (type == Boolean.TYPE) {
+ defaults[i] = Boolean.FALSE;
+
+ } else if (type == Byte.TYPE) {
+ defaults[i] = new Byte((byte) 0);
+
+ } else if (type == Character.TYPE) {
+ defaults[i] = new Character((char) 0);
+
+ } else if (type == Short.TYPE) {
+ defaults[i] = new Short((short) 0);
+
+ } else if (type == Integer.TYPE) {
+ defaults[i] = new Integer(0);
+
+ } else if (type == Long.TYPE) {
+ defaults[i] = new Long(0);
+
+ } else if (type == Float.TYPE) {
+ defaults[i] = new Float(0);
+
+ } else if (type == Double.TYPE) {
+ defaults[i] = new Double(0);
+
+ } else {
+ defaults[i] = null;
+ }
+ }
+ return defaults;
+ }
+
+ private Map buildInstanceMap(Class beanClass, LinkedHashMap cmpFields) {
Map instanceMap;
instanceMap = new HashMap();
// add the cmp-field getters and setters to the instance table
- addFieldOperations(instanceMap, beanClass, cmpFields, cmpFieldTransforms);
+ addFieldOperations(instanceMap, beanClass, cmpFields);
- // add the cmr getters and setters to the instance table.
- addFieldOperations(instanceMap, beanClass, relations, relationTransforms);
+ // todo add the cmr getters and setters to the instance table.
- // add the select methods
- for (int i = 0; i < queries.length; i++) {
- MethodSignature signature = queries[i];
- if (signature.getMethodName().startsWith("ejbSelect")) {
- // add select method to the instance table
- QueryCommand query = queryCommands[i][0];
- instanceMap.put(signature, new CMPSelectMethod(query));
- }
- }
+ // todo add the select methods
+
return instanceMap;
}
- private void addFieldOperations(Map instanceMap, Class beanClass, String[]
fields, FieldTransform[] transforms) {
- for (int i = 0; i < fields.length; i++) {
- String fieldName = fields[i];
+ private void addFieldOperations(Map instanceMap, Class beanClass, LinkedHashMap
fields) {
+ for (Iterator iterator = fields.entrySet().iterator(); iterator.hasNext();)
{
+ Map.Entry entry = (Map.Entry) iterator.next();
+ String fieldName = (String) entry.getKey();
+ CMPFieldTransform fieldTransform = (CMPFieldTransform) entry.getValue();
try {
String baseName = Character.toUpperCase(fieldName.charAt(0)) +
fieldName.substring(1);
Method getter = beanClass.getMethod("get" + baseName, null);
Method setter = beanClass.getMethod("set" + baseName, new
Class[]{getter.getReturnType()});
-// instanceMap.put(new MethodSignature(getter), new
CMPGetter(fieldName, transforms[i]));
-// instanceMap.put(new MethodSignature(setter), new
CMPSetter(fieldName, transforms[i]));
+ instanceMap.put(new MethodSignature(getter), new
CMPGetter(fieldName, fieldTransform));
+ instanceMap.put(new MethodSignature(setter), new
CMPSetter(fieldName, fieldTransform));
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException("Missing accessor for field " +
fieldName);
}
}
}
- protected LinkedHashMap buildVopMap(Class beanClass) throws Exception {
+ protected LinkedHashMap buildVopMap(
+ Class beanClass,
+ CacheTable cacheTable,
+ IdentityTransform primaryKeyTransform,
+ IdentityTransform localProxyTransform,
+ IdentityTransform remoteProxyTransform) throws Exception {
+
LinkedHashMap vopMap = new LinkedHashMap();
// get the context set unset method objects
@@ -211,6 +404,7 @@
signature,
postCreateSignature,
cacheTable,
+ identityDefiner,
localProxyTransform,
remoteProxyTransform));
} else if (name.startsWith("ejbHome")) {
@@ -244,17 +438,32 @@
}
}
- for (int i = 0; i < queries.length; i++) {
- MethodSignature signature = queries[i];
- if (signature.getMethodName().startsWith("ejbFind")) {
- // add the finder method to the virtual operation table
- QueryCommand localQuery = queryCommands[i][0];
- QueryCommand remoteQuery = queryCommands[i][1];
- vopMap.put(
- MethodHelper.translateToInterface(signature),
- new CMPFinder(localQuery, remoteQuery));
- }
- }
+// for (int i = 0; i < queries.length; i++) {
+// MethodSignature signature = queries[i];
+// if (signature.getMethodName().startsWith("ejbFind")) {
+// // add the finder method to the virtual operation table
+// QueryCommand localQuery = queryCommands[i][0];
+// QueryCommand remoteQuery = queryCommands[i][1];
+// vopMap.put(
+// MethodHelper.translateToInterface(signature),
+// new CMPFinder(localQuery, remoteQuery));
+// }
+// }
return vopMap;
}
+
+ private static final class TranqlEJBProxyFactory implements
org.tranql.ejb.EJBProxyFactory {
+ private EJBProxyFactory ejbProxyFactory;
+
+ private TranqlEJBProxyFactory() {
+ }
+
+ public EJBLocalObject getLocalProxy(Object pk) {
+ return ejbProxyFactory.getEJBLocalObject(pk);
+ }
+
+ public EJBObject getRemoteProxy(Object pk) {
+ return ejbProxyFactory.getEJBObject(pk);
+ }
+ }
}
1.4 +9 -5
openejb/modules/core/src/java/org/openejb/entity/cmp/CMPCreateMethod.java
Index: CMPCreateMethod.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/cmp/CMPCreateMethod.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CMPCreateMethod.java 22 Mar 2004 00:41:19 -0000 1.3
+++ CMPCreateMethod.java 11 Apr 2004 05:55:25 -0000 1.4
@@ -68,9 +68,11 @@
import org.tranql.cache.CacheRow;
import org.tranql.cache.CacheTable;
import org.tranql.cache.DuplicateIdentityException;
+import org.tranql.cache.InTxCache;
import org.tranql.identity.IdentityTransform;
import org.tranql.identity.UndefinedIdentityException;
import org.tranql.identity.IdentityTransformException;
+import org.tranql.identity.IdentityDefiner;
/**
*
@@ -82,6 +84,7 @@
private final MethodSignature createSignature;
private final MethodSignature postCreateSignature;
private final CacheTable cacheTable;
+ private final IdentityDefiner identityDefiner;
private final IdentityTransform localProxyTransform;
private final IdentityTransform remoteProxyTransform;
@@ -94,6 +97,7 @@
MethodSignature createSignature,
MethodSignature postCreateSignature,
CacheTable cacheTable,
+ IdentityDefiner identityDefiner,
IdentityTransform localProxyTransform,
IdentityTransform remoteProxyTransform) {
@@ -101,6 +105,7 @@
this.createSignature = createSignature;
this.postCreateSignature = postCreateSignature;
this.cacheTable = cacheTable;
+ this.identityDefiner = identityDefiner;
this.localProxyTransform = localProxyTransform;
this.remoteProxyTransform = remoteProxyTransform;
@@ -150,11 +155,10 @@
Object proxy;
try {
TransactionContext transactionContext =
invocation.getTransactionContext();
-// InTxCache cache = transactionContext.getInTxCache();
+ InTxCache cache = transactionContext.getInTxCache();
// add the row to the cache (returning a new row containing identity)
-// IdentityDefiner pkDefiner = null;
-// cacheRow = cacheTable.addRow(cache,
pkDefiner.defineIdentity(cacheRow), cacheRow);
+ cacheRow = cacheTable.addRow(cache,
identityDefiner.defineIdentity(cacheRow), cacheRow);
ctx.setCacheRow(cacheRow);
// convert the global identity into a pk and assign the pk into the
context
@@ -203,6 +207,6 @@
}
private Object readResolve() {
- return new CMPCreateMethod(beanClass, createSignature, postCreateSignature,
cacheTable, localProxyTransform, remoteProxyTransform);
+ return new CMPCreateMethod(beanClass, createSignature, postCreateSignature,
cacheTable, identityDefiner, localProxyTransform, remoteProxyTransform);
}
}
1.3 +2 -2
openejb/modules/core/src/java/org/openejb/entity/cmp/CMPGetter.java
Index: CMPGetter.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/cmp/CMPGetter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CMPGetter.java 22 Mar 2004 00:41:19 -0000 1.2
+++ CMPGetter.java 11 Apr 2004 05:55:25 -0000 1.3
@@ -66,7 +66,7 @@
}
public Object invokeInstance(CMPInstanceContext ctx, Object[] args) {
- assert args.length != 0 : "CMPGetter must not be passed any arguments:" +
+ assert args.length == 0 : "CMPGetter must not be passed any arguments:" +
" fieldName=" + fieldName + ", args.length=" + args.length;
CacheRow row = ctx.getCacheRow();
1.4 +13 -4
openejb/modules/core/src/java/org/openejb/entity/cmp/CMPInstanceContext.java
Index: CMPInstanceContext.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/cmp/CMPInstanceContext.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CMPInstanceContext.java 22 Mar 2004 00:41:19 -0000 1.3
+++ CMPInstanceContext.java 11 Apr 2004 05:55:25 -0000 1.4
@@ -58,6 +58,8 @@
import org.openejb.entity.EntityInstanceContext;
import org.openejb.proxy.EJBProxyFactory;
import org.tranql.cache.CacheRow;
+import org.tranql.cache.CacheTable;
+import org.tranql.cache.InTxCache;
import org.tranql.identity.IdentityTransform;
import org.tranql.identity.GlobalIdentity;
@@ -72,10 +74,12 @@
private final IdentityTransform primaryKeyTransform;
private CacheRow cacheRow;
private TransactionContext transactionContext;
+ private final CacheTable cacheTable;
- public CMPInstanceContext(Object containerId, EJBProxyFactory proxyFactory,
InstanceOperation[] itable, IdentityTransform primaryKeyTransform,
CMPInstanceContextFactory contextFactory) throws Exception {
+ public CMPInstanceContext(Object containerId, EJBProxyFactory proxyFactory,
InstanceOperation[] itable, CacheTable cacheTable, IdentityTransform
primaryKeyTransform, CMPInstanceContextFactory contextFactory) throws Exception {
super(containerId, proxyFactory);
this.itable = itable;
+ this.cacheTable = cacheTable;
this.primaryKeyTransform = primaryKeyTransform;
instance = contextFactory.createCMPBeanInstance(this);
}
@@ -108,10 +112,15 @@
public void associate() throws Exception {
Object id = getId();
- if (id != null && !isStateValid()) {
+ if (id != null) {
// locate the cache row for this instance
GlobalIdentity globalId = primaryKeyTransform.getGlobalIdentity(id);
- cacheRow = transactionContext.getInTxCache().get(globalId);
+ InTxCache inTxCache = transactionContext.getInTxCache();
+ cacheRow = inTxCache.get(globalId);
+ if (cacheRow == null) {
+ cacheRow = cacheTable.newRow(globalId);
+ inTxCache.associate(cacheRow);
+ }
}
super.associate();
}
1.4 +7 -4
openejb/modules/core/src/java/org/openejb/entity/cmp/CMPInstanceContextFactory.java
Index: CMPInstanceContextFactory.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/cmp/CMPInstanceContextFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CMPInstanceContextFactory.java 22 Mar 2004 00:41:19 -0000 1.3
+++ CMPInstanceContextFactory.java 11 Apr 2004 05:55:25 -0000 1.4
@@ -69,6 +69,7 @@
import org.openejb.InstanceContextFactory;
import org.openejb.proxy.EJBProxyFactory;
import org.tranql.identity.IdentityTransform;
+import org.tranql.cache.CacheTable;
/**
*
@@ -78,15 +79,17 @@
public class CMPInstanceContextFactory implements InstanceContextFactory,
Serializable {
private final Object containerId;
private final EJBProxyFactory proxyFactory;
+ private final CacheTable cacheTable;
private final IdentityTransform primaryKeyTransform;
private final Class beanClass;
private final Map imap;
private final InstanceOperation[] itable;
private transient final Enhancer enhancer;
- public CMPInstanceContextFactory(Object containerId, EJBProxyFactory
proxyFactory, IdentityTransform primaryKeyTransform, Class beanClass, Map imap) throws
ClassNotFoundException {
+ public CMPInstanceContextFactory(Object containerId, EJBProxyFactory
proxyFactory, CacheTable cacheTable, IdentityTransform primaryKeyTransform, Class
beanClass, Map imap) throws ClassNotFoundException {
this.containerId = containerId;
this.proxyFactory = proxyFactory;
+ this.cacheTable = cacheTable;
this.primaryKeyTransform = primaryKeyTransform;
this.beanClass = beanClass;
this.imap = imap;
@@ -111,7 +114,7 @@
}
public synchronized InstanceContext newInstance() throws Exception {
- return new CMPInstanceContext(containerId, proxyFactory, itable,
primaryKeyTransform, this);
+ return new CMPInstanceContext(containerId, proxyFactory, itable,
cacheTable, primaryKeyTransform, this);
}
public synchronized EntityBean createCMPBeanInstance(CMPInstanceContext
instanceContext) {
@@ -130,7 +133,7 @@
private Object readResolve() throws ObjectStreamException {
try {
- return new CMPInstanceContextFactory(containerId, proxyFactory,
primaryKeyTransform, beanClass, imap);
+ return new CMPInstanceContextFactory(containerId, proxyFactory,
cacheTable, primaryKeyTransform, beanClass, imap);
} catch (ClassNotFoundException e) {
throw (InvalidClassException) new InvalidClassException("Cound not load
method argument class").initCause(e);
}
1.3 +2 -2
openejb/modules/core/src/java/org/openejb/entity/cmp/CMPSetter.java
Index: CMPSetter.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/cmp/CMPSetter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CMPSetter.java 22 Mar 2004 00:41:19 -0000 1.2
+++ CMPSetter.java 11 Apr 2004 05:55:25 -0000 1.3
@@ -66,7 +66,7 @@
}
public Object invokeInstance(CMPInstanceContext ctx, Object[] args) {
- assert args.length != 1 : "CMPSetter must be passed exactally one
argument:" +
+ assert args.length == 1 : "CMPSetter must be passed exactally one
argument:" +
" fieldName=" + fieldName + ", args.length=" + args.length;
CacheRow row = ctx.getCacheRow();