Source Code Cross Referenced for EntityLockImpl.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » concurrency » locking » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » uPortal_rel 2 6 1 GA » org.jasig.portal.concurrency.locking 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2002 The JA-SIG Collaborative.  All rights reserved.
002:         *  See license distributed with this file and
003:         *  available online at http://www.uportal.org/license.html
004:         */
005:
006:        package org.jasig.portal.concurrency.locking;
007:
008:        import java.util.Date;
009:
010:        import org.jasig.portal.concurrency.IEntityLock;
011:        import org.jasig.portal.concurrency.IEntityLockService;
012:        import org.jasig.portal.concurrency.LockingException;
013:
014:        /**
015:         * An implementation of IEntityLock.  A lock is granted to a
016:         * <code>lockOwner</code> for an <code>entityType</code> and
017:         * <code>entityKey</code>.  It guarantees some degree of exclusive
018:         * access to the entity, depending on <code>lockType</code> and
019:         * <code>expirationTime</code>.
020:         *
021:         * @author Dan Ellentuck
022:         * @version $Revision: 34757 $
023:         * @see org.jasig.portal.concurrency.IEntityLock
024:         */
025:        public class EntityLockImpl implements  IEntityLock {
026:            private Class entityType;
027:            private String entityKey;
028:            private String lockOwner;
029:            private Date expirationTime;
030:            private int lockType;
031:            private IEntityLockService service;
032:
033:            /**
034:             *
035:             */
036:            protected EntityLockImpl(Class newEntityType, String newEntityKey,
037:                    int newLockType, Date newExpirationTime, String newLockOwner) {
038:                super ();
039:                setEntityType(newEntityType);
040:                setEntityKey(newEntityKey);
041:                setLockType(newLockType);
042:                setExpirationTime(newExpirationTime);
043:                setLockOwner(newLockOwner);
044:            }
045:
046:            /**
047:             *
048:             */
049:            protected EntityLockImpl(Class newEntityType, String newEntityKey,
050:                    int newLockType, Date newExpirationTime,
051:                    String newLockOwner, IEntityLockService newService) {
052:                super ();
053:                setEntityType(newEntityType);
054:                setEntityKey(newEntityKey);
055:                setLockType(newLockType);
056:                setExpirationTime(newExpirationTime);
057:                setLockOwner(newLockOwner);
058:                setService(newService);
059:            }
060:
061:            /**
062:             * Delegate to the service.
063:             * @param newType int
064:             * @exception org.jasig.portal.concurrency.LockingException - if the conversion fails.
065:             */
066:            public void convert(int newType) throws LockingException {
067:                getService().convert(this , newType);
068:            }
069:
070:            /**
071:             * Delegate to the service.
072:             * @param newType int
073:             * @param duration int
074:             * @exception org.jasig.portal.concurrency.LockingException - if the conversion fails.
075:             */
076:            public void convert(int newType, int duration)
077:                    throws LockingException {
078:                getService().convert(this , newType);
079:            }
080:
081:            /**
082:             * @param obj the Object to compare with
083:             * @return true if these Objects are equal; false otherwise.
084:             * @see java.util.Hashtable
085:             */
086:            public boolean equals(Object obj) {
087:                if (obj == null)
088:                    return false;
089:                if (obj == this )
090:                    return true;
091:                if (!(obj instanceof  EntityLockImpl))
092:                    return false;
093:
094:                IEntityLock candidate = (IEntityLock) obj;
095:                return this .getEntityType().equals(candidate.getEntityType())
096:                        && this .getEntityKey().equals(candidate.getEntityKey())
097:                        && this .getLockOwner().equals(candidate.getLockOwner())
098:                        && this .getLockType() == candidate.getLockType()
099:                        && this .getExpirationTime().equals(
100:                                candidate.getExpirationTime());
101:            }
102:
103:            /**
104:             */
105:            protected void expire() {
106:                setExpirationTime(new Date(0));
107:            }
108:
109:            /**
110:             * @throws Throwable
111:             */
112:            protected void finalize() throws Throwable {
113:                super .finalize();
114:            }
115:
116:            /**
117:             * @return java.lang.String
118:             */
119:            public String getEntityKey() {
120:                return entityKey;
121:            }
122:
123:            /**
124:             * @see org.jasig.portal.EntityTypes for known types.
125:             * @return java.lang.Class
126:             */
127:            public Class getEntityType() {
128:                return entityType;
129:            }
130:
131:            /**
132:             * @return java.util.Date
133:             */
134:            public Date getExpirationTime() {
135:                return expirationTime;
136:            }
137:
138:            /**
139:             * Could be the portal user or the framework or ...?
140:             * @return java.lang.String
141:             */
142:            public String getLockOwner() {
143:                return lockOwner;
144:            }
145:
146:            /**
147:             * See IEntityLockingService for a description of lock types.
148:             * @return int
149:             */
150:            public int getLockType() {
151:                return lockType;
152:            }
153:
154:            /**
155:             * @return org.jasig.portal.concurrency.locking.IEntityLockService
156:             */
157:            protected IEntityLockService getService() {
158:                return service;
159:            }
160:
161:            /**
162:             * This method is supported primarily for hash tables, such as those provided in java.util.
163:             * @return an integer hash code for the receiver
164:             * @see java.util.Hashtable
165:             */
166:            public int hashCode() {
167:                return getEntityType().hashCode() + getEntityKey().hashCode()
168:                        + getLockOwner().hashCode();
169:            }
170:
171:            /**
172:             * Answer if the lock is unexpired.
173:             * @return boolean
174:             */
175:            public boolean isLocked() {
176:                return getExpirationTime().after(new Date());
177:            }
178:
179:            /**
180:             * Delegate to the service.
181:             * @return boolean
182:             */
183:            public boolean isValid() throws LockingException {
184:                return getService().isValid(this );
185:            }
186:
187:            /**
188:             * Delegate to the service.
189:             */
190:            public void release() throws LockingException {
191:                getService().release(this );
192:            }
193:
194:            /**
195:             * Delegate to the service.
196:             */
197:            public void renew() throws LockingException {
198:                getService().renew(this );
199:            }
200:
201:            /**
202:             * Delegate to the service.
203:             */
204:            public void renew(int duration) throws LockingException {
205:                getService().renew(this , duration);
206:            }
207:
208:            /**
209:             * @param newEntityKey
210:             */
211:            private void setEntityKey(String newEntityKey) {
212:                entityKey = newEntityKey;
213:            }
214:
215:            /**
216:             * @param newEntityType
217:             */
218:            private void setEntityType(Class newEntityType) {
219:                entityType = newEntityType;
220:            }
221:
222:            /**
223:             * @param newExpirationTime
224:             */
225:            void setExpirationTime(Date newExpirationTime) {
226:                expirationTime = newExpirationTime;
227:            }
228:
229:            /**
230:             * @param newLockOwner
231:             */
232:            private void setLockOwner(String newLockOwner) {
233:                lockOwner = newLockOwner;
234:            }
235:
236:            /**
237:             * @param newLockType
238:             */
239:            void setLockType(int newLockType) {
240:                lockType = newLockType;
241:            }
242:
243:            /**
244:             * @param newService org.jasig.portal.concurrency.locking.IEntityLockService
245:             */
246:            private void setService(IEntityLockService newService) {
247:                service = newService;
248:            }
249:
250:            /**
251:             * Returns a String that represents the value of this object.
252:             * @return a string representation of the receiver
253:             */
254:            public String toString() {
255:                return "EntityLockImpl for " + getEntityType().getName() + "("
256:                        + getEntityKey() + ")" + " type " + getLockType()
257:                        + " owner " + getLockOwner() + " "
258:                        + getExpirationTime();
259:            }
260:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.