Package org.apache.openjpa.conf

Examples of org.apache.openjpa.conf.OpenJPAConfigurationImpl


            return factory;
        }

        // standard brokerfactory getter implemented by subclasses
        public static BrokerFactoryTest newInstance(ConfigurationProvider cp) {
            OpenJPAConfigurationImpl conf = new OpenJPAConfigurationImpl();
            cp.setInto(conf);
            return new BrokerFactoryTest(conf);
        }
View Full Code Here


    @Override
    public boolean beforeConfigurationLoad(Configuration c) {
        if (!(c instanceof OpenJPAConfigurationImpl))
            return false;
       
        OpenJPAConfigurationImpl conf = (OpenJPAConfigurationImpl) c;
        conf.metaFactoryPlugin.setAlias(ALIAS_EJB.getName(), PersistenceMetaDataFactory.class.getName());
        conf.metaFactoryPlugin.setAlias(SPEC_JPA.getName(),  PersistenceMetaDataFactory.class.getName());
       
        conf.addValue(new EntityManagerFactoryValue());
       
        conf.readLockLevel.setAlias("optimistic", String.valueOf(MixedLockLevels.LOCK_OPTIMISTIC));
        conf.readLockLevel.setAlias("optimistic-force-increment", String
            .valueOf(MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT));
        conf.readLockLevel.setAlias("pessimistic-read", String
            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_READ));
        conf.readLockLevel.setAlias("pessimistic-write", String
            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_WRITE));
        conf.readLockLevel.setAlias("pessimistic-force-increment", String
            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT));

        conf.writeLockLevel.setAlias("optimistic", String
            .valueOf(MixedLockLevels.LOCK_OPTIMISTIC));
        conf.writeLockLevel.setAlias("optimistic-force-increment", String
            .valueOf(MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT));
        conf.writeLockLevel.setAlias("pessimistic-read", String
            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_READ));
        conf.writeLockLevel.setAlias("pessimistic-write", String
            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_WRITE));
        conf.writeLockLevel.setAlias("pessimistic-force-increment", String
            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT));

        conf.lockManagerPlugin.setAlias("mixed", "org.apache.openjpa.jdbc.kernel.MixedLockManager");

        configureBeanValidation(conf);
       
        conf.dataCacheMode = conf.addString(JPAProperties.CACHE_MODE);
        conf.dataCacheMode.setDefault(DataCacheMode.UNSPECIFIED.toString());
        conf.dataCacheMode.set(DataCacheMode.UNSPECIFIED.toString());

        return true;
    }
