/** * Method to remove the specified class from the classes that are being managed. * In practical terms this means remove all knowledge of the class from the metadata service, and also from * the StoreManager service. It doesn't mean to remove the datastore representation (i.e table) of this class. * @param className Name of the class */ public void unmanageClass(String className) { // Unload the metadata for this class MetaDataManager mmgr = nucleusContext.getMetaDataManager(); mmgr.unloadMetaDataForClass(className); // Unmanage from the store nucleusContext.getStoreManager().unmanageClass(nucleusContext.getClassLoaderResolver(null), className, false); }
protected Configuration getConfiguration() { return nucleusContext.getConfiguration(); }
/** * Return non-configurable properties of this PersistenceManagerFactory. * Properties with keys VendorName and VersionNumber are required. Other keys are optional. * @return the non-configurable properties of this PersistenceManagerFactory. */ public Properties getProperties() { Properties props = new Properties(); props.setProperty("VendorName", "DataNucleus"); props.setProperty("VersionNumber", nucleusContext.getPluginManager().getVersionForBundle("org.datanucleus.api.jdo")); // Add all properties from the persistence configuration props.putAll(nucleusContext.getConfiguration().getPersistenceProperties()); return props; }
/** * Gets the object that is embedded within the current entry. * @return the object */ private Object fetchEmbedded() { // use embedded meta data from field EmbeddedMetaData embeddedMetaData = mmd.getEmbeddedMetaData(); // use field meta data from embedded meta data List<AbstractMemberMetaData> embeddedMmds = new ArrayList<AbstractMemberMetaData>(Arrays.asList(embeddedMetaData.getMemberMetaData())); // TODO Provide the owner in this call ObjectProvider embeddedSM = ec.getNucleusContext().getObjectProviderFactory().newForEmbedded(ec, effectiveClassMetaData, null, -1); // TODO Why get SM just after creating it???? embeddedSM = getEmbeddedObjectProvider(embeddedSM.getObject()); return fetchMerge(embeddedSM, attributes, embeddedMmds, embeddedMetaData); }
/** * Convenience method to return the (DataNucleus) identity for an object. * @param obj The object * @param acmd MetaData for the object * @param ec execution context * @param odb ODB to use * @return The DataNucleus identity */ public static Object getIdentityForObject(Object obj, AbstractClassMetaData acmd, ExecutionContext ec, ODB odb) { if (acmd.getIdentityType() == IdentityType.DATASTORE) { long datastoreId = odb.getObjectId(obj).getObjectId(); return ec.getNucleusContext().getIdentityManager().getDatastoreId(datastoreId); } else if (acmd.getIdentityType() == IdentityType.APPLICATION) { return ec.getNucleusContext().getIdentityManager().getApplicationId(obj, acmd); } else { // Nondurable identity return null; } } }
@Override public String getJavaTypeForDatastoreMapping(int index) { if (converter == null) { return UUID.class.getName(); } return storeMgr.getNucleusContext().getTypeManager().getDatastoreTypeForTypeConverter(converter, getJavaType()).getName(); }
@Override public void initialize(RDBMSStoreManager storeMgr, String type) { // We don't have access to any field info yet, so have no idea whether we need a TypeConverter, so just create one Class fieldType = storeMgr.getNucleusContext().getClassLoaderResolver(null).classForName(type); converter = storeMgr.getNucleusContext().getTypeManager().getDefaultTypeConverterForType(fieldType); if (converter == null) { throw new NucleusUserException("Unable to find TypeConverter for converting " + fieldType + " to String"); } super.initialize(storeMgr, type); }
id = ec.getNucleusContext().getIdentityManager().getApplicationId(obj, acmd); sm = ec.getNucleusContext().getObjectProviderFactory().newForPersistentClean(ec, id, obj); AbstractClassMetaData cmd = sm.getClassMetaData();
/** * 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)); }
if (ec.getNucleusContext().isClassMultiTenant(cmd)) String value = ec.getNucleusContext().getMultiTenancyId(ec, cmd); multitenancyText = propName + " = \"" + value + "\""; if (filterText != null)
public ClassLoaderResolver getClassLoaderResolver() { if (clr == null) { clr = rdbmsMgr.getNucleusContext().getClassLoaderResolver(null); } return clr; }
String filename = nucleusContext.getConfiguration().getStringProperty(PropertyNames.PROPERTY_PERSISTENCE_XML_FILENAME); boolean validateXML = nucleusContext.getConfiguration().getBooleanProperty(PropertyNames.PROPERTY_METADATA_XML_VALIDATE); boolean supportXMLNamespaces = nucleusContext.getConfiguration().getBooleanProperty(PropertyNames.PROPERTY_METADATA_XML_NAMESPACE_AWARE); ClassLoaderResolver clr = nucleusContext.getClassLoaderResolver(null); pumd = MetaDataUtils.getMetaDataForPersistenceUnit(nucleusContext.getPluginManager(), filename, getPersistenceUnitName(), validateXML, supportXMLNamespaces, clr);
/** * For JRebel plugin */ public static MetaDataManager getMetaDataManager() { return instance != null ? ((JDOPersistenceManagerFactory)instance.persistenceManagerFactory).getNucleusContext().getMetaDataManager() : null; }
ClassLoaderResolver clr = storeMgr.getNucleusContext().getClassLoaderResolver(null); loadDatastoreMappings(storeMgr.getNucleusContext().getPluginManager(), clr);
if (!ec.getNucleusContext().getApiAdapter().isPersistable(cls) || !hasPersistenceInformationForClass(cls)) if (cmd.getIdentityType() == IdentityType.DATASTORE) return ec.getNucleusContext().getIdentityManager().getDatastoreIdClass(); return ec.getNucleusContext().getIdentityManager().getDatastoreIdClass();
protected void initialiseMetaData(PersistenceUnitMetaData pumd) nucleusContext.getMetaDataManager().setAllowXML(getConfiguration().getBooleanProperty(PropertyNames.PROPERTY_METADATA_ALLOW_XML)); nucleusContext.getMetaDataManager().setAllowAnnotations(getConfiguration().getBooleanProperty(PropertyNames.PROPERTY_METADATA_ALLOW_ANNOTATIONS)); nucleusContext.getMetaDataManager().setValidate(getConfiguration().getBooleanProperty(PropertyNames.PROPERTY_METADATA_XML_VALIDATE)); nucleusContext.getMetaDataManager().setDefaultNullable(getConfiguration().getBooleanProperty(PropertyNames.PROPERTY_METADATA_DEFAULT_NULLABLE)); nucleusContext.getMetaDataManager().loadPersistenceUnit(pumd, null); boolean allowMetadataLoad = nucleusContext.getConfiguration().getBooleanProperty(PropertyNames.PROPERTY_METADATA_ALLOW_LOAD_AT_RUNTIME); if (!allowMetadataLoad) nucleusContext.getMetaDataManager().setAllowMetaDataLoad(false);
jdoPmf.getNucleusContext().getPluginManager(); Field registryField = pluginManager.getClass().getDeclaredField("registry"); registryField.setAccessible(true);
AbstractClassMetaData targetCmd = storeMgr.getNucleusContext().getMetaDataManager().getMetaDataForClass(className, clr); SQLExpression discExpr = factory.newExpression(stmt, stmt.getPrimaryTable(), discriminatorMapping); SQLExpression discValExpr = factory.newLiteral(stmt, discriminatorMapping, targetCmd.getDiscriminatorValue()); SQLTable tenantSqlTbl = stmt.getTable(multitenancyMapping.getTable(), tblGroupName); SQLExpression tenantExpr = stmt.getSQLExpressionFactory().newExpression(stmt, tenantSqlTbl, multitenancyMapping); SQLExpression tenantVal = stmt.getSQLExpressionFactory().newLiteral(stmt, multitenancyMapping, ec.getNucleusContext().getMultiTenancyId(ec, cmd)); stmt.whereAnd(tenantExpr.eq(tenantVal), true); AbstractClassMetaData targetSubCmd = storeMgr.getNucleusContext().getMetaDataManager().getMetaDataForClass(subclassName, clr); AbstractClassMetaData[] targetSubCmds = storeMgr.getClassesManagingTableForClass(targetSubCmd, clr); subclassTables = new DatastoreClass[targetSubCmds.length];
private void createSchema( final PersistenceManagerFactory persistenceManagerFactory, final Set<String> persistableClassNameSet, final Map<String, String> datanucleusProps) { JDOPersistenceManagerFactory jdopmf = (JDOPersistenceManagerFactory) persistenceManagerFactory; final PersistenceNucleusContext nucleusContext = jdopmf.getNucleusContext(); final SchemaAwareStoreManager schemaAwareStoreManager = (SchemaAwareStoreManager)nucleusContext.getStoreManager(); final MetaDataManager metaDataManager = nucleusContext.getMetaDataManager(); registerMetadataListener(metaDataManager, datanucleusProps); schemaAwareStoreManager.createSchemaForClasses(persistableClassNameSet, asProperties(datanucleusProps)); }
SQLExpression tenantVal = stmt.getSQLExpressionFactory().newLiteral(stmt, multitenancyMapping, ec.getNucleusContext().getMultiTenancyId(ec, candidateCmd)); stmt.whereAnd(tenantExpr.eq(tenantVal), true);