01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.servicemix.jbi.messaging;
18:
19: import javax.jbi.messaging.MessageExchange;
20: import javax.jbi.messaging.MessagingException;
21: import javax.jbi.messaging.NormalizedMessage;
22:
23: /**
24: * A plugin strategy which marshals an Object into and out of a JBI message.
25: * This interface is used by the ServiceMixClient to marshal POJOs into and out
26: * of JBI messages.
27: *
28: * @version $Revision: 564607 $
29: */
30: public interface PojoMarshaler {
31:
32: /**
33: * The key on the message to store the message body which cannot be
34: * marshaled into or out of XML easily or to provide a cache of the object
35: * representation of the object.
36: */
37: String BODY = "org.apache.servicemix.body";
38:
39: /**
40: * Marshals the payload into the normalized message, typically as the
41: * content property.
42: *
43: * @param exchange
44: * the message exchange in which to marshal
45: * @param message
46: * the message in which to marshal
47: * @param body
48: * the body of the message as a POJO
49: */
50: void marshal(MessageExchange exchange, NormalizedMessage message,
51: Object body) throws MessagingException;
52:
53: /**
54: * Unmarshals the response out of the normalized message.
55: *
56: * @param exchange
57: * the message exchange, which is an {@link InOut} or
58: * {@link InOptionalOut}
59: * @param message
60: * the output message
61: * @return the unmarshaled body object, extracted from the message
62: * @throws MessagingException
63: */
64: Object unmarshal(MessageExchange exchange, NormalizedMessage message)
65: throws MessagingException;
66: }
|