Class JmsNamespaceBridge

java.lang.Object
com.trafficparrot.sdk.messaging.JmsNamespaceBridge
Direct Known Subclasses:
JmsNamespaceBridge

public class JmsNamespaceBridge extends Object
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: InvocationTargetException is unwrapped so checked exceptions (e.g., JMSException) propagate directly without UndeclaredThrowableException wrapping.
  • 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
    Constructor
    Description
    Not needed, since every method is static.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T extends jakarta.jms.Message>
    T
    wrapAsJakarta(javax.jms.Message javaxMessage)
    A jakarta.jms view of a javax.jms message: calls on the view go to the message.
    static <T extends javax.jms.Message>
    T
    wrapAsJavax(jakarta.jms.Message jakartaMessage)
    A javax.jms view of a jakarta.jms message: calls on the view go to the message.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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)
      A jakarta.jms view of a javax.jms message: calls on the view go to the message. A text message gives a jakarta.jms.TextMessage, a bytes message a jakarta.jms.BytesMessage, and any other message a plain jakarta.jms.Message. A message that is itself a javax.jms view of a jakarta.jms message gives that message back.
      Type Parameters:
      T - the jakarta.jms message 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)
      A javax.jms view of a jakarta.jms message: calls on the view go to the message. A text message gives a javax.jms.TextMessage, a bytes message a javax.jms.BytesMessage, and any other message a plain javax.jms.Message. A message that is itself a jakarta.jms view of a javax.jms message gives that message back.
      Type Parameters:
      T - the javax.jms message 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