001: /**
002: * Copyright (C) 2001-2005 France Telecom R&D
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */package org.objectweb.speedo.ejb.pobjects.basic;
018:
019: import junit.framework.Assert;
020:
021: import javax.persistence.Entity;
022: import javax.persistence.EntityListeners;
023: import javax.persistence.Id;
024: import javax.persistence.PostLoad;
025: import javax.persistence.PostPersist;
026: import javax.persistence.PostRemove;
027: import javax.persistence.PostUpdate;
028: import javax.persistence.PrePersist;
029: import javax.persistence.PreRemove;
030: import javax.persistence.PreUpdate;
031: import javax.persistence.Table;
032: import javax.persistence.Version;
033:
034: /**
035: * This class defines the callbacks associated to the lifecycle events of EJB3
036: * entities.
037: * @author P. Dechamboux
038: */
039: @Entity
040: @Table(name="EJB_CALLBACKDEF")
041: @EntityListeners({ExtCallBack.class})
042: public class CallbackDef {
043: @Id
044: private Long oid;
045: @Version
046: public int version;
047:
048: @PrePersist
049: public void prePersist() {
050:
051: }
052:
053: @PreRemove
054: public void preRemove() {
055:
056: }
057:
058: @PreUpdate
059: public void preUpdate() {
060:
061: }
062:
063: public void assign(Long longval) {
064: this .oid = longval;
065: }
066:
067: public void check(Long longval) {
068: Assert.assertEquals("bad boolean_field value", oid, longval);
069: }
070:
071: public Long retrieve_oid() {
072: return oid;
073: }
074:
075: public void assign_oid(Long oid) {
076: this .oid = oid;
077: }
078: }
079:
080: class ExtCallBack {
081: @PostPersist
082: public void PostPersist(Object o) {
083:
084: }
085:
086: @PostRemove
087: public void PostRemove(CallbackDef o) {
088:
089: }
090:
091: @PostUpdate
092: public void PostUpdate(Object o) {
093:
094: }
095:
096: @PostLoad
097: public void PostLoad(CallbackDef o) {
098:
099: }
100: }
|