|
Sun GlassFish(tm) Message Queue v4.4 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.messaging.bridge.service.MessageTransformer<T,S>
public abstract class MessageTransformer<T,S>
The message transformer class to be extended by user. Its implementation must provide a public zero-argument constructor. The following is an example usage of this class for MQ STOMP bridge
import java.util.*; import javax.jms.*; import com.sun.messaging.bridge.service.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; }
Nested Class Summary | |
---|---|
static class |
MessageTransformer.JMSMessageType
|
Field Summary | |
---|---|
static String |
STOMP
The predefined provider name for JMS message to/from STOMP client |
static String |
SUN_MQ
The predefined provider name for JMS message to/from Sun Java Message Queue |
Constructor Summary | |
---|---|
MessageTransformer()
|
Method Summary | |
---|---|
protected Message |
branchTo(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() method to a different destination in the target provider |
protected Message |
createJMSMessage(MessageTransformer.JMSMessageType type)
Create a JMS message object. |
protected Queue |
createQueue(String d)
To be called from the transform() method when needs to create a JMS Queue object to the target provider |
protected Topic |
createTopic(String d)
To be called from the transform() method when needs to create a JMS Topic object to the target provider |
void |
init(Object obj,
String bridgeType)
This method is called by the bridge service before transform() is called. |
abstract T |
transform(S message,
boolean readOnly,
String charsetName,
String source,
String target,
Properties properties)
To be implemented by user |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String SUN_MQ
public static final String STOMP
Constructor Detail |
---|
public MessageTransformer()
Method Detail |
---|
public final void init(Object obj, String bridgeType)
protected final Message createJMSMessage(MessageTransformer.JMSMessageType type) throws Exception
type
- the type of the JMS message to be created
IllegalStateException
- if this MessageTransfomer object is not initialized
Exception
- if fails to create the JMS Messageprotected final Queue createQueue(String d) throws Exception
queueName
- the name of the Queue
IllegalStateException
- if this MessageTransfomer object is not initialized
Exception
- if fails to create the Queue objectprotected final Topic createTopic(String d) throws Exception
topicName
- the name of the Topic
IllegalStateException
- if this MessageTransfomer object is not initialized
Exception
- if fails to create the Topic objectprotected final Message branchTo(Object d) throws Exception
IllegalStateException
- if this MessageTransfomer object is not initialized
IllegalArgumentException
- if null argument
UnsupportedOperationException
- if the operation is not supported for the bridge type
Exception
- if fails to create the JMS Messagepublic abstract T transform(S message, boolean readOnly, String charsetName, String source, String target, Properties properties) throws 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 none
Exception
- if unable to transform message
|
Sun GlassFish(tm) Message Queue v4.4 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |