Examples of OMFContext


Examples of org.datanucleus.OMFContext

  }

  @Override
  public void setStoreManager(StoreManager storeMgr) {
    super.setStoreManager(storeMgr);
    OMFContext omfContext = getOMFContext();
    MetaDataManager mdm = omfContext.getMetaDataManager();
    ClassLoaderResolver clr = omfContext.getClassLoaderResolver(getClass().getClassLoader());
    AbstractClassMetaData acmd = mdm.getMetaDataForClass((String) properties.get("class-name"), clr);
    if (acmd != null) {
      ((DatastoreManager) storeMgr).validateMetaDataForClass(acmd, clr);
    }
View Full Code Here

Examples of org.datanucleus.OMFContext

  }

  @Override
  public void setStoreManager(StoreManager storeMgr) {
    super.setStoreManager(storeMgr);
    OMFContext omfContext = getOMFContext();
    MetaDataManager mdm = omfContext.getMetaDataManager();
    ClassLoaderResolver clr = omfContext.getClassLoaderResolver(getClass().getClassLoader());
    AbstractClassMetaData acmd = mdm.getMetaDataForClass((String) properties.get("class-name"), clr);
    if (acmd != null) {
      ((DatastoreManager) storeMgr).validateMetaDataForClass(acmd, clr);
    }
View Full Code Here

Examples of org.datanucleus.OMFContext

  }

  @Override
  public void setStoreManager(StoreManager storeMgr) {
    super.setStoreManager(storeMgr);
    OMFContext omfContext = getOMFContext();
    MetaDataManager mdm = omfContext.getMetaDataManager();
    ClassLoaderResolver clr = omfContext.getClassLoaderResolver(getClass().getClassLoader());
    AbstractClassMetaData acmd = mdm.getMetaDataForClass((String) properties.get("class-name"), clr);
    if (acmd != null) {
      ((DatastoreManager) storeMgr).validateMetaDataForClass(acmd, clr);
    }
View Full Code Here

Examples of org.datanucleus.OMFContext

        TableName tableName = newInstance(TableName.class, new Class[] {String.class, String.class, Boolean.TYPE},
                "" /*namespace*/, entityClass.getSimpleName().toLowerCase(), false /*parseForSuffix*/);
       
        // Construct a virtual TableImpl just like how the ForceStoreSchemaHandler would
        // (see ForceStoreSchemaHandler.addVirtualTable)
        OMFContext omfContext = new OMFContext(new PersistenceConfiguration() { });
        MetaDataManager metaDataManager = new JPAMetaDataManager(omfContext);
        return new TableImpl(tableName,
                             metaDataManager.getMetaDataForClass(entityClass, omfContext.getClassLoaderResolver(null)));
    }
View Full Code Here

Examples of org.datanucleus.OMFContext

        if (props != null)
        {
            // This is actually wrong since we should apply them *after* any default props below
            conf.setOptions(props);
        }
        omfContext = new OMFContext(conf, OMFContext.CONTEXT_ENHANCE);
        Map map = omfContext.getApiAdapter().getDefaultFactoryProperties();
        conf.setOptions(map);
        omfContext.setApi(api);
        clr = omfContext.getClassLoaderResolver(null);
    }
View Full Code Here

Examples of org.datanucleus.OMFContext

  }

  @Override
  public void setStoreManager(StoreManager storeMgr) {
    super.setStoreManager(storeMgr);
    OMFContext omfContext = getOMFContext();
    MetaDataManager mdm = omfContext.getMetaDataManager();
    ClassLoaderResolver clr = omfContext.getClassLoaderResolver(getClass().getClassLoader());
    AbstractClassMetaData acmd = mdm.getMetaDataForClass((String) properties.get("class-name"), clr);
    if (acmd != null) {
      ((DatastoreManager) storeMgr).validateMetaDataForClass(acmd, clr);
    }
View Full Code Here

Examples of org.datanucleus.OMFContext

        {
            // This is our class so yes it will be PersistenceCapable
            return true;
        }

        OMFContext omfCtx = cmd.getMetaDataManager().getOMFContext();
        Class cls = clr.classForName(className, new EnhancerClassLoader());
        if (omfCtx.getApiAdapter().isPersistable(cls))
        {
            // The specified class is already PersistenceCapable
            return true;
        }
View Full Code Here

Examples of org.datanucleus.OMFContext

        }
    }

    public RuntimeEnhancer(PersistenceConfiguration config)
    {
        omfContext = new OMFContext(config, OMFContext.CONTEXT_ENHANCE);
        api = omfContext.getPersistenceConfiguration().getStringProperty("datanucleus.persistenceApiName");
        pluginMgr = omfContext.getPluginManager();
        clr = omfContext.getClassLoaderResolver(null);
    }
