001 /**
002 *
003 * Copyright 2004 Protique Ltd
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 *
017 **/
018 package org.codehaus.activesoap.wsif;
019
020 import org.codehaus.activesoap.Handler;
021 import org.codehaus.activesoap.MessageExchange;
022 import org.codehaus.activesoap.handler.stax.AnyElementMarshaler;
023 import org.apache.wsif.WSIFMessage;
024
025 import javax.xml.stream.XMLStreamException;
026 import java.util.Iterator;
027
028 /**
029 * Fires the parts of the given message into the handler for invocations from
030 * <a href="http://ws.apache.org/wsif/">WSIF</a> into <a href="http://activesoap.codehaus.org/">ActiveSOAP</a>
031 *
032 * @version $Revision: 1.1 $
033 */
034 public class WSIFHandler implements Handler {
035 private WSIFMessage message;
036 private AnyElementMarshaler marshaler;
037
038 public WSIFHandler(WSIFMessage message, AnyElementMarshaler marshaler) {
039 this.message = message;
040 this.marshaler = marshaler;
041 }
042
043 public void invoke(MessageExchange exchange) throws Exception {
044 for (Iterator iter = message.getPartNames(); iter.hasNext(); ) {
045 String name = (String) iter.next();
046 Object part = message.getObjectPart(name);
047 processPart(name, part, exchange);
048 }
049 }
050
051 protected void processPart(String name, Object part, MessageExchange exchange) throws XMLStreamException {
052 marshaler.writeElement(part, exchange.getOut());
053 }
054 }