Package org.datanucleus.store.valuegenerator

Examples of org.datanucleus.store.valuegenerator.ValueGenerationManager


            }
        }
        props.put("sequence-name", seqMetaData.getDatastoreSequence());

        // Get a ValueGenerationManager to create the generator
        ValueGenerationManager mgr = storeManager.getValueGenerationManager();
        ValueGenerationConnectionProvider connProvider = new ValueGenerationConnectionProvider()
            {
                ManagedConnection mconn;

                public ManagedConnection retrieveConnection()
                {
                    // Obtain a new connection
                    // Note : it may be worthwhile to use the PM's connection here however where a Sequence doesnt yet
                    // exist the connection would then be effectively dead until the end of the tx
                    // The way around this would be to find a way of checking for existence of the sequence
                    PersistenceConfiguration conf = ec.getNucleusContext().getPersistenceConfiguration();
                    int isolationLevel = TransactionUtils.getTransactionIsolationLevelForName(
                        conf.getStringProperty("datanucleus.valuegeneration.transactionIsolation"));
                    this.mconn = ((RDBMSStoreManager)storeManager).getConnection(isolationLevel);
                    return mconn;
                }

                public void releaseConnection()
                {
                    try
                    {
                        // Release the connection
                        mconn.close();
                    }
                    catch (NucleusException e)
                    {
                        NucleusLogger.PERSISTENCE.error(LOCALISER.msg("017007", e));
                        throw e;
                    }
                }
            };
        Class cls = null;
        ConfigurationElement elem =
            ec.getNucleusContext().getPluginManager().getConfigurationElementForExtension(
                "org.datanucleus.store_valuegenerator",
                new String[]{"name", "datastore"},
                new String[] {valueGeneratorName, storeManager.getStoreManagerKey()});
        if (elem != null)
        {
            cls = ec.getNucleusContext().getPluginManager().loadClass(
                elem.getExtension().getPlugin().getSymbolicName(), elem.getAttribute("class-name"));
        }
        if (cls == null)
        {
            throw new NucleusException("Cannot create ValueGenerator for strategy "+valueGeneratorName);
        }
        generator = mgr.createValueGenerator(seqMetaData.getName(), cls, props, storeManager, connProvider);

        if (NucleusLogger.PERSISTENCE.isDebugEnabled())
        {
            NucleusLogger.PERSISTENCE.debug(LOCALISER.msg("017003", seqMetaData.getName(), valueGeneratorName));
        }
View Full Code Here


     */
    public ValueGenerationManager getValueGenerationManager()
    {
        if (valueGenerationMgr == null)
        {
            this.valueGenerationMgr = new ValueGenerationManager();
        }
        return valueGenerationMgr;
    }
View Full Code Here

        this.autoStartMechanism = conf.getStringProperty("datanucleus.autoStartMechanism");

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

        this.valueGenerationMgr = new ValueGenerationManager();

        if (omfContext.getJMXManager() != null)
        {
            // register MBean in MbeanServer
            ManagementManager mgmtMgr = omfContext.getJMXManager();
View Full Code Here

            }
        }
        props.put("sequence-name", seqMetaData.getDatastoreSequence());

        // Get a ValueGenerationManager to create the generator
        ValueGenerationManager mgr = storeManager.getValueGenerationManager();
        ValueGenerationConnectionProvider connProvider = new ValueGenerationConnectionProvider()
        {
            ManagedConnection mconn;
            public ManagedConnection retrieveConnection()
            {
                mconn = storeManager.getConnection(om);
                return mconn;
            }

            public void releaseConnection()
            {
                this.mconn.release();
                this.mconn = null;
            }
        };

        Class cls = null;
        ConfigurationElement elem =
            om.getOMFContext().getPluginManager().getConfigurationElementForExtension(
                "org.datanucleus.store_valuegenerator",
                new String[]{"name", "datastore"},
                new String[] {valueGeneratorName, storeManager.getStoreManagerKey()});
        if (elem != null)
        {
            cls = om.getOMFContext().getPluginManager().loadClass(
                elem.getExtension().getPlugin().getSymbolicName(), elem.getAttribute("class-name"));
        }
        if (cls == null)
        {
            throw new NucleusException("Cannot create ValueGenerator for strategy "+valueGeneratorName);
        }
        generator = mgr.createValueGenerator(seqMetaData.getName(), cls, props, storeManager, connProvider);

        if (NucleusLogger.JDO.isDebugEnabled())
        {
            NucleusLogger.JDO.debug(LOCALISER.msg("017003", seqMetaData.getName(), valueGeneratorName));
        }
View Full Code Here

TOP

Related Classes of org.datanucleus.store.valuegenerator.ValueGenerationManager

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.