Author: toad
Date: 2009-03-13 13:33:21 +0000 (Fri, 13 Mar 2009)
New Revision: 26016
Added:
trunk/contrib/db4o/src/db4oj/core/src/com/db4o/foundation/Listener.java
trunk/contrib/db4o/src/db4oj/core/src/com/db4o/foundation/ListenerRegistry.java
trunk/contrib/db4o/src/db4oj/core/src/com/db4o/internal/reflect/
trunk/contrib/db4o/src/db4oj/core/src/com/db4o/internal/reflect/generic/
trunk/contrib/db4o/src/db4oj/core/src/com/db4o/internal/reflect/generic/KnownClassesCollector.java
trunk/contrib/db4o/src/db4oj/core/src/com/db4o/reflect/generic/GenericObjectBase.java
trunk/contrib/db4o/src/db4oj/core/src/com/db4o/ta/ActivatableInstrumented.java
trunk/contrib/db4o/src/db4ojdk1.2/core/src/com/db4o/reflect/generic/
trunk/contrib/db4o/src/db4ojdk1.2/core/src/com/db4o/reflect/generic/GenericObject.java
trunk/contrib/db4o/src/db4ojdk1.2/test/src/com/db4o/db4ounit/common/migration/KnownClassesMigrationTestCase.java
trunk/contrib/db4o/src/db4ojdk1.2/test/src/com/db4o/db4ounit/jre12/assorted/UnavailableClassAsTreeSetElementTestCase.java
Log:
Missing files from db4o update!
Added: trunk/contrib/db4o/src/db4oj/core/src/com/db4o/foundation/Listener.java
===================================================================
--- trunk/contrib/db4o/src/db4oj/core/src/com/db4o/foundation/Listener.java
(rev 0)
+++ trunk/contrib/db4o/src/db4oj/core/src/com/db4o/foundation/Listener.java
2009-03-13 13:33:21 UTC (rev 26016)
@@ -0,0 +1,30 @@
+/* Copyright (C) 2004 - 2008 db4objects Inc. http://www.db4o.com
+
+This file is part of the db4o open source object database.
+
+db4o is free software; you can redistribute it and/or modify it under
+the terms of version 2 of the GNU General Public License as published
+by the Free Software Foundation and as clarified by db4objects' GPL
+interpretation policy, available at
+http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
+Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
+Suite 350, San Mateo, CA 94403, USA.
+
+db4o is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+package com.db4o.foundation;
+
+/**
+ * @exclude
+ */
+public interface Listener {
+
+ public void onEvent(Object event);
+
+}
Added:
trunk/contrib/db4o/src/db4oj/core/src/com/db4o/foundation/ListenerRegistry.java
===================================================================
---
trunk/contrib/db4o/src/db4oj/core/src/com/db4o/foundation/ListenerRegistry.java
(rev 0)
+++
trunk/contrib/db4o/src/db4oj/core/src/com/db4o/foundation/ListenerRegistry.java
2009-03-13 13:33:21 UTC (rev 26016)
@@ -0,0 +1,62 @@
+/* Copyright (C) 2004 - 2008 db4objects Inc. http://www.db4o.com
+
+This file is part of the db4o open source object database.
+
+db4o is free software; you can redistribute it and/or modify it under
+the terms of version 2 of the GNU General Public License as published
+by the Free Software Foundation and as clarified by db4objects' GPL
+interpretation policy, available at
+http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
+Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
+Suite 350, San Mateo, CA 94403, USA.
+
+db4o is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+package com.db4o.foundation;
+
+
+/**
+ * @exclude
+ */
+public class ListenerRegistry {
+
+ public static ListenerRegistry newInstance() {
+ return new ListenerRegistry();
+ }
+
+ private Collection4 _listeners;
+
+ public void register(Listener listener){
+ if(_listeners == null){
+ _listeners = new Collection4();
+ }
+ if (_listeners.containsByIdentity(listener)) {
+ return;
+ }
+
+ _listeners.add(listener);
+ }
+
+ public void notifyListeners(Object event){
+ if(_listeners == null){
+ return;
+ }
+ Iterator4 i = _listeners.iterator();
+ while(i.moveNext()){
+ ((Listener)i.current()).onEvent(event);
+ }
+ }
+
+ public void remove(Listener listener) {
+ if (_listeners == null) {
+ return;
+ }
+ _listeners.remove(listener);
+ }
+}
Added:
trunk/contrib/db4o/src/db4oj/core/src/com/db4o/internal/reflect/generic/KnownClassesCollector.java
===================================================================
---
trunk/contrib/db4o/src/db4oj/core/src/com/db4o/internal/reflect/generic/KnownClassesCollector.java
(rev 0)
+++
trunk/contrib/db4o/src/db4oj/core/src/com/db4o/internal/reflect/generic/KnownClassesCollector.java
2009-03-13 13:33:21 UTC (rev 26016)
@@ -0,0 +1,91 @@
+/* Copyright (C) 2004 - 2008 db4objects Inc. http://www.db4o.com
+
+This file is part of the db4o open source object database.
+
+db4o is free software; you can redistribute it and/or modify it under
+the terms of version 2 of the GNU General Public License as published
+by the Free Software Foundation and as clarified by db4objects' GPL
+interpretation policy, available at
+http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
+Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
+Suite 350, San Mateo, CA 94403, USA.
+
+db4o is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+package com.db4o.internal.reflect.generic;
+
+import com.db4o.foundation.*;
+import com.db4o.internal.*;
+import com.db4o.reflect.*;
+import com.db4o.reflect.generic.*;
+
+public class KnownClassesCollector {
+
+ private final ObjectContainerBase _container;
+ private final KnownClassesRepository _repository;
+
+ public KnownClassesCollector(ObjectContainerBase container,
KnownClassesRepository repository) {
+ _container = container;
+ _repository = repository;
+ }
+
+ public ReflectClass[] collect() {
+ Collection4 classes = new Collection4();
+ collectKnownClasses(classes);
+
+ return (ReflectClass[])classes.toArray(new
ReflectClass[classes.size()]);
+ }
+
+ private void collectKnownClasses(final Collection4 classes) {
+ final Listener collectingListener =
newCollectingClassListener(classes);
+ _repository.addListener(collectingListener);
+ try {
+ collectKnownClasses(classes,
Iterators.copy(_repository.classes()));
+ } finally {
+ _repository.removeListener(collectingListener);
+ }
+ }
+
+ private Listener newCollectingClassListener(final Collection4 classes) {
+ return new Listener() {
+ public void onEvent(Object addedClass) {
+ collectKnownClass(classes, (ReflectClass)
addedClass);
+ }
+ };
+ }
+
+ private void collectKnownClasses(Collection4 collector, Iterator4
knownClasses) {
+ while(knownClasses.moveNext()){
+ ReflectClass clazz = (ReflectClass) knownClasses.current();
+ collectKnownClass(collector, clazz);
+ }
+ }
+
+ private void collectKnownClass(Collection4 classes, ReflectClass clazz)
{
+ if(isInternalClass(clazz))
+ return;
+
+ if(isSecondClass(clazz))
+ return;
+
+ if(clazz.isArray())
+ return;
+
+ classes.add(clazz);
+ }
+
+ private boolean isInternalClass(ReflectClass clazz) {
+ return
_container._handlers.ICLASS_INTERNAL.isAssignableFrom(clazz);
+ }
+
+ private boolean isSecondClass(ReflectClass clazz) {
+ ClassMetadata clazzMeta =
_container.classMetadataForReflectClass(clazz);
+ return clazzMeta != null && clazzMeta.isSecondClass();
+ }
+}
Added:
trunk/contrib/db4o/src/db4oj/core/src/com/db4o/reflect/generic/GenericObjectBase.java
===================================================================
---
trunk/contrib/db4o/src/db4oj/core/src/com/db4o/reflect/generic/GenericObjectBase.java
(rev 0)
+++
trunk/contrib/db4o/src/db4oj/core/src/com/db4o/reflect/generic/GenericObjectBase.java
2009-03-13 13:33:21 UTC (rev 26016)
@@ -0,0 +1,68 @@
+/* Copyright (C) 2004 - 2008 db4objects Inc. http://www.db4o.com
+
+This file is part of the db4o open source object database.
+
+db4o is free software; you can redistribute it and/or modify it under
+the terms of version 2 of the GNU General Public License as published
+by the Free Software Foundation and as clarified by db4objects' GPL
+interpretation policy, available at
+http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
+Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
+Suite 350, San Mateo, CA 94403, USA.
+
+db4o is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+package com.db4o.reflect.generic;
+
+public class GenericObjectBase {
+
+ private final GenericClass _class;
+ private Object[] _values;
+
+ public GenericObjectBase(GenericClass clazz) {
+ _class = clazz;
+ }
+
+ private void ensureValuesInitialized() {
+ if(_values == null) {
+ _values = new Object[_class.getFieldCount()];
+ }
+ }
+
+ public void set(int index, Object value) {
+ ensureValuesInitialized();
+ _values[index]=value;
+ }
+
+ /**
+ *
+ * @param index
+ * @return the value of the field at index, based on the fields
obtained GenericClass.getDeclaredFields
+ */
+ public Object get(int index) {
+ ensureValuesInitialized();
+ return _values[index];
+ }
+
+ public String toString() {
+ if(_class == null){
+ return super.toString();
+ }
+ return _class.toString(cast());
+ }
+
+ private GenericObject cast() {
+ return (GenericObject)this;
+ }
+
+ public GenericClass getGenericClass() {
+ return _class;
+ }
+
+}
\ No newline at end of file
Added:
trunk/contrib/db4o/src/db4oj/core/src/com/db4o/ta/ActivatableInstrumented.java
===================================================================
---
trunk/contrib/db4o/src/db4oj/core/src/com/db4o/ta/ActivatableInstrumented.java
(rev 0)
+++
trunk/contrib/db4o/src/db4oj/core/src/com/db4o/ta/ActivatableInstrumented.java
2009-03-13 13:33:21 UTC (rev 26016)
@@ -0,0 +1,28 @@
+/* Copyright (C) 2004 - 2008 db4objects Inc. http://www.db4o.com
+
+This file is part of the db4o open source object database.
+
+db4o is free software; you can redistribute it and/or modify it under
+the terms of version 2 of the GNU General Public License as published
+by the Free Software Foundation and as clarified by db4objects' GPL
+interpretation policy, available at
+http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
+Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
+Suite 350, San Mateo, CA 94403, USA.
+
+db4o is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+package com.db4o.ta;
+
+/**
+ * Marker interface to declare a class already implements the required TA/TP
hooks
+ * and does not want to be instrumented further.
+ */
+public interface ActivatableInstrumented {
+}
Added:
trunk/contrib/db4o/src/db4ojdk1.2/core/src/com/db4o/reflect/generic/GenericObject.java
===================================================================
---
trunk/contrib/db4o/src/db4ojdk1.2/core/src/com/db4o/reflect/generic/GenericObject.java
(rev 0)
+++
trunk/contrib/db4o/src/db4ojdk1.2/core/src/com/db4o/reflect/generic/GenericObject.java
2009-03-13 13:33:21 UTC (rev 26016)
@@ -0,0 +1,35 @@
+/* Copyright (C) 2004 - 2008 db4objects Inc. http://www.db4o.com
+
+This file is part of the db4o open source object database.
+
+db4o is free software; you can redistribute it and/or modify it under
+the terms of version 2 of the GNU General Public License as published
+by the Free Software Foundation and as clarified by db4objects' GPL
+interpretation policy, available at
+http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
+Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
+Suite 350, San Mateo, CA 94403, USA.
+
+db4o is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+package com.db4o.reflect.generic;
+
+/**
+ * @exclude
+ */
+public class GenericObject extends GenericObjectBase implements Comparable {
+
+ public GenericObject(GenericClass clazz) {
+ super(clazz);
+ }
+
+ public int compareTo(Object ignored) {
+ return 0;
+ }
+}
Added:
trunk/contrib/db4o/src/db4ojdk1.2/test/src/com/db4o/db4ounit/common/migration/KnownClassesMigrationTestCase.java
===================================================================
---
trunk/contrib/db4o/src/db4ojdk1.2/test/src/com/db4o/db4ounit/common/migration/KnownClassesMigrationTestCase.java
(rev 0)
+++
trunk/contrib/db4o/src/db4ojdk1.2/test/src/com/db4o/db4ounit/common/migration/KnownClassesMigrationTestCase.java
2009-03-13 13:33:21 UTC (rev 26016)
@@ -0,0 +1,72 @@
+/* Copyright (C) 2004 - 2008 db4objects Inc. http://www.db4o.com
+
+This file is part of the db4o open source object database.
+
+db4o is free software; you can redistribute it and/or modify it under
+the terms of version 2 of the GNU General Public License as published
+by the Free Software Foundation and as clarified by db4objects' GPL
+interpretation policy, available at
+http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
+Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
+Suite 350, San Mateo, CA 94403, USA.
+
+db4o is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+package com.db4o.db4ounit.common.migration;
+
+import java.util.*;
+
+import com.db4o.config.*;
+import com.db4o.db4ounit.common.handlers.*;
+import com.db4o.ext.*;
+import com.db4o.foundation.*;
+import com.db4o.reflect.*;
+
+import db4ounit.*;
+
+/**
+ * @sharpen.ignore
+ * @decaf.ignore.jdk11
+ */
+public class KnownClassesMigrationTestCase extends FormatMigrationTestCaseBase
{
+
+ protected void assertObjectsAreReadable(ExtObjectContainer
objectContainer) {
+ if (isVersionWithoutTCollection())
+ return;
+
+ final ReflectClass[] knownClasses =
objectContainer.knownClasses();
+
+ Assert.isNotNull(knownClasses);
+ Assert.isGreater(2, knownClasses.length);
+
+ ReflectClass type =
objectContainer.reflector().forClass(TCollection.class);
+ Assert.isGreaterOrEqual(0, Arrays4.indexOf(knownClasses, type));
+ }
+
+ private boolean isVersionWithoutTCollection() {
+ return db4oMajorVersion() < 5;
+ }
+
+ protected String fileNamePrefix() {
+ return "KnownClasses";
+ }
+
+ protected void store(ExtObjectContainer objectContainer) {
+ objectContainer.set(new Item(new LinkedList()));
+ }
+
+ private static class Item {
+ public Item(LinkedList list) {
+ _list = list;
+ }
+
+ public LinkedList _list;
+ }
+
+}
Added:
trunk/contrib/db4o/src/db4ojdk1.2/test/src/com/db4o/db4ounit/jre12/assorted/UnavailableClassAsTreeSetElementTestCase.java
===================================================================
---
trunk/contrib/db4o/src/db4ojdk1.2/test/src/com/db4o/db4ounit/jre12/assorted/UnavailableClassAsTreeSetElementTestCase.java
(rev 0)
+++
trunk/contrib/db4o/src/db4ojdk1.2/test/src/com/db4o/db4ounit/jre12/assorted/UnavailableClassAsTreeSetElementTestCase.java
2009-03-13 13:33:21 UTC (rev 26016)
@@ -0,0 +1,77 @@
+/* Copyright (C) 2004 - 2008 db4objects Inc. http://www.db4o.com
+
+This file is part of the db4o open source object database.
+
+db4o is free software; you can redistribute it and/or modify it under
+the terms of version 2 of the GNU General Public License as published
+by the Free Software Foundation and as clarified by db4objects' GPL
+interpretation policy, available at
+http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
+Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
+Suite 350, San Mateo, CA 94403, USA.
+
+db4o is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+package com.db4o.db4ounit.jre12.assorted;
+
+import java.util.*;
+
+import com.db4o.*;
+import com.db4o.db4ounit.common.assorted.*;
+
+import db4ounit.*;
+
+public class UnavailableClassAsTreeSetElementTestCase extends
UnavailableClassTestCaseBase {
+
+ public static class Item implements Comparable {
+ private int _value;
+
+ public Item(int value) {
+ _value = value;
+ }
+
+ public int compareTo(Object o) {
+ return _value - ((Item)o)._value;
+ }
+ }
+
+ public static class Parent {
+ Set _items = new TreeSet();
+
+ public Parent(Item[] items) {
+ for (int i = 0; i < items.length; i++) {
+ _items.add(items[i]);
+ }
+ }
+ }
+
+ protected void store() throws Exception {
+ store(new Parent(new Item[] { new Item(-1), new Item(42) }));
+ }
+
+ public void testDefragment() throws Exception {
+ reopenHidingItemClass();
+ defragment();
+ }
+
+ private void reopenHidingItemClass() throws Exception {
+ reopenHidingClasses(new Class[] { Item.class });
+ }
+
+ public void testUnavailableItem() throws Exception {
+ reopenHidingItemClass();
+
+ final ObjectSet result = newQuery().execute();
+ Assert.areEqual(4, result.size());
+ while (result.hasNext()) {
+ Assert.isNotNull(result.next());
+ }
+ }
+
+}
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs