HOWTO Support A New Datastore
The process of adding support for a new datastore is simple in concept. It has particular components that can be supported or not. You dont have to support everything at once. The following gives guidelines on how to do it
- Is there a supported datastore that is similar in terms of its access ? If so, copy the existing datastore plugin (renaming packages etc). For example to support another OODB, you could take the datanucleus-db4o plugin as a start point. Develop the XXXStoreManager class. You are recommended to extend org.datanucleus.store.AbstractStoreManager. Make sure you specify the getSupportedOptions() method specifying what is supported
- Develop the ConnectionFactoryImpl. This provides connectivity to the datastore. If the datastore has a simple connection that you open then commit then this file will be very simple. Again, copy an existing one if there is something suitable. You are recommended to extend org.datanucleus.store.connection.AbstractConnectionFactory
- Develop the PersistenceHandler. This provides the capability to do insert/update/delete/fetch/locate and so provides support for persistence to this datastore. You are recommended to extend org.datanucleus.store.AbstractPersistenceHandler
- Does your datastore support the concept of a schema ? i.e you need to create some table in the datastore to store objects in? If so then you should implement the SchemaHandler. You are recommended to extend org.datanucleus.store.schema.AbstractStoreSchemaHandler
- Develop the JDOQL support. Make use of the org.datanucleus.query classes. You need to decide how much of the query can be embodied in the native query language of the datastore. If you cant support some feature in the datastore native language then use the in-memory query evaluation
- Add on support for other features like inheritance strategy, discriminators, version checks, type converters as they are required.
As a guide, the basic connection, persistence could maybe be done in 2-4 days supporting complete-table only. To provide JDOQL in-memory capability, you could do that in very short time also since the in-memory evaluator is done and the only thing you need to do is retrieve the candidate objects (of the candidate type). To provide JDOQL in-datastore capability would take longer, how much would depend on the native query language structure for your datastore. Supporting things like other inheritance strategies may take significantly longer depending in the datastore.