Skip to content
Permalink
Browse files

git-svn-id: https://svn.origo.ethz.ch/zoodb/trunk@1 b278144e-e56a-474…

…8-98cb-974f122dab01
  • Loading branch information
tilmann
tilmann committed Sep 15, 2010
0 parents commit 38eec908429f0fa48d2caacd1697e5c3f5377248
Showing with 19,921 additions and 0 deletions.
  1. +280 −0 org/zoodb/jdo/AbstractPersistenceManagerFactory.java
  2. +97 −0 org/zoodb/jdo/ExtentImpl.java
  3. +42 −0 org/zoodb/jdo/ExtentIterator.java
  4. +23 −0 org/zoodb/jdo/JDOConnectionImpl.java
  5. +36 −0 org/zoodb/jdo/JDOConstants.java
  6. +369 −0 org/zoodb/jdo/PersistenceManagerFactoryImpl.java
  7. +823 −0 org/zoodb/jdo/PersistenceManagerImpl.java
  8. +548 −0 org/zoodb/jdo/QueryImpl.java
  9. +605 −0 org/zoodb/jdo/QueryParser.java
  10. +209 −0 org/zoodb/jdo/TransactionImpl.java
  11. +102 −0 org/zoodb/jdo/ZooExtentCollection.java
  12. +75 −0 org/zoodb/jdo/api/DBHashtable.java
  13. +8 −0 org/zoodb/jdo/api/DBLargeVector.java
  14. +10 −0 org/zoodb/jdo/api/DBParentAware.java
  15. +128 −0 org/zoodb/jdo/api/DBVector.java
  16. +49 −0 org/zoodb/jdo/api/Schema.java
  17. +125 −0 org/zoodb/jdo/custom/DataStoreManager.java
  18. +258 −0 org/zoodb/jdo/custom/DataStoreManagerOneFile.java
  19. +7 −0 org/zoodb/jdo/custom/JDOAuthenticationException.java
  20. +64 −0 org/zoodb/jdo/custom/ZooJdoProperties.java
  21. +8 −0 org/zoodb/jdo/internal/Config.java
  22. +46 −0 org/zoodb/jdo/internal/Connection.java
  23. +771 −0 org/zoodb/jdo/internal/DataDeSerializer.java
  24. +568 −0 org/zoodb/jdo/internal/DataSerializer.java
  25. +11 −0 org/zoodb/jdo/internal/DataStoreHandler.java
  26. +14 −0 org/zoodb/jdo/internal/DatabaseLogger.java
  27. +356 −0 org/zoodb/jdo/internal/DirectOutputStream.java
  28. +64 −0 org/zoodb/jdo/internal/ISchema.java
  29. +52 −0 org/zoodb/jdo/internal/Node.java
  30. +412 −0 org/zoodb/jdo/internal/ObjectGraphTraverser.java
  31. +336 −0 org/zoodb/jdo/internal/ObjectIdentitySet.java
  32. +43 −0 org/zoodb/jdo/internal/OidBuffer.java
  33. +5 −0 org/zoodb/jdo/internal/PageAccess.java
  34. +16 −0 org/zoodb/jdo/internal/PropagationCorruptedException.java
  35. +34 −0 org/zoodb/jdo/internal/SerialInput.java
  36. +36 −0 org/zoodb/jdo/internal/SerialOutput.java
  37. +130 −0 org/zoodb/jdo/internal/Serializer.java
  38. +198 −0 org/zoodb/jdo/internal/Session.java
  39. +21 −0 org/zoodb/jdo/internal/TxAPI.java
  40. +44 −0 org/zoodb/jdo/internal/User.java
  41. +35 −0 org/zoodb/jdo/internal/Util.java
  42. +99 −0 org/zoodb/jdo/internal/VersantClassTools.java
  43. +116 −0 org/zoodb/jdo/internal/ZooClassDef.java
  44. +39 −0 org/zoodb/jdo/internal/ZooFactory.java
  45. +56 −0 org/zoodb/jdo/internal/ZooFieldDef.java
  46. +26 −0 org/zoodb/jdo/internal/client/AbstractCache.java
  47. +173 −0 org/zoodb/jdo/internal/client/CachedObject.java
  48. +157 −0 org/zoodb/jdo/internal/client/SchemaManager.java
  49. +235 −0 org/zoodb/jdo/internal/client/session/ClientSessionCache.java
  50. +12 −0 org/zoodb/jdo/internal/model1p/Connection1P.java
  51. +14 −0 org/zoodb/jdo/internal/model1p/Factory1P.java
  52. +187 −0 org/zoodb/jdo/internal/model1p/Node1P.java
  53. +18 −0 org/zoodb/jdo/internal/model1p/OidBuffer1P.java
  54. +41 −0 org/zoodb/jdo/internal/server/DiskAccess.java
  55. +678 −0 org/zoodb/jdo/internal/server/DiskAccessOneFile.java
  56. +38 −0 org/zoodb/jdo/internal/server/PageAccessFile.java
  57. +367 −0 org/zoodb/jdo/internal/server/PageAccessFile_BB.java
  58. +329 −0 org/zoodb/jdo/internal/server/PageAccessFile_MappedBB.java
  59. +283 −0 org/zoodb/jdo/internal/server/PageAccessFile_NoBuf.java
  60. +334 −0 org/zoodb/jdo/internal/server/PagedObjectAccess.java
  61. +27 −0 org/zoodb/jdo/internal/server/index/AbstractIndex.java
  62. +448 −0 org/zoodb/jdo/internal/server/index/AbstractPagedIndex.java
  63. +76 −0 org/zoodb/jdo/internal/server/index/GlobalPageCache.java
  64. +166 −0 org/zoodb/jdo/internal/server/index/ObjectIndex.java
  65. +191 −0 org/zoodb/jdo/internal/server/index/OidIndex.java
  66. +235 −0 org/zoodb/jdo/internal/server/index/PagedOidIndex.java
  67. +675 −0 org/zoodb/jdo/internal/server/index/PagedOidIndex_OLD.java
  68. +784 −0 org/zoodb/jdo/internal/server/index/PagedUniqueLongLong.java
  69. +231 −0 org/zoodb/jdo/internal/server/index/SchemaIndex.java
  70. +522 −0 org/zoodb/jdo/spi/PersistenceCapableImpl.java
  71. +397 −0 org/zoodb/jdo/spi/StateManagerImpl.java
  72. +48 −0 org/zoodb/jdo/stuff/Debug.java
  73. +275 −0 org/zoodb/jdo/stuff/FormattedStringBuilder.java
  74. +551 −0 org/zoodb/jdo/stuff/TransientField.java
  75. +1,030 −0 org/zoodb/jdo/stuff/WeakIdentityHashMap.java
  76. +5 −0 org/zoodb/test/AllTest.java
  77. +327 −0 org/zoodb/test/PageAccessFileMock.java
  78. +142 −0 org/zoodb/test/PerfByteArray.java
  79. +111 −0 org/zoodb/test/PerfExceptionHandling.java
  80. +98 −0 org/zoodb/test/TestClass.java
  81. +104 −0 org/zoodb/test/TestTools.java
  82. +133 −0 org/zoodb/test/Test_010_DbAdmin.java
  83. +85 −0 org/zoodb/test/Test_020_Session.java
  84. +224 −0 org/zoodb/test/Test_030_Schema.java
  85. +140 −0 org/zoodb/test/Test_040_Transactions.java
  86. +382 −0 org/zoodb/test/Test_050_ObjectCreation.java
  87. +142 −0 org/zoodb/test/Test_060_Extents.java
  88. +164 −0 org/zoodb/test/Test_070_Query.java
  89. +718 −0 org/zoodb/test/Test_071_QueryExamples.java
  90. +84 −0 org/zoodb/test/Test_072_PolePosBarcelonaDelete.java
  91. +154 −0 org/zoodb/test/Test_072_PolePosBarcelonaQuery.java
  92. +27 −0 org/zoodb/test/data/CheckSummable.java
  93. +44 −0 org/zoodb/test/data/JB0.java
  94. +43 −0 org/zoodb/test/data/JB1.java
  95. +42 −0 org/zoodb/test/data/JB2.java
  96. +44 −0 org/zoodb/test/data/JB3.java
  97. +75 −0 org/zoodb/test/data/JB4.java
  98. +117 −0 org/zoodb/test/data/JdoIndexedPilot.java
  99. +117 −0 org/zoodb/test/data/JdoPilot.java
  100. +81 −0 org/zoodb/test/data/JdoTree.java
  101. +26 −0 org/zoodb/test/data/JdoTreeVisitor.java
  102. +324 −0 org/zoodb/test/server/TestOidIndex.java
  103. +8 −0 org/zoodb/test/test_071/Department.java
  104. +7 −0 org/zoodb/test/test_071/EmpInfo.java
  105. +5 −0 org/zoodb/test/test_071/EmpWrapper.java
  106. +20 −0 org/zoodb/test/test_071/Employee.java
  107. +12 −0 org/zoodb/test/test_071/Info.java
@@ -0,0 +1,280 @@
/*
* $Id: AbstractPersistenceManagerFactory.java,v 1.2 2008/03/26 13:21:43 tzaeschk Exp $
*
* Copyright (c) 2002 European Space Agency
*/
package org.zoodb.jdo;

import java.util.Properties;

import javax.jdo.Constants;
import javax.jdo.JDOUserException;
import javax.jdo.PersistenceManagerFactory;


/**
* This class simulates the JDO PersistenceManagerFactory
*
* @author Tilmann Zaeschke
*/
public abstract class AbstractPersistenceManagerFactory
implements PersistenceManagerFactory, Cloneable {

//See JDO 2.0 Chapter 11, p87
// /** <code>OPTION_CONNECTION_URL</code> =
// * "javax.jdo.option.ConnectionURL"*/
//public static final String OPTION_CONNECTION_URL =
// "javax.jdo.option.ConnectionURL";

// /** <code>OPTION_RETAIN_VALUES</code> =
// * "javax.jdo.option.RetainValues"*/
// public static final String OPTION_RETAIN_VALUES =
// "javax.jdo.option.RetainValues";

// public static final String OPTION_USERNAME =
// "javax.jdo.option.ConnectionUserName";
// public static final String OPTION_PASSWORD =
// "javax.jdo.option.ConnectionPassword";

private static final long serialVersionUID = 1L;


//standard properties
private boolean _isOptimistic = false;
private boolean _isRetainValues = false;
private boolean _isAutoJoinThreads = false;
private String _userName = null;
private transient String _password = null;
private String _database = null;

private boolean _nonTransactionalRead = false;

//Non-standard properties.
//private boolean _isReadOnly = false; //now in JDO 2.2
private String _sessionName = null;
private int _loidAllocation = 50;

private boolean _isFrozen = false;

/**
* @param props
*/
public AbstractPersistenceManagerFactory(Properties props) {
/*
• "javax.jdo.option.Optimistic"
• "javax.jdo.option.RetainValues"
• "javax.jdo.option.RestoreValues"
• "javax.jdo.option.IgnoreCache"
• "javax.jdo.option.NontransactionalRead"
• "javax.jdo.option.NontransactionalWrite"
• "javax.jdo.option.Multithreaded"
• "javax.jdo.option.DetachAllOnCommit"
• "javax.jdo.option.CopyOnAttach"
• "javax.jdo.option.ConnectionUserName"
• "javax.jdo.option.ConnectionPassword"
• "javax.jdo.option.ConnectionURL"
• "javax.jdo.option.ConnectionDriverName"
• "javax.jdo.option.ConnectionFactoryName"
• "javax.jdo.option.ConnectionFactory2Name"
• "javax.jdo.option.Mapping"
• "javax.jdo.mapping.Catalog"
• "javax.jdo.mapping.Schema"
• "javax.jdo.option.TransactionType"
• "javax.jdo.option.ServerTimeZoneID"
• "javax.jdo.option.ReadOnly"
The following two properties are only used in the props, not in the overrides.
• "javax.jdo.option.Name"
• "javax.jdo.option.PersistenceUnitName"
The property "javax.jdo.PersistenceManagerFactoryClass"
*/
for (Object keyO: props.keySet()) {
String key = (String) keyO;
if (Constants.PROPERTY_OPTIMISTIC.equals(key)) {
_isOptimistic = Boolean.parseBoolean(props.getProperty(key));
} else if (Constants.PROPERTY_RETAIN_VALUES.equals(key)) {
System.out.println("STUB: Property not supported: " + key + "=" + props.get(key)); //TODO
} else if (Constants.PROPERTY_RESTORE_VALUES.equals(key)) {
System.out.println("STUB: Property not supported: " + key + "=" + props.get(key)); //TODO
} else if (Constants.PROPERTY_IGNORE_CACHE.equals(key)) {
System.out.println("STUB: Property not supported: " + key + "=" + props.get(key)); //TODO
} else if (Constants.PROPERTY_NONTRANSACTIONAL_READ.equals(key)) {
System.out.println("STUB: Property not supported: " + key + "=" + props.get(key)); //TODO
_nonTransactionalRead = Boolean.parseBoolean(props.getProperty(key));
} else if (Constants.PROPERTY_NONTRANSACTIONAL_WRITE.equals(key)) {
System.out.println("STUB: Property not supported: " + key + "=" + props.get(key)); //TODO
} else if (Constants.PROPERTY_MULTITHREADED.equals(key)) {
System.out.println("STUB: Property not supported: " + key + "=" + props.get(key)); //TODO
} else if (Constants.PROPERTY_DETACH_ALL_ON_COMMIT.equals(key)) {
System.out.println("STUB: Property not supported: " + key + "=" + props.get(key)); //TODO
} else if (Constants.PROPERTY_COPY_ON_ATTACH.equals(key)) {
System.out.println("STUB: Property not supported: " + key + "=" + props.get(key)); //TODO
} else if (Constants.PROPERTY_CONNECTION_USER_NAME.equals(key)) {
_userName = props.getProperty(key);
} else if (Constants.PROPERTY_CONNECTION_PASSWORD.equals(key)) {
_password = props.getProperty(key);
} else if (Constants.PROPERTY_CONNECTION_URL.equals(key)) {
_database = props.getProperty(key);
} else if (Constants.PROPERTY_CONNECTION_DRIVER_NAME.equals(key)) {
System.out.println("STUB: Property not supported: " + key + "=" + props.get(key)); //TODO
} else if (Constants.PROPERTY_CONNECTION_FACTORY_NAME.equals(key)) {
System.out.println("STUB: Property not supported: " + key + "=" + props.get(key)); //TODO
} else if (Constants.PROPERTY_CONNECTION_FACTORY2_NAME.equals(key)) {
System.out.println("STUB: Property not supported: " + key + "=" + props.get(key)); //TODO
} else if (Constants.PROPERTY_MAPPING.equals(key)) {
System.out.println("STUB: Property not supported: " + key + "=" + props.get(key)); //TODO
} else if (Constants.PROPERTY_MAPPING_CATALOG.equals(key)) {
System.out.println("STUB: Property not supported: " + key + "=" + props.get(key)); //TODO
} else if (Constants.PROPERTY_MAPPING_SCHEMA.equals(key)) {
System.out.println("STUB: Property not supported: " + key + "=" + props.get(key)); //TODO
} else if ("javax.jdo.option.TransactionType".equals(key)) {
System.out.println("STUB: Property not supported: " + key + "=" + props.get(key)); //TODO
} else if (Constants.PROPERTY_SERVER_TIME_ZONE_ID.equals(key)) {
System.out.println("STUB: Property not supported: " + key + "=" + props.get(key)); //TODO
} else if (Constants.PROPERTY_READONLY.equals(key)) {
System.out.println("STUB: Property not supported: " + key + "=" + props.get(key)); //TODO

//The following two properties are only used in the props, not in the overrides.
} else if (Constants.PROPERTY_NAME.equals(key)) {
_sessionName = props.getProperty(key);
} else if (Constants.PROPERTY_PERSISTENCE_UNIT_NAME.equals(key)) {
_sessionName = props.getProperty(key);
// } else if ("options".equals(key)) {
// String opt = props.getProperty(key);
// if ("0".equals(opt)) {
//
// } else {
// throw new IllegalArgumentException("o=" + opt);
// }
} else if (Constants.PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS .equals(key)) {
//ignore
} else {
//throw new IllegalArgumentException("Unknown key: " + key);
System.err.println("Property not recognised: " + key + "=" + props.getProperty(key));
}
}
}

/**
* Freezes the properties of this factory. Should be called from any method
* that creates a PersistenceManager.
*/
protected void setFrozen() {
_isFrozen = true;
}

/**
* Throws a JDOUserException if this factories properties are frozen.
* Should be called from every set-method.
*/
protected void checkFrozen() {
if (_isFrozen) {
//TODO is this the correct exception?
throw new JDOUserException("This factory can't be modified.");
}
}

/**
* @see org.zoodb.jdo.oldStuff.PersistenceManagerFactory
* #getRetainValues()
*/
public boolean getRetainValues() {
return _isRetainValues;
}

/**
* @see org.zoodb.jdo.oldStuff.PersistenceManagerFactory
* #setRetainValues(boolean)
*/
public void setRetainValues(boolean flag) {
checkFrozen();
_isRetainValues = flag;
}

public String getConnectionUserName() {
return _userName;
}

protected String getConnectionPassword() {
return _password;
}

@Override
public boolean getOptimistic() {
return _isOptimistic;
}

@Override
public boolean getNontransactionalRead() {
return _nonTransactionalRead;
}

public void setConnectionPassword(String password) {
checkFrozen();
_password = password;
}

public void setConnectionUserName(String userName) {
checkFrozen();
_userName = userName;
}

public void setOptimistic(boolean flag) {
checkFrozen();
_isOptimistic = flag;
}

public String getConnectionURL() {
return _database;
}

public void setConnectionURL(String url) {
checkFrozen();
_database = url;
}

public String getSessionName() {
return _sessionName;
}

public void setSessionName(String sessionName) {
checkFrozen();
_sessionName = sessionName;
}

public int getLoidAllocation() {
return _loidAllocation;
}

public void setLoidAllocation(int size) {
checkFrozen(); //is this check required?
_loidAllocation = size;
}

public boolean getAutoJoinThreads() {
return _isAutoJoinThreads;
}

public void setAutoJoinThreads(boolean flag) {
_isAutoJoinThreads = flag;
}

public Object clone() {
AbstractPersistenceManagerFactory obj;
try {
obj = (AbstractPersistenceManagerFactory) super.clone();
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}

obj._isFrozen = false; //Allow modification of cloned object
obj.setConnectionPassword(getConnectionPassword());
obj.setConnectionURL(getConnectionURL());
obj.setConnectionUserName(getConnectionUserName());
obj.setLoidAllocation(getLoidAllocation());
obj.setOptimistic(getOptimistic());
obj.setReadOnly(getReadOnly());
obj.setRetainValues(getRetainValues());
obj.setSessionName(null); //Force creation of a new name
return obj;
}
}
@@ -0,0 +1,97 @@
package org.zoodb.jdo;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import javax.jdo.Extent;
import javax.jdo.FetchPlan;
import javax.jdo.PersistenceManager;

