| 1 | /** |
| 2 | * Copyright (C) 2008 NetMind Consulting Bt. |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Lesser General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 3 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Lesser General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Lesser General Public |
| 15 | * License along with this library; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | */ |
| 18 | |
| 19 | package hu.netmind.beankeeper.lock.impl; |
| 20 | |
| 21 | import java.io.Serializable; |
| 22 | import java.util.Date; |
| 23 | import hu.netmind.beankeeper.object.PersistenceMetaData; |
| 24 | import hu.netmind.beankeeper.lock.*; |
| 25 | |
| 26 | /** |
| 27 | * Meta-data for locking objects. |
| 28 | * @author Brautigam Robert |
| 29 | * @version CVS Revision: $Revision$ |
| 30 | */ |
| 31 | public class LockMetaData implements Comparable, Serializable, PersistenceMetaData |
| 32 | { |
| 33 | private Long objectId; |
| 34 | private Class objectClass; |
| 35 | private Long lastCurrentSerial; |
| 36 | private Long startSerial; |
| 37 | private Long endSerial; |
| 38 | |
| 39 | public String toString() |
| 40 | { |
| 41 | if ( objectId == null ) |
| 42 | return "[Lock class "+objectClass.getName()+" ("+lastCurrentSerial+")"+"]"; |
| 43 | else |
| 44 | return "[Lock object "+objectClass.getName()+":"+objectId+" ("+lastCurrentSerial+")]"; |
| 45 | } |
| 46 | |
| 47 | public int compareTo(Object obj) |
| 48 | { |
| 49 | LockMetaData o = (LockMetaData) obj; |
| 50 | if ( (o.objectId==null) && (objectId==null) ) |
| 51 | { |
| 52 | // Two classes, compare with names |
| 53 | return objectClass.getName().compareTo(o.objectClass.getName()); |
| 54 | } else if ( (o.objectId!=null) && (objectId==null) ) { |
| 55 | // This is a class, other is not, so this is first |
| 56 | return -1; |
| 57 | } else if ( (o.objectId==null) && (objectId!=null) ) { |
| 58 | // Other way around |
| 59 | return 1; |
| 60 | } |
| 61 | // Default, both are objects |
| 62 | return objectId.compareTo(o.objectId); |
| 63 | } |
| 64 | |
| 65 | public Long getPersistenceId() |
| 66 | { |
| 67 | return objectId; |
| 68 | } |
| 69 | public void setPersistenceId(Long objectId) |
| 70 | { |
| 71 | this.objectId=objectId; |
| 72 | } |
| 73 | |
| 74 | public Class getObjectClass() |
| 75 | { |
| 76 | return objectClass; |
| 77 | } |
| 78 | public void setObjectClass(Class objectClass) |
| 79 | { |
| 80 | this.objectClass=objectClass; |
| 81 | } |
| 82 | |
| 83 | public Long getPersistenceStart() |
| 84 | { |
| 85 | return startSerial; |
| 86 | } |
| 87 | public void setPersistenceStart(Long startSerial) |
| 88 | { |
| 89 | this.startSerial=startSerial; |
| 90 | } |
| 91 | |
| 92 | public Long getPersistenceEnd() |
| 93 | { |
| 94 | return endSerial; |
| 95 | } |
| 96 | public void setPersistenceEnd(Long endSerial) |
| 97 | { |
| 98 | this.endSerial=endSerial; |
| 99 | } |
| 100 | |
| 101 | public Long getLastCurrentSerial() |
| 102 | { |
| 103 | return lastCurrentSerial; |
| 104 | } |
| 105 | public void setLastCurrentSerial(Long lastCurrentSerial) |
| 106 | { |
| 107 | this.lastCurrentSerial=lastCurrentSerial; |
| 108 | } |
| 109 | |
| 110 | public Date getCreationDate() |
| 111 | { |
| 112 | return null; |
| 113 | } |
| 114 | public Date getRemoveDate() |
| 115 | { |
| 116 | return null; |
| 117 | } |
| 118 | public Long getRegistrationSerial() |
| 119 | { |
| 120 | return null; |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | |