jaxb2: right log4j2 configuration
[SpringWebServicesForFun/.git] / HOWSPRINGWORKS.txt
1
2
3 *************************** Porque estoy usando sws:annotation-driven ***************************
4
5 Porque estoy usando sws:annotation-driven y no declarando explícitamente los beans en XML existe un
6 orden de búsqueda de por defecto de macheadores de endpoints y excepciones. Ver: org.springframework.ws.config.AnnotationDrivenBeanDefinitionParser
7 Cuanto más bajo es el valor de order mayor es la prioridad.
8
9
10         1. Manejadores de excepción, orden por defecto inicializado en AnnotationDrivenBeanDefinitionParser:
11         a) SoapFaultAnnotationExceptionResolver será el primer manejador de excepciones que se intente usar por defecto. order = 0
12         b) SimpleSoapExceptionResolver será el último manejador de excepciones que se intente usar por defecto. order = Ordered.LOWEST_PRECEDENCE
13            Se usará si la excepción generada no pudo ser manejada por SoapFaultAnnotationExceptionResolver (porque la excepción no fue anotada con
14            @SoapFault. Este manejador se traga cualquier excepción.
15         
16         2. Endpoints a buscar, orden por defecto inicializado en AnnotationDrivenBeanDefinitionParser:
17         a) PayloadRootAnnotationMethodEndpointMapping será el primer tipo de endpoints que se buscará y que se intentará usar. order = 0
18            Si el XML SOAP que llega no machea ningún metodo anotado con este EndPoint pasamos a b).
19         b) SoapActionAnnotationMethodEndpointMapping será el segundo tipo de endpoints que se intentará usar. order = 1
20            Si el XML SOAP que llega no machea ningún metodo anotado con este EndPoint pasamos a c).
21         c) AnnotationActionEndpointMapping será el último tipo de endpoints que se buscará. order = 2
22            Si el XML SOAP que llega no machea tampoco métodos anotado con este EndPoint se
23            lanza NoEndpointFoundException desde org.springframework.ws.server.MessageDispatcher.dispatch()
24
25
26         EN LUGAR DE USAR LA ANOTACIÓN PODRÍAMOS HABER DECLARADO EXPLÍCITAMENTE CADA BEAN TAL QUE ASÍ:
27         
28         <bean id="soapFaultMappingExceptionResolver"
29                 class="org.springframework.ws.soap.server.endpoint.SoapFaultMappingExceptionResolver">
30                 <property name="order" value="0" />
31         </bean>
32         
33         <bean id="payloadRootAnnotationMethodEndpointMapping"
34                 class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
35                 <property name="order" value="0" />
36         </bean>
37         
38         CON LA ANOTACIÓN ME AHORRO DECLARAR bean POR bean PERO LO MALO ES QUE INSTANCIO MANEJADORES QUE LUEGO NO USO :(
39
40
41
42
43 *************************** org.springframework.ws.server.MessageDispatcher ***************************
44
45
46 org.springframework.ws.server.MessageDispatcher ES LA CLASE QUE BUSCA EndPoints Y MANEJADORES DE EXCEPCIÓN
47
48 ORDEN DE BUSQUEDA DE IMPLEMENTACIONES DE MANEJADORES DE EXCEPCION
49 Busca en el ApplicationContext manejadores de excepción siguiendo este orden. Cuanto más bajo es el valor de order
50 mayor es la prioridad.
51
52 Por haber usado sws:annotation-driven el orden es el siguiente:
53
54
55 1. Primero se busca por excepciones anotadas con @SoapFault. Si la excepcion generada
56 está anotada son @SoapFault entonces se usa este manejador de excepcion.
57
58 Implementation of the org.springframework.ws.server.EndpointExceptionResolver interface
59 that uses the SoapFault annotation to map exceptions to SOAP Faults.
60 org.springframework.ws.soap.server.endpoint.SoapFaultAnnotationExceptionResolver
61
62
63
64 2. Segundo usa este manejador de excepción. Este manejador machea cualquier excepción así que si
65 este manejador llega primero siempre resolverá la excepción.
66 Simple, SOAP-specific EndpointExceptionResolver implementation that stores
67 the exception's message as the fault string. 
68 org.springframework.ws.soap.server.endpoint.SimpleSoapExceptionResolver
69
70
71 3. Un manejador de excepciones inyectado por mi en un archivo XML de Spring. Si no se pone prioridad por defecto
72 Spring le pone la prioridad más baja que es lo que me pasó a mí al principio y SimpleSoapExceptionResolver
73 se meterá siempre por el medio :(
74 org.springframework.ws.soap.server.endpoint.SoapFaultMappingExceptionResolver
75
76
77 Si ninguno machea MessageDispatcher lanza la Excepción desde org.springframework.ws.server.MessageDispatcher.processEndpointException()
78
79
80
81 ORDEN DE BUSQUEDA DE ENDPOINTS EN EL APPLICATION CONTEXT:
82 Busca en el ApplicationContext metodos anotados siguiendo este orden. Si el XML SOAP que me llega
83 machea con alguna de estas anotaciones, entonces ese método anotado será usado. Y NO SE CONTINUARÁ
84 BUSCANDO MÁS MANEJADORES. EN CUANTO UNO MACHEA YA NO SE BUSCA POR MÁS.
85
86
87 Por haber usado sws:annotation-driven el orden es el siguiente:
88
89
90 1. Primero se busca por métodos de este modo. Si el XML SOAP machea con algún metodo anotado
91 de este modo, entonces ese método será usado y no se continúa buscando matches.
92
93 Implementation of the org.springframework.ws.server.EndpointMapping interface that uses the
94 PayloadRoot annotation to map methods to request payload root elements. 
95 org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping
96 @Endpoint
97 public class MyEndpoint {
98
99     @PayloadRoot(localPart = "Request", namespace = "http://springframework.org/spring-ws")
100     public Source doSomethingWithRequest() {
101          ...
102     }
103 }
104
105 2. Segundo se busca por métodos de este modo. Si el XML SOAP machea con algún metodo anotado
106 de este modo, entonces ese método será usado y no se continúa buscando matches.
107
108 Implementation of the org.springframework.ws.server.EndpointMapping interface that uses the
109 SoapAction annotation to map methods to the request SOAPAction header. 
110 org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping
111 @Endpoint
112 public class MyEndpoint{
113
114     @SoapAction("http://springframework.org/spring-ws/SoapAction")
115     public Source doSomethingWithRequest() {
116          ...
117     }
118 }
119
120
121 3. Tercero se busca por métodos de este modo. Si el XML SOAP machea con algún metodo anotado
122 de este modo, entonces ese método será usado.
123
124 Implementation of the org.springframework.ws.server.EndpointMapping interface that uses the
125 @Action annotation to map methods to a WS-Addressing Action header. 
126 org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping
127 @Endpoint
128 @Address("mailto:joe@fabrikam123.example")
129 public class MyEndpoint{
130
131     @Action("http://fabrikam123.example/mail/Delete")
132     public Source doSomethingWithRequest() {
133          ...
134     }
135 }
136
137
138 Si ninguno machea MessageDispatcher lanza NoEndpointFoundException desde org.springframework.ws.server.MessageDispatcher.dispatch()