NucleusContext nc = jdoPmf.getNucleusContext(); try { Field pmCache = pmf.getClass().getDeclaredField("pmCache"); jdoPmf.getNucleusContext().getPluginManager(); Field registryField = pluginManager.getClass().getDeclaredField("registry"); registryField.setAccessible(true);
/** * Set the default RestoreValues setting for all <tt>PersistenceManager</tt> * instances obtained from this factory. * @param flag the default RestoreValues setting. */ public void setRestoreValues(boolean flag) { assertConfigurable(); getConfiguration().setProperty(PropertyNames.PROPERTY_RESTORE_VALUES, flag ? Boolean.TRUE : Boolean.FALSE); }
pmf = new JDOPersistenceManagerFactory(props); Boolean singleton = pmf.getConfiguration().getBooleanObjectProperty(PROPERTY_SINGLETON_PMF_BY_NAME); if (singleton != null && singleton) String name = pmf.getName(); if (name == null) name = pmf.getPersistenceUnitName(); pmf.close(); NucleusLogger.PERSISTENCE.warn("Requested PMF of name \"" + name + "\" but already exists and using singleton pattern, so returning existing PMF"); return pmfByName.get(name); pmf.freezeConfiguration();
private static boolean isSchemaAwareStoreManager(Map<String,String> datanucleusProps) { // we create a throw-away instance of PMF so that we can probe whether DN has // been configured with a schema-aware store manager or not. final JDOPersistenceManagerFactory probePmf = (JDOPersistenceManagerFactory)JDOHelper.getPersistenceManagerFactory(datanucleusProps); try { final PersistenceNucleusContext nucleusContext = probePmf.getNucleusContext(); final StoreManager storeManager = nucleusContext.getStoreManager(); return storeManager instanceof SchemaAwareStoreManager; } finally { probePmf.close(); } }
/** * Return a new PersistenceManagerFactory with options set according to the given Properties. * This method exists for JDO1 compliance whereas in JDO2+ the method takes a Map. * @param overridingProps The Properties to initialize the PersistenceManagerFactory with. * @return A PersistenceManagerFactory with options set according to the given Properties. * @see javax.jdo.JDOHelper#getPersistenceManagerFactory(java.util.Map) */ public synchronized static PersistenceManagerFactory getPersistenceManagerFactory(Properties overridingProps) { // Extract the properties into a Map allowing for a Properties object being used Map overridingMap = new HashMap(); // Make sure we handle default properties too (java.util.Properties class oddness) for (Enumeration e = overridingProps.propertyNames() ; e.hasMoreElements() ;) { // Use props.get to allow for user misusing Properties class String param = (String)e.nextElement(); overridingMap.put(param, overridingProps.get(param)); } return getPersistenceManagerFactory(overridingMap); }
protected void finalize() throws Throwable { close(); super.finalize(); }
pmf = new JDOPersistenceManagerFactory(p); pmf.freezeConfiguration();
seq = pmf.getSequenceForFactoryClass(seqmd.getFactoryClass()); if (seq == null) pmf.addSequenceForFactoryClass(seqmd.getFactoryClass(), seq);
addInstanceLifecycleListener(listener, classes);
/** * Set the default NontransactionalWrite setting for all * <tt>PersistenceManager</tt> instances obtained from this factory. * @param flag the default NontransactionalWrite setting. */ public void setNontransactionalWrite(boolean flag) { assertConfigurable(); getConfiguration().setProperty(PropertyNames.PROPERTY_TRANSACTION_NONTX_WRITE, flag ? Boolean.TRUE : Boolean.FALSE); }
properties.put(HiveConfigConstants.JAVAX_JDO_DATASTOREREADTIMEOUT, JDO_TIMEOUT); properties.put(HiveConfigConstants.JAVAX_JDO_DATASTOREWRITETIMEOUT, JDO_TIMEOUT); result = JDOPersistenceManagerFactory.getPersistenceManagerFactory(properties); factories.put(name, result);
/** * For JRebel plugin */ public static MetaDataManager getMetaDataManager() { return instance != null ? ((JDOPersistenceManagerFactory)instance.persistenceManagerFactory).getNucleusContext().getMetaDataManager() : null; }
/** * Set the default for whether to auto-commit non-tx writes for all * <tt>PersistenceManager</tt> instances obtained from this factory. * @param flag whether to auto-commit non-tx writes */ public void setNontransactionalWriteAutoCommit(boolean flag) { assertConfigurable(); getConfiguration().setProperty(PropertyNames.PROPERTY_TRANSACTION_NONTX_ATOMIC, flag ? Boolean.TRUE : Boolean.FALSE); }
properties.put(HiveConfigConstants.JAVAX_JDO_DATASTOREREADTIMEOUT, JDO_TIMEOUT); properties.put(HiveConfigConstants.JAVAX_JDO_DATASTOREWRITETIMEOUT, JDO_TIMEOUT); result = JDOPersistenceManagerFactory.getPersistenceManagerFactory(properties); factories.put(name, result);
/** * Accessor for the names of the classes that have MetaData for this PMF. * @param pmf The PMF * @return The class names */ public static String[] getClassesWithMetaData(PersistenceManagerFactory pmf) { if (pmf == null || !(pmf instanceof JDOPersistenceManagerFactory)) { return null; } JDOPersistenceManagerFactory myPMF = (JDOPersistenceManagerFactory)pmf; Collection classes = myPMF.getNucleusContext().getMetaDataManager().getClassesWithMetaData(); return (String[])classes.toArray(new String[classes.size()]); }
/** * Mutator for the CopyOnAttach setting. * @param flag the default CopyOnAttach setting. */ public void setCopyOnAttach(boolean flag) { assertConfigurable(); getConfiguration().setProperty(PropertyNames.PROPERTY_COPY_ON_ATTACH, flag ? Boolean.TRUE : Boolean.FALSE); }
/** * Accessor for the MetaData for the specified class * @param pmf PersistenceManager factory * @param cls The class * @return The MetaData for the class */ public static ClassMetaData getMetaDataForClass(PersistenceManagerFactory pmf, Class cls) { if (pmf == null || cls == null) { return null; } if (!(pmf instanceof JDOPersistenceManagerFactory)) { return null; } JDOPersistenceManagerFactory myPMF = (JDOPersistenceManagerFactory)pmf; MetaDataManager mdmgr = myPMF.getNucleusContext().getMetaDataManager(); return (ClassMetaData)mdmgr.getMetaDataForClass(cls, myPMF.getNucleusContext().getClassLoaderResolver(null)); }
/** * Set the name for any mapping, used in searching for ORM/Query metadata files. * @param mapping the mapping name */ public void setMapping(String mapping) { assertConfigurable(); getConfiguration().setProperty(PropertyNames.PROPERTY_MAPPING, mapping); }
NucleusContext nc = jdoPmf.getNucleusContext(); try { Field pmCache = pmf.getClass().getDeclaredField("pmCache"); org.datanucleus.plugin.PluginManager pluginManager = jdoPmf.getNucleusContext().getPluginManager(); Field registryField = pluginManager.getClass().getDeclaredField("registry"); registryField.setAccessible(true);
/** * Mutator for the schema to use for this persistence factory. * @param schema Name of the schema */ public void setSchema(String schema) { assertConfigurable(); getConfiguration().setProperty(PropertyNames.PROPERTY_MAPPING_SCHEMA, schema); }