1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.axis.message.addressing.handler;
18
19 import org.apache.axis.AxisFault;
20 import org.apache.axis.handlers.BasicHandler;
21 import org.apache.axis.message.addressing.uuid.AxisUUIdGenerator;
22 import org.apache.ws.addressing.uuid.UUIdGeneratorFactory;
23
24 import javax.xml.namespace.QName;
25 import javax.xml.rpc.JAXRPCException;
26 import javax.xml.rpc.handler.Handler;
27 import javax.xml.rpc.handler.HandlerInfo;
28
29 /***
30 * Helper class to which the Axis-specific JAX-RPC handlers in this package
31 * can delegate methods defined in the Axis {@link org.apache.axis.Handler}
32 * interface. This is one so that the Axis handler base class
33 * {@link BasicHandler} can be leveraged.
34 *
35 * @author Ian P. Springer
36 */
37 class GenericAxisHandler extends BasicHandler
38 {
39
40 private Handler jaxRpcHandler;
41
42 public GenericAxisHandler( Handler handler )
43 {
44 jaxRpcHandler = handler;
45 }
46
47 /***
48 * Impl of {@link org.apache.axis.Handler#init()}
49 * that delegates to
50 * JAX-RPC {@link Handler#init(javax.xml.rpc.handler.HandlerInfo)}.
51 */
52 public void init()
53 {
54 jaxRpcHandler.init( new HandlerInfo( jaxRpcHandler.getClass(), getOptions(), new QName[0] ) );
55 }
56
57 /***
58 * Impl of {@link org.apache.axis.Handler#invoke(org.apache.axis.MessageContext)}
59 * that delegates to either
60 * JAX-RPC {@link Handler#handleRequest(javax.xml.rpc.handler.MessageContext)} or
61 * JAX-RPC {@link Handler#handleResponse(javax.xml.rpc.handler.MessageContext)},
62 * depending upon whether the handler chain pivot has been passed yet or not.
63 */
64 public void invoke( org.apache.axis.MessageContext msgContext ) throws AxisFault
65 {
66 if ( !msgContext.getPastPivot() )
67 {
68 jaxRpcHandler.handleRequest( msgContext );
69 }
70 else
71 {
72 jaxRpcHandler.handleResponse( msgContext );
73 }
74 }
75
76 /***
77 * Impl of {@link org.apache.axis.Handler#onFault(org.apache.axis.MessageContext)}
78 * that delegates to
79 * JAX-RPC {@link Handler#handleFault(javax.xml.rpc.handler.MessageContext)}.
80 */
81 public void onFault( org.apache.axis.MessageContext msgContext )
82 {
83 jaxRpcHandler.handleFault( msgContext );
84 }
85
86 /***
87 * Use the UUID generator that comes with Axis.
88 *
89 * @return a UUID
90 */
91 String generateUUId()
92 {
93 try
94 {
95 return UUIdGeneratorFactory.createUUIdGenerator( AxisUUIdGenerator.class ).generateUUId();
96 }
97 catch ( RuntimeException re )
98 {
99 throw new JAXRPCException( "Failed to generate UUId using Axis UUId generator " + AxisUUIdGenerator.class.getName() + ".", re );
100 }
101 }
102
103 }