Source Code Cross Referenced for DefaultResource.java in  » Workflow-Engines » wfmopen-2.1.1 » de » danet » an » workflow » spis » rms » 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 » Workflow Engines » wfmopen 2.1.1 » de.danet.an.workflow.spis.rms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file is part of the WfMOpen project.
003:         * Copyright (C) 2001-2003 Danet GmbH (www.danet.de), GS-AN.
004:         * All rights reserved.
005:         *
006:         * This program is free software; you can redistribute it and/or modify
007:         * it under the terms of the GNU General Public License as published by
008:         * the Free Software Foundation; either version 2 of the License, or
009:         * (at your option) any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         *
020:         * $Id: DefaultResource.java,v 1.5 2007/03/27 21:59:43 mlipp Exp $
021:         *
022:         * $Log: DefaultResource.java,v $
023:         * Revision 1.5  2007/03/27 21:59:43  mlipp
024:         * Fixed lots of checkstyle warnings.
025:         *
026:         * Revision 1.4  2007/02/27 14:34:08  drmlipp
027:         * Some refactoring to reduce cyclic dependencies.
028:         *
029:         * Revision 1.3  2006/10/15 19:29:51  mlipp
030:         * Merged changes from 1.4.x up to 1.4ea3pre1.
031:         *
032:         * Revision 1.2.2.1  2006/10/14 21:34:06  mlipp
033:         * Simplified resource assignment service implementation.
034:         *
035:         * Revision 1.2  2006/10/03 17:04:02  mlipp
036:         * Fixed visibility.
037:         *
038:         * Revision 1.1  2006/10/02 20:53:56  mlipp
039:         * New resource base classes.
040:         *
041:         * Revision 1.2  2006/09/29 12:32:12  drmlipp
042:         * Consistently using WfMOpen as projct name now.
043:         *
044:         * Revision 1.1.1.2  2004/08/18 15:17:38  drmlipp
045:         * Update to 1.2
046:         *
047:         * Revision 1.11  2002/12/19 21:37:42  lipp
048:         * Reorganized interfaces.
049:         *
050:         * Revision 1.10  2002/11/26 11:23:29  lipp
051:         * Modified RemoteException comment.
052:         *
053:         * Revision 1.9  2002/04/03 12:53:05  lipp
054:         * JavaDoc fixes.
055:         *
056:         * Revision 1.8  2002/01/15 13:42:21  lipp
057:         * Added resourceByKey to ResourceAssignmentService and some missing
058:         * NoSuchResourceExceptions in various methods.
059:         *
060:         * Revision 1.7  2001/12/20 22:27:34  lipp
061:         * WfResource release semantics fixed.
062:         *
063:         * Revision 1.6  2001/12/19 09:05:15  lipp
064:         * Made it serializable.
065:         *
066:         * Revision 1.5  2001/12/17 12:14:04  lipp
067:         * Adapted to configurable ResourceManagement/AssignmentServices.
068:         *
069:         * Revision 1.4  2001/12/16 21:48:57  lipp
070:         * addAssignment implemented.
071:         *
072:         * Revision 1.3  2001/12/11 12:55:36  robert
073:         * fixed parameter error
074:         *
075:         * Revision 1.2  2001/12/11 12:47:37  lipp
076:         * JavaDoc fixes.
077:         *
078:         * Revision 1.1  2001/12/09 14:03:08  lipp
079:         * Improved design of workflow/resource management interface.
080:         *
081:         */
082:        package de.danet.an.workflow.spis.rms;
083:
084:        import java.io.Serializable;
085:
086:        import java.util.Collection;
087:
088:        import java.rmi.RemoteException;
089:
090:        import de.danet.an.workflow.omgcore.InvalidResourceException;
091:        import de.danet.an.workflow.omgcore.NotAssignedException;
092:        import de.danet.an.workflow.omgcore.WfAssignment;
093:        import de.danet.an.workflow.omgcore.WfResource;
094:
095:        import de.danet.an.workflow.api.Activity;
096:        import de.danet.an.workflow.api.NoSuchResourceException;
097:
098:        import de.danet.an.workflow.spis.ras.ResourceAssignmentService;
099:
100:        /**
101:         * This class provides a default implementation of the {@link
102:         * de.danet.an.workflow.omgcore.WfResource <code>WfResource</code>}'s methods
103:         * {@link de.danet.an.workflow.omgcore.WfResource#workItems
104:         * <code>workItems</code>},
105:         * {@link de.danet.an.workflow.omgcore.WfResource#isMemberOfWorkItems
106:         * <code>isMemberOfWorkItems</code>} and
107:         * {@link de.danet.an.workflow.omgcore.WfResource#release <code>release</code>}.
108:         * The implementation is based on the methods of a
109:         * {@link ResourceAssignmentContext <code>ResourceAssignmentContext</code>}
110:         * passed to the constructor.
111:         */
112:        public class DefaultResource implements  WfResource, Serializable {
113:
114:            /**
115:             * The resource service factory used.
116:             */
117:            private ResourceAssignmentContext callbackHandler = null;
118:
119:            private String resourceKey = null;
120:
121:            private String resourceName = null;
122:
123:            /**
124:             * The constructor. It ensures that a valid factory exists.
125:             * 
126:             * @param assignSvc
127:             *            the callback handler
128:             * @param key
129:             *            the resource's key
130:             * @param name
131:             *            the resource's name
132:             */
133:            public DefaultResource(ResourceAssignmentContext cbh, String key,
134:                    String name) {
135:                callbackHandler = cbh;
136:                resourceKey = key;
137:                resourceName = name;
138:            }
139:
140:            /**
141:             * Retrieve the key of a resource.
142:             * 
143:             * @return key of resource
144:             * @throws RemoteException
145:             *             problems accessing resource
146:             */
147:            public String resourceKey() throws RemoteException {
148:                return resourceKey;
149:            }
150:
151:            /**
152:             * Retrieve the name of a resource.
153:             * 
154:             * @return name of resource
155:             * @throws RemoteException
156:             *             problems accessing resource
157:             */
158:            public String resourceName() throws RemoteException {
159:                return resourceName;
160:            }
161:
162:            /**
163:             * This method returns the {@link WfAssignment <code>WfAssignments</code>}s
164:             * associated with a resource.
165:             * 
166:             * @return the associated {@link WfAssignment <code>WfAssignments</code>}s.
167:             * @throws RemoteException
168:             *             if a system-level error occurs.
169:             * @throws IllegalStateException
170:             *             if the resource has become invalid. This is actually a
171:             *             remapping of the <code>NoSuchResourceException</code>
172:             *             thrown by {@link ResourceAssignmentService#workItems
173:             *             <code>ResourceAssignmentService.workItems()</code>}. It
174:             *             must be remapped because this method's signature is specified
175:             *             by
176:             *             {@link WfResource#workItems <code>WfResource.workItems()</code>}.
177:             */
178:            public Collection workItems() throws RemoteException,
179:                    IllegalStateException {
180:                try {
181:                    return callbackHandler.workItems(this );
182:                } catch (NoSuchResourceException e) {
183:                    throw new IllegalStateException(e.getMessage());
184:                }
185:            }
186:
187:            /**
188:             * Checks if a given {@link WfAssignment <code>WfAssignment</code>} is
189:             * associated with this resource.
190:             * 
191:             * @param assignment
192:             *            the assignment in question.
193:             * @return <code>true</code> if the association exists.
194:             * @throws RemoteException
195:             *             if a system-level error occurs. This is actually a remapping
196:             *             of the <code>NoSuchResourceException</code> thrown by
197:             *             {@link ResourceAssignmentService#isMemberOfWorkItems
198:             *             <code>ResourceAssignmentService.isMemberOfWorkItems(...)</code>}.
199:             *             It must be remapped because this method's signature is
200:             *             specified by {@link WfResource#isMemberOfWorkItems 
201:             *             <code>WfResource.isMemberOfWorkItems(...)</code>}.
202:             * @throws IllegalStateException
203:             *             if the resource has become invalid.
204:             */
205:            public boolean isMemberOfWorkItems(WfAssignment assignment)
206:                    throws RemoteException, IllegalStateException {
207:                try {
208:                    return callbackHandler
209:                            .isMemberOfWorkItems(this , assignment);
210:                } catch (NoSuchResourceException e) {
211:                    throw new IllegalStateException(e.getMessage());
212:                }
213:            }
214:
215:            /**
216:             * Signals to the resource that it is no longer needed for a specific
217:             * assignment. The default implementation calls
218:             * <code>removeAssignment</code> on the activity.
219:             * 
220:             * @param fromAssignment
221:             *            the specific assignment.
222:             * @param releaseInfo
223:             *            specifies additional information on the reason for realizing
224:             *            the resource as input.
225:             * @throws NotAssignedException
226:             *             if the resource is not associated with the given assignment.
227:             * @throws RemoteException
228:             *             if a system-level error occurs.
229:             */
230:            public void release(WfAssignment fromAssignment, String releaseInfo)
231:                    throws RemoteException, NotAssignedException {
232:                try {
233:                    ((Activity) fromAssignment.activity())
234:                            .removeAssignment(fromAssignment.assignee());
235:                } catch (InvalidResourceException e) {
236:                    throw (NotAssignedException) (new NotAssignedException())
237:                            .initCause(e);
238:                }
239:            }
240:
241:            /*
242:             * (non-Javadoc)
243:             * 
244:             * @see java.lang.Object#hashCode()
245:             */
246:            public int hashCode() {
247:                final int PRIME = 31;
248:                int result = 1;
249:                result = PRIME * result
250:                        + ((resourceKey == null) ? 0 : resourceKey.hashCode());
251:                return result;
252:            }
253:
254:            /*
255:             * (non-Javadoc)
256:             * 
257:             * @see java.lang.Object#equals(java.lang.Object)
258:             */
259:            public boolean equals(Object obj) {
260:                if (this  == obj) {
261:                    return true;
262:                }
263:                if (obj == null) {
264:                    return false;
265:                }
266:                if (getClass() != obj.getClass()) {
267:                    return false;
268:                }
269:                final DefaultResource other = (DefaultResource) obj;
270:                if (resourceKey == null) {
271:                    if (other.resourceKey != null) {
272:                        return false;
273:                    }
274:                } else if (!resourceKey.equals(other.resourceKey)) {
275:                    return false;
276:                }
277:                return true;
278:            }
279:
280:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.