com.force.sdk.jpa
Class ForceStoreManager

java.lang.Object
  extended by org.datanucleus.store.AbstractStoreManager
      extended by com.force.sdk.jpa.ForceStoreManager
All Implemented Interfaces:
org.datanucleus.store.StoreManager

public class ForceStoreManager
extends org.datanucleus.store.AbstractStoreManager

The store manager that holds all of the persistence.xml properties.

Author:
Fiaz Hossain

Field Summary
static String FORCE_KEY
          Store manager type for Force.com JPA.
 
Fields inherited from class org.datanucleus.store.AbstractStoreManager
autoStartMechanism, connectionMgr, fixedDatastore, LOCALISER, nontxConnectionFactoryName, omfContext, persistenceHandler2, readOnlyDatastore, schemaHandler, starter, starterInitialised, storeDataMgr, storeManagerKey, storeManagerRuntime, txConnectionFactoryName, valueGenerationMgr
 
Constructor Summary
ForceStoreManager(org.datanucleus.ClassLoaderResolver clr, org.datanucleus.OMFContext omfContext)
          create a store manager for use with the Force.com API.
 
Method Summary
 TableImpl addTable(org.datanucleus.metadata.AbstractClassMetaData acmd, ForceManagedConnection mconn)
          register a table with the schema handler.
 TableImpl addVirtualTable(org.datanucleus.metadata.AbstractClassMetaData acmd)
          register a virtual table with the schema handler (a table not backed by an actual object but is still needed for JPA queries, e.g.
 void close()
          Release of resources.
 ForceManagedConnection createConnection()
          creates a ForceManagedConnection for connection to Force.com.
 ForceConnectorConfig getConfig()
           
 ForceMetaDataListener getMetaDataListener()
           
 org.datanucleus.store.NucleusConnection getNucleusConnection(org.datanucleus.store.ExecutionContext om)
           
 int getPoolMinEvictableIdleTimeMillis()
           
 int getPoolTimeBetweenEvictionRunsMillis()
           
 ForceSchemaWriter getSchemaWriter()
           
 Collection getSupportedOptions()
          Accessor for the supported options in string form.
 TableImpl getTable(org.datanucleus.metadata.AbstractClassMetaData acmd)
          Retrieves Force.com table information from JPA class metadata.
 boolean isAutoCreateColumns()
          Whether fields should be created automatically on app startup.
 boolean isAutoCreateTables()
          Whether objects should be created automatically on app startup.
 boolean isAutoCreateWarnOnError()
          Used for schema mismatches, e.g.
 boolean isEnableOptimisticTransactions()
          Whether optimistic locking is enabled for this persistence unit.
 boolean isForDelete()
          whether this application has been started up with the flag to delete schema rather than create/upsert it.
 boolean isSchemaCreateClient()
          This is a flag for clients that can create schema to set.
protected  void registerConnectionMgr()
           
 
Methods inherited from class org.datanucleus.store.AbstractStoreManager
addClass, addClasses, assertReadOnlyForUpdateOfObject, clearAutoStarter, deregisterAllStoreData, getApiAdapter, getBackingStoreForField, getClassNameForObjectID, getConnection, getConnection, getConnection, getConnectionDriverName, getConnectionFactory, getConnectionFactory2, getConnectionFactory2Name, getConnectionFactoryName, getConnectionManager, getConnectionPassword, getConnectionURL, getConnectionUserName, getDatastoreDate, getExtent, getMetaDataManager, getNucleusSequence, getOMFContext, getPersistenceHandler, getPropertiesForGenerator, getQueryCacheKey, getRuntimeManager, getSchemaHandler, getStoreManagerKey, getStrategyForNative, getStrategyValue, getStrategyValueForGenerator, getSubClassesForClass, getValueGenerationManager, initialiseAutoStart, isStrategyDatastoreAttributed, logConfiguration, manageClassForIdentity, managesClass, newStoreData, notifyObjectIsOutdated, performVersionCheck, printInformation, registerConnectionFactory, registerStoreData, removeAllClasses, supportsQueryLanguage, supportsValueStrategy, transactionCommitted, transactionRolledBack, transactionStarted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORCE_KEY

public static final String FORCE_KEY
Store manager type for Force.com JPA.

See Also:
Constant Field Values
Constructor Detail

ForceStoreManager

public ForceStoreManager(org.datanucleus.ClassLoaderResolver clr,
                         org.datanucleus.OMFContext omfContext)
                  throws NoSuchFieldException,
                         IllegalAccessException
create a store manager for use with the Force.com API. Setup the API connection configs, set some default properties and read in values from persistence.xml

Parameters:
clr - the class loader resolver
omfContext - the corresponding object manager factory context
Throws:
NoSuchFieldException - thrown if there is a problem setting up the plugin manager
IllegalAccessException - thrown if there is a problem setting up the plugin manager
Method Detail

registerConnectionMgr

protected void registerConnectionMgr()
Overrides:
registerConnectionMgr in class org.datanucleus.store.AbstractStoreManager

getConfig

public ForceConnectorConfig getConfig()

close

public void close()
Release of resources.

Specified by:
close in interface org.datanucleus.store.StoreManager
Overrides:
close in class org.datanucleus.store.AbstractStoreManager

getNucleusConnection

public org.datanucleus.store.NucleusConnection getNucleusConnection(org.datanucleus.store.ExecutionContext om)
Specified by:
getNucleusConnection in interface org.datanucleus.store.StoreManager
Overrides:
getNucleusConnection in class org.datanucleus.store.AbstractStoreManager

getSupportedOptions

public Collection getSupportedOptions()
Accessor for the supported options in string form.

Specified by:
getSupportedOptions in interface org.datanucleus.store.StoreManager
Overrides:
getSupportedOptions in class org.datanucleus.store.AbstractStoreManager

isAutoCreateColumns

public boolean isAutoCreateColumns()
Whether fields should be created automatically on app startup.

Returns:
true if fields should be created

isAutoCreateTables

public boolean isAutoCreateTables()
Whether objects should be created automatically on app startup.

Returns:
true if objects should be created

isAutoCreateWarnOnError

public boolean isAutoCreateWarnOnError()
Used for schema mismatches, e.g. a column or table are specified in an application, the column or table does not exist in the Force.com organization, and schema creation is turned OFF for field or columns. Value defaults to false but can be set in persistence.xml, if true warnings will be logged, exceptions will not be thrown.

Returns:
true if schema mismatches should log warnings, false if they should throw errors

getPoolMinEvictableIdleTimeMillis

public int getPoolMinEvictableIdleTimeMillis()

getPoolTimeBetweenEvictionRunsMillis

public int getPoolTimeBetweenEvictionRunsMillis()

getTable

public TableImpl getTable(org.datanucleus.metadata.AbstractClassMetaData acmd)
Retrieves Force.com table information from JPA class metadata.

Parameters:
acmd - JPA class metadata
Returns:
Force.com table information

addTable

public TableImpl addTable(org.datanucleus.metadata.AbstractClassMetaData acmd,
                          ForceManagedConnection mconn)
register a table with the schema handler.

Parameters:
acmd - the class metadata of the table to register
mconn - the managed connection to the Force.com APIs
Returns:
the created TableImpl for this object

addVirtualTable

public TableImpl addVirtualTable(org.datanucleus.metadata.AbstractClassMetaData acmd)
register a virtual table with the schema handler (a table not backed by an actual object but is still needed for JPA queries, e.g. Owner)

Parameters:
acmd - the class metadata of the virtual table to regsiter
Returns:
the TableImpl for this object

isEnableOptimisticTransactions

public boolean isEnableOptimisticTransactions()
Whether optimistic locking is enabled for this persistence unit. Optimistic transactions prevent two separate transactions from updating the same record at the same time, thus overwriting one transaction's update

Returns:
true if optimistic transactions are enabled

getMetaDataListener

public ForceMetaDataListener getMetaDataListener()

createConnection

public ForceManagedConnection createConnection()
creates a ForceManagedConnection for connection to Force.com.

Returns:
the created managed connection to Force.com

getSchemaWriter

public ForceSchemaWriter getSchemaWriter()

isForDelete

public boolean isForDelete()
whether this application has been started up with the flag to delete schema rather than create/upsert it.

Returns:
true if this application should delete schema

isSchemaCreateClient

public boolean isSchemaCreateClient()
This is a flag for clients that can create schema to set. Users would not be setting this flag themselves

Returns:
true if the schema creation call is being made by a client (like CLIforce)


Copyright © 2011. All Rights Reserved.