private boolean handleFault(int i) {
    Handler handler = _chain.get(i);

    boolean success = false;
    _invoked[i] = true;

    try {
      if (handler instanceof LogicalHandler) {
        _logicalContext.getMessage().setPayload(_source);
        success = handler.handleFault(_logicalContext);
        _source = _logicalContext.getMessage().getPayload();
      } else if (handler instanceof SOAPHandler) {
        try {
          _soapContext.setMessage(_source);
          success = handler.handleFault(_soapContext);
          _source = _soapContext.getMessage().getSOAPPart().getContent();
        } catch (SOAPException e) {
          throw new WebServiceException(e);
        }
      } else {
        throw new WebServiceException(
            L.l("Unsupported Handler type: {0}", handler.getClass().getName()));
      }

      _protocolException = null;
    } catch (ProtocolException e) {
      _protocolException = e;
      serializeProtocolException();
    } catch (RuntimeException e) {
      _runtimeException = e;
      serializeRuntimeException();
    }

    return success;
  }
コード例 #2
0
  /** Injects the given 'init-params' into the given handler. */
  @Internal
  protected void injectInitParams(
      final Handler<CONTEXT> handler, final Map<String, String> initParams) {
    for (final Field field : handler.getClass().getDeclaredFields()) {
      if (field.getAnnotation(Resource.class) != null
          && field.getType().isAssignableFrom(initParams.getClass())) {
        try {
          LOG.info(
              "Inject 'initParams' to JAX-WS handler [path={}#{}]",
              handler.getClass().getName(),
              field.getName());
          field.setAccessible(true);
          field.set(handler, initParams);
          return;
        } catch (final ReflectiveOperationException e) {
          throw new PlatformException(
              "Failed to inject 'InitParams' for handler '{}'", handler.getClass().getName(), e);
        }
      }
    }

    if (!initParams.isEmpty()) {
      LOG.warn(
          "'InitParams' could not be injected into handler because no field found that is of type Map<String, String> and annotated with @Resource [handler={}, initParams={}]",
          handler.getClass().getName(),
          initParams);
    }
  }
コード例 #3
0
ファイル: HandlerChainBuilder.java プロジェクト: Jutten/cxf
 private void initializeViaInitMethod(
     Handler<?> handler, Map<String, String> params, Method init) {
   try {
     init.invoke(handler, params);
   } catch (InvocationTargetException ex) {
     Throwable t = ex.getCause() != null ? ex.getCause() : ex;
     LogUtils.log(LOG, Level.WARNING, "INIT_METHOD_THREW_EXCEPTION", t, handler.getClass());
   } catch (IllegalAccessException ex) {
     LOG.log(Level.SEVERE, "CANNOT_ACCESS_INIT", handler.getClass());
   }
 }
  public String toString() {
    StringBuilder sb = new StringBuilder("HandlerChainInvoker[\n");

    for (Handler handler : _chain) {
      sb.append(handler.toString());
      sb.append('\n');
    }

    sb.append(']');

    return sb.toString();
  }
コード例 #5
0
 /**
  * Method invoked to optionally run the given {@link Callable} on behalf of a {@link RunContext}.
  */
 @Internal
 protected <T> T handle(
     final MessageContext messageContext, final String method, final Callable<T> callable) {
   try {
     if (m_handlerRunContextProducer == null) {
       return callable.call();
     } else {
       final Subject subject = MessageContexts.getSubject(messageContext, HANDLER_SUBJECT);
       return m_handlerRunContextProducer
           .produce(subject)
           .call(
               new Callable<T>() {
                 @Override
                 public T call() throws Exception {
                   return callable.call();
                 }
               },
               DefaultExceptionTranslator.class);
     }
   } catch (final Exception e) {
     LOG.error(
         "Failed to handle message [handler={}, method={}, inbound={}]",
         m_handler.getClass().getName(),
         method,
         MessageContexts.isInboundMessage(messageContext),
         e);
     throw new HTTPException(
         HttpServletResponse.SC_INTERNAL_SERVER_ERROR); // do not send cause to the client
   }
 }
コード例 #6
0
ファイル: HandlerChainBuilder.java プロジェクト: Jutten/cxf
 private Method getInitMethod(Handler<?> handler) {
   Method m = null;
   try {
     m = handler.getClass().getMethod("init", Map.class);
   } catch (NoSuchMethodException ex) {
     // empty
   }
   return m;
 }
  private void close(int i) {
    Handler handler = _chain.get(i);

    if (!_invoked[i]) return;

    _invoked[i] = false;

    if (handler instanceof LogicalHandler) {
      _logicalContext.getMessage().setPayload(_source);
      handler.close(_logicalContext);
      _source = _logicalContext.getMessage().getPayload();
    } else if (handler instanceof SOAPHandler) {
      try {
        _soapContext.setMessage(_source);
        handler.close(_soapContext);
        _source = _soapContext.getMessage().getSOAPPart().getContent();
      } catch (SOAPException e) {
        throw new WebServiceException(e);
      }
    }
  }
コード例 #8
0
  @SuppressWarnings("unchecked")
  public HandlerDelegate(
      final org.eclipse.scout.rt.server.jaxws.provider.annotation.Handler handlerAnnotation) {
    m_handler =
        BEANS.get(ClazzUtil.resolve(handlerAnnotation.value(), Handler.class, "@Handler.value"));

    final RunWithRunContext runHandleWithRunContext =
        m_handler.getClass().getAnnotation(RunWithRunContext.class);
    m_handlerRunContextProducer =
        (runHandleWithRunContext != null ? BEANS.get(runHandleWithRunContext.value()) : null);

    injectInitParams(m_handler, toInitParamMap(handlerAnnotation.initParams()));
  }