/**
* This class implements JDO behavior for the class Extend.
* @param <T>
*
* @author Tilmann Zäschke
*/
public class ExtentImpl<T> implements Extent<T> {

private final Class<T> _class;
private final boolean _subclasses;
private final List<ExtentIterator<T>> _allIterators = new LinkedList<ExtentIterator<T>>();
private final PersistenceManagerImpl _pManager;
private final Class<?> _minClass;

/**
* @param persistenceCapableClass
* @param subclasses
* @param pm
*/
public ExtentImpl(Class<T> persistenceCapableClass,
boolean subclasses, PersistenceManagerImpl pm, Class<?> minClass) {
_class = persistenceCapableClass;
_subclasses = subclasses;
_pManager = pm;
_minClass = minClass;
}

/**
* @see org.zoodb.jdo.oldStuff.Extent#iterator()
*/
public Iterator<T> iterator() {
Iterator<T> it =
_pManager.getSession().loadAllInstances(_class, _subclasses, _minClass).iterator();
ExtentIterator<T> eIt = new ExtentIterator<T>(it);
_allIterators.add(eIt);
return eIt;
}

/**
* @see org.zoodb.jdo.oldStuff.Extent#close(java.util.Iterator)
*/
public void close(Iterator<T> i) {
ExtentIterator.class.cast(i).close();
_allIterators.remove(i);
}

/**
* @see org.zoodb.jdo.oldStuff.Extent#closeAll()
*/
public void closeAll() {
for (ExtentIterator<T> i: _allIterators) {
i.close();
}
_allIterators.clear();
}

/**
* @see org.zoodb.jdo.oldStuff.Extent#hasSubclasses()
*/
public boolean hasSubclasses() {
return _subclasses;
}

/**
* @see org.zoodb.jdo.oldStuff.Extent#getPersistenceManager()
*/
public PersistenceManager getPersistenceManager() {
return _pManager;
}

@Override
protected void finalize() throws Throwable {
closeAll();
super.finalize();
}

@Override
public Class<T> getCandidateClass() {
return _class;
}

@Override
public FetchPlan getFetchPlan() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException();
}
}

0 comments on commit 38eec90

Please sign in to comment.
You can’t perform that action at this time.