docs: @Override
      public MessageContext getMessageContext()
                      throws IllegalStateException
      {
          boolean isEndpointMethod = false; // LI2281.07
  
          // Get the method context for the current thread, and check to see if
          // the current method is from WebService Endpoint interface.       d174057
          Object context = EJSContainer.getMethodContext(); // d646139.1
          if (context instanceof EJSDeployedSupport)
          {
              EJSDeployedSupport s = (EJSDeployedSupport) context;
              if (s.methodInfo.ivInterface == MethodInterface.SERVICE_ENDPOINT)
              {
                  isEndpointMethod = true;
              }
          }
  
          // getMessageContext is allowed only from within Web Service Endpoint
          // interface methods.  StatefulSessionBeanO overrides this method and
          // throws an exception for that spec restriction.
          if (!isEndpointMethod)
          {
              IllegalStateException ise;
  
              // Not an allowed method for Stateful beans per EJB Specification.
              ise = new IllegalStateException("SessionBean: getMessageContext not " +
                                              "allowed from Non-WebService " +
                                              "Endpoint method");
              if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                  Tr.debug(tc, "getMessageContext: " + ise);
  
              throw ise;
          }
  
          if (messageContextMethod == null) {
              try {
                  messageContextMethod =
                                  Class.forName("com.ibm.ws.webservices.engine.MessageContext")
                                                  .getMethod("getCurrentThreadsContext", (Class[]) null);
              } catch (SecurityException e) {
                  FFDCFilter.processException(
                                              e,
                                              CLASS_NAME + ".getMessageContext",
                                              "348",
                                              this);
              } catch (NoSuchMethodException e) {
                  FFDCFilter.processException(
                                              e,
                                              CLASS_NAME + ".getMessageContext",
                                              "354",
                                              this);
              } catch (ClassNotFoundException e) {
                  FFDCFilter.processException(
                                              e,
                                              CLASS_NAME + ".getMessageContext",
                                              "360",
                                              this);
              }
          }
  
          MessageContext theMessageContext = null;
          try {
              theMessageContext = (MessageContext) messageContextMethod.invoke(null, (Object[]) null);
          } catch (IllegalArgumentException e) {
              FFDCFilter.processException(
                                          e,
                                          CLASS_NAME + ".getMessageContext",
                                          "372",
                                          this);
          } catch (IllegalAccessException e) {
              FFDCFilter.processException(
                                          e,
                                          CLASS_NAME + ".getMessageContext",
                                          "378",
                                          this);
          } catch (InvocationTargetException e) {
              FFDCFilter.processException(
                                          e,
                                          CLASS_NAME + ".getMessageContext",
                                          "384",
                                          this);
          }
  
          return theMessageContext;
  
      }