From 7977fcd381e17c4e3bdfebfbf7ca4c0d90cdba1f Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Sun, 10 Jun 2007 04:22:34 +0000 Subject: Added methods to access Storable properties by name. --- .../com/amazon/carbonado/spi/LobEngineTrigger.java | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/spi') diff --git a/src/main/java/com/amazon/carbonado/spi/LobEngineTrigger.java b/src/main/java/com/amazon/carbonado/spi/LobEngineTrigger.java index 4b5ac5f..d278556 100644 --- a/src/main/java/com/amazon/carbonado/spi/LobEngineTrigger.java +++ b/src/main/java/com/amazon/carbonado/spi/LobEngineTrigger.java @@ -20,8 +20,6 @@ package com.amazon.carbonado.spi; import java.util.List; -import org.cojen.util.BeanPropertyAccessor; - import com.amazon.carbonado.FetchException; import com.amazon.carbonado.PersistException; import com.amazon.carbonado.Storable; @@ -38,14 +36,12 @@ import com.amazon.carbonado.lob.Lob; class LobEngineTrigger extends Trigger { final LobEngine mEngine; private final int mBlockSize; - private final BeanPropertyAccessor mAccessor; private final LobProperty[] mLobProperties; LobEngineTrigger(LobEngine engine, Class type, int blockSize, List> lobProperties) { mEngine = engine; - mAccessor = BeanPropertyAccessor.forClass(type); mBlockSize = blockSize; mLobProperties = new LobProperty[lobProperties.size()]; @@ -59,11 +55,11 @@ class LobEngineTrigger extends Trigger { Object[] userLobs = new Object[length]; for (int i=0; i prop = mLobProperties[i]; - Object userLob = mAccessor.getPropertyValue(storable, prop.mName); + Object userLob = storable.getPropertyValue(prop.mName); userLobs[i] = userLob; if (userLob != null) { Object lob = prop.createNewLob(mBlockSize); - mAccessor.setPropertyValue(storable, prop.mName, lob); + storable.setPropertyValue(prop.mName, lob); } } return userLobs; @@ -79,7 +75,7 @@ class LobEngineTrigger extends Trigger { Object userLob = userLobs[i]; if (userLob != null) { LobProperty prop = mLobProperties[i]; - Lob lob = (Lob) mAccessor.getPropertyValue(storable, prop.mName); + Lob lob = (Lob) storable.getPropertyValue(prop.mName); prop.setLobValue(mEngine.getLocator(lob), (Lob) userLob); } } @@ -112,9 +108,9 @@ class LobEngineTrigger extends Trigger { throw e.toPersistException(); } - Object userLob = mAccessor.getPropertyValue(storable, prop.mName); + Object userLob = storable.getPropertyValue(prop.mName); userLobs[i] = userLob; - Lob existingLob = (Lob) mAccessor.getPropertyValue(existing, prop.mName); + Lob existingLob = (Lob) existing.getPropertyValue(prop.mName); if (userLob == null) { if (existingLob != null) { // User is setting existing lob to null, so delete it. @@ -126,7 +122,7 @@ class LobEngineTrigger extends Trigger { existingLob = prop.createNewLob(mBlockSize); } prop.setLobValue(mEngine.getLocator(existingLob), (Lob) userLob); - mAccessor.setPropertyValue(storable, prop.mName, existingLob); + storable.setPropertyValue(prop.mName, existingLob); } } @@ -154,7 +150,7 @@ class LobEngineTrigger extends Trigger { if (existing != null) { // After successful delete of master storable, delete all the lobs. for (LobProperty prop : mLobProperties) { - Lob lob = (Lob) mAccessor.getPropertyValue(existing, prop.mName); + Lob lob = (Lob) ((S) existing).getPropertyValue(prop.mName); mEngine.deleteLob(lob); } } @@ -175,7 +171,7 @@ class LobEngineTrigger extends Trigger { for (int i=0; i