[Joafip-svn] SF.net SVN: joafip:[2921] trunk
Brought to you by:
luc_peuvrier
|
From: <luc...@us...> - 2011-10-16 04:45:37
|
Revision: 2921
http://joafip.svn.sourceforge.net/joafip/?rev=2921&view=rev
Author: luc_peuvrier
Date: 2011-10-16 04:45:29 +0000 (Sun, 16 Oct 2011)
Log Message:
-----------
auto save done when create new instance
Modified Paths:
--------------
trunk/joafip/doc/_todo.txt
trunk/joafip/src/main/java/net/sf/joafip/reflect/HelperReflect.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectAndPersistInfo.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractDelegatingToStoreManagers.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/EnhanceCodeGenerator.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/DetachedProxyCallBack.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/IProxyCallBackProxyDelegation.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/IProxyCallBackToImplement.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/NullProxyCallBack.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyCallBack.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/StaticProxyCallBack.java
trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobASDelegatingListenDelegate.java
trunk/joafip/src/test/java/net/sf/joafip/service/TestTreeListIteratorIntercept.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSave.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ProxyCallBackForTest.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PMapKeyNavigableSet.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/service/rel400/ServiceRel400Tests.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/store/service/proxy/ProxyTests.java
Added Paths:
-----------
trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/KeyDef.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestConstructEntrySetIteratorOfPMapKeyNavigableSet.java
trunk/joafip/src/test/java/net/sf/joafip/store/entity/proxy/BobCallInConstructor.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestProxyCreationConstructed.java
Modified: trunk/joafip/doc/_todo.txt
===================================================================
--- trunk/joafip/doc/_todo.txt 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip/doc/_todo.txt 2011-10-16 04:45:29 UTC (rev 2921)
@@ -22,6 +22,7 @@
- export speed up
- kept in memory for object referenced by static field
- check field access constraints, direct field access disallow to force use of getter and/or setter
+- static field persistence feature removed because a non sense
minor changes:
- added search last in red black tree manager
@@ -94,10 +95,8 @@
garbage management error with jhupedom
-keptinmemory problem
+kept in memory problem
-static field persistence problem
-
joafip reflect project (see setAccessible )
- joafip
- joafip-log4j
Modified: trunk/joafip/src/main/java/net/sf/joafip/reflect/HelperReflect.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/reflect/HelperReflect.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip/src/main/java/net/sf/joafip/reflect/HelperReflect.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -573,6 +573,12 @@
}
stringBuilder.append('\n');
}
+ final Constructor<?>[] constructors = objectClass
+ .getDeclaredConstructors();
+ stringBuilder.append("constructors:\n");
+ for (Constructor<?> constructor : constructors) {
+ stringBuilder.append(constructor.toString());
+ }
return new ReflectException(stringBuilder.toString(), exception);
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectAndPersistInfo.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectAndPersistInfo.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectAndPersistInfo.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -460,6 +460,7 @@
public void clearSubstitution() {
if (substitutionOfObject != null) {
substitutionOfObject.substituteObjectAndPersistInfo = null;// NOPMD
+ substitutionOfObject = null;// NOPMD
}
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -425,7 +425,7 @@
queueSize = 0;
queueNumberOfWeakRef = 0;
}
- // FIXMELUC ____________________static persistence information live
+ // FIXMELUC _________________static persistence information live
// with file persistence
staticStateMap.clear();
// checkNullFieldError();
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractDelegatingToStoreManagers.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractDelegatingToStoreManagers.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractDelegatingToStoreManagers.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -588,7 +588,7 @@
} catch (final ClassInfoException exception) {
throw new StoreException(exception);
}
- // FIXMELUC _______________________not good classInfo.setKeptInMemory()
+ // FIXMELUC ___________________not good classInfo.setKeptInMemory()
classInfo.setKeptInMemory();
setSubstituteObjectManager(objectClass, KeptInMemoryObjectKey.class,
keptInMemorySubstituteObjectManager);
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/EnhanceCodeGenerator.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/EnhanceCodeGenerator.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/bytecode/proxy/EnhanceCodeGenerator.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -85,6 +85,11 @@
private String forceLoadMethodDesc;
+ private static final String SET_IN_CONSTRUCTION_METHOD_NAME =
+ /**/"setInConstruction$JOAFIP$";
+
+ private String setInConstructionMethodDesc;
+
private static final String[] FORCE_LOAD_EXCEPTION = new String[] {
/**/Type.getInternalName(ObjectIOException.class),
/**/Type.getInternalName(ObjectIODataRecordNotFoundException.class),
@@ -189,6 +194,11 @@
forceLoadMethodDesc = Type.getMethodDescriptor(method);
method = IProxyCallBack.class.getMethod(
+ /**/SET_IN_CONSTRUCTION_METHOD_NAME,
+ /**/new Class[] { boolean.class });
+ setInConstructionMethodDesc = Type.getMethodDescriptor(method);
+
+ method = IProxyCallBack.class.getMethod(
/**/UNLOAD_METHOD_NAME,
/**/NO_PARAMETERS);
unloadMethodDesc = Type.getMethodDescriptor(method);
@@ -456,6 +466,33 @@
methodVisitor.visitEnd();
/*
+ * setInConstruction
+ */
+
+ methodVisitor = classWriter.visitMethod(
+ /**/ACC_PUBLIC,
+ /**/SET_IN_CONSTRUCTION_METHOD_NAME,
+ /**/setInConstructionMethodDesc,
+ /**/null,
+ /**/null);
+ methodVisitor.visitCode();
+ methodVisitor.visitVarInsn(ALOAD, 0);
+ methodVisitor.visitFieldInsn(
+ /**/GETFIELD,
+ /**/classInternalName,
+ /**/PROXY_CALL_BACK_FIELD_NAME, I_PROXY_CALL_BACK_DELEGATION_DESC);
+ methodVisitor.visitVarInsn(ILOAD, 1);
+ methodVisitor.visitMethodInsn(
+ /**/INVOKEINTERFACE,
+ /**/I_PROXY_CALL_BACK_INTERFACE,
+ /**/SET_IN_CONSTRUCTION_METHOD_NAME,
+ /**/setInConstructionMethodDesc);
+ methodVisitor.visitInsn(RETURN);
+ // FIXMELUC _visitmaxs call needed ?
+ methodVisitor.visitMaxs(0, 0);
+ methodVisitor.visitEnd();
+
+ /*
* unload
*/
methodVisitor = classWriter.visitMethod(
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -80,12 +80,6 @@
heapDataManagerForSet.stopService();
}
- // FIXMELUC ___________________no more needed because of auto save
- // public void save() throws HeapException {
- // heapDataManagerForQue.flush();
- // heapDataManagerForSet.flush();
- // }
-
public DataRecordIdentifier pollFirst() throws HeapException {
return heapDataManagerForQue.removeFirstDataRecord();
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/DetachedProxyCallBack.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/DetachedProxyCallBack.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/DetachedProxyCallBack.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -121,4 +121,10 @@
public IObjectIOManagerForProxyObjectIO getObjectIOManager$JOAFIP$() {
throw new UnsupportedOperationException();
}
+
+ @SuppressWarnings("PMD")
+ @Override
+ public void setInConstruction$JOAFIP$(final boolean inConstruction) {
+ throw new UnsupportedOperationException();
+ }
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/IProxyCallBackProxyDelegation.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/IProxyCallBackProxyDelegation.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/IProxyCallBackProxyDelegation.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -110,4 +110,7 @@
@SuppressWarnings("PMD")
ObjectAndPersistInfo getInstance$JOAFIP$();
+
+ @SuppressWarnings("PMD")
+ void setInConstruction$JOAFIP$(boolean inConstruction);
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/IProxyCallBackToImplement.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/IProxyCallBackToImplement.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/IProxyCallBackToImplement.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -66,4 +66,7 @@
@Fortest
@SuppressWarnings("PMD")
int getInObjectCount$JOAFIP$();
+
+ @SuppressWarnings("PMD")
+ boolean isAutoSaveEnabled$JOAFIP$();
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/NullProxyCallBack.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/NullProxyCallBack.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/NullProxyCallBack.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -179,4 +179,16 @@
public int getInObjectCount$JOAFIP$() {
throw new UnsupportedOperationException();
}
+
+ @Override
+ @SuppressWarnings("PMD")
+ public boolean isAutoSaveEnabled$JOAFIP$() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ @SuppressWarnings("PMD")
+ public void setInConstruction$JOAFIP$(final boolean inConstruction) {
+ throw new UnsupportedOperationException();
+ }
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyCallBack.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyCallBack.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyCallBack.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -88,6 +88,8 @@
private final boolean autoSaveEnabled;
+ private boolean inConstruction;
+
public static void setUseJavaAgent(final boolean useJavaAgent) {
ProxyCallBack.useJavaAgent = useJavaAgent;
}
@@ -206,6 +208,7 @@
}
if (!loaded
+ && !inConstruction
&& !FINALIZER_THREAD_NAME.equals(Thread.currentThread()
.getName())) {
/*
@@ -277,7 +280,7 @@
ObjectIOClassNotFoundException, ObjectIODataCorruptedException,
ObjectIONotSerializableException {
synchronized (storeMutex) {
- if (!loading) {
+ if (!loading && !inConstruction) {
loading = true;
if (!loaded) {
load();
@@ -296,7 +299,7 @@
/*
* inObjectCount==0 because can not unload object when running its code
*/
- if (loaded) {
+ if (loaded && !inConstruction) {
if (!loading && inObjectCount == 0) {
loaded = false;
objectIOManager.unsetProxyObjectState(getInstance$JOAFIP$());
@@ -376,6 +379,18 @@
}
@Override
+ @SuppressWarnings("PMD")
+ public void setInConstruction$JOAFIP$(final boolean inConstruction) {
+ this.inConstruction = inConstruction;
+ }
+
+ @Override
+ @SuppressWarnings("PMD")
+ public boolean isAutoSaveEnabled$JOAFIP$() {
+ return autoSaveEnabled;
+ }
+
+ @Override
public String toString() {
return super.toString() + ", for " + getInstance$JOAFIP$().toString();
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -290,9 +290,12 @@
if (constructed) {
assert getProxyCallBack(instanceCreated) != NULL_PROXY_CALL_BACK_INSTANCE;
+ setNotInConstruction(instanceCreated);
+ // set is loaded last for auto save
objectAndPersistInfo.setIsLoaded();
}
} else {
+ // FIXMELUC ___________one method for objectAndPersistInfo action
// created by save
assert constructed;
objectAndPersistInfo.unWeakReferenceOnObject();
@@ -304,6 +307,9 @@
* objectAndPersistInfo.setIsLoaded() should be good to, may be
* better
*/
+ // objectAndPersistInfo.getProxyCallBackOfObject().setInConstruction$JOAFIP$(false);
+ setNotInConstruction(instanceCreated);
+ // set is loaded last for auto save
setIsLoaded(instanceCreated);
}
return objectAndPersistInfo;
@@ -394,6 +400,15 @@
}
}
+ private void setNotInConstruction(final Object object) {
+ if (useJavaAgent) {
+ StaticProxyCallBack.setInConstruction(object, false);
+ } else if (isProxy(object)) {
+ ((IProxyCallBackProxyDelegation) object)
+ .setInConstruction$JOAFIP$(false);
+ }
+ }
+
public static void setIsLoadedNoSave(final Object object)
throws ProxyException {
try {
@@ -546,6 +561,15 @@
+ object.getClass().getName()
+ "@"
+ System.identityHashCode(object);
+ // FIXMELUC _______________________old proxy call back
+ // FIXMELUC _______________________only for autosave
+ // if(proxyCallBack.isAutoSaveEnabled$JOAFIP$())
+ final IProxyCallBackToImplement oldProxyCallBack = proxy
+ .getProxyCallBack$JOAFIP$();
+ if (oldProxyCallBack == NULL_PROXY_CALL_BACK_INSTANCE) {// NOPMD
+ // in construction
+ proxyCallBack.setInConstruction$JOAFIP$(true);
+ }
proxy.setProxyCallBack$JOAFIP$(proxyCallBack);
}
proxyCallBack.setInstance$JOAFIP$(objectAndPersistInfo);
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/StaticProxyCallBack.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/StaticProxyCallBack.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/StaticProxyCallBack.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -141,6 +141,17 @@
}
}
+ public static void setInConstruction(final Object object,
+ final boolean inConstruction) {
+ final IProxyCallBackProxyDelegation proxyCallBack;
+ synchronized (StaticProxyCallBack.class) {
+ proxyCallBack = proxyCallBackOfObject(object);
+ }
+ if (proxyCallBack != null) {
+ proxyCallBack.setInConstruction$JOAFIP$(inConstruction);
+ }
+ }
+
public static void setIsLoadedNoSave(final Object object)
throws ObjectIOException {
final IProxyCallBackProxyDelegation proxyCallBack;
Modified: trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobASDelegatingListenDelegate.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobASDelegatingListenDelegate.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobASDelegatingListenDelegate.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -44,6 +44,7 @@
if (delegate == null) {
throw new IllegalStateException("delegate must not be null");
}
+ initialize();// NOPMD
}
public static BobASDelegatingListenDelegate newInstance(
@@ -60,6 +61,10 @@
return newInstance;
}
+ public void initialize() {
+ // no implementation
+ }
+
public void action() {
// delegate action job
delegate.action();
Added: trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/KeyDef.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/KeyDef.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/KeyDef.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.entity.rel400;
+
+import net.sf.joafip.StorableClass;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@StorableClass
+public class KeyDef {
+
+ private final String name;
+
+ public KeyDef(final String name) {
+ super();
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/TestTreeListIteratorIntercept.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/TestTreeListIteratorIntercept.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/TestTreeListIteratorIntercept.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -138,4 +138,15 @@
final ObjectAndPersistInfo objectAndPersistInfo) {
// no implementation
}
+
+ @Override
+ public boolean isAutoSaveEnabled$JOAFIP$() {// NOPMD
+ // no implementation
+ return false;
+ }
+
+ @Override
+ public void setInConstruction$JOAFIP$(final boolean inConstruction) {// NOPMD
+ // no implementation
+ }
}
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSave.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSave.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSave.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -20,8 +20,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.sf.joafip.service.rel400;
+package net.sf.joafip.service.rel400;//NOPMD
+import java.util.Iterator;
+import java.util.Map.Entry;
+
import net.sf.joafip.AbstractDeleteFileTestCase;
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
@@ -30,6 +33,8 @@
import net.sf.joafip.entity.rel400.BobASDelegatingListenDelegate;
import net.sf.joafip.entity.rel400.BobASWithTransientCaller;
import net.sf.joafip.entity.rel400.BobForAutoSaveTest;
+import net.sf.joafip.entity.rel400.KeyDef;
+import net.sf.joafip.java.util.PTreeMap;
import net.sf.joafip.service.FilePersistence;
import net.sf.joafip.service.FilePersistenceBuilder;
import net.sf.joafip.service.FilePersistenceClassNotFoundException;
@@ -41,6 +46,7 @@
import net.sf.joafip.service.IAutoSaveEventListener;
import net.sf.joafip.service.IExclusiveDataAccessSession;
import net.sf.joafip.store.entity.objectio.ObjectAndPersistInfo;
+import net.sf.joafip.store.entity.proxy.BobCallInConstructor;
import net.sf.joafip.store.service.objectfortest.Bob1;
import net.sf.joafip.store.service.objectfortest.Bob2;
import net.sf.joafip.store.service.objectio.ObjectIOException;
@@ -411,6 +417,49 @@
session.close();
}
+ public void testCallInConstructor() throws FilePersistenceException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceTooBigForSerializationException {
+ final IInstanceFactory instanceFactory = session.getInstanceFactory();
+ session.open();
+ final Class<?> objectClass = BobCallInConstructor.class;
+ saveDoneFlag = false;
+ instanceFactory.newInstance(objectClass,
+ new Class<?>[] { String.class }, new Object[] { "a name" });
+ assertTrue(MUST_SAVE, saveDoneFlag);
+ session.close();
+ }
+
+ private static final KeyDef KEY_DEF_1 = new KeyDef("key1");
+
+ private static final KeyDef KEY_DEF_2 = new KeyDef("key2");
+
+ @SuppressWarnings("unchecked")
+ public void testRefToStatic() throws FilePersistenceException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceNotSerializableException {
+ final IInstanceFactory instanceFactory = session.getInstanceFactory();
+ session.open();
+ final PTreeMap<String, KeyDef> map = (PTreeMap<String, KeyDef>) instanceFactory
+ .newInstance(PTreeMap.class);
+ map.put(KEY_DEF_1.getName(), KEY_DEF_1);
+ map.put(KEY_DEF_2.getName(), KEY_DEF_2);
+ final Iterator<Entry<String, KeyDef>> iterator = map.entrySet()
+ .iterator();
+ assertTrue("must has next", iterator.hasNext());
+ Entry<String, KeyDef> next = iterator.next();
+ assertEquals("bad key", KEY_DEF_1.getName(), next.getKey());
+ assertTrue("must has next", iterator.hasNext());
+ next = iterator.next();
+ assertEquals("bad key", KEY_DEF_2.getName(), next.getKey());
+ assertFalse("must not has next", iterator.hasNext());
+ }
+
@Override
public boolean doSave() {
return true;
Added: trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestConstructEntrySetIteratorOfPMapKeyNavigableSet.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestConstructEntrySetIteratorOfPMapKeyNavigableSet.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestConstructEntrySetIteratorOfPMapKeyNavigableSet.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.service.rel400;
+
+import java.util.Iterator;
+import java.util.NavigableMap;
+
+import net.sf.joafip.AbstractJoafipCommonTestCase;
+import net.sf.joafip.TestException;
+import net.sf.joafip.java.util.PMapKeyNavigableSet;
+import net.sf.joafip.java.util.PTreeMap;
+import net.sf.joafip.reflect.HelperReflect;
+import net.sf.joafip.reflect.ReflectException;
+import net.sf.joafip.service.FilePersistenceRuntimeException;
+import net.sf.joafip.store.service.proxy.IInstanceFactory;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class TestConstructEntrySetIteratorOfPMapKeyNavigableSet extends
+ AbstractJoafipCommonTestCase implements IInstanceFactory {
+
+ public TestConstructEntrySetIteratorOfPMapKeyNavigableSet()
+ throws TestException {
+ super();
+ }
+
+ public TestConstructEntrySetIteratorOfPMapKeyNavigableSet(final String name)
+ throws TestException {
+ super(name);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void test() { // NOPMD
+ final NavigableMap<String, String> navigableMap = new PTreeMap<String, String>();
+ final PMapKeyNavigableSet<String, String> map = PMapKeyNavigableSet
+ .newInstance(this, navigableMap);
+ final Iterator<String> iterator = map.iterator();
+ assertFalse("must be empty", iterator.hasNext());
+ final Iterator<String> descendingIterator = map.descendingIterator();
+ assertFalse("must be empty", descendingIterator.hasNext());
+ }
+
+ @Override
+ public Object newInstance(final Class<?> objectClass,
+ final Class<?>[] parameterTypes, final Object[] initargs) {
+ try {
+ return HelperReflect.getInstance().newInstanceConstruct(
+ objectClass, parameterTypes, initargs);
+ } catch (ReflectException exception) {
+ throw new FilePersistenceRuntimeException(exception);
+ }
+ }
+
+ @Override
+ public Object newInstance(final Class<?> objectClass) {
+ throw new UnsupportedOperationException("should not be used");
+ }
+}
Added: trunk/joafip/src/test/java/net/sf/joafip/store/entity/proxy/BobCallInConstructor.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/entity/proxy/BobCallInConstructor.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/entity/proxy/BobCallInConstructor.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.entity.proxy;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class BobCallInConstructor {
+
+ private String name;
+
+ private int age;
+
+ public BobCallInConstructor(final String name, final int age) {
+ super();
+ setName(name);// NOPMD
+ setAge(age);// NOPMD
+ }
+
+ public BobCallInConstructor(final String name) {
+ this(name, -1);
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(final int age) {
+ this.age = age;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+}
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ProxyCallBackForTest.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ProxyCallBackForTest.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ProxyCallBackForTest.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -292,4 +292,17 @@
throws ObjectIOException {
// no implementation
}
+
+ @SuppressWarnings("PMD")
+ @Override
+ public boolean isAutoSaveEnabled$JOAFIP$() {
+ // no implementation
+ return false;
+ }
+
+ @SuppressWarnings("PMD")
+ @Override
+ public void setInConstruction$JOAFIP$(final boolean inConstruction) {
+ // no implementation
+ }
}
Added: trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestProxyCreationConstructed.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestProxyCreationConstructed.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestProxyCreationConstructed.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.store.service.proxy;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.TestException;
+import net.sf.joafip.heapfile.record.entity.DataRecordIdentifier;
+import net.sf.joafip.service.ClassLoaderProvider;
+import net.sf.joafip.store.entity.classinfo.ClassInfo;
+import net.sf.joafip.store.entity.objectio.ObjectAndPersistInfo;
+import net.sf.joafip.store.entity.objectio.StorageInfo;
+import net.sf.joafip.store.entity.proxy.BobCallInConstructor;
+import net.sf.joafip.store.service.classinfo.ClassInfoException;
+import net.sf.joafip.store.service.objectio.ObjectIOClassNotFoundException;
+import net.sf.joafip.store.service.objectio.ObjectIODataCorruptedException;
+import net.sf.joafip.store.service.objectio.ObjectIODataRecordNotFoundException;
+import net.sf.joafip.store.service.objectio.ObjectIOException;
+import net.sf.joafip.store.service.objectio.ObjectIOInvalidClassException;
+import net.sf.joafip.store.service.objectio.ObjectIONotSerializableException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class TestProxyCreationConstructed extends
+ AbstractObjectIoManagerForProxyTest {
+
+ private boolean inConstruction;
+
+ public TestProxyCreationConstructed() throws TestException {
+ super();
+ }
+
+ public TestProxyCreationConstructed(final String name) throws TestException {
+ super(name);
+ }
+
+ public void test() throws ClassInfoException, ProxyException {
+ final Class<?> objectClass = BobCallInConstructor.class;
+ final ClassInfo classInfo = classInfoFactory
+ .getNoProxyClassInfo(objectClass);
+ final ProxyManager2 proxyManager2 = new ProxyManager2(
+ new ClassLoaderProvider(), classInfoFactory);
+ final StorageInfo storageInfo = new StorageInfo(0);
+ inConstruction = true;
+ final BobCallInConstructor object = (BobCallInConstructor) proxyManager2
+ .newInstanceConstruct(classInfo,
+ new Class<?>[] { String.class },
+ new Object[] { "a name" }, storageInfo, this,
+ DataRecordIdentifier.LAST, true);
+ inConstruction = false;
+ assertTrue("must say is a proxy",
+ ProxyManager2.isProxyOrEnhanced(object));
+ assertTrue("must be loaded", ProxyManager2.isLoadedOrNotAProxy(object));
+ assertEquals("bad object proxied class", objectClass, proxyManager2
+ .classInfoOfObject(object).getObjectClass());
+ ProxyManager2.unload(object);
+ setted = false;
+ object.setName("a new name");
+ assertTrue(setted);
+ }
+
+ @Override
+ public boolean isAutoSaveEnabled() {
+ return true;
+ }
+
+ @Override
+ public void setProxyObjectState(
+ final ObjectAndPersistInfo objectAndItsClassInfo)
+ throws ObjectIOException, ObjectIODataRecordNotFoundException,
+ ObjectIOInvalidClassException, ObjectIOClassNotFoundException,
+ ObjectIODataCorruptedException, ObjectIONotSerializableException {
+ if (inConstruction) {
+ throw new ObjectIOException("in construction");
+ }
+ super.setProxyObjectState(objectAndItsClassInfo);
+ }
+}
Modified: trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PMapKeyNavigableSet.java
===================================================================
--- trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PMapKeyNavigableSet.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PMapKeyNavigableSet.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -57,7 +57,7 @@
this((IInstanceFactory) null, navigableMap);
}
- private PMapKeyNavigableSet(final IInstanceFactory instanceFactory,
+ protected PMapKeyNavigableSet(final IInstanceFactory instanceFactory,
final NavigableMap<K, V> navigableMap) {
super();
this.instanceFactory = instanceFactory;
@@ -83,6 +83,7 @@
return newInstance;
}
+ @StorableClass
private class EntrySetIterator implements Iterator<K> {
@AssertNotNull
@@ -119,8 +120,9 @@
.iterator());
} else {
entrySetIterator = (EntrySetIterator) instanceFactory.newInstance(
- EntrySetIterator.class, new Class[] { Iterator.class },
- new Object[] { navigableMap.entrySet().iterator() });
+ EntrySetIterator.class, new Class[] {
+ PMapKeyNavigableSet.class, Iterator.class },
+ new Object[] { this, navigableMap.entrySet().iterator() });
}
return entrySetIterator;
}
@@ -173,9 +175,12 @@
entrySetDescendingIterator = (EntrySetDescendingIterator) instanceFactory
.newInstance(
EntrySetDescendingIterator.class,
- new Class[] { Iterator.class },
- new Object[] { ((NavigableSet<Map.Entry<K, V>>) navigableMap
- .entrySet()).descendingIterator() });
+ new Class[] { PMapKeyNavigableSet.class,
+ Iterator.class },
+ new Object[] {
+ this,
+ ((NavigableSet<Map.Entry<K, V>>) navigableMap
+ .entrySet()).descendingIterator() });
}
return entrySetDescendingIterator;
}
Modified: trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -24,8 +24,10 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import net.sf.joafip.store.service.TestGarbageForegroundFile;
-import net.sf.joafip.store.service.collection.subs.TestStoreCollectionHashMapSubsNoG;
+import net.sf.joafip.service.rel300.TestSubstitutionWithMethodInterception0;
+import net.sf.joafip.service.rel300.TestSubstitutionWithMethodInterception1;
+import net.sf.joafip.service.rel300.TestSubstitutionWithMethodInterception2;
+import net.sf.joafip.service.rel400.TestAutoSave;
/**
*
@@ -42,8 +44,10 @@
public static Test suite() {
final TestSuite suite = new TestSuite("in error Tests");
// $JUnit-BEGIN$
- suite.addTestSuite(TestStoreCollectionHashMapSubsNoG.class);
- suite.addTestSuite(TestGarbageForegroundFile.class);
+ suite.addTestSuite(TestSubstitutionWithMethodInterception0.class);
+ suite.addTestSuite(TestSubstitutionWithMethodInterception1.class);
+ suite.addTestSuite(TestSubstitutionWithMethodInterception2.class);
+ suite.addTestSuite(TestAutoSave.class);
// suite.addTest(xxxx.suite());
// $JUnit-END$
return suite;
Modified: trunk/joafip-testsuite/src/main/java/net/sf/joafip/service/rel400/ServiceRel400Tests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/service/rel400/ServiceRel400Tests.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/service/rel400/ServiceRel400Tests.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -19,6 +19,7 @@
suite.addTestSuite(TestAutoSaveWithStatic.class);
suite.addTestSuite(TestStoredImmutableEnum.class);
suite.addTestSuite(TestFileManagementOptions.class);
+ suite.addTestSuite(TestConstructEntrySetIteratorOfPMapKeyNavigableSet.class);
// $JUnit-END$
return suite;
}
Modified: trunk/joafip-testsuite/src/main/java/net/sf/joafip/store/service/proxy/ProxyTests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/store/service/proxy/ProxyTests.java 2011-10-14 08:55:42 UTC (rev 2920)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/store/service/proxy/ProxyTests.java 2011-10-16 04:45:29 UTC (rev 2921)
@@ -27,12 +27,14 @@
final TestSuite suite = new TestSuite(
"Test for net.sf.joafip.store.service.proxy");
// $JUnit-BEGIN$
+ suite.addTestSuite(TestProxyAutoSave.class);
suite.addTestSuite(TestProxyCreation.class);
+ suite.addTestSuite(TestProxyCreationConstructed.class);
suite.addTestSuite(TestProxyFieldReflect.class);
+ suite.addTestSuite(TestProxyInterceptPackageVisibility.class);
suite.addTestSuite(TestProxyInterceptPrivate.class);
suite.addTestSuite(TestProxyInterceptProtected.class);
- suite.addTestSuite(TestProxyInterceptPackageVisibility.class);
- suite.addTestSuite(TestProxyAutoSave.class);
+ suite.addTestSuite(TestProxyManager2.class);
// $JUnit-END$
return suite;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|