Java:警告:处理程序是原始类型。对泛型类型处理程序的引用<;C>;应该参数化
我有一个HandlerResolverImpl类:Java:警告:处理程序是原始类型。对泛型类型处理程序的引用<;C>;应该参数化,java,spring,web-services,soap,handler,Java,Spring,Web Services,Soap,Handler,我有一个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;
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);
}
}
import java.util.ArrayList;
导入java.util.List;
导入javax.xml.ws.handler.handler;
导入javax.xml.ws.handler.HandlerResolver;
导入javax.xml.ws.handler.PortInfo;
导入javax.xml.ws.handler.soap.SOAPMessageContext;
公共类HandlerResolverImpl实现HandlerResolver{
私人名单处理者名单;
公共HandlerResolverImpl(){
}
公共装卸工(最终装卸工){
handlerList=新的ArrayList();
handlerList.add(headerHandler);
}
公共列表getHandlerList(){
返回新的ArrayList(handlerList);
}
公共无效设置句柄列表(最终列表句柄列表){
this.handlerList=新的ArrayList(handlerList);
}
@凌驾
公共列表getHandlerChain(最终PortInfo PortInfo){
返回新的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);
}
/**
*{@code HandlerResolver}是一个实现的接口
*由应用程序控制处理程序链
*在创建代理/分派对象时对其进行设置。
*
*可以在{@code Service}上设置{@code HandlerResolver}
*使用{@code setHandlerResolver}方法。
*
*当运行时调用{@CodeHandlerResolver}时,它将
*将包含信息的{@code-PortInfo}对象传递给它
*关于代理/分派对象将访问的端口。
*
*@see javax.xml.ws.Service#setHandlerResolver
*
*@自1.6以来,JAX-WS 2.0
**/
公共接口HandlerResolver{
/**
*获取指定端口的处理程序链。
*
*@param portInfo包含有关正在访问的端口的信息。
*@return{@code java.util.List}链
**/
public java.util.List getHandlerChain(PortInfo-PortInfo);
}
和通用接口处理程序
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);
}
import javax.xml.ws.ProtocolException;
/**{@code Handler}接口
*是JAX-WS处理程序的基本接口。
*
*@param消息上下文
*@自1.6以来,JAX-WS 2.0
**/
公共接口处理程序{
/**调用{@code handleMessage}方法进行正常处理
*入站和出站消息的。请参阅处理程序的说明
*完整细节请参见JAX-WS规范中的框架。
*
*@param context消息上下文。
*@返回处理程序处理是否应继续的指示
*当前消息
*
*- 返回{@code true}继续
*处理
*- 将{@code false}返回到块
*处理
*
*@throws RuntimeException导致JAX-WS运行时停止
*处理程序处理并生成错误。
*@throws-ProtocolException导致JAX-WS运行时切换到
*故障信息处理。
**/
公共布尔handleMessage(C上下文);
/**为错误消息调用{@code handleFault}方法
*正在处理。请参阅处理程序的说明
*完整细节请参见JAX-WS规范中的框架。
*
*@param context消息上下文
*@返回处理程序故障处理是否应继续的指示
*对于当前消息
*
*- 返回{@code true}继续
*处理
*- 将{@code false}返回到块
*处理
*
*@throws RuntimeException导致JAX-WS运行时停止
*处理故障并分派故障。
*@throws-ProtocolException导致JAX-WS运行时停止
*处理故障并分派故障。
**/
公共布尔handleFault(C上下文);
/**
*在之前的消息交换模式结束时调用
*JAX-WS运行时正在调度消息、故障或异常。请参阅
*处理程序的描述
*完整细节请参见JAX-WS规范中的框架。
*
*@param context消息上下文
**/
公共作废关闭(MessageContext);
}
对于方法列出getHandlerChain(最终PortInfo-PortInfo)
我得到警告:处理程序是原始类型。对泛型类型处理程序的引用应该参数化
由于HandlerResolverImpl接口上定义的方法未将处理程序类型实现为泛型,是否可以避免此警告
我尝试了几种方法,但我一直无法正确解决此警告。“由于HandlerResolverImpl接口上定义的方法没有将处理程序类型实现为泛型,是否可以避免此警告?”-
@SuppressWarning(“rawtypes”)
。但是您应该通过参数化列表
@SuppressWarnings(“rawtypes”)来正确地解决这个问题,当然可以删除警告,但隐藏原始问题。那么,用HandlerResolver接口施加的条件参数化getHandlerChain方法的正确方法是什么呢?不要使用那个(设计糟糕的)接口。如果你不得不使用这个接口而不能重构它,那么这几乎是不可修复的。我也面临着同样的问题。如何根据上述要求解决声纳问题?