Package org.apache.openjpa.conf

Examples of org.apache.openjpa.conf.OpenJPAConfigurationImpl


     */
    public static boolean run(final String[] args, Options opts) {
        return Configurations.runAgainstAllAnchors(opts,
            new Configurations.Runnable() {
            public boolean run(Options opts) throws IOException {
                OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
                try {
                    return PCEnhancer.run(conf, args, opts);
                } finally {
                    conf.close();
                }
            }
        });
    }
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

     * 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 static boolean run(final String[] args, Options opts) {
        return Configurations.runAgainstAllAnchors(opts,
            new Configurations.Runnable() {
            public boolean run(Options opts) throws IOException {
                OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
                try {
                    return PCEnhancer.run(conf, args, opts);
                } finally {
                    conf.close();
                }
            }
        });
    }
View Full Code Here

     */
    public static void main(String[] args)
        throws IOException {
        Options opts = new Options();
        args = opts.setFromCmdLine(args);
        OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
        try {
            if (!run(conf, args, opts))
                System.err.println(_loc.get("enhance-usage"));
        } finally {
            conf.close();
        }
    }
View Full Code Here

     */
    public static boolean run(final String[] args, Options opts) {
        return Configurations.runAgainstAllAnchors(opts,
            new Configurations.Runnable() {
            public boolean run(Options opts) throws IOException {
                OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
                try {
                    return PCEnhancer.run(conf, args, opts);
                } finally {
                    conf.close();
                }
            }
        });
    }
View Full Code Here

        }
    }

    private static void registerClassLoadEnhancer(Instrumentation inst,
        Options opts) {
        OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
        Configurations.populateConfiguration(conf, opts);
        // don't allow connections
        conf.setConnectionUserName(null);
        conf.setConnectionPassword(null);
        conf.setConnectionURL(null);
        conf.setConnectionDriverName(null);
        conf.setConnectionFactoryName(null);
        // set single class resolver
        final ClassLoader tmpLoader = (ClassLoader) AccessController
            .doPrivileged(J2DoPrivHelper
                .newTemporaryClassLoaderAction((ClassLoader) AccessController
                    .doPrivileged(J2DoPrivHelper.getContextClassLoaderAction())
                    ));
        conf.setClassResolver(new ClassResolver() {
            public ClassLoader getClassLoader(Class context, ClassLoader env) {
                return tmpLoader;
            }
        });
        conf.setReadOnly(Configuration.INIT_STATE_FREEZING);
        conf.instantiateAll(); // avoid threading issues

        PCClassFileTransformer transformer = new PCClassFileTransformer
            (conf.newMetaDataRepositoryInstance(), opts, tmpLoader);
        inst.addTransformer(transformer);
    }
View Full Code Here

     */
    public static boolean run(final String[] args, Options opts) {
        return Configurations.runAgainstAllAnchors(opts,
            new Configurations.Runnable() {
            public boolean run(Options opts) throws IOException {
                OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
                try {
                    return PCEnhancer.run(conf, args, opts);
                } finally {
                    conf.close();
                }
            }
        });
    }
View Full Code Here

        // Added for OPENJPA-993
        assertFalse(actual.contains("bad_provider"));
    }
    public void testEncryptionPluginConfiguration() throws Exception {
    PersistenceProductDerivation ppd = new PersistenceProductDerivation();
    OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
    String encryptedPassword = "encrypted_password";
    ClassLoader loader = null;

    ConfigurationProvider provider = ppd.load(
        PersistenceProductDerivation.RSRC_DEFAULT,
        "encryption_plugin_pu", loader);
    provider.setInto(conf);
    EncryptionProvider ep = conf.getEncryptionProvider();
    assertNotNull(ep);
    // Cast to test impl
    TestEncryptionProvider tep = (TestEncryptionProvider) ep;

    conf.setConnectionPassword(encryptedPassword);
    // Validate that when we get the ConnectionPassword from configuration
    // that it is decrypted
    assertEquals(TestEncryptionProvider.decryptedPassword, conf
        .getConnectionPassword());
    // Validate that the EncryptionProvider is called with the 'encrypted'
    // password
    assertEquals(encryptedPassword, tep.getEncryptedPassword());
  }
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.