Examples of BrokerFactory


Examples of org.apache.openjpa.kernel.BrokerFactory

        args = opts.setFromCmdLine(args);
        boolean devpath = opts.getBooleanProperty("scanDevPath", "ScanDevPath",
            true);

        ConfigurationProvider cp = new MapConfigurationProvider(opts);
        BrokerFactory factory = Bootstrap.newBrokerFactory(cp, null);
        try {
            MetaDataCacheMaintenance maint = new MetaDataCacheMaintenance(
                factory, devpath);

            if (args.length != 1) {
                usage();
                return;
            }

            if ("store".equals(args[0]))
                maint.store();
            else if ("dump".equals(args[0]))
                maint.dump();
            else
                usage();
        } finally {
            factory.close();
        }
    }
View Full Code Here

Examples of org.apache.openjpa.kernel.BrokerFactory

    public TestBrokerFactoryPooling(String name) {
        super(name);
    }

    public void testPooling() {
        BrokerFactory bf0 = Bootstrap.getBrokerFactory();
        BrokerFactory bf1 = Bootstrap.getBrokerFactory();
        assertSame(bf0, bf1);
    }
View Full Code Here

Examples of org.apache.openjpa.kernel.BrokerFactory

        endTx(pm);
        endEm(pm);
    }

    private static BrokerFactory toBrokerFactory(EntityManagerFactory emf) {
        BrokerFactory bf = JPAFacadeHelper.toBrokerFactory(emf);
        if (bf instanceof DelegatingBrokerFactory)
            bf = ((DelegatingBrokerFactory) bf).getInnermostDelegate();
        return bf;
    }
View Full Code Here

Examples of org.apache.openjpa.kernel.BrokerFactory

            ConfigurationProvider cp = pd.load(resource, name, m);
            if (cp == null) {
                return null;
            }

            BrokerFactory factory = getBrokerFactory(cp, poolValue, null);
            OpenJPAConfiguration conf = factory.getConfiguration();
            _log = conf.getLog(OpenJPAConfiguration.LOG_RUNTIME);           
            pd.checkPuNameCollisions(_log,name);
           
            // add enhancer
            loadAgent(factory);
View Full Code Here

Examples of org.apache.openjpa.kernel.BrokerFactory

            // should be doing proper resource management.
            if (!Configurations.containsProperty(BrokerValue.KEY, cp.getProperties())) {
                cp.addProperty("openjpa." + BrokerValue.KEY, getDefaultBrokerAlias());
            }

            BrokerFactory factory = getBrokerFactory(cp, poolValue, pui.getClassLoader());
            if (transformerException != null) {
                Log log = factory.getConfiguration().getLog(OpenJPAConfiguration.LOG_RUNTIME);
                if (log.isTraceEnabled()) {
                    log.warn(_loc.get("transformer-registration-error-ex", pui), transformerException);
                } else {
                    log.warn(_loc.get("transformer-registration-error", pui));
                }
            }
            OpenJPAConfiguration conf = factory.getConfiguration();
            setPersistenceEnvironmentInfo(conf, pui);
            _log = conf.getLog(OpenJPAConfiguration.LOG_RUNTIME);

            // Create appropriate LifecycleEventManager
            loadValidator(factory);
View Full Code Here

Examples of org.apache.openjpa.kernel.BrokerFactory

        Map propsMap = new HashMap();
        propsMap.put("openjpa.DataCache", "true");
        propsMap.put("openjpa.RemoteCommitProvider", "sjvm");
        EntityManagerFactory emf = getEmf(propsMap);
        BrokerFactory factory = JPAFacadeHelper.toBrokerFactory(emf);

        Broker broker = factory.newBroker();
        broker.begin();
        broker.persist(new CacheObjectAChild1("foo", "foo", 0), null);
        broker.persist(new CacheObjectAChild1("bar", "bar", 1), null);
        broker.commit();
        broker.close();

        _broker = factory.newBroker();
    }
View Full Code Here

Examples of org.apache.openjpa.kernel.BrokerFactory

     */
    static void assertInCache(AbstractTestCase tc, Query query, Boolean inCache,
        Object[] args) {
        QueryKey qk = QueryKey.newInstance(query, args);
        Broker broker = query.getBroker();
        BrokerFactory factory = broker.getBrokerFactory();

        QueryCache qc = cacheManager(factory).getSystemQueryCache();
        if (inCache == Boolean.FALSE && qc.get(qk) != null) {
            tc.fail("query should not be in cache; was.");
        } else if (inCache == Boolean.TRUE || (inCache == null
View Full Code Here

Examples of org.apache.openjpa.kernel.BrokerFactory

            em.close();
        }
    }
   
    public void testDataCacheOneOneSetsIntermediate() {
        BrokerFactory factory = getBrokerFactory(new String[]{
            "openjpa.DataCache", "true",
            "openjpa.RemoteCommitProvider", "sjvm",
        });
       
        // get obj into cache
        Broker broker = factory.newBroker();
        try {
            broker.find(_pc, true, null);
        } finally {
            broker.close();
        }
       
        // test from cache
        broker = factory.newBroker();
        try {
            oneOneIntermediateTest(broker);
        } finally {
            broker.close();
            try {
                factory.close();
            } catch (Exception e) {
            }
        }
    }
View Full Code Here

Examples of org.apache.openjpa.kernel.BrokerFactory

    }
   
    protected boolean findPersistenceUnit() {
        if (_emf == null) {
            System.err.println("Discovering auxiliary Persistent Unit  " + _unit);
            BrokerFactory bf = AbstractBrokerFactory.getPooledFactoryForKey(_unit);
            if (bf != null) {
                _emf = (OpenJPAEntityManagerFactory)bf.getUserObject(JPAFacadeHelper.EMF_KEY);
            }
            System.err.println("Discovered auxiliary Persistent Unit  " + _unit + ":" + _emf);
        }
        return _emf != null;
    }
View Full Code Here

Examples of org.apache.openjpa.kernel.BrokerFactory

                // check if we've already warned for this query-factory combo
                StoreContext ctx = resolver.getQueryContext().getStoreContext();
                String query = currentQuery();
                if (ctx.getBroker() != null && query != null) {
                    String key = getClass().getName() + ":" + query;
                    BrokerFactory factory = ctx.getBroker().getBrokerFactory();
                    Object hasWarned = factory.getUserObject(key);
                    if (hasWarned != null)
                        break;
                    else
                        factory.putUserObject(key, Boolean.TRUE);
                }
                Log log = conf.getLog(OpenJPAConfiguration.LOG_QUERY);
                if (log.isWarnEnabled())
                    log.warn(_loc.get("query-extensions-warning", clause,
                        currentQuery()));
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.