001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)MessageAdaptorFactory.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.binding.jms.handler;
030:
031: import javax.jms.Session;
032: import javax.jms.Message;
033:
034: /**
035: * Factory class for message adaptors.
036: *
037: * @author Sun Microsystems Inc.
038: */
039: class MessageAdaptorFactory {
040: /**
041: * Creates a new MessageAdaptorFactory object.
042: */
043: public MessageAdaptorFactory() {
044: }
045:
046: /**
047: * Returs the appropriate adaptor.
048: *
049: * @param msg JMS message.
050: *
051: * @return message adaptor implementation.
052: */
053: public static MessageAdaptor getAdaptor(Message msg, String deptype) {
054: MessageAdaptor adaptor = null;
055:
056: if (msg instanceof javax.jms.TextMessage) {
057: if (deptype.trim().equals("WSDL11")) {
058: adaptor = new Wsdl11TextMessageAdaptor();
059: } else {
060: adaptor = new TextMessageAdaptor();
061: }
062:
063: // process text
064: } else if (msg instanceof javax.jms.BytesMessage) {
065: ;// processByteMessage();
066: } else if (msg instanceof javax.jms.StreamMessage) {
067: ;// processStreamMessage();
068: } else if (msg instanceof javax.jms.MapMessage) {
069: ;// processMapMessage();
070: } else if (msg instanceof javax.jms.ObjectMessage) {
071: ;// processObjectMessage();
072: } else {
073: ;// seend some error back
074: }
075:
076: return adaptor;
077: }
078:
079: /**
080: * Gets the adaptor based on the type.
081: *
082: * @param outputtype type of output message.
083: *
084: * @return message adaptor implementation.
085: */
086: public static MessageAdaptor getAdaptor(String outputtype,
087: String deptype) {
088: MessageAdaptor adaptor = null;
089:
090: if (outputtype.trim().equals(MessageProperties.TEXT_MESSAGE)) {
091: if (deptype.trim().equals("WSDL11")) {
092: adaptor = new Wsdl11TextMessageAdaptor();
093: } else {
094: adaptor = new TextMessageAdaptor();
095: }
096:
097: } else if (outputtype.trim().equals(
098: MessageProperties.STREAM_MESSAGE)) {
099: ;
100: } else if (outputtype.trim().equals(
101: MessageProperties.OBJECT_MESSAGE)) {
102: ;
103: } else if (outputtype.trim().equals(
104: MessageProperties.MAP_MESSAGE)) {
105: ;
106: } else if (outputtype.trim().equals(
107: MessageProperties.BYTE_MESSAGE)) {
108: ;
109: }
110:
111: return adaptor;
112: }
113: }
|