01: /*
02: * BEGIN_HEADER - DO NOT EDIT
03: *
04: * The contents of this file are subject to the terms
05: * of the Common Development and Distribution License
06: * (the "License"). You may not use this file except
07: * in compliance with the License.
08: *
09: * You can obtain a copy of the license at
10: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
11: * See the License for the specific language governing
12: * permissions and limitations under the License.
13: *
14: * When distributing Covered Code, include this CDDL
15: * HEADER in each file and include the License file at
16: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
17: * If applicable add the following below this CDDL HEADER,
18: * with the fields enclosed by brackets "[]" replaced with
19: * your own identifying information: Portions Copyright
20: * [year] [name of copyright owner]
21: */
22:
23: /*
24: * @(#)ExchangePattern.java
25: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
26: *
27: * END_HEADER - DO NOT EDIT
28: */
29: package com.sun.jbi.messaging;
30:
31: import java.net.URI;
32:
33: import org.w3c.dom.Document;
34:
35: /**
36: *
37: * @author Sun Microsystems, Inc.
38: */
39: public enum ExchangePattern {
40: IN_ONLY("http://www.w3.org", "2004/08", "in-only"), IN_OUT(
41: "http://www.w3.org", "2004/08", "in-out"), ROBUST_IN_ONLY(
42: "http://www.w3.org", "2004/08", "robust-in-only"), IN_OPTIONAL_OUT(
43: "http://www.w3.org", "2004/08", "in-opt-out"), UNKNOWN("",
44: "", "");
45:
46: private String mPatternStr;
47: private URI mPatternUri;
48:
49: ExchangePattern(String uriRoot, String version, String mep) {
50: mPatternStr = uriRoot + "/" + version + "/wsdl/" + mep;
51:
52: try {
53: mPatternUri = new URI(mPatternStr);
54: } catch (java.net.URISyntaxException uriEx) {
55: throw new IllegalArgumentException(mPatternStr, uriEx);
56: }
57: }
58:
59: public String toString() {
60: return mPatternStr;
61: }
62:
63: public URI getURI() {
64: return mPatternUri;
65: }
66:
67: public static ExchangePattern valueOf(URI pattern) {
68: String mep = pattern.toString();
69:
70: // At this point, we only recognize MEPs defined by the W3C WSDL WG
71: if (!mep.startsWith("http://www.w3.org/")) {
72: return UNKNOWN;
73: }
74:
75: // Match based on the actual MEP name
76: if (mep.endsWith("/in-only")) {
77: return IN_ONLY;
78: } else if (mep.endsWith("/in-out")) {
79: return IN_OUT;
80: } else if (mep.endsWith("/robust-in-only")) {
81: return ROBUST_IN_ONLY;
82: } else if (mep.endsWith("/in-opt-out")) {
83: return IN_OPTIONAL_OUT;
84: } else {
85: return UNKNOWN;
86: }
87: }
88:
89: }
|