public abstract class MessageTransformer<T,S>
extends java.lang.Object
import java.util.*; import javax.jms.*; import com.sun.messaging.bridge.api.MessageTransformer; public class MessageTran extends MessageTransformer <Message, Message> { public Message transform(Message message, boolean readOnly, String charsetName, String source, String target, Properties properties) throws Exception { Message m = message; if (source.equals(STOMP)) { //from STOMP client to Java Message Queue //convert any invalid headers from STOMP SEND frame if (properties != null) { ...... //convert key to valid JMS message property name, then call m.setStringProperty() ...... } } else if (source.equals(SUN_MQ)) { //from Java Message Queue to STOMP client if (message instanceof ObjectMessage) { //create a new BytesMessage for message to be transformed to BytesMessage bm = (BytesMessage)createJMSMessage(JMSMessageType.BYTESMESSAGE); //convert message to the BytesMessage ...... m = bm; } else { .... } } return m; }
Modifier and Type | Class and Description |
---|---|
static class |
MessageTransformer.JMSMessageType |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
STOMP
The predefined provider name for JMS message to/from STOMP client
|
static java.lang.String |
SUN_MQ
The predefined provider name for JMS message to/from Sun Java Message Queue
|
Constructor and Description |
---|
MessageTransformer() |
Modifier and Type | Method and Description |
---|---|
protected void |
branchTo(java.lang.Object d)
To be called from the transform() method when needs to tell the bridge to branch the message that is to be returned
by the transform() call to a different destination in the target provider
|
protected javax.jms.Message |
createJMSMessage(MessageTransformer.JMSMessageType type)
Create a JMS message object.
|
protected javax.jms.Queue |
createQueue(java.lang.String queueName)
To be called from the transform() method when needs to create a JMS Queue object to the target provider
|
protected javax.jms.Topic |
createTopic(java.lang.String topicName)
To be called from the transform() method when needs to create a JMS Topic object to the target provider
|
java.lang.Object |
getBranchTo()
This method is called by the bridge service after transform() is returned for bridge types that support branchTo()
|
void |
init(java.lang.Object obj,
java.lang.String bridgeType)
This method is called by the bridge service before transform() is called.
|
boolean |
isNoTransfer()
This method is called by the bridge service after transform() is returned for bridge types that support noTransfer()
|
protected void |
noTransfer()
To be called from the transform() method when needs to tell the bridge to consume from source and not transfer to
target the message that is to be returned by the transform() call
|
abstract T |
transform(S message,
boolean readOnly,
java.lang.String charsetName,
java.lang.String source,
java.lang.String target,
java.util.Properties properties)
To be implemented by user
|
public static final java.lang.String SUN_MQ
public static final java.lang.String STOMP
public final void init(java.lang.Object obj, java.lang.String bridgeType)
public final java.lang.Object getBranchTo()
public final boolean isNoTransfer()
protected final javax.jms.Message createJMSMessage(MessageTransformer.JMSMessageType type) throws java.lang.Exception
type
- the type of the JMS message to be createdjava.lang.IllegalStateException
- if this MessageTransfomer object is not initializedjava.lang.Exception
- if fails to create the JMS Messageprotected final javax.jms.Queue createQueue(java.lang.String queueName) throws java.lang.Exception
queueName
- the name of the Queuejava.lang.IllegalStateException
- if this MessageTransfomer object is not initializedjava.lang.Exception
- if fails to create the Queue objectprotected final javax.jms.Topic createTopic(java.lang.String topicName) throws java.lang.Exception
topicName
- the name of the Topicjava.lang.IllegalStateException
- if this MessageTransfomer object is not initializedjava.lang.Exception
- if fails to create the Topic objectprotected final void branchTo(java.lang.Object d) throws java.lang.Exception
d
- a java.lang.String or javax.jms.Destination object that specifies the destination in target provider to
branch the message tojava.lang.IllegalStateException
- if this MessageTransfomer object is not initializedjava.lang.IllegalArgumentException
- if null or unexpected object type passed injava.lang.UnsupportedOperationException
- if the operation is not supported for the bridge typejava.lang.Exception
- if fails to create the JMS Messageprotected final void noTransfer() throws java.lang.Exception
java.lang.IllegalStateException
- if this MessageTransfomer object is not initializedjava.lang.UnsupportedOperationException
- if the operation is not supported for the bridge typejava.lang.Exception
public abstract T transform(S message, boolean readOnly, java.lang.String charsetName, java.lang.String source, java.lang.String target, java.util.Properties properties) throws java.lang.Exception
message
- the message object to be tranformed.readOnly
- if the message is in read-only modecharsetName
- the charset name for message if applicable, null if not availablesource
- the source provider nametarget
- the target provider nameproperties
- any properties for the transform() call, null if nonejava.lang.Exception
- if unable to transform messageCopyright (c) 2010, 2017 Oracle and/or its affiliates. All rights reserved.