1 29 30 package com.caucho.soa.client; 31 32 import com.caucho.soa.encoding.UnknownServiceEncodingException; 33 34 import javax.xml.bind.JAXBException; 35 import java.net.MalformedURLException ; 36 import java.util.HashMap ; 37 import java.util.logging.Logger ; 38 39 public class ProxyManager { 40 private static final Logger log 41 = Logger.getLogger(WebServiceClient.class.getName()); 42 43 private static final HashMap <String ,EncodingProxyFactory> _factories = 44 new HashMap <String ,EncodingProxyFactory>(); 45 46 public static void addEncodingProxyFactory(String name, 47 EncodingProxyFactory factory) 48 { 49 _factories.put(name, factory); 50 } 51 52 public static Object getWebServiceProxy(Class serviceInterface, String url) 53 throws MalformedURLException , UnknownServiceEncodingException, JAXBException 54 { 55 String [] components = url.split(":", 2); 56 57 if (components.length < 2) 58 throw new MalformedURLException (url); 59 60 String factoryName = components[0]; 61 EncodingProxyFactory factory = _factories.get(factoryName); 62 63 if (factory == null) 64 throw new UnknownServiceEncodingException(factoryName); 65 66 return factory.getProxy(serviceInterface, components[1]); 67 } 68 69 public static Object getWebServiceProxy(Class serviceInterface, String url, 70 String jaxbPackages) 71 throws MalformedURLException , UnknownServiceEncodingException, JAXBException 72 { 73 String [] components = url.split(":", 2); 74 75 if (components.length < 2) 76 throw new MalformedURLException (url); 77 78 String factoryName = components[0]; 79 EncodingProxyFactory factory = _factories.get(factoryName); 80 81 if (factory == null) 82 throw new UnknownServiceEncodingException(factoryName); 83 84 return factory.getProxy(serviceInterface, components[1], jaxbPackages); 85 } 86 87 public static Object getWebServiceProxy(Class serviceInterface, String url, 88 Class [] jaxbClasses) 89 throws MalformedURLException , UnknownServiceEncodingException, JAXBException 90 { 91 String [] components = url.split(":", 2); 92 93 if (components.length < 2) 94 throw new MalformedURLException (url); 95 96 String factoryName = components[0]; 97 EncodingProxyFactory factory = _factories.get(factoryName); 98 99 if (factory == null) 100 throw new UnknownServiceEncodingException(factoryName); 101 102 return factory.getProxy(serviceInterface, components[1], jaxbClasses); 103 } 104 105 static { 106 addEncodingProxyFactory("hessian", new HessianEncodingProxyFactory()); 107 addEncodingProxyFactory("rest", new RestEncodingProxyFactory()); 108 addEncodingProxyFactory("soap", new SoapEncodingProxyFactory()); 109 addEncodingProxyFactory("vm", new VMEncodingProxyFactory()); 110 } 111 } 112 | Popular Tags |