public void prePersist(Object pc) { validate(pc,getGroups(conf.getStringProperty("javax.persistence.validation.group.pre-persist"))); }
boolean autoCreateSchema = conf.getBooleanProperty("datanucleus.autoCreateSchema"); if (autoCreateSchema) { autoCreateTables = true; autoCreateColumns = true; } else { autoCreateTables = conf.getBooleanProperty("datanucleus.autoCreateTables"); autoCreateColumns = conf.getBooleanProperty("datanucleus.autoCreateColumns"); autoCreateWarnOnError = conf.getBooleanProperty("datanucleus.autoCreateWarnOnError"); forDelete = conf.getBooleanProperty("force.deleteSchema"); boolean purgeOnDelete = conf.getBooleanProperty("force.purgeOnDeleteSchema"); poolTimeBetweenEvictionRunsMillis = conf.getIntProperty("datanucleus.connectionPool.timeBetweenEvictionRunsMillis"); if (poolTimeBetweenEvictionRunsMillis == 0) { poolTimeBetweenEvictionRunsMillis = 15 * 1000; // default, 15 secs poolMinEvictableIdleTimeMillis = conf.getIntProperty("datanucleus.connectionPool.minEvictableIdleTimeMillis"); if (poolMinEvictableIdleTimeMillis == 0) { poolMinEvictableIdleTimeMillis = 30 * 1000; // default, 30 secs Object isEnabled = omfContext.getPersistenceConfiguration().getProperty("datanucleus.Optimistic"); enableOptimisticTransactions = isEnabled != null && (isEnabled instanceof Boolean && isEnabled.equals(Boolean.TRUE) || isEnabled instanceof String && "true".equals(isEnabled));
if (conf.hasProperty("datanucleus.connectionPool.maxIdle")) int value = conf.getIntProperty("datanucleus.connectionPool.maxIdle"); if (value > 0) if (conf.hasProperty("datanucleus.connectionPool.minIdle")) int value = conf.getIntProperty("datanucleus.connectionPool.minIdle"); if (value > 0) if (conf.hasProperty("datanucleus.connectionPool.maxActive")) int value = conf.getIntProperty("datanucleus.connectionPool.maxActive"); if (value > 0) if (conf.hasProperty("datanucleus.connectionPool.maxWait")) int value = conf.getIntProperty("datanucleus.connectionPool.maxWait"); if (value > 0) if (conf.hasProperty("datanucleus.connectionPool.timeBetweenEvictionRunsMillis")) int value = conf.getIntProperty("datanucleus.connectionPool.timeBetweenEvictionRunsMillis"); if (value > 0) if (conf.hasProperty("datanucleus.connectionPool.minEvictableIdleTimeMillis")) int value = conf.getIntProperty("datanucleus.connectionPool.minEvictableIdleTimeMillis"); if (value > 0)
/** * Constructs a connection factory for the datastore. * Provides ManagedConnections to communicate with the datastore. * * @param storeMgr The store manager * @param resourceType Name of the resource ("appengine", "appengine-nontx") */ public DatastoreConnectionFactoryImpl(StoreManager storeMgr, String resourceType) { super(storeMgr, resourceType); PersistenceConfiguration conf = storeMgr.getNucleusContext().getPersistenceConfiguration(); if (conf.getProperty(DatastoreConnectionFactoryImpl.AUTO_CREATE_TXNS_PROPERTY) == null) { // User hasn't configured the "auto-create" property, so set it conf.setProperty(DatastoreConnectionFactoryImpl.AUTO_CREATE_TXNS_PROPERTY, Boolean.TRUE.toString()); } this.isAutoCreateTransaction = conf.getBooleanProperty(AUTO_CREATE_TXNS_PROPERTY); }
if (conf.hasProperty("javax.persistence.validation.mode")) if (conf.getStringProperty("javax.persistence.validation.mode").equalsIgnoreCase("none")) if (conf.hasProperty("javax.persistence.validation.mode")) if (conf.getStringProperty("javax.persistence.validation.mode").equalsIgnoreCase("callback"))
/** * * @param clr * @param conf */ public BeanValidatorHandler(ObjectManager om) { ValidatorFactory factory; conf = om.getOMFContext().getPersistenceConfiguration(); clr = om.getClassLoaderResolver(); if (conf.hasProperty("javax.persistence.validation.factory")) { //create from javax.persistence.validation.factory if given factory = (ValidatorFactory) conf.getProperty("javax.persistence.validation.factory"); } else { factory = Validation.buildDefaultValidatorFactory(); } validator = factory.usingContext().traversableResolver(new JPATraversalResolver(om)).getValidator(); }
/** * Instantiates the connections to the Force.com service. It either reads the configs * from thread local (which would have been set from OAuth) or it gets the config from * the store manager. * {@inheritDoc} */ @Override public ManagedConnection createManagedConnection(Object poolKey, Map transactionOptions) { ForceStoreManager storeManager = (ForceStoreManager) omfContext.getStoreManager(); ForceServiceConnector connector = new ForceServiceConnector(); // A ConnectorConfig might have been set via OAuth in which case we should be // using that. ForceConnectorConfig tlConfig; if ((tlConfig = ForceServiceConnector.getThreadLocalConnectorConfig()) != null) { connector.setConnectorConfig(tlConfig); } else { connector.setConnectorConfig(storeManager.getConfig()); } connector.setConnectionName(omfContext.getPersistenceConfiguration().getStringProperty("force.ConnectionName")); connector.setClientId(ForceServiceConnector.API_USER_AGENT); connector.setTimeout(omfContext.getPersistenceConfiguration().getIntProperty("datanucleus.datastoreReadTimeout")); connector.setSkipCache(omfContext.getPersistenceConfiguration() .getBooleanProperty("force.skipConfigCache", false /* resultIfNotSet */)); return new ForceManagedConnection(connector); } }
public FileMetaData[] loadPersistenceUnit(PersistenceUnitMetaData pumd, ClassLoader loader) { if (!omfContext.getPersistenceConfiguration().hasProperty("force.ConnectionName")) { omfContext.getPersistenceConfiguration().setProperty("force.ConnectionName", pumd.getName()); } else if (omfContext.getPersistenceConfiguration().getStringProperty("datanucleus.ConnectionUrl") == null) { throw new NucleusUserException("Must specify unit name or connection url");
private DatastoreServiceConfig createDatastoreServiceConfigPrototype( PersistenceConfiguration persistenceConfiguration, String... timeoutProps) { DatastoreServiceConfig datastoreServiceConfig = DatastoreServiceConfig.Builder.withDefaults(); for (String timeoutProp : timeoutProps) { int defaultDeadline = persistenceConfiguration.getIntProperty(timeoutProp); if (defaultDeadline > 0) { datastoreServiceConfig.deadline(defaultDeadline / 1000d); } } String defaultReadConsistencyStr = persistenceConfiguration.getStringProperty( DATASTORE_READ_CONSISTENCY_PROPERTY); if (defaultReadConsistencyStr != null) { try { datastoreServiceConfig.readPolicy(new ReadPolicy(Consistency.valueOf(defaultReadConsistencyStr))); } catch (IllegalArgumentException iae) { throw new NucleusFatalUserException( "Illegal value for " + DATASTORE_READ_CONSISTENCY_PROPERTY + ". Valid values are " + Arrays.toString(Consistency.values())); } } return datastoreServiceConfig; }
if (!conf.getStringProperty("datanucleus.cache.level2.type").equalsIgnoreCase("none")) conf.setProperty("datanucleus.datastoreIdentityType", "unique");
@SuppressWarnings("deprecation") private TransactionOptions createDatastoreTransactionOptionsPrototype( PersistenceConfiguration persistenceConfig) { // return TransactionOptions.Builder.withXG( return TransactionOptions.Builder.allowMultipleEntityGroups( persistenceConfig.getBooleanProperty(DATASTORE_ENABLE_XG_TXNS_PROPERTY)); }
if (conf.hasProperty("datanucleus.connectionPool.maxStatements")) int size = conf.getIntProperty("datanucleus.connectionPool.maxStatements"); if (size >= 0) if (conf.hasProperty("datanucleus.connectionPool.maxPoolSize")) int size = conf.getIntProperty("datanucleus.connectionPool.maxPoolSize"); if (size >= 0) if (conf.hasProperty("datanucleus.connectionPool.minPoolSize")) int size = conf.getIntProperty("datanucleus.connectionPool.minPoolSize"); if (size >= 0) if (conf.hasProperty("datanucleus.connectionPool.maxIdle")) int value = conf.getIntProperty("datanucleus.connectionPool.maxIdle"); if (value > 0)
.getPersistenceConfiguration().getIntProperty("datanucleus.maxFetchDepth"); if (maxDepth > 5) { throw new NucleusException("Max fetch depth cannot be greater than 5.");
conf.setProperty("datanucleus.attachSameDatastore", Boolean.TRUE.toString()); // Always only one datastore conf.setProperty("datanucleus.datastoreTransactionFlushLimit", Integer.MAX_VALUE); conf.setProperty("datanucleus.identityKeyTranslatorType", "appengine");
public JsonAPIImpl(Map props) { //TODO change this to json ctx = new NucleusContext("JDO", null); ctx.getPersistenceConfiguration().setPersistenceProperties(props); ctx.initialise(); ec = new JsonAPIExecutionContext(ctx); tx = new JsonAPITransactionImpl(ec.getTransaction()); }
/** * Instantiates the connections to the Force.com service. It either reads the configs * from thread local (which would have been set from OAuth) or it gets the config from * the store manager. * {@inheritDoc} */ @Override public ManagedConnection createManagedConnection(Object poolKey, Map transactionOptions) { ForceStoreManager storeManager = (ForceStoreManager) omfContext.getStoreManager(); ForceServiceConnector connector = new ForceServiceConnector(); // A ConnectorConfig might have been set via OAuth in which case we should be // using that. ForceConnectorConfig tlConfig; if ((tlConfig = ForceServiceConnector.getThreadLocalConnectorConfig()) != null) { connector.setConnectorConfig(tlConfig); } else { connector.setConnectorConfig(storeManager.getConfig()); } connector.setConnectionName(omfContext.getPersistenceConfiguration().getStringProperty("force.ConnectionName")); connector.setClientId(ForceServiceConnector.API_USER_AGENT); connector.setTimeout(omfContext.getPersistenceConfiguration().getIntProperty("datanucleus.datastoreReadTimeout")); connector.setSkipCache(omfContext.getPersistenceConfiguration() .getBooleanProperty("force.skipConfigCache", false /* resultIfNotSet */)); return new ForceManagedConnection(connector); } }
public FileMetaData[] loadPersistenceUnit(PersistenceUnitMetaData pumd, ClassLoader loader) { if (!omfContext.getPersistenceConfiguration().hasProperty("force.ConnectionName")) { omfContext.getPersistenceConfiguration().setProperty("force.ConnectionName", pumd.getName()); } else if (omfContext.getPersistenceConfiguration().getStringProperty("datanucleus.ConnectionUrl") == null) { throw new NucleusUserException("Must specify unit name or connection url");
/** * Creates an object manager with datastore credentials. * * @param omf the object manager factory * @param owner the owning persistence manager or entity manager * @param userName the username to the datastore * @param password the password to the datastore */ public ForceObjectManagerImpl(ObjectManagerFactoryImpl omf, Object owner, String userName, String password) { super(omf, owner, userName, password); this.allOrNothingEnabled = omf.getOMFContext().getPersistenceConfiguration().getBooleanProperty("force.AllOrNothing"); }
if (conf.hasProperty("datanucleus.connectionPool.maxStatements")) int size = conf.getIntProperty("datanucleus.connectionPool.maxStatements"); if (size >= 0) if (conf.hasProperty("datanucleus.connectionPool.maxPoolSize")) int size = conf.getIntProperty("datanucleus.connectionPool.maxPoolSize"); if (size >= 0) if (conf.hasProperty("datanucleus.connectionPool.minPoolSize")) int size = conf.getIntProperty("datanucleus.connectionPool.minPoolSize"); if (size >= 0) if (conf.hasProperty("datanucleus.connectionPool.initialPoolSize")) int size = conf.getIntProperty("datanucleus.connectionPool.initialPoolSize"); if (size >= 0)
.getPersistenceConfiguration().getIntProperty("datanucleus.maxFetchDepth"); if (maxDepth > 5) { throw new NucleusException("Max fetch depth cannot be greater than 5.");