Package org.datanucleus

Examples of org.datanucleus.PersistenceConfiguration


        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


     * If the supplied exception is a PersistenceException, also mark the current transaction for rollback.
     * @param re The exception
     */
    private Object throwException(RuntimeException re) {
        if (re instanceof PersistenceException) {
            PersistenceConfiguration conf = om.getOMFContext().getPersistenceConfiguration();
            boolean markForRollback = conf.getBooleanProperty("datanucleus.jpa.txnMarkForRollbackOnException");
            if (markForRollback) {
                // The JPA spec says that all PersistenceExceptions thrown should mark the transaction for
                // rollback. Seems excessive to me. For example, you try to find an object with a particular id and it
                // doesn't exist so you then have to rollback the txn and start again.
                getTransaction().setRollbackOnly();
View Full Code Here

        LOGGER.info(LOCALISER.msg("Enhancer.ClassEnhancer", enhancerName, api));

        this.api = api;
        this.enhancerName = enhancerName;

        PersistenceConfiguration conf = new PersistenceConfiguration() {};
        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

        clr = omfContext.getClassLoaderResolver(null);
    }

    public RuntimeEnhancer()
    {
        this(new PersistenceConfiguration() {});
    }
View Full Code Here

     */
    protected AbstractStoreManager(String key, ClassLoaderResolver clr, OMFContext omfContext)
    {
        this.storeManagerKey = key;
        this.omfContext = omfContext;
        PersistenceConfiguration conf = omfContext.getPersistenceConfiguration();
        this.readOnlyDatastore = conf.getBooleanProperty("datanucleus.readOnlyDatastore");
        this.readOnlyDatastoreAction = conf.getStringProperty("datanucleus.readOnlyDatastoreAction");
        this.fixedDatastore = conf.getBooleanProperty("datanucleus.fixedDatastore");
        this.autoStartMechanism = conf.getStringProperty("datanucleus.autoStartMechanism");

        // Register this StoreManager with the OMFContext
        omfContext.setStoreManager(this);

        this.valueGenerationMgr = new ValueGenerationManager();
View Full Code Here

     */
    protected void logConfiguration()
    {
        if (NucleusLogger.DATASTORE.isDebugEnabled())
        {
            PersistenceConfiguration conf = omfContext.getPersistenceConfiguration();

            NucleusLogger.DATASTORE.debug("======================= Datastore =========================");
            NucleusLogger.DATASTORE.debug("StoreManager : \"" + storeManagerKey + "\" (" + getClass().getName() + ")");
            if (autoStartMechanism != null)
            {
                String classNames = conf.getStringProperty("datanucleus.autoStartClassNames");
                NucleusLogger.DATASTORE.debug("AutoStart : mechanism=" + autoStartMechanism +
                    ", mode=" + conf.getStringProperty("datanucleus.autoStartMechanismMode") +
                    ((classNames != null) ? (", classes=" + classNames) : ""));
            }
            String url = omfContext.getPersistenceConfiguration().getStringProperty("datanucleus.ConnectionURL");
            NucleusLogger.DATASTORE.debug(LOCALISER.msg("032020", storeManagerKey, url,
                (readOnlyDatastore ? "read-only" : "read-write"), (fixedDatastore ? ", fixed" : "")));
View Full Code Here

     * is attempting to be updated.
     * @param sm StateManager for the object
     */
    public void assertReadOnlyForUpdateOfObject(StateManager sm)
    {
        PersistenceConfiguration conf = getOMFContext().getPersistenceConfiguration();
        if (conf.getBooleanProperty("datanucleus.readOnlyDatastore"))
        {
            if (conf.getStringProperty("datanucleus.readOnlyDatastoreAction").equalsIgnoreCase("EXCEPTION"))
            {
                throw new DatastoreReadOnlyException(LOCALISER.msg("032004",
                    StringUtils.toJVMIDString(sm.getObject())), sm.getObjectManager().getClassLoaderResolver());
            }
            else
View Full Code Here

     */
    protected void setUp() throws Exception
    {
        ApiAdapter api = new JDOAdapter();
        ClassLoaderResolver clr = new JDOClassLoaderResolver();
        PluginManager pluginMgr = new PluginManager(new PersistenceConfiguration() {}, clr);
        pluginMgr.registerExtensionPoints();
        pluginMgr.registerExtensions();
        pluginMgr.resolveConstraints();
        typeMgr = new TypeManager(api, pluginMgr, clr);
    }
View Full Code Here

        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)
            {
View Full Code Here

     * Changing the contents of the map does not change the configuration in effect.
     * @return properties
     */
    public Map<String, Object> getProperties()
    {
        PersistenceConfiguration conf =
            ((ObjectManagerFactoryImpl)pmf).getOMFContext().getPersistenceConfiguration();
        return conf.getOptions();
    }
View Full Code Here

TOP

Related Classes of org.datanucleus.PersistenceConfiguration

Copyright © 2018 www.massapicom. 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.