View Full Code Here

Examples of org.datanucleus.OMFContext

        // Initialise the PMF
        pmf = initialisePMF(unitMetaData, overridingProps);

        // Initialise the L2 cache (if used)
        JDODataStoreCache cache = (JDODataStoreCache)pmf.getDataStoreCache();
        OMFContext omfCtx = ((JDOPersistenceManagerFactory)pmf).getOMFContext();
        if (cache != null)
        {
            datastoreCache = new JPADataStoreCache(omfCtx, cache.getLevel2Cache());
        }

        // Turn off loading of metadata from here if required
        boolean allowMetadataLoad =
            omfCtx.getPersistenceConfiguration().getBooleanProperty("datanucleus.metadata.allowLoadAtRuntime");
        if (!allowMetadataLoad)
        {
            omfCtx.getMetaDataManager().setAllowMetaDataLoad(false);
        }
    }
View Full Code Here

Examples of org.datanucleus.OMFContext

        unitMetaData = EntityManagerFactoryImpl.unitMetaDataCache.get(unitName);
        if (unitMetaData == null)
        {
            // Find all "META-INF/persistence.xml" files in the current thread loader CLASSPATH and parse them
            // Create a temporary PMFContext so we have a parser
            OMFContext pmfCtxt = new OMFContext(new PersistenceConfiguration(){});
            pmfCtxt.setApi("JPA");
            MetaDataManager metadataMgr = pmfCtxt.getMetaDataManager();
            PersistenceFileMetaData[] files = metadataMgr.parsePersistenceFiles();
            if (files == null)
            {
                // No "persistence.xml" files found
                NucleusLogger.JPA.warn(LOCALISER.msg("EMF.NoPersistenceXML"));
                //throw new NoPersistenceXmlException(LOCALISER.msg("EMF.NoPersistenceXML"));
            }
            else
            {
                for (int i=0;i<files.length;i++)
                {
                    PersistenceUnitMetaData[] unitmds = files[i].getPersistenceUnits();
                    for (int j=0;j<unitmds.length;j++)
                    {
                        // Cache the "persistence-unit" for future reference
                        EntityManagerFactoryImpl.unitMetaDataCache.put(unitmds[j].getName(), unitmds[j]);
                        if (unitmds[j].getName().equals(unitName))
                        {
                            unitMetaData = unitmds[j];
                            unitMetaData.clearJarFiles(); // Jar files not applicable to J2SE [JPA 6.3]
                        }
                    }
                }
            }

            if (unitMetaData == null)
            {
                // No "persistence-unit" of the same name as requested so nothing to manage the persistence of
                NucleusLogger.JPA.warn(LOCALISER.msg("EMF.PersistenceUnitNotFound", unitName));
            }
            else
            {
                EntityManagerFactoryImpl.unitMetaDataCache.put(unitMetaData.getName(), unitMetaData);
            }
        }

        // Check the provider is ok for our use
        boolean validProvider = false;
        if (unitMetaData != null)
        {
            if (unitMetaData.getProvider() == null ||
                unitMetaData.getProvider().equals(PersistenceProviderImpl.class.getName()))
            {
                validProvider = true;
            }
        }
        if (overridingProps != null &&
            PersistenceProviderImpl.class.getName().equals(overridingProps.get("javax.persistence.provider")))
        {
            validProvider = true;
        }
        if (!validProvider)
        {
            // Not a valid provider
            throw new NotProviderException(LOCALISER.msg("EMF.NotProviderForPersistenceUnit",
                unitName));
        }

        // Initialise the PMF (even if unitMetaData is null)
        pmf = initialisePMF(unitMetaData, overridingProps);

        // Initialise the L2 cache (if used)
        JDODataStoreCache cache = (JDODataStoreCache)pmf.getDataStoreCache();
        OMFContext omfCtx = ((JDOPersistenceManagerFactory)pmf).getOMFContext();
        if (cache != null)
        {
            datastoreCache = new JPADataStoreCache(omfCtx, cache.getLevel2Cache());
        }

        // Turn off loading of metadata from here if required
        boolean allowMetadataLoad =
            omfCtx.getPersistenceConfiguration().getBooleanProperty("datanucleus.metadata.allowLoadAtRuntime");
        if (!allowMetadataLoad)
        {
            omfCtx.getMetaDataManager().setAllowMetaDataLoad(false);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.