1 29 30 package com.caucho.soap.jaxws; 31 32 import com.caucho.soap.skeleton.Skeleton; 33 import com.caucho.util.L10N; 34 35 import javax.xml.ws.BindingProvider; 36 import java.lang.reflect.InvocationHandler ; 37 import java.lang.reflect.Method ; 38 import java.util.HashMap ; 39 import java.util.logging.Logger ; 40 41 44 public class PortProxyHandler implements InvocationHandler { 45 private final static Logger log 46 = Logger.getLogger(PortProxyHandler.class.getName()); 47 private final static L10N L = new L10N(PortProxyHandler.class); 48 49 private final static HashMap <Method ,SpecialMethod> _specialMethods 50 = new HashMap <Method ,SpecialMethod>(); 51 52 private Skeleton _skeleton; 53 private String _url; 54 55 private HashMap <String ,Object > _requestContext 56 = new HashMap <String ,Object >(); 57 58 private HashMap <String ,Object > _responseContext 59 = new HashMap <String ,Object >(); 60 61 public PortProxyHandler(Skeleton skeleton, String url) 62 { 63 _url = url; 64 _skeleton = skeleton; 65 } 66 67 public Object invoke(Object proxy, Method method, Object [] args) 68 throws Throwable 69 { 70 SpecialMethod specialMethod = _specialMethods.get(method); 71 72 if (specialMethod != null) { 73 switch (specialMethod) { 74 case TO_STRING: 75 return "PortProxyHandler[]"; 76 case EQUALS: 77 return false; 78 case HASH_CODE: 79 return System.identityHashCode(this); 80 81 case GET_REQUEST_CONTEXT: 82 return _requestContext; 83 84 case GET_RESPONSE_CONTEXT: 85 return _responseContext; 86 } 87 } 88 89 Object ret = _skeleton.invoke(method, _url, args); 90 91 return ret; 92 } 93 94 static { 95 try { 96 _specialMethods.put(Object .class.getMethod("toString", 97 new Class [0]), 98 SpecialMethod.TO_STRING); 99 100 _specialMethods.put(Object .class.getMethod("equals", 101 new Class [] { Object .class }), 102 SpecialMethod.EQUALS); 103 104 _specialMethods.put(Object .class.getMethod("hashCode", 105 new Class [0]), 106 SpecialMethod.HASH_CODE); 107 108 _specialMethods.put(BindingProvider.class.getMethod("getRequestContext", 109 new Class [0]), 110 SpecialMethod.GET_REQUEST_CONTEXT); 111 112 _specialMethods.put(BindingProvider.class.getMethod("getResponseContext", 113 new Class [0]), 114 SpecialMethod.GET_RESPONSE_CONTEXT); 115 } 116 catch (Exception e) { 117 e.printStackTrace(); 118 } 119 } 120 121 enum SpecialMethod { 122 TO_STRING, 123 EQUALS, 124 HASH_CODE, 125 126 GET_REQUEST_CONTEXT, 127 GET_RESPONSE_CONTEXT 128 }; 129 } 130 | Popular Tags |