Source Code Cross Referenced for ThreadSafeOperationRegistry.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » javax » media » jai » 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 » 6.0 JDK Modules » Java Advanced Imaging » javax.media.jai 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: ThreadSafeOperationRegistry.java,v $
003:         *
004:         * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * Use is subject to license terms.
007:         *
008:         * $Revision: 1.1 $
009:         * $Date: 2005/02/11 04:57:21 $
010:         * $State: Exp $
011:         */
012:        package javax.media.jai;
013:
014:        import com.sun.media.jai.util.RWLock;
015:        import java.io.IOException;
016:        import java.io.InputStream;
017:        import java.io.ObjectInput;
018:        import java.io.ObjectOutput;
019:        import java.io.OutputStream;
020:        import java.util.Iterator;
021:        import java.util.List;
022:        import java.util.Vector;
023:
024:        /**
025:         * A wrapper class on <code>OperationRegistry</code> which is
026:         * thread safe. Every method is wrapped with an appropriate read
027:         * or a write lock. Exceptions are caught and the lock is released
028:         * before the exception is re-thrown.
029:         *
030:         * @since JAI 1.1
031:         */
032:        final class ThreadSafeOperationRegistry extends OperationRegistry {
033:
034:            /** The reader/writer lock for this class. */
035:            private RWLock lock;
036:
037:            public ThreadSafeOperationRegistry() {
038:                super ();
039:
040:                // Create an upgradable reader/writer lock.
041:                lock = new RWLock(true);
042:            }
043:
044:            public String toString() {
045:                try {
046:                    lock.forReading();
047:                    String t = super .toString();
048:                    lock.release();
049:                    return t;
050:                } catch (RuntimeException e) {
051:                    lock.release();
052:                    throw e;
053:                }
054:            }
055:
056:            public void writeToStream(OutputStream out) throws IOException {
057:                try {
058:                    lock.forReading();
059:                    super .writeToStream(out);
060:                    lock.release();
061:                } catch (IOException ioe) {
062:                    lock.release();
063:                    throw ioe;
064:                } catch (RuntimeException e) {
065:                    lock.release();
066:                    throw e;
067:                }
068:            }
069:
070:            public void initializeFromStream(InputStream in) throws IOException {
071:                try {
072:                    lock.forWriting();
073:                    super .initializeFromStream(in);
074:                    lock.release();
075:                } catch (IOException ioe) {
076:                    lock.release();
077:                    throw ioe;
078:                } catch (RuntimeException e) {
079:                    lock.release();
080:                    throw e;
081:                }
082:            }
083:
084:            public void updateFromStream(InputStream in) throws IOException {
085:                try {
086:                    lock.forWriting();
087:                    super .updateFromStream(in);
088:                    lock.release();
089:                } catch (IOException ioe) {
090:                    lock.release();
091:                    throw ioe;
092:                } catch (RuntimeException e) {
093:                    lock.release();
094:                    throw e;
095:                }
096:            }
097:
098:            public void readExternal(ObjectInput in) throws IOException,
099:                    ClassNotFoundException {
100:
101:                try {
102:                    lock.forWriting();
103:                    super .readExternal(in);
104:                    lock.release();
105:                } catch (IOException ioe) {
106:                    lock.release();
107:                    throw ioe;
108:                } catch (RuntimeException e) {
109:                    lock.release();
110:                    throw e;
111:                }
112:            }
113:
114:            public void writeExternal(ObjectOutput out) throws IOException {
115:                try {
116:                    lock.forReading();
117:                    super .writeExternal(out);
118:                    lock.release();
119:                } catch (IOException ioe) {
120:                    lock.release();
121:                    throw ioe;
122:                } catch (RuntimeException e) {
123:                    lock.release();
124:                    throw e;
125:                }
126:            }
127:
128:            /********************** NEW JAI 1.1 methods *************************/
129:
130:            public void removeRegistryMode(String modeName) {
131:                try {
132:                    lock.forWriting();
133:                    super .removeRegistryMode(modeName);
134:                    lock.release();
135:                } catch (RuntimeException e) {
136:                    lock.release();
137:                    throw e;
138:                }
139:            }
140:
141:            public String[] getRegistryModes() {
142:                try {
143:                    lock.forReading();
144:                    String[] t = super .getRegistryModes();
145:                    lock.release();
146:                    return t;
147:                } catch (RuntimeException e) {
148:                    lock.release();
149:                    throw e;
150:                }
151:            }
152:
153:            public void registerDescriptor(RegistryElementDescriptor descriptor) {
154:                try {
155:                    lock.forWriting();
156:                    super .registerDescriptor(descriptor);
157:                    lock.release();
158:                } catch (RuntimeException e) {
159:                    lock.release();
160:                    throw e;
161:                }
162:            }
163:
164:            public void unregisterDescriptor(
165:                    RegistryElementDescriptor descriptor) {
166:                try {
167:                    lock.forWriting();
168:                    super .unregisterDescriptor(descriptor);
169:                    lock.release();
170:                } catch (RuntimeException e) {
171:                    lock.release();
172:                    throw e;
173:                }
174:            }
175:
176:            public RegistryElementDescriptor getDescriptor(
177:                    Class descriptorClass, String descriptorName) {
178:                try {
179:                    lock.forReading();
180:                    RegistryElementDescriptor t = super .getDescriptor(
181:                            descriptorClass, descriptorName);
182:                    lock.release();
183:                    return t;
184:                } catch (RuntimeException e) {
185:                    lock.release();
186:                    throw e;
187:                }
188:            }
189:
190:            public List getDescriptors(Class descriptorClass) {
191:                try {
192:                    lock.forReading();
193:                    List t = super .getDescriptors(descriptorClass);
194:                    lock.release();
195:                    return t;
196:                } catch (RuntimeException e) {
197:                    lock.release();
198:                    throw e;
199:                }
200:            }
201:
202:            public String[] getDescriptorNames(Class descriptorClass) {
203:                try {
204:                    lock.forReading();
205:                    String[] t = super .getDescriptorNames(descriptorClass);
206:                    lock.release();
207:                    return t;
208:                } catch (RuntimeException e) {
209:                    lock.release();
210:                    throw e;
211:                }
212:            }
213:
214:            public RegistryElementDescriptor getDescriptor(String modeName,
215:                    String descriptorName) {
216:                try {
217:                    lock.forReading();
218:                    RegistryElementDescriptor t = super .getDescriptor(modeName,
219:                            descriptorName);
220:                    lock.release();
221:                    return t;
222:                } catch (RuntimeException e) {
223:                    lock.release();
224:                    throw e;
225:                }
226:            }
227:
228:            public List getDescriptors(String modeName) {
229:
230:                try {
231:                    lock.forReading();
232:                    List t = super .getDescriptors(modeName);
233:                    lock.release();
234:                    return t;
235:                } catch (RuntimeException e) {
236:                    lock.release();
237:                    throw e;
238:                }
239:            }
240:
241:            public String[] getDescriptorNames(String modeName) {
242:                try {
243:                    lock.forReading();
244:                    String[] t = super .getDescriptorNames(modeName);
245:                    lock.release();
246:                    return t;
247:                } catch (RuntimeException e) {
248:                    lock.release();
249:                    throw e;
250:                }
251:            }
252:
253:            public void setProductPreference(String modeName,
254:                    String descriptorName, String preferredProductName,
255:                    String otherProductName) {
256:                try {
257:                    lock.forWriting();
258:                    super .setProductPreference(modeName, descriptorName,
259:                            preferredProductName, otherProductName);
260:                    lock.release();
261:                } catch (RuntimeException e) {
262:                    lock.release();
263:                    throw e;
264:                }
265:            }
266:
267:            public void unsetProductPreference(String modeName,
268:                    String descriptorName, String preferredProductName,
269:                    String otherProductName) {
270:                try {
271:                    lock.forWriting();
272:                    super .unsetProductPreference(modeName, descriptorName,
273:                            preferredProductName, otherProductName);
274:                    lock.release();
275:                } catch (RuntimeException e) {
276:                    lock.release();
277:                    throw e;
278:                }
279:            }
280:
281:            public void clearProductPreferences(String modeName,
282:                    String descriptorName) {
283:                try {
284:                    lock.forWriting();
285:                    super .clearProductPreferences(modeName, descriptorName);
286:                    lock.release();
287:                } catch (RuntimeException e) {
288:                    lock.release();
289:                    throw e;
290:                }
291:            }
292:
293:            public String[][] getProductPreferences(String modeName,
294:                    String descriptorName) {
295:                try {
296:                    lock.forReading();
297:                    String[][] t = super .getProductPreferences(modeName,
298:                            descriptorName);
299:                    lock.release();
300:                    return t;
301:                } catch (RuntimeException e) {
302:                    lock.release();
303:                    throw e;
304:                }
305:            }
306:
307:            public Vector getOrderedProductList(String modeName,
308:                    String descriptorName) {
309:                try {
310:                    lock.forReading();
311:                    Vector t = super .getOrderedProductList(modeName,
312:                            descriptorName);
313:                    lock.release();
314:                    return t;
315:                } catch (RuntimeException e) {
316:                    lock.release();
317:                    throw e;
318:                }
319:            }
320:
321:            public void registerFactory(String modeName, String descriptorName,
322:                    String productName, Object factory) {
323:                try {
324:                    lock.forWriting();
325:                    super .registerFactory(modeName, descriptorName,
326:                            productName, factory);
327:                    lock.release();
328:                } catch (RuntimeException e) {
329:                    lock.release();
330:                    throw e;
331:                }
332:            }
333:
334:            public void unregisterFactory(String modeName,
335:                    String descriptorName, String productName, Object factory) {
336:                try {
337:                    lock.forWriting();
338:                    super .unregisterFactory(modeName, descriptorName,
339:                            productName, factory);
340:                    lock.release();
341:                } catch (RuntimeException e) {
342:                    lock.release();
343:                    throw e;
344:                }
345:            }
346:
347:            public void setFactoryPreference(String modeName,
348:                    String descriptorName, String productName,
349:                    Object preferredOp, Object otherOp) {
350:                try {
351:                    lock.forWriting();
352:                    super .setFactoryPreference(modeName, descriptorName,
353:                            productName, preferredOp, otherOp);
354:                    lock.release();
355:                } catch (RuntimeException e) {
356:                    lock.release();
357:                    throw e;
358:                }
359:            }
360:
361:            public void unsetFactoryPreference(String modeName,
362:                    String descriptorName, String productName,
363:                    Object preferredOp, Object otherOp) {
364:                try {
365:                    lock.forWriting();
366:                    super .unsetFactoryPreference(modeName, descriptorName,
367:                            productName, preferredOp, otherOp);
368:                    lock.release();
369:                } catch (RuntimeException e) {
370:                    lock.release();
371:                    throw e;
372:                }
373:            }
374:
375:            public void clearFactoryPreferences(String modeName,
376:                    String descriptorName, String productName) {
377:                try {
378:                    lock.forWriting();
379:                    super .clearFactoryPreferences(modeName, descriptorName,
380:                            productName);
381:                    lock.release();
382:                } catch (RuntimeException e) {
383:                    lock.release();
384:                    throw e;
385:                }
386:            }
387:
388:            public Object[][] getFactoryPreferences(String modeName,
389:                    String descriptorName, String productName) {
390:                try {
391:                    lock.forReading();
392:                    Object[][] t = super .getFactoryPreferences(modeName,
393:                            descriptorName, productName);
394:                    lock.release();
395:                    return t;
396:                } catch (RuntimeException e) {
397:                    lock.release();
398:                    throw e;
399:                }
400:            }
401:
402:            public List getOrderedFactoryList(String modeName,
403:                    String descriptorName, String productName) {
404:                try {
405:                    lock.forReading();
406:                    List t = super .getOrderedFactoryList(modeName,
407:                            descriptorName, productName);
408:                    lock.release();
409:                    return t;
410:                } catch (RuntimeException e) {
411:                    lock.release();
412:                    throw e;
413:                }
414:            }
415:
416:            public Iterator getFactoryIterator(String modeName,
417:                    String descriptorName) {
418:                try {
419:                    lock.forReading();
420:                    Iterator t = super .getFactoryIterator(modeName,
421:                            descriptorName);
422:                    lock.release();
423:                    return t;
424:                } catch (RuntimeException e) {
425:                    lock.release();
426:                    throw e;
427:                }
428:            }
429:
430:            public Object getFactory(String modeName, String descriptorName) {
431:                try {
432:                    lock.forReading();
433:                    Object t = super .getFactory(modeName, descriptorName);
434:                    lock.release();
435:                    return t;
436:                } catch (RuntimeException e) {
437:                    lock.release();
438:                    throw e;
439:                }
440:            }
441:
442:            public Object invokeFactory(String modeName, String descriptorName,
443:                    Object[] args) {
444:                try {
445:                    lock.forReading();
446:                    Object t = super .invokeFactory(modeName, descriptorName,
447:                            args);
448:                    lock.release();
449:                    return t;
450:                } catch (RuntimeException e) {
451:                    lock.release();
452:                    throw e;
453:                }
454:            }
455:
456:            public void addPropertyGenerator(String modeName,
457:                    String descriptorName, PropertyGenerator generator) {
458:                try {
459:                    lock.forWriting();
460:                    super .addPropertyGenerator(modeName, descriptorName,
461:                            generator);
462:                    lock.release();
463:                } catch (RuntimeException e) {
464:                    lock.release();
465:                    throw e;
466:                }
467:            }
468:
469:            public void removePropertyGenerator(String modeName,
470:                    String descriptorName, PropertyGenerator generator) {
471:                try {
472:                    lock.forWriting();
473:                    super .removePropertyGenerator(modeName, descriptorName,
474:                            generator);
475:                    lock.release();
476:                } catch (RuntimeException e) {
477:                    lock.release();
478:                    throw e;
479:                }
480:            }
481:
482:            public void copyPropertyFromSource(String modeName,
483:                    String descriptorName, String propertyName, int sourceIndex) {
484:                try {
485:                    lock.forWriting();
486:                    super .copyPropertyFromSource(modeName, descriptorName,
487:                            propertyName, sourceIndex);
488:                    lock.release();
489:                } catch (RuntimeException e) {
490:                    lock.release();
491:                    throw e;
492:                }
493:            }
494:
495:            public void suppressProperty(String modeName,
496:                    String descriptorName, String propertyName) {
497:                try {
498:                    lock.forWriting();
499:                    super .suppressProperty(modeName, descriptorName,
500:                            propertyName);
501:                    lock.release();
502:                } catch (RuntimeException e) {
503:                    lock.release();
504:                    throw e;
505:                }
506:            }
507:
508:            public void suppressAllProperties(String modeName,
509:                    String descriptorName) {
510:                try {
511:                    lock.forWriting();
512:                    super .suppressAllProperties(modeName, descriptorName);
513:                    lock.release();
514:                } catch (RuntimeException e) {
515:                    lock.release();
516:                    throw e;
517:                }
518:            }
519:
520:            public void clearPropertyState(String modeName) {
521:                try {
522:                    lock.forWriting();
523:                    super .clearPropertyState(modeName);
524:                    lock.release();
525:                } catch (RuntimeException e) {
526:                    lock.release();
527:                    throw e;
528:                }
529:            }
530:
531:            public String[] getGeneratedPropertyNames(String modeName,
532:                    String descriptorName) {
533:                try {
534:                    lock.forReading();
535:                    String[] t = super .getGeneratedPropertyNames(modeName,
536:                            descriptorName);
537:                    lock.release();
538:                    return t;
539:                } catch (RuntimeException e) {
540:                    lock.release();
541:                    throw e;
542:                }
543:            }
544:
545:            public PropertySource getPropertySource(String modeName,
546:                    String descriptorName, Object op, Vector sources) {
547:                try {
548:                    lock.forReading();
549:                    PropertySource t = super .getPropertySource(modeName,
550:                            descriptorName, op, sources);
551:                    lock.release();
552:                    return t;
553:                } catch (RuntimeException e) {
554:                    lock.release();
555:                    throw e;
556:                }
557:            }
558:
559:            public PropertySource getPropertySource(OperationNode op) {
560:                try {
561:                    lock.forReading();
562:                    PropertySource t = super .getPropertySource(op);
563:                    lock.release();
564:                    return t;
565:                } catch (RuntimeException e) {
566:                    lock.release();
567:                    throw e;
568:                }
569:            }
570:
571:            public void registerServices(ClassLoader cl) throws IOException {
572:                try {
573:                    lock.forWriting();
574:                    super .registerServices(cl);
575:                    lock.release();
576:                } catch (RuntimeException e) {
577:                    lock.release();
578:                    throw e;
579:                }
580:            }
581:
582:            /********************** DEPRECATED METHODS *************************/
583:
584:            public void unregisterOperationDescriptor(String operationName) {
585:                try {
586:                    lock.forWriting();
587:                    super .unregisterOperationDescriptor(operationName);
588:                    lock.release();
589:                } catch (RuntimeException e) {
590:                    lock.release();
591:                    throw e;
592:                }
593:            }
594:
595:            public void clearOperationPreferences(String operationName,
596:                    String productName) {
597:                try {
598:                    lock.forWriting();
599:                    super .clearOperationPreferences(operationName, productName);
600:                    lock.release();
601:                } catch (RuntimeException e) {
602:                    lock.release();
603:                    throw e;
604:                }
605:            }
606:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.