Source Code Cross Referenced for RMVersion.java in  » 6.0-JDK-Modules-com.sun » wsit » com » sun » xml » 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 » 6.0 JDK Modules com.sun » wsit » com.sun.xml.ws.rm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.sun.xml.ws.rm;
002:
003:        import com.sun.xml.bind.api.JAXBRIContext;
004:
005:        import javax.xml.bind.JAXBException;
006:        import javax.xml.bind.Marshaller;
007:        import javax.xml.bind.Unmarshaller;
008:        import javax.xml.namespace.QName;
009:        import java.util.ArrayList;
010:        import java.util.Arrays;
011:        import java.util.List;
012:
013:        /**
014:         * This is the class which will determine which RM version we are dealing with
015:         * WSRM 1.0 or WSRM 1.1
016:         */
017:        public enum RMVersion {
018:
019:            WSRM10("http://schemas.xmlsoap.org/ws/2005/02/rm",
020:                    "http://schemas.xmlsoap.org/ws/2005/02/rm/policy",
021:                    "com.sun.xml.ws.rm.v200502"
022:
023:            ) {
024:
025:                @Override
026:                public String getNamespaceURI() {
027:                    return namespaceUri;
028:                }
029:
030:                @Override
031:                public String getPolicyNamespaceURI() {
032:                    return policyNamespaceUri;
033:                }
034:
035:                @Override
036:                public String getPackageName() {
037:                    return packageName;
038:                }
039:
040:                @Override
041:                public List<Class> getClassesToBeBound() throws RMException {
042:                    final Class[] classes;
043:                    final ArrayList<Class> classList;
044:                    try {
045:                        classes = new Class[] {
046:                                Class.forName(getPackageName()
047:                                        + ".AckRequestedElement"),
048:                                Class.forName(getPackageName()
049:                                        + ".SequenceElement"),
050:                                Class.forName(getPackageName()
051:                                        + ".SequenceAcknowledgementElement"),
052:                                Class.forName(getPackageName() + ".Identifier"),
053:                                Class.forName(getPackageName()
054:                                        + ".CreateSequenceElement"),
055:                                Class.forName(getPackageName()
056:                                        + ".CreateSequenceResponseElement"),
057:                                Class.forName(getPackageName()
058:                                        + ".SequenceFaultElement"),
059:                                Class.forName(getPackageName()
060:                                        + ".TerminateSequenceElement"),
061:                                Class.forName(getPackageName() + ".AcceptType"),
062:                                Class.forName(getPackageName() + ".OfferType"),
063:                                Class.forName(getPackageName() + ".Expires"),
064:
065:                        };
066:                        classList = new ArrayList<Class>(Arrays.asList(classes));
067:                        classList.add(RMConstants.W3C.getAcksToClass());
068:
069:                        return classList;
070:                    } catch (ClassNotFoundException e) {
071:                        throw new RMException(
072:                                "Cannot bind the following class with JAXBContext"
073:                                        + e);
074:                    }
075:                }
076:
077:            },
078:            WSRM11("http://docs.oasis-open.org/ws-rx/wsrm/200702",
079:                    "http://docs.oasis-open.org/ws-rx/wsrmp/200702",
080:                    "com.sun.xml.ws.rm.v200702") {
081:
082:                @Override
083:                public String getNamespaceURI() {
084:                    return namespaceUri;
085:                }
086:
087:                @Override
088:                public String getPolicyNamespaceURI() {
089:                    return policyNamespaceUri;
090:                }
091:
092:                @Override
093:                public String getPackageName() {
094:                    return packageName;
095:                }
096:
097:                public List<Class> getClassesToBeBound() throws RMException {
098:                    final Class[] classes;
099:                    final ArrayList<Class> classList;
100:                    try {
101:                        classes = new Class[] {
102:                                Class.forName(getPackageName()
103:                                        + ".AckRequestedElement"),
104:                                Class.forName(getPackageName()
105:                                        + ".SequenceElement"),
106:                                Class.forName(getPackageName()
107:                                        + ".SequenceAcknowledgementElement"),
108:                                Class.forName(getPackageName() + ".Identifier"),
109:                                Class.forName(getPackageName()
110:                                        + ".CreateSequenceElement"),
111:                                Class.forName(getPackageName()
112:                                        + ".CreateSequenceResponseElement"),
113:                                Class.forName(getPackageName()
114:                                        + ".SequenceFaultElement"),
115:                                Class.forName(getPackageName()
116:                                        + ".TerminateSequenceElement"),
117:                                Class.forName(getPackageName()
118:                                        + ".TerminateSequenceResponseElement"),
119:                                Class.forName(getPackageName() + ".AcceptType"),
120:                                Class.forName(getPackageName() + ".OfferType"),
121:                                Class.forName(getPackageName() + ".Expires"),
122:                                Class.forName(getPackageName()
123:                                        + ".CloseSequenceResponseElement"),
124:                                Class.forName(getPackageName()
125:                                        + ".CloseSequenceElement")
126:
127:                        };
128:                        classList = new ArrayList<Class>(Arrays.asList(classes));
129:                        classList.add(RMConstants.W3C.getAcksToClass());
130:
131:                        return classList;
132:                    } catch (ClassNotFoundException e) {
133:                        throw new RMException(
134:                                "Cannot bind the following class with JAXBContext"
135:                                        + e);
136:                    }
137:                }
138:
139:            };
140:
141:            public final String namespaceUri;
142:
143:            public final String policyNamespaceUri;
144:
145:            public final String packageName;
146:
147:            private JAXBRIContext jc;
148:
149:            public JAXBRIContext jaxbricontext;
150:
151:            private RMVersion(String nsUri, String policynsuri,
152:                    String packagename) {
153:                this .namespaceUri = nsUri;
154:                this .policyNamespaceUri = policynsuri;
155:                this .packageName = packagename;
156:                init();
157:
158:            }
159:
160:            public abstract String getNamespaceURI();
161:
162:            public abstract String getPolicyNamespaceURI();
163:
164:            public abstract String getPackageName();
165:
166:            public String getCreateSequenceAction() {
167:                return namespaceUri + "/CreateSequence";
168:            }
169:
170:            public String getTerminateSequenceAction() {
171:                return namespaceUri + "/TerminateSequence";
172:            }
173:
174:            public String getAckRequestedAction() {
175:                return namespaceUri + "/AckRequested";
176:            }
177:
178:            public String getCreateSequenceResponseAction() {
179:                return namespaceUri + "/CreateSequenceResponse";
180:            }
181:
182:            public String getSequenceAcknowledgementAction() {
183:                return namespaceUri + "/SequenceAcknowledgement";
184:            }
185:
186:            public String getMakeConnectionAction() {
187:                return namespaceUri + "/MakeConnection";
188:            }
189:
190:            public QName getRMPolicyAssertionQName() {
191:                return new QName(getPolicyNamespaceURI(), "RMAssertion");
192:            }
193:
194:            public QName getInactivityTimeoutAssertionQName() {
195:                return new QName(getPolicyNamespaceURI(), "InactivityTimeout");
196:            }
197:
198:            public QName getSequenceSTRAssertionQName() {
199:                return new QName(getPolicyNamespaceURI(), "SequenceSTR");
200:            }
201:
202:            public QName getSequenceTransportSecurityAssertionQName() {
203:                return new QName(getPolicyNamespaceURI(),
204:                        "SequenceTransportSecurity");
205:            }
206:
207:            /**
208:             * Returns {@link RMVersion} whose {@link #nsUri} equals to
209:             * the given string.
210:             *
211:             *
212:             *
213:             * @param nsUri
214:             *      must not be null.
215:             * @return always non-null.
216:             */
217:            public static RMVersion fromNsUri(String nsUri) {
218:                if (nsUri.equals(WSRM10.namespaceUri)) {
219:                    return WSRM10;
220:
221:                } else {
222:                    //return WSRM 1.1 by default
223:                    return WSRM11;
224:                }
225:
226:            }
227:
228:            private List<Class> getHeaderClassesToBeBound() throws RMException {
229:                final Class[] classes;
230:                final ArrayList<Class> classList;
231:                try {
232:                    classes = new Class[] {
233:                            Class.forName(getPackageName()
234:                                    + ".AckRequestedElement"),
235:                            Class
236:                                    .forName(getPackageName()
237:                                            + ".SequenceElement"),
238:                            Class.forName(getPackageName()
239:                                    + ".SequenceAcknowledgementElement"),
240:                            Class.forName(getPackageName() + ".Identifier"),
241:
242:                    };
243:                    classList = new ArrayList<Class>(Arrays.asList(classes));
244:                    classList.add(RMConstants.W3C.getAcksToClass());
245:                    return classList;
246:                } catch (ClassNotFoundException e) {
247:                    throw new RMException(
248:                            "Cannot bind the following class with JAXBContext"
249:                                    + e);
250:                }
251:            }
252:
253:            private void init() {
254:                try {
255:
256:                    List<Class> classes = getClassesToBeBound();
257:                    jc = JAXBRIContext.newInstance(classes
258:                            .toArray(new Class[0]), null, null, null, false,
259:                            null);
260:
261:                    Class[] clazzes = getHeaderClassesToBeBound().toArray(
262:                            new Class[0]);
263:                    jaxbricontext = JAXBRIContext.newInstance(clazzes, null,
264:                            null, null, false, null);
265:
266:                } catch (JAXBException e) {
267:                    throw new Error(e);
268:                } catch (RMException e) {
269:                    throw new Error(e);
270:                }
271:
272:            }
273:
274:            public JAXBRIContext getJAXBContext() {
275:                return jc;
276:            }
277:
278:            public JAXBRIContext getJAXBRIContextHeaders() {
279:                return jaxbricontext;
280:            }
281:
282:            public Marshaller createMarshaller() {
283:                try {
284:                    Marshaller marshaller = jc.createMarshaller();
285:                    marshaller.setProperty(Marshaller.JAXB_FRAGMENT,
286:                            Boolean.TRUE);
287:                    return marshaller;
288:                } catch (JAXBException e) {
289:                    return null;
290:                }
291:            }
292:
293:            public Unmarshaller createUnmarshaller() {
294:                try {
295:                    return jc.createUnmarshaller();
296:                } catch (JAXBException e) {
297:                    return null;
298:                }
299:            }
300:
301:            public QName getMessageNumberRolloverQname() {
302:                return new QName(namespaceUri, "MessageNumberRollover");
303:
304:            }
305:
306:            public QName getUnknownSequenceQname() {
307:                return new QName(namespaceUri, "UnknownSequence");
308:            }
309:
310:            public QName getClosedSequenceQname() {
311:                return new QName(namespaceUri, "SequenceClosed");
312:            }
313:
314:            public QName getCreateSequenceRefusedQname() {
315:                return new QName(namespaceUri, "CreateSequenceRefused");
316:            }
317:
318:            public QName getSequenceTerminatedQname() {
319:                return new QName(namespaceUri, "SequenceTerminated");
320:
321:            }
322:
323:            public QName getSequenceQName() {
324:                return new QName(getNamespaceURI(), "Sequence");
325:            }
326:
327:            public QName getAckRequestedQName() {
328:                return new QName(getNamespaceURI(), "AckRequested");
329:            }
330:
331:            public QName getSequenceAcknowledgementQName() {
332:                return new QName(getNamespaceURI(), "SequenceAcknowledgement");
333:            }
334:
335:            /**
336:             * Returns the value of the WS-Addressing Action property stand alone Sequence
337:             * messages with Last child.
338:             *
339:             * @return The Action value (http://schemas.xmlsoap.org/ws/2005/02/rm/Last)
340:             */
341:            public String getLastAction() {
342:                return namespaceUri + "/LastMessage";
343:            }
344:
345:            public String getCloseSequenceAction() {
346:                return namespaceUri + "/CloseSequence";
347:            }
348:
349:            public String getCloseSequenceResponseAction() {
350:                return namespaceUri + "/CloseSequenceResponse";
351:            }
352:
353:            public String getTerminateSequenceResponseAction() {
354:                return namespaceUri + "/TerminateSequenceResponse";
355:            }
356:
357:            public abstract List<Class> getClassesToBeBound()
358:                    throws RMException;
359:
360:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.