Package org.apache.openjpa.event

Examples of org.apache.openjpa.event.LifecycleEventManager$ListenerList


        // called again?
        if (field != -1 && isLoading())
            return;

        // no listeners?
        LifecycleEventManager mgr = _broker.getLifecycleEventManager();
        if (mgr == null || !mgr.isActive(_meta) || !mgr.hasLoadListeners(getManagedInstance(), _meta))
            return;

        if (fetch == null)
            fetch = _broker.getFetchConfiguration();
        // is this field a post-load field?
View Full Code Here


    public String getLifecycleEventManager() {
        return lifecycleEventManager.getString();
    }

    public LifecycleEventManager getLifecycleEventManagerInstance() {
        LifecycleEventManager lem = null;
        if (!getCompatibilityInstance().isSingletonLifecycleEventManager() ||
                (lem = (LifecycleEventManager)lifecycleEventManager.get()) == null) {
            lem = (LifecycleEventManager)lifecycleEventManager
                .instantiate(LifecycleEventManager.class, this);
        }
View Full Code Here

                return null;

            if (!isUpdate) {
                // if there are any delete callbacks, we need to
                // execute in-memory so the callbacks are invoked
                LifecycleEventManager mgr = ctx.getStoreContext().getBroker()
                    .getLifecycleEventManager();
                if (mgr.hasDeleteListeners(null, mappings[i]))
                    return null;
            }
        }

        JDBCFetchConfiguration fetch = (JDBCFetchConfiguration)
View Full Code Here

            ((OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.cast(
                OpenJPAPersistence.createEntityManagerFactory("TestConv2", "")))
                .
                    getConfiguration().getMetaDataRepositoryInstance();
        ClassMetaData meta = repos.getMetaData(RuntimeTest2.class, null, true);
        LifecycleEventManager mgr = new LifecycleEventManager();
        RuntimeTest2 pc = new RuntimeTest2();
        Listener listener = new Listener();

        assertFalse(mgr.hasLoadListeners(pc, meta));
        assertFalse(mgr.hasStoreListeners(pc, meta));

        mgr.addListener(listener, null);
        assertEquals(0, listener.load);
        assertEquals(0, listener.store);
        assertTrue(mgr.hasLoadListeners(pc, meta));
        assertTrue(mgr.hasStoreListeners(pc, meta));
        assertFalse(mgr.hasDirtyListeners(pc, meta));
        assertEquals(0, listener.load);
        assertEquals(0, listener.store);

        Listener listener2 = new Listener();
        mgr.addListener(listener2, null);
        assertTrue(mgr.hasLoadListeners(pc, meta));
        assertTrue(mgr.hasStoreListeners(pc, meta));
        assertFalse(mgr.hasDirtyListeners(pc, meta));

        mgr.fireEvent(pc, meta, LifecycleEvent.AFTER_LOAD);
        assertEquals(1, listener.load);
        assertEquals(0, listener.store);
        assertEquals(0, listener.preStore);
        assertEquals(1, listener2.load);
        assertEquals(0, listener2.store);

        mgr.removeListener(listener2);
        assertTrue(mgr.hasLoadListeners(pc, meta));
        assertTrue(mgr.hasStoreListeners(pc, meta));
        assertFalse(mgr.hasDirtyListeners(pc, meta));

        mgr.fireEvent(pc, meta, LifecycleEvent.AFTER_LOAD);
        assertEquals(2, listener.load);
        assertEquals(0, listener.store);
        assertEquals(0, listener.preStore);
        assertEquals(1, listener2.load);
        assertEquals(0, listener2.store);

        mgr.fireEvent(pc, meta, LifecycleEvent.AFTER_STORE);
        assertEquals(2, listener.load);
        assertEquals(1, listener.store);
        assertEquals(0, listener.preStore);
        assertEquals(1, listener2.load);
        assertEquals(0, listener2.store);

        mgr.fireEvent(pc, meta, LifecycleEvent.BEFORE_STORE);
        assertEquals(2, listener.load);
        assertEquals(2, listener.store);
        assertEquals(1, listener.preStore);
        assertEquals(1, listener2.load);
        assertEquals(0, listener2.store);

        mgr.fireEvent(pc, meta, LifecycleEvent.AFTER_DIRTY);
        assertEquals(2, listener.load);
        assertEquals(2, listener.store);

        mgr.removeListener(listener);
        assertFalse(mgr.hasLoadListeners(pc, meta));
        assertFalse(mgr.hasStoreListeners(pc, meta));
        mgr.fireEvent(pc, meta, LifecycleEvent.AFTER_STORE);
        assertEquals(2, listener.load);
        assertEquals(2, listener.store);
    }
View Full Code Here

                OpenJPAPersistence.createEntityManagerFactory("TestConv2", "")))
                .
                    getConfiguration().getMetaDataRepositoryInstance();
        ClassMetaData meta = repos.getMetaData(RuntimeTest2.class, null, true);

        LifecycleEventManager mgr = new LifecycleEventManager();
        RuntimeTest2 pc = new RuntimeTest2();
        Listener listener = new Listener();

        assertFalse(mgr.hasLoadListeners(pc, meta));
        assertFalse(mgr.hasStoreListeners(pc, meta));

        mgr.addListener(listener, new Class[]{ RuntimeTest1.class });
        assertEquals(0, listener.load);
        assertEquals(0, listener.store);
        assertTrue(mgr.hasLoadListeners(pc, meta));
        assertTrue(mgr.hasStoreListeners(pc, meta));
        assertFalse(mgr.hasDirtyListeners(pc, meta));
        assertFalse(mgr.hasLoadListeners(new RuntimeTest4("foo"), meta));
        assertEquals(0, listener.load);
        assertEquals(0, listener.store);

        Listener listener2 = new Listener();
        mgr.addListener(listener2, new Class[]{ RuntimeTest2.class });
        assertTrue(mgr.hasLoadListeners(pc, meta));
        assertTrue(mgr.hasStoreListeners(pc, meta));
        assertFalse(mgr.hasDirtyListeners(pc, meta));
        assertFalse(mgr.hasLoadListeners(new RuntimeTest4("foo"), meta));

        mgr.fireEvent(pc, meta, LifecycleEvent.AFTER_LOAD);
        assertEquals(1, listener.load);
        assertEquals(0, listener.store);
        assertEquals(1, listener2.load);
        assertEquals(0, listener2.store);

        mgr.fireEvent(pc, meta, LifecycleEvent.AFTER_LOAD);
        assertEquals(2, listener.load);
        assertEquals(0, listener.store);
        assertEquals(2, listener2.load);
        assertEquals(0, listener2.store);

        mgr.fireEvent(new RuntimeTest1(), meta, LifecycleEvent.AFTER_LOAD);
        assertEquals(3, listener.load);
        assertEquals(0, listener.store);
        assertEquals(2, listener2.load);
        assertEquals(0, listener2.store);

        mgr.removeListener(listener2);
        assertTrue(mgr.hasLoadListeners(pc, meta));
        assertTrue(mgr.hasStoreListeners(pc, meta));

        mgr.fireEvent(pc, meta, LifecycleEvent.AFTER_STORE);
        assertEquals(3, listener.load);
        assertEquals(1, listener.store);
        assertEquals(2, listener2.load);
        assertEquals(0, listener2.store);

        mgr.fireEvent(pc, meta, LifecycleEvent.AFTER_DIRTY);
        assertEquals(3, listener.load);
        assertEquals(1, listener.store);

        mgr.fireEvent(new RuntimeTest4("foo"), meta,
            LifecycleEvent.AFTER_STORE);
        assertEquals(3, listener.load);
        assertEquals(1, listener.store);

        mgr.removeListener(listener);
        assertFalse(mgr.hasLoadListeners(pc, meta));
        assertFalse(mgr.hasStoreListeners(pc, meta));
        mgr.fireEvent(pc, meta, LifecycleEvent.AFTER_STORE);
        assertEquals(3, listener.load);
        assertEquals(1, listener.store);
    }
View Full Code Here

                return null;

            if (!isUpdate) {
                // if there are any delete callbacks, we need to
                // execute in-memory so the callbacks are invoked
                LifecycleEventManager mgr = ctx.getStoreContext().getBroker()
                    .getLifecycleEventManager();
                if (mgr.hasDeleteListeners(null, mappings[i]))
                    return null;
            }
        }

        JDBCFetchConfiguration fetch = (JDBCFetchConfiguration)
View Full Code Here

    public String getLifecycleEventManager() {
        return lifecycleEventManager.getString();
    }

    public LifecycleEventManager getLifecycleEventManagerInstance() {
        LifecycleEventManager lem = (LifecycleEventManager)
            lifecycleEventManager.get();
        if (lem == null) {
            lem = (LifecycleEventManager)lifecycleEventManager
                .instantiate(LifecycleEventManager.class, this);
        }
View Full Code Here

        // called again?
        if (field != -1 && isLoading())
            return;

        // no listeners?
        LifecycleEventManager mgr = _broker.getLifecycleEventManager();
        if (mgr == null || !mgr.hasLoadListeners(getManagedInstance(), _meta))
            return;

        if (fetch == null)
            fetch = _broker.getFetchConfiguration();
        // is this field a post-load field?
View Full Code Here

            _runtime = _conf.getManagedRuntimeInstance();
        else
            _runtime = new LocalManagedRuntime(this);

        if (!fromDeserialization) {
            _lifeEventManager = new LifecycleEventManager();
            _transEventManager = new TransactionEventManager();
            int cmode = _conf.getMetaDataRepositoryInstance().
                getMetaDataFactory().getDefaults().getCallbackMode();
            setLifecycleListenerCallbackMode(cmode);
            setTransactionListenerCallbackMode(cmode);
View Full Code Here

        // called again?
        if (field != -1 && isLoading())
            return;

        // no listeners?
        LifecycleEventManager mgr = _broker.getLifecycleEventManager();
        if (mgr == null || !mgr.hasLoadListeners(getManagedInstance(), _meta))
            return;

        if (fetch == null)
            fetch = _broker.getFetchConfiguration();
        // is this field a post-load field?
View Full Code Here

TOP

Related Classes of org.apache.openjpa.event.LifecycleEventManager$ListenerList

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.