Package org.apache.openjpa.conf

Examples of org.apache.openjpa.conf.OpenJPAConfigurationImpl


        final String[] arguments = opts.setFromCmdLine(args);
        boolean ret = (args.length > 0) &&
            Configurations.runAgainstAllAnchors(opts,
            new Configurations.Runnable() {
            public boolean run(Options opts) throws Exception {
                OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
                try {
                    return MetaDataTool.run(conf, arguments, opts);
                } finally {
                    conf.close();
                }
            }
        });
        if (!ret) {
            // START - ALLOW PRINT STATEMENTS
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));


        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.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

        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(false, conf.getPostLoadOnMerge());
        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

    }

    public void testBeanAccessors()
        throws Exception {
        OpenJPAConfiguration conf = getConfiguration();
        OpenJPAConfigurationImpl simp = (OpenJPAConfigurationImpl) conf.clone();

        Value[] values = simp.getValues();
        PropertyDescriptor[] pds = simp.getPropertyDescriptors();
        List failures = new ArrayList();
        for (int i = 0; i < values.length; i++) {
            try {
                assertNotNull(pds[i].getShortDescription());
                assertNotNull(pds[i].getDisplayName());
View Full Code Here

    /**
     * Tests that invalid plug-in values throw the appropriate exception
     * type.
     */
    public void testInvalidPlugins() {
        OpenJPAConfiguration config = new OpenJPAConfigurationImpl();
        config.setLog("log3j");
        try {
            config.getLogFactory().getLog("Foo");
            fail("getting the Foo log should have failed");
        } catch (RuntimeException re) {
            // as expected ... make sure the exception suggests the
            // name "log4j" in the message
            assertTrue(-1 != re.getMessage().indexOf("log4j"));
View Full Code Here

     * data is maintained at the factory level and is available to all OpenJPA
     * components; therefore it is a good place to maintain shared resources
     * such as connection pools, etc.
     */
    protected OpenJPAConfiguration newConfiguration() {
        return new OpenJPAConfigurationImpl();
    }
View Full Code Here

    public void testInvalidConfigurationWarnings() {
        Properties props = new Properties();
        props.setProperty("openjpa.MaxxFetchDepth", "1");

        OpenJPAConfiguration config = new OpenJPAConfigurationImpl();
        // track the messages
        BufferedLogFactory log = new BufferedLogFactory();
        config.setLogFactory(log);

        config.fromProperties(props);

        // make sure we got a warning that contains the string with the
        // bad property name and a hint for the valid property name.
        log.assertLogMessage("*\"openjpa.MaxxFetchDepth\"*");
        log.assertLogMessage("*\"openjpa.MaxFetchDepth\"*");

        log.clear();

        // now make sure we do *not* try to validate sub-configurations (such
        // as openjpa.jdbc.Foo).
        props.clear();
        props.setProperty("openjpa.jdbc.Foo", "XXX");
        props.setProperty("oponjpa", "XXX");
        config.fromProperties(props);
        log.assertNoLogMessage("*\"openjpa.jdbc.Foo\"*");
        log.assertNoLogMessage("*\"oponjpa\"*");
    }
View Full Code Here

    /**
     * Tests that invalid fixed-list values throw the appropriate exception
     * type.
     */
    public void testInvalidNonPluginValues() {
        OpenJPAConfiguration config = new OpenJPAConfigurationImpl();
        try {
            config.setConnectionFactoryMode("aoeu");
            fail("setting the ConnectionFactoryMode to aoeu should fail");
        } catch (RuntimeException re) {
            // as expected ... make sure the exception suggests the
            // valid names in the message.
            assertTrue(-1 != re.getMessage().indexOf("managed"));
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

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.