使用@Endpoint一次或多次

时间:2014-08-15 00:34:48

标签: spring spring-ws

选项1和版本之间是否存在性能差异?选项2如下所述?

选项1

将一个端点文件用于多个请求

  • First_Second_Endpoint

     @Endpoint
      public class First_Second_Endpoint 
          {
           @PayloadRoot(localPart = "FirstRequest", namespace = "...")
           @ResponsePayload
           public FirstResponse methodName(@RequestPayload FirstRequest request) {...}
    
           @PayloadRoot(localPart = "SecondRequest", namespace = "...")
           @ResponsePayload
           public SecondResponse secondMethodName(@RequestPayload SecondRequest request)
           {...}
    
        }
    

选项2

为多个请求使用多个Endpoint文件

  • First_Endpoint.java

     @Endpoint
      public class First_Endpoint 
          {
           @PayloadRoot(localPart = "FirstRequest", namespace = "...")
           @ResponsePayload
           public FirstResponse methodName(@RequestPayload FirstRequest request) {...}
    
        }
    
  • Second_Endpoint.java

      @Endpoint
      public class Second_Endpoint 
      {
           @PayloadRoot(localPart = "SecondRequest", namespace = "...")
           @ResponsePayload
           public SecondResponse secondMethodName(@RequestPayload SecondRequest request)
           {...}
    
        }
    

1 个答案:

答案 0 :(得分:0)

不,没有区别,因为最后任何@Endpoint类刚刚在应用程序中注册为bean。但这并不重要,因为只需要进一步method scanning,并为每种方法endpointMapping注册一个AbstractMethodEndpointMapping

for (Method method : methods) {
    List<T> keys = getLookupKeysForMethod(method);
    for (T key : keys) {
        registerEndpoint(key, new MethodEndpoint(beanName, getApplicationContext(), method));
    }
}

如您所见,它没有为此基础结构使用根@Endpoint对象,只有方法对于SOAP请求的映射非常重要。

它不会影响运行时的性能,因为只有AbstractMethodEndpointMapping.endpointMap正在使用中:

protected MethodEndpoint lookupEndpoint(T key) {
    return endpointMap.get(key);
}