Examples of TimeStamped


Examples of com.spaceprogram.simplejpa.model.Timestamped

    @PrePersist
    public void prePersist(Object object) {
        System.out.println("prePersist");
        if(object instanceof Timestamped){
            System.out.println("Setting timestamps.");
            Timestamped timestamped = (Timestamped) object;
            Date now = new Date();
            timestamped.setCreated(now);
            timestamped.setUpdated(now);
        }
    }
View Full Code Here

Examples of com.spaceprogram.simplejpa.model.Timestamped

    @PreUpdate
    public void preUpdate(Object object) {
        System.out.println("preUpdate.");
        if(object instanceof Timestamped){
            System.out.println("Setting timestamps.");
            Timestamped timestamped = (Timestamped) object;
            timestamped.setUpdated(new Date());
        }
    }
View Full Code Here

Examples of org.springframework.aop.framework.TimeStamped

    TestBean raw = new TestBean();
    assertTrue(! (raw instanceof TimeStamped));
    ProxyFactory factory = new ProxyFactory(raw);
 
    MockControl tsControl = MockControl.createControl(TimeStamped.class);
    TimeStamped ts = (TimeStamped) tsControl.getMock();
    ts.getTimeStamp();
    long timestamp = 111L;
    tsControl.setReturnValue(timestamp, 1);
    tsControl.replay();

    factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts)));
   
    TimeStamped tsp = (TimeStamped) factory.getProxy();
    assertTrue(tsp.getTimeStamp() == timestamp);
 
    tsControl.verify();
  }
View Full Code Here

Examples of org.springframework.aop.framework.TimeStamped

    tsControl.setReturnValue(timestamp, 1);
    tsControl.replay();

    factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts), TimeStamped.class));

    TimeStamped tsp = (TimeStamped) factory.getProxy();
    assertTrue(!(tsp instanceof SubTimeStamped));
    assertTrue(tsp.getTimeStamp() == timestamp);

    tsControl.verify();
  }
View Full Code Here

Examples of org.springframework.aop.framework.TimeStamped

   
    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvisor(0, new DefaultIntroductionAdvisor(ii));
   
    //assertTrue(Arrays.binarySearch(pf.getProxiedInterfaces(), TimeStamped.class) != -1);
    TimeStamped ts = (TimeStamped) pf.getProxy();
   
    assertTrue(ts.getTimeStamp() == t);
    ((ITest) ts).foo();
   
    ((ITestBean) ts).getAge();
  }
View Full Code Here

Examples of org.springframework.aop.framework.TimeStamped

    IntroductionAdvisor ia = new DefaultIntroductionAdvisor(ii);
    assertTrue(ia.isPerInstance());
    pf.addAdvisor(0, ia);
   
    //assertTrue(Arrays.binarySearch(pf.getProxiedInterfaces(), TimeStamped.class) != -1);
    TimeStamped ts = (TimeStamped) pf.getProxy();
   
    assertTrue(ts instanceof TimeStamped);
    // Shoulnd't proxy framework interfaces
    assertTrue(!(ts instanceof MethodInterceptor));
    assertTrue(!(ts instanceof IntroductionInterceptor));
   
    assertTrue(ts.getTimeStamp() == t);
    ((ITest) ts).foo();
    ((ITestBean) ts).getAge();
   
    // Test removal
    ii.suppressInterface(TimeStamped.class);
View Full Code Here

Examples of org.springframework.aop.framework.TimeStamped

  public void testIntroductionInterceptorDoesntReplaceToString() throws Exception {
    TestBean raw = new TestBean();
    assertTrue(! (raw instanceof TimeStamped));
    ProxyFactory factory = new ProxyFactory(raw);
 
    TimeStamped ts = new SerializableTimeStamped(0);

    factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts) {
      public String toString() {
        throw new UnsupportedOperationException("Shouldn't be invoked");
      }
    }));
   
    TimeStamped tsp = (TimeStamped) factory.getProxy();
    assertEquals(0, tsp.getTimeStamp());
 
    assertEquals(raw.toString(), tsp.toString());
  }
View Full Code Here

Examples of org.springframework.aop.framework.TimeStamped

    serializableTarget.setName("Tony");
   
    ProxyFactory factory = new ProxyFactory(serializableTarget);
    factory.addInterface(Person.class);
    long time = 1000;
    TimeStamped ts = new SerializableTimeStamped(time);
 
    factory.addAdvisor(new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts)));
    factory.addAdvice(new SerializableNopInterceptor());
   
    Person p = (Person) factory.getProxy();
View Full Code Here

Examples of org.springframework.aop.framework.TimeStamped

    TestBean target = new TargetClass(t + 1);
 
    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvisor(0, new DefaultIntroductionAdvisor(ii));
 
    TimeStamped ts = (TimeStamped) pf.getProxy();
    // From introduction interceptor, not target
    assertTrue(ts.getTimeStamp() == t);
  }
View Full Code Here

Examples of org.springframework.tests.TimeStamped

    tb.setName(name);
    ProxyFactory pc = new ProxyFactory(tb);
    NopInterceptor di = new NopInterceptor();
    pc.addAdvice(di);
    final long ts = 37;
    pc.addAdvice(new DelegatingIntroductionInterceptor(new TimeStamped() {
      @Override
      public long getTimeStamp() {
        return ts;
      }
    }));

    ITestBean proxied = (ITestBean) createProxy(pc);
    assertEquals(name, proxied.getName());
    TimeStamped intro = (TimeStamped) proxied;
    assertEquals(ts, intro.getTimeStamp());
  }
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.