Package com.trafficparrot.sdk.messaging
Class JmsNamespaceBridge
java.lang.Object
com.trafficparrot.sdk.messaging.JmsNamespaceBridge
- Direct Known Subclasses:
JmsNamespaceBridge
Bridges between javax.jms and jakarta.jms namespaces using dynamic proxies.
This bridge exists ONLY for backward compatibility with old customer plugins that use javax.jms.
Jakarta-based plugins are first-class citizens and should receive native jakarta.jms objects
directly -- they should never need bridging. The framework calls jakarta plugins via
JmsResponseTransformer.transformJakarta(com.trafficparrot.sdk.messaging.Destination, jakarta.jms.Message, com.trafficparrot.sdk.messaging.JmsResponse, com.github.tomakehurst.wiremock.extension.Parameters) which passes the native jakarta.jms.Message
without any wrapping.
The bridge is used only when calling old javax.jms customer plugins: it wraps the native jakarta.jms objects as javax.jms proxies so that legacy plugin code can work unchanged.
The bridge handles:
- Return value wrapping: methods returning JMS types (e.g.,
getJMSDestination(),getJMSReplyTo()) are automatically wrapped to the caller's expected namespace. - Argument type conversion: method parameter types are mapped across namespaces so that
e.g.
setJMSReplyTo(Destination)resolves to the delegate's namespace. - Exception propagation:
InvocationTargetExceptionis unwrapped so checked exceptions (e.g., JMSException) propagate directly withoutUndeclaredThrowableExceptionwrapping. - Double-proxy unwrap: if a message is already a bridge proxy wrapping an object of the target namespace, the original object is returned instead of creating a nested proxy.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends jakarta.jms.Message>
TwrapAsJakarta(javax.jms.Message javaxMessage) Ajakarta.jmsview of ajavax.jmsmessage: calls on the view go to the message.static <T extends javax.jms.Message>
TwrapAsJavax(jakarta.jms.Message jakartaMessage) Ajavax.jmsview of ajakarta.jmsmessage: calls on the view go to the message.
-
Constructor Details
-
JmsNamespaceBridge
public JmsNamespaceBridge()Not needed, since every method is static. Declared so that code which creates an instance keeps working.
-
-
Method Details
-
wrapAsJakarta
public static <T extends jakarta.jms.Message> T wrapAsJakarta(javax.jms.Message javaxMessage) Ajakarta.jmsview of ajavax.jmsmessage: calls on the view go to the message. A text message gives ajakarta.jms.TextMessage, a bytes message ajakarta.jms.BytesMessage, and any other message a plainjakarta.jms.Message. A message that is itself ajavax.jmsview of ajakarta.jmsmessage gives that message back.- Type Parameters:
T- thejakarta.jmsmessage type the caller expects, which must be one the message gives- Parameters:
javaxMessage- the message to view; may be null- Returns:
- the view, or null for a null message
-
wrapAsJavax
public static <T extends javax.jms.Message> T wrapAsJavax(jakarta.jms.Message jakartaMessage) Ajavax.jmsview of ajakarta.jmsmessage: calls on the view go to the message. A text message gives ajavax.jms.TextMessage, a bytes message ajavax.jms.BytesMessage, and any other message a plainjavax.jms.Message. A message that is itself ajakarta.jmsview of ajavax.jmsmessage gives that message back.- Type Parameters:
T- thejavax.jmsmessage type the caller expects, which must be one the message gives- Parameters:
jakartaMessage- the message to view; may be null- Returns:
- the view, or null for a null message
-