Package org.apache.cayenne.reflect

Examples of org.apache.cayenne.reflect.LifecycleCallbackRegistry$AnnotationReader


        assertEquals(1, a1.getPostLoaded());
        assertSame(a1, listener.getPublicCalledbackEntity());
    }

    public void testPostLoad_Relationship() throws Exception {
        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();

        registry.addCallback(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
        MockCallingBackListener listener = new MockCallingBackListener();
        registry.addListener(
                LifecycleEvent.POST_LOAD,
                Artist.class,
                listener,
                "publicCallback");
View Full Code Here


        assertEquals(1, a1.getPostLoaded());
        assertSame(a1, listener.getPublicCalledbackEntity());
    }

    public void testPostLoad_Prefetch() throws Exception {
        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();

        registry.addCallback(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
        MockCallingBackListener listener = new MockCallingBackListener();
        registry.addListener(
                LifecycleEvent.POST_LOAD,
                Artist.class,
                listener,
                "publicCallback");
View Full Code Here

        assertEquals(1, a1.getPostLoaded());
        assertSame(a1, listener.getPublicCalledbackEntity());
    }

    public void testPostLoad_LocalObject() throws Exception {
        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();

        Artist a1 = context.newObject(Artist.class);
        a1.setArtistName("XX");
        context.commitChanges();

        registry.addCallback(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
        MockCallingBackListener listener = new MockCallingBackListener();
        registry.addListener(
                LifecycleEvent.POST_LOAD,
                Artist.class,
                listener,
                "publicCallback");
View Full Code Here

        assertEquals(1, a2.getPostLoaded());
        assertSame(a2, listener.getPublicCalledbackEntity());
    }

    public void testPostLoad_ThatModifiesObject() {
        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();

        registry.addCallback(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
        MockCallingBackListener listener = new MockCallingBackListener() {
          @Override
          public void publicCallback(Object entity) {
            super.publicCallback(entity);
            Artist a = (Artist)entity;
            a.setArtistName("Changed"); // modify object during postLoad callback
          }
        };
        registry.addListener(
                LifecycleEvent.POST_LOAD,
                Artist.class,
                listener,
                "publicCallback");
View Full Code Here

        assertSame(a1, listener.getPublicCalledbackEntity());
    }
   
    public void testPreUpdate() {

        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();

        Artist a1 = context.newObject(Artist.class);
        a1.setArtistName("XX");
        context.commitChanges();
        assertFalse(a1.isPreUpdated());

        a1.setArtistName("YY");
        context.commitChanges();
        assertFalse(a1.isPreUpdated());

        registry
                .addCallback(LifecycleEvent.PRE_UPDATE, Artist.class, "preUpdateCallback");
        a1.setArtistName("ZZ");
        context.commitChanges();
        assertTrue(a1.isPreUpdated());

        a1.resetCallbackFlags();
        assertFalse(a1.isPreUpdated());

        MockCallingBackListener listener2 = new MockCallingBackListener();
        registry.addListener(
                LifecycleEvent.PRE_UPDATE,
                Artist.class,
                listener2,
                "publicCallback");
View Full Code Here

        assertSame(a1, listener2.getPublicCalledbackEntity());
    }

    public void testPostUpdate() {

        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();

        Artist a1 = context.newObject(Artist.class);
        a1.setArtistName("XX");
        context.commitChanges();
        assertFalse(a1.isPostUpdated());

        a1.setArtistName("YY");
        context.commitChanges();
        assertFalse(a1.isPostUpdated());

        registry.addCallback(
                LifecycleEvent.POST_UPDATE,
                Artist.class,
                "postUpdateCallback");
        a1.setArtistName("ZZ");
        context.commitChanges();
        assertTrue(a1.isPostUpdated());

        a1.resetCallbackFlags();
        assertFalse(a1.isPostUpdated());

        MockCallingBackListener listener2 = new MockCallingBackListener();
        registry.addListener(
                LifecycleEvent.POST_UPDATE,
                Artist.class,
                listener2,
                "publicCallback");
View Full Code Here

        assertSame(a1, listener2.getPublicCalledbackEntity());
    }

    public void testPostRemove() {

        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();

        Artist a1 = context.newObject(Artist.class);
        a1.setArtistName("XX");
        context.commitChanges();

        registry.addCallback(
                LifecycleEvent.POST_REMOVE,
                Artist.class,
                "postRemoveCallback");
        MockCallingBackListener listener2 = new MockCallingBackListener();
        registry.addListener(
                LifecycleEvent.POST_REMOVE,
                Artist.class,
                listener2,
                "publicCallback");
View Full Code Here

        assertSame(a1, listener2.getPublicCalledbackEntity());
    }

    public void testPostRemove_UpdatedDeleted() {

        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();

        Artist a1 = context.newObject(Artist.class);
        a1.setArtistName("XX");
        context.commitChanges();

        MockCallingBackListener listener1 = new MockCallingBackListener();
        registry.addListener(
                LifecycleEvent.POST_REMOVE,
                Artist.class,
                listener1,
                "publicCallback");

        MockCallingBackListener listener2 = new MockCallingBackListener();
        registry.addListener(
                LifecycleEvent.POST_UPDATE,
                Artist.class,
                listener2,
                "publicCallback");
View Full Code Here

        assertSame(a1, listener1.getPublicCalledbackEntity());
    }

    public void testPostRemove_InsertedUpdatedDeleted() {

        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();

        MockCallingBackListener listener0 = new MockCallingBackListener();
        registry.addListener(
                LifecycleEvent.POST_PERSIST,
                Artist.class,
                listener0,
                "publicCallback");

        MockCallingBackListener listener1 = new MockCallingBackListener();
        registry.addListener(
                LifecycleEvent.POST_REMOVE,
                Artist.class,
                listener1,
                "publicCallback");

        MockCallingBackListener listener2 = new MockCallingBackListener();
        registry.addListener(
                LifecycleEvent.POST_UPDATE,
                Artist.class,
                listener2,
                "publicCallback");
View Full Code Here

        assertNull(listener2.getPublicCalledbackEntity());
    }

    public void testPostPersist() {

        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();

        Artist a1 = context.newObject(Artist.class);
        a1.setArtistName("XX");
        context.commitChanges();
        assertFalse(a1.isPostPersisted());

        registry.addCallback(
                LifecycleEvent.POST_PERSIST,
                Artist.class,
                "postPersistCallback");
        MockCallingBackListener listener2 = new MockCallingBackListener() {

            @Override
            public void publicCallback(Object entity) {
                super.publicCallback(entity);
                assertFalse(((Persistent) entity).getObjectId().isTemporary());
            }
        };
        registry.addListener(
                LifecycleEvent.POST_PERSIST,
                Artist.class,
                listener2,
                "publicCallback");
View Full Code Here

TOP

Related Classes of org.apache.cayenne.reflect.LifecycleCallbackRegistry$AnnotationReader

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.