Examples of OjbConfiguration


Examples of org.apache.ojb.broker.util.configuration.impl.OjbConfiguration

        an ODMG tx before any modifications are taking place.
        I simply moved the lock two lines up and the test passed.
     */
    public void testImplicitLocking() throws Exception
    {
        OjbConfiguration conf = (OjbConfiguration)OjbConfigurator.getInstance().getConfigurationFor(null);
        boolean useImplicitLocking = conf.useImplicitLocking();
        boolean restore = false;

        // prepare test case
        try
        {
            if(useImplicitLocking)
            {
                restore = true;
                conf.setUseImplicitLocking(false);
            }
            Implementation odmg = OJB.getInstance();
            Database db = odmg.newDatabase();
            db.open(databaseName, Database.OPEN_READ_WRITE);

            String name = "testImplicitLocking - " + System.currentTimeMillis();
            String queryString = "select sites from " + Site.class.getName() + " where name = $1";

            /* Create an object */
            Site site = new Site();
            site.setName(name);

            Transaction tx = odmg.newTransaction();
            tx.begin();
            tx.lock(site, Transaction.WRITE);
            tx.commit();

            /* Retrieve from the object created, and set the year*/
            OQLQuery query = odmg.newOQLQuery();
            query.create(queryString);
            query.bind(name);

            tx.begin();
            List result = (List) query.execute();
            assertEquals(1, result.size());
            site = (Site) result.get(0);
            assertNotNull(site);
            assertNull(site.getYear());
            tx.lock(site, Transaction.UPGRADE);
            site.setYear(new Integer(2003));

            tx.commit();

            /* Flush the cache, and retrieve the object again */
            query = odmg.newOQLQuery();
            query.create(queryString);
            query.bind(name);
            tx.begin();
            ((HasBroker) tx).getBroker().clearCache();
            result = (List) query.execute();
            assertEquals(1, result.size());
            site = (Site) result.get(0);
            assertNotNull(site);
            assertNotNull("year should not be null", site.getYear());
            tx.commit();

            db.close();
        }
        finally
        {
            // reset configuration
            if(restore)
            {
                conf.setUseImplicitLocking(useImplicitLocking);
            }
        }
    }
View Full Code Here

Examples of org.apache.ojb.broker.util.configuration.impl.OjbConfiguration

        an ODMG tx before any modifications are taking place.
        I simply moved the lock two lines up and the test passed.
     */
    public void testImplicitLocking() throws Exception
    {
        OjbConfiguration conf = (OjbConfiguration)OjbConfigurator.getInstance().getConfigurationFor(null);
        boolean useImplicitLocking = conf.useImplicitLocking();
        boolean restore = false;

        // prepare test case
        try
        {
            if(useImplicitLocking)
            {
                restore = true;
                conf.setUseImplicitLocking(false);
            }
            Implementation odmg = OJB.getInstance();
            Database db = odmg.newDatabase();
            db.open(databaseName, Database.OPEN_READ_WRITE);

            String name = "testImplicitLocking - " + System.currentTimeMillis();
            String queryString = "select sites from " + Site.class.getName() + " where name = $1";

            /* Create an object */
            Site site = new Site();
            site.setName(name);

            Transaction tx = odmg.newTransaction();
            tx.begin();
            tx.lock(site, Transaction.WRITE);
            tx.commit();

            /* Retrieve from the object created, and set the year*/
            OQLQuery query = odmg.newOQLQuery();
            query.create(queryString);
            query.bind(name);

            tx.begin();
            List result = (List) query.execute();
            assertEquals(1, result.size());
            site = (Site) result.get(0);
            assertNotNull(site);
            assertNull(site.getYear());
            tx.lock(site, Transaction.WRITE);
            site.setYear(new Integer(2003));

            tx.commit();

            /* Flush the cache, and retrieve the object again */
            query = odmg.newOQLQuery();
            query.create(queryString);
            query.bind(name);
            tx.begin();
            ((HasBroker) tx).getBroker().clearCache();
            result = (List) query.execute();
            assertEquals(1, result.size());
            site = (Site) result.get(0);
            assertNotNull(site);
            assertNotNull("year should not be null", site.getYear());
            tx.commit();

            db.close();
        }
        finally
        {
            // reset configuration
            if(restore)
            {
                conf.setUseImplicitLocking(useImplicitLocking);
            }
        }
    }
View Full Code Here

Examples of org.apache.ojb.broker.util.configuration.impl.OjbConfiguration

        try
        {
            // obtain broker instance
            broker = PersistenceBrokerFactory.defaultPersistenceBroker();
            // manipulate configuration to use maximum performance field access
            OjbConfiguration conf = (OjbConfiguration) PersistenceBrokerFactory.
                    getConfigurator().getConfigurationFor(null);
            conf.setPersistentFieldClass(PersistentFieldDirectAccessImpl.class);
        }
        catch (PBFactoryException e)
        {
        }
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.