docs: @Override
      final public ManagedConnection createManagedConnection(
                                                             final Subject subject, final ConnectionRequestInfo requestInfo)
                      throws ResourceException {
  
          if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
              SibTr.entry(this, TRACE, "createManagedConnection", new Object[] {
                                                                                JmsJcaManagedConnection.subjectToString(subject),
                                                                                requestInfo });
          }
  
          // If we have some request information then see if it already has a core
          // connection associated with it
  
          JmsJcaConnectionRequestInfo jmsJcaRequestInfo = null;
          SICoreConnection requestCoreConnection = null;
          SICoreConnection coreConnection = null;
  
          if (requestInfo != null) {
  
              // Check we have the right type of request information
  
              if (!(requestInfo instanceof JmsJcaConnectionRequestInfo)) {
  
                  throw new ResourceAdapterInternalException(NLS
                                  .getFormattedMessage(("EXCEPTION_RECEIVED_CWSJR1022"),
                                                       new Object[] {
                                                                     "createManagedConnection",
                                                                     JmsJcaConnectionRequestInfo.class
                                                                                     .getName(),
                                                                     requestInfo.getClass().getName() },
                                                       null));
  
              }
  
              jmsJcaRequestInfo = (JmsJcaConnectionRequestInfo) requestInfo;
              requestCoreConnection = jmsJcaRequestInfo.getSICoreConnection();
  
              if (requestCoreConnection != null) {
                  // Check that the core connection is still available, ie hasn't been closed. If the
                  // core connection is no longer available, null it out and continue without it.
  
                  try {
                      // There is no isAvailable() method on a core connection we use getConnectionListeners()
                      // which is believed to be the cheapest alternative method.
                      requestCoreConnection.getConnectionListeners();
  
                  } catch (final SIException e) {
                      // No FFDC code needed
                      if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled())
                          SibTr.debug(TRACE, "Connection Request Info core connection no longer available");
                      jmsJcaRequestInfo.setSICoreConnection(null);
                      requestCoreConnection = null;
                  } catch (final SIErrorException e) {
                      // No FFDC code needed
                      if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled())
                          SibTr.debug(TRACE, "Connection Request Info core connection no longer available");
                      jmsJcaRequestInfo.setSICoreConnection(null);
                      requestCoreConnection = null;
                  }
              }
          }
  
          // See if we can get a user name and password from the subject or
          // request information
  
          final JmsJcaUserDetails userDetails = getUserDetails(subject,
                                                               requestInfo);
  
          // If we didn't get any request information or we did but it didn't
          // contain a core connection, create a new one
  
          if (requestCoreConnection == null) {
  
              // Obtain a core connection factory
  
              final SICoreConnectionFactory coreConnectionFactory;
  
              if (!UTEHelperFactory.jmsTestEnvironmentEnabled) {
  
                  try {
  
                      coreConnectionFactory = SICoreConnectionFactorySelector
                                      .getSICoreConnectionFactory(FactoryType.TRM_CONNECTION);
  
                  } catch (final SIException exception) {
  
                      FFDCFilter.processException(exception, CLASS_NAME
                                                             + ".createManagedConnection", FFDC_PROBE_5, this);
                      throw new ResourceException(NLS.getFormattedMessage(
                                                                          "EXCEPTION_RECEIVED_CWSJR1021", new Object[] {
                                                                                                                        exception, "getSICoreConnectionFactory" },
                                                                          null), exception);
  
                  }
  
              } else {
  
                  coreConnectionFactory = UTEHelperFactory.getHelperInstance()
                                  .setupJmsTestEnvironment();
  
              }
  
              // Check we have obtained a core connection factory successfully
  
              if (coreConnectionFactory == null) {
  
                  throw new ResourceAdapterInternalException(NLS
                                  .getFormattedMessage(
                                                       ("SICORECONNECTION_ERROR_CWSJR1023"),
                                                       new Object[] { "createManagedConnection" },
                                                       null));
  
              }
  
              // Create a connection
  
              try {
  
                  final Map trmProperties = getTrmProperties();
  
                  if (userDetails == null) {
  
                      requestCoreConnection = coreConnectionFactory
                                      .createConnection(subject, trmProperties);
  
                  } else {
  
                      requestCoreConnection = coreConnectionFactory
                                      .createConnection(userDetails.getUserName(),
                                                        userDetails.getPassword(), trmProperties);
  
                  }
  
              } catch (final SIException exception) {
  
                  FFDCFilter.processException(exception, CLASS_NAME
                                                         + ".createManagedConnection", FFDC_PROBE_1, this);
                  if (TraceComponent.isAnyTracingEnabled() && TRACE.isEventEnabled()) {
                      SibTr.exception(this, TRACE, exception);
                  }
                  throw new ResourceException(NLS.getFormattedMessage(
                                                                      "EXCEPTION_RECEIVED_CWSJR1028", new Object[] {
                                                                                                                    exception, "createManagedConnection" }, null),
                                  exception);
  
              } catch (final SIErrorException exception) {
  
                  FFDCFilter.processException(exception, CLASS_NAME
                                                         + ".createManagedConnection", FFDC_PROBE_2, this);
                  if (TraceComponent.isAnyTracingEnabled() && TRACE.isEventEnabled()) {
                      SibTr.exception(this, TRACE, exception);
                  }
                  throw new ResourceException(NLS.getFormattedMessage(
                                                                      "EXCEPTION_RECEIVED_CWSJR1028", new Object[] {
                                                                                                                    exception, "createManagedConnection" }, null),
                                  exception);
  
              }
  
              // If we have some request information, set the core connection back
              // into it
  
              if (jmsJcaRequestInfo != null) {
  
                  jmsJcaRequestInfo.setSICoreConnection(requestCoreConnection);
  
              }
  
              // This is a new coreConnection so set this parent coreConnection in 
              // the managedConnection by assigning it to the coreConnection here.
              // The managedconnection will now have full control over the parent
              // coreconnection.
              coreConnection = requestCoreConnection;
          }
          else
          {
  
              try {
                  // We are here as we already have a valid coreconnection in our requestInfo, this
                  // means we already have a managedConnection that is looking at the parent, so we
                  // need to create a clone of that coreConnection to pass into our new managedConnection.
  
                  // Create a clone to give to the managed connection object which will be stored in the 
                  // J2C connection pool.
                  coreConnection = requestCoreConnection.cloneConnection();
              } catch (final SIException e) {
                  FFDCFilter.processException(e, CLASS_NAME + ".createManagedConnection", FFDC_PROBE_7, this);
                  if (TraceComponent.isAnyTracingEnabled() && TRACE.isEventEnabled())
                      SibTr.exception(this, TRACE, e);
                  throw new ResourceException(NLS.getFormattedMessage("EXCEPTION_RECEIVED_CWSJR1028",
                                                                      new Object[] { e, "createManagedConnection" },
                                                                      null), e);
              } catch (final SIErrorException e) {
                  FFDCFilter.processException(e, CLASS_NAME + ".createManagedConnection", FFDC_PROBE_8, this);
                  if (TraceComponent.isAnyTracingEnabled() && TRACE.isEventEnabled())
                      SibTr.exception(this, TRACE, e);
                  throw new ResourceException(NLS.getFormattedMessage("EXCEPTION_RECEIVED_CWSJR1028",
                                                                      new Object[] { e, "createManagedConnection" },
                                                                      null), e);
              }
          }
  
          final JmsJcaManagedConnection managedConnection;
  
          try {
  
              // Create a managed connection
  
              if ((getShareDataSourceWithCMP() != null)
                  && (getShareDataSourceWithCMP().booleanValue())) {
  
                  // ShareDataSourceWithCMP is set - return a managed connection
                  // implementing SynchronizationProvider
  
                  managedConnection = new JmsJcaManagedConnectionSynchronizationProvider(
                                  this, coreConnection, userDetails, subject);
  
              } else {
  
                  // ShareDataSourceWithCMP is not set - return a normal managed
                  // connection
  
                  managedConnection = new JmsJcaManagedConnection(this,
                                  coreConnection, userDetails, subject);
  
              }
  
          } catch (final SIException exception) {
  
              FFDCFilter.processException(exception, CLASS_NAME
                                                     + ".createManagedConnection", FFDC_PROBE_3, this);
              throw new ResourceException(NLS.getFormattedMessage(
                                                                  "EXCEPTION_RECEIVED_CWSJR1026", new Object[] { exception,
                                                                                                                "createManagedConnection" }, null), exception);
  
          }
  
          if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
              SibTr.exit(this, TRACE, "createManagedConnection",
                         managedConnection);
          }
          return managedConnection;
  
      }