View Full Code Here

    public boolean afterSpecificationSet(Configuration c) {
        if (!OpenJPAConfigurationImpl.class.isInstance(c)
         && !SPEC_JPA.isSame(((OpenJPAConfiguration) c).getSpecification()))
            return false;
        OpenJPAConfigurationImpl conf = (OpenJPAConfigurationImpl) c;
        conf.metaFactoryPlugin.setDefault(SPEC_JPA.getName());
        conf.metaFactoryPlugin.setString(SPEC_JPA.getName());
        conf.lockManagerPlugin.setDefault("mixed");
        conf.lockManagerPlugin.setString("mixed");
        conf.nontransactionalWrite.setDefault("true");
        conf.nontransactionalWrite.set(true);
        Specification spec = ((OpenJPAConfiguration) c).getSpecificationInstance();
        int specVersion = spec.getVersion();
        Compatibility compatibility = conf.getCompatibilityInstance();
        spec.setCompatibility(compatibility);
        if (specVersion < 2) {
            compatibility.setFlushBeforeDetach(true);
            compatibility.setCopyOnDetach(true);
            compatibility.setPrivatePersistentProperties(true);
View Full Code Here

     * enhancement in ClassTransformerImpl. If OpenJPAConfigurationImpl
     * instance is used, configuration options declared in configuration
     * sub-class will not be recognized and a warning is posted in the log.
     */
    protected OpenJPAConfiguration newConfigurationImpl() {
        return new OpenJPAConfigurationImpl();
    }
View Full Code Here

    public TestNonPersistentFields(String test) {
        super(test, "metacactusapp");
    }

    public void setUp() {
        MetaDataRepository repos = new OpenJPAConfigurationImpl().
            newMetaDataRepositoryInstance();
        _meta = repos.getMetaData(NonPersistentFieldsPC.class, null, true);
    }
View Full Code Here

        super(test);
    }

    protected MetaDataRepository getRepository()
        throws Exception {
        OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
        MetaDataRepository repos = conf.newMetaDataRepositoryInstance();
        repos.getMetaData(MetaTest5.class, null, true);
        repos.getMetaData(MetaTest3.class, null, true);
        repos.getMetaData(MetaTest2.class, null, true);
        repos.getMetaData(MetaTest1.class, null, true);
        repos.getMetaData(MetaTest6.class, null, true);
View Full Code Here

public class TestEnhancementWithMultiplePUs
    extends AbstractCachedEMFTestCase {

    public void testExplicitEnhancementWithClassNotInFirstPU()
        throws ClassNotFoundException {
        OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
        Configurations.populateConfiguration(conf, new Options());
        MetaDataRepository repos = conf.getMetaDataRepositoryInstance();
        ClassLoader loader = AccessController
            .doPrivileged(J2DoPrivHelper.newTemporaryClassLoaderAction(
                getClass().getClassLoader()));
        Project project = new Project();
View Full Code Here

        return bc;
    }

    public void testEnhancementOfSecondPUWithClassNotInFirstPU()
        throws IOException {
        OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
        Options opts = new Options();
        opts.setProperty("p",
            "META-INF/persistence.xml#second-persistence-unit");
        Configurations.populateConfiguration(conf, opts);
        MetaDataRepository repos = conf.getMetaDataRepositoryInstance();
        ClassLoader loader = AccessController
            .doPrivileged(J2DoPrivHelper.newTemporaryClassLoaderAction(
                getClass().getClassLoader()));
        Project project = new Project();
View Full Code Here

        assertTrue(written.contains(className));
    }

    public void testEnhancementOfAllPUsWithinAResource()
        throws IOException {
        OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
        Options opts = new Options();
        opts.setProperty("p", "META-INF/persistence.xml");
        Configurations.populateConfiguration(conf, opts);
        MetaDataRepository repos = conf.getMetaDataRepositoryInstance();
        ClassLoader loader = AccessController
            .doPrivileged(J2DoPrivHelper.newTemporaryClassLoaderAction(
                getClass().getClassLoader()));
        Project project = new Project();
View Full Code Here

        map.put("openjpa.LockTimeout", new Integer(503));
        map.put("javax.persistence.query.timeout", new Integer(1500));

        // use new conf so no unexpected restrictions on type of connection
        // factory
        OpenJPAConfiguration conf = new OpenJPAConfigurationImpl(true, false);
        conf.fromProperties(map);
        assertEquals(cfactory, conf.getConnectionFactory());
        assertEquals(cfactory2, conf.getConnectionFactory2());
        assertEquals(false, conf.getOptimistic());
        assertEquals(503, conf.getLockTimeout());
        assertEquals(1500, conf.getQueryTimeout());

        OpenJPAConfiguration conf2 = new OpenJPAConfigurationImpl(true, false);
        conf2.fromProperties(map);
        assertEquals(conf, conf2);

        Map p = conf.toProperties(false);
        assertTrue(!p.containsKey("openjpa.ConnectionFactory"));
        assertTrue(!p.containsKey("openjpa.ConnectionFactory2"));
        assertEquals("false", p.get("openjpa.Optimistic"));
        assertEquals("503", p.get("openjpa.LockTimeout"));
        assertEquals(p, conf2.toProperties(false));

        map.put("openjpa.LockTimeout", new Integer(504));
        OpenJPAConfiguration conf3 = new OpenJPAConfigurationImpl(true, false);
        conf3.fromProperties(map);
        assertNotEquals(conf, conf3);
    }
View Full Code Here

TOP

Related Classes of org.apache.openjpa.conf.OpenJPAConfigurationImpl

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.