Java: Предупреждение: обработчик является необработанным типом. Ссылки на generi c type Handler <C>должны быть параметризованы - PullRequest
0 голосов
/ 15 февраля 2020

У меня есть класс HandlerResolverImpl:

import java.util.ArrayList;
import java.util.List;

import javax.xml.ws.handler.Handler;
import javax.xml.ws.handler.HandlerResolver;
import javax.xml.ws.handler.PortInfo;
import javax.xml.ws.handler.soap.SOAPMessageContext;

public class HandlerResolverImpl implements HandlerResolver {

    private List<Handler<SOAPMessageContext>> handlerList;

    public HandlerResolverImpl() {
    }

    public HandlerResolverImpl(final HeaderHandler headerHandler) {
        handlerList = new ArrayList<>();
        handlerList.add(headerHandler);
    }

    public List<Handler<SOAPMessageContext>> getHandlerList() {
        return new ArrayList<>(handlerList);
    }

    public void setHandlerList(final List<Handler<SOAPMessageContext>> handlerList) {
        this.handlerList = new ArrayList<>(handlerList);
    }

    @Override
    public List<Handler> getHandlerChain(final PortInfo portInfo) {
        return new ArrayList<>(this.handlerList);
    }

}

Интерфейс HandlerResolver

/** 
 *  {@code HandlerResolver} is an interface implemented
 *  by an application to get control over the handler chain
 *  set on proxy/dispatch objects at the time of their creation.
 *  <p>
 *  A {@code HandlerResolver} may be set on a {@code Service}
 *  using the {@code setHandlerResolver} method.
 *  <p>
 *  When the runtime invokes a {@code HandlerResolver}, it will
 *  pass it a {@code PortInfo} object containing information
 *  about the port that the proxy/dispatch object will be accessing.
 *
 *  @see javax.xml.ws.Service#setHandlerResolver
 *
 *  @since 1.6, JAX-WS 2.0
**/
public interface HandlerResolver {

  /** 
   *  Gets the handler chain for the specified port.
   *
   *  @param portInfo Contains information about the port being accessed.
   *  @return {@code java.util.List<Handler>} chain
  **/
  public java.util.List<Handler> getHandlerChain(PortInfo portInfo);
}

И универсальный обработчик c интерфейса

import javax.xml.ws.ProtocolException;

/** The {@code Handler} interface
 *  is the base interface for JAX-WS handlers.
 *
 * @param <C> message context
 *  @since 1.6, JAX-WS 2.0
**/
public interface Handler<C extends MessageContext> {

  /** The {@code handleMessage} method is invoked for normal processing
   *  of inbound and outbound messages. Refer to the description of the handler
   *  framework in the JAX-WS specification for full details.
   *
   *  @param context the message context.
   *  @return An indication of whether handler processing should continue for
   *  the current message
   *                 <ul>
   *                 <li>Return {@code true} to continue
   *                     processing.</li>
   *                 <li>Return {@code false} to block
   *                     processing.</li>
   *                  </ul>
   *  @throws RuntimeException Causes the JAX-WS runtime to cease
   *    handler processing and generate a fault.
   *  @throws ProtocolException Causes the JAX-WS runtime to switch to
   *    fault message processing.
  **/
  public boolean handleMessage(C context);

  /** The {@code handleFault} method is invoked for fault message
   *  processing.  Refer to the description of the handler
   *  framework in the JAX-WS specification for full details.
   *
   *  @param context the message context
   *  @return An indication of whether handler fault processing should continue
   *  for the current message
   *                 <ul>
   *                 <li>Return {@code true} to continue
   *                     processing.</li>
   *                 <li>Return {@code false} to block
   *                     processing.</li>
   *                  </ul>
   *  @throws RuntimeException Causes the JAX-WS runtime to cease
   *    handler fault processing and dispatch the fault.
   *  @throws ProtocolException Causes the JAX-WS runtime to cease
   *    handler fault processing and dispatch the fault.
  **/
  public boolean handleFault(C context);

  /**
   * Called at the conclusion of a message exchange pattern just prior to
   * the JAX-WS runtime dispatching a message, fault or exception.  Refer to
   * the description of the handler
   * framework in the JAX-WS specification for full details.
   *
   * @param context the message context
  **/
  public void close(MessageContext context);
}

Для метода Список getHandlerChain (окончательный PortInfo portInfo)

Я получаю предупреждение: обработчик является необработанным типом. Ссылки на обработчик типа c должны быть параметризованы.

Поскольку метод, определенный в интерфейсе HandlerResolverImpl, не реализует тип Handler как generi c, возможно ли избежать этого предупреждения?

Я попробовал несколько идей, но я застрял, пытаясь решить это предупреждение правильно.

...