Source Code Cross Referenced for Source.java in  » Web-Services-apache-cxf-2.0.1 » ws-rm » org » apache » cxf » ws » rm » 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 » Web Services apache cxf 2.0.1 » ws rm » org.apache.cxf.ws.rm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements. See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership. The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License. You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied. See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         */package org.apache.cxf.ws.rm;
019:
020:        import java.util.ArrayList;
021:        import java.util.Collection;
022:        import java.util.HashMap;
023:        import java.util.Map;
024:        import java.util.concurrent.locks.Condition;
025:        import java.util.concurrent.locks.Lock;
026:        import java.util.concurrent.locks.ReentrantLock;
027:
028:        import org.apache.cxf.helpers.CastUtils;
029:        import org.apache.cxf.ws.rm.persistence.RMStore;
030:
031:        public class Source extends AbstractEndpoint {
032:
033:            private static final String REQUESTOR_SEQUENCE_ID = "";
034:
035:            private Map<String, SourceSequence> map;
036:            private Map<String, SourceSequence> current;
037:            private Lock sequenceCreationLock;
038:            private Condition sequenceCreationCondition;
039:            private boolean sequenceCreationNotified;
040:
041:            Source(RMEndpoint reliableEndpoint) {
042:                super (reliableEndpoint);
043:                map = new HashMap<String, SourceSequence>();
044:                current = new HashMap<String, SourceSequence>();
045:
046:                sequenceCreationLock = new ReentrantLock();
047:                sequenceCreationCondition = sequenceCreationLock.newCondition();
048:            }
049:
050:            public SourceSequence getSequence(Identifier id) {
051:                return map.get(id.getValue());
052:            }
053:
054:            public Collection<SourceSequence> getAllSequences() {
055:                return CastUtils.cast(map.values());
056:            }
057:
058:            public void addSequence(SourceSequence seq) {
059:                addSequence(seq, true);
060:            }
061:
062:            public void addSequence(SourceSequence seq, boolean persist) {
063:                seq.setSource(this );
064:                map.put(seq.getIdentifier().getValue(), seq);
065:                if (persist) {
066:                    RMStore store = getReliableEndpoint().getManager()
067:                            .getStore();
068:                    if (null != store) {
069:                        store.createSourceSequence(seq);
070:                    }
071:                }
072:            }
073:
074:            public void removeSequence(SourceSequence seq) {
075:                map.remove(seq.getIdentifier().getValue());
076:                RMStore store = getReliableEndpoint().getManager().getStore();
077:                if (null != store) {
078:                    store.removeSourceSequence(seq.getIdentifier());
079:                }
080:            }
081:
082:            /**
083:             * Returns a collection of all sequences for which have not yet been
084:             * completely acknowledged.
085:             * 
086:             * @return the collection of unacknowledged sequences.
087:             */
088:            public Collection<SourceSequence> getAllUnacknowledgedSequences() {
089:                Collection<SourceSequence> seqs = new ArrayList<SourceSequence>();
090:                for (SourceSequence seq : map.values()) {
091:                    if (!seq.allAcknowledged()) {
092:                        seqs.add(seq);
093:                    }
094:                }
095:                return seqs;
096:            }
097:
098:            /**
099:             * Returns the current sequence used by a client side source.
100:             * 
101:             * @return the current sequence.
102:             */
103:            SourceSequence getCurrent() {
104:                return getCurrent(null);
105:            }
106:
107:            /**
108:             * Sets the current sequence used by a client side source.
109:             * @param s the current sequence.
110:             */
111:            public void setCurrent(SourceSequence s) {
112:                setCurrent(null, s);
113:            }
114:
115:            /**
116:             * Returns the current sequence used by a server side source for responses to a message
117:             * sent as part of the inbound sequence with the specified identifier.
118:             * 
119:             * @return the current sequence.
120:             */
121:            SourceSequence getCurrent(Identifier i) {
122:                sequenceCreationLock.lock();
123:                try {
124:                    return getAssociatedSequence(i);
125:                } finally {
126:                    sequenceCreationLock.unlock();
127:                }
128:            }
129:
130:            /**
131:             * Returns the sequence associated with the given identifier.
132:             * 
133:             * @param i the corresponding sequence identifier
134:             * @return the associated sequence
135:             * @pre the sequenceCreationLock is already held
136:             */
137:            SourceSequence getAssociatedSequence(Identifier i) {
138:                return current.get(i == null ? REQUESTOR_SEQUENCE_ID : i
139:                        .getValue());
140:            }
141:
142:            /**
143:             * Await the availability of a sequence corresponding to the given identifier.
144:             * 
145:             * @param i the sequence identifier
146:             * @return
147:             */
148:            SourceSequence awaitCurrent(Identifier i) {
149:                sequenceCreationLock.lock();
150:                try {
151:                    SourceSequence seq = getAssociatedSequence(i);
152:                    while (seq == null) {
153:                        while (!sequenceCreationNotified) {
154:                            try {
155:                                sequenceCreationCondition.await();
156:                            } catch (InterruptedException ie) {
157:                                // ignore
158:                            }
159:                        }
160:                        seq = getAssociatedSequence(i);
161:                    }
162:                    return seq;
163:                } finally {
164:                    sequenceCreationLock.unlock();
165:                }
166:            }
167:
168:            /**
169:             * Sets the current sequence used by a server side source for responses to a message
170:             * sent as part of the inbound sequence with the specified identifier.
171:             * @param s the current sequence.
172:             */
173:            void setCurrent(Identifier i, SourceSequence s) {
174:                sequenceCreationLock.lock();
175:                try {
176:                    current.put(i == null ? REQUESTOR_SEQUENCE_ID : i
177:                            .getValue(), s);
178:                    sequenceCreationNotified = true;
179:                    sequenceCreationCondition.signal();
180:                } finally {
181:                    sequenceCreationLock.unlock();
182:                }
183:            }
184